- Remove .svn directories from current and sub directories under it:
This command is useful when a SVN deliverable is to be given to a client.
find . -name “*.svn” | xargs rm -rf
- List file system content in human readable form:
When you want to find out exact status of your disk quickly, you can use this command.
Filesystem Size Used Avail Use% Mounted on /dev/sda1 125G 109G 9.7G 92% / none 741M 260K 741M 1% /dev none 750M 12M 738M 2% /dev/shm none 750M 128K 749M 1% /var/run none 750M 0 750M 0% /var/lock none 750M 0 750M 0% /lib/init/rw
- List the details of all the processes running which have ‘keyword’ in its command
When you want to find out more details of the process/es which are executing a particular command.
ps aux | grep “keyword”
ps aux | grep terminal
user 11005 5.9 42.2 3055624 647596 ? Rl Feb03 178:48 /usr/bin/xfce4-terminal
- Kill a process with a hydrogen bomb:
When a process is taking too long to proceed further or load and you want to restart it but before that you want to kill this existing one!
kill -9 process_id
Note: Be careful about the process_id you are supplying, else you may end up crashing your system!
- Insert/Remove (load/unload) a LKM (Loadable Kernel Module) :
LKMs are normally developed to test a new file system or interface. Below commands come very handy while debugging or to try out quickly some changes to the module. Ensure you have removed the previously installed module before trying the new version.
sudo insmod my_kernel_module.ko
sudo rmmod my_kernel_module.ko
modprobe is another intelligent option to do the same!
- Copying files intelligently:
I used this option during Android/Angstrom kernel/driver development on BeagleBoard where I wanted to copy the updated Device images and other files to a SD card. -l option copies symlinks as symlinks.
rsync -l source destination
- Watch output of a command on a periodic basis:
Following command-set executes ‘ls -l *.mp4’ command every five seconds and shows its output.
watch -n 5 ls -l *.mp4
If you want to watch syslog content (last 5 lines) after every one minute, you can use following command-set.
watch -n 60 tail -5 /var/log/syslog
- Find number of times a word/pharase appears in a file:
During my previous project I needed this command-set to get an idea of refactoring effort.
cat my_file | grep -o ‘phrase’ | wc -l
If you need to count number of times ‘device’ appears in syslog.
cat /var/log/syslog | grep -o ‘device’ | wc -l
For more Linux command reference please visit: die.net