Useful linux commands
disk space : df -h
disk space by folder : du -sk * | sort -n
file/dir sizes : du -hs
Remove directory : rm -rf
Count files in folder : ls | wc -l
Count lines in text file : wc -l emails.txt
Emails in file : grep -Eiorh '([[:alnum:]_.-]+@[[:alnum:]_.-]+?\.[[:alpha:].]{2,6})' “$@” * | sort | uniq > emails.txt
Find files with text : find . -type f -exec grep -H "text-to-find-here" {} \;
List machine users : cut -d: -f1 /etc/passwd
Version Ubuntu : lsb_release -a
php version : php --version
mySQL version : mysql --version
Update(Mise à jour) Ubuntu : apt-get update && apt-get upgrade -y
To replace a string in multiple files you can use:
grep -rl matchstring somedir/ | xargs sed -i 's/string1/string2/g'
E.g.
grep -rl 'windows' ./ | xargs sed -i 's/windows/linux/g'