Differences

This shows you the differences between the selected revision and the current version of the page.

technology:unix:useful_commands 12.22.2009 23:28 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 9: Line 24:
ps axo pid,tty,stat,bsdstart,bsdtime,command    ; list processes with time started and cpu time taken ps axo pid,tty,stat,bsdstart,bsdtime,command    ; list processes with time started and cpu time taken
ps -aux                                        ; easier process list, alsp try without the '-' ps -aux                                        ; easier process list, alsp try without the '-'
-ps -ef                                          ; short columned process list (less fields returned per process+ps -ef                                          ; short columned process list (less fields returned) 
-smbd &                                          ; postfix any command with '&' to have it run in the background+smbd &                                          ; postfix with '&' to have it run in the background
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
-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; same as above, MUCH easier +
-find . -type f -user zenoss -name "*.py" -exec grep -il "blah" {} \; +
-                                                ; find text "blah" in files belonging to zenoss user, extension .py+
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
du -h --max-depth=1 . | sort -rn                ; show totalled directory sizes for current dir du -h --max-depth=1 . | sort -rn                ; show totalled directory sizes for current dir
Line 23: Line 34:
chkconfig                                      ; services on / off chkconfig                                      ; services on / off
crontab -l                                      ; list the existing cron instances crontab -l                                      ; list the existing cron instances
 +crontab -e                                      ; add crontab entries for current user
dmesg | more                                    ; print out bootup messages / kernel ring buffer dmesg | more                                    ; print out bootup messages / kernel ring buffer
whoami                                          ; tells you who you are currently logged in as whoami                                          ; tells you who you are currently logged in as
Line 41: Line 53:
service smtpd status/stop/start                ; Email service stop/start; /var/log/maillog for some debug info service smtpd status/stop/start                ; Email service stop/start; /var/log/maillog for some debug info
for i in *.txt; do mv "$i" `basename $i .txt`.doc; done    ; Rename all txt files to doc for i in *.txt; do mv "$i" `basename $i .txt`.doc; done    ; Rename all txt files to doc
 +/usr/bin/ssh -i ~/.ssh/id_dsa server_name "ls"  ; run command on another server and get results; id_dsa is ref to PKI login info... no passwd needed
 +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
-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)
dig ns zenoss.loc                              ; gives nameserver of domain dig ns zenoss.loc                              ; gives nameserver of domain
netstat -anp | grep 8082                        ; will tell you what process is listening at 8082, if any netstat -anp | grep 8082                        ; will tell you what process is listening at 8082, if any
 +netstat -an | grep LIST                        ; show listening ports (LIST = LISTEN)
tcpdump ip proto ICMP                          ; shows you what ping requests are being send and received, realtime tcpdump ip proto ICMP                          ; shows you what ping requests are being send and received, realtime
 +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
 +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
yum install gnote                              ; install gnote and all its dependancies yum install gnote                              ; install gnote and all its dependancies
 +patch < /patch/to/apply.diff
 +patch -R --dry-run --verbose < patch.diff      ; undo / backout a patch
 +yast                                            ; opensolaris / SLES package manager
</code> </code>
 
technology/unix/useful_commands.1261542521.txt.gz · Last modified: 01.11.2010 13:39 by nyeates1
 
Recent changes RSS feed Creative Commons License Donate Powered by PHP Valid XHTML 1.0 Valid CSS Driven by DokuWiki