User Tools

Site Tools


shell:usefull

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 but do not shutdown the computer).

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

MySQL

dump just data

dump just data (-c option is here so that I can insert this data to tables which have new columns)

mysqldump -u user -p -c --no-create-info database > filename

make child directory have same ownership and permissions

:!: without ACL

  • set parent dir ownership you would like child to have
  • set setuid bit with chmod
  • every user have to set umask (just once) with wanted permissions

Example

We wnat to that all child dirs have group office and that office group have write permissions.

chown :office
chmod g+s .

Each user before creating subdir have to set umask (just once) with mask for wanted permissions. For example:

umask 0002

GoAccess - apache log analyzer

Nice small log terminal analyzer. GoAccess

shell/usefull.txt · Last modified: d.m.Y H:i by kodmasin