This shows you the differences between the selected revision and the current version of the page.
technology:unix:useful_commands 08.03.2010 09:22 | technology:unix:useful_commands 03.18.2013 05:53 current | ||
---|---|---|---|
Line 1: | Line 1: | ||
====== Useful commands ====== | ====== Useful commands ====== | ||
<code shell> | <code shell> | ||
- | = Top = | + | = Performance = |
- | ; shows running processes; | + | top ; shows running processes; |
'c' = see process details; '1' = show processor cores; 'k' = kill a process | 'c' = see process details; '1' = show processor cores; 'k' = kill a process | ||
'A' = show many windows; 'a,w' = navigate windows; 'z' = color; 'x' = highlight sort col | 'A' = show many windows; 'a,w' = navigate windows; 'z' = color; 'x' = highlight sort col | ||
+ | shift-w = save it too your .toprc | ||
+ | = Finding Stuff = | ||
+ | find / -name "file_name" -print ; find file name from root directory path (/) | ||
+ | find . -user root ; find files owned by root user, in current directory (.) | ||
+ | locate -i fstab ; find file name in database that keeps track of filenames | ||
+ | find . -type f -user zenoss -name "*.py" -exec grep -il "blah" {} \; | ||
+ | ; find text "blah" in .py files belonging to zenoss user | ||
+ | locate Data.fs | xargs ls -l ; xargs to pipe results of one command to another | ||
+ | find ./ -name '*py' | xargs grep signal ; Find string "signal" inside text of .py files; xargs looks inside the files instead of at the file name | ||
+ | grep -ir "timeout" . ; find the string "timeout" in any file below the current dir | ||
= Various = | = Various = | ||
Line 18: | Line 28: | ||
wget <http url> ; download a file from the web | wget <http url> ; download a file from the web | ||
sar ; system activity reporter | sar ; system activity reporter | ||
- | |||
- | = Finding Stuff = | ||
- | find / -name "file_name" -print ; find file name from root directory path (/) | ||
- | find . -user root ; find files owned by root user, in current directory (.) | ||
- | locate -i fstab ; find file name in database that keeps track of filenames | ||
- | find . -type f -user zenoss -name "*.py" -exec grep -il "blah" {} \; | ||
- | ; find text "blah" in .py files belonging to zenoss user | ||
- | locate Data.fs | xargs ls -l ; xargs to pipe results of one command to another | ||
- | find ./ -name '*py' | xargs grep signal ; Find string "signal" inside text of .py files; xargs looks inside the files instead of at the file name | ||
- | |||
du -k ~ | more ; show disk usage (useful for over quota) for home directory | du -k ~ | more ; show disk usage (useful for over quota) for home directory | ||
Line 56: | Line 56: | ||
ps -A -o pid,state,command | grep D ; find process that's blocking due to IO wait | ps -A -o pid,state,command | grep D ; find process that's blocking due to IO wait | ||
; 'D' is for Delayed processes, IO wait is most common cause | ; 'D' is for Delayed processes, IO wait is most common cause | ||
- | grep -ir "timeout" . ; find the string "timeout" in any file below the current dir | ||
Line 63: | Line 62: | ||
lsof /media/documents/ ; show list of files open | lsof /media/documents/ ; show list of files open | ||
lsof / | grep media ; in case above doesnt work, lsof seems to work better on root and then grep it out for what you need | lsof / | grep media ; in case above doesnt work, lsof seems to work better on root and then grep it out for what you need | ||
+ | lsof +D /var/log/ ; list of files open under the given directory (recursive) (use +d for non-recurse) | ||
Line 74: | Line 74: | ||
tcpdump port 80 or port 443 ; shows traffic in and out on http and https | tcpdump port 80 or port 443 ; shows traffic in and out on http and https | ||
echo “newhostname” > /proc/sys/kernel/hostname ; set new hostname on CentOS / RedHat | echo “newhostname” > /proc/sys/kernel/hostname ; set new hostname on CentOS / RedHat | ||
+ | netstat -rn ; routing table | ||
= Package Management = | = Package Management = | ||
rpm -qa ; Packages installed on system | rpm -qa ; Packages installed on system | ||
+ | rpm -qa | grep httpd* ; See if httpd is installed | ||
+ | yum list installed httpd ; See if httpd is installed | ||
yum provides /etc/fstab ; name of the package which contains a particular file | yum provides /etc/fstab ; name of the package which contains a particular file | ||
yum list ; lists information about available packages | yum list ; lists information about available packages |