Huu Phan | Blog Linux operating system | Linux operating system -Blog Huu Phan | www.huuphan.com
huuphan.com. Powered by Blogger.

The usefull linux commands

The usefull linux commands


How to find and delete logs file MORE THAN 30 DAYS OLD






# find /path/to/log/ -type f -name \*.log\* -mtime +30 -exec rm {} \; > /dev/null 2>&1
How to find and delete logs file LESS THAN 30 DAYS OLD
# find /path/to/log/ -type f -name \*.log\* -mtime -30 -exec rm {} \; > /dev/null 2>&1

How to one-liner that allows to create a directory and move into it at the same time.
# mkdir test-dir && cd $_

How to display size of folder.
#du -csbh /path/to/folder
How to display output as a table
# cat /etc/passwd | column -t -s: 
Run last command as root
# sudo !!
Return to previous directory
# cd -
How to add passphrase into id_rsa file use ssh-keygen command
#ssh-keygen -f id_rsa -p
How to combine wget and tar in one command
# wget -qO- http://link-download | tar xvz
How to combine find and xargs command
# find /home/huupv -name *.jpg | xargs -d '\n' ls -ll
grep command regurar expression match all IP address in a log file
grep -oE "\b([0-9]{1,3}\.){3}[0-9]{1,3}\b"
how to check file duplicate
find /home/huupv/ -type f -print0 | xargs -0 md5sum | sort | uniq -D -w 32
How to determining own ip public 
curl ipinfo.io/ip
or
curl -s checkip.dyndns.org | sed -e 's/.*Current IP Address: //' -e 's/<.*$//'

post new :

Huu Phan | Blog Linux operating system | Huu Phan ~ Zimbra Mail Server,linux,bash script,centos,linux command | www.huuphan.com