免费注册 查看新帖 |

Chinaunix

  平台 论坛 博客 文库
最近访问板块 发新帖
查看: 2990 | 回复: 0
打印 上一主题 下一主题

Shell Commands [复制链接]

论坛徽章:
0
跳转到指定楼层
1 [收藏(0)] [报告]
发表于 2009-07-07 12:24 |只看该作者 |倒序浏览

Additional Resources
1.
All Solaris Commands
*
2005-08-09 -->
2.
[/url]
[url=http://www.onlamp.com/linux/cmd/]Alphabetical Directory of Linux Commands

*
2008-05-29 -->
3.
Awk, Nawk and GNU Awk Cheat Sheet
*
2009-01-20 -->
4.
[/url]
[url=http://www.allcommands.com/samples/ICR.pdf]Comparision of Shell commands (PDF)

*
2005-11-19 -->
5.
[/url]
[url=http://www.coolcommands.com/]coolcommands.com

*
2005-10-13 -->
6.
[/url]
[url=http://www.mcsr.olemiss.edu/unixhelp/DOStoUNIX.html]DOS to UNIX command translation

*
2006-02-09 -->
7.
[/url]
[url=http://www.catonmat.net/blog/awk-one-liners-explained-part-one/]Famous Awk One-Liners Explained, Part I

*
2009-01-16 -->
8.
[/url]
[url=http://www.catonmat.net/blog/awk-one-liners-explained-part-two/]Famous Awk One-Liners Explained, Part II

*
2009-01-16 -->
9.
[/url]
[url=http://docs.sun.com/app/docs/doc/816-5166/6mbb1kpt0?a=expand]Man Pages: System Administration Commands (Solaris 10)


2006-02-14 -->
10.
[/url]
[url=http://docs.sun.com/app/docs/doc/816-0211/6m6nc66m6?a=expand]Man Pages: System Administration Commands (Solaris 9)


2006-02-14 -->
11.
[/url]
[url=http://docs.sun.com/app/docs/doc/816-5165/6mbb0m9b1?a=expand]Man Pages: User Commands (Solaris 10)


2006-02-14 -->
12.
[/url]
[url=http://docs.sun.com/app/docs/doc/816-0210/6m6nb7m46?a=expand]Man Pages: User Commands (Solaris 9)


2006-02-14 -->
13.
[/url]
[url=http://sunsite.uakom.sk/sunworldonline/swol-09-1999/swol-09-unix101.html]Tips on good shell programming practices

*
2006-03-10 -->
14.
[/url]
[url=http://www.cyberciti.biz/tips/linux-unix-commands-cheat-sheets.html]Top 10 Best Cheat Sheets and Tutorials for Linux / UNIX Commands

*
2008-12-02 -->
15.
[/url]
[url=http://www.ucgbook.com/index.php3?page=http%3A//www.ucgbook.com/unix.html]Universal Command Guide for Operating Systems

*
2005-01-19 -->
16.
[/url]
[url=http://find.unixpin.com/]Unix 'find command' helper

*
2008-12-02 -->
17.
[/url]
[url=http://www.softpanorama.org/Tools/Find/find_mini_tutorial.shtml]Unix Find Command Tutorial

*
2009-06-10 - New/Updated -->
18.
[/url]
[url=http://hell.jedicoder.net/?cat=4]Useful Solaris Commands (Blog)

*
Debugging
19.   cat -v -t -e [file]
/* Show non-printing characters */   
20.   dumpadm -d swap
/* Configure swap device as dump device */   
21.   ld -l  
/* Check if you have a particular library */   
22.   truss -f -p  
/* Using multiple windows, this can be used to trace setuid/setgid programs */   
23.   truss executable
/* Trace doing of given command ( useful debugging ) */   
Back to top

Disk Commands
24.   /bin/mount -F hsfs -o ro /dev/sr0 /cdrom
/* Mount an ISO 9660 CDROM */   
25.   /usr/bin/iostat -E
/* Command to display drives statistics */   
26.   du -ad /var | sort -nr
/* Report the the disk used in /var in reverse order */   
27.   du -k .
/* Report disk usage in Kilobytes */   
28.   du -sk * | sort -nr | head
/* Shows the top ten largest files/directories */   
29.   du -sk *|sort -k1,1n
/* Reports total disk space used in Kilobytes in present directory */   
30.   du -sk .
/* Report total disk usage in Kilobytes */   
31.   fdformat -d -U
/* Format diskette */   
32.   mount -F hsfs -o ro `lofiadm -a /export/temp/software.iso` /mnt
/* Mount an ISO Image */   
33.   newfs -Nv /dev/rdsk/c0t0d0s1
/* To view the superfblocks available */   
34.   One-liner to copy a partition table
/* prtvtoc /dev/dsk/c1t2d0s2 | fmthard -s - /dev/rdsk/c1t3d0s2 */   
35.   prtvtoc /dev/rdsk/c0t0d0s2
/* Disk geometry and partitioning info */   
36.   prtvtoc /dev/rdsk/c0t0d0s2 | fmthard -s - /dev/rdsk/c0t1d0s2
/* Copy partition table from one disk to another */   
37.   quot -af
/* How much space is used by users in kilobytes */   
38.   volrmmount -i floppy
/* Mount a floppy or other media easily by its nickname. */   
Back to top

Driver Parameters
39.   ndd /dev/ip ip_forwarding
/* Show the ip_forwarding variable in the kernel */   
40.   ndd /dev/ip ip_forwarding 1
/* Set the ip_forwarding variable in the kernel */   
41.   ndd /dev/ip \?
/* Show all IP variables set in the kernel */   
Back to top

File Manipulation
42.   dos2unix | -ascii  
/* Converts DOS file formats to Unix */   
43.   fold -w 180
/* To break lines to have maximum char */   
44.   split [-linecount] [file]
/* Split files into pieces */   
45.   [vi] : %s/existing/new/g
/* Search and Replace text in vi */   
46.   [vi] :set list
/* Show non-printing characters in vi */   
47.   [vi] :set nu
/* Set line numbers in vi */   
48.   [vi] :set ts=[num]
/* Set tab stops in vi */   
Back to top

File System
49.   /sbin/uadmin x x
/* Syncs File Systems and Reboots systems fast */   
50.   awk ' END {print NR}' file_name
/* Display the Number of lines in a file */   
51.   cat /dev/null > filename
/* Zero's out the file without breaking pipe */   
52.   cksum [filename]
/* View the checksum value for the given file */   
53.   dd if=/dev/rdsk/... of=/dev/rdsk/... bs=4096
/* Make a mirror image of your boot disk */   
54.   df -k | grep dg| awk '{print $6}' |xargs -n 1 umount
/* Unmount all file systems in disk group dg */   
55.   fsck -F ufs -o b=97472 /dev/rdsk/c0t0d0s0
/* Check and repair a UFS filesystem on c0t0d0s0, using an alternate superblock */   
56.   fsck -F ufs -y /dev/rdsk/c0t0d0s0
/* Check a UFS filesystem on c0t0d0s0, repair any problems without prompting. */   
57.   fsck -F ufs /dev/rdsk/c0t0d0s0
/* Check a UFS filesystem on c0t0d0s0 */   
58.   gzip -d -c tarball.tgz | (cd /[dir];tar xf - ) &
/* Unpacking tarballs to diff location */   
59.   gzip -dc file1.tar.gz | tar xf -
/* Unpack .tar.gz files in place */   
60.   ln [-fhns]   
/* Creating hard links and soft links */   
61.   ls -al | awk '$3 == "oracle" || $3 == "root" {print $9}'
/* List all file names by testing owner */   
62.   ls -l | sort +4n
/* List files by size */   
63.   ls -la | awk '{ print $5,"    ",$9 }' | sort -rn
/* File sizes of current directory */   
64.   ls -lR | awk '{total +=$5};END {print "Total size: " total/1024/1024 "MB" }'
/* Recursive directory size calculations in MB */   
65.   mkisofs -l -L -r -o [image-name].iso [directory]
/* Create an ISO image of a directory */   
66.   mount -F ufs -o rw,remount /
/* Used to remount root to make it writeable */   
67.   mount -o remount,logging /spare
/* Re-mount the ro file system rw and turn on ufs logging */   
68.   mount DOS fdisk partition from Solaris
/* mount -f pcfs /dev/dsk/c0d0p1 /export/dos */   
69.   mv [filename]{,.new_suffix}
/* Renaming file */   
70.   pax -rw . /newdir
/* Efficient alternative for copying directories */   
71.   prtvtoc /dev/rdsk/c0t0d0s2 | fmthard -s - /dev/rdsk/c0t1d0s2
/* Cloning Partitiontables */   
72.   rpm -q --queryformat '%{INSTALLPREFIX}\n' [packagename]
/* [Linux] Locate binaries */   
73.   tar cf - . | (cd /newdir ; tar xf -)
/* Recursively copy files and their permissions */   
74.   tar cvf filename.tar
/* Create a tape (tar) archive */   
75.   tar xvf filename.tar
/* Extract a tape (tar) archive */   
76.   X=$(wc -l '
/* Converts hexadecimal number to decimal. */   
86.   /usr/bin/catman -w
/* Create windex databases for man page directories */   
87.   echo 'obase=16;255' | bc
/* Simple way to convert decimal to hex */   
88.   FQ_FILENAME=; echo ${FQ_FILENAME%/*}
/* Extract directory from fully-qualified file name. */   
89.   mailx -H -u  
/* List out mail headers for specified user */   
90.   ps -ef | grep -i $@
/* Access common commands quicker */   
91.   set filec
/* Set file-completion for csh */   
92.   uuencode [filename] [filename] | mailx -s "Subject" [user to mail]
/* Send files as attachments */   
93.   xauth -f /home/${LOGNAME} extract - ${DISPLAY} | xauth merge -
/* Allow root to xdisplay after su */   
Back to top

Hardware
94.   cfgadm
/* Verify reconfigurable hardware resources */   
95.   m64config -depth 8|24
/* Sets the screen depth of your M64 graphics accelerator */   
96.   m64config -prconf
/* Print M64 hardware configuration */   
97.   m64config -res 'video_mode'
/* Change the resolution of your M64 graphics accelerator */   
98.   prtpicl -v | grep sync-speed
/* Discover SCSI sync speed */   
Back to top

Kernel
99.   /usr/sbin/modinfo
/* Display kernel module information */   
100.   /usr/sbin/modload  
/* Load a kernel module */   
101.   /usr/sbin/modunload -i  
/* Unload a kernel module */   
102.   /usr/sbin/sysdef
/* Show system kernal tunable details */   
103.   nm -x /dev/ksyms | grep OBJ | more
/* Tuneable kernel parameters */   
104.   update_drv -f [driver name]
/* Force a driver to reread it's .conf file without reloading the driver */   
Back to top

Memory
105.   pagesize -a
/* Available page sizes for Solaris 9 */   
106.   prtconf | grep Mem
/* Display Memory Size of the local machine. */   
Back to top

Network Information
107.   arp -a
/* Ethernet address arp table */   
108.   arp -d myhost
/* Delete an ethernet address arp table entry */   
109.   lsof
-iTCP@10.20.2.9

/* Display open files for internet address */   
110.   named-xfer -z qantas.com.au -f /tmp/allip
/* Get All IP Addresses On A DNS Server */   
111.   ndd /dev/arp arp_cache_report
/* Prints ARP table in cache with IP and MAC address */   
112.   netstat -a | grep EST | wc -l
/* Displays number active established connections to the localhost */   
113.   netstat -a | more
/* Show the state of all the sockets on a machine */   
114.   netstat -i
/* Show the state of the interfaces used for TCP/IP traffice */   
115.   netstat -k hme0
/* Undocumented netstat command */   
116.   netstat -np
/* Similar to arp -a without name resolution */   
117.   netstat -r
/* Show the state of the network routing table for TCP/IP traffic */   
118.   netstat -rn
/* Displays routing information but bypasses hostname lookup. */   
119.   snoop -S -ta [machine]
/* Snoop for network packets and get size and time stamp entries. */   
120.   traceroute  
/* Follow the route to the ipaddress */   
Back to top

Network Tuning
121.   /sbin/ifconfig hme0:1 inet 10.210.xx.xxx netmask 255.255.0.0 broadcast 10.210.xxx.xxx
/* Virtual Interfaces */   
122.   /sbin/ifconfig hme0:1 up
/* Bring virtual interface up */   
123.   /usr/sbin/ndd -set /dev/hme adv_100fdx_cap 1
/* Nailling to 100Mbps */   
124.   ifconfig eth0 10.1.1.1 netmask 255.255.255.255
/* Add an Interface */   
125.   ifconfig eth0 mtu 1500
/* Change MTU of interface */   
126.   ndd -set /dev/ip ip_addrs_per_if 1-8192
/* To set more than 256 virtual ip addresses. */   
127.   ndd -set /dev/tcp tcp_recv_hiwat 65535
/* Increase TCP-receivebuffers on Sol2.5.1 systems with 100BaseTx */   
128.   ndd -set /dev/tcp tcp_xmit_hiwat 65535
/* Increase TCP-transmitbuffers on Sol2.5.1 systems with 100BaseTx */   
Back to top

Processes
129.   /usr/proc/bin/ptree  
/* Print the parent/child process 'tree' of a process */   
130.   /usr/proc/bin/pwdx  
/* Print the working directory of a process */   
131.   /usr/ucb/ps -aux | more
/* Displays CPU % usage for each process in ascending order */   
132.   /usr/ucb/ps -auxww | grep  
/* Gives the full listing of the process (long listing) */   
133.   coreadm -i core.%f.%p
/* Append program name and process id to core file names */   
134.   fuser -uc /var
/* Processes that are running from /var */   
135.   ipcs
/* Report inter-process communication facilities status */   
136.   kill -HUP `ps -ef | grep [p]roccess | awk '{print $2}'`
/* HUP any related process in one step */   
137.   lsof -i TCP:25
/* Mapping port with process */   
138.   pfiles  
/* Shows processes' current open files */   
139.   pkill -n  
/* Kill a process by name */   
140.   prstat -a
/* An alternative for top command */   
141.   ps -edf -o pcpu,pid,user,args
/* Nicely formatted 'ps' */   
142.   ps -ef | grep -i  | awk '{ print $2 }'
/* Creates list of running PID by  */   
143.   ps -ef | grep -i  | awk '{ print $2 }'
/* Creates list of running PID by */   
144.   ps -ef | grep  | grep -v grep | cut -c 10-15 | xargs kill -9
/* Find and kill all instances of a given process */   
145.   ps -ef | more
/* Show all processes running */   
146.   ps -ef|grep -v "0:00"|more
/* Gives you a list of any process with CPU time more than 0:00 */   
147.   ps -eo pid,args
/* List processes in simplified format */   
148.   ps -fu oracle|grep pmon
/* See which instances of Oracle are running */   
149.   top -b 1
/* Returns the process utilizing the most cpu and quits */   
Back to top

Resource Management
150.   /usr/bin/ldd [filename]
/* List the dynamic dependencies of executable files */   
151.   /usr/proc/bin/pmap pid
/* Report address space map a process occupies */   
Back to top

Route Configuration
152.   route add net 128.50.0.0 128.50.1.6 1
/* Add a route to the routing table */   
153.   route change 128.50.0.0 128.50.1.5
/* Changes the destination address for a route */   
154.   route delete net 128.50.0.0 128.50.1.6
/* Delete a route from the routing table */   
155.   route flush
/* Flush the routing table, which will remove all entries */   
156.   route get [hostname]
/* Which interface will be used to contact hostname */   
157.   route monitor
/* Monitor routing table lookup misses and changes */   
Back to top

Searching Items
158.   cat  | awk '{if (substr($1,1,1) == '#') print $0 }'
/* Print all lines in a file beginning with a specific character */   
159.   egrep "patterna|patternb"  
/* Search for multiple patterns within the same file */   
160.   find  -name "" -exec rm -rf {} \;
/* Recursively finds files by name and automatically removes them */   
161.   find . -type f -print | xargs grep -i [PATTERN]
/* Recursive grep on files */   
162.   find . ! -mtime - | /usr/bin/xargs rm -rf
/* Finds and removes files older than  specified */   
163.   find . -exec egrep -li "str" {} \;
/* Find a string in files starting cwd */   
164.   find . -mtime -1 -type f
/* Find recently modified files */   
165.   find . -type f -exec grep "" {} \; -print
/* Find files (and content) containing  within directory tree */   
166.   find . -type f -exec grep -l "" {} \;
/* Find files (and content) containing  within directory tree */   
167.   find ./ \! -type f -exec ls -l {} \;|grep -v '^[l|p|s|-]'|grep -v 'total' | wc -l
/* Find number of directories under the current directory */   
168.   find / -fstype nfs -prune -o fstype autofs -prune -o -name filename -print
/* find without traversing NFS mounted file systems */   
169.   find / -mtime  
/* Find files modified during the past # of days */   
170.   find / -perm -2 -a ! -type l
/* Find files writable by 'others' */   
171.   find / -type f |xargs ls -s | sort -rn |more
/* List files taking up the most system space */   
172.   find / -user  
/* Find all files owned by  */   
173.   find / -xdev -type f -ls|sort -nr -k 7,7
/* Find largest files in a file system */   
174.   find / | grep [file mask]
/* Fast way to search for files */   
175.   find /proc/*/fd -links 0 -type f -size +2000 -ls
/* Find large files moved or deleted and held open by a process */   
176.   grep  /var/sadm/install/contents| awk '{ print $1 ' ' $10 }'
/* Find which package contains a particular file */   
177.   ls -lR | grep  
/* Fast alternative to find. */   
178.   pkgchk -l -p /absolute/path/todir
/* Which package does this file belong to? */   
Back to top

Security
179.   crypt  abc && rm abc.cr
/* Decrypting a file that has been encrypted */   
180.   crypt  abc.cr && rm abc
/* File encryption with crypt */   
181.   echo 'Please go away' > /etc/nologin
/* Stops users logging in */   
182.   find / -perm -0777 -type d -ls
/* Find all your writable directories */   
183.   find / -type f -perm -2000 -print
/* Find all SGID files */   
184.   find / -type f -perm -4000 -print
/* find all SUID files */   
185.   getpwenc [encryption scheme] password
/* Genrate passwords for LDAP Using 'getpwenc' Utility */   
186.   trap 'exit 0' 1 2 3 9 15
/* Trap specific signals and exit */   
187.   vi -x [filename]
/* Encrypt a file with vi editor */   
Back to top

Setting Term Options
188.   stty erase ^?
/* Set the delete key to delete a character */   
189.   stty erase ^H
/* Set the backspace to delete a character */   
190.   stty sane
/* Reset terminal after viewing a binary file. */   
191.   tput rmacs
/* Reset to standard char set */   
Back to top

Snoop
192.   snoop -d pcelx0
/* Watch all the packets on a device */   
193.   snoop -i /tmp/mylog -o /tmp/newlog host1
/* Filter out all the host1 packets and write them to a new logfile */   
194.   snoop -i /tmp/mylog -v -p101
/* Show verbose info on packet number 101 in the logfile */   
195.   snoop -i /tmp/mylog host1 host2
/* View packets from a logfile between hosts1 and host2 */   
196.   snoop -o /tmp/mylog pcelx0
/* Save all the packets from a device to a logfile */   
197.   snoop -s 120
/* Return the first 120 bytes in the packet header */   
198.   snoop -v arp
/* Capture arp broadcasts on your network */   
199.   snoop port [port-number]
/* Monitor particular port for traffic */   
Back to top

Swap Files
200.   mkfile -nv 10m /export/disk1/myswap
/* Makes an empty 10 Megabyte swapfile in /export/disk */   
201.   mkfile -v 10m /export/disk1/myswap
/* Makes a 10 Megabyte swapfile in /export/disk */   
Back to top

Swap Space
202.   swap -a /export/disk1/swapfile
/* Add a swap file */   
203.   swap -d /dev/dsk/c0t0d0s4
/* Delete a swap device */   
204.   swap -l
/* List the current swap devices */   
205.   swap -s
/* List the amount of swap space available */   
Back to top

System Configuration
206.   /usr/sbin/eeprom auto-boot? false
/* Changes eeprom autoboot? setting without going to Ok prompt */   
207.   /usr/sbin/eeprom diag-switch? true
/* Set the system to perform diagnostics on the next reboot. */   
208.   /usr/sbin/eeprom local-mac-address?=true
/* Multiple Port Network Card Setting */   
209.   /usr/sbin/grpck
/* Check /etc/group file syntax */   
210.   /usr/sbin/pwck
/* Check /etc/passwd file syntax */   
211.   /usr/sbin/sys-unconfig
/* Clear host specific network configuration information */   
212.   /usr/sbin/useradd
/* Add a new user to the system */   
213.   drvconfig ; disks
/* Adding hot-plug disks to system */   
Back to top

System Information/Monitoring
214.   /bin/echo "0t${stamp}>Y\n 13 | grep ':'
/* Get the time on remote Unix machine */   
232.   uname -a
/* Displays system information */   
233.   uname -X
/* Displays system information */   
234.   vmstat 10
/* Displays summary of what the system is doing every 10 seconds */   
235.   who -b
/* Displays the date of the last system reboot. */   
236.   ypcat hosts | sort -n -t. +0 -1 +1 -2 +2 -3 +3 -4
/* Take the input of "ypcat hosts" or "cat /etc/inet/hosts" and sort by IP. */  


本文来自ChinaUnix博客,如果查看原文请点:http://blog.chinaunix.net/u3/98478/showart_1988210.html
您需要登录后才可以回帖 登录 | 注册

本版积分规则 发表回复

  

北京盛拓优讯信息技术有限公司. 版权所有 京ICP备16024965号-6 北京市公安局海淀分局网监中心备案编号:11010802020122 niuxiaotong@pcpop.com 17352615567
未成年举报专区
中国互联网协会会员  联系我们:huangweiwei@itpub.net
感谢所有关心和支持过ChinaUnix的朋友们 转载本站内容请注明原作者名及出处

清除 Cookies - ChinaUnix - Archiver - WAP - TOP