Table of Contents hide
2. Unix/Linux Commands

Important Key Combination 

      • CTRL+C – To halt the current command.
      • CTRL+D – To save the written file contents/generate end-of-file character/Logout the current session, similar to exit.
      • CTRL+G – To resume flow of long output of the screen stopped by CRTL+S, so that screen passes fastly.
      • CTRL+Q -To restart the output to continue on the screen.
      • CTRL+R – Used to type to bring up a recent command.
      • CTRL+S – To stop flow of long output of the screen temporarily so that a user can read it easily.
      • CTRL+U- To erase whole line in the current cursor line from a paragraph of text.
      • CTRL+W – To erases one word in the current line.
      • CTRL+Z – To stops the current command, resume with fg command in the foreground or bg command in the background.
      • !! – Used to repeat the last command. 
      • exit – Logout the current session.

Unix/Linux Commands

Common Conventions regarding Unix/Linux Commands 

  •  Unix/Linux commands are usually written in lowercase letters.
  • The syntax of typical Unix/Linux commands are  – 
    • Commands without options/arguments
      • Syntax : – $ command_name (press enter) 
      • Example – $ clear/$ date/$ pwd (press enter)
    • Commands with options/arguments
      • Syntax : – $ command_name options arguments (press enter) 
      • Example – $ ls -x  (press enter)              
  • File name must be used with its extension name, if any.

Category of Unix/Linux Commands 

  • Linux has a large family of commands, some of them are quite powerful.
  • Incidentally, most Linux commands are represented as files in the system.
  • There are following categories of Unix/Linux commands –

(a) Directory Commands

  • Those commands which are mainly responsible for directory related process/operations.
  • Examples are – cd, ls, md, rd, mkdir, rmdir, pwd etc.

(a) File Commands

  • Those commands which are mainly responsible for file related process/operation.
  • Examples are – ls, cp, more, less, cat, cmp, comm, mv, rm, chmod, file,head, tail, grep, sort, diff, man, touch etc.

(i) File Editors for creating and editing files – vi, joe, vim etc.

(ii) File Operation Commands – ws, sat, cut, dd etc.

(b) Input/Output Commands

  • Those commands which are mainly responsible for input/output related process/operations.
  • Examples are – read, echo, etc.

(c) Process Commands

  • Those commands which are mainly responsible for system related process/operations acts on user given jobs.
  • Examples are – ps, top, kill, bg, fg etc.

(d) Mathematical Commands

  • Those commands which are mainly responsible for arithmetic  process/operations/calculations.
  • Examples are – bc, expr, factor, units etc.

(e) Searching Commands

  • Those commands which are mainly responsible for finding unique contents from a files or memory.
  • Examples are – grep, pgrep, find, locate, which, whereis, whatis etc.

(f) Printing & Formatting Commands

  • Those commands which are mainly responsible for printing contents either from files or memory on the page as hard copy for further use.
  • Examples are – lpq, lpr, lprm, lprloc etc. 

(g) Disk related Commands

  • Those commands which are mainly responsible for physical drive/ hard disk related process/operations.
  • Examples are – du, df, fdisk, lshw, sfdisk, free etc 

(h) Network Commands

  • Those commands which are mainly responsible for handling computer network related process/operations.
  • Examples are – ipconfig, ip, ping, netstat, ss, traceroute, wget, dig, whois, w, whoami, finger,  etc.

(i) Setup Commands

  • Those commands which are mainly used for  system setup process/operations.
  • Examples are – date, passwd, env, set, alias, stty etc. 

(j) Status Commands

  • Those commands which are mainly used for giving the status of process/operations.
  • Examples are – logout, finger, ps, history etc

(k) Program Controls Commands

  • Those commands which are mainly responsible for controlling the program related process/operations.
  • Examples are – jobs, bg, fg, sleep, kill, nice, renice, &, ps, who, man etc.

(l) Data Editing Commands

  • Those commands which are mainly responsible for editing the data stored in a file/memory related process/operations.
  • Examples are – pico, vi, gnuemacs, diff, sort, wc, look, awk etc.

(m) Compression Commands

  • Those commands which are mainly responsible for compressing the data without degrading the quality stored in a file/memory.
  • Examples are – tar, gzip etc.

List of Unix/Linux Commands

(Alphabetically) 

A

  • alias

Definition
      • The alias command provides us to give/put our own short name to a unix/linux command or sequence of commands.

      • When we use/type an alias name in place of linux command name it works, and thus, saves a few keystrokes/time.

      • Once Aliases defined on the command line, it will die with the closing of terminal window. 
      • To make aliases always be available to us, it is better to add them to the.bash_aliases file in the home directory of linux.
Syntax
      • $ alias alias_name = Unix/Linux_commands_name.
Example
      • $ alias cls=clear.
      • $ cls (press enter)   [Clears the screen].
  • at

    • The alternative of this command is a cron command. However, at command execute jobs only once, whereas cron jobs are recurring events.
    • If this command not found in some version of linux then install/update it.
    • at command also works with pipe(|) symbol.
Definition
    • At is a utility command in Linux used to schedule a job for later execution. This command reads commands from standard input and groups them into an at job, which executes only once.
Syntax

at [option] runtime

Here runtime may be –

(a)The absolute runtime expressions are:

      • YYMMDDhhmm[.ss]. Specify an abbreviated year, month, day, hour, minute, and optionally seconds.
      • CCYYMMDDhhmm[.ss]. Specify a full year, month, day, hour, minute, and optionally seconds.
      • now. Indicates the current day and time and immediate execution.
      • midnight. Indicates 00:00 AM.
      • noon. Indicating 12:00 PM.
      • teatime. Interpreted as 4 PM.
      • AM. Indicates time before 12:00 PM.
      • PM. Indicates time after 12:00 PM.
      • today. The current day.
      • tomorrow. The day after the current day.

(b)The relative runtime expressions are:

A relative runtime expression may also be represented by adding a plus sign (+), with some amount value, are one of the following:

        • minutes
        • hours
        • days
        • weeks
        • months
        • years
Example
    • echo “hello” | at 5PM (press enter) [this command schedules an echo command invocation at 5PM]
    • echo “hello” | at now +5 minutes (press enter) [this command schedules an echo command invocation five minutes after scheduling the job]
  • awk

    • The awk command or GNU awk provides a shell scripting language for text processing. 
Definition
    • Using awk command, we can define variables, use string and arithmetic operators, use control flow and loops, generate formatted reports, to process log files etc.
Syntax
    • $ awk options(press enter)
Example
    • To define awk scripts/message –
      • $ awk ‘{print “Hello how are you”}’ (press enter)
      • To terminate the program, press Ctrl+D.
    • To print the complete lines of a file-
      • $ awk ‘{print $0}’ file1.txt (press enter)
    • To print the first word of each line
      • $ awk ‘{print $1}’ file1.txt (press enter)
      • $ awk ‘{print $1}’ etc\file1.txt (press enter)
    • To print the fifth word of each line
      • $ awk ‘{print $5}’ file1.txt (press enter)
    • To print the multiple words of each line
      • $ awk ‘{print $5, $8, $11 }’ file1.txt (press enter)
    • To create a title or a header message for our output –
$ awk ‘BEGIN {print “The ouputs are “}
{print $0}’ file1.txt 
    • To create a title or a header and footer message for our output –
$ awk ‘BEGIN {print “The ouputs are “}
{print $0} file1.txt
END {print “File printing finishes”}’ file1.txt
    • To assign values into user defined variables  –
      • $ awk ‘ BEGIN{ msg=”Welcome in shell scripting program” print msg }’

    • To assign control flow statement  –
      • $ awk ‘{if ($1 > 10) print $1}’ file1.txt [prints all the values greater than 10 from file file1]

      • $ awk ‘{ if ($1 > 10) { x = $1 * 5 print x } }’ file1.txt      OR

$ awk ‘{

if ($1 > 10)

{

x = $1 * 5

print x

}

}’ file1.txt

      • $ awk ‘{ if ($1 > 10) { x = $1 * 5 print x } else { x = $1 / 2 print x }}’ file1.txt

      • $ awk ‘{ sum = 0 i = 1 while (i <= 15) { sum += $i i++ } avg = sum / 15 print “Average value is :”, avg }’ file1.txt

    • To print the output in formatted order  –
      • The list of the format specifiers we can use in printing work:

c            To print numeric output as a string.

d            To print an integer value.

e            To print scientific numbers.

f             To print float values.

o            To print an octal value.

s            To print a text string.

      • $ awk ‘BEGIN{ x = 10 * 10 printf “The result is: %e\n”, x }’
    • To use several built-in functions already present in awk –
      • $ awk ‘BEGIN{x=exp(7); print x}’ [math function]

      • $ awk ‘BEGIN{x = “Welcome”; print toupper(x)}’ [string function]

$ awk ‘
function abc()
{
printf ” welcome”
}
BEGIN
{
FS=”:”
}
{
abc()
}’ file1.txt

B

Definition
    • This command is used to display/print the string message on the screen as floating/animated form, normally in capital letters.
    • On each line, it displays a maximum of 10 characters.
    • The message appear on the screen with # sign, by default. We can change the default symbol # with any other symbol such as * symbol – $ banner codershelpline : tr “#” “*” (press enter) now # symbol is replaced with * symbol.
Syntax
    • $ banner messagetext (press enter)
Example
    • $ banner codershelpline (press enter) [display only 10 chars in one line as capital letters]
    • $ banner coders helpline (press enter) [display chars in two lines from space position, i.e. coders in first line and helpline in second line as capital letters]
  • bc

Definition
    • This command makes any type of arithmetic calculation as calculator and get result immediately.
Syntax
    • $ bc (press enter)
Example
    • $ bc (press enter)
_   2+5+6 (press enter)
     13 (Output)
     Press CTRL+D to come out from bc command.
$_
  • bg

Definition
    • This command sends the recently (suspended) foreground process in background.
Syntax

$ bg  process id/job_spec (press enter)

C

  • cal (Calendar)

Definition
    • This command is used to see the calendar of any specific/complete month or year or date, depend on what the system date has been set to.
    • This command displays the day/month/year details between 1 and 9999 year.
Syntax

$ cal option/arguments (press enter)

Example
    • $ cal (press enter) [ Display the current month calendar]
    • $ cal  4 2005(press enter) [ Display the calendar of April month 2005]
    • $ cal 4(press enter) [ Display all the months of year 4]
    • $ cal 1990 (press enter) [ Display all the months of year 1990]
  • cat (concatenate)

   Definition

    • This command performs the following functions –  

(i) This is faster than opening the file in a vi editor, and there’s           no chance to alter the file accidentally.

(a) This command can be used to displays the contents (only last 24 lines ) of single/multiple files on the terminal/screen.

Syntax : $ cat filename (Press Enter)  [For single file]
Example : $ cat file1.txt (Press Enter)
Syntax : $ cat filename1 filename2  (Press Enter)  [For multiple file]
Example : $ cat file1.txt  file2.txt (Press Enter)
    (b) This command can be used to displays the contents page wise (less command can be used) of single/multiple files on the terminal/screen.
Syntax : $ cat filename |less (Press Enter)                    [For single file]
Example : $ cat file1 |less (Press Enter)
Syntax : $ cat filename1 filename2 |less (Press Enter)                          [For multiple file]
Example : $ cat file1 file2 |less (Press Enter)

NB : To move/scroll page forward and backward we can use Up or Down Arrow keys  or PgUp or PgDn keys, or the Home or End keys. To come out from ‘less ‘ option,  press  ‘q’ button to quit from less option.

(ii) This command can also be used to combines/copy the contents of multiple files into another single blank file by copying it.

Syntax : $ cat filename1 filename2 > filename3 (Press Enter)                          
Example : $ cat file1 file2 > file3 (Press Enter)   [Here file3 contains the copied contents of  both file1 and file2]

(iii) This command can also be used to add the contents of multiple files into another existing file (at the end of the file).

Syntax : $ cat filename1 filename2 >> filename3 (Press Enter)                          
Example : $ cat file1 file2 >> file3 (Press Enter)   [Here file3 assigns the contents of  file1 and file2 at the end of it]
  • cd (Change Directory)

   Definition

    • Used to change the current working directory i.e. it moves to a new directory.

   Example

(i) $ cd\  (Press Enter)   [Change current working to root directory in one go.]

(ii) $ cd .. (Press Enter)    [Back one directory(i.e. parent directory) from current working.]

(iii) $ /usr/dummy/prg  

        $ cd /usr/dummy (Press Enter) [To come out from prg directory to dummy directory.]

(iv) $ /usr/dummy/cd dir1  (Press Enter)    [To go into new directory (dir1) from current working directory(dummy).]

       $ /usr/dummy/dir1

  • chmod

Definition
    • The chmod command is used to set a new/change the old file access permissions flags of a file or folder stored in memory for security purpose.
    • The file access permission flags define who can read(r), write(w) to or execute(x) the file.
    • When we list the stored files using ls -l option we see a string of characters(10) in the following format that appear as –
      -rwxrwxrwx
      • Here the first character format of string is a then the item is a (ordinary type of) file, if it is a d in place of – symbol then the item is a directory. The rest of the 9 strings for file access permission which is further divided into three sets of three characters (rwx). From the left, the first three represent the  owner file permissions , the middle three represent the group/group members file permissions and the rightmost group of three characters represent the other users permissions .
    • If the letter r, w, or x character is present in format of strings then it is considered that file access permission is granted and if the letter is not present/missing or a – symbol appears instead, then that file permission is not granted/given. If all the 3 letters are present in a set of format strings it means that a particular category of user has full access permission otherwise partial access permission and in the case of no letters i.e. no access permission.
    • There is way to use chmod command to provide the permissions to the owner, group, and other users as a 3 digit number. The meaning of each digit we can use or what they represent are listed below :-

      0: No permission
      1: Execute permission
      2: Write permission
      3: Write and execute permissions
      4: Read permission
      5: Read and execute permissions
      6: Read and write permissions
      7: Read, write and execute permissions

For example – If a file(say abc.txt) has all three sets of characters as rwx. It means that everyone has read, write and execute rights with this file (abc.txt) .

    Syntax
      • To set the permission to be read, write, and execute for a file (choose 7 from the list) for the owner; read and write for a file (choose 6 from the list) for the group; and read and execute for a file (choose 5 from the list) for the others. Thus, to set the above permission in a file,the command will be given for that specific file is –
        $ chmod -R 765 abc.txt (press enter)
    Example
      • We can see the permission of a file, we simply use – 

    $ ls -l abc.txt (press enter)

    • chpasswd

    Definition
    Syntax
    Example
    • chown

    Definition
      • This command allows to change the user, owner or group of owner of a file/directory or both.
      • As we know that in Linux, all files/directories are associated with an owner and a group ownership along with permission access rights for the file owner, the group members, and others.
      • Normal users can change the group of the file only if they own the file and only to a group of which they are a member.
      • Administrative users can change the group ownership of all files.
      • Each user has a default group created when the user is created. That user is the only member of that group. This shows that the file is not shared with any other groups of users.
      • To see the owner/group details of a file, we use the ls -l command.

    ls -l example.txt (press enter)

    (The first output of these indicates the name of the file owner, and the second output shows that the name of the group owner.)

    Syntax
      • chown [OPTIONS] USER[:GROUP] FILENAME(s)
    Here, 
    USER is the user name or the user ID (UID) of the new owner.Numeric user IDs is prefixed with the + symbol. 
    GROUP is the name of the new group or the group ID (GID). FILENAME(s) is the name of one or more files, directories or links.
      • Rules for chown

    USER – If only the user is specified in a file, the specified user will become the owner of the given files, the group ownership is not changed.
    USER: – When the username is followed by a colon (:) symbol in a file, and the group name is not given, the user will become the owner of the files, and the files group ownership is changed to user’s login group.
    USER:GROUP – If both the user and the group are specified (with no space betwen them), the user ownership of the files is changed to the given user and the group ownership is changed to the given group.
    :GROUP – If the User is omitted and the group is prefixed with a colon (:), only the group ownership of the files is changed to the given group.
    : If only a colon : is given, without specifying the user and the group, no change is made.
    (By default, on success, chown doesn’t produce any output and returns zero.)

    Example
      • To change both the owner and the group owner of a file with single user name (say dummy) – $ chown dummy:dummy example.txt (press enter) 
    • chroot

    Definition
    Syntax
    Example
    • chsh

    Definition
    Syntax
    Example
    • clear

    Definition
      • Used to removes the previous screen contents and the cursor remains at the top of the screen after the system prompt.
    Syntax
      • $ clear (press enter)
    • clear screen

    Definition
      • Used to removes the previous screen contents and the cursor remains at the bottom of the screen .
      • Applicable in few versions of Unix/Linux.
    Syntax
      • $ clear screen (press enter)
    • cmp

    Definition
      • This command compares two files contents byte-by-byte.
    Syntax
      • $ cmp firstfilename secondfilename
    Example
      • $ cmp file1 file2 (press enter)
    • compress

    Definition
    Syntax
    Example
    • cp (Copy)

    Definition
        • It is used to make copy of an existing file.
    Syntax
        • $ cp source_filename destination_filename (press enter)
    Example
        • $ cp file1 file2 (press enter)
    [copy the contents of file1 into file2 in the current directory]
        • $ cp file1 /usr/dummy/prg/file2 (press enter)

    [copy the contents of file1 into file2 in another directory (prg)]

    • cron

    Definition
        • The cron is a software utility, that automates the scheduled task at a predetermined time. It is called a daemon process, which runs as a background process and performs the specified operations at the predefined time when a certain event or condition is triggered/met without the intervention of a user.
        • It enables the users to execute the scheduled task on a regular basis tasks like doing the backup every day at midnight, scheduling updates on a weekly basis, synchronizing the files at some regular interval.
        • It organizes the scheduled jobs based on their importance or the frequency and group them by their action or the time range.
        • Cron checks for the scheduled job recurrently and when the scheduled time fields match the current time fields, the scheduled commands are executed.
        • It is started automatically from /etc/init.d on entering multi-user run levels. 
    Syntax

    cron [-f] options 

    where
    -f : Used to stay in foreground mode, and don’t daemonize.
    Example

    * * * * * /root/backup.sh (Run Cron Opeartion Every Minute)

    30 * * * * /root/backup.sh (Run Cron Opeartion Every 30 Minutes)

    0 * * * /root/backup.sh (Run Cron Opeartion Every Hour)

    0 0 * * * /root/backup.sh (Run Cron Opeartion at Midnight Every Day)

    0 2 * * * /root/backup.sh (Run Cron Opeartion Every Day at 2 am)

    0 0 1 * * /root/backup.sh (Run Cron Opeartion Every First of the Month)

    0 0 1 5 * * /root/backup.sh (Run Cron Opeartion Every Fifteen of the Month)

    0 0 0 1 2 * /root/backup.sh (Run Cron Opeartion at Midnight on December 1st)

    0 0 * * 6 /root/backup.sh (Run Cron Opeartion at Midnight on Saturday)

    • cut 

    Definition
        • Used to cut/extract desired number of characters from the specified file.
    Syntax

    $ cut -c list filename (press enter) [ Here, -c helps to cut the character and list tells from which position to which position.]

    Example
        • Suppose a file name ‘dummy’ contains 4 lines data as –                   Temporary                                                                                           Public                                                                                                   Reverse                                                                                                 Anil                                                                                                 Now –                                                                                                                 $ cut -c 1 dummy (press enter)
    Output :(cut single char. from each line)
    T
    P
    R
    A

     $ cut -c 1 -4 dummy (press enter)

    Output :(starts cutting char. from first to fourth from each line)
    Temp
    Publ
    Reve
    Anil

     $ cut -c 2- dummy (press enter)

    Output :(starts cutting char. from second till the end from each line char. from each line)
     emporary                                                             ublic                                                                       everse                                                                   nil   

    D

    • date

    Definition
      • This command displays the system date & time as set by the system administrator.
      • The date command doesn’t prompt us to change either date or time.This is done by system administrator mainly.
    Syntax

    $ date (press enter)

    Example

    $ date (press enter)

    Output : Tue Nov 19 21:37:51 CST/IST 2010

    • dc

    Definition
    Syntax

    Example

    • df

    Definition
      • The df command is used to display the size, used space, and available space on the mounted file systems of our computer.
      • The two most useful options linked with df are  -h (human readable) and -x (exclude) options.
      • Here, the human-readable option displays the sizes in Mb or Gb instead of in bytes.
      • The exclude option allows df command to discount file systems we are not interested in. 
    Syntax

    $ df -h -x filesystem_drivename (press enter)

    Example

    $ df -h -x dummyfs (press enter) [dummyfs is the name of mounted filesystem of the system]

    • dir

    Definition
      • This command lists the contents of current directory.
      • It is similar as ls command.
    Syntax

    $ dir (press enter)

    • dump

    Definition
    Syntax
    Example

    E

    • echo

       Definition
      • Used to print/display string message or variable or expression value in the form of output.
       Syntax
      • $ echo string_message/’string_message’/”string_message” (Press Enter)
      • $ echo variable (Press Enter)
      • $ echo expression (Press Enter)
       Example
      • $ echo codershelpline (Press Enter)
      • $ echo ‘codershelpline’ (Press Enter)
      • $ echo “codershelpline” (Press Enter)
      • $ echo codershelpline is          our         site (Press Enter)
    Output : codershelpline is our site [No space in output]
      • $ echo “codershelpline is          our         site” (Press Enter)
    Output : codershelpline is          our         site
        • $ x=10 (Press Enter)
        • echo x (Press Enter)
        • $ x=10 (Press Enter)
        • $ echo `expr $x+1 (Press Enter)
      • egrep(extended grep)

      Definition
        • egrep command works similar as grep does but egrep scans a specific file, line to line, and prints the line(s) that contain the search string/regular expression.
      Syntax

      Example
        • To search a specific string from a file –
          • Syntax : $ egrep searching_string filename
          • Example : $ egrep welcome file1.txt(Press Enter)
        • To search a specific string from multiple file –
          • Syntax : $ egrep searching_string multiple_filename
          • Example : $ egrep “welcome” *.txt (Press Enter)
        • To search a specific string from a current directory –
          • Syntax : $ egrep -r “searching_string” *
          • Example : $ egrep -r welcome * (Press Enter)
        •  To search all the words that contain the string as a sub-string-
          • for searching the string ‘ram’ will display all the words containing the string ‘ram’ like ‘ram’, ‘ramu’, ‘raman’ ‘ramesh’ etc.
          • Syntax : $ egrep -w searching_string filename
          • Example : $ egrep -w ram file1.txt (Press Enter)
        • To search all the words that contain the string as a sub-string ignoring case –
          • Example : $ egrep -i ram file1.txt (Press Enter)
          • Example : $ egrep -iw ram file1.txt  (Press Enter)
        • To search a specific word  and print only them –
          • Example : $ egrep -o welcome file1_.txt (Press Enter)
      • exit

      Definition
          • Used to come out from the Unix/Linux System.
      Syntax
          • $ exit (Press Enter)
      Example
          • $ exit (Press Enter)
      • expr

      Definition
        • expr command is used to calculate an arithmetic expression mainly in a shell programming work.
        • They are often used with command substitution to assign a variable.
        • This command is also used in incrementing the value of a variable. eg- 
      Syntax

      Example

        F

        • find

        Definition
        Syntax
        Example
        • finger

        Definition
          • This command gives a short information about a user, such as the time of the user’s last login, the user’s home directory, the user account’s full name, mailing details etc.
        Syntax
          • $ finger username (Press Enter)
        Example
          • $ finger dummy (Press Enter)

        G

        • grep(Global Regular Expression Print)

        Definition
          • The grep command searches the given pattern of contents from lines of contents.
          • The grep command can also search the contents of files in the current directory.
          • The output lists the name of the file and shows the lines that matched the contents.
          • The matching text is highlighted in the lines of files.
        Syntax
          • $ grep searched contetns/pattern filename (Press Enter)
        Example
          • $ grep computer abc.txt (Press Enter) [Searched the term computer from abc .txt files]
          • $ grep computer *.txt (Press Enter) [Searched the term computer from all .txt files]
        • gzip

        Definition
        Syntax
        Example

        H

        • halt

        Definition
        Syntax
        Example
        • head

        Definition
          • Display the first few lines (usually 10)/characters of a file to the screen.
        Syntax
          • $ head filename (Press Enter) 
        Example
          • $ head file1.txt (Press Enter)       [ By default, to display the first 10 lines of a file to the screen.]
          • $ head -n 2 file1.txt (Press Enter)       [ To display the first 2 lines of a file to the screen.]
          • $ head -c 20 file1.txt (Press Enter)       [ To display the first 20 characters/bytes of a file to the screen.]
          • help

          Definition
          Syntax
          Example
          • history

          Definition
            • The history command lists the commands we have previously used on the command line.
            • We can repeat/use any of the history lists commands again by typing an exclamation symbol (!) with the index number of the command from the history list. for example – !52
            • To repeats the previous command again two exclamation symbol is used such as !!.
          Syntax
            • $ history (Press Enter)
          Example

          I

          • id

          Definition
          Syntax
          Example
          • ifconfig

            • ifconfig stands for ‘Interface Configuration’.
            • This is a utility command mainly used in system/network administration work.
            • We can say that the ifconfig command is bundle of argumnets used for displaying current network configuration information, setting up an ip address, netmask, or broadcast address to a network interface, creating an alias for the network interface, setting up hardware address, and enable or disable network interfaces etc.
          Definition
            • This command is used in Unix/Linux operating systems to configure, manage and query network interface parameters via command-line interface or through any system configuration scripts.
            • The ifconfig command is also used to check the assigned IP address of a server.
          Syntax
            • $ ifconfig arguments interface_name (Enter)
          Example
            • The ifconfig command with no arguments displays all the active interfaces details.
              • $ ifconfig (Enter)
            • The ifconfig command with the -a argument displays information of all active or inactive network interfaces on the server. It displays the results for common interfaces of a Linux network as eth0(ethernet), lo(local), sit0 and tun0.
              • $ ifconfig -a (Enter)
            • To view network settings of specific interface –

              • $ ifconfig -eth0 (Enter)
            • The up or ifup flag with interface name (eth0) activates/enables that specific network interface.
              •  $ ifconfig eth0 up (Enter)
              • $ ifup eth0 (Enter)
            • The down or ifdown flag with interface name (eth0) de-activates/disables that specific network interface.
              • $ ifconfig eth0 down or ifdown eth0 (Enter)
              • $ ifdown eth0 (Enter)
            • To assign a specific IP address to a specific interface, the ifconfig command with an interface name (eth0) and ip address is used to set the IP address to an interface.
              •  $ ifconfig eth0 162.26.28.110 (Enter)
            • To assign a Broadcast to a specific interface-
              • $ ifconfig eth0 broadcast 162.26.28.110 (Enter)
            • To change the MAC address of a specific interface-
              • $ ifconfig eth0 hw ether ab:bc:cd:de:ef (Enter)
          • ipconfig

          Definition
          Syntax
          Example

          J

          K

          • kill

          Definition
            • The kill command is used to terminates a running process by giving process ID (PID) of that process. 
            • This command also tells the Unix/Linux to kill the lines written on $ prompt i.e. it ignores everything on the line on Unix/Linux prompt.
          Syntax
            • $ kill process_Id (Press Enter)
          Example
            • $ kill 1240 (Press Enter)

          L

          • last

          Definition
          Syntax
          Example
          • less

          Definition
            • To see the contents of a larger file on the screen pagewise.
            • To move/scroll page forward and backward we can use Up or Down Arrow keys  or PgUp or PgDn keys, or the Home,Space or End keys.
            • To come out from ‘less ‘ option,  press  ‘q’ button to quit from less option.
          Syntax
            • $ less filename (Press Enter)
          Example
            • $ less file1.txt (Press Enter)
              • let

              Definition
              Syntax
              Example
              • ls

              Definition
                • This command displays all the stored and saved working directory contents i.e. all files except hidden files in the current working directory alphabetically in which first file name is in uppercase letters in multiple columns. 
                • The output of ls is always sorted in some specific order, default is alphabetical.
                • The ls command exists in several form with different options –
                  1. ls-x (displays all the stored and saved files or directories from the current working directory, arranged horizontally width wise from left to right on each line)
                  2. ls-s (displays all the stored and saved files or directories from the current working directory, arranged size in disk block for each entry and total for all entries on each line)
                  3. ls-c (displays all the stored and saved files or directories from the current working directory, arranged horizontally width wise from left to right but sorts each column in descending order column wise)
                  4. ls-m (displays all the stored and saved files or directories from the current working directory, arranged horizontally width wise from left to right on each line and each file name is separated by comma from next file)
                  5. ls-l (displays all the stored and saved files or directories from the current working directory, with certain associated information of each file such as modes, permission, GID [group identification number] number, GID name, UID [User identification number], size, month, date, time, file name etc. All these information are represented in symbolic form i.e. the first character of first column represent mode/type of file i.e. if the first letter is d- denotes directory, – symbol denotes ordinary file, b&c denotes device, next nine consecutive letters for file access permission)
                  6. ls-r (Used to display file name and directory within the current working directory without date and time information in reverse order. The name with slash(/) symbol denotes directory name while others are ordinary files)
                  7. ls-p (Used to display file name and directory within the current working directory in ascending order. The name with slash(/) symbol denotes directory name while others are ordinary files)
                  8. ls-n (works similar as ls-l option except owner and group name in place of UID and GID)
                  9. ls-wild character[*/?] (used to search files from current working directory. For example – $ ls dummy* (press enter) or $ ls dummy? (press enter)
                  10. ls-a (Used to display all files including hidden files. Hidden files are started with . symbol)
                  11. ls-f (Used to display all  executable files (.exe) started with * symbol attached ahead to it with the list.)
                  12. ls-m (Used to display the directory,  sub-directory and file contents in very compact form separated by comma.)
                  13. ls directory_name (Used to display the contents of given directory eg- $ ls /usr/dummy (press enter))
              Syntax
                • $ ls (press enter)
                • $ ls  path of directory (press enter)
              Example
                • $ ls (press enter)
                • $ ls /home/system/dir1 (press enter)

              M

              • mail

              Definition
              • Used to send message to other users who are connected to the network and are present/will come on other terminal. The coming user got the message when he/she logged in as an informative statement-There is a mail.
              • To read the mail message, user can type mail on $ prompt.
              Syntax
              $ mail UID (press enter)
              type the message
              ctrl+d – to come out from message typing.
              Example

              • man (Manual/Help)

              Definition
                • To take help or see/know the more details (help) about any commands used in Unix/Linux.
              Syntax
                • $ man commandname (Press Enter)
              Syntax
                • $ man wc (Press Enter)
                • $ man ls (Press Enter)
                • $ man man (Press Enter)
              • md

              Definition
              Syntax
              Example
              • mkdir

              Definition
                • Used to create a new fresh/blank directory/sub-directory into current directory where we are working/present now. 
              Syntax
                • $ mkdir direcotry/sub-directory name (Press Enter)
              Example
                • $ mkdir Dir1 (Press Enter)
                • $ ls (Press Enter)                   [To see the created new directory]
              • more

              Definition
              Syntax
              Example
              • mv (Move)

              Definition

              It performs following functions –

              (i) Used to rename the saved/existing file or directory in the current working directory.

              Syntax : $ mv  oldfilename  newfilename (unique)     [Press Enter]
              Example : $ mv  file1  file2     [Press Enter]
                                  $ ls     [Press Enter]  (To see the renamed file)

              (ii) Used to move/cut a file from their existing location/directory and is ready to paste at given new location/directory.

              Syntax : $ mv  filename  path_of_new_location     [Press Enter]
              Example : $ mv  file1  /usr/dummy     [Press Enter]             (Moves file1 into new dummy directory)

              N

              • netconfig

                • netconfig stands for network configuration.
              Definition
                • This command is used to manage the network resources.
              Syntax
                • NET CONFIG SERVER options [Press Enter]
              Example
                • NET CONFIG SERVER /Autodisconnect:mm [Press Enter] [To change the idle session timeout (default = 15 minutes)]
                • NET CONFIG SERVER /Autodisconnect:-1 [Press Enter] [To disable idle timeouts altogether]
                • NET CONFIG SERVER /hidden:yes [Press Enter] [To hide a machine from Network Neighbourhood]
                • NET CONFIG WORKSTATION /? [Press Enter] [Display or change the Workstation Service communication device settings]
              • netstat

                • netstat stands for ‘network statistics’.
                • This commnad is available with Unix/Linux or Windows OS.
                • This is a very useful network commands mainly used in network troubleshooting and performance measurement.
                • This command is very important and much useful for Linux network administrators as well as system administrators to monitor and troubleshoot their network-related problems and determine network traffic performance.
                • In new version of Linux, netstat command is replaced by a new command called ss, which is capable of displaying more information about network connections and it is much faster than the older netstat command.
              Definition
                • This is an open-source command-line network monitoring tool that monitors incoming and outgoing network packets traffic.
                • It is believed that netstat command is one of the most basic network service debugging tools, telling us what ports are open or close and whether any programs are listening on ports or not.
              Syntax
                • $ netstat argument [Press Enter]
              Example
                • Lists all the functioning/listening ports of a network using TCP and UDP connections- 
                  • $ netstat -a | more [Press Enter]
                • Lists all the functioning/listening ports of a network uses only TCP connections- 
                  • $ netstat -at [Press Enter]
                • Lists all the functioning/listening ports of a network uses only UDP connections- 
                  • $ netstat -au [Press Enter]
                • Lists all active listening ports connections in a network –
                  • $ netstat -l [Press Enter]
                • Lists all active listening TCP ports in a network –
                  • $ netstat -lt [Press Enter]
                • Lists all active listening UDP ports in a network –
                  • $ netstat -lu [Press Enter]
                • Lists all active UNIX/Linux listening ports in a network –
                  • $ netstat -lx [Press Enter]
                • To Display service name with their PID number –
                  • $ netstat -tp [Press Enter]

              O

              P

              • passwd

              Definition
                • This command is used to change/modify the old password with new one of the user who logged currently in to the terminal.
              Syntax

              $ passwd (press enter and follow the instructions to change)

              Example

              • ping

              Definition
              Syntax
              Example
              • ps (process status)

              Definition
                • Gives information about the currently running process/task.
              Syntax
                • $ ps (press enter)
              Example

              • pwd (Print Working Directory)

              Definition
                  • It displays the full/complete/absolute path details of current working directory.
                  • It does not take any argument/option.
              Syntax
                  • $ command_name (press enter)
              Example
                  • $ pwd (press enter)
                  • Output = /ramdisk/home/knoppix
                  • Here first / = root directory, home = parent or group directory, knoppix = working or current or home directory.

              Q

              R

              • read

                • The read command can be used with and without arguments. 
              Definition
                • read command in Linux system is used to read/accept values or  the contents of a line into a variable from user at run time.
              Syntax
                • read [options] [variable_name…] (press enter) 
              Example
                • read (press enter)[when we use the read command without any argument, it will take/accept a line of data as user input and store by default in a built-in variable ‘REPLY.]
                  • echo $REPLY  (press enter) [output will appear]
                • read x y z (press enter) [This command will store the frist string before space in ‘x’, the another string in ‘y’, and all the remaining string in ‘z’.]
                  • echo “[$x] [$y] [$z]”  
                • read x y z (press enter)
                  • India is \    
                  • > our motherland \   
                  • > we love too much. [This command will take each line as one input string and will store it into the respected variable.]
                • echo “Enter your name..?”; read name; echo “Hello $name” 

                OR 

                    • echo “Enter your name..?”
                    • read name
                    • echo “Hello $name”
                  • read -p ” Enter a value: ” (press enter) [here,  ‘-p’ option is used for the prompt text. It reads the data in default variable reply] 
                    • echo ” $REPLY”  (press enter)
                  • read -n 15 -p ” Enter 15 characters only: ” (press enter) 
                • rename

                Definition
                Syntax
                Example
                • rm (Remove)

                Definition
                    • Used to remove/delete a file from a current working directory.
                Syntax
                    • $ rm filename (Press Enter)
                Example
                    • $ rm file1 (Press Enter)
                    • [Removes file1 from current working directory]
                    • $ rm /usr/dummy/prg/file1 (Press Enter)
                    • [Removes file1 from another directory(prg)]
                • rmdir (Remove Directory)

                Definition
                    • Used to delete/remove an empty directory/sub-directory, not file.
                Syntax
                    • $ rmdir directory_name (Press Enter)
                Example
                    • $ rmdir dir1 (Press Enter)

                    S

                    • sed

                      • SED stands for stream editor.
                      • This is a multi fuctions commands i.e., it performs a lot of functions on file such as searching, finding and replacing, insertion or deletion etc.
                    Definition
                      • SED is a fast, powerful and find and replace stream editor tool than VI editor because it can edit files even without opening them.
                    Syntax
                      • $ sed options (Press Enter)
                    Example
                      • To replace first occurrence of the text –
                        • $ sed ‘s/school/college/’ file1.txt (Press Enter)  [here, school is replaced by college in file1.txt file.]
                        • Here ‘s’ specifies the substitution operation. 
                        • By default, the sed command replaces the first occurrence of the search text/pattern in each line and it won’t replace the second, third…occurrence in the line.
                      • To replace nth (here 3rd)occurrence of the text –
                        • $ sed ‘s/school/college/3’ file1.txt (Press Enter) 
                      • To replace all occurrence(here g=global) of the text –
                        • $ sed ‘s/school/college/g’ file1.txt (Press Enter) 
                      • To replace all occurrence from nth found (here 3 to all)position of the text –
                        • $ sed ‘s/school/college/3g’ file1.txt (Press Enter) 
                      • To replace all occurrence of the text in a particular line(here it is 3)-
                        • $ sed ‘3 s/school/college/’ file1.txt (Press Enter) 
                      • To replace all occurrence of the text in a range of lines(here it is 3 to 6)-
                        • $ sed ‘3, 6 s/school/college/’ file1.txt (Press Enter) 
                      • To delete a particular line(here 3) –
                        • $ sed ‘3d’ file1.txt (Press Enter) 
                      • To delete the last line –
                        • $ sed ‘$d’ file1.txt (Press Enter) 
                      • To delete the range of line(here 3 to 6)-
                        • $ sed ‘3,6d’ file1.txt (Press Enter) 
                      • To Delete from nth to last line(here from 3 to last)-
                        • $ sed ‘3,$d’ file1.txt (Press Enter) 
                    • shutdown

                    Definition
                    Syntax
                    Example
                    • sort

                    Definition
                    Syntax
                    Example
                    • ssh

                    Definition
                    Syntax
                    Example
                    • stty

                    Definition
                      • This command enables us to see the previous erasing character by kill command. It also allows us to change them.
                      • This command also allows us to examine and alter many other terminal settings as well.

                    Syntax

                    Example

                    T

                    • tar

                    Definition
                    Syntax
                    Example
                    • tail

                    Definition
                      • Display the last few lines, usually 10 lines/characters of a file to the screen.
                    Syntax
                      • $ tail filename (Press Enter) 
                    Example
                      • $ tail file1.txt (Press Enter)       [ By default, to display the last 10 lines of a file to the screen.]
                      • $ tail -n 2 file1.txt (Press Enter)       [ To display the last 2 lines of a file to the screen.]
                      • $ tail -c 20 file1.txt (Press Enter)       [ To display the last 20 characters/bytes of a file to the screen.]
                    • time

                    Definition
                    Syntax
                    Example

                    U

                    • uname

                    Definition
                    Syntax
                    Example
                    • uniq

                      • uniq command isn’t able to detect the duplicate lines unless they are scattered rather adjacent to each other. Thus, the content in the file must be therefore sorted before using uniq command or we can simply use sort -u instead of uniq command. 
                    Definition
                      • This command is a utility command tool that reports or filters out the repeated/duplicate lines after detection from a file. 
                    Syntax
                    $uniq [OPTION] [INPUT[OUTPUT]]
                    Example
                      • $uniq file1.txt  [gives duplicate/repeated lines of contents, if any]
                      • $uniq -c file1.txt  [gives the no. of duplicate/repeated lines of contents, at the starting of each line in output file]
                      • $uniq -d file1.txt [ it only displayed one duplicate line per group and prints the repeated lines only]
                      • $uniq -D file1.txt [ it displayed all duplicate line per group and prints the repeated lines only]
                      • $uniq -u file1.txt [ only unique lines are displayed and prints these.]
                    • users

                    Definition
                    Syntax
                    Example

                    V

                    • vi

                       Definition
                      • It is a popular Editor of Linux/Unix  in which a user can create a new large file mainly for programming purpose or edit a created/existing file or to search a particular string.
                      • vi editor works in two mode- append/insert mode and edit mode.
                       Syntax
                      • $ vi file name (Press Enter)
                       Example
                      • $ vi abc.sh (Press Enter)

                    W

                    • w

                    Definition
                      • The ‘w’ command lists the currently logged in users to that network.
                    Example
                      • $ w (press enter)
                    • wall

                    Definition
                    Syntax
                    Example
                    • wc

                    Definition
                      • This command gives the number of lines, words and characters present in a file respectively.
                    Syntax
                      • $ wc filename (Press Enter)
                    Example
                      • $ wc file1 (Press Enter)
                    •            Output : 10 23 54 file1 (lines – 10, words – 23, characters – 54)
                    •  
                      • $ wc – 1 file1 (Press Enter)
                        • Output : 10  file1 (lines  – 10) Display only the total no. of lines in a file.
                      • $ wc -w file1 (Press Enter)
                        • Output : 23  file1 (words – 23) Display only the total no. of words in a file.
                      • $ wc -c file1 (Press Enter)
                        • Output : 54 file1 (characters – 54) Display only the total no. of characters in a file.
                    • wget

                    Definition
                    Syntax
                    Example
                    • who

                    Definition
                      • Displays the total no. of currently logged in user id in Linux environment along with terminal name the user working on, date & month, login time etc.
                    Syntax

                    $ who (press enter)

                    Example
                      • $ who -b (press enter) [Used to find the date the machine was started/booted.]
                      • $ who -q (press enter)[Used to find how many users are currently logged in this system/environment.]
                    • whoami

                    Definition
                      • Displays the currently logged in (myself) single user id only in Linux environment along with terminal name the user working on, date & month, login time etc.
                    Syntax
                      • $ who am I (press enter)
                    • whoareyou/whoitwas

                    Definition
                      • Functional in some versions of Linux/Unix.
                      • Similar as whoami command but sounds much more intelligent.
                    Syntax
                      • $ who am I (press enter)
                    • write

                    Definition
                    Syntax
                    Example

                    X

                    Y

                    Z

                    • zip

                    Definition
                    Syntax
                    Example

                    Loading

                    Categories: Unix/Linux OS

                    0 Comments

                    Leave a Reply

                    Your email address will not be published. Required fields are marked *

                    This site uses Akismet to reduce spam. Learn how your comment data is processed.