Advanced Solaris Commands PDF Print E-mail
Written by Administrator   
Friday, 20 March 2009 03:54
    1 
    2 
    3 
    4 
    5 
    6 
    7 
    8 
    9 
   10 
   11 
   12 
   13 
   14 
   15 
   16 
   17 
   18 
   19 
   20 
   21 
   22 
   23 
   24 
   25 
   26 
   27 
   28 
   29 
   30 
   31 
   32 
   33 
   34 
   35 
   36 
   37 
   38 
   39 
   40 
   41 
   42 
   43 
   44 
   45 
   46 
   47 
   48 
   49 
   50 
   51 
   52 
   53 
   54 
   55 
   56 
   57 
   58 
   59 
   60 
   61 
   62 
   63 
   64 
   65 
   66 
   67 
   68 
   69 
   70 
   71 
   72 
   73 
   74 
   75 
   76 
   77 
   78 
   79 
   80 
   81 
   82 
   83 
   84 
   85 
   86 
   87 
   88 
   89 
   90 
   91 
   92 
   93 
   94 
   95 
   96 
   97 
   98 
   99 
  100 
  101 
  102 
  103 
  104 
  105 
  106 
  107 
  108 
  109 
  110 
  111 
  112 
  113 
  114 
  115 
  116 
  117 
  118 
  119 
  120 
  121 
  122 
  123 
  124 
  125 
  126 
  127 
  128 
  129 
  130 
  131 
  132 
  133 
  134 
  135 
  136 
  137 
  138 
  139 
  140 
  141 
  142 
  143 
  144 
  145 
  146 
  147 
  148 
  149 
  150 
  151 
  152 
  153 
  154 
  155 
  156 
  157 
  158 
  159 
  160 
  161 
  162 
  163 
  164 
  165 
  166 
  167 
  168 
  169 
  170 
  171 
  172 
  173 
  174 
  175 
  176 
  177 
  178 
  179 
  180 
  181 
  182 
  183 
  184 
  185 
  186 
  187 
  188 
  189 
  190 
  191 
  192 
  193 
  194 
  195 
  196 
  197 
  198 
  199 
  200 
  201 
  202 
  203 
  204 
  205 
  206 
  207 
  208 
  209 
  210 
  211 
  212 
  213 
  214 
  215 
  216 
  217 
  218 
  219 
  220 
  221 
  222 

  223 
  224 
  225 
  226 
  227 
  228 

  229 
  230 
  231 
  232 
  233 
  234 
  235 
  236 
  237 
  238 
  239 
  240 
  241 
  242 
  243 
  244 
  245 
  246 
  247 
  248 
  249 
  250 
  251 
  252 
  253 
  254 
  255 
  256 
  257 
  258 
  259 
  260 
  261 
  262 
  263 
  264 
  265 
  266 
  267 
  268 
  269 
  270 
  271 
  272 
  273 
  274 
  275 
  276 
  277 
  278 
  279 
  280 
  281 
  282 
  283 
  284 
  285 
  286 
  287 
  288 
  289 
  290 
  291 
  292 
  293 
  294 
  295 
  296 
  297 
  298 
  299 
  300 
  301 
  302 
  303 
  304 
  305 
  306 
  307 
  308 
  309 
  310 
  311 
  312 
  313 
  314 
  315 
  316 
  317 
  318 
  319 
  320 
  321 
  322 
  323 
  324 
  325 
  326 
  327 
  328 
  329 
  330 
  331 
  332 
  333 
  334 
  335 
  336 
  337 
  338 
  339 
  340 
  341 
  342 
  343 
  344 
  345 
  346 
  347 
  348 
  349 
  350 
  351 
  352 
  353 
  354 
  355 
  356 
  357 
  358 
  359 
  360 
  361 
  362 
  363 
  364 
  365 
  366 
  367 
  368 
  369 
  370 
  371 
  372 
  373 
  374 
  375 
  376 
  377 
  378 
  379 
  380 
  381 
  382 
  383 
  384 
  385 

  386 
  387 
  388 
  389 
  390 
  391 
  392 
  393 
  394 
  395 
  396 
  397 

  398 
  399 
  400 
  401 
  402 
  403 
  404 
  405 
  406 
  407 
  408 
  409 
  410 
  411 
  412 
  413 
  414 
  415 
  416 
  417 
  418 
  419 
  420 
  421 
  422 
  423 
  424 
  425 
  426 
  427 
  428 
  429 
  430 
  431 
  432 
  433 
  434 
  435 
  436 
  437 
  438 
  439 
  440 
  441 
  442 
  443 
  444 
  445 
  446 
  447 
  448 
  449 
  450 
  451 
  452 
  453 
  454 
  455 
  456 
  457 
  458 
  459 
  460 
  461 
  462 
  463 
  464 
  465 
  466 
  467 
  468 
  469 
  470 
  471 
  472 
  473 
  474 
  475 
  476 
  477 
  478 
  479 
  480 
  481 
  482 
  483 
  484 
  485 
  486 
  487 
  488 
  489 
  490 
  491 
  492 
  493 
  494 
  495 
  496 
  497 
  498 
  499 
  500 
  501 
  502 
  503 
  504 
  505 
  506 
  507 
  508 
  509 
  510 
  511 
  512 
  513 
  514 
  515 
  516 
  517 
  518 
  519 
  520 
  521 
  522 
  523 
  524 
  525 
  526 
  527 
  528 
  529 
  530 
  531 
  532 
  533 
  534 
  535 
  536 
  537 
  538 
  539 
  540 
  541 
  542 
  543 
  544 
  545 
  546 
  547 
  548 
  549 
  550 
  551 
  552 
  553 
  554 
  555 
  556 
  557 
  558 
  559 
  560 
  561 
  562 
  563 
  564 
  565 
  566 
  567 
  568 
  569 
  570 
  571 
  572 
  573 
  574 
  575 
  576 
  577 
  578 
  579 
  580 
  581 
  582 
  583 
  584 
  585 
  586 
  587 
  588 
  589 
  590 
  591 
  592 
  593 
  594 
  595 
  596 
  597 
  598 
  599 
  600 
  601 
  602 
  603 
  604 
  605 
  606 
  607 
  608 
  609 
  610 
  611 
  612 
  613 
  614 
  615 
  616 
  617 
  618 
  619 
  620 
  621 
  622 
  623 
  624 

  625 
  626 
  627 
  628 
  629 
  630 
  631 
  632 
  633 
  634 
  635 
  636 
  637 
  638 
  639 
  640 
  641 
  642 
  643 
  644 
  645 
  646 
  647 
  648 
  649 
  650 
  651 
  652 
  653 
  654 
  655 
  656 
  657 
  658 
  659 
  660 
  661 
  662 
  663 
  664 
  665 
  666 
  667 
  668 
  669 
  670 
  671 
  672 
  673 
  674 
  675 
  676 
  677 
  678 
  679 
  680 
  681 
  682 
  683 
  684 
  685 
  686 
  687 
  688 
  689 
  690 
  691 
  692 
  693 
  694 
  695 
  696 
  697 
  698 
  699 
  700 
  701 
  702 
  703 
  704 
  705 
  706 
  707 
  708 
  709 
  710 
  711 
  712 
  713 
  714 
  715 
  716 
  717 
  718 
  719 
  720 
  721 
  722 
  723 
  724 
  725 
  726 
  727 
  728 
  729 
  730 
  731 
  732 
  733 
  734 
  735 
  736 
  737 
  738 
  739 
  740 
  741 
  742 
  743 
  744 
  745 
  746 
  747 
  748 
  749 
  750 
  751 
  752 
  753 
  754 
  755 
  756 
  757 
  758 
  759 
  760 
  761 
  762 
  763 
  764 
  765 
  766 
  767 
  768 
  769 
  770 
  771 
  772 
  773 
  774 
  775 
  776 
  777 
  778 
  779 
  780 
  781 
  782 
  783 
  784 
  785 
  786 
  787 
  788 
  789 
  790 
  791 
  792 
  793 
  794 
  795 
  796 
  797 
  798 
  799 
  800 
  801 
  802 
  803 
  804 
  805 
  806 
  807 
  808 
  809 
  810 
  811 
  812 
  813 
  814 
  815 
  816 
  817 
  818 
  819 
  820 
  821 
  822 
  823 
  824 
  825 
  826 
  827 
  828 
  829 
  830 
  831 
  832 
  833 
  834 
  835 
  836 
  837 
  838 
  839 
  840 
  841 
  842 
  843 
  844 
  845 
  846 
  847 
  848 
  849 
  850 
  851 
  852 
  853 
  854 
  855 
  856 
  857 
  858 
  859 
  860 
  861 
  862 
  863 
  864 
  865 
  866 
  867 
  868 
  869 
  870 
  871 
  872 
  873 
  874 
  875 
  876 
  877 
  878 
  879 
  880 
  881 
  882 
  883 
  884 
  885 
  886 
  887 
  888 
  889 
  890 
  891 
  892 
  893 
  894 
  895 
  896 
  897 
  898 
  899 
  900 
  901 
  902 
  903 
  904 

  905 
  906 
  907 
  908 
  909 
  910 
  911 
  912 
  913 
  914 
  915 
  916 
  917 
  918 
  919 
  920 
  921 
  922 
  923 
  924 
  925 
  926 
  927 
  928 
  929 
  930 
  931 
  932 
  933 
  934 
  935 
  936 
  937 
  938 
  939 
  940 
  941 
  942 
  943 
  944 
  945 
  946 
  947 
  948 
  949 
  950 
  951 
  952 
  953 
  954 
  955 
  956 
  957 
  958 
  959 
  960 
  961 
  962 
  963 

  964 
  965 
  966 
  967 
  968 
  969 
  970 
  971 
  972 
  973 
  974 
  975 
  976 
  977 
  978 
  979 
  980 
  981 
  982 
  983 
  984 
  985 
  986 
  987 
  988 
  989 
  990 
  991 
  992 
  993 
  994 
  995 
  996 
  997 
  998 
  999 
 1000 
 1001 
 1002 
 1003 
 1004 
 1005 
 1006 
 1007 
 1008 
 1009 
 1010 
 1011 
 1012 
 1013 
 1014 
 1015 
 1016 
 1017 
 1018 
 1019 
 1020 
 1021 
 1022 
 1023 
 1024 
 1025 
 1026 
 1027 
 1028 
 1029 
 1030 
 1031 
 1032 
 1033 
 1034 
 1035 
 1036 
 1037 
 1038 
 1039 
 1040 
 1041 
 1042 
 1043 
 1044 
 1045 
 1046 
 1047 
 1048 
 1049 
 1050 
 1051 
 1052 
 1053 
 1054 
 1055 
 1056 
 1057 
 1058 
 1059 
 1060 
 1061 
 1062 
 1063 
 1064 
 1065 
 1066 
 1067 
 1068 
 1069 
 1070 
 1071 
 1072 
 1073 
 1074 
 1075 
 1076 
 1077 
 1078 
 1079 
 1080 
 1081 
 1082 
 1083 
 1084 
 1085 
 1086 
 1087 
 1088 
 1089 
 1090 
 1091 
 1092 
 1093 
 1094 
 1095 
 1096 
 1097 
 1098 
 1099 
 1100 
 1101 
 1102 
 1103 
 1104 
 1105 
 1106 
 1107 
 1108 
 1109 
 1110 
 1111 
 1112 
 1113 
 1114 
 1115 
 1116 
 1117 
 1118 
 1119 
 1120 
 1121 
 1122 
 1123 
 1124 
 1125 
 1126 
 1127 
 1128 
 1129 
 1130 
 1131 
 1132 
 1133 
 1134 
 1135 
 1136 
 1137 
 1138 
 1139 
 1140 
 1141 
 1142 
 1143 
 1144 
 1145 
 1146 
 1147 
 1148 
 1149 
 1150 
 1151 
 1152 
 1153 
 1154 
 1155 
 1156 
 1157 
 1158 
 1159 
 1160 
 1161 
 1162 
 1163 
 1164 
 1165 
 1166 
 1167 
 1168 
 1169 
 1170 
 1171 
 1172 
 1173 
 1174 
 1175 
 1176 
 1177 
 1178 
 1179 
 1180 
 1181 
 1182 
 1183 
 1184 
 1185 
 1186 
 1187 
 1188 
 1189 
 1190 
 1191 
 1192 
 1193 
 1194 
 1195 
 1196 
 1197 
 1198 
 1199 
 1200 
 1201 
 1202 
 1203 
 1204 
 1205 
 1206 
 1207 
 1208 
 1209 
 1210 
 1211 
 1212 
 1213 
 1214 
 1215 
 1216 
 1217 
 1218 
 1219 
 1220 
 1221 
 1222 
 1223 
 1224 
 1225 
 1226 
 1227 
 1228 
 1229 
 1230 
 1231 
 1232 
 1233 
 1234 
 1235 
 1236 
 1237 
 1238 
 1239 
 1240 
 1241 
 1242 
 1243 
 1244 
 1245 
 1246 
 1247 
 1248 
 1249 
 1250 
 1251 
 1252 
 1253 
 1254 
 1255 
 1256 
 1257 
 1258 
 1259 
 1260 
 1261 
 1262 
 1263 
 1264 
 1265 
 1266 
 1267 
 1268 
 1269 
 1270 
 1271 
 1272 
 1273 
 1274 
 1275 
 1276 
 1277 
 1278 
 1279 
 1280 
 1281 
 1282 
 1283 
 1284 
 1285 
 1286 
 1287 
 1288 
 1289 
 1290 
 1291 
 1292 
 1293 
 1294 
 1295 
 1296 
 1297 
 1298 
 1299 
 1300 
 1301 
 1302 
 1303 
 1304 
 1305 
 1306 
 1307 
 1308 
 1309 
 1310 
 1311 
 1312 
 1313 
 1314 
 1315 
 1316 
 1317 
 1318 
 1319 
 1320 
 1321 
 1322 
 1323 
 1324 
cat -v -t -e [file]
/* Show non-printing characters */
=======================================

     
     
dumpadm -d swap
/* Configure swap device as dump device */
=======================================

     
     
ld -l <libname without 'lib'>
/* Check if you have a particular library */
=======================================

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

     
     
truss executable
/* Trace doing of given command ( useful debugging ) */
=======================================

     
     
Disk Commands
/bin/mount -F hsfs -o ro /dev/sr0 /cdrom
/* Mount an ISO 9660 CDROM */
=======================================

     
     
/usr/bin/iostat -E
/* Command to display drives statistics */
=======================================

     
     
du -ad /var | sort -nr
/* Report the the disk used in /var in reverse order */
=======================================

     
     
du -k .
/* Report disk usage in Kilobytes */
=======================================

     
     
du -sk * | sort -nr | head
/* Shows the top ten largest files/directories */
=======================================

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

     
     
du -sk .
/* Report total disk usage in Kilobytes */
=======================================

     
     
fdformat -d -U
/* Format diskette */
=======================================

     
     
mount -F hsfs -o ro `lofiadm -a /export/temp/software.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. */
=======================================

     
     
Driver Parameters
ndd /dev/ip ip_forwarding
/* Show the ip_forwarding variable in the kernel */
=======================================

     
     
ndd /dev/ip ip_forwarding 1
/* Set the ip_forwarding variable in the kernel */
=======================================

     
     
ndd /dev/ip \?
/* Show all IP variables set in the kernel */
=======================================

     
     
File Manipulation
dos2unix | -ascii <filename>
/* Converts DOS file formats to Unix */
=======================================

     
     
fold -w 180
/* To break lines to have maximum char */
=======================================

     
     
split [-linecount] [file]
/* Split files into pieces */
=======================================

     
     
[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
/sbin/uadmin x x
/* Syncs File Systems and Reboots systems fast */
=======================================

     
     
awk ' END {print NR}' file_name
/* Display the Number of lines in a file */
=======================================

     
     
cat /dev/null > filename
/* Zero's out the file without breaking pipe */
=======================================

     
     
cksum [filename]
/* View the checksum value for the given file */
=======================================

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

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

     
     
fsck -F ufs -o b=97472 /dev/rdsk/c0t0d0s0
/* Check and repair a UFS filesystem on c0t0d0s0, using an alternate superblock 
  */
=======================================

     
     
fsck -F ufs -y /dev/rdsk/c0t0d0s0
/* Check a UFS filesystem on c0t0d0s0, repair any problems without prompting. 
  */
=======================================

     
     
fsck -F ufs /dev/rdsk/c0t0d0s0
/* Check a UFS filesystem on c0t0d0s0 */
=======================================

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

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

     
     
ln [-fhns] <source file> <destination file>
/* Creating hard links and soft links */
=======================================

     
     
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,"    ",$9 }' | sort -rn
/* File sizes of current directory */
=======================================

     
     
ls -lR | awk '{total +=$5};END {print "Total size: " total/1024/1024 "MB" }'
/* Recursive directory size calculations in MB */
=======================================

     
     
mkisofs -l -L -r -o [image-name].iso [directory]
/* Create an ISO image of a directory */
=======================================

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

     
     
mount -o remount,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]{,.new_suffix}
/* Renaming file */
=======================================

     
     
pax -rw . /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 */
=======================================

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

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

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

     
     
X=$(wc -l < filename); echo $X
/* Count number of lines in a file into a variable (ksh) */
=======================================

     
     
zcat <patch_file.tar.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
find . -depth | cpio -pdmv /path/tobe/copied/to
/* Fast alternative to cp -pr */
=======================================

     
     
find . -follow | cpio -pdumL /path/tobe/copied/to
/* Copy with symbolic links to be followed */
=======================================

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

     
     
Move any file(s) without actually touching them
/* ssh cd /some/directory \&\& tar cf - | ssh cd /some/direstory \&\& tar xvf - 
  */
=======================================

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

     
     
sendport
/* FTP command for transferring large numbers of files within the same control 
  session */
=======================================

     
     
General
/bin/printf '%d\n' '0x<hex>'
/* Converts hexadecimal number to decimal. */
=======================================

     
     
/usr/bin/catman -w
/* Create windex databases for man page directories */
=======================================

     
     
echo 'obase=16;255' | bc
/* Simple way to convert decimal to hex */
=======================================

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

     
     
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
cfgadm
/* Verify reconfigurable hardware resources */
=======================================

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

     
     
m64config -prconf
/* Print M64 hardware configuration */
=======================================

     
     
m64config -res 'video_mode'
/* Change the resolution of your M64 graphics accelerator */
=======================================

     
     
prtpicl -v | grep sync-speed
/* Discover SCSI sync speed */
=======================================

     
     
Kernel
/usr/sbin/modinfo
/* Display kernel module information */
=======================================

     
     
/usr/sbin/modload <module>
/* 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 .conf file without reloading the driver */
=======================================

     
     
Memory
pagesize -a
/* Available page sizes for Solaris 9 */
=======================================

     
     
prtconf | grep Mem
/* Display Memory Size of the local machine. */
=======================================

     
     
Network Information
arp -a
/* Ethernet address arp table */
=======================================

     
     
arp -d myhost
/* Delete an ethernet address arp table entry */
=======================================

     
     
lsof -iTCP@10.20.2.9
/* Display open files for internet address */
=======================================

     
     
named-xfer -z qantas.com.au -f /tmp/allip
/* Get All IP Addresses On A DNS Server */
=======================================

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

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

     
     
netstat -a | more
/* Show the state of all the sockets on a machine */
=======================================

     
     
netstat -i
/* Show the state of the interfaces used for TCP/IP 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. */
=======================================

     
     
snoop -S -ta [machine]
/* Snoop for network packets and get size and time stamp entries. */
=======================================

     
     
traceroute <ipaddress>
/* Follow the route to the ipaddress */
=======================================

     
     
Network Tuning
/sbin/ifconfig hme0:1 inet 10.210.xx.xxx netmask 255.255.0.0 broadcast 
  10.210.xxx.xxx
/* Virtual Interfaces */
=======================================

     
     
/sbin/ifconfig hme0:1 up
/* Bring virtual interface up */
=======================================

     
     
/usr/sbin/ndd -set /dev/hme adv_100fdx_cap 1
/* Nailling to 100Mbps */
=======================================

     
     
ifconfig eth0 10.1.1.1 netmask 255.255.255.255
/* Add an Interface */
=======================================

     
     
ifconfig eth0 mtu 1500
/* Change MTU of interface */
=======================================

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

     
     
ndd -set /dev/tcp tcp_recv_hiwat 65535
/* Increase TCP-receivebuffers on Sol2.5.1 systems with 100BaseTx */
=======================================

     
     
ndd -set /dev/tcp tcp_xmit_hiwat 65535
/* Increase TCP-transmitbuffers on Sol2.5.1 systems with 100BaseTx */
=======================================

     
     
Processes
/usr/proc/bin/ptree <pid>
/* Print the parent/child process 'tree' of a process */
=======================================

     
     
/usr/proc/bin/pwdx <pid>
/* Print the working directory of a process */
=======================================

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

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

     
     
coreadm -i core.%f.%p
/* Append program name and process id to core file names */
=======================================

     
     
fuser -uc /var
/* Processes that are running from /var */
=======================================

     
     
ipcs
/* Report inter-process communication facilities status */
=======================================

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

     
     
lsof -i TCP:25
/* Mapping port with process */
=======================================

     
     
pfiles <pid>
/* Shows processes' current open files */
=======================================

     
     
pkill -n <name>
/* Kill a process by name */
=======================================

     
     
prstat -a
/* An alternative for top command */
=======================================

     
     
ps -edf -o pcpu,pid,user,args
/* Nicely formatted 'ps' */
=======================================

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

     
     
ps -ef | grep -i <string> | awk '{ print $2 }'
/* 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,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
/usr/bin/ldd [filename]
/* List the dynamic dependencies of executable files */
=======================================

     
     
/usr/proc/bin/pmap pid
/* Report address space map a process occupies */
=======================================

     
     
Route Configuration
route add net 128.50.0.0 128.50.1.6 1
/* Add a route to the routing table */
=======================================

     
     
route change 128.50.0.0 128.50.1.5
/* Changes the destination address for a route */
=======================================

     
     
route delete net 128.50.0.0 128.50.1.6
/* Delete a route from the routing table */
=======================================

     
     
route flush
/* Flush the routing table, which will remove all entries */
=======================================

     
     
route get [hostname]
/* Which interface will be used to contact hostname */
=======================================

     
     
route monitor
/* Monitor routing table lookup misses and changes */
=======================================

     
     
Searching Items
cat <filename> | awk '{if (substr($1,1,1) == '#') print $0 }'
/* Print all lines in a file beginning with a specific character */
=======================================

     
     
egrep "patterna|patternb" <filename>
/* Search for multiple patterns within the same file */
=======================================

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

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

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

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

     
     
find . -mtime -1 -type f
/* Find recently modified files */
=======================================

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

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

     
     
find ./ \! -type f -exec ls -l {} \;|grep -v '^[l|p|s|-]'|grep -v 'total' | wc 
  -l
/* Find number of directories under the current directory */
=======================================

     
     
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,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. */
=======================================

     
     
pkgchk -l -p /absolute/path/todir
/* Which package does this file belong to? */
=======================================

     
     
Security
crypt <abc.cr> abc && rm abc.cr
/* Decrypting a file that has been encrypted */
=======================================

     
     
crypt <abc> abc.cr && rm abc
/* File encryption with crypt */
=======================================

     
     
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
stty erase ^?
/* Set the delete key to delete a character */
=======================================

     
     
stty erase ^H
/* Set the backspace to delete a character */
=======================================

     
     
stty sane
/* Reset terminal after viewing a binary file. */
=======================================

     
     
tput rmacs
/* Reset to standard char set */
=======================================

     
     
Snoop
snoop -d pcelx0
/* Watch all the packets on a device */
=======================================

     
     
snoop -i /tmp/mylog -o /tmp/newlog host1
/* Filter out all the host1 packets and write them to a new logfile */
=======================================

     
     
snoop -i /tmp/mylog -v -p101
/* Show verbose info on packet number 101 in the logfile */
=======================================

     
     
snoop -i /tmp/mylog host1 host2
/* View packets from a logfile between hosts1 and 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
mkfile -nv 10m /export/disk1/myswap
/* Makes an empty 10 Megabyte swapfile in /export/disk */
=======================================

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

     
     
Swap Space
swap -a /export/disk1/swapfile
/* Add a swap file */
=======================================

     
     
swap -d /dev/dsk/c0t0d0s4
/* Delete a swap device */
=======================================

     
     
swap -l
/* List the current swap devices */
=======================================

     
     
swap -s
/* List the amount of swap space available */
=======================================

     
     
System Configuration
/usr/sbin/eeprom auto-boot? false
/* Changes eeprom autoboot? setting without going to Ok prompt */
=======================================

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

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

     
     
/usr/sbin/grpck
/* 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 ; disks
/* Adding hot-plug disks to system */
=======================================

     
     
System Information/Monitoring
/bin/echo "0t${stamp}>Y\n<Y=Y" | adb
/* Convert UNIX timestamp to something human-readable */
=======================================

     
     
/usr/sbin/eeprom
/* Show eeprom parameters */
=======================================

     
     
/usr/sbin/prtconf -vp
/* Show system configuration details */
=======================================

     
     
coreadm -e log
/* Report global core */
=======================================

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

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

     
     
last
/* Tells who was or still is on the system */
=======================================

     
     
logger -i
/* Log the process ID */
=======================================

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

     
     
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. */
=======================================

     
     
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. */
=======================================

     
     
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. */
=======================================

     
     

Comments
Search
Only registered users can write comments!

!joomlacomment 4.0 Copyright (C) 2009 Compojoom.com . All rights reserved."

Last Updated on Friday, 20 March 2009 04:10
 

Founder MJ12Net

Founder MJ12Net.org

Brian Bills
Founder MJ12Net
System Admin

Stumble Us

Valid XHTML & CSS | Template Design ah-68 | Copyright © 2009 by Firma