Useful Unix commands

A few days ago , I was asked to update an existing script and to make it generic for all instances. Though I understood still working in vi editor was difficult in the starting as I always ended up typing unwanted characters while moving the cursors or deleting the entire script instead of a particular line.

Working constantly for a few days I got to know a few useful commands few of them which I am sharing below:

  • To get rid of extra lines in vi editor ,  type esc -> :  -> g/^$/d
  • When you move a file from windows to unix environment you see a ^M character at the end of each line. You can remove them by using dos2unix <filename>  <filename> at the command prompt.
  • To a list of all the commands that has been used recently use history command.
  • Unix is sensitive to extra spaces. Don’t use a space before and after a = operator.
  • To go to home directory type cd ~
  • To delete n lines press esc then <n>dd
  • To go to the end of a line press esc $
  • To go to the begining press esc I
  • To exit and save esc : wq , to exit without saving esc : q!
  • To run the script , go to the script path then type ./<script name> or sh <script name>
  • To display the local queue manager of MQ Series in the server type : dspmq . For remote queue we need a WMQ client.
  • To find the IP address of the server type: grep ‘/etc/hosts/’ | awk ‘{print $0}’
  • To find the environment related details : env
Advertisements

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s