Wednesday, August 26, 2015

Linux Cheat Sheet

Linux Cheat Sheet

To find specific string e.g. "127.0.0.2" inside files in current directory print those filenames.
 
find . -type f -exec grep 127.0.0.2 {} \; -print
 
To find and print files modified last 10 minutes in current directory
 
find . -type f -mmin -10
 
To find all files in current directory modified 30 days ago and remove them
find . -type f -mtime +30 -exec rm {} \;
 
To print inodes usage
df -ki
 
To count files inside current directory
ls | wc -l
To check Linux version
uname -a
cat /proc/version
To check CentOS/Redhat release
cat /etc/redhat-release
cat /etc/centos-release
To find specific keyword within a bz2 file: e.g
bzcat /var/log/abc.log.8.bz2 |grep XYZ | grep 10.48.95
bzcat /var/log/abc.log.8.bz2 |grep XYZ | grep 10.48.95 | sed -e 's/  / /g' | cut -d " " -f 1-3,6-20

No comments:

Post a Comment