Industry guru Dave Taylor answers questions about a wide variety of technical topics, including SEO, Google AdSense, Unix, Linux, MySpace, blogging, mp3 players, Mac OS X, shell scripting, Vista and Microsoft Windows.

Unix and Linux Help

How can I read a password without echoing it in C?

I'm trying to figure out how to disable the echo flag in C. I want to do this because I am coding a C program that must ask for a users password, so I would like to disable Echo, let the user enter his password, then re-enable Echo.

Unix and Linux Help

What does the $( ) notation mean in a Bash script?

On page 329 (Hour 16) of your book Teach Yourself Unix in 24 Hours is the example:

value=3 ; string="my horse Horace"
test $value < $(echo $string | wc –c)
test `wc –l filename` -ge 10000

If I try this with this code:
#!/bin/sh/
value=3;string="my horse Horace"
test $value < $(echo $string | wc -c)
test `wc -l ched4` -ge 10000

I get:-
syntax error at line 3: `(' unexpected

Are you able to quickly explain what the line test $value < $(echo $string | wc -c) is actually trying to do? I don’t quite understand the $(…) part … and is the < performing a ‘redirection for input’ or is it meant to be ‘less than’?

Unix and Linux Help

How do I change my PS1 command prompt in Bash?

I have read about 15 chapters of your book (Teach Yourself UNIX in 24 Hours) so far. We are using vi. On the PS1 command, how do I see what is in it so I can add to it and not change what is already there? We are using bash. What I see now is: ctdaywbsdv:/u/gwilki$

When I enter ‘echo $PS1’ I get: $ \[\e[0m\]

How do I keep the above and add the histcmd option? What does the \e and 0m\ mean? What do the [] the square brackets mean? I can’t find a man page for PS1. How do I find the rest of the options for this PS1?

Mac OS X Help

How do I get "vi" shell edit mode in Mac OS X Terminal?

I just finished Learning Unix for Mac OS X Tiger, and think it is an excellent little resource. I'm recently out of school, a school where we weren't taught anything about Unix, just enough to get by. I started work with the data converter team at Agilent labs, and have been able to glean quite a bit off of them (considering many of them were either directly or indirectly responsible for writing many of them commands in common use today). Thus, I'm often embarrassed to ask them questions about exactly some of the stuff you cover in the book.

Okay, now for the question: at work, they have the terminal set up such that the command line works like vi. That is, if I want to search my command history, I simply change mode via escape, type /pattern_to_be_searched, it finds the command, and then I can use other vi commands to change the command a little bit, and then execute it via the shell. How do I set this up in OS X?

Unix and Linux Help

Can I change VNC on Ubuntu to use a different port?

I have 2 Ubuntu Dapper machines at home. One is going to a college dorm with may daughter in a couple weeks. I can get her desktop on my computer through VNC here at home. It's using port 5900.

Is there a way to know whether I'll be able to reach her machine through this port when she's at college? I have no idea how they manage their network - nor do I care to ask! On a quick look, I could not find how to get her VNC server to listen to a different port - or maybe this is done through ssh?

d) None of the Above

Do most music CDs have 12 tracks?

This might sound like some wild conspiracy theory, but I'm looking at my music collection and it sure seems like most of them have exactly 12 tracks, no more, no less. Is there some marketing reason this would be the case, or am I witness to some great conspiracy? :-)

Unix and Linux Help

How do I configure my Solaris VPN network?

I have 5 offices in Texas VPN'd into our Seattle office where we have two Solaris Servers. I can ping the Solaris servers from within our Seattle office; however I cannot from the remote offices. I have checked the VPNs and I can ping any other piece of equipment from the remote sites except the Seattle servers.

When trying to ping a computer at one of the remote sites from the Solaris servers to a computer I get the following reply: " ICMP Communication Administratively Prohibited from gateway".

I'm questioning the ip configuration of our Solaris servers in Seattle. When running the command "/sbin/ifconfig -a/" , I received the following in return:

lo0: flags=1000849
mtu 8232 index 1 inet 127.0.0.1 netmask ff000000 eri0:
flags=1000843
mtu 1500 index 2 inet 10.10.10.21 netmask ff000000
broadcast 10.255.255.255 ether 0:3:ba:18:6f:5

The segment in Seattle is 10.10.10.0 with a subnet of 255.255.255.0 and a Gateway 10.10.10.1; however, this is not what I see above. One of the remote sites uses the 10.140.59.0 segment. Do I have to configure routing tables within each Solaris or just properly configure the ip settings? Can you comment?

Sony PSP, MP3 Players, Etc.

What is a WEP key?

Hi I'm having a problem with my Sony PSP and connecting it to the internet see I can get through everything but the WEP code. Is there a common WEP key? Are they all different? How would I be able to get mine? I searched everywhere but I still can't find it! HELP ME PLEASE!

Unix and Linux Help

How do I configure a DMZ on my local LAN?

A question about DMZ's: We run a privately addressed network(192.168...) on a workgroup. We have a server running DHCP. If I set up a DMZ on a managed switch I would like to know if a potentially infected (spyware/trojans) PC which is then plugged into it would be able to infect the server.

Unix and Linux Help

Why is Mailman complaining "Site list is missing: mailman"?

I've been running the Python-based "mailman" mailing list management program for quite a while with good results, but all of a sudden when I try to start it up I get the error "Site list is missing: mailman" and it won't start. What the heck? How do I fix this?

Unix and Linux Help

Why do my FTP transfers all freeze up?

I've been trying to copy some files off an FTP archive, but every time I go to do the transfer, it says "Entering Extended Passive Mode" and never gets any further. My conclusion: this passive mode thing is a bust. How can I transfer the files without using passive mode? I'm using ftp from within a Terminal on my Mac, by the way.

Unix and Linux Help

How can I check disk quotas on my Verio VPS account?

I have a couple of clients who are on the same Verio/NTT Virtual Private Server (VPS) system, and I want to have some simple script to check their disk usage. It's not a simple "du" sort of task, however, because of the peculiarities of the VPS environment. Any ideas?

Unix and Linux Help

How can my server be DNS spoofed?

Help! For some reason when I try to use "ssh" to connect to my server from my Mac, it fails and is saying that I might be a victim of a "DNS Spoof"? What's going on, and how do I fix the problem?

Business and Management

How do I deal with angry customers?

I have a big problem which frequently loops me. I am in the field of IT support, and when a customer comes to me and is short tempered, I really don't know how to convince them that their request is not my part of job and someone else should attend to it.

This happens to me at least 4 - 6 times a week. Can you please tell me how I can answer nicely about the job, and give me some suggestions about handling customers over the mail, phone and face to face in tough times?

Unix and Linux Help

How can I run an app if another app is running?

I need to run a Unix application if a different application is running, from within a shell script. How do I do this?

Unix and Linux Help

How do I find all child processes in Unix?

There is a process that must be shutdown for maintenance purpose every morning at 5:00 am. Usually it spawn several children and sometimes some of those children don't die, so the parent process won't die either. When the application starts up again it raises a new parent process but in confict with the old one that hasn't died yet. All I need is kill the childs of the old process.

How can I look for every process when I know the parent process id?

Mac OS X Help

Former admin is hacking into our Mac server, help!

Dave, we have a server security problem in Mac OSX, it is being remotely accessed by a former sys admin who has been stealing our business and the webfiles that go with them. Could you work with me to help lock down this machine?

He set the machine up, it is one of several we run. As a result, he knows the root level password. I am finding when we try to change the MySQL root password, which is the same, the websites which rely on MySQL can no longer "see" their data tables. We also must shut out this fellow's access through terminal, or change the server's root name and pass.

Help!

Unix and Linux Help

How do I mask a password from "ps"?

i need to run a process, PB, and keep it running, for avoiding problems i run it as background providing the user, and password, for connecting to oracle, this with the command:

  PB -u myuser -p my password &

but by using 'ps -ef | grep PB' anyone can see the password. There is another way to run the process, run it in foregroung:

  PB -u myuser

and it prompts for the password
'Enter password:' once typed the process is started.

I would like to run the process in background, but avoiding the password to be shown with any 'ps'?

Unix and Linux Help

How can I generate reports in Linux with an Awk script?

I'm trying to write an awk script that will take a text file phone report from a windows box and break it up into smaller text files. I know it'll only take a few minutes, but I'm not all that familiar with AWK and slogging through this O'Reilly book is really starting to tick me off. Any chance you can help?

Unix and Linux Help

My background jobs in Linux have become invisible?

Last night i started downloading all of Fedora core via rsync. It was getting late, so I put it in the background and logged out. i just logged in this morning, and wanted to see where it was at, so I typed "jobs", but surprise, it isn't there. I know it's still running, because the lights on my hub are still blinking, it shows up in "top", and i can see (du -bs fedora/) that the folder is still growing. How do i get the output back on my terminal?

Unix and Linux Help

Sony PSP Connected to Linux Systems?

I want to transfer music and movies to my Sony PSP, on my computer I'm using Suse Linux 9.2. What kind of program or software can I use? The problem is that my computer can't find the Sony PSP when I plug it in the USB port.

Mac OS X Help

How do I set the shell prompt in Mac OS X Terminal?

I'm new to Mac, last Apple I owned was a IIe in the 80's. This question is related to your book Learning Unix for Mac OS X Tiger book, page 41 "Changing the Command Prompt. In this section you give the following command for changing the prompt:

      PS1= "? "

I typed this, but got the following response from the terminal window:

      -bash: ? : command not found

What am I doing wrong?

Unix and Linux Help

How do I install DHCP on my Linux Server?

I am planning to install DHCP on my Linux Server. I do not know that much in Linux (Red Hat), however. How can I install and configure a DHCP server on my system?

Unix and Linux Help

What does "cat -" do on the Unix command line?

Hello I would like to know the what exactly does cat - mean in Unix? I was recently reading through an article that mentioned this command and couldn't understand what it did.

Unix and Linux Help

Latest edition of "Teach Yourself Unix in 24 Hours"?

I received this lovely email message from a reader this morning: "Just wanted to thank you for "Teach Yourself Unix in a Week." I read the whole thing cover to cover back in '94, when I was sleeping on a cot at work (!). It got me started in the world of Unix and has provided me employment ever since. My buddy Nick and I owe both you and Kamran Hussein a night of beers for kicking off our sys admin careers."

Unix and Linux Help

Slackware Linux screen resolution problem?

I am using Slackware 10.1 GNU/Linux? OS and quite happy with that. Though I am an advance user, I am having a problem with that!

I want to set the screen resolution to 1152 X 864 with 75Hz Monitor VF that works well with dual boot Windows 2000 Pro. Currently Slackware shows, 800 x 600, 1024 x 768 and 1280 x 1024 (60 Hz). I tried with XorgConfig file but in vain.

So, what do you think?

Unix and Linux Help

Can my PATH include directory names with spaces?

Dave, I would like to use an environmental variable to change directories and included files into vim on Mac OS Tiger. I've found that this works:
  export pm="/volumes/Macintosh HD/Documents/pmwiki"
for shell commands, but then I have to use something like: cd "$pm"

Is there a better way which doesn't require the double quotes? Also, is there some interaction with the PATH variable?

Unix and Linux Help

How can I hide passwords in a shell script?

Dave, we have to do sudo in a shell/perl scripts for certain commands. As you know sudo needs password to be supplied. sudo has -S option for stdin.

For example:

echo $pw | sudo -S command

Assume, somehow, we figure out the password and pass it in for the above echo. But, the buggest concern is, if someone does a "ps", one will be able to see the password. The above example is part of a shell script and what we need to know is how do we hide the password?

Unix and Linux Help

How do I enable root login with ssh?

Dave, I've been using ssh like a good Internet citizen to connect to my remote server, but for security reasons the ISP has disabled root login from ssh on every server. Problem is, I really need to be able to log in as root occasionally. How do I re-enable it?

Unix and Linux Help

How do I delete all occurances of a file in Linux?

How can I delete one file from every place on my disk using Linux? In Windows' I'd open up a command window and use the command

    del archive.txt /s

but what's the Linux equivalent?

Unix and Linux Help

Where can I find docs for Sony DDS hardware?

Hi Mr.Dave, I am Max from Italy and I am a technician. At the moment I am searching for tutorials or service manuals about DDS2-3 and AIT1-2-3 like the SONY SDT-7000, SDT-9000, SDT-10000 and SONY SDX-300C, SDX-400C, SDX-500C but with no results!! I strongly need these documentations, because i must repair these DAT units. Helicoidal scan technology is used in these devices and our clients use those under SCO OPEN SERVER 5.0.4. I have already requested this material from SONY, but their answer has been negative.

Unix and Linux Help

Porting C programs from Windows to Unix?

Dave, I read your books Teach Yourself Unix in 24 Hours and Wicked Cool Shell Scripts and since then I can't imagine working again on a system like windows!

My problem is that I've started to make my C files Unix-compatible but I can't find a command for C in Windows that does the same thing as system("cmd") for Unix. Any suggestions?

Unix and Linux Help

Configuring Squid as a Linux Proxy Server?

Dave, I am running an Internet Café in which I have about 10 workstations and one server. Now I am planning to configure a proxy server on LINUX for my cafe to improve performance in browsing. For this I have installed Complete REDHAT 9.0 in a machine equiped with 1.3G RAM, 80GB HDD, 1GHz MP, Intel P4, plus 2 NICs (Real Tech). But I have no idea about how to configure PROXY on it. Kindly let me know about any links or tutorial which can help me in a jumpstart. I do not want to mess with linux deeper. I just want to sonfigure PROXY and that is it.

Unix and Linux Help

How do I change the hostname in Solaris 9?

Dave, I have just purchased your book Solaris 9 for Dummies to help me learn the OS. I have been accustomed to the rubbish Windows XP Pro system and fed up with crashes and the rest of the multitude of problems that are inherent to Windows therefore I purchased a Sun Ultra 5 workstation (refurbished) and really want to get to know it and how to use it.

My problem is that the welcome screen names Alfred as the host. Please would you tell me how to change the name? bearing in mind that I am completely new to Unix systems and somewhat intimidated by the jargon.

Unix and Linux Help

How can I quickly create millions of tiny files in Linux?

Dave, I have searched the web over and can't seem to find an appropriate answer to this question. I have a need for a script that will create millions of 1-5Kbyte files in a linux filesystem for testing purposes. I have to do this on a regular basis and it would be really cool to have it scripted. I am not sure what the quickest way to do this would be?

Mac OS X Help

How do I flatten a directory structure in Unix?

Dave, how can I flatten a directory structure? I've got a directory "foo", with many more sub-directories and files within. I want to take all the files from all levels beneath foo and put them in foo itself.

I've tried this: find . *.mp3 -print0 | xargs -0 mv . but I get an error on the mv command that I can't figure out. Help!

Unix and Linux Help

Where can I find the 'rev' utility for Solaris?

Dave, I am a Sun Solaris sysadmin and really liked your book Wicked Cool Shell Scripts. However, I don't seem to find the "rev" utility on any of my Sun servers running Solaris 2.6, 7, 8, and even 9. I couldn't find it on the sunfreeware.com site either. Could you tell me where I can find it?

Unix and Linux Help

How do I selectively copy files from a directory structure?

Dave, I want to copy a directory tree BUT I want to specify the root of the operation and the destination directory and then specify name/type patterns a la find. The result I want is the root at the destination and then only the directories which have files that match the pattern and the files themselves. Does that make sense?

Unix and Linux Help

Why do the fonts in Firefox Linux look so terrible?

Dave, Why is it that, "out of the box", the Firefox browser looks great (font wise) when run on a Windows OS but looks terrible (almost too small and unreadable) on any Linux OS I have tried it on. It is probably the number one killer reason for me not switching to Linux.

Unix and Linux Help

How do I list files that don't match a pattern?

Dave, I have a straightforward Linux question that's got me stumped. I have a directory with lots of files that include an underscore, but I want to produce a listing of files that don't have the underscore, not those that do have it. I can get it with a combination of ls, grep -v and such, but it's painful and convoluted. Is there a simpler solution?

Unix and Linux Help

How do I set up Mail Filters in Ximian Evolution on Linux?

I've been migrating to Ximian Evolution on my Linux box and I love it, but I haven't been able to figure out how to set up all the mailing list rules I want to add to the program. Can you help me figure out how to set up a mailing list rule?

Unix and Linux Help

How do I search lots of files at once?

Dave, I need to conduct a number of searches through more than 2500 text files. Each search is for a different specific text string. The text files are on my Mac hard drive (Mac OS X 10.3.7) and are arranged into folders within folders within folders. I want the result in a new text file. I think I should be able to do this using some sort of grep or script but cannot figure out how to do it. Please help.

Unix and Linux Help

Can you explain exactly how umask works in Unix and Linux?

Dave, I know you can't solve trivial questions for everyone, but if you could have someone help me with the umask command and the content on pp. 107-109 of your book Teach Yourself Unix is 24 Hours, I'd appreciate it. I've taken two hours to try to figure out how in the world umask 277 produces a read-only file. It seems to me it would be write only. Can you shed some light on this, please?

Mac OS X Help

How do I keep my Safari bookmarks in sync?

Dave, I have a number of different computers running Mac OS X, and would like to keep my Safari bookmarks in sync. I don't necessarily need to to have these bookmarks accessible within other Web browsers (though it'd be a bonus if Firefox saw them too) but if I designate one as my master bookmark file, is there any way to have my other Safari browsers stay synchronized?

Shell Script Programming

Does -prune work like -maxdepth in Unix "find" on AIX?

Dave, I purchased your Wicked Cool Shell Scripts book a month or so ago (great book), and have used it to "learn by example" in writing some shell scripts, as I've a long way to go in this area.

I need to rotate logs on an IBM AIX 5.1 Unix box, and tried using your script #55, rotatelogs for this but it didn't work, as -maxdepth is not supported in AIX's find command. So, I commented it out, and it worked, but also rotated everything in the subdirectories as well (no problem...backed up directory first, then restored). I am trying to get it to work using -prune which my search in Google found to be a good fix for the lack of –maxdepth, but it's not doing what I want. Help!

Unix and Linux Help

What's acceptable syntax in Unix and Linux sh scripts?

Dave, I ran across your sites and Wicked Cool Shell Scripts book while trying to convince myself that `sleep 0` is a valid and relatively portable command to use freely in my unix shell scripts.

I looked at a few of the Bourne shell scripts and they seem to use constructs like $( ... ) and $(( ... )) which are not standard Bourne shell (to my understanding). So I actually have three questions, rather than just one:

  1. In what flavor of /bin/sh are those scripts written?
  2. Can you suggest any references regarding writing portable (Bourne) shell scripts?
  3. I would love to find an equivalent reference for what unix utilities *and options* to use for increasing script portability. Any suggestions?

Unix and Linux Help

How can I filter robot crawler hits out of my Apache access_log file?

On a mailing list I'm on, a member recently asked: "Due to an abusive web crawler, I now have a 230MB Apache access_log file on my Web server. I tried to trim it down using grep, but I don't have enough disk space for the command to succeed. Help!"

Unix and Linux Help

How do I add custom SpamAssassin rules for content filtering?

Dave, using SpamAssassin, how do I proceed with content filtering? I want to block 15 words that can appear in the email being sent to me. I already have SpamAssassin set up on my Linux system, I just need to figure out how to configure the rules file properly!

Unix and Linux Help

How do I skip certain directories in "du" output?

On a mailing list I'm on, someone asked an interesting question about the du command: "I want to figure out how much disk space I'm using in different directories, but I don't know how to exclude certain directories from the output. Anyone have a suggestion?"

Unix and Linux Help

Does Lynx request images when viewing a Web site?

A reader writes to me: "I work with HumaniNet, an organization that assists humanitarian field teams with their communications needs, mostly over satellite. Bandwidth is typically very expensive, in the dollars per minute range. Am I correct to assume that Lynx doesn't even request images or other forms of 'rich content' like Flash, and would therefore save dramatically on bandwidth costs? In other words, Lynx doesn't download anything beyond (x)html, right?"

Unix and Linux Help

What capabilities does the Lynx text-only Web browser offer?

A reader writes in to me, asking whether I think that the Lynx web browser, a command-line screen-oriented alternative to the big, splashy graphical web browsers like Firefox, Mozilla, Safari and Internet Explorer, has any relevance in the modern world of technology and broadband. It's a fair question, and in fact I just published an article in SysAdmin Magazine on this subject.

Unix and Linux Help

Can yaboot support three OS choices for Linuxes and Mac OS X?

If you've been reading my entries, you already know that I've been working on installing different Linuxes on my Mac OS X PowerBook system, with success. All works well until you actually have more than one Linux installed on the system, creating a tri-boot, rather than dual-boot Apple computer. The problem is that, by default, each Linux installs its own version of yaboot which only knows about Mac OS X or itself. So I needed to figure out how to significantly modify the yaboot configuration file to support both Ubuntu and Yellow Dog Linux simultaneously.

Unix and Linux Help

Tweak yaboot so Mac OS X is my default OS, not Ubuntu or Yellow Dog Linux?

I've been working on installing some different Linux operating systems on my G4-based Apple PowerBook as alternative operating systems to the (elegant) Mac OS X. Why? Because they're there. :-)

Once installed, Ubuntu Linux and Yellow Dog Linux both add something called yaboot which then controls the boot-up sequence. This boot control application that lets you pick which operating system you want to have run gives you about 15 seconds to pick between Linux and Mac OS X then defaults to launching Ubuntu. Not what I wanted at all.

Unix and Linux Help

What capabilities does the "cat" command have?

A reader writes:
I had taken an intro course to UNIX a few years ago, but have found your book Teach Yourself Unix in 24 Hours MUCH more comprehensive and user-aware!

I have hit a stumbling block in Chapter 16 (page 337) where you illustrate the use of cat, however. You show:

$ cat average.awk
NF > 2 { count += 1
        totalsize += $5
}
There is more that follows on this page and page 338. This seems to illustrate that the cat command allows you to input text into the named file. Perhaps that is not what you meant. Did I miss something?

Unix and Linux Help

Answers to the questions in Teach Yourself Unix in 24 Hours?

A reader writes:
I've just bought your Teach Yourself Unix in 24 hours, and I have to tell you that I love the book. I always answer the questions at the end of each chapter without knowing whether I get it right or wrong. Do you provide solutions to those answer questions?

Unix and Linux Help

How do I get SSH & X Windows working?

A reader sent in an appeal for some Linux help this morning:
I have your book Teach Yourself Unix System Administration in 24 Hours, but still have some questions:
  • I have root access to a remote server which is limited to SSH. Can I make an X-server connection and how do I do that while I have an X-server already running?
  • From that remote server I need to take files located in a particular account and copy them to a new local server I've installed.
  • How do I set up an SSL enabled login account for someone accessing the new local server?

Unix and Linux Help

How do Unix / Linux "hard links" work?

A reader writes:
So, I'm partway through your book, and I want to check on hard links. When you say it creates another door to the same body of data, is that literally true? For example, if all I have in my ./Documents directory is 001.doc (size 512K), and I hard link as hardlink.doc then run ls, do I see A or B?

A) 001.doc 512K
hardlink.doc 512K
total 1024K

B) 001.doc 512K
hardlink.doc 512K
total 512K

If it's not B, I'm not sure what the point is, other than maybe not changing the timestamp.

Unix and Linux Help