Archive for the ‘linux’ Category

Linux Tips

Display the top most process utilizing most CPU (top -b 1)
Show the working directory of a process ? (pwdx pid )
Display the parent/child tree of a process ? (ptree pid )
Display the no.of active established connections to localhost ? (netstat -a | grep EST)
How to create null file ? (cat /dev/null > filename1)
Display top ten largest files/directories ? (du -sk * | sort -nr | head)
Display disk usage (du -h)
How to save man pages to a file ? (man | col -b > filename )
Display the files in the directory by file size ? (ls -ltr | sort -nr -k 5)
Display the processes, which are running under yourusername ( ps -aef | grep username)
Display the all files recursively with path under current directory ? ( find . -depth -print)
Display the Disk Usage of file sizes under each directory in currentDirectory ? (du -k . | sort -nr)
List the files in current directory sorted by size ? (ls -l | grep ^- | sort -nr)

Read Full Post »

There are some variables which are set internally by the shell and which are available to the user:

$1 - $9   These variables are the positional parameters.
$0        The name of the command currently being executed.
$#        The number of positional arguments given to this invocation of the shell.
$?        The exit status of the last command executed is given as a decimal string.        When a command completes successfully, it returns the exit status of 0        (zero), otherwise it returns a non-zero exit status.
$$        The process number of this shell - useful for including in filenames, to        make them unique.
$!        The process id of the last command run in the background.
$-        The current options supplied to this invocation of the shell.
$*        A string containing all the arguments to the shell, starting at $1.
$@@       Same as above, except when quoted.

Read Full Post »