Useful Commands for the Terminal

Snippets of commands I use occasionally and tend to forget. Gets updated.

Count files in a directory

ls -1 . | wc -l

Count files in a directory recursively (all files in all sub-directories)

find . -type f | wc -l

Get information about a process

ps -u -p 12959

Get storage usage for directories

du -sh /home/*

Compress to .bz2

tar cjf file.tar.bz2 dir

Extracting .bz2

tar xvjf file.tar.bz2 

## Extracting .gz

tar xvzf file.tar.gz