Unix

top - Display Linux tasks

Display most CPU-intensive processes

More details on the process cat /proc/28400/status

  • -b - Batch Mode - Direct output to another file.
  • -n - Number of times the command should run ( run infinitely if unspecified)
  • -d - Delay time between two snapshots
  • -p<pid> - Monitor only the specified process(es).

ps - Report a snapshot of current processes. Runs just once. Use top for continuous updates. 



  • -e / -A - Select all processes
  • -f - Does a full format listing
  • -r - Only running processes 
ps -aux | less

pstree - Print process tree

pstree -p | less

kill - Signal or Terminate  a process (64 signals)

kill -<signal_name | signal_number> <PID>

kill -3 <PID>= QUIT - 
kill -9 <PID>= KILL - 

kill -<signal> -1 = Signal All process of the User. If Super User signal all user's processes.


su - Substitute User Identity

su [login] - Switch to provided user login. If none is provided switch to Super User.




grep - File Pattern Searcher

grep [pattern] [file ...]

  • a - ascii / text file
  • i - ignore case
  • c - Return only the count of matching lines
  • n - Print line number for each matching line
  • R - recursive
  • v - invert natch
  • z - behave as zgrep
  • w - full words only - no substring
  • l - show only file names (not the matching lines)

  • zgrep - Accept files compressed with gzip



tail



less


more


du - Estimate file space usage

du -h <directory> - Displays disk space in Human readable format
-s - Total usage (not individual files)
-a - all files ( recursive )
-c - grand total in last line.
--exclude <pattern>- exclude files matching pattern
--time displays modification time

http://www.tecmint.com/check-linux-disk-usage-of-files-and-directories/



df - Check disk space
-h - human readable
-i - display informatino on inodes




free - Memory available on the machine

free
-m - show memory in MB
/-g (in MB or GB)

-t (show total swap + RAM)


zcat - To list contents of a zip file.

grep - find a string/pattern in a file
a) -i = ignore case
b) -w = full words only - no substring
c) -l = show only file names (not the matching lines)

sed - Search & Replace in a Stream (can be a file as well) 

sed -i 's/foo/bar/g' filename
option -i replace the data in file. (otherwise only on command output)

gzip - reduces size of the file by encoding it

Whenever possible, the original file is replace by one with extension .gz . (It ignores symbolic links)

gunzip

pscp - File Transfer using putty. pscp [options] [user@]host:source target

vmstat - Report Virtual memory stat

No comments:

Post a Comment