Useful shell commands

deleting .svn folders (files)

Sometimes people who use subversion need to delete all .svn folders in their working copy. To use below command you must be in root directory of your working copy and all .svn folders and files will be deleted.

find . -name .svn -exec rm -rf {} \;

:!: Be careful you can not undo this

sending server resource usage by email

Here are commands I found useful:

  • mutt is great program for sending emails from command line
  • df for disks usage stats
  • top for processor usage
  • vnstat for network traffic usage
  • last user login statistic read from /var/log/wtmp file

Complete example using above commands will be:

> (top -b -n 1; df -h; vnstat -d; last) | mutt -s "Resource usage" your.email@example.com

Best is when you use this command in combination with cron:

0 5 * * *    (top -b -n 1; df -h; vnstat -d; last) | mutt -s "Resource usage" your.email@example.com

'nohup' and background process

To put process in background you should suffix '&' to the command. If you log out background process will stop.

If you want to keep process running after you logout you should use nohup command. This command will not put process to background automatically.

Example: Let say one want to download opensuse linux DVD iso file. He would also like to do something after he run this command. He also do not want to take care if download is not over and he has to go home (logout).

nohup wget -c http://download.opensuse.org/distribution/11.1/iso/openSUSE-11.1-DVD-i586.iso &

''iptables'' - denay access to one particular IP address

If you need to deny access from one particular IP address use:

iptables -I INPUT -s 218.108.247.138 -j DROP

If sometimes after you want to allow access to that IP address use:

iptables -D INPUT -s 218.108.247.138 -j DROP

To check iptables configuration use:

iptables -L
 
shell/usefull.txt · Last modified: 2010/02/07 21:09 by kodmasin
 
Copyright (c) 2000-2010 kodmasin.net
Recent changes RSS feed Donate Powered by PHP Valid XHTML 1.0 Valid CSS Driven by DokuWiki