Useful Commands for the Terminal

by Johannes Filter, Feb 5, 2019

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

Execute the same command N times in parallel

parallel -j $n_parallel $command ::: {1..$n_times}

If ‘-j’ is unspecified, defaults to number of cores.