Linux Shell Insights: Volume 1

Hello readers,

I thought I’d share some intriguing and useful one-liners that could make your life easier on the Linux/Unix shell environment. I hope to offer a regular multi-part series for those who are fans of the Linux platform.

  1. View Physical Console via SSH
    This will view the console (and makes assumption that the console is an 80 character screen.) It’s helpful to scrape error messages that are printed to the local console. Great for when you don’t have physical access to the server and need to see the terminal; we also find it useful here by eliminating unnecessary trips to the data center floor.

    shell# sudo cat /dev/vcs1 | fold -w 80

  2. Remove multiple RPM packages by a defined pattern
    This is useful for remove all packages that are part of a common suite. This example would uninstall any package in the system with ‘php’ in the name. (Disclaimer: Check what packages contain the string prior to running this. Unpredictable results could remove system critical packages! I’d suggest this for advanced shell users only.)

    shell# yum erase `yum list installed | grep ‘php’`

  3. Reduce a file to zero bytes
    I’m sure every administrator has needed to zero out a log file taking too much space; or clear a users mail spool. Many commands involve piping /dev/null to the file or similar. The following command is probably the easiest and quickest way that many users overlook.

    shell# > file_to_wipe.txt

  4. Look at the strings stored in RAM
    This one is more for fun; though it could be used for security auditing. This command will access the system RAM and reveal text strings stored in memory. Don’t worry, this file is read-only by the kernel. You can usually find interesting data stored in memory with this command.

    shell# sudo dd if=/dev/mem | cat | strings

That’s it for now; more in this series coming soon.

Related Posts

SociBook del.icio.us Digg Facebook Google Yahoo Buzz StumbleUpon

Tags: , , , , , ,

Leave a Reply

You must be logged in to post a comment.