Linux : frequently / commonly used commands

my frequently used linux’s command :-

1. Rename file.. replace space to dash ‘-‘
# rename ' ' '_' *

2. List file size in folder and sort
# du -sh * | sort -h

3. Log reading .. continuously
# tail -f /var/log/apache/error.log | grep --line-buffered ""

4. Tar folder in one file ( need to add “z” -zcvf  if you want to compress it, by default it will not compress the folder)
# tar -cvf namaarkib.tar folder/

5.  Append string to existing file
# echo "teks yang perlu dimasukkan" | tee -a /opt/

6. Useful command to check server type (virtual or physical) and any other hardware information (like memory slot)
# dmidecode
# dmidecode | less
# dmidecode -s system-product-name

7. Find contents of files.
# find . -type f -name "config.php" -exec grep -H "dbuser" {} \;
can manipulate -name and grep behavior . etc: -l to list file only

8. Netstat with wathch command.
# watch -n 30 "netstat -ntu | awk '{print \$5}' | cut -d: -f1 | sort | uniq -c | sort -n"
# watch -n 10 "netstat -ntp"
# netstat -c
monitoring withou filter but continuous
use "watch" for looping + filter

9. Tar GZ command to compress directory
tar -zcf usmsmart.tar.gz usmsmart

10. Listing directories only in current path
ls -d */

11. Using “Setup” in centos 6
yum install -y setuptool system-config-network* system-config-firewall* system-config-securitylevel-tui system-config-keyboard ntsysv


Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out /  Change )

Google+ photo

You are commenting using your Google+ account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )


Connecting to %s