Showing posts with label Solaris. Show all posts
Showing posts with label Solaris. Show all posts

Monday, October 6, 2014

VI commands

  • vi test.txt     > create the file using the vi command
  • :q!                > quit the VI editor without save
  • :wq!             > save and quit the VI editor
  • shift + g (G) > Move  the cursor to the end of the file
  • g                  > Move cursor to the first line of the file
  • i                   >The characters typed in will be inserted before the current cursor position
  • I                   >The characters typed in will be inserted in first of the current line
  • Shift + A     >The characters typed in will be inserted in end of the current line
  • x                  > Delete the  character under the cursor
  • {number}x  > Delete the character under the cursor and next n number right characters
  • X                 >Delete the  character before the cursor
  • {number}X > Delete the n number characters before the cursor position (Not the cursor)
  • u                  >Undo the last change to the file. Typing u again will re-do the change. 
  • dd                > Delete the current line 
  • {number}dd > Remove the n number of lines down wards include current line
  • d{number}k > Delete the n  number of above lines including current line
  • d{number}j  > Delete the n number of down lines including current line
  • :3,18d        >delete lines 3 through 18
  • :1,$d              > Delete the all lines in file
  • :n  + Enter    > Go to nth line in a file Ex; :10 + ENTER
  • h                    >Move the cursor to the left one character position. 
  • j                     >Move the cursor down one line. 
  • k                    >Move the cursor up one line. 
  • l                     >Move the cursor to the right one character position. 
  • d^                  >Deletes from current cursor position to the beginning of the line. 
  • d$                  >Deletes from current cursor position to the end of the line. 
  • dw                  >Deletes from current cursor position to the end of the word. 
  • db                  > Deletes from current cursor position to the starting of the word
  • :1,$s/up/right/ > To Replace string Ex:1,$s/test1/test2
  • 16,25m30  > Move lines 16 through 25 to after line 30
  • 23,29co62 > Copy specified lines and place after line 62

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




Cron Tab


Cron is a UNIX, Solaris utility that allows tasks to be automatically run in the background at regular intervals by the cron daemon. These tasks are often termed as cron jobs in UNIX, Solaris.  Crontab (CRON TABle) is a file which contains the schedule of cron entries to be run and at specified times.

1. Crontab Restrictions

You can execute crontab if your name appears in the file /usr/lib/cron/cron.allow. If that file does not exist, you can use crontab if your name does not appear in the file /usr/lib/cron/cron.deny.

If only cron.deny exists and is empty, all users can use crontab. If neither file exists, only the root user can use crontab. The allow/deny files consist of one user name per line.

2. Crontab Commands

export EDITOR=vi ;To specify a editor to open crontab file.

crontab -e    Edit your crontab file, or create one if it doesn’t already exist.

crontab -l      Display your crontab file.

crontab -r      Remove your crontab file.

crontab -v      Display the last time you edited your crontab file. (This option is only available on a few systems.)

3. Crontab file

Crontab syntax:

A crontab file has five fields for specifying day, date and time followed by the command to be run at that interval.

*     *       *           command to be executed
-     -     -   -    -
|     |     |   |    |
|     |     |   |    +----- day of week (0 - 6) (Sunday=0)
|     |     |   +------- month (1 - 12)
|     |     +--------- day of        month (1 - 31)
|     +----------- hour (0 - 23)

+------------- min (0 - 59)

Example:

0 6 * * 1 cd /data/test; ksh test.sh 1>>/logs/Test.log 2>>/logs/TestError.log

  •  Fist 0 indicates the min
  •  second "6" indicates the hour 6
  •   last "1" indicates the Moday

Here cron job will run every Monday 6 AM

  •  Test.log contians the normal SOP statements
  • TestError.log Contains the error and stack statements 

Mailx Command

Mailx Command to send the files from solaris box

For Single file
uuencode file1.txt file1.txt |mailx -s "Subject"  <Mail id>
Ex:uuencode Diff.text Diff.text |mailx -s " Difference" ramprasad@gmail.com

For multiple Files :