Moving around with Bash short-cut
Answer:
Bash has some shortcuts that allow you to move around the command prompt
1. Ctrl + a
Just to the start of the current line.
2. Ctrl + e
Just to the endof the current line.
Linux Ask! is a Q & A web site specific for Linux related questions. Questions are collected, answered and audited by experienced Linux users.
Moving around with Bash short-cut
Answer:
Bash has some shortcuts that allow you to move around the command prompt
1. Ctrl + a
Just to the start of the current line.
2. Ctrl + e
Just to the endof the current line.
Kill all processes listening on a particular port
Answer:
To kill all processes listening on a particular port, e.g. port 80
# kill -9 $( lsof -i:80 -t )
Replace 80 by the port you want.
How to check the startup time of a particular program
Answer:
E.g. To check the startup time of MySQL server:
# ps -eo pid,user,cmd,lstart | grep /sbin/mysqld
3546 mysql /usr/sbin/mysqld --basedir= Tue Mar 30 21:29:12 2010
9195 root grep /sbin/mysqld Tue Mar 30 22:43:33 2010
Repeat previous command in Bash
Answer:
It is easy to type !! when you want to repeat the previous executed command in Bash
# ls -l /var/log/messages
-rw-r----- 1 syslog adm 330 Mar 29 17:17 /var/log/messages
# !!
ls -l /var/log/messages
-rw-r----- 1 syslog adm 330 Mar 29 17:17 /var/log/messages
Packet sniffing with tcpdump
Answer:
To perform packet sniffing, it is easy with tcpdump
# tcpdump -i eth0 -w dump.cap -s 0
After you terminated the tcpdump, you can use tool such as Wireshark to analyse the dump.cap.