Slashdot Mirror


Essential UNIX Tricks and Tools?

Chris Lesner asks: "What handy UNIX tricks/tools do you use everyday? I'm asking for stuff that amazes your friends and makes you wonder how they use UNIX w/o them. Some simple examples include: job control (with fg, bg/&, jobs, Ctrl-Z); moving login sessions between machines with Screen for vt100 and VNC for X11 and using screen and VNC to share login session b/w users for demos etc.; using find, xargs -i and echo to build command strings which after inspection can be piped back though bash e.g. `find . -type f | xargs -i{} echo "cp {} {}.bak" | bash` I'm asking b/c my source for this kind of information has dried up as my UNIX skills have matured. I'm guessing other Slashdot readers have the same problem. By the way, if you think the examples I give are lame I challenge you to better them!"

1 of 185 comments (clear)

  1. Re:dusort by Phexro · · Score: 5, Interesting
    But why bother with the awk, when you can just do:

    $ du -s /path/to/wherever/* | sort -rn | head -10


    to get the top ten hogs in /path/to/wherever?

    Also, sometimes there are some big files, and you are only interested in the directories full of crap:

    $ du -s `find /path/to/wherever/* -type d` | sort -rn | head -10


    While we're on the subject, you can use this handy-dandy snippet to find the disk usage of one user in any part of the filesystem:

    $ find /path -type f -user jsmith -exec ls -l {} \; 2>/dev/null \
    > | awk '{ sum += $5} END { print sum }'