Debugging 23. cat -v -t -e [file] /* Show non-printing characters */ 24. dumpadm -d swap /* Configure swap device as dump device */ 25.

ld -l <libname without 'lib'> /* Check if you have a particular library */ 26. truss -f -p <pid of a shell> /* Using multiple windows, this can be used to trace setuid/setgid programs */ 27. truss executable /* Trace doing of given command ( useful debugging ) */ Disk Commands 28. /bin/mount -F hsfs -o ro /dev/sr0 /cdrom /* Mount an ISO 9660 CDROM */ 29. /usr/bin/iostat -E /* Command to display drives statistics */ 30. du -ad /var | sort -nr /* Report the the disk used in /var in reverse order */ 31. du -k . /* Report disk usage in Kilobytes */ 32. du -sk * | sort -nr | head /* Shows the top ten largest files/directories */ 33. du -sk *|sort -k1,1n /* Reports total disk space used in Kilobytes in present directory */ 34. du -sk . /* Report total disk usage in Kilobytes */ 35. du -sk `ls -A` | sort -nr | head /* Shows the ten largest files/directories (including hidden ones) */ 36. fdformat -d -U /* Format diskette */

37. ndd /dev/ip \? /* Show all IP variables set in the kernel */ File Manipulation 47. 38. ndd /dev/ip ip_forwarding 1 /* Set the ip_forwarding variable in the kernel */ 46.tar. ndd /dev/ip ip_forwarding /* Show the ip_forwarding variable in the kernel */ 45. bzcat mydir. mount -F hsfs -o ro `lofiadm -a /export/temp/software. 42. fold -w 180 /* To break lines to have maximum char */ 50. 41. dos2unix | -ascii <filename> /* Converts DOS file formats to Unix */ 49. split [-linecount] [file] /* Split files into pieces */ . 39. */ Driver Parameters 44. 43. 40.bz2 | tar xvf /* Untar and bunzip2 in a single command */ 48.iso` /mnt /* Mount an ISO Image */ newfs -Nv /dev/rdsk/c0t0d0s1 /* To view the superfblocks available */ One-liner to copy a partition table /* prtvtoc /dev/dsk/c1t2d0s2 | fmthard -s /dev/rdsk/c1t3d0s2 */ prtvtoc /dev/rdsk/c0t0d0s2 /* Disk geometry and partitioning info */ prtvtoc /dev/rdsk/c0t0d0s2 | fmthard -s /dev/rdsk/c0t1d0s2 /* Copy partition table from one disk to another */ quot -af /* How much space is used by users in kilobytes */ volrmmount -i floppy /* Mount a floppy or other media easily by its nickname.

>> mydir. cksum [filename] /* View the checksum value for the given file */ 60. 53.tar. tar cvf .bz2 /* Create 'tar' archive and 'bzip2' in a single command */ [vi] : %s/existing/new/g /* Search and Replace text in vi */ [vi] :set list /* Show non-printing characters in vi */ [vi] :set nu /* Set line numbers in vi */ [vi] :set ts=[num] /* Set tab stops in vi */ File System 56.. dd if=/dev/rdsk/. fsck -F ufs /dev/rdsk/c0t0d0s0 /* Check a UFS filesystem on c0t0d0s0 */ 65.gz | tar xf /* Unpack . 52.51. gzip -d -c tarball.tar. 55. */ 64.tar. using an alternate superblock */ 63.tgz | (cd /[dir]. of=/dev/rdsk/.. cat /dev/null > filename /* Zero's out the file without breaking pipe */ 59. fsck -F ufs -y /dev/rdsk/c0t0d0s0 /* Check a UFS filesystem on c0t0d0s0.. bs=4096 /* Make a mirror image of your boot disk */ 61.gz files in place */ .) & /* Unpacking tarballs to diff location */ 66. fsck -F ufs -o b=97472 /dev/rdsk/c0t0d0s0 /* Check and repair a UFS filesystem on c0t0d0s0..tar xf . /sbin/uadmin x x /* Syncs File Systems and Reboots systems fast */ 57. 54./mydir | bzip2 . gzip -dc file1. df -k | grep dg| awk '{print $6}' |xargs -n 1 umount /* Unmount all file systems in disk group dg */ 62. repair any problems without prompting.. awk ' END {print NR}' file_name /* Display the Number of lines in a file */ 58.

75. 76.. 68. 78. /newdir /* Efficient alternative for copying directories */ prtvtoc /dev/rdsk/c0t0d0s2 | fmthard -s /dev/rdsk/c0t1d0s2 /* Cloning Partitiontables */ rpm -q --queryformat '%{INSTALLPREFIX}\n' [packagename] /* [Linux] Locate binaries */ tail -f <path to file> /* Follow updates to a file in real time */ tar cf . 82. 73. tar xf -) . 74. ln [-fhns] <source file> <destination file> /* Creating hard links and soft links */ ls -1d [directory]/* /* List only subdirectories . 79.new_suffix} /* Renaming file */ pax -rw . 70.$9 }' | sort -rn /* File sizes of current directory */ ls -lR | awk '{total +=$5}. 77.remount / /* Used to remount root to make it writeable */ mount -o remount.1 per line */ ls -al | awk '$3 == "oracle" || $3 == "root" {print $9}' /* List all file names by testing owner */ ls -l | sort +4n /* List files by size */ ls -la | awk '{ print $5.67.logging /spare /* Re-mount the ro file system rw and turn on ufs logging */ mount DOS fdisk partition from Solaris /* mount -f pcfs /dev/dsk/c0d0p1 /export/dos */ mv [filename]{." ".END {print "Total size: " total/1024/1024 "MB" }' /* Recursive directory size calculations in MB */ mkisofs -l -L -r -o [image-name]. 80.. 72. 81. | (cd /newdir .iso [directory] /* Create an ISO image of a directory */ mount -F ufs -o rw. 69. 71.

echo 'obase=16.*/ 92. echo $X /* Count number of lines in a file into a variable (ksh) */ zcat <patch_file. */ 95. /bin/printf '%d\n' '0x<hex>' /* Converts hexadecimal number to decimal. 85. /* Recursively copy files and their permissions */ tar cvf filename. /usr/bin/catman -w /* Create windex databases for man page directories */ 96.255' | bc .tar /* Undocumented Feature of FTP */ 93..tar.tar /* Create a tape (tar) archive */ tar xvf filename. 86. get filename. find . sendport /* FTP command for transferring large numbers of files within the same control session */ General 94." filename.tar /* Extract a tape (tar) archive */ X=$(wc -l < filename). put "| tar cf .83.suffix |"tar xf -" /* Undocumented Feature of FTP */ 91. -follow | cpio -pdumL /path/tobe/copied/to /* Copy with symbolic links to be followed */ 90.Z | tar xvf /* Extract the patch_file that is a compressed tar file */ zcat [cpio file] | cpio -itmv /* Show the contents of a compressed cpio */ File Transfer 88. Move any file(s) without actually touching them /* ssh cd /some/directory \&\& tar cf . find .| ssh cd /some/direstory \&\& tar xvf . 87. -depth | cpio -pdmv /path/tobe/copied/to /* Fast alternative to cp -pr */ 89. 84.

prtpicl -v | grep sync-speed /* Discover SCSI sync speed */ Kernel 108. */ mailx -H -u <username> /* List out mail headers for specified user */ ps -ef | grep -i $@ /* Access common commands quicker */ set filec /* Set file-completion for csh */ uuencode [filename] [filename] | mailx -s "Subject" [user to mail] /* Send files as attachments */ xauth -f /home/${LOGNAME} extract ${DISPLAY} | xauth merge /* Allow root to xdisplay after su */ Hardware 103. m64config -prconf /* Print M64 hardware configuration */ 106. /* Simple way to convert decimal to hex */ FQ_FILENAME=<fully_qualified_file_name>. /usr/sbin/modinfo /* Display kernel module information */ 109. 99. m64config -res 'video_mode' /* Change the resolution of your M64 graphics accelerator */ 107.97. cfgadm /* Verify reconfigurable hardware resources */ 104. 101. echo ${FQ_FILENAME%/*} /* Extract directory from fully-qualified file name. m64config -depth 8|24 /* Sets the screen depth of your M64 graphics accelerator */ 105. 100. 102. 98. /usr/sbin/modload <module> .

arp -a /* Ethernet address arp table */ 117.110.9 /* Display open files for internet address */ 119.com. 113. arp -d myhost /* Delete an ethernet address arp table entry */ 118. 112. 111. lsof -iTCP@10. ndd /dev/arp arp_cache_report /* Prints ARP table in cache with IP and MAC address */ 121. named-xfer -z qantas. */ Network Information 116.au -f /tmp/allip /* Get All IP Addresses On A DNS Server */ 120.2. /* Load a kernel module */ /usr/sbin/modunload -i <module id> /* Unload a kernel module */ /usr/sbin/sysdef /* Show system kernal tunable details */ nm -x /dev/ksyms | grep OBJ | more /* Tuneable kernel parameters */ update_drv -f [driver name] /* Force a driver to reread it's . pagesize -a /* Available page sizes for Solaris 9 */ 115.conf file without reloading the driver */ Memory 114. prtconf | grep Mem /* Display Memory Size of the local machine. netstat -a | grep EST | wc -l /* Displays number active established connections to the localhost */ 122. netstat -i /* Show the state of the interfaces used for TCP/IP .20. netstat -a | more /* Show the state of all the sockets on a machine */ 123.

1.0.1. ifconfig eth0 mtu 1500 /* Change MTU of interface */ 135. /sbin/ifconfig hme0:1 inet 10. 129.xxx netmask 255. ndd -set /dev/tcp tcp_recv_hiwat 65535 /* Increase TCP-receivebuffers on Sol2.xxx /* Virtual Interfaces */ 131.210. 128.5.255.210.255.5.0 broadcast 10. /usr/sbin/ndd -set /dev/hme adv_100fdx_cap 1 /* Nailling to 100Mbps */ 133. /sbin/ifconfig hme0:1 up /* Bring virtual interface up */ 132. */ traceroute <ipaddress> /* Follow the route to the ipaddress */ Network Tuning 130. ifconfig eth0 10.255. ndd -set /dev/tcp tcp_xmit_hiwat 65535 /* Increase TCP-transmitbuffers on Sol2. 127. */ snoop -S -ta [machine] /* Snoop for network packets and get size and time stamp entries. ndd -set /dev/ip ip_addrs_per_if 1-8192 /* To set more than 256 virtual ip addresses. traffice */ netstat -k hme0 /* Undocumented netstat command */ netstat -np /* Similar to arp -a without name resolution */ netstat -r /* Show the state of the network routing table for TCP/IP traffic */ netstat -rn /* Displays routing information but bypasses hostname lookup. 126. */ 136.1 netmask 255. 125.xx.124.255 /* Add an Interface */ 134.1 .xxx.1 systems with 100BaseTx */ 137.

ps -edf -o pcpu.user.systems with 100BaseTx */ Processes 138. ps -ef | grep -i <string> | awk '{ print $2 }' .%f. pfiles <pid> /* Shows processes' current open files */ 148. pkill -n <name> /* Kill a process by name */ 149. kill -HUP `ps -ef | grep [p]roccess | awk '{print $2}'` /* HUP any related process in one step */ 146.pid. ipcs /* Report inter-process communication facilities status */ 145. lsof -i TCP:25 /* Mapping port with process */ 147.%p /* Append program name and process id to core file names */ 143. fuser -uc /var /* Processes that are running from /var */ 144. /usr/proc/bin/pwdx <pid> /* Print the working directory of a process */ 140. ps -ef | grep -i <string> | awk '{ print $2 }' /* Creates list of running PID by <string> */ 152. prstat -a /* An alternative for top command */ 150. /usr/proc/bin/ptree <pid> /* Print the parent/child process 'tree' of a process */ 139. coreadm -i core. /usr/ucb/ps -aux | more /* Displays CPU % usage for each process in ascending order */ 141. /usr/ucb/ps -auxww | grep <process name> /* Gives the full listing of the process (long listing) */ 142.args /* Nicely formatted 'ps' */ 151.

1.50. 155.50. route add net 128. /* Creates list of running PID by */ ps -ef | grep <process name> | grep -v grep | cut -c 10-15 | xargs kill -9 /* Find and kill all instances of a given process */ ps -ef | more /* Show all processes running */ ps -ef|grep -v "0:00"|more /* Gives you a list of any process with CPU time more than 0:00 */ ps -eo pid.50. route flush /* Flush the routing table.args /* List processes in simplified format */ ps -fu oracle|grep pmon /* See which instances of Oracle are running */ top -b 1 /* Returns the process utilizing the most cpu and quits */ Resource Management 159.5 /* Changes the destination address for a route */ 163.0 128. which will remove all entries */ 165.50.0 128.6 1 /* Add a route to the routing table */ 162.0. route change 128.1. route get [hostname] /* Which interface will be used to contact hostname . 156. route delete net 128.0 128.1.6 /* Delete a route from the routing table */ 164.0. 157. /usr/proc/bin/pmap pid /* Report address space map a process occupies */ Route Configuration 161. /usr/bin/ldd [filename] /* List the dynamic dependencies of executable files */ 160.50. 154.50.0. 158.153.

166. -type f -exec grep -l "<sub-string>" {} \. ! -mtime -<days> | /usr/bin/xargs rm -rf /* Finds and removes files older than <days> specified */ 172.|grep -v '^[l|p|s|]'|grep -v 'total' | wc -l /* Find number of directories under the current directory */ . find . -exec egrep -li "str" {} \. -print /* Find files (and content) containing <sub-string> within directory tree */ 175. egrep "patterna|patternb" <filename> /* Search for multiple patterns within the same file */ 169. -type f -exec grep "<sub-string>" {} \. -mtime -1 -type f /* Find recently modified files */ 174.1) == '#') print $0 }' /* Print all lines in a file beginning with a specific character */ 168.1. find . find . /* Find files (and content) containing <sub-string> within directory tree */ 176. find . cat <filename> | awk '{if (substr($1./ \! -type f -exec ls -l {} \. /* Find a string in files starting cwd */ 173. find . */ route monitor /* Monitor routing table lookup misses and changes */ Searching Items 167. find . find <start_path> -name "<file_name>" -exec rm -rf {} \. find . -type f -print | xargs grep -i [PATTERN] /* Recursive grep on files */ 171. /* Recursively finds files by name and automatically removes them */ 170.

182.cr> abc && rm abc. cat /dev/urandom | tr -dc '[a-z][A-Z][0-9]_!@#$%^&*()_+{}|:<>?=' | fold -w 10| head -n 5 /* Generate 5 random ten-character strings. crypt <abc> abc.177. 180. 179. find / -fstype nfs -prune -o fstype autofs -prune -o name filename -print /* find without traversing NFS mounted file systems */ find / -mtime <# of days> /* Find files modified during the past # of days */ find / -perm -2 -a ! -type l /* Find files writable by 'others' */ find / -type f |xargs ls -s | sort -rn |more /* List files taking up the most system space */ find / -user <username> /* Find all files owned by <username> */ find / -xdev -type f -ls|sort -nr -k 7. 181. 185.7 /* Find largest files in a file system */ find / | grep [file mask] /* Fast way to search for files */ find /proc/*/fd -links 0 -type f -size +2000 -ls /* Find large files moved or deleted and held open by a process */ grep <full_path_to_filename> /var/sadm/install/contents| awk '{ print $1 ' ' $10 }' /* Find which package contains a particular file */ ls -lR | grep <sub_string> /* Fast alternative to find. 187. 183. with symbols */ 189.cr /* Decrypting a file that has been encrypted */ 190. 178. */ pkgchk -l -p /absolute/path/todir /* Which package does this file belong to? */ Security 188.cr && rm abc /* File encryption with crypt */ . crypt <abc. 184. 186.

snoop -i /tmp/mylog -o /tmp/newlog host1 /* Filter out all the host1 packets and write them to a new logfile */ 204. echo 'Please go away' > /etc/nologin /* Stops users logging in */ find / -perm -0777 -type d -ls /* Find all your writable directories */ find / -type f -perm -2000 -print /* Find all SGID files */ find / -type f -perm -4000 -print /* find all SUID files */ getpwenc [encryption scheme] password /* Genrate passwords for LDAP Using 'getpwenc' Utility */ trap 'exit 0' 1 2 3 9 15 /* Trap specific signals and exit */ vi -x [filename] /* Encrypt a file with vi editor */ Setting Term Options 198. snoop -i /tmp/mylog -v -p101 /* Show verbose info on packet number 101 in the logfile */ 205. 192. 195. stty sane /* Reset terminal after viewing a binary file. 197. 193. snoop -i /tmp/mylog host1 host2 /* View packets from a logfile between hosts1 and . stty erase ^? /* Set the delete key to delete a character */ 199. stty erase ^H /* Set the backspace to delete a character */ 200.191. 194. 196. */ 201. snoop -d pcelx0 /* Watch all the packets on a device */ 203. tput rmacs /* Reset to standard char set */ Snoop 202.

mkfile -v 10m /export/disk1/myswap /* Makes a 10 Megabyte swapfile in /export/disk */ Swap Space 212. 209. mkfile -nv 10m /export/disk1/myswap /* Makes an empty 10 Megabyte swapfile in /export/disk */ 211. */ 218. 208. /usr/sbin/eeprom local-mac-address?=true /* Multiple Port Network Card Setting */ 219. swap -a /export/disk1/swapfile /* Add a swap file */ 213. /usr/sbin/eeprom auto-boot? false /* Changes eeprom autoboot? setting without going to Ok prompt */ 217. /usr/sbin/grpck . 207.206. /usr/sbin/eeprom diag-switch? true /* Set the system to perform diagnostics on the next reboot. host2 */ snoop -o /tmp/mylog pcelx0 /* Save all the packets from a device to a logfile */ snoop -s 120 /* Return the first 120 bytes in the packet header */ snoop -v arp /* Capture arp broadcasts on your network */ snoop port [port-number] /* Monitor particular port for traffic */ Swap Files 210. swap -s /* List the amount of swap space available */ System Configuration 216. swap -l /* List the current swap devices */ 215. swap -d /dev/dsk/c0t0d0s4 /* Delete a swap device */ 214.

disks /* Adding hot-plug disks to system */ System Information/Monitoring 224. 222. /bin/echo "0t${stamp}>Y\n<Y=Y" | adb /* Convert UNIX timestamp to something humanreadable */ 225. 221. isainfo -bv /* Quickly checkout if machine is in 32 or 64 bit mode */ 230. . /* Check /etc/group file syntax */ /usr/sbin/pwck /* Check /etc/passwd file syntax */ /usr/sbin/sys-unconfig /* Clear host specific network configuration information */ /usr/sbin/useradd /* Add a new user to the system */ drvconfig . grep "\-root" /var/adm/sulog | grep -v \+ | tail -25 /* List most recent attempts to switch to superuser account. logger -i /* Log the process ID */ 232. last /* Tells who was or still is on the system */ 231. coreadm -e log /* Report global core */ 228. 223. prtconf -vp | grep bootpath /* Determine which root disk you are booted from. /usr/sbin/eeprom /* Show eeprom parameters */ 226. prtconf -pv | grep banner-name |awk -F\' ' { print $2 } ' | head -1 /* Show actual model name of machine */ 233.220. /usr/sbin/prtconf -vp /* Show system configuration details */ 227. */ 229.

238. */ prtdiag -v /* System Diagnostics */ prtpicl -v | grep wwn /* A command to find persistent binding of storage */ psradm -f [processor id] /* Take processor offline */ psrinfo | wc -l /* Display number of processors */ sar -u /* Report CPU Utilization */ sar [ -aA ] [ -o filename ] t [ n ] /* Provides cumulative reports about system activity. 245. 244. 235. */ showrev -p /* Show a list of patches installed */ telnet <remote machine> 13 | grep ':' /* Get the time on remote Unix machine */ uname -a /* Displays system information */ uname -X /* Displays system information */ vmstat 10 /* Displays summary of what the system is doing every 10 seconds */ who -b /* Displays the date of the last system reboot. 243. 239. 246. 236. */ ypcat hosts | sort -n -t.234. 241. 240. 242. +0 -1 +1 -2 +2 -3 +3 -4 /* Take the input of "ypcat hosts" or "cat /etc/inet/hosts" and sort by IP. */ . 237.

Sign up to vote on this title
UsefulNot useful