Command Line Utilities

From Elvanör's Technical Wiki
Revision as of 11:04, 29 July 2008 by Elvanor (talk | contribs)
Jump to navigation Jump to search

This is a collection of random useful command line tools.

  • To obtain the space available on a HD: df -h

rsync

  • --no-p: this will disable permissions synchronization.
  • --no-o: this will disable owner synchronization.

tar

  • Use the -C option to switch to a directory before compressing. Very useful.
  • Use the -h option to follow symbolic links.

cpio

  • This seems to be something similar to tar.
  • Allows you to do nice stuff like
find . -name '*.txt' print0 | cpio -o -0 | ssh elvanor@otherbox 'cd dirB && cpio -iduv -0'

This would copy the *.txt files to another box, preserving the directory hierarchy.

gpasswd

  • This is the command used on Gentoo to change an user's groups. You can also edit /etc/group, but this is not the right way of doing things. It will usually fail because you also need to change /etc/gshadow. Note that /etc/group- is just a backup of /etc/group.

Tricks and tips

  • Redirecting all outputs to a file:
foo &> bar

To redirect only stderr:

foo 2> bar