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 "%[email protected] %p\n" | cut -d\  -f2-

Search for specific file recursively

find -type f -name "foo.txt"

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

Rsync

# High CPU
rsync -chavzP --stats . [email protected]:/path/to/dir

# Less CPU
rsync -havP --stats . [email protected]:/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" *