Linux Workshop (2:30) ___ X Windows Tricks (3:00) ___ Love Your Shell (3:30) ___ Make It Safe (3:45) ___ Keep It New (4:00) ___ Crash Recovery (4:15)

2.3   Some Useful Commands

Removable Media
How to eject a mounted CDROM? (alternative solution)

$ eject /mnt/cdrom

Printing
How to print a text file through a default postscript printer?

$ a2ps file

How to print a file with 2 shrinked pages per sheet?

$ mpage -2 file

4 shrinked pages per sheet?

$ mpage file

Repetitive Tasks
How to remove all symbolic links in a directory? (alternative solution)

$ for i in *; do [ -L $i ] && rm $i; done

How to create 10 empty files (each with a numbered name) in a directory?

$ for i in $(seq 1 10); do touch $i.txt; done

Finder and Executor
How to find all *.txt files under directory /tmp?

$ find /tmp -name '*.txt'

How to gnu-zip all *.txt files under home directory (sub-directory excluded)?

$ find $HOME -name '*.txt' -maxdepth 1 | xargs gzip

Perl
Simple Calculator

$ perl -l -e 'print 1024 * 1024'

String Replacement for Multiple Files

$ perl -p -i -e 's/XFree86/x.org/g' file1.txt ...

Cron Job Scheduler(common users need authorization from super-users to use)
Edit cron jobs (example)

$ crontab -e

View current cron jobs

$ crontab -l

Previous | Next