Linux snippets

Just a small, unsorted collection of Linux commandline snippets. Just for myself mostly.

Show free space

df -h

Show used space

du -sh /

list files and dirs sorted by size

du -cks * |sort -g

list dirs sorted by size

du -cks `find . -maxdepth 2 -type d `|sort -g

find a dir

find -name "images" | less

find file

find -name "" | less

find text in file by dir

grep -r ohohoh /var/some/path/dir/

give me last 20 lines of file filename

tail -n 20 filename

File monitoring with tail (e.g. apache logs)

tail -f -n 40 /var/log/messages

give me first 20 lines of file filename

head -n 20 filename

change owner of file (and subdirs)

chown -R spielprinzip:apache /var/www/virtual/path/dir

change file permissions to dir

chmod -R g+w /var/www/virtual/path/dir

view process status

ps ax | grep java

will result in a list with all processes, where java is matching