A Few Useful Linux Shell Commands

A few handy commands

Linux gurus will already know these nifty command line utilities, but newbs and even mid-level users might find them useful.

Remember that if you have questions about syntax or options for any command, just do man [command].

First, commands that webmasters and network admins will like:

whois This is a great one for tracking visits to your websites. You can do "whois ipaddress" or "whois domain."

traceroute If you want to know where someone is, do a traceroute on their IP address. This is good when people are trying to gain unauthorized access to your local machine, too.

diff Excellent tool if you're trying to suss out the differences between new and old versions of scripts or text documents.

nslookup Check the nameserver information for a domain.

ping See if your server (or some other networked computer) is up and running.

ftp Quick way to ftp -- great for getting or putting multiple files.

Wget Kind of like ftp, but better for grabbing entire directories and directory systems.

netstat See what's going on with your machine's network connections. Great for smacking crackers!

Now a couple commands for everyday use...

crontab You need to use this if you want to schedule tasks.

rsync Incredibly powerful tool for local and remote backups. Make a crontab entry for your backups and never worry about losing data again. You can get really groovy with it and build your own time machine.

find Lightning-fast searches of your entire file system or network. I'm pretty sure Google makes copious use of this on their jillions of Linux servers. whereis and locate are similar. Try them all.

top See what processes are running on your system.

kill Something acting up? Don't need to have a process running? Kill it.

File manipulation tools...

ls List files. You'll need this. "ls -a" if you want to see hidden files, too.

chmod Change permissions of a file or directory.

cp Copy files and directories. Super if you want to copy a whole bunch of stuff. Use the "-r" option to copy recursively. You'll never click and drag again.

mv Move files or directories -- similar to
cp but it erases the files from the original location. I use this for large video and audio files when I don't want multiple copies laying around hogging disk space.

cmp Compare two files. See which is newer or which is bigger or whatever.

grep Powerful tool to match strings -- I use this all the time. If you're looking for every file that has the string "Chuck is wonderful," just grep everything in the directory, and you'll find every file that has that string. Very useful for coding and debugging.

cat Great for quickly checking the contents of a file without having a chance of altering it in any way. Excellent for hacking system files that you want to be very careful about altering.

User management commands...

passwd Change the password.

adduser You can figure this one out, right?

addgroup Ummm... obvious, no?

chown Change the owner of a file.

------------------------------------

This list is by no means complete. These are just a few of the command line tools that come to me off the top of my head because I use them all the time.

Remember the maxims:

"Once you go command line, you'll never be blind." (Actually, I just made that up.)

"No C, no 'see.'" (I didn't make that one up.)

Now fire up that terminal and see what you can do!

Share/Save

Post new comment

  • Allowed HTML tags: <a> <em> <strong> <cite> <code> <ul> <ol> <li> <dl> <dt> <dd> <strike> <i> <b> <blockquote>
  • Lines and paragraphs break automatically.

More information about formatting options