UNIX Commands

UNIX Commands

Different types of UNIX commands can be categorized as below:

  • Process Commands
  • File Commands
  • Directory Commands
  • Networking commands
  • Environmental Commands
  • System Admin Commands

Process Commands

  • ps – to see all the processes running with your own userid (process status)
  • ps -f – to list all information associated with the process run using your own userid.
  • ps aux – to display all running processes where a – select all processes on a terminal including those of other users, x- select processes without controlling ttys
  • pstree – display tree of a process
  • pgrep <string> – it looks through the currently running processes and list the process ids which matches the selection criteria.
  • kill – to kill a running process in normal mode
  • kill -9 – to kill a running process in abort mode
  • top – this command gives system statistics such as system load and the total number of tasks.
  • nice – use this command to run a program with certain nice value and it works at the beginning of a new program. For e.g., nice -n 15 abcd_command
  • renice – to alter nice value of a command that is already running. For e.g., renice 0 PID_of_pgm
  • htop – improved version of top command to get user friendly display.
  • jobs – display background and suspended processes.
  • osview – displays the operating system statistics
  • Ctrl -c – interrupt current process
  • Ctrl -z – suspends current process
  • bg – send a process to run in background
  • fg %jobnumber – bring a running job from back ground to front

File Commands

  • ls – list files in a directory
  • ls -ltr – long listing of all files in a directory with time stamp
  • ls -ltrh – long listing of all files in a directory with time stamp in human readable format of file size
  • ls -al – list all files including hidden files in a directory
  • cp – copy files
  • cp -r – recursive copy of file from a directory
  • mv – move a file or other way of renaming a file
  • rm -remove a file
  • rm -rf – forcefully remove directory and its content
  • diff – compare 2 files and shows the difference
  • diff -y – shows difference line by line
  • wc – tells how many lines, words and characters are there in a file
  • chmod – changes read, write, execute permission of files and folders
  • chown – change ownership of a file
  • chgrp – change group of a file
  • gzip – compress files to reduce space
  • gunzip – uncompress files compressed by gunzip
  • gunzip -c – view the content of gzipped file without opening it
  • gzcat – view the content of gzipped file without opening it.
  • cat – view the content of a file and show till the end.
  • more – view the content of a file one page at a time. You can scroll down a big file but not up with this
  • less – view the content of a file. You can scroll up and down the content of a big file which will not fit in one screen.
  • head – show the top n lines of file as specified
  • tail – shows the bottom n lines of file as specified

Directory Commands

  • mkdir – make new directory
  • cd – change directory
  • pwd – show present working directory
  • tar – to compress directory
  • rmdir – to remove empty directory
  • rm -rf – remove directory with its content
  • df – shows free disk space details
  • du – shows disk usage

Networking Commands

  • ping – test if the machine is reachable
  • traceroute – trace the route of packet transfer between source and target host over a network medium
  • netstat – displays network connections, routing tables, interface statistics.
  • telnet – logon to remote server for transferring file
  • ftp – start file transfer protocol window to transfer file to a target server.
  • sftp – secure mode of transferring files
  • ssh – used for logging in to a remote system with secure encrypted communication between the local and remote system using SSH protocol.
  • scp – secure copy of files over network
  • get – used for pulling file from a target host
  • put – used for placing file in a target system
  • wget – download file from a network
  • mget – used for pulling multiple files from a target host
  • mput –used for posting multiple files to a target system
  • hostname- display host/ domain name of the system
  • ifconfig – gives the network configuration of the system
  • arp – use this address resolution protocol command to see the IP to MAC address translation table if you are having problem in connecting to other hosts
  • nslookup – query DNS lookup name
  • tcpdump – shows headers of network packets as they arrive in the system




Environmental Commands

  • alias – creates a new command
  • setenv – list environmental variables
  • export – export the parameters for the logged in session. For e.g., export TMOUT=6000 will not disconnect the session till 6000 s
  • who – list all users logged in to the same OS and from which terminal
  • w – tells who logged in and what they are doing i.e., if they are idle or typing some input from their keyboard
  • whoami – list the name of the current user
  • which – list the location of executable command
  • whereis – list the absolute path of commands
  • finger – gives more information of a logged in user
  • talk – to have a typed conversation with another logged in user.
  • last – tells you when the user last logged on and off and from where.
  • Id – list the userid
  • date – show date of the current system
  • cal – shows calendar
  • passwd – allow logged in user to change its own password.
  • logout – closes the terminal session
  • exit – closes the terminal session
  • quota – gives details of disk quota usage
  • man – display online reference of each command
  • history – display list of command already fired from the same terminal
  • grep – searches for lines containing a specified pattern in a file
  • awk – used for accessing the rows and columns of a file for data extraction and reporting
  • Sed – stream editor utility for editing content of a file
  • Cut – used for extracting specific section from each lines of input file
  • find – searches for files in directories and sub directories
  • locate – find file in system by name
  • file – tells about the type of a file
  • uptime – shows system uptime
  • crontab – used for updating cron entries for scheduling of jobs, scripts
  • at – used for single run of scheduling of jobs
  • vi – opens a vi editor




System Admin Commands

  • usermod – modify attributes of an existing user account.
  • userdel – delete an existing user account
  • useradd – adds a new user account in the system
  • groupadd – adds a group to the system
  • groupmod – modifies the group of an existing user account
  • groupdel – delete an existing group
  • chown – change ownership of a file
  • osview – display operating system statistics.
  • lsof – show list of open files
  • sudo – use this command to run any command as the superuser root.
  • mount – mount a file system
  • umount – unmount a file system
  • shutdown – brings the system down

Read more on UNIX Processes
Read more on UNIX Architecture

«BACK