Your Linux Data Center Experts

I know there are lot of GUI tools out there, but I'm very much a command-line person. In general I'd like to type “ls” more than to find a file listing dialog, for example, because you can so easily do small variations like “ls -ltr” (show files sorted by time), “ls -lSr” (sorted by size), “ls -l | grep foo” (what file have “foo "in the name), etc. GUIs work very well for the casual user, but they don't work as well for frequent use. Here are some of my favorite commands and command sequences.

  • "stat” gives all sorts of information about a file or directory including type, size, permissions, device… Want to know if “/etc/services” is on your root file-system? Check the device number with: “stat -c %d /etc/services /”. Are you out of inodes in “/”? “stat -f -c %d /” will tell you.
  • “df -i” is often overlooked when checking for full file-systems. Often it's because of lack of data space, but if not that it's probably because of lack of inodes.
  • “du -x | sort -n” will show disc usage by directory, largest directories at the bottom.
  • “fuser -n tcp 80” will show the process(es) which is bound to port 80/tcp. Very handy in scripts to see if a network program is running.
  • “ssh” is useful all over the place. Secure logins to remote systems, running remote commands, scripting data transfers to other machines. A great tool.
  • “rsync” is another great multi-purpose tool. Great for copying ISO files, if you have one that's close to the one you need to copy it can make a huge difference. Last week I updated a 200MB ISO file to a new version over a 7KB/sec CDMA line in just a few minutes. Can also be used to do full and incremental system backups and even act like a file-system diff, even across machines.
  • “rpm -qf /path/to/file” tells you what package a file is part of.
  • “clear” when I'm done doing something in a window clears it so that I can keep context around when I need it and only when I'm still working on it.
  • “file” analyzes the contents of a file and tries to figure out what type of file it is. It doesn't matter what extension the file has.
  • “dd” has all sorts of options for dealing with processing data to and from files and devices. Including setting block sizes, skipping and limiting the data copied.
  • “echo $[RANDOM%1024]” from the shell will randomly generate a number below 1024, a good way to come up with a non-WKS to move SSH to so that dorks who are hitting SSH can't find it as easily.
  • “mkdir -p” will recursively make a directory and all directories above it if they don't exist.

Certainly there are a ton of different commands, but these are some that I particularly like.

comments powered by Disqus

Join our other satisfied clients. Contact us today.