0% found this document useful (0 votes)
36 views60 pages

Unit - 1 Software Engineer Notes

Software Engineer notes Which help you to understand software Engineer
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
36 views60 pages

Unit - 1 Software Engineer Notes

Software Engineer notes Which help you to understand software Engineer
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 60

UNIT 1: INTRODUCTION TO LINUX AND LINUX UTILTIES

History:
Linux is an open-source operating system that was first created by Linus Torvalds
in 1991 while he was a student at the University of Helsinki in Finland. Torvalds
was interested in creating an operating system that was free and could be
customized by anyone, so he decided to create his own. Linux was originally
based on the Unix operating system and was released under the GNU General
Public License, which means that it is free to use and distribute. Since then, Linux
has become one of the most popular operating systems in the world, with millions
of users and developers working on it.
Architecture:

The Linux operating system's architecture mainly contains some of the


components: the Kernel, System Library, Hardware layer, System, and Shell
utility.

1. Kernel: The kernel is one of the core section of an operating system. It is


responsible for each of the major actions of the Linux OS. This operating system
contains distinct types of modules and cooperates with underlying hardware
directly. The kernel facilitates required abstraction for hiding details of low-level
hardware or application programs to the system. There are some of the important
kernel types which are mentioned below:

o Monolithic Kernel
o Micro kernels
o Exo kernels
o Hybrid kernels

MADE WITH AND HARDWORK BY VIKAS KUMAWAT


2. System Libraries: These libraries can be specified as some special functions.
These are applied for implementing the operating system's functionality and don't
need code access rights of the modules of kernel.

3. System Utility Programs: It is responsible for doing specialized level and


individual activities.

4. Hardware layer: Linux operating system contains a hardware layer that


consists of several peripheral devices like CPU, HDD, and RAM.

5. Shell: It is an interface among the kernel and user. It can afford the services of
kernel. It can take commands through the user and runs the functions of the
kernel. The shell is available in distinct types of OSes. These operating systems
are categorized into two different types, which are the graphical
shells and command-line shells.

The graphical line shells facilitate the graphical user interface, while the
command line shells facilitate the command line interface. Thus, both of these
shells implement operations. However, the graphical user interface shells work
slower as compared to the command-line interface shells.

Features:
Linux is known for its many features and benefits, including:
1. Open-source: Linux is an open-source operating system, which means that
the source code is freely available to anyone who wants to use, modify, or
distribute it.
2. Customizable: Linux can be customized to suit the needs of the user or
organization. Users can choose from a wide range of software packages
and desktop environments to create their own unique Linux distribution.
3. Security: Linux is known for its strong security features, including access
control, encryption, and firewall support.
4. Stability: Linux is known for its stability and reliability. It is commonly
used in servers and other mission-critical systems where downtime is not
an option.
5. Compatibility: Linux supports a wide range of hardware platforms,
including desktops, servers, embedded systems, and mobile devices.
6. Performance: Linux is known for its high performance, especially in multi-
tasking and multi-user environments.
7. Community support: Linux has a large and active community of users and
developers who contribute to the development of the operating system and
provide support to other users.

MADE WITH AND HARDWORK BY VIKAS KUMAWAT


Linux Commands :

Sudo :
The sudo command in Linux stands for "Superuser Do" and is used to execute
commands with administrative or root privileges.
When a command is executed with sudo, it runs with elevated permissions that
allow it to modify system files, directories, and other resources that are normally
restricted to regular users. This is useful for performing system maintenance tasks
or installing software that requires administrative privileges.
The basic syntax of the sudo command is:
sudo [options] [command]
Here, options can be used to specify additional arguments and command is the
command that you want to execute with elevated privileges.
Some common options used with sudo include:
 -u : Run the command as a different user.
 -s : Run the shell specified by the SHELL environment variable or the shell
specified by the sudoers file.
 -i : Run the command with a clean environment.
 -H : Set the HOME environment variable to the target user's home directory.

Note that sudo requires the user to enter their own password to confirm their
identity before executing the command with elevated privileges. The specific
requirements for using sudo can be configured in the /etc/sudoers file.
Using sudo can be dangerous, as it allows users to modify critical system files
and resources. As such, it should only be used by experienced users who
understand the risks involved.

MADE WITH AND HARDWORK BY VIKAS KUMAWAT


man :
The man command in Linux is used to display the manual pages (or simply "man
pages") for other commands, utilities, and system calls. These manual pages contain
detailed information about how to use a particular command, including its syntax,
options, and examples.
The basic syntax of the man command is:
man [section] [command]
Here, section specifies the section of the manual that you want to view (usually a
number from 1 to 8), and command is the name of the command or utility for which
you want to view the manual page. If section is not specified, man will search through
all available sections for a matching manual page.
For example, to view the manual page for the ls command, you would use the following
command: man ls
This would display the manual page for ls in the default section (usually section 1).
The sections of the manual pages are organized as follows:
Section 1: User commands
Section 2: System calls
Section 3: C library functions
Section 4: Device drivers and kernel interfaces
Section 5: File formats and conventions
Section 6: Games and screensavers
Section 7: Miscellanea
Section 8: System administration and privileged commands
You can view the manual page for a command in a specific section by specifying the
section number before the command name. For example, to view the manual page for
the chmod system call (which is in section 2), you would use the following command:
man 2 chmod
In addition to viewing manual pages, man also provides some navigation and search
functionality. For example, you can use the arrow keys or page up/down keys to scroll
through the manual page, and type / followed by a search term to search for a specific
term within the page. To exit the manual page, press the q key.

MADE WITH AND HARDWORK BY VIKAS KUMAWAT


echo :
The echo command in Linux is used to print a specified message or string to the
terminal output. It is one of the most commonly used commands in Linux shell
scripting and can be used for a variety of purposes, such as displaying status
messages, printing variables, and generating command output.
The basic syntax of the echo command is:
echo [options] [string]
Here, options can be used to specify additional arguments, and string is the
message or string that you want to display on the terminal. If string is not
provided, echo will simply output a blank line.
Some common options used with echo include:
-n : Do not output the trailing newline character.
-e : Interpret backslash escapes in the string (e.g. "\t" for a tab character).
-E : Do not interpret backslash escapes in the string (this is the default behavior).
For example, to display the message "Hello, world!" on the terminal, you would
use the following command:
echo "Hello, world!"
This would output the message "Hello, world!" on the terminal.
In addition to printing simple messages, echo can also be used to display the value
of a variable. For example, to display the value of a variable named myvar, you
would use the following command:
echo $myvar
This would display the value of myvar on the terminal.
Note that echo does not require any special privileges and can be used by any
user on the system.

MADE WITH AND HARDWORK BY VIKAS KUMAWAT


printf :
The printf command in Linux is used to format and print a specified message or
string to the terminal output. It is similar to the echo command but provides more
control over the output format.

The basic syntax of the printf command is:


printf format [arguments...]
Here, format specifies the output format for the message or string, and
arguments are the values that are used to fill in the placeholders in the format
string.
The format string can contain placeholders, which are indicated by the %
character followed by a letter that specifies the data type of the value to be printed.
Some common data type placeholders include:
%d : Decimal integer
%f : Floating-point number
%s : String
For example, to display the message "The value of x is 10" on the terminal, you
would use the following command:
printf "The value of x is %d\n" 10
This would output the message "The value of x is 10" on the terminal.
In addition to placeholders for data types, printf also supports various formatting
options, such as specifying the width and precision of a value, left or right
justification, and padding with zeros or spaces.
For example, to display the message "The value of pi is 3.14" on the terminal,
with the floating-point number formatted to two decimal places, you would use
the following command:
printf "The value of pi is %.2f\n" 3.14159
This would output the message "The value of pi is 3.14" on the terminal.
Note that printf does not require any special privileges and can be used by any
user on the system. However, because it provides more control over the output
format than echo, it is often used in shell scripting and other programming
contexts.

MADE WITH AND HARDWORK BY VIKAS KUMAWAT


script :
The script command in Linux is used to create a typescript of a terminal session.
It records all the commands and output that are generated during a terminal
session and saves them to a file for later review.
The basic syntax of the script command is:
script [options] [filename]
Here, options can be used to specify additional arguments, and filename is the
name of the file to which the typescript should be saved. If filename is not
provided, the typescript will be saved to a file named "typescript" in the current
directory.
Some common options used with script include:
-a : Append the typescript to an existing file instead of creating a new file.
-c : Run a command instead of starting an interactive shell.
-q : Run in quiet mode (do not display status messages).
For example, to start a typescript session and save the output to a file named
"session.log", you would use the following command:
script session.log
This would start a typescript session and save all the commands and output to the
file "session.log".
Once the typescript session is complete, you can exit by typing exit or pressing
Ctrl+D. The typescript file can then be opened in a text editor or viewed with the
cat command.
Note that the script command can be useful for troubleshooting and debugging
terminal sessions, as it provides a record of all the commands and output that
were generated during the session. However, it can also be used to capture
sensitive information such as passwords, so it should be used with caution and
only in appropriate contexts.

MADE WITH AND HARDWORK BY VIKAS KUMAWAT


Passwd :
The passwd command in Linux is used to change the password for a user account.
It is a command-line interface for the passwd system call, which updates the
encrypted password in the system password file.
The basic syntax of the passwd command is:
passwd [options] [username]
Here, options can be used to specify additional arguments, and username is the
name of the user account for which the password should be changed. If username
is not provided, passwd will change the password for the current user.
Some common options used with passwd include:
-l : Lock the specified user account (disable login).
-u : Unlock the specified user account (enable login).
-S : Display the status of the specified user account (locked or unlocked).
-d : Delete the password for the specified user account (allow login without a
password).
-e : Expire the password for the specified user account (force a password change
on next login).
-n : Set the minimum number of days between password changes.
-x : Set the maximum number of days between password changes.
For example, to change the password for a user account named "johndoe", you
would use the following command:
passwd johndoe
This would prompt you to enter the new password twice for the "johndoe"
account.
Note that the passwd command requires root privileges to change the password
for another user account. If you are not logged in as the root user, you will need
to use the sudo command to run passwd with elevated privileges.

MADE WITH AND HARDWORK BY VIKAS KUMAWAT


uname :
The uname command in Linux is used to display information about the system
and operating system on which it is running. The name "uname" stands for
"UNIX name".
The basic syntax of the uname command is:
uname [options]
Here, options can be used to specify additional arguments to control the output
format.
Some common options used with uname include:
-a : Display all available information about the system, including the kernel name,
version, hostname, processor type, and operating system.
-s : Display the kernel name (e.g. "Linux").
-n : Display the hostname of the system.
-r : Display the kernel release number.
-v : Display the kernel version.
-m : Display the machine hardware name.
-p : Display the processor type.
-i : Display the hardware platform (identical to -p on Linux systems).
-o : Display the operating system name.
For example, to display the kernel name and version on a Linux system, you
would use the following command:
uname -sr
This would output something like "Linux 5.4.0-88-generic".
The uname command can be useful for troubleshooting and system
administration tasks, such as verifying that the correct kernel version is installed,
checking system hardware information, and ensuring compatibility with software
packages.

MADE WITH AND HARDWORK BY VIKAS KUMAWAT


who :
The who command in Linux is used to display information about users who are
currently logged in to the system. It displays a list of usernames, login times, and
the terminal or display that each user is currently using.
The basic syntax of the who command is:
who [options]
Here, options can be used to specify additional arguments to control the output
format.
Some common options used with who include:
-a : Display information about all users, including system processes and logged-
out users.
-b : Display the time when the system was last booted.
-q : Display only the number of logged-in users.
-u : Display information about the login sessions of each user, including the time
of the last keystroke and the amount of CPU time used.
For example, to display a list of users who are currently logged in to the system,
you would use the following command:
who
This would output something like:
username tty1 2022-02-28 08:25 (:0)
username pts/0 2022-02-28 08:26 (:0)
This indicates that the user "username" is currently logged in on the local console
(tty1) and a remote terminal (pts/0).
The who command can be useful for monitoring user activity and managing
system resources. It can help you identify who is currently using the system,
which terminals or displays are in use, and how long each user has been logged
in.

MADE WITH AND HARDWORK BY VIKAS KUMAWAT


date :
The date command in Linux is used to display or set the system date and time. It
can display the current date and time, or it can be used to set the date and time to
a specific value.
The basic syntax of the date command is:
date [options] [+format]
Here, options can be used to specify additional arguments to control the output
format or behavior of the command, and +format is an optional argument that
specifies the date and time format to use.
Some common options used with date include:
-u : Display or set the date and time in Coordinated Universal Time (UTC).
-R : Display the date and time in RFC 2822 format.
-I : Display the date and time in ISO 8601 format.
-s : Set the system date and time to a specific value.
For example, to display the current date and time in the default format, you would
use the following command:
date
This would output something like:
Mon Mar 7 15:47:39 UTC 2022
To set the system date and time to a specific value, you would use the -s option
followed by the desired date and time in a specific format. For example, to set the
system date and time to March 7, 2022 at 3:30 PM, you would use the following
command:
sudo date -s "2022-03-07 15:30:00"
Note that setting the system date and time requires root privileges, so the sudo
command is used to run the date command with elevated privileges.
The date command can be useful for troubleshooting time-related issues,
scheduling tasks, and working with files that have specific date and time
requirements.

MADE WITH AND HARDWORK BY VIKAS KUMAWAT


stty :
The stty command in Linux is used to change or display terminal line settings. It
is used to configure various parameters related to the terminal, such as
input/output control, baud rate, character size, and flow control.
The basic syntax of the stty command is:
stty [options] [device]
Here, options can be used to specify various settings related to the terminal, and
device is the name of the device file associated with the terminal (usually /dev/tty
or /dev/console).
Some common options used with stty include:
-a : Display all current terminal settings.
-F : Specify a different device file to use for the terminal.
-echo : Turn off terminal echo (i.e. disable echoing of input characters to the
screen).
-icanon : Turn on canonical input mode (i.e. buffer input until a newline or EOF
is received).
-isig : Turn on signal generation for input events (e.g. generate SIGINT for
CTRL-C).
For example, to display the current terminal settings for the current terminal, you
would use the following command:
stty -a
This would output a list of settings and their current values, such as:
speed 38400 baud; rows 50; columns 200; line = 0;
intr = ^C; quit = ^\; erase = ^?; kill = ^U; eof = ^D; eol = <undef>; eol2 = <undef>; swtch = <undef>;
start = ^Q; stop = ^S; susp = ^Z; rprnt = ^R; werase = ^W; lnext = ^V; flush = ^O; min = 1; time = 0;

To change a terminal setting, you would use the appropriate stty option followed
by the desired value. For example, to turn off terminal echo, you would use the
following command: stty -echo
This would disable echoing of input characters to the screen.
The stty command can be useful for configuring terminal settings for specific use
cases or troubleshooting terminal-related issues.

MADE WITH AND HARDWORK BY VIKAS KUMAWAT


pwd :
The pwd command in Linux stands for "print working directory". It is used to
display the current working directory, which is the directory in the file system
that the user is currently working in.
For example, to display the current working directory, you would use the
following command:
pwd
This would output the path to the current working directory, such as:
/home/user/documents
The pwd command is useful when working with the command line interface, as
it allows you to keep track of the current directory as you navigate the file system.
You can use this command to verify the current directory before executing
commands or to specify the path to files or directories in subsequent commands.

MADE WITH AND HARDWORK BY VIKAS KUMAWAT


cd :
The cd command in Linux is used to change the current working directory to a
different directory in the file system. It stands for "change directory".
The basic syntax of the cd command is:
cd [directory]
Here, directory is the name of the directory that you want to change to. This can
be a relative or absolute path.
For example, to change the current working directory to the
/home/user/documents directory, you would use the following command:
cd /home/user/documents
This would change the current working directory to /home/user/documents.
Some common options used with cd include:
- : Change the current directory to the previous directory that you were in.
.. : Move up one directory level in the file system (i.e. change to the parent
directory).
. : Remain in the current directory (i.e. do nothing).
For example, to move up one directory level from the current directory, you
would use the following command:
cd ..
This would change the current working directory to the parent directory of the
current directory.
The cd command is an essential tool for navigating the file system in the
command line interface. It allows you to quickly move between directories and
access files and directories in different locations.

MADE WITH AND HARDWORK BY VIKAS KUMAWAT


mkdir :
The mkdir command in Linux is used to create a new directory in the file system.
It stands for "make directory".
The basic syntax of the mkdir command is:
mkdir [options] directory
Here, options can be used to specify additional arguments to control the behavior
of the command, and directory is the name of the directory that you want to
create.
For example, to create a new directory named "mydir" in the current working
directory, you would use the following command:
mkdir mydir
This would create a new directory named "mydir" in the current working
directory.
Some common options used with mkdir include:
-p : Create parent directories as needed (i.e. create all missing directories in the
specified path).
-m : Set the permissions for the new directory.
For example, to create a new directory named "mydir" and set the permissions to
755, you would use the following command:
mkdir -m 755 mydir
This would create a new directory named "mydir" in the current working
directory and set the permissions to rwxr-xr-x (755 in octal notation).
The mkdir command is an essential tool for creating new directories in the file
system. It is useful for organizing files and directories and creating a directory
structure that meets your needs.

MADE WITH AND HARDWORK BY VIKAS KUMAWAT


rmdir :
The rmdir command in Linux is used to remove a directory from the file system.
It stands for "remove directory".
The basic syntax of the rmdir command is:
rmdir [options] directory
Here, options can be used to specify additional arguments to control the behavior
of the command, and directory is the name of the directory that you want to
remove.
For example, to remove a directory named "mydir" in the current working
directory, you would use the following command:
rmdir mydir
This would remove the directory named "mydir" from the file system.
The rmdir command only works for removing empty directories. If the directory
contains files or other directories, you will need to use the rm command with the
-r or -R option to recursively remove the directory and its contents.
Some common options used with rmdir include:
-p : Remove parent directories as needed (i.e. remove all empty directories in the
specified path).
For example, to remove a directory named "mydir" and all its parent directories
if they are empty, you would use the following command:
rmdir -p mydir
This would remove the directory named "mydir" and any parent directories that
are empty.
The rmdir command is a useful tool for cleaning up the file system and removing
directories that are no longer needed.

MADE WITH AND HARDWORK BY VIKAS KUMAWAT


ls :
The ls command in Linux is used to list the files and directories in the current
working directory or in a specified directory. It stands for "list".
The basic syntax of the ls command is:
ls [options] [directory]
Here, options can be used to specify additional arguments to control the behavior
of the command, and directory is the name of the directory that you want to list
the contents of. If no directory is specified, ls will list the contents of the current
working directory.
For example, to list the files and directories in the current working directory, you
would use the following command:
ls
This would list the files and directories in the current working directory.
Some common options used with ls include:
-l : List the files and directories in long format, including detailed information
about each file or directory (e.g. permissions, owner, size, etc.).
-a : List all files and directories, including hidden files and directories (i.e. files
and directories that start with a dot ".").
-h : List file sizes in human-readable format (e.g. "10K" for 10 kilobytes).
For example, to list the files and directories in the current working directory in
long format, including hidden files and directories, you would use the following
command:
ls -la
This would list all files and directories in the current working directory, including
hidden files and directories, in long format.
The ls command is a useful tool for navigating the file system in the command
line interface. It allows you to quickly see what files and directories are present
in a directory, and to get additional information about those files and directories
if needed.

MADE WITH AND HARDWORK BY VIKAS KUMAWAT


cp :
The cp command in Linux is used to copy files and directories from one location
to another. It stands for "copy".
The basic syntax of the cp command is:
cp [options] source_file destination
Here, options can be used to specify additional arguments to control the behavior
of the command, source_file is the name of the file or directory that you want to
copy, and destination is the name of the target directory or file.
For example, to copy a file named "file.txt" from the current working directory
to a directory named "backup", you would use the following command:
cp file.txt backup/
This would copy the file named "file.txt" to the directory named "backup" in the
current working directory.
Some common options used with cp include:
-r : Copy directories recursively (i.e. copy all files and directories within the
directory).
-i : Prompt before overwriting existing files.
-v : Verbose output (i.e. show the names of files as they are being copied).
For example, to copy a directory named "dir" and all its contents to a directory
named "backup", and prompt before overwriting any existing files, you would
use the following command:
cp -ri dir backup/
This would copy the directory named "dir" and all its contents to the directory
named "backup" in the current working directory, and prompt before overwriting
any existing files.
The cp command is a useful tool for making backups of important files and for
copying files and directories between different locations.

MADE WITH AND HARDWORK BY VIKAS KUMAWAT


mv :
The mv command in Linux is used to move or rename files and directories from one
location to another. It stands for "move".
The basic syntax of the mv command is:
mv [options] source_file destination
Here, options can be used to specify additional arguments to control the behavior of the
command, source_file is the name of the file or directory that you want to move or
rename, and destination is the name of the target directory or file.
For example, to rename a file named "oldname.txt" to "newname.txt", you would use
the following command:
mv oldname.txt newname.txt
This would rename the file named "oldname.txt" to "newname.txt" in the current
working directory.
To move a file or directory to another location, you would specify the target directory
as the destination. For example, to move a file named "file.txt" to a directory named
"backup", you would use the following command:
mv file.txt backup/
This would move the file named "file.txt" to the directory named "backup" in the current
working directory.
Some common options used with mv include:
-i : Prompt before overwriting existing files.
-v : Verbose output (i.e. show the names of files as they are being moved).
For example, to move a directory named "dir" and all its contents to a directory named
"backup", and prompt before overwriting any existing files, you would use the
following command:
mv -i dir backup/
This would move the directory named "dir" and all its contents to the directory named
"backup" in the current working directory, and prompt before overwriting any existing
files.
The mv command is a useful tool for renaming and moving files and directories in the
command line interface. It allows you to quickly and easily organize your files and
directories and make changes to their names or locations.

MADE WITH AND HARDWORK BY VIKAS KUMAWAT


rm :
The rm command in Linux is used to remove or delete files and directories. It
stands for "remove".
The basic syntax of the rm command is:
rm [options] file(s)/directory(s)
Here, options can be used to specify additional arguments to control the behavior
of the command, and file(s)/directory(s) is the name of the file or directory that
you want to remove.
For example, to remove a file named "file.txt", you would use the following
command:
rm file.txt
This would delete the file named "file.txt" from the current working directory.
To remove a directory and all its contents, you would use the -r (recursive)
option. For example, to remove a directory named "dir" and all its contents, you
would use the following command:
rm -r dir
This would delete the directory named "dir" and all its contents from the current
working directory.
Some common options used with rm include:
-i : Prompt before removing each file.
-f : Force the removal of files without prompting for confirmation.
-v : Verbose output (i.e. show the names of files as they are being removed).
For example, to remove a file named "file.txt" and prompt before removing it,
you would use the following command:
rm -i file.txt
This would prompt you to confirm the removal of the file named "file.txt" before
deleting it.
The rm command is a powerful tool for deleting files and directories in the
command line interface. It should be used with caution, as it can permanently
delete files and directories without the ability to recover them.

MADE WITH AND HARDWORK BY VIKAS KUMAWAT


cat :
The cat command in Linux is used to display the contents of a file or concatenate
multiple files and display their contents together. It stands for "concatenate".
The basic syntax of the cat command is:
cat [options] file(s)
Here, options can be used to specify additional arguments to control the behavior
of the command, and file(s) is the name of the file or files whose contents you
want to display.
For example, to display the contents of a file named "file.txt", you would use the
following command:
cat file.txt
This would display the contents of the file named "file.txt" on the terminal.
To concatenate two or more files and display their contents together, you would
specify the names of the files in the order in which you want them to be displayed.
For example, to concatenate the contents of two files named "file1.txt" and
"file2.txt", you would use the following command:
cat file1.txt file2.txt
This would display the contents of "file1.txt" followed by the contents of
"file2.txt" on the terminal.
Some common options used with cat include:
-n : Number the output lines.
-E : Display a $ character at the end of each line.
-v : Display non-printing characters in a visible way.
For example, to display the contents of a file named "file.txt" with line numbers,
you would use the following command:
cat -n file.txt
This would display the contents of the file named "file.txt" with line numbers on
the terminal.
The cat command is a simple yet powerful tool for displaying the contents of a
file or concatenating multiple files. It is often used in shell scripting and other
command line operations.

MADE WITH AND HARDWORK BY VIKAS KUMAWAT


more :
The more command in Linux is used to display the contents of a file in a
paginated form. It is similar to the cat command, but instead of displaying the
entire file at once, it displays one page at a time and allows you to scroll
through the file.
The basic syntax of the more command is:
more [options] file(s)
Here, options can be used to specify additional arguments to control the
behavior of the command, and file(s) is the name of the file or files whose
contents you want to display.
For example, to display the contents of a file named "file.txt" using the more
command, you would use the following command:
more file.txt
This would display the first page of the file on the terminal. To scroll through
the file, you can press the space bar to display the next page or the enter key to
display the next line.
Some common options used with more include:
-d : Display the percentage of the file that has been displayed.
-f : Count logical rather than screen lines, i.e. lines containing newline
characters.
-c : Clear the screen before displaying each page.
-p : Specify a regular expression to search for in the file.
For example, to display the contents of a file named "file.txt" with the
percentage of the file that has been displayed, you would use the following
command:
more -d file.txt
This would display the first page of the file and show the percentage of the file
that has been displayed.
The more command is a useful tool for displaying the contents of large files in
a readable and navigable manner. It is often used in conjunction with other
commands in shell scripting and other command line operations.

MADE WITH AND HARDWORK BY VIKAS KUMAWAT


wc :
The wc command in Linux is used to count the number of lines, words, and
characters in a file or set of files. It stands for "word count".
The basic syntax of the wc command is:
wc [options] file(s)
Here, options can be used to specify additional arguments to control the behavior
of the command, and file(s) is the name of the file or files whose contents you
want to count.
For example, to count the number of lines, words, and characters in a file named
"file.txt", you would use the following command:
wc file.txt
This would display the number of lines, words, and characters in the file named
"file.txt" on the terminal.
Some common options used with wc include:
-l : Count only the number of lines.
-w : Count only the number of words.
-c : Count only the number of characters.
-m : Count the number of characters, including newline characters.
For example, to count only the number of lines in a file named "file.txt", you
would use the following command:
wc -l file.txt
This would display only the number of lines in the file named "file.txt" on the
terminal.
The wc command is a simple yet powerful tool for counting the number of lines,
words, and characters in a file or set of files. It is often used in shell scripting and
other command line operations.

MADE WITH AND HARDWORK BY VIKAS KUMAWAT


lp :
The lp command in Linux is used to print files to a printer connected to the
system. It stands for "line printer".
The basic syntax of the lp command is:
lp [options] file(s)
Here, options can be used to specify additional arguments to control the behavior
of the command, and file(s) is the name of the file or files that you want to print.
For example, to print a file named "file.txt" to the default printer, you would use
the following command:
lp file.txt
This would send the file to the default printer and start the printing process.
Some common options used with lp include:
-d : Specify the name of the printer to which the file should be sent.
-n : Specify the number of copies to print.
-o : Specify additional options for the printer, such as the paper size or orientation.
For example, to print a file named "file.txt" to a printer named "myprinter" with
two copies and double-sided printing, you would use the following command:
lp -d myprinter -n 2 -o sides=two-sided-long-edge file.txt
This would send the file to the printer named "myprinter", print two copies of the
file, and set the printing to be double-sided with the long edge as the binding
edge.
The lp command is a powerful tool for printing files from the command line. It
is often used in shell scripting and other command line operations to automate
printing tasks.

MADE WITH AND HARDWORK BY VIKAS KUMAWAT


od :
The od command in Linux is used to display the contents of a file in various
formats such as octal, decimal, hexadecimal, and ASCII. It stands for "octal
dump".
The basic syntax of the od command is:
od [options] file(s)
Here, options can be used to specify additional arguments to control the behavior
of the command, and file(s) is the name of the file or files whose contents you
want to display.
For example, to display the contents of a file named "file.txt" in hexadecimal
format, you would use the following command:
od -x file.txt
This would display the contents of the file named "file.txt" in hexadecimal format
on the terminal.
Some common options used with od include:
-c : Display the contents of the file in ASCII character format.
-b : Display the contents of the file in octal format.
-d : Display the contents of the file in decimal format.
-h : Display the contents of the file in hexadecimal format.
For example, to display the contents of a file named "file.txt" in ASCII character
format, you would use the following command:
od -c file.txt
This would display the contents of the file named "file.txt" in ASCII character
format on the terminal.
The od command is a useful tool for displaying the contents of a file in different
formats. It is often used in shell scripting and other command line operations to
analyze file contents.

MADE WITH AND HARDWORK BY VIKAS KUMAWAT


tar :
The tar command in Linux is used to create, extract, and manipulate archive files
in the tar format. It stands for "tape archive".
The basic syntax of the tar command is:
tar [options] [archive-file] [file(s) or directory]
Here, options can be used to specify additional arguments to control the behavior
of the command, archive-file is the name of the archive file to create or extract,
and file(s) or directory is the name of the file(s) or directory to include in the
archive.
For example, to create a new tar archive file named "archive.tar" from a directory
named "mydir", you would use the following command:
tar -cvf archive.tar mydir
This would create a new tar archive file named "archive.tar" containing the
contents of the directory named "mydir".
Some common options used with tar include:
-c : Create a new archive file.
-x : Extract the contents of an archive file.
-v : Verbose output, show progress while creating or extracting files.
-f : Specifies the name of the archive file to create or extract.
For example, to extract the contents of a tar archive file named "archive.tar" to
the current directory, you would use the following command:
tar -xvf archive.tar
This would extract the contents of the tar archive file named "archive.tar" to the
current directory.
The tar command is a powerful tool for managing archive files in the tar format.
It is often used in shell scripting and other command line operations to automate
file management tasks.

MADE WITH AND HARDWORK BY VIKAS KUMAWAT


gzip :
The gzip command in Linux is used to compress and decompress files in the gzip
format. It stands for "GNU zip".
The basic syntax of the gzip command is:
gzip [options] [file(s)]
Here, options can be used to specify additional arguments to control the behavior
of the command, and file(s) is the name of the file(s) you want to compress or
decompress.
For example, to compress a file named "file.txt", you would use the following
command:
gzip file.txt
This would compress the file named "file.txt" and create a new file named
"file.txt.gz" in the gzip format.
Some common options used with gzip include:
-d : Decompress a file.
-v : Verbose output, show progress while compressing or decompressing files.
-f : Force compression or decompression even if a file with the same name already
exists.
For example, to decompress a file named "file.txt.gz", you would use the
following command:
gzip -d file.txt.gz
This would decompress the file named "file.txt.gz" and create a new file named
"file.txt" in the uncompressed format.
The gzip command is a useful tool for compressing and decompressing files in
the gzip format. It is often used in shell scripting and other command line
operations to reduce the size of files and conserve disk space.

MADE WITH AND HARDWORK BY VIKAS KUMAWAT


Networking Commands -
unlink :
The unlink command in Linux is used to remove a file or symbolic link. It is
similar to the rm command, but is more commonly used to remove symbolic
links.
The basic syntax of the unlink command is:
unlink [file(s)]
Here, file(s) is the name of the file or symbolic link you want to remove.
For example, to remove a symbolic link named "link.txt", you would use the
following command:
unlink link.txt
This would remove the symbolic link named "link.txt" from the file system.
If you want to remove a regular file using unlink, you can use it in the same way
as the rm command, for example:
unlink file.txt
This would remove the regular file named "file.txt" from the file system.
The unlink command is a useful tool for removing files and symbolic links from
the file system. It is often used in shell scripting and other command line
operations to automate file management tasks.

MADE WITH AND HARDWORK BY VIKAS KUMAWAT


du :
The du command in Linux is used to estimate the file space usage for a specified
directory or file(s). It stands for "disk usage".
The basic syntax of the du command is:
du [options] [file(s)]
Here, options can be used to specify additional arguments to control the behavior
of the command, and file(s) is the name of the file(s) or directory you want to
check the disk usage of.
For example, to check the disk usage of a directory named "mydir", you would
use the following command:
du mydir
This would show you the total disk space used by the files and subdirectories
within the "mydir" directory.
Some common options used with du include:
-h : Human-readable output, display disk usage in a more readable format, such
as in "K", "M", "G" units.
-s : Summary, display only the total disk space used by the specified file(s) or
directory.
-c : Total, display the total disk space used by all specified files or directories.
For example, to display the disk usage of a directory named "mydir" in human-
readable format, you would use the following command:
du -h mydir
This would display the disk usage of the "mydir" directory in a more readable
format.
The du command is a useful tool for checking the disk usage of files and
directories on your system. It is often used in shell scripting and other command
line operations to monitor disk usage and free up disk space when needed.

MADE WITH AND HARDWORK BY VIKAS KUMAWAT


df :
The df command in Linux is used to display information about the file system
disk space usage. It stands for "disk free".
The basic syntax of the df command is:
df [options] [file(s)]
Here, options can be used to specify additional arguments to control the behavior
of the command, and file(s) is the name of the file(s) or directory you want to
check the disk space usage of.
For example, to display the disk space usage of all file systems mounted on your
system, you would use the following command:
df
This would display information about the disk space usage for all mounted file
systems on your system, including the total size, used space, and available space.
Some common options used with df include:
-h : Human-readable output, display disk usage in a more readable format, such
as in "K", "M", "G" units.
-T : File system type, display the file system type along with the disk usage
information.
-i : Inode usage, display information about the inode usage in addition to the disk
space usage.
For example, to display the disk space usage of all file systems mounted on your
system in human-readable format, you would use the following command:
df -h
This would display the disk space usage of all mounted file systems on your
system in a more readable format.
The df command is a useful tool for checking the disk space usage of file systems
on your system. It is often used in shell scripting and other command line
operations to monitor disk usage and free up disk space when needed.

MADE WITH AND HARDWORK BY VIKAS KUMAWAT


mount :
The mount command in Linux is used to mount a file system (such as a partition,
a CD-ROM or a USB drive) at a specific mount point in the directory tree.
The basic syntax of the mount command is:
mount [options] device mountpoint
Here, options can be used to specify additional arguments to control the behavior
of the command, device is the device file of the file system you want to mount
(e.g. /dev/sda1), and mountpoint is the directory where you want to mount the
file system.
For example, to mount a USB drive at the /mnt/usb mount point, you would use
the following command:
mount /dev/sdb1 /mnt/usb
This would mount the file system on the USB drive (assuming it is located at
/dev/sdb1) at the /mnt/usb mount point.
Some common options used with mount include:
-t : File system type, specify the file system type of the device.
-o : Mount options, specify additional mount options (such as read-only mode or
noexec mode).
For example, to mount an ISO file at the /mnt/iso mount point and specify that it
should be mounted in read-only mode, you would use the following command:
mount -t iso9660 -o ro /dev/cdrom /mnt/iso
This would mount the file system on the CD-ROM at the /mnt/iso mount point
in read-only mode.
The mount command is a powerful tool for managing file systems in Linux. It
allows you to mount and unmount file systems as needed, and to specify
additional mount options to control how the file system is accessed.

MADE WITH AND HARDWORK BY VIKAS KUMAWAT


umount :
The umount command in Linux is used to unmount a file system, which is a
process of detaching a file system from the file hierarchy. This allows the file
system to be safely removed or disconnected from the system.
The basic syntax of the umount command is:
umount [options] mountpoint
Here, options can be used to specify additional arguments to control the behavior
of the command, and mountpoint is the directory where the file system is
currently mounted.
For example, to unmount a USB drive that is mounted at the /mnt/usb mount
point, you would use the following command:
umount /mnt/usb
This would unmount the file system on the USB drive that is currently mounted
at /mnt/usb. Note that you need to have root privileges (i.e. use sudo) to unmount
a file system.
Some common options used with umount include:
-f : Force unmount, forcibly unmount the file system if it is busy.
-l : Lazy unmount, detach the file system from the file hierarchy now, and cleanup
everything later.
For example, to forcibly unmount a file system mounted at /mnt/usb even if it is
busy, you would use the following command:
umount -f /mnt/usb

The umount command is a powerful tool for managing file systems in Linux. It
allows you to unmount file systems as needed, and to specify additional options
to control how the file system is unmounted.

MADE WITH AND HARDWORK BY VIKAS KUMAWAT


find :
The find command in Linux is used to search for files and directories in a
directory hierarchy based on various criteria such as name, type, size, ownership,
modification time, and more.
The basic syntax of the find command is:
find [path] [expression]
Here, path is the directory or path where the search will start, and expression is
the set of conditions that will be used to search for files and directories.
For example, to find all files with the name "example.txt" in the current directory
and its subdirectories, you would use the following command:
find . -name "example.txt"
This would search for all files named "example.txt" in the current directory
(represented by .) and all its subdirectories.
Some common options used with find include:
-type : Specifies the type of file to search for (e.g. -type f for regular files, -type
d for directories).
-size : Specifies the size of files to search for (e.g. -size +10M for files larger than
10 megabytes).
-mtime : Specifies the modification time of files to search for (e.g. -mtime -7 for
files modified in the last 7 days).
-user : Specifies the user that owns the files to search for (e.g. -user john for files
owned by user "john").
For example, to find all directories named "docs" that were modified in the last 7
days in the /home/user directory, you would use the following command:
find /home/user -type d -name "docs" -mtime -7
This would search for all directories named "docs" in the /home/user directory
that were modified in the last 7 days.
The find command is a powerful tool for searching for files and directories in a
directory hierarchy based on various criteria. It allows you to specify complex
search criteria and can be combined with other commands to perform more
advanced operations.

MADE WITH AND HARDWORK BY VIKAS KUMAWAT


unmask :
In Linux, the umask command is used to set the default file permissions for
newly created files and directories. The umask value is subtracted from the
default permissions to determine the final permissions.
The default umask value is usually 022, which means that newly created files
will have permissions of 644 (readable and writable by the owner, and readable
by others), and newly created directories will have permissions of 755 (readable,
writable, and searchable by the owner, and readable and searchable by others).
The umask value can be set using the umask command followed by a three-digit
octal value that represents the permissions to be masked. For example, to set the
umask value to 027, you would use the following command:
umask 027
This would set the umask value to 027, which means that newly created files will
have permissions of 640 (readable and writable by the owner, and not readable
by others), and newly created directories will have permissions of 750 (readable,
writable, and searchable by the owner, and not readable or searchable by others).
The umask command can be used in conjunction with other commands, such as
mkdir and touch, to set the default permissions for newly created files and
directories. For example, to create a new directory with permissions of 755
(readable, writable, and searchable by the owner, and readable and searchable by
others), you would use the following command:
mkdir -m 755 newdir
This would create a new directory named "newdir" with permissions of 755.

MADE WITH AND HARDWORK BY VIKAS KUMAWAT


ulimit :
The ulimit command in Linux is used to set or display resource limits for the
current shell and its child processes.
By default, the ulimit command displays the current resource limits for the
current shell. These limits can include:
 The maximum size of files that can be created (-f)
 The maximum size of core files that can be created (-c)
 The maximum size of the data segment (-d)
 The maximum size of the stack segment (-s)
 The maximum number of open file descriptors (-n)
 The maximum number of processes that can be created by a user (-u)
 The maximum size of memory that can be locked into RAM (-l)
To set a new limit for a particular resource, you can use the ulimit command
followed by the resource flag and the new limit. For example, to set the maximum
number of open file descriptors to 5000, you would use the following command:
ulimit -n 5000
This would set the maximum number of open file descriptors to 5000 for the
current shell and its child processes.
Note that the ulimit command can only be used to set resource limits within the
limits of what the system allows. Additionally, changes made using the ulimit
command only apply to the current shell and its child processes, and do not affect
other processes on the system. To make permanent changes to resource limits,
you may need to modify system-wide configuration files.

MADE WITH AND HARDWORK BY VIKAS KUMAWAT


ps :
The ps command in Linux is used to display information about currently running
processes. It is a powerful tool for process management and troubleshooting.
By default, the ps command displays a list of processes running in the current
shell. It shows the process ID (PID), the terminal associated with the process
(TTY), the status of the process (STAT), the amount of CPU time used by the
process (TIME), and the command that started the process (CMD).
There are several options that can be used with the ps command to customize its
output. Some of the most commonly used options include:
-e: Displays information about all running processes on the system, not just those
associated with the current shell.
-f: Provides a more detailed output format that includes the parent process ID
(PPID), the user who started the process, the start time of the process, and more.
-u <user>: Displays information about all processes owned by the specified user.
-aux: This is a commonly used option that displays a detailed list of all running
processes, including information about CPU and memory usage, start time, and
more.
For example, to display a detailed list of all running processes on the system,
sorted by CPU usage, you could use the following command:
ps aux --sort=-%cpu
This would display a list of all processes on the system, sorted by CPU usage in
descending order.
Note that the output of the ps command can be customized using various options
and formatting codes. It is a powerful tool for monitoring and managing processes
on a Linux system.

MADE WITH AND HARDWORK BY VIKAS KUMAWAT


w:
The w command in Linux is used to display information about currently logged-
in users and their activities. It provides a quick summary of who is logged in to
the system, what they are doing, and how long they have been active.
By default, the w command displays the following information for each logged-
in user:
 User: the username of the logged-in user.
 TTY: the terminal device associated with the user's login session.
 From: the remote host or IP address from which the user is connected.
 Login@: the time at which the user logged in.
 Idle: the amount of time the user has been idle.
 JCPU: the amount of CPU time used by all processes associated with the user's
login session.
 PCPU: the amount of CPU time used by the most CPU-intensive process
associated with the user's login session.
 Command: the name of the command currently being executed by the user, or
the name of the user's shell.
There are several options that can be used with the w command to customize its
output. Some of the most commonly used options include:
-h: Disables the header that is normally displayed at the top of the output.
-u <user>: Displays information about the specified user only.
-f: Provides a more detailed output format that includes the UID, PID, and PPID
of each process associated with the user's login session.
For example, to display a list of all currently logged-in users, you could use the
following command:
w
This would display a list of all users currently logged in to the system, along with
information about their activities.
Note that the w command is a useful tool for system administrators to monitor
user activity on a Linux system.

MADE WITH AND HARDWORK BY VIKAS KUMAWAT


finger :
The finger command in Linux is used to display information about one or more users
on the system. It is typically used to get a quick summary of a user's login name, full
name, home directory, login time, and whether they are currently logged in or not.
By default, the finger command displays the following information for each user
specified:
 Login: the user's login name.
 Name: the user's full name (if available).
 Directory: the user's home directory.
 Shell: the user's login shell.
 Last login: the date and time the user last logged in to the system.
 Idle: the length of time since the user last typed anything into the terminal.
 JCPU: the amount of CPU time used by all processes associated with the user's login
session.
 PCPU: the amount of CPU time used by the most CPU-intensive process associated
with the user's login session.
 What: the user's current activity or command being executed.
There are several options that can be used with the finger command to customize its
output. Some of the most commonly used options include:
-s: Displays a shorter output format that excludes the user's full name and home
directory.
-l: Displays a more detailed output format that includes additional information such as
the user's login class, the date their account was created, and their mail status.
-m: Forces the output to be in a machine-readable format.
<username>: Specifies the username or usernames to display information for.
For example, to display information about the user "john", you could use the following
command:
finger john
This would display information about the user "john", including their login name, full
name (if available), home directory, login time, and current activity.
Note that the finger command is not installed by default on some Linux distributions
due to potential security issues, and may need to be installed separately.

MADE WITH AND HARDWORK BY VIKAS KUMAWAT


arp :
The arp command in Linux is used to display and manipulate the Address
Resolution Protocol (ARP) cache. ARP is a protocol used to map a network
address (such as an IP address) to a physical address (such as a MAC address).
The ARP cache is a table that stores this mapping information, allowing a device
to quickly look up the physical address of another device on the same network.
The most commonly used options for the arp command are:
-a or --all: Displays the current contents of the ARP cache.
-d or --delete <hostname>: Deletes the entry for the specified hostname from
the ARP cache.
-s or --set <hostname> <mac address>: Adds a static entry to the ARP cache,
mapping the specified hostname to the specified MAC address.
For example, to display the current contents of the ARP cache, you can use the
following command:
arp -a
This will show a list of all the devices that have been recently accessed on the
local network, along with their IP and MAC addresses.
To add a static entry to the ARP cache, you can use the -s option followed by the
hostname and MAC address:
arp -s 192.168.0.2 00:11:22:33:44:55
This will add an entry to the ARP cache mapping the IP address 192.168.0.2 to
the MAC address 00:11:22:33:44:55. This entry will persist until it is deleted or
the system is rebooted.
Note that the arp command may require root privileges to run certain operations,
such as modifying the ARP cache.

MADE WITH AND HARDWORK BY VIKAS KUMAWAT


ftp :
The ftp command in Linux is used to connect to a remote FTP server and transfer
files between the local system and the remote server. FTP (File Transfer Protocol)
is a standard network protocol used to transfer files between a client and a server
on a computer network.
Here are some commonly used options for the ftp command:
-n: Disables automatic login to the FTP server. This is useful when scripting FTP
commands.
-v: Enables verbose output, displaying additional information about the FTP
connection and transfer process.
-p: Enables passive mode FTP. This can be useful when connecting to FTP
servers behind firewalls or NAT devices.
Here's an example of how to use the ftp command to connect to an FTP server:
ftp ftp.example.com
This will connect to the FTP server at ftp.example.com. You will be prompted
to enter your username and password to log in.
Once you are logged in, you can use a variety of commands to interact with the
FTP server, such as:
ls: Lists the contents of the current directory on the remote server.
cd: Changes the current directory on the remote server.
get: Downloads a file from the remote server to the local system.
put: Uploads a file from the local system to the remote server.
For example, to download a file named example.txt from the remote server to
the local system, you can use the following command:
get example.txt
This will download the file to the current directory on the local system.
To exit the FTP session, you can use the bye or exit command.

MADE WITH AND HARDWORK BY VIKAS KUMAWAT


telnet :
The telnet command in Linux is used to connect to a remote host over a network
using the Telnet protocol, which allows a user to access a command-line interface
(CLI) on the remote host as if they were physically connected to it.
Here are some commonly used options for the telnet command:
-l: Specifies a username to use when logging in to the remote host.
-a: Specifies that the terminal type should be set to "ansi" when connecting to the
remote host.
-E: Disables the local echo feature, which echoes characters typed on the local
terminal back to the terminal. This can be useful for password entry, as it prevents
the password from being displayed on the screen.
Here's an example of how to use the telnet command to connect to a remote host:
telnet example.com
This will connect to the host at example.com. You will be prompted to enter your
username and password to log in.
Once you are logged in, you can use a variety of commands to interact with the
remote host, such as running shell commands, launching applications, and so on.
For example, you can run the ls command to list the contents of the current
directory, or run a text editor to edit a file on the remote host.
To exit the Telnet session, you can use the quit or exit command. Note that the
Telnet protocol is not secure, as it sends all data, including passwords, in plain
text. It is recommended to use SSH instead for secure remote access.

MADE WITH AND HARDWORK BY VIKAS KUMAWAT


rlogin :
The rlogin command in Linux is used to connect to a remote host over a network
using the Remote Login (rlogin) protocol. This protocol is similar to Telnet, but
it provides additional security features, such as password encryption and user
authentication based on the .rhosts file.
Here are some commonly used options for the rlogin command:
-l: Specifies a username to use when logging in to the remote host.
-L: Enables the use of local echo mode, which echoes characters typed on the
local terminal back to the terminal. This can be useful for debugging purposes.
Here's an example of how to use the rlogin command to connect to a remote host:
rlogin example.com
This will connect to the host at example.com. You will be prompted to enter your
username and password to log in. If you have set up the .rhosts file correctly, you
may not be prompted for a password.
Once you are logged in, you can use a variety of commands to interact with the
remote host, such as running shell commands, launching applications, and so on.
For example, you can run the ls command to list the contents of the current
directory, or run a text editor to edit a file on the remote host.
To exit the rlogin session, you can use the exit command. Note that the rlogin
protocol is not considered secure, and it is recommended to use SSH instead for
secure remote access.

MADE WITH AND HARDWORK BY VIKAS KUMAWAT


Text Processing Commands -
tail :
The tail command in Linux is used to display the last part of a file. By default, it
prints the last 10 lines of a file, but you can specify a different number of lines
with the -n option.
Here are some commonly used options for the tail command:
-n: Specifies the number of lines to display from the end of the file. For example,
tail -n 20 file.txt will display the last 20 lines of file.txt.
-f: Causes tail to follow the file in real-time, displaying new lines as they are
added. This is useful for monitoring log files or other continuously updated files.
-c: Specifies the number of bytes to display from the end of the file. For example,
tail -c 1024 file.txt will display the last 1024 bytes of file.txt.
-q: Suppresses the header that displays the file name when multiple files are
specified.
Here's an example of how to use the tail command to display the last 20 lines of
a file:
tail -n 20 file.txt
This will display the last 20 lines of file.txt. You can also use the -f option to
monitor a file in real-time, like this:
tail -f log.txt
This will display new lines as they are added to log.txt, allowing you to monitor
the file for changes. To exit the tail command, you can press Ctrl-C to interrupt
the process.

MADE WITH AND HARDWORK BY VIKAS KUMAWAT


head :
The head command in Linux is used to display the first part of a file. By default,
it prints the first 10 lines of a file, but you can specify a different number of lines
with the -n option.
Here are some commonly used options for the head command:
-n: Specifies the number of lines to display from the beginning of the file. For
example, head -n 20 file.txt will display the first 20 lines of file.txt.
-c: Specifies the number of bytes to display from the beginning of the file. For
example, head -c 1024 file.txt will display the first 1024 bytes of file.txt.
-q: Suppresses the header that displays the file name when multiple files are
specified.
Here's an example of how to use the head command to display the first 20 lines
of a file:
head -n 20 file.txt
This will display the first 20 lines of file.txt. You can also use the -c option to
display the first N bytes of a file, like this:
head -c 1024 file.txt
This will display the first 1024 bytes of file.txt.

MADE WITH AND HARDWORK BY VIKAS KUMAWAT


sort :
The sort command in Linux is used to sort lines of text in a file or standard input
alphabetically, numerically or in user-defined order. By default, it sorts text in
ascending order, but it can be used to sort in descending order as well.
Here are some commonly used options for the sort command:
-r: Sorts the text in reverse order, i.e. in descending order.
-n: Sorts the text in numerical order.
-k: Sorts the text based on a specific field or column. You can specify the field
number using the -k option. For example, sort -k 2 file.txt will sort the text based
on the second field.
-t: Specifies the field separator. By default, sort uses whitespace as the field
separator. You can specify a different separator using the -t option. For example,
sort -t ':' -k 2 file.txt will use the colon character as the field separator.
Here's an example of how to use the sort command to sort the lines of a file in
ascending order:
sort file.txt
This will sort the lines of file.txt in ascending order based on the default field
separator, which is whitespace. If you want to sort the lines in descending order,
you can use the -r option, like this:
sort -r file.txt
If the lines in the file are delimited by a specific character, like a comma or a
colon, you can specify the delimiter using the -t option, like this:
sort -t ':' -k 2 file.txt
This will sort the lines of file.txt based on the second field, which is separated by
a colon character.

MADE WITH AND HARDWORK BY VIKAS KUMAWAT


nl :
The nl command in Linux is used to add line numbers to a file or standard input.
It is often used in conjunction with other commands that generate large amounts
of output to provide an easy way to locate specific lines within that output.
Here are some commonly used options for the nl command:
-b: Specifies the type of numbering to use. The -b option can be used with one of
three arguments:
a: Adds line numbers to all lines.
t: Adds line numbers to all non-empty lines.
n: Does not add any line numbers.
-n: Specifies the starting line number. By default, nl starts line numbering at 1.
You can specify a different starting line number using the -n option.
-w: Specifies the minimum width of the line numbers. By default, nl pads the line
numbers with leading zeros so that they are all the same width. You can specify
a different minimum width using the -w option.
Here's an example of how to use the nl command to add line numbers to a file:
nl file.txt
This will add line numbers to each line of file.txt, starting with 1 and padding the
line numbers with leading zeros so that they are all the same width.
If you want to start the line numbering at a different number, you can use the -n
option, like this:
nl -n 10 file.txt
This will add line numbers to each line of file.txt, starting with 10 and padding
the line numbers with leading zeros so that they are all the same width.
If you want to use a different type of numbering, you can use the -b option, like
this:
nl -b t file.txt
This will add line numbers to all non-empty lines of file.txt, starting with 1 and
padding the line numbers with leading zeros so that they are all the same width.

MADE WITH AND HARDWORK BY VIKAS KUMAWAT


uniq :
The uniq command is a Linux/Unix command that is used to remove duplicate lines
from a file. It takes an input file as argument, removes any duplicate lines in it, and
writes the result to the output.
Here are some commonly used options for the uniq command:
-c: This option counts the number of occurrences of each line and precedes it with its
count.
-d: This option prints only the duplicate lines from the input file.
-i: This option ignores the case sensitivity of the input file.
-u: This option prints only the unique lines from the input file.
-w: This option specifies the number of characters to compare when checking for
duplicates.
Here's an example of how to use the uniq command:
Suppose we have a file named example.txt with the following contents:
apple
banana
apple
orange
banana
To remove duplicate lines and print only unique lines, we can use the following
command:
uniq example.txt
This will output:
apple
banana
orange
To count the number of occurrences of each line, we can use the -c option:
uniq -c example.txt
This will output:
2 apple
2 banana
1 orange
To print only the duplicate lines from the input file, we can use the -d option:
uniq -d example.txt
This will output:
apple
banana

MADE WITH AND HARDWORK BY VIKAS KUMAWAT


grep :
The grep command is a Linux/Unix command used to search for specific patterns of
characters or text strings in files. It allows you to search for text within one or more
files, and can be used with regular expressions to specify complex search patterns.
Here are some commonly used options for the grep command:
-i: This option enables case-insensitive searching.
-n: This option prints the line numbers of the matching lines.
-r: This option searches all files in a directory and its subdirectories recursively.
-v: This option inverts the search, showing only lines that do not match the pattern.
-w: This option matches the whole word only and not just a substring.
Here's an example of how to use the grep command:
Suppose we have a file named example.txt with the following contents:
apple
banana
cherry
date
elderberry

To search for the word "apple" in the file, we can use the following command:
grep apple example.txt
This will output: apple
To search for the word "berry" in the file, ignoring case sensitivity, we can use the -i
option:
grep -i berry example.txt
This will output: elderberry
To search for the word "berry" in the file, showing the line numbers of the matching
lines, we can use the -n option:
grep -n berry example.txt
This will output: 5:elderberry
To search for the word "berry" in all files within a directory and its subdirectories
recursively, we can use the -r option:
grep -r berry /path/to/directory
This will output all matching lines in all files within the directory and its subdirectories.

MADE WITH AND HARDWORK BY VIKAS KUMAWAT


egrep:
egrep is a command-line tool in Linux used to search for regular expressions in
a file or files. The egrep command stands for "extended global regular expression
print". It is similar to the grep command, but it supports a more extended set of
regular expressions.
The basic syntax of egrep command is:
egrep [options] pattern [files]
Some of the commonly used options with the egrep command are:
-i: This option performs case-insensitive searching.
-v: This option returns all the lines that do not match the specified pattern.
-w: This option matches the whole word.
-c: This option displays the count of matching lines.
-r: This option searches for files recursively in the specified directory.
For example, the following command will search for the lines that contain the
word "example" in the file "test.txt":
egrep "example" test.txt
The following command will search for the lines that contain the word "example"
or "sample" in the file "test.txt":
egrep "example|sample" test.txt
The egrep command can also be used with regular expressions to search for more
complex patterns in files.

MADE WITH AND HARDWORK BY VIKAS KUMAWAT


fgrep:
fgrep is a command-line tool in Linux used to search for fixed strings or patterns
in a file or files. The fgrep command stands for "fixed-string global regular
expression print". It is similar to the grep command, but it treats the search string
as a fixed string, rather than a regular expression.
The basic syntax of the fgrep command is:
fgrep [options] string [files]
Some of the commonly used options with the fgrep command are:
-i: This option performs case-insensitive searching.
-v: This option returns all the lines that do not match the specified pattern.
-c: This option displays the count of matching lines.
-r: This option searches for files recursively in the specified directory.
For example, the following command will search for the lines that contain the
string "example" in the file "test.txt":
fgrep "example" test.txt
The fgrep command is useful when you want to search for fixed strings in files
and don't want to deal with regular expressions. It is faster than grep and uses
less system resources.

MADE WITH AND HARDWORK BY VIKAS KUMAWAT


cut :
The cut command is a Linux command-line utility used to extract sections or
columns from a file or a set of files. It is mostly used for processing text data,
such as log files and CSV files.
The basic syntax of the cut command is:
cut [options] filename
Some commonly used options with the cut command are:
-f: This option is used to specify the fields or columns to be extracted. For
example, -f 1,3 will extract the first and third fields.
-d: This option is used to specify the delimiter that separates the fields in the file.
For example, -d "," will specify the comma as the delimiter.
-c: This option is used to extract characters or bytes instead of fields. For example,
-c 1-5 will extract the first five characters from each line.
For example, the following command will extract the first and third fields from
the "data.csv" file using a comma as the delimiter:
cut -d "," -f 1,3 data.csv
The cut command is useful when you want to extract specific data from a file or
when you want to remove unwanted data from a file.

MADE WITH AND HARDWORK BY VIKAS KUMAWAT


paste :
The paste command is a Linux command-line utility used to merge lines from
multiple files or standard input and print them to standard output. It is mostly
used for combining data from different sources, such as log files or database
dumps.
The basic syntax of the paste command is:
paste [options] file1 file2 ...
Some commonly used options with the paste command are:
-d: This option is used to specify a delimiter to separate the merged lines. For
example, -d "," will use a comma as the delimiter.
-s: This option is used to merge the lines of each file sequentially instead of in
parallel.
For example, the following command will merge the lines from "file1.txt" and
"file2.txt" using a comma as the delimiter and print them to standard output:
paste -d "," file1.txt file2.txt
You can also use the paste command with the output of other commands by
piping their output to paste. For example, the following command will merge the
output of two commands, ls and grep, using a space as the delimiter:
ls | grep "file" | paste -s -d " "
The paste command is useful when you want to combine data from multiple
sources or when you want to format the output of a command.

MADE WITH AND HARDWORK BY VIKAS KUMAWAT


join :

The join command in Linux is used to combine two files on the basis of a
common field or key. It is used to join lines from two files on a specified field,
which must be present in both files. The join command assumes that the input
files are sorted on the join field.

The basic syntax of the join command is:


join [options] file1 file2
Some commonly used options with the join command are:
-t: This option is used to specify the delimiter that separates fields in the input
files. For example, -t ',' will use a comma as the delimiter.
-1: This option is used to specify the join field from the first file.
For example, -1 1 will use the first field in the first file as the join field.
-2: This option is used to specify the join field from the second file.
For example, -2 2 will use the second field in the second file as the join field.
For example, the following command will join the lines from "file1.txt" and
"file2.txt" based on the first field and print the result to standard output:
join -t "," -1 1 -2 1 file1.txt file2.txt
You can also use the join command with the output of other commands by piping
their output to join. For example, the following command will join the output of
two commands, ls and grep, based on the filename and print the result to standard
output:
ls | grep "file" | join -t " " -1 1 -2 1 - file1.txt
The join command is useful when you want to combine data from two files on a
common field or key. It is commonly used for data processing, database
management, and text manipulation tasks.

MADE WITH AND HARDWORK BY VIKAS KUMAWAT


tee :
The tee command is a simple yet useful command in Linux that reads standard
input and writes it to both standard output and one or more files.
Here are some of the options available with tee command:
-a or --append: appends to the given files instead of overwriting them.
-i or --ignore-interrupts: ignores interrupt signals.
-p or --preserve: preserves the timestamps of the input files.
-u or --unbuffered: writes the output to the file immediately instead of buffering.
Example Usage:
ls -l | tee file.txt # output of ls -l is written to file.txt and displayed in the terminal
ls -l | tee -a file.txt # append output of ls -l to file.txt and display in the terminal
Note: In the above examples, the output of the ls -l command is written to the file
file.txt and displayed on the terminal as well.

MADE WITH AND HARDWORK BY VIKAS KUMAWAT


pg :
The pg command is a simple command line tool in Linux that allows you to view
text files one page at a time. It is similar to the more command, but provides
some additional features, such as the ability to move both forward and backward
in the file.
Here are some of the options available with pg command:
-n or --no-renumber: do not renumber pages.
-p or --prompt: change the default prompt to the specified string.
-s or --squeeze-blank: squeeze multiple blank lines into one.
Example Usage:
pg file.txt # display the content of file.txt one page at a time
pg -s file.txt # display the content of file.txt, squeezing multiple blank lines into one

Once you open a file in pg, you can use the following commands to navigate
through the file:
 Press the spacebar to move forward one page.
 Press the Enter key to move forward one line.
 Press the b key to move backward one page.
 Press the q key to quit the pg command.

MADE WITH AND HARDWORK BY VIKAS KUMAWAT


comm :
The comm command is a Linux utility that compares two sorted files line by line
and writes the lines that are unique or common to either file to the standard output.
It is a simple tool that can be used for comparing files and identifying differences
between them.
Here are some of the options available with the comm command:
-1, --check-order: check that the first file is correctly sorted.
-2, --nocheck-order: do not check that the second file is correctly sorted.
-3, --nocheck-order: do not check that either file is correctly sorted.
-i, --ignore-case: ignore differences in case when comparing lines.
-u, --unique: output only lines that are unique to either file.
-d, --check-order: output only lines that are common to both files.
Example Usage:
comm file1.txt file2.txt # compare file1.txt and file2.txt and output unique and
common lines
comm -i file1.txt file2.txt # compare file1.txt and file2.txt, ignoring case, and output
unique and common lines
By default, comm assumes that the input files are sorted in ascending order.
Therefore, it is important to sort the input files before running the comm
command. You can use the sort command to sort the files in ascending order
before running the comm command.

MADE WITH AND HARDWORK BY VIKAS KUMAWAT


cmp :
The cmp command is a Linux utility that is used to compare two files byte by
byte and display the differences between them.
The basic syntax of the cmp command is as follows:
cmp [OPTION]... FILE1 [FILE2 [SKIP1 [SKIP2]]]
Some of the commonly used options with cmp command are:
-l: displays the byte number and the differing bytes in octal.
-s: suppresses the output and returns only an exit status.
-i N: skips the first N bytes of both files before starting the comparison.
-n N: compares only the first N bytes of the files.
If no option is specified, cmp uses the default option -s.
Here's an example usage of the cmp command to compare two files:
$ cmp file1.txt file2.txt
file1.txt file2.txt differ: byte 5, line 1

MADE WITH AND HARDWORK BY VIKAS KUMAWAT


diff :
The diff command is a Linux utility that is used to compare two files line by line
and display the differences between them.
The basic syntax of the diff command is as follows:
diff [OPTION] FILE1 FILE2
Some of the commonly used options with diff command are:
-u: displays the differences in unified format.
-c: displays the differences in context format.
-r: performs a recursive comparison of directories.
-i: ignores changes in case.
-w: ignores whitespace changes.
If no option is specified, diff uses the default option -u.
Here's an example usage of the diff command to compare two files:
$ diff file1.txt file2.txt
4c4
< This is line 4 in file1
---
> This is line 4 in file2
This output shows that the fourth line in file1 is different from the fourth line in
file2. The "<" symbol indicates that the line is present in file1, while the ">"
symbol indicates that the line is present in file2. The "---" line separates the
differences.

MADE WITH AND HARDWORK BY VIKAS KUMAWAT


tr :
The tr command in Linux is used to translate, or delete, or squeeze characters
from the standard input and writes the result to the standard output or files.
The syntax of the tr command is as follows:
tr [options] set1 [set2]
The set1 and set2 arguments are sets of characters that can be specified in a
variety of ways, such as individual characters, ranges of characters, or character
classes.
Here are some commonly used options with the tr command:
-d or --delete: deletes specified characters
-s or --squeeze-repeats: replaces each sequence of identical characters that are
listed in the input set with a single occurrence of that character.
-t or --truncate-set1: Truncate the first set of characters (characters to be
translated) to length of the second set of characters (replacement characters).
-c or --complement: complement the set1 character set
Here are some examples:
1. Translating lowercase to uppercase:
echo "hello world" | tr '[:lower:]' '[:upper:]'
Output: HELLO WORLD
2. Deleting all spaces:
echo "Hello World" | tr -d ' '
Output: HelloWorld
3. Complementing the character set:
echo "Hello 123 World" | tr -c '[:digit:]' 'X'
Output: XXXX 123 XXXXX
4. Replacing newline characters with spaces:
cat file.txt | tr '\n' ' '

5. Squeezing repeated characters:


echo "aaabbbccc" | tr -s 'a'
Output: abbbccc

MADE WITH AND HARDWORK BY VIKAS KUMAWAT


Cpio :
cpio is a Linux command used for creating and manipulating archives of files. It
can be used to create archives of files and directories, as well as extract files
from archives. The name "cpio" is derived from "copy in and out".
Here are some commonly used options with cpio:
-i: Extract files from an archive.
-o: Create an archive.
-t: List the contents of an archive.
-d: Create directories as needed when extracting files.
-v: Verbose mode. Print the names of files as they are processed.
-c: Use a portable format when creating an archive. This ensures that the
archive can be read on other systems with different byte ordering.
-F: Specify the archive file name.
--no-preserve-owner: Do not preserve file ownership information when
extracting files from an archive.
Example usage:
To create a cpio archive of all files in the current directory and its
subdirectories, use the following command:
find . | cpio -o > archive.cpio
To extract files from an archive, use the following command:
cpio -i < archive.cpio

MADE WITH AND HARDWORK BY VIKAS KUMAWAT

You might also like