How to Use watch Command
If you need to execute a certain command repeatedly, you may use the watch command to do the repeating for you.
In this example, the command ps will be run every 2 seconds to monitor how fast the new processes spawn:
$ watch -n2 "ps aux|grep http"
The watch command will run ps every two seconds and it will display the output in stdout. You may increase or decrease the interval as necessary. This is useful if you want to monitor a process at certain time intervals. Personally, I use this to check for processes that spawns children way too fast.
How to Use the alias Command
Let us say you execute the command ‘ls –alh’ every time you need a long listing of files and directories. Now you want a shortcut to do this. Fortunately, you can do so by using the command alias.
The alias command is useful for creating shortcuts for long commands or for correcting typing mistakes.
To create a shortcut for ls, you can do this:
$ alias ls=”ls -alh”
Now, everytime you execute ls command, it will be run as if you are executing the whole ls –alh command. Be reminded that this will replace the existing ls command. You may use a different name for the new shortcut like so:
$ alias ll=”ls -alh”
However, once you exit the current terminal, the alias will not be saved. To make the alias permanent, you may edit the .bashrc file in user’s home directory:
$ vi ~rai/.bashrc
Then insert the alias command after the line that says #system wide functions and aliases. Save and exit.
That should do it!
Search PinoyTux
Subscribe to Email Feeds
Blog Lounge
Popular Posts
Recent Posts
Drop your Card Here
Recent Comments
- Anidich1 on Tip: Add User and Generate Password Script
- Tom S on Cebu Pacific Sucks
- kadersardar on PinoyTux Spreads Some CommentLuv
- Steve on Creative Labs Threatens Third Party Driver Modder
- Barry on Free Laptops with Broadband Connection








