{"id":168,"date":"2008-12-11T11:46:02","date_gmt":"2008-12-11T15:46:02","guid":{"rendered":"http:\/\/jianmingli.com\/wp\/?p=168"},"modified":"2013-07-20T14:31:02","modified_gmt":"2013-07-20T19:31:02","slug":"solaris-commands","status":"publish","type":"post","link":"https:\/\/jianmingli.com\/wp\/?p=168","title":{"rendered":"Solaris Commands"},"content":{"rendered":"<p>who (who is on the system)<br \/>\nwho -b (when was last reboot)<br \/>\nwho -r (current run level)<br \/>\nw (who is doing what)<\/p>\n<p>df -h (disk usage info in human readable form)<\/p>\n<p>Unix commands<\/p>\n<p>\u00a7cut<br \/>\n\tCut out columns from a table or fields from each line of a file<br \/>\n\u2022cut -c5<br \/>\n\tcut out at character 5<br \/>\n\u2022cut -c1,5,10<br \/>\n\tcut out at chars 1, 5, 10<br \/>\n\u2022cut -c1-10<br \/>\n\tinclusive from 1 to 10<br \/>\n\u2022cut -c5-<br \/>\n\tto eol<br \/>\n\u2022cut -d: -f1 \/etc\/password<br \/>\n\tuse : as delimiter<br \/>\n\tcut at field 1<br \/>\n\u2022cut -f1<br \/>\n\tdefault to -dTab<br \/>\n\u2022sed -n l file<br \/>\n\tprint tab as ><\/p>\n<p>\u00a7paste<br \/>\n\tConcatenate lines of input files.<br \/>\n\u2022paste files<br \/>\n\tConcatenate lines of input files.<br \/>\n\u2022paste -d&#8217;+&#8217; files<br \/>\n\tUse + instead of TAB to replace NEWLINE charactem<br \/>\n\u2022paste -s file<br \/>\n\tConcatenate all lines of each file except the last line<\/p>\n<p>\u00a7sed<br \/>\n\u2022sed &#8216;s\/unix\/UNIX\/&#8217; file<br \/>\n\treplace 1st occurance<br \/>\n\u2022sed &#8216;s\/unix\/UNIX\/g&#8217; file<br \/>\n\treplace all occurance<br \/>\n\u2022who | sed &#8216;s\/ .*$\/\/&#8217;<br \/>\n\tdel<br \/>\n\u2022sed -n &#8216;1,2p&#8217; file<br \/>\n\tprint 1st 2 lines<br \/>\n\u2022sed -n &#8216;\/UNIX\/p&#8217; file<br \/>\n\tprint all lines w\/ UNIX<br \/>\n\u2022sed &#8216;1,2d&#8217; file<br \/>\n\tdelete 2 lines<br \/>\n\u2022sed &#8216;\/UNIX\/d&#8217; file<br \/>\n\tdelete UNIX<br \/>\n\u2022sed -n &#8216;l&#8217; file<br \/>\n\ttab as ><br \/>\n\u2022Replace all occurrance of c:\/Perl to \/usr\/perl in all perl scripts in current directory<\/p>\n<pre lang=\"xml\">for i in 'ls *.pl'\r\ndo\r\n fileName='echo $i | awk -F\".\" { print $1 }'\r\n sed 's\/c:\\\/Perl\/\\\/usr\\\/perl\/' $i > $fileName.new\r\n cp $fileName.new $fileName.pl\r\ndone\r\n<\/pre>\n<p>\u00a7tr\t\t\tworks on single char<br \/>\n\u2022tr : &#8216;\t&#8216;<br \/>\n\tcolon to tab<br \/>\n\u2022tr &#8216;[a-z]&#8217; &#8216;[A-Z]&#8217;\tto upper case<br \/>\n\u2022tr -s &#8216; &#8216; &#8216; &#8216;\t\t\tsqueeze out mult<br \/>\n\u2022tr -d &#8216; &#8216; < file\t\tdel all spaces\n\u2022tr '\\012' ' '\tchange new line char to space. Same as \nawk '{printf \"%s \",$0}'\n\n\n\u00a7grep\n\u2022grep pattern files\n\u2022grep -i\t\tignore case\n\u2022grep -v\t\tinverse\n\u2022grep -l\t\tlist file names only\n\u2022qrep -n\t\tshow line number\n\n\u00a7sort\n\u2022sort file\n\u2022sort -u\t\tremove dup lines\n\u2022sort -r\t\treverse sort\n\u2022sort file -o sorted_file\n\u2022sort -n file\tsort as number\n\u2022sort +2n file\tskip 2 fields,sort num\n\u2022sort +2n -t:\tdelimit by :\n\n\u00a7uniq\tonly works on consecutive \n\t\tduplicate lines\n\u2022uniq file\n\u2022sort file | uniq\t\tsort,uniq\n\u2022sort \/etc\/password | uniq -d \n\t\t\tlist duplicate lines\n\u2022sort \/etc\/password | cut -f1 -d: | uniq -d\t\tfind dup user id\n\u2022uniq -c\t\tcount dups\n\n\u00a7shift\n\u2022left shift positional parameters by 1\n\u2022shift 3\tleft shift by 3\n\nrestart inetd:\nps -ef | qrep inetd --> qet psid<br \/>\nkill -HUP <psid>\n<p>start inetd<br \/>\n\/etc\/init.d\/inetsvc start<\/p>\n<p><strong>Patch manaqement<\/strong><br \/>\npatchadd<br \/>\npatchrm<br \/>\nshowrev -p<br \/>\npkgparam<\/p>\n<p>Solaris: pkgadd -d <file><br \/>\npkgrm SMCgcc<br \/>\npkginfo<\/p>\n<p>linux:<br \/>\nrpm -iv somefile.rpm<br \/>\nrpm -qa | grep binutils<br \/>\nrpm -Uvh &#8211;force &#8211;nodeps binutils-2.11.90.0.8-13.i386.rpm<\/p>\n<p><strong>Enable root ssh<\/strong><br \/>\n* Edit <em>\/etc\/ssh\/sshd_config<\/em> and set<br \/>\nPermitRootLogin <strong>yes<\/strong><br \/>\n*Restart network services<\/p>\n<pre lang=\"bash\">\r\nsvcadm restart svc:\/network\/ssh:default\r\n<\/pre>\n<p><strong>References<\/strong><br \/>\n<a href=\"http:\/\/www.sun.com\/bigadmin\/shellme\/\">http:\/\/www.sun.com\/bigadmin\/shellme\/<\/a><br \/>\n<a href=\"http:\/\/cb.vu\/unixtoolbox.xhtml\">unixtoolbox<\/a><br \/>\n<a href=\"http:\/\/www.cyberciti.biz\/tips\/linux-unix-commands-cheat-sheets.html\">linux-unix-commands-cheat-sheets<\/a><\/p>\n","protected":false},"excerpt":{"rendered":"<p>who (who is on the system) who -b (when was last reboot) who -r (current run level) w (who is doing what) df -h (disk usage info in human readable form) Unix commands \u00a7cut Cut out columns from a table &hellip; <a href=\"https:\/\/jianmingli.com\/wp\/?p=168\">Continue reading <span class=\"meta-nav\">&rarr;<\/span><\/a><\/p>\n","protected":false},"author":2,"featured_media":0,"comment_status":"closed","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"_exactmetrics_skip_tracking":false,"_exactmetrics_sitenote_active":false,"_exactmetrics_sitenote_note":"","_exactmetrics_sitenote_category":0,"jetpack_post_was_ever_published":false,"_jetpack_newsletter_access":"","_jetpack_dont_email_post_to_subs":false,"_jetpack_newsletter_tier_id":0,"_jetpack_memberships_contains_paywalled_content":false,"_jetpack_memberships_contains_paid_content":false,"footnotes":"","jetpack_publicize_message":"","jetpack_publicize_feature_enabled":true,"jetpack_social_post_already_shared":false,"jetpack_social_options":{"image_generator_settings":{"template":"highway","default_image_id":0,"font":"","enabled":false},"version":2}},"categories":[45],"tags":[],"class_list":["post-168","post","type-post","status-publish","format-standard","hentry","category-solaris"],"jetpack_publicize_connections":[],"jetpack_featured_media_url":"","jetpack_sharing_enabled":true,"jetpack_shortlink":"https:\/\/wp.me\/p8cRUO-2I","_links":{"self":[{"href":"https:\/\/jianmingli.com\/wp\/index.php?rest_route=\/wp\/v2\/posts\/168","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/jianmingli.com\/wp\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/jianmingli.com\/wp\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/jianmingli.com\/wp\/index.php?rest_route=\/wp\/v2\/users\/2"}],"replies":[{"embeddable":true,"href":"https:\/\/jianmingli.com\/wp\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=168"}],"version-history":[{"count":5,"href":"https:\/\/jianmingli.com\/wp\/index.php?rest_route=\/wp\/v2\/posts\/168\/revisions"}],"predecessor-version":[{"id":477,"href":"https:\/\/jianmingli.com\/wp\/index.php?rest_route=\/wp\/v2\/posts\/168\/revisions\/477"}],"wp:attachment":[{"href":"https:\/\/jianmingli.com\/wp\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=168"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/jianmingli.com\/wp\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=168"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/jianmingli.com\/wp\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=168"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}