免费注册 查看新帖 |

Chinaunix

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

Solaris管理员常用命令简明手册(好你就顶拉) [复制链接]

论坛徽章:
0
跳转到指定楼层
1 [收藏(0)] [报告]
发表于 2004-01-15 10:04 |只看该作者 |倒序浏览
转贴自Sun BigAdmin.
没有翻译,因为本身已经很简单了,你觉得不错就顶。呵呵~
有人再加上自己觉得好用的命令技巧就更好了~


  1. SysAdmin Commands

  2. Debugging

  3.   truss executable
  4. /* Trace doing of given command ( useful debugging ) */  

  5.   truss -f -p <pid of a shell>;
  6. /* Using multiple windows, this can be used to trace setuid/setgid programs */  

  7. Arp, ethernet trouble shooting  

  8.   arp -a .
  9. /* Shows the ethernet address arp table */  

  10.   arp -d myhost
  11. /* Delete a stale ethernet entry for host myhost */  

  12. Disk Commands  

  13.   du -k .
  14. /* Reports disk space used in Kilobytes */  

  15.   du -sk .
  16. /* Reports only total disk space used in Kilobytes */  

  17.   du -sk *|sort -k1,1n
  18. /* Reports total disk space used in Kilobytes in present directory */

  19.   du -ad /var | sort -nr
  20. /* Tells you how big the /var files are in reverse order */  

  21.   fdformat -d -U
  22. /* Format diskette */  

  23.   /usr/bin/iostat -E
  24. /* Command to display drives statistics */  

  25.   /bin/mount -F hsfs -o ro /dev/sr0 /cdrom
  26. /* Mount an ISO 9660 CDROM */  

  27.   newfs -Nv /dev/rdsk/c0t0d0s1
  28. /* To view the superfblocks available */  

  29.   prtvtoc /dev/rdsk/c0t0d0s2
  30. /* Disk geometry and partitioning info */  

  31.   quot -af
  32. /* How much space is used by users in kilobytes */  

  33. Driver Parameters  

  34.   ndd /dev/ip \?
  35. /* Shows IP variables in the kernel */  

  36.   ndd /dev/ip ip_forwarding
  37. /* Tells you if forwarding is on (=1) */  

  38.   ndd -set /dev/ip ip_forwarding 1
  39. /* Enables IP forwarding between interfaces */  

  40. File Manipulation  

  41.   dos2unix | -ascii <filename>;
  42. /* Converts DOS file formats to Unix */  

  43.   split
  44. /* Split files into pieces */  

  45.   [vi] : %s/existing/new/g
  46. /* Search and Replace text in vi */  

  47.   [vi] :set nu
  48. /* Set line numbers in vi */  

  49.   [vi] :set ts=[num]
  50. /* Set tab stops in vi */  

  51. File System  

  52.   cat /dev/null >; filename
  53. /* Zero's out the file without breaking pipe */  

  54.   dd if=/dev/rdsk/... of=/dev/rdsk/... bs=4096
  55. /* Make a mirror image of your boot disk */  

  56.   df -k | grep dg| awk '{print $6}' |xargs -n 1 umount
  57. /* Unmount all file systems in disk group dg */  

  58.   fsck -F ufs /dev/rdsk/c0t0d0s0
  59. /* Check a UFS filesystem on c0t0d0s0 */  

  60.   fsck -F ufs -y /dev/rdsk/c0t0d0s0
  61. /* Check answering yes to all questions */  

  62.   fsck -F ufs -o b=97472 /dev/rdsk/c0t0d0s0
  63. /* Check using an alternate super block */  

  64.   gzip -dc file1.tar.gz | tar xf -
  65. /* Unpack .tar.gz files in place */  

  66.   gzip -d -c tarball.tgz | (cd /[dir];tar xf - ) &
  67. /* Unpacking tarballs to diff location */  

  68.   ln [-fhns] <source file>; <destination file>;
  69. /* Creating hard links and soft links */  

  70.   ls -la | awk '{ print $5,"    ",$9 }' | sort -rn
  71. /* File sizes of current directory */  

  72.   mount -f pcfs /dev/dsk/c0d0p1 /export/dos
  73. /* Mount DOS fdisk partition from Solaris */  

  74.   mount -F ufs -o rw,remount /
  75. /* Used to remount root to make it writeable */  

  76.   mount -o remount,logging /spare
  77. /* Re-mount the ro file system rw and turn on ufs logging */  

  78.   pax -rw . /newdir
  79. /* Efficient alternative for copying directories */  

  80.   prtvtoc /dev/rdsk/c0t0d0s2 | fmthard -s - /dev/rdsk/c0t1d0s2
  81. /* Cloning Partitiontables */  

  82.   tar cvf filename.tar
  83. /* Create a tape (tar) archive */  

  84.   tar xvf filename.tar
  85. /* Extract a tape (tar) archive */  

  86.   tar cf - . | (cd /newdir ; tar xf -)
  87. /* Recursively copy files and their permissions */  

  88.   /sbin/uadmin x x
  89. /* Syncs File Systems and Reboots systems fast */  

  90.   zcat [cpio file] | cpio -itmv
  91. /* Show the contents of a compressed cpio */  

  92.   zcat <patch_file.tar.Z | tar xvf -
  93. /* Extract the patch_file that is a compressed tar file */  

  94. File Transfer  

  95.   get filename.suffix |"tar xf -"
  96. /* Undocumented Feature of FTP */  

  97.   put "| tar cf - ." filename.tar
  98. /* Undocumented Feature of FTP */  

  99.   find . -depth | cpio -pdmv /path/tobe/copied/to
  100. /* Fast alternative to cp -pr */  

  101.   sendport
  102. /* Transferring large numbers of files within the same ftp control session */  

  103. General  

  104.   /usr/bin/catman -w
  105. /* Create windex databases for man page directories */  

  106.   FQ_FILENAME=<fully_qualified_file_name>;; echo ${FQ_FILENAME%/*}
  107. /* Extract directory from fully-qualified file name. */  

  108.   mailx -H -u <username>;
  109. /* List out mail headers for specified user */  

  110.   set filec
  111. /* Set file-completion for csh */  

  112.   uuencode [filename] [filename] | mailx -s "Subject" [user to mail]
  113. /* Send files as attachments */  

  114. Hardware  

  115.   cfgadm
  116. /* Verify reconfigurable hardware resources */  

  117.   m64config -prconf
  118. /* Print M64 hardware configuration */  

  119.   m64config -depth 8|24
  120. /* Sets the screen depth of your M64 graphics accelerator */  

  121.   m64config -res 'video_mode'
  122. /* Change the resolution of your M64 graphics accelerator */  

  123. Kernel  

  124.   /usr/sbin/modinfo
  125. /* Display kernel module information */  

  126.   /usr/sbin/modload <module>;
  127. /* Load a kernel module */  

  128.   /usr/sbin/modunload -i <module id>;
  129. /* Unload a kernel module */  

  130.   nm -x /dev/ksyms | grep OBJ | more
  131. /* Tuneable kernel parameters */  

  132.   /usr/sbin/sysdef
  133. /* Show system kernal tunable details */  

  134. Memory  

  135.   prtconf | grep Mem
  136. /* Display Memory Size */  

  137. Network Information  

  138.   ndd /dev/arp arp_cache_report
  139. /* Prints ARP table in cache with IP and MAC address */  

  140.   netstat -a | grep EST | wc -l
  141. /* Displays number active established connections to the localhost */  

  142.   netstat -k hme0
  143. /* Undocumented netstat command */  

  144.   netstat -i
  145. /* Show the TCP/IP network interfaces */  

  146.   netstat -np
  147. /* Similar to arp -a without name resolution */  

  148.   netstat -r
  149. /* Show network route table */  

  150.   netstat -rn
  151. /* Displays routing information but bypasses hostname lookup. */  

  152.   netstat -a | more
  153. /* Show the state of all sockets */  

  154.   traceroute <ipaddress>;
  155. /* Follow the route to the ipaddress */  

  156. Network/Tuning  

  157.   ifconfig eth0 mtu 1500
  158. /* Change MTU of interface */  

  159.   ifconfig eth0 10.1.1.1 netmask 255.255.255.255
  160. /* Add an Interface */  

  161.   /sbin/ifconfig hme0:1 inet 10.210.xx.xxx netmask 255.255.0.0 broadcast 10.210.xxx.xxx
  162. /* Virtual Interfaces */  

  163.   /sbin/ifconfig hme0:1 up
  164. /* Bring virtual interface up */  

  165.   /usr/sbin/ndd -set /dev/hme adv_100fdx_cap 1
  166. /* Nailling to 100Mbps */  

  167.   ndd -set /dev/ip ip_addrs_per_if 1-8192
  168. /* To set more than 256 virtual ip addresses. */  

  169.   ndd -set /dev/tcp tcp_xmit_hiwat 65535
  170. /* Increase TCP-transmitbuffers */  

  171.   ndd -set /dev/tcp tcp_recv_hiwat 65535
  172. /* Increase TCP-receivebuffers */  

  173. Processes  

  174.   fuser -uc /var
  175. /* Processes that are running from /var */  

  176.   kill -HUP `ps -ef | grep [p]roccess | awk '{print $2}'`
  177. /* HUP any related process in one step */  

  178.   lsof -i TCP:25
  179. /* Mapping port with process */  

  180.   pfiles <pid>;
  181. /* Shows processes' current open files */  

  182.   pkill -n <name>;
  183. /* Kill a process by name */  

  184.   kill `ps -ef | grep program_name | grep -v grep | cut -f8 -d ' '`
  185. /* pkill for solaris 2.6 */  

  186.   prstat -a
  187. /* An alternative for top command */  

  188.   /usr/ucb/ps -aux | more
  189. /* Displays CPU % usage for each process in ascending order */  

  190.   /usr/ucb/ps -auxww | grep <process name>;
  191. /* Gives the full listing of the process (long listing) */  

  192.   ps -ef | grep -i <string>; | awk '{ print $2 }'
  193. /* Creates list of running PID by */  

  194.   ps -ef | grep -v "0:00" | more
  195. /* Gives you a list of any process with CPU time more than 0:00 */  

  196.   ps -ef | more
  197. /* Show all processes running */  

  198.   ps -eo pid,args
  199. /* List processes in simplified format */  

  200.   ps -fu oracle|grep pmon
  201. /* See which instances of Oracle are running */  

  202.   /usr/proc/bin/ptree <pid>;
  203. /* Print the parent/child process 'tree' of a process */  

  204.   /usr/proc/bin/pwdx <pid>;
  205. /* Print the working directory of a process */  

  206.   top -b 1
  207. /* Returns the process utilizing the most cpu and quits */  

  208. Resource Management  

  209.   /usr/bin/ldd [filename]
  210. /* List the dynamic dependencies of executable files */  

  211.   /usr/proc/bin/pmap pid
  212. /* Report address space map a process occupies */  

  213. Route Configuration  

  214.   route add net 128.50.0.0 128.50.1.6 1
  215. /* Adds route to 128.50 network via 128.50.1.6 */  

  216.   route change 128.50.0.0 128.50.1.5
  217. /* Changes the destination address for a route */  

  218.   route delete net 128.50.0.0 128.50.1.6
  219. /* Deletes route to 128.50 network */  

  220.   route get [hostname]
  221. /* Which interface will be used to contact hostname */  

  222.   route monitor
  223. /* Monitors traffic to the routes */  

  224.   route flush
  225. /* Removes all entries in the route table */  

  226. Searching Items  

  227.   egrep "patterna|patternb" <filename>;
  228. /* Search for multiple patterns within the same file */  

  229.   find . -exec egrep -li "str" {} \;
  230. /* Find a string in files starting cwd */  

  231.   find / -fstype nfs -prune -o fstype autofs -prune -o -name filename -print
  232. /* Find without traversing NFS mounted file systems */  

  233.   find . -mtime -1 -type f
  234. /* Find recently modified files */
  235.   
  236.   find / -mtime <# of days>;
  237. /* Find files modified during the past # of days */

  238.   find . ! -mtime -<days>; | /usr/bin/xargs rm -rf
  239. /* Finds and removes files older than <days>; specified */  

  240.   find . -type f -exec grep "<sub-string>;" {} \; -print
  241. /* Find files (and content) containing <sub-string>; within directory tree */  

  242.   find . -type f -exec grep -l "<sub-string>;" {} \;
  243. /* Find filenames containing <sub-string>; within directory tree */  

  244.   find . -type f -print | xargs grep -i [PATTERN]
  245. /* Recursive grep on files */  

  246.   find / -user <username>;
  247. /* Find all files owned by <username>; */  

  248.   find / | grep [file mask]
  249. /* Fast way to search for files */  

  250.   find <start_path>; -name "<file_name>;" -exec rm -rf {} \;
  251. /* Recursively finds files by name and automatically removes them */  

  252.   find /proc/*/fd -links 0 -type f -size +2000 -ls
  253. /* Find large files held open by a process */  

  254.   ls -lR | grep <sub_string>;
  255. /* Fast alternative to find */  

  256. Security  

  257.   echo 'Please go away' >; /etc/nologin
  258. /* Stops users logging in */  

  259.   find / -perm -0777 -type d -ls
  260. /* Find all your writable directories */  

  261.   find / -type f -perm -2000 -print
  262. /* Find all SGID files */  

  263.   find / -type f -perm -4000 -print
  264. /* find all SUID files */  

  265. Set Terminal Options  

  266.   stty erase ^H
  267. /* Sets the Backspace Key to erase */  

  268.   stty erase ^?
  269. /* Sets the Delete Key to erase */  

  270.   stty sane
  271. /* Rreset terminal after viewing a binary file. */  

  272.   tput rmacs
  273. /* Reset to standard char set */  

  274. Snoop Your Network  

  275.   snoop -d pcelx0
  276. /* Watch all network packets on device pcelx0 */  

  277.   snoop -o /tmp/mylog pcelx0
  278. /* Saves packets from device pcelx0 to a file */  

  279.   snoop -i /tmp/mylog host1 host2
  280. /* View packets from logfile between host1 & host2 */  

  281.   snoop -i /tmp/mylog -v -p101
  282. /* Show all info on packet number 101 from a logfile */  

  283.   snoop -i /tmp/mylog -o /tmp/newlog host1
  284. /* Write a new logfile with all host1 packets */  

  285.   snoop -s 120
  286. /* Return the first 120 bytes in the packet header */  

  287.   snoop -v arp
  288. /* Capture arp broadcasts on your network */  

  289. Swap File  

  290.   mkfile -v 10m /export/disk1/myswap
  291. /* Makes a 10 Megabyte swapfile in /export/disk */  

  292.   mkfile -nv 10m /export/disk1/myswap
  293. /* Makes an empty 10 Megabyte swapfile */  

  294. Swap Space  

  295.   swap -s
  296. /* List the amount of swap space available, also see mkfile */  

  297.   swap -a /export/disk1/swapfile
  298. /* Add a swapfile */  

  299.   swap -d /dev/dsk/c0t0d0s4
  300. /* Deletes a swap device */  

  301.   swap -l
  302. /* List the current swap devices */  

  303. System Configuration  

  304.   drvconfig ; disks
  305. /* Adding hot-plug disks to system */  

  306.   /usr/sbin/eeprom auto-boot? false
  307. /* Changes eeprom autoboot? setting without going to Ok prompt */  

  308.   /usr/sbin/eeprom diag-switch? true
  309. /* Set the system to perform diagnostics on the next reboot. */  

  310.   /usr/sbin/eeprom local-mac-address?=true
  311. /* Multiple Port Network Card Setting */  

  312.   /usr/sbin/grpck
  313. /* Check /etc/group file syntax */  

  314.   /usr/sbin/pwck
  315. /* Check /etc/passwd file syntax */  

  316.   /usr/sbin/sys-unconfig
  317. /* Clear host specific network configuration information */  

  318. System Information and Monitoring  

  319.   coreadm -e log
  320. /* Report global core */  

  321.   /bin/echo "0t${stamp}>;Y\n<Y=Y" | adb
  322. /* Convert UNIX timestamp to something human-readable */  

  323.   /usr/sbin/eeprom
  324. /* Show eeprom parameters */  

  325.   grep "\-root" /var/adm/sulog | grep -v \+ | tail -25
  326. /* List most recent attempts to switch to superuser account. */  

  327.   isainfo -bv
  328. /* Quickly checkout if machine is in 32 or 64 bit mode */  

  329.   last
  330. /* Tells who was or still is on the system */  

  331.   logger -i
  332. /* Log the process ID */  

  333.   psradm -f [processor id]
  334. /* Take processor offline */  

  335.   /usr/sbin/prtconf -vp
  336. /* Show system configuration details */  

  337.   /usr/platform/`/bin/uname -i`/sbin/prtdiag -v
  338. /* System Diagnostics */  

  339.   prtconf -pv | grep banner-name |awk -F\' ' { print $2 } ' | head -1
  340. /* Show actual model name of machine */  

  341.   psrinfo | wc -l
  342. /* Display number of processors */  

  343.   sar -A <time in sec>;
  344. /* Provides cumulative system report. */  

  345.   sar -a <time in sec>;
  346. /* Report use of file access system routines. */  

  347.   sar -u
  348. /* Report CPU Utilization */  

  349.   telnet <remote machine>; 13 | grep ':'
  350. /* Get the time on remote Unix machine */  

  351.   uname -a
  352. /* Displays system information */  

  353.   vmstat 10
  354. /* Displays summary of what the system is doing every 10 seconds */  

  355.   who -b
  356. /* Displays the date of the last system reboot. */  

  357.   ypcat hosts | sort -n -t. +0 -1 +1 -2 +2 -3 +3 -4
  358. /* Take the input of "ypcat hosts" or "cat /etc/inet/hosts" and sort by IP. */  

复制代码

论坛徽章:
0
2 [报告]
发表于 2004-01-15 10:05 |只看该作者

Solaris管理员常用命令简明手册(好你就顶拉)

非常感谢,鼓励一下

论坛徽章:
0
3 [报告]
发表于 2004-01-15 10:19 |只看该作者

Solaris管理员常用命令简明手册(好你就顶拉)

感谢!!学习!!

论坛徽章:
0
4 [报告]
发表于 2004-01-15 10:23 |只看该作者

Solaris管理员常用命令简明手册(好你就顶拉)

要仔细品味,相信你也会发现:哦?!xxx命令原来这样用才更好啊~
我当初发现了这个dos2unix | -ascii <filename>;,才解决了一个摸索了好久的文件转换怪问题,原来解决方法是这么的简单的啊。
我以前还在本版发了一个检查系统配置的script,呵呵,可以用这里的命令补充功能的哦~

论坛徽章:
1
2016科比退役纪念章
日期:2016-05-26 15:48:47
5 [报告]
发表于 2004-01-15 10:25 |只看该作者

Solaris管理员常用命令简明手册(好你就顶拉)

metor可以下岗了。。。。。。

论坛徽章:
0
6 [报告]
发表于 2004-01-15 10:40 |只看该作者

Solaris管理员常用命令简明手册(好你就顶拉)

不错,谢谢

论坛徽章:
0
7 [报告]
发表于 2004-01-15 10:54 |只看该作者

Solaris管理员常用命令简明手册(好你就顶拉)

论坛徽章:
1
荣誉会员
日期:2011-11-23 16:44:17
8 [报告]
发表于 2004-01-15 11:04 |只看该作者

Solaris管理员常用命令简明手册(好你就顶拉)

原帖由 "陈小奚" 发表:
要仔细品味,相信你也会发现:哦?!xxx命令原来这样用才更好啊~
我当初发现了这个dos2unix | -ascii <filename>;,才解决了一个摸索了好久的文件转换怪问题,原来解决方法是这么的简单的啊。
我以前还在本版..........


同意。

论坛徽章:
0
9 [报告]
发表于 2004-01-15 11:20 |只看该作者

Solaris管理员常用命令简明手册(好你就顶拉)

好东东,拷下来慢慢看

论坛徽章:
0
10 [报告]
发表于 2004-01-15 11:40 |只看该作者

Solaris管理员常用命令简明手册(好你就顶拉)

好,谢谢~!
您需要登录后才可以回帖 登录 | 注册

本版积分规则 发表回复

  

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

清除 Cookies - ChinaUnix - Archiver - WAP - TOP