Unix commands and tools you just can't live without

Are you someone who never met a Unix command you didn't like? OK, maybe not. But are there commands you just can't imagine living without? Let's look at some that have made a big difference on my busiest days and those that people I've worked with over the years have said are their most important essentials.

By  

The find command is wonderfully versatile in that you can search for files by so many different criteria -- ownership, size, permissions, type, modification date, inode number, group, whether it's newer than some reference file, the number of links ... and, of course, name! You can even use find to locate files that have no recognized group or owner (i.e., no groups or owners on the system that are associated with the particular GIDs and UIDs). And then you can decide what to do with your finds -- just print the information or take some action such as removing the files or changing their permissions or ownership.

du -sk [dir]

The du command is, of course, valuable when evaluating disk space. You can use the du -sk * command to see how much space each file and directory in your current file system location is using or du -sk . to see the space occupied by everything in your current directory. I've become particular fond of these commands.

df -k .

I may have come to where I am sitting in the file system by some circuitous route, following symbolic links or not. This df command both shows me what file system I'm sitting in and how much space is available in it.

$ df -k .
Filesystem           1K-blocks      Used Available Use% Mounted on
boson:/data          201582336   4991232 186351104   3% /data/boson

lsof

The lsof (list open files) command is a powerful tool for displaying open files. It doesn't matter what kind of files are open or even if they're the kind of thing that most of us don't normally think of as files -- such as pipes, character and block special files, directories and sockets. The lsof command will provide valuable information. Want to see all open files? Just use the lsof command by itself. Want to see what processes are using a specific file? Use the command lsof filename. The lsof -u username command will show you all files currently open by a particular user. Very valuable information indeed!

fuser

The fuser command is one which I only learned sometime in the last ten years or so (i.e., recent for me). It is definitely the right tool for the job when you want to know what process is using a particular file or why you can unmount a file system that the system keeps saying is "busy".

netstat

I truly appreciate the netstat command, especially netstat -rn which shows you a system's routing table and netstat -a | grep "LISTEN " which shows you listening ports on Linux (netstat -a | grep LISTEN on Solaris).

awk

Another all-time winner for me is awk. Being able to select a single column from a file or from command output provides a huge number of shortcuts. I often use awk to manipulate huge data files.

Photo Credit: 

flickr / L. Marie

Join us:
Facebook

Twitter

Pinterest

Tumblr

LinkedIn

Google+

Operating SystemsWhite Papers & Webcasts

See more White Papers | Webcasts

Join us:
Facebook

Twitter

Pinterest

Tumblr

LinkedIn

Google+

Ask a Question