Linux : frequently used command

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 "mydomain.com"

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/runbind.sh

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

Advertisements

Leave a Reply

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

WordPress.com Logo

You are commenting using your WordPress.com 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 )

Google+ photo

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

Connecting to %s