Find the process ID of a running program
Answer:
The easiest way to get all the process IDs of a running program in Linux, see the following example:
# pidof apache2
29747 29745 29700 29698 29696 29695 29687 29678 29677 29664 23931
Linux Ask! is a Q & A web site specific for Linux related questions. Questions are collected, answered and audited by experienced Linux users.
Find the process ID of a running program
Answer:
The easiest way to get all the process IDs of a running program in Linux, see the following example:
# pidof apache2
29747 29745 29700 29698 29696 29695 29687 29678 29677 29664 23931
Create a short URL from command
Answer:
TinyUrl has a simple api for creating short URL for any web site.
E.g. Assume http://example.com
# curl 'http://tinyurl.com/api-create.php?url=http://example.com/'
http://tinyurl.com/kotu
What are the difference between tail -f and tail -F?
Answer:
Basically these two command are very similar, except tail -F do one more thing: the retry.
This is useful when you are tailing a web server log, e.g. apache log. When the the log file got rotated, the tail -F will continue to work since it will retry for the rotated file, while tail -f can't.
Display the top 10 processes used up the most of the memory
Answer:
The following command display the most top 10 processes used up the most of the memory in your Linux system.
Example:
# ps aux | sort -nk +4 | tail
www-data 27972 0.0 2.8 253896 14916 ? S 13:10 0:00 /usr/sbin/apache2 -k start
www-data 27725 0.0 2.9 254028 15572 ? S 12:52 0:00 /usr/sbin/apache2 -k start
www-data 27912 0.0 2.9 253896 15660 ? S 13:06 0:00 /usr/sbin/apache2 -k start
www-data 27946 0.0 2.9 253764 15492 ? S 13:08 0:00 /usr/sbin/apache2 -k start
root 2710 0.0 3.1 252996 16444 ? Ss Dec08 1:20 /usr/sbin/apache2 -k start
www-data 27885 0.0 3.4 253508 18152 ? S 13:05 0:00 /usr/sbin/apache2 -k start
www-data 27892 0.1 6.7 261748 35472 ? S 13:06 0:00 /usr/sbin/apache2 -k start
www-data 27975 0.3 7.0 263036 37128 ? S 13:10 0:00 /usr/sbin/apache2 -k start
www-data 27964 0.7 8.2 268532 43452 ? S 13:09 0:00 /usr/sbin/apache2 -k start
mysql 2480 0.4 8.7 223920 46096 ? Sl Dec08 21:07 /usr/sbin/mysqld
Since the apache2 was configured to run in the prefork mode, so you see multiple apache processes there.
List the size of sub directories in the current directory
Answer:
To check the disk usage of all sub directories in the current directory, you can try the following method:
# sudo du -h --max-depth=1
4.0K ./src
341M ./lib
68M ./bin
24K ./games
195M ./share
36M ./local
18M ./sbin
18M ./include
673M .