Table of Contents hide

Important Key Combination 

      • CTRL+C – To halt the current command.
      • CTRL+D – To save the written file contents, generate an end-of-file character, and log out of the current session, similar to exit.
      • CTRL+G – To resume the 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 the flow of long output of the screen temporarily so that a user can read it easily.
      • CTRL+U- To erase the whole line in the current cursor line from a paragraph of text.
      • CTRL+W – To erase one word in the current line.
      • CTRL+Z – To stop the current command, resume with the fg command in the foreground or the bg command in the background.
      • !! – Used to repeat the last command. 
      • exit – Log out of 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)              
  • The file name must be used with its extension name, if any.

Category of Unix/Linux Commands 

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

(a) Directory Commands

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

(a) File Commands

  • Those commands are mainly responsible for file-related processes/operations.
  • 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 are mainly responsible for input/output-related processes/operations.
  • Examples are – read, echo, etc.

(c) Process Commands

  • Those commands that are mainly responsible for system-related processes/operations act on user-given jobs.
  • Examples are – ps, top, kill, bg, fg, etc.

(d) Mathematical Commands

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

(e) Searching Commands

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

(f) Printing & Formatting Commands

  • Those commands 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 are mainly responsible for physical drive/ hard disk-related processes/operations.
  • Examples are – du, df, fdisk, lshw, sfdisk, free, etc 

(h) Network Commands

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

(i) Setup Commands

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

(j) Status Commands

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

(k) Program Controls Commands

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

(l) Data Editing Commands

  • Those commands 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 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 allows 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 a Linux command name it works, and thus, saves a few keystrokes/time.
      • Once Aliases are defined on the command line, they will die with the closing of the terminal window. 
      • To make aliases always available to us, it is better to add them to the.bash_aliases file in the Linux home directory.
Syntax
      • $ alias alias_name = Unix/Linux_commands_name.

Example

      • $ alias cls=clear.
      • $ cls (press enter)   [Clears the screen].
  • at

    • The alternative to this command is a cron command. However, at command execute jobs only once, whereas cron jobs are recurring events.
    • If this command is 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 second.
      • 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 5 PM (press enter) [this command schedules an echo command invocation at 5 PM]
    • 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 the awk command, we can define variables, use string and arithmetic operators, use control flow and loops, generate formatted reports, 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 outputs are “}
{print $0}’ file1.txt 
    • To create a title or a header and footer message for our output –
$ awk ‘BEGIN {print “The outputs are “}
{print $0} file1.txt
END {print “File printing finishes”}’ file1.txt
    • To assign values to 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 displays/prints the string message on the screen in floating/animated form, normally in capital letters.
    • Each line displays a maximum of 10 characters.
    • The message appears on the screen with a # 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 the first line and helpline in the second line as capital letters]
  • bc

Definition
    • This command makes any arithmetic calculation a calculator and gets results immediately.
Syntax
    • $ bc (press enter)
Example
    • $ bc (press enter)
_   2+5+6 (press enter)
     13 (Output)
     Press CTRL+D to come out from the bc command.
$_
  • bg

Definition
    • This command sends the recently (suspended) foreground process in the 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, year, or date, depending on what the system date has been set to.
    • This command displays the day/month/year details between 1 and 9999 years.
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 the 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 display the contents (only the 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 display 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 combine/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 a new directory (dir1) from the current working directory(dummy).]

       $ /usr/dummy/dir1

  • chmod (File Permissions and Ownership)

Definition
    • Linux implements a robust permission system to control access to files and directories. Every file and directory in Linux has:-
      • Owner: The user who owns the file.
      • Group: A group of users who have certain permissions.
      • Others: Users who are neither the owner nor in the group.
    • Permissions are divided into read (r), write (w), and execute (x), and are set for the owner, group, and others.
    • 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 purposes.
    • 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 the ls -l option we see a string of characters(10) in the following format that appears as –
      -rwxrwxrwx/drwxrwxrwx
      • Here the first character format of the string is a then the item is an (ordinary type of) file, if it is a d in place of the – 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 (rwx) represent the owner file permissions, the middle three (rwx) represent the group/group members file permissions and the rightmost group of three (rwx) characters represents the other user’s permissions.
    • If the letter r, w, or x character is present in the 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 (rwx) are present in a set of format strings it means that a particular category of users has full access permission otherwise partial access (–x) permission and in the case of no letters (—) i.e. no access permission.
    • There is a 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
      • The chpasswd command in Linux updates multiple user passwords in bulk by reading a list of username-password pairs from standard input or a file.
      • chpasswd commands expect input in the form of username:password, where each pair is on a new line. This input can be passed via a file or from a pipeline.
      • The chpasswd command is a useful tool for system administrators to manage/change passwords for multiple users at once efficiently. 
      • Only users with root or superuser privileges can change other users’ passwords.
      • Passwords updated using chpasswd are encrypted using the system’s default password encryption method unless a specific method is indicated (such as DES, MD5, SHA256, or SHA512).
    Syntax
      • $ chpasswd [options] (Press Enter)
    Example
      • Suppose we have a list of users and their corresponding passwords stored in a file called password.txt, with the format:-
    user1:newpassword1
    user2:newpassword2
    user3:newpassword3
    To update all the passwords at once, we can use:-
    sudo chpasswd < password.txt
    This will update the passwords for user1, user2, and user3.
    • chown

    Definition
      • This command allows us to change the user, owner, or group of owners of a file/directory or both.
      • As we know 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 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 file group ownership is changed to the user’s login group.
    USER: GROUP – If both the user and the group are specified (with no space between 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 a single user name (say dummy) – $ chown dummy: dummy example.txt (press enter) 
    • chroot

    Definition
      • The chroot command in Linux is used to change the root directory (/) for a given process and its child processes.
      • It is commonly used for testing, debugging, and enhancing security by limiting a process’s access to a specific directory tree.
      • The new root directory must contain the necessary binaries and libraries required for the desired commands to work.
      • The chroot command is a versatile tool for creating isolated environments in Linux. While it is primarily used for testing and system recovery, it offers basic security by restricting access to specific filesystem parts. System administrators typically use this command for:
        • Testing software in a controlled environment.
        • Repairing a damaged system from a rescue environment.
        • Running older software without affecting the main system.
    Syntax
      • chroot [OPTION] NEW_ROOT [COMMAND…] (Press Enter)

    Where

    NEW_ROOT: The directory to set as the new root (/).
    COMMAND: Optional command to execute within the new root environment. If omitted, a default shell is opened.
    Example
    mkdir /chroot_env (Press Enter)
    mkdir -p /chroot_env/{bin,lib,lib64}  (Press Enter)  (Copy required binaries and libraries)
    sudo chroot /chroot_env /bin/bash (Press Enter)

    chsh(change shell)

    Definition
      • The chsh command in Linux is used to change a user’s login shell.
      • It allows to specify which shell will be used as the default for a user when they log in.
      • The chsh command is a simple and secure way to manage user shells in Linux. It allows for customization of login environments, especially for users working with different shell preferences like bash, zsh, or fish
      • User shell information is stored in the /etc/passwd file.
    The format is : username:x:UID:GID:Comment:Home_Directory:Shell
    The example is : user1:x:1001:1001:user1:/home/user1:/bin/bash. Here, The last field (/bin/bash) is the user’s default shell.
    Syntax
      • chsh [OPTIONS] [USERNAME]

    where USERNAME is optional, whose shell do we want to change? If omitted, it applies to the current user.

    Example
      • chsh -s  /bin/bash (Press Enter) [Changes the current user’s default shell to bash.]

    The -s option to specify the path to the desired shell

      • sudo chsh -s /bin/zsh username (Press Enter)  [Changes the shell for the user username to /bin/zsh. It requires superuser privileges. ] 
      • cat /etc/shells (Press Enter)  [ To check the available shells/list all the valid shells ]

    /bin/bash
    /bin/sh
    /usr/bin/zsh
    /usr/bin/fish

      • sudo chsh -s /sbin/nologin username (Press Enter) [Prevents a user from logging in by setting their shell to /sbin/nologin.]
      • echo $SHELL   # Shows the current shell for the logged-in user.
    • clear

    Definition
      • Used to remove 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 remove the previous screen contents and the cursor remains at the bottom of the screen.
      • Applicable in a few versions of Unix/Linux.
    Syntax
      • $ clear screen (press enter)
    • cmp

    Definition
      • The cmp command in Linux is used to compare the contents of two files byte by byte.
      • It is often used for comparing binary files, but it can also be used with text files.
    Syntax
      • $ cmp [option] firstfilename secondfilename
    Example
      • $ cmp file1 file2 (press enter)
    • compress

    Definition
      • The compress command in Linux is used to compress files using the LZW (Lempel-Ziv-Welch) algorithm.
      • It creates compressed files with the same name and a  .Z extension, reducing file size to save disk space.
      • The compress command is a simple and quick tool for compressing files in Linux. However, for better compression and modern compatibility, tools like gzip and bzip2 are often preferred. The compress is primarily used when working with legacy systems or specific environments that require .Z files.
      • The compress command does not directly compress directories. However, we can use it with tar to compress directories: –

    tar -cf archive.tar directory_name
    compress archive.tar

    It creates archive.tar.Z compress directory.

      • The uncompress command is used to decompress .Z files.

    Syntax: uncompress filename .Z (Press Enter) [Restores the file to its original state as filename.]

      • The compress command is outdated and is less commonly used today as newer compression tools like gzip, bzip2, and xz provide better compression ratios. gzip( gzip filename ) is similar to compress, but more efficient. bzip2 (bzip2 filename) provides better compression than gzip. xz (xz filename) offers the highest compression ratio but is slower.
      • It produces .Z files/file format, which may not be compatible with modern tools without uncompress.
    Syntax
      • compress [OPTIONS] FILENAME… (Press Enter)
      • compress -v filename (Press Enter) [ Displays compression details, such as the compression ratio. Text files have a high compression ratio and Binary files (e.g., images, videos) have a Low compression ratio.]
    Example
      • compress file1 (Press Enter) [Compresses single file file1into file1.Z.]
      • compress file1 file2 file3 (Press Enter) [Compresses multiple files file1, file2, and file3 into file1.Z, file2.Z, and file3.Z.]
    • cp (Copy)

    Definition
        • It is used to make a 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 tasks regularly tasks as doing the backup every day at midnight, scheduling updates every week, and synchronizing the files at regular intervals.
        • It organizes the scheduled jobs based on their importance or frequency and groups 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 the 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 of 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 the second till the end of 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 the date or time. This is done by the 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 the 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 the mounted filesystem of the system]

    • dir

    Definition
      • This command lists the contents of the current directory.
      • It is similar to the 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 similarly to grep 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 files –
          • 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-
          • 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 for 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
        • The expr command in Linux is used for evaluating expressions and performing simple arithmetic calculations directly in the shell.
        • It is commonly used in shell scripting for tasks like arithmetic operations, string comparisons, and pattern matching.
        • 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
        • expr 5 + 3  (Press Enter)  Output: 8
        • expr 10 – 4  (Press Enter)  Output: 6
        • expr 4 \* 5    (Press Enter)  Output: 20 (Since the * character is treated as a wildcard in a shell, hence needs to escape it with a backslash \character.)   
        • expr 20 / 4    (Press Enter)  Output: 5
        • expr 17 % 3    (Press Enter)  Output: 2
        • expr “hello” = “hello”    (Press Enter)  Output: 1(True) [We can use expr statement for string comparisons to check if two strings are equal or not.]
        • expr “hello” != “hello”    (Press Enter)  Output: 0(False) 
        • expr length “hello”  (Press Enter)  Output: 5  [We can find the length of a string by using the length function within expr.]
        • expr substr “hello world” 1 5    (Press Enter)  Output: hello [We can extract a substring from a string using substr. This extracts 5 characters starting from position 1.]
        • expr index “hello” “e”    (Press Enter)  Output: 2 (position of ‘e’) [We can use expr to match patterns in a string using regular expressions. To find the position of a pattern index is used.]
        • expr “hello123world”: ‘.*\([0-9][0-9]*\)’    (Press Enter)  Output: 123 (extracts only numbers from the string)    [To extract a part of a string using a regular expression with expr. ]
        • ‘expr’ can also be used in a simple shell script to perform arithmetic operations:
      a=10
      b=20
      sum=$(expr $a + $b)
      echo “Sum Total is = $sum” 

        F

        • find

        Definition
        Syntax
        Example
        • finger

        Definition
          • This command gives a piece of 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 match the contents.
          • The matching text is highlighted in the lines of files.
        Syntax
          • $ grep searched contents/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 on 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 list commands again by typing an exclamation symbol (!) with the index number of the command from the history list. for example – !52
            • To repeat the previous command two exclamation symbols are 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 a bundle of arguments 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 interface details.
              • $ ifconfig (Enter)
            • The ifconfig command with the -a argument displays information on 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 interfaces –

              • $ 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 terminate a running process by giving the process ID (PID) of that process. 
            • This command also tells the Unix/Linux to kill the lines written on the $ prompt i.e. it ignores everything on the line on the 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 the page forward and backward we can use the Up or Down Arrow keys, PgUp or PgDn keys, or the Home, Space, or End keys.
            • To come out from the ‘less ‘ option,  press the ‘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 the 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 forms 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 the 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 this information are represented in symbolic form i.e. the first character of the first column represents the mode/type of file i.e. if the first letter is d- denotes directory, the – symbol denotes ordinary file, b&c denotes device, and 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 a slash(/) symbol denotes the 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 similarly to ls-l option except for owner and group name in place of UID and GID)
                  9. ls-wild character[*/?] (used to search files from the 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 a very compact form separated by a comma.)
                  13. ls directory_name (Used to display the contents of a 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 messages to other users who are connected to the network and are present/will come on other terminals. The coming user got the message when he/she logged in as an informative statement-There is a mail.
              • To read the mail message, the user can type mail on the $ 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 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 the current directory where we are working/present now. 
              Syntax
                • $ mkdir directory/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 the 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 a 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 command is available with Unix/Linux or Windows OS.
                • This is a very useful network command mainly used in network troubleshooting and performance measurement.
                • This command is very important and useful for Linux network administrators as well as system administrators to monitor and troubleshoot their network-related problems and determine network traffic performance.
                • In the 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 packet traffic.
                • It is believed that netstat command is one of the most basic network service debugging tools, telling us what ports are open or closed 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 a new one of the user who is logged currently into 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 the 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 the 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 it 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 first string before space in ‘x’, another string in ‘y’, and all the remaining strings 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 the 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 a file.
                Syntax
                    • $ rmdir directory_name (Press Enter)
                Example
                    • $ rmdir dir1 (Press Enter)

                    S

                    • sed

                      • SED stands for stream editor.
                      • This is a multi-functions command i.e., it performs a lot of functions on file such as searching, finding and replacing, insertion or deletion, etc.
                    Definition
                      • SED is a faster, 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 the 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, or third…occurrence in the line.
                      • To replace the 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 occurrences from the nth found (here 3 to all)position of the text –
                        • $ sed ‘s/school/college/3g’ file1.txt (Press Enter) 
                      • To replace all occurrences of the text in a particular line(here it is 3)-
                        • $ sed ‘3 s/school/college/’ file1.txt (Press Enter) 
                      • To replace all occurrences 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 the nth to the 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 the kill command. It also allows us to change them.
                      • This command also allows us to examine and alter many other terminal settings.

                    Syntax

                    Example

                    T

                    • tar

                    Definition
                      • The tar command in Linux is used to create, extract, and manipulate archive files.
                      • It stands for Tape Archive and is commonly used to package multiple files and directories into a single file (archive) or extract files from an archive.
                      • tar is one of the most commonly used tools in Linux for file archiving and backup purposes.
                    Syntax

                    $ tar [options] [archive-file] [file or directory to be archived] (Press Enter)

                    Example
                      • Create a tar archive (without compression)file
                    tar -cvf archive-name.tar /path/to/directory-or-file
                    where
                          • -c: Create an archive.
                          • -v: Verbose mode, shows file names being archived.
                          • -f: Specifies the archive file (archive-name.tar).
                      • Create a compressed tar archive file using gzip
                    tar -czvf archive-name.tar.gz /path/to/directory-or-file
                    where -z Compress with gzip.
                      • Create a compressed tar archive using bzip2
                    tar -cjvf archive-name.tar.bz2 /path/to/directory-or-file
                    where -j: Compress with bzip2.
                      • Extract a tar archive
                    tar -xvf archive-name.tar
                    where -x: Extract files from the archive.
                      • Extract a tar.gz archive
                    tar -xzvf archive-name.tar.gz
                    where -z: Handles the gzip compression during extraction.
                      • Extract a tar archive to a specific directory
                    tar -xvf archive-name.tar -C /path/to/destination
                    where -C: Extract the files to the specified directory.
                      • List the contents of a tar archive without extracting
                    tar -tvf archive-name.tar
                    where -t: List files in the archive.
                    • 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 duplicate lines unless they are scattered rather than adjacent to each other. Thus, the content in the file must be therefore sorted before using the uniq command or we can simply use the sort -u instead of the uniq command. 
                    Definition
                      • This command is a utility command tool that reports or filters out 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 start of each line in the 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 lines 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 purposes edit a created/existing file or search a particular string.
                      • vi editor works in append/insert mode and edit mode.
                       Syntax
                      • $ vi file name (Press Enter)
                       Example
                      • $ vi abc.sh (Press Enter)

                    W

                    • w

                    Definition
                      • The w command in Linux is used to display information about the users currently logged into the system, along with their activities.
                      • It provides an overview of who is logged in, what they are doing, and the system’s current load average.
                      • The w command is a powerful tool for system administrators to monitor logged-in users, their activities, and system performance. Its combination of user and system information makes it invaluable for troubleshooting and managing multi-user Linux environments.
                    Syntax
                      • $ w [OPTIONS] [USER] (press enter)
                    Example
                      • $ w (press enter) [Displays a summary of all users currently logged in and their activities.]. The typical output format of the w command looks like this:-
                    12:00:00 up 5 days,  4:22,  3 users,  load average: 0.15, 0.10, 0.05
                    USER     TTY      FROM             LOGIN@   IDLE   JCPU   PCPU   WHAT
                    User1   pts/0192.168.1.509:305:100.20s  0.15s  vim file.txt
                    User2   pts/1192.168.1.1010:001:000.30s  0.10s  bash
                    User3   pts/2    –                10:150.00s  0.40s  0.30s  sshd: User3

                    Where

                          • System Information:

                            • Time: Current system time (e.g., 12:00:00).
                            • Uptime: How long the system has been running (e.g., 5 days, 4:22).
                            • Users: Number of users logged in (e.g., 3 users).
                            • Load Average: System load average over the last 1, 5, and 15 minutes (e.g., 0.15, 0.10, 0.05).
                          • User Information:

                            • USER: Username of the logged-in user.
                            • TTY: Terminal type (e.g., pts/0 for pseudo-terminal).
                            • FROM: Hostname or IP address of the user (or – if unavailable).
                            • LOGIN@: Time the user logged in.
                            • IDLE: Duration of user inactivity.
                            • JCPU: Total CPU time for all processes run by the user in the session.
                            • PCPU: CPU time used by the current process.
                            • WHAT: The current process or command the user is running.
                      • w -h (press enter) [Display the user information mainly by removing the first line of system information/header.]
                      • w -i  (press enter)  [ Display IP address instead of hostname in the “FROM” field.]
                      • w user2 (press enter) [ Display activity details for a specific user such as user2.]
                    • wall

                    Definition
                      • The wall command in Linux sends a message to all logged-in users on the system.
                      • It broadcasts the message to all users who have messaging enabled on their terminals, making it a quick way to notify users, especially in multi-user environments.
                      • Only superusers (e.g., root) can use the wall command on some systems.
                      • Messages won’t appear on terminals with messaging when disabled (mesg n).
                      • The wall command is a practical tool for system administrators to broadcast messages to all users in real-time.
                      • It is especially useful for system-wide announcements and emergency alerts in a Linux multi-user environment.
                      • By default, the wall command includes a header with the sender’s username, hostname, and time. Use -n to suppress it if it is not needed. The header format is usually –
                    Broadcast message from root@server (pts/0) (Sat Dec 14 12:00:00 2024)
                    where
                          • root@server: The sender’s username and hostname.
                          • pts/0: The sender’s terminal device.
                          • Date and Time: When the message was sent.
                    Syntax

                    wall [OPTIONS] [MESSAGE]  (press enter)

                    Example
                      • $ wall “The server will undergo maintenance at midnight.” (press enter) – [Broadcast a Simple & common Message to all the logged-in users. ]
                      • $ wall message.txt (press enter) – [Sends the contents of message.txt to all logged-in users.]
                    • wc

                    Definition
                      • This command gives the number of lines, words, and characters in a file.
                    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
                      • The wget command in Linux is a non-interactive utility that downloads files from the specified web and saves them in the current directory.
                      • It supports HTTP, HTTPS, and FTP protocols and can work in the background, making it ideal for scripting and automated downloads.
                    Syntax
                      • wget [OPTIONS] URL (Press Enter)

                    Where the URL is the web address of the file to download.

                    Example
                      • wget https://example.com/file.zip (Press Enter)  [Downloads file.zip from the specified URL and save it in the current directory.]
                      • wget -O user_custom_name.zip https://example.com/file.zip (Press Enter) [Download and Save file.zip with a Specific Name user_custom_name.zip]
                      • wget -b https://example.com/largefile.zip (Press Enter) [Download largefile.zip file in the background.]
                      • wget –limit-rate=100k https://example.com/largefile.zip (Press Enter)  [ Limit download speed up to 100 KB/s).]
                      • wget -r https://example.com  (Press Enter)  [ Download all files and subdirectories from a website]
                      • wget -c https://example.com/largefile.zip (Press Enter)  [Resume an interrupted download.]
                      • wget –tries=5 https://example.com/file.zip  (Press Enter)   [Retries downloading up to 5 times if the download fails.]
                    • who

                    Definition
                      • Displays the total no. of currently logged-in user ID in a Linux environment along with the 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 a Linux environment along with the 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 to whoami command but sounds much more intelligent.
                    Syntax
                      • $ whoitwas (press enter)
                      • $ whoareyou (press enter)
                    • write

                    Definition
                      • The write command in Linux is used to send messages directly to another logged-in user on the same system.
                      • The wall command is used to send a message to all logged-in users.
                      • It’s a simple communication tool commonly used in multi-user environments.
                      • The write command is a quick and effective way to communicate with other users on the same system.
                      • It’s ideal for real-time messages in multi-user environments, though its usage is less common today due to modern messaging tools.
                      • The write command may be disabled on some systems for security or privacy reasons.
                      • We can only send messages to users who are currently logged into the system.
                    Syntax
                      • write USERNAME [TTY] (Press Enter)

                    where USERNAME is the username of the recipient and TTY is optional which defines the terminal device associated with the recipient. The TTY argument is mainly used to direct the message to a specific terminal if the user is logged into multiple terminals.

                    Example
                      • To send a message to the user :- 
                    First of all, use the who or w command to see all logged-in users and their terminal devices such as –
                    $ who (Press Enter)

                    user1   pts/0   2024-12-11 10:00
                    user2   pts/1   2024-12-11 10:05
                    ———————————————
                    Now, send a message to any of the listed users
                    write user2 pts/1 (Press Enter)
                    Hello, user2!
                    Are you free for a chat?
                    Ctrl+D (to come out from write message)
                    ———————————————
                    The recipient must have messaging features enabled to get the message.
                    (To allow messages enabled – mesg command with y option(Press Enter) and To block/disable messages – mesg n (Press Enter) )
                    If enabled then, Recipient (user2 sees this message):
                    Message from user1@hostname on pts/1 at 10:15
                    Hello, user2!
                    Are you free for a chat?

                    X

                    Y

                    Z

                    • zip

                    Definition
                      • The zip command is a versatile and user-friendly tool for compressing files and directories in Linux.
                      • The zip command in Linux is used to compress files and directories into a single archive file.
                      • It creates files with a .zip extension and is widely used due to its compatibility across different operating systems.
                      • Its high compatibility and options for encryption, exclusion, and recursion make it a go-to choice for archiving tasks.
                    Syntax
                      • zip [OPTIONS] ZIPFILE FILES…(Press Enter)

                    where ZIPFILE is the name of the output ZIP archive (e.g., archive.zip) and FILES are the files or directories to include in the ZIP archive.

                    Example
                      • To compress a single file :- zip my_file1.zip file1.txt (Press Enter) [It creates a my_file1 zip file containing file1.]
                      • To compress multiple files :- zip my_file2.zip file1.txt file2.txt file3.txt (Press Enter) [It creates my_file2.zip file that include file1, file2, and file3.]
                      • To compress a directory :- zip -r project.zip folder1 (Press Enter) [It compresses the folder1 directory (and all its contents) into project.zip.]
                      • To Add Password Protection to the zip file :- zip -e project.zip confidential.txt (Press Enter) [It prompts for a password to protect the project.zip file.]
                      • To make Zip file excluding some specific files :- zip project.zip * -x “*.bak” (Press Enter) [Compresses all files from the current directory into the project zip file excluding files with the .bak extension.]
                      • To Add Files to an Existing ZIP :- zip project.zip newfile1.txt (Press Enter) [It adds newfile.txt to the existing archive.zip file.]
                      • To Extract ZIP files :- unzip project.zip (Press Enter)
                      • To View/List the Contents of a ZIP File :- unzip -l project.zip (Press Enter) [Extracts the contents of project.zip into the current directory.]

                    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.