List the files in current directory sorted by size ?
- ls -l | grep ^- | sort -nr
List the hidden files in current directory ?
- ls -a1 | grep “^\.”
Delete blank lines in a file ?
- cat sample.txt | grep -v ‘^$’ > new_sample.txt
What command used to search for a string in particular files ?
- grep <string_to_search> <Filenames>
Command to display the newly appending lines of a file during appendingdata to the same file by some processes ?
- tail -f
Change to a directory, which is having very long name ?
- cd CDMA_3X_GEN*
- Here original directory name is . .CDMA_3X_GENERATION_DATA..
Display the all files recursively with path under current directory ?
- find . -depth -print
Set the Display automatically for the current new user ?
- export DISPLAY=`eval ‘who am i | cut -d”(” -f2 | cut -d”)” -f1′`Here in above command, see single quote, double quote, grave ascent is used. Observe carefully.
Display the processes, which are running under yourusername ?
- ps -aef | grep <username>
List some Hot Keys for bash shell ?
- Ctrl+l . Clears the Screen.
- Ctrl+r . Does a search in previously given commands in shell.
- Ctrl+u – Clears the typing before the hotkey.
- Ctrl+a . Places cursor at the beginning of the command at shell.
- Ctrl+e . Places cursor at the end of the command at shell.
- Ctrl+d . Kills the shell.
- Ctrl+z . Places the currently running process into background.
Display the files in the directory by file size ?
- ls -ltr | sort -nr -k 5
How to save man pages to a file ?
- man <command> | col -b > <output-file>
- Example : man top | col -b > top_help.txt
How to get the Unix system time?
How do you find out drive statistics?
- iostat -E
How to create null file ?
- cat /dev/null > filename1
Access common commands quicker ?
- ps -ef | grep -i $@
Display the page size of memory ?
- pagesize -a
Display Ethernet Address arp table ?
- arp -a
Display the no.of active established connections to localhost ?
- netstat -a | grep EST
Display the state of interfaces used for TCP/IP traffice ?
- netstat -i
Display the parent/child tree of a process ?
- ptree <pid> Example: ptree 1267
- pstree in linux
Show the working directory of a process ?
- pwdx <pid> Example: pwdx 1267
Display the processes current open files ?
- pfiles <pid> Example: pfiles 1267
Display the inter-process communication facility status ?
Display the top most process utilizing most CPU ?
Alternative for top command ?
- prstat -a
Explain iostat, vmstat and netstat.
- Iostat reports on terminal, disk and tape I/O activity.
- Vmstat reports on virtual memory statistics for processes, disk, tape and CPU activity.
- Netstat reports on the contents of network data structures.