Useful Linux commands

Run command without output

command > /dev/null 2>&1

Run command in background without output

nohup command > /dev/null 2>&1 &

List all files recursively

find -type f -printf "%T@ %p\n" | cut -d\  -f2-

Search for specific file recursively

find -type f -name "foo.txt"

## Finds find-me.html OR find-me.html
find -type f -name "find-me.html" -or -name "find-me.php"

Search for specific directory recursively

find -type d -name "my-directory"

Search string in specific file type recursively

find -type f -name "*.php" -print0 | xargs -0 grep "my_string" -n --color=auto

Find and exclude recursively

find -type f -name "*.php" ! -name "ignore-me.php"

Find paths recursively

find -path "*dir/sub-dir"

Rsync

# High CPU (compress)
rsync -chavzP --stats . user@server:/path/to/dir

# Low CPU (raw)
rsync -havP --stats . user@server:/path/to/dir

chmod recursively in current directory

## Directories
find -type d -print0 | xargs -0 chmod 755

## Files.
find -type f -print0 | xargs -0 chmod 644

View octal permissions

stat -c "%a %n" *

Watch CPU(s) clock speed

watch -n 0.5 "cat /proc/cpuinfo | grep \"^[c]pu MHz\""
dd if=/dev/zero of=testfile1.rar bs=1 count=0 seek=100G