Monday, March 29, 2010

Run the last command as ROOT

There are many privileged commands which you run as non-prev user only to get error or moy desired output. Then you think like sudo and type the same command again.
We can type sudo !! to execute the last command as PRIV user

Sunday, March 28, 2010

How to know the status of all the running services

There are many commands like netstat -plant,ps -aux but when you want to know all the services which are running presently into your RHEL box, service --status-all command is very handy . It shows all the running services into your box.

Quit from shell without saving into history

There are many instances when we want to quit from shell without saving any command in history. We might have run by mistake some rookie command and you dont want to disclose it to others.

kill -9 $$ will do the needful as $$ will provide the PID of the current shell.

Saturday, March 27, 2010

Keyboard shortcuts for shell

Some useful and more often used keyboard short cuts in bash shell under Mac

1)CTRL + A Move to the start of the line.

2)CTRL + E Move to the end of the line.( e for END)

3)CTRL + W Delete word backwards

4)CTRL + U Delete whole line backwards.(Delete from the cursor to the beginning of the line,If cursor is at the end of the line, it will delete the whole line) It can also be used to delete whole line if you are at the end of the command and you wish not to execute it.

5)CTRL + k Delete from the cursor to the end of the line.(Delete WHOLE LINE,if the cursor is in the starting,it will delete whole line)
Place the cursor in the right place and press Either U or K to delete rest of the line

6)CTRL + R to Search history. Press escape to verify and enter to execute

7)CTRL + L To clear line leaving the last line on the screen.