This shows you the differences between the selected revision and the current version of the page.
technology:unix:useful_commands 08.02.2010 01:36 | technology:unix:useful_commands 03.18.2013 05:53 current | ||
---|---|---|---|
Line 1: | Line 1: | ||
====== Useful commands ====== | ====== Useful commands ====== | ||
<code shell> | <code shell> | ||
- | top ; shows running processes; 'c' = see process details; 'q' = quit; '1' = show processor cores; 'k' = kill a process | + | = Performance = |
+ | top ; shows running processes; | ||
+ | '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 | ||
+ | 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 = | ||
screen ; lets you share screens with other people | screen ; lets you share screens with other people | ||
nano ; text editor that lets you use modern keyboard keys | nano ; text editor that lets you use modern keyboard keys | ||
Line 13: | 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 51: | 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 | ||
- | File System Manipulation | + | = File System Manipulation = |
fuser -m /dev/md0 ; shows processes being used by device | fuser -m /dev/md0 ; shows processes being used by device | ||
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) | ||
- | Network Information | + | = Network Information = |
nslookup 10.175.211.10 ; reverse DNS lookup; gives the hostname associated with the IP | nslookup 10.175.211.10 ; reverse DNS lookup; gives the hostname associated with the IP | ||
host -a www.google.com ; DNS lookup; gives IP associated with the hostname (verbose) | host -a www.google.com ; DNS lookup; gives IP associated with the hostname (verbose) | ||
Line 69: | 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 |