Thursday, August 1, 2013

Solaris Commands


  • uname -a 
    • To know the server information like operating system,servername,osversion
  • uptime
    • show how long the system has been up
  • last reboot
    • Display the server reboot information including last reboot time

ls Commands
  • ls  (Display the list of file)
  • ls  |head  (Display the first 10 files in the folder)
  • ls | head -n  (Display the first "n" number of files)
  • ls |tail (Display the last 10 files in a folder)
  • ls |tail -n (Display the last "n" numbers of files)
  • ls -a (Display the hidden files and normal fiels.Hidden files begin with a ".", i.e. ".htaccess" files.
  • ls -l|grep '^d' :To Display only Directories
  • ls -l |wc -l  To know the count of the files  in a directory
  • ls -lrt | grep -v "distribute*" | xargs zip logs_1.zip $*
  • ls d -1 $PWD/* > /tmp/ans/temp.txt
  • ls -f -1 $PWD/* > /tmp/ans/temp.txt
  • ls -l test.sh |cut -f18 -d' ' : To know the time stamp of the current file
  • sed '3d' fileName.txt (Remove the 3rd line)
  • sed '7,9d' filename.txt (Remove the interval between lines 7 and 9)
grep Commands
  • grep -n "1311179383812" file.txt (To find the line number of a word in file)
  • grep -w -c \"text\" file name (To find the count of the word in file)
  • jps -l (To Know the process id and arguments of java process)
Note: It is working in only solaris

Find Commands
  • find . -type f -exec grep -l "string" {} + 
    • Find the file names which contains the string in current and sub folders.         
  • find . -name '*.jsp' -exec touch {} \;
    • Find the jsp file names and update the time stamp of the jsp files.
Touch Commands
  • touch -t 200908201024 touch.txt 
    • To change the time stamp of the file to our choice        
prstat -Z

To know the cpu utilization in local zone
ZONEID    NPROC  SWAP   RSS       MEMORY    TIME                CPU ZONE
     2            57           4160M  3857M   1.5%              10:06:52 0.3%   tst-server


Change file or Directory ownership 

chown (change ownership command change the ownership of the file or directory)

chown  user2 temp.txt : It changes the ownership of the temp.txt file  to user2

chown -R java_user * :It changes the all files , directories and sub directories ownership  to java_user

  • netstat -an |grep -i "LISTEN"
    • To know the list of listen ports in a machine       
  • netstat -a |grep 7001
    • To know whether port 7001 is listen or not
  • showrev -p
    • To know the applied patched in solaris
  • showrev -a | grep "126546-05"
Patch: 126546-05 Obsoletes:  Requires:  Incompatibles:  Packages: SUNWbash, SUNWsfman
Patch: IDR151577-01 Obsoletes:  Requires: 126546-05 Incompatibles: 126546-06 Packages: SUNWbash
  • wget Commad
wget command location in solaris is : /usr/sfw/bin/wget

Usage:  wget http://ramaprasad434.blogspot.in/2013/07/solaris-commands.html




No comments:

Post a Comment