OpenSource For You

TIPS &TRICKS

-

The process tree

pstree is a small tool that prints the tree of the processes that are running. It gives you a clear picture of the processes on the system. Basically, the output of pstree is the same as the command ps but with a nice view of the tree with its branches.

While debugging, it is often useful to know which is the parent of a given process. This can be done with ps but you need to keep track of ppid. With the tree of processes, it is much easier to find this out.

pstree starts with the first process, that is init with PID 1, unless otherwise specified. It has very good options to sort and show PIDs, along with names, etc.

For more informatio­n, do check out the man page.

—Rahul Bedarkar, rahulbedar­kar89@gmail.com

Auto-correction of typos

Typing on the command line isn’t easy. First, it takes a lot of time to learn how all the commands work. Then, even after that, you need to be very precise with your file and directory names, otherwise you’ll have to keep trying again and again.

But there’s a way out. Bash has a built-in command called shopt that lets you set various command-line options. For example, running the following command:

#shopt s cdspell

…enables automatic typo correction for directory names, so that when you type the following:

#cd /hom/hudzila

…you will get to the nearest match /home/hudzila if hudzila is not present.

You can also use the command given below:

#shopt s nocaseglob

…so that when you type part of a file name and press Tab it will auto-complete.

—Sachith H.M., sachith@smartbrain­sinfotech.com

Download files directly from Web pages

Given below is a command for downloadin­g an mp3 file directly from a Web page:

wget r l1 H t1 nd N np A.mp3 erobots=off [url of website]

The complete descriptio­n of this command is as follows: -r Recursive

-l1 Maximum recursion depth (1= use only this directory)

-H Span hosts (visit other hosts in the recursion) -t1 Number of retries

 ??  ??
 ??  ??
 ??  ??
 ??  ??

Newspapers in English

Newspapers from India