Just another WordPress weblog
Useful Linux Commands
Here is a list of Linux commands that I frequently use, it’s easier to keep them in one place.
- Fix files and folders permission
1
2find . -type d -print0 | xargs -0 chmod 0775 # For directories
find . -type f -print0 | xargs -0 chmod 0664 # For files - Alternative to
rmwhen there are too many files to be deleted1find . -name "*"| xargs rm -rf - Alternative to
mvwhen there are too many files to be moved1find . -name "your_wildcard" -exec mv {} /path/to/destination/dir \; - Remove all .svn folders to prevent vulnerability
1find ./ -name ".svn" | xargs rm -Rf
- Transferring files from the current server to a remote server
1rsync -avhe 'ssh -p {SSH Port}' {Source} {user}@{Destination Host}:{Destination} --exclude-from '{exclude}'
- Check server memory resources every second
1watch -n 1 -d free -m
- Check server CPU usage every second
1watch -n 1 mpstat -P ALL
- Check server process usage
1ps -eo pid,%cpu,vsz,args,wchan
- Total network stats
1netstat -a -n|grep -E "^(tcp)"| cut -c 68-|sort|uniq -c|sort -n
- List of processes of a user displayed in a hierarchical manner
1ps f -u [username]
- Watch over MySQL process (130 is terminal width)
1watch 'mysqladmin proc | grep -v Sleep | cut -b0-130'
- Viewing mysql Import Process
1bar -if=data.sql | mysql
These commands have been found around the internet, but I have forgotten their origins. Most were found within forums and I appreciate the original posters!