To Study Details About Linux Utilities
To Study Details About Linux Utilities
Utilities
SUBJECT :OSY
1. 34
Kabir More 2209350250
2. 38
Rushikesh Waghmare 2209350260
3. 47
Hemant Ingale 2209350281
To Study Details
About Linux
Utilities
Linux provides a powerful command-line interface compared to
other operating systems such as Windows and MacOS. We can do
basic work and advanced work through its terminal. We can do
some basic tasks such as creating a file, deleting a file, moving a file,
and more. In addition, we can also perform advanced tasks such as
administrative tasks (including package installation, user
management), networking tasks (ssh connection), security tasks, and
many more. Linux terminal is a user-friendly terminal as it provides
various support options. To open the Linux terminal, press "CTRL +
ALT + T" keys together, and execute a command by pressing the
'ENTER' key.
by Hemant Ingale
preencoded.png
Linux Directory
Commands
The pwd command is used to display the location of the current working directory. Syntax: $ pwd. The mkdir command is used tocreate a
new directory under any directory. Syntax: $ mkdir . The rmdir command is used to delete a directory. Syntax: $ rmdir . The ls command
is used todisplay a list of content of a directory. Syntax: $ ls. The cd command is used to change the current directory. Syntax: $ cd . The
touch command is used tocreate empty files. We can create multiple empty files by executing it once. Syntax: 1. $ touch 2. $ touch .
The cat command is a multi-purpose utility in the Linux system. It can be used to create a file, display content of the file, copy the
content of one file to another file, and more. Syntax: 1. cat [OPTION]... [FILE]. To create a file, execute it as follows: 1. cat > 2. // Enter file
content Press "CTRL+ D" keys to save the file. To display the content of the file, execute it as follows: 1. $ Cat . The rm command is used
to remove a file. Syntax: $ rm . The cp command is used to copy a file or directory. Syntax: To copy in the same directory: 1. $ cp <
existing file name > . To copy in a different directory: Output: . The mv command is used to move a file or a directory form one location
to another location. Syntax: $ mv < file name >< directory path >. The rename command is used to rename files. It is useful for renaming
a large group of files. Syntax: rename 's/old- name/new-name/' files. For example, to convert all the text files into pdf files, execute the
below
pwdcommand: $ rename 's/\.txt$/\.pdf/' *.txt. mkdir
Displays the current working Creates a new
directory. directory.
rmdir ls
Deletes a Lists the contents of a
directory. directory.
preencoded.png
Linux File Content
Commands
The head command is used to display the content of a file. It displays the first 10 lines of a file. Syntax: $ Head < File
Na me >. The tail command is similar to the head command. The difference between both commands is that it
displays the last ten lines of the fi le content. It is useful for reading the error message. Syntax: $ tail < file name >.
The tac command is the reverse of cat command, as its name specified. It displays the file content in reverse order
(from the last line). Syntax: $ tac < file name >. The more com mand is quite similar to the cat command, as it is
used to display the file content in the same way that the cat command does. The only difference between both
commands is that, in case of larger files, the more command displays screenful output at a time. In more command ,
the following keys are used to scroll the page: ENTER key: To scroll down page by line. Space bar: To move to the
next page. b ke y: To move to the previous page. / key: To search the string. Syntax: $ more < file name >. The less
command is similar to the more command. It also includes some extra features such as 'adjustment in width and
height of the terminal.' Comparatively, the mo re command cuts the output in the width of the terminal. Syntax: $
less < file name >.
head tail tac
Displays the first 10 lines of Displays the last 10 lines of Displays the file content in reverse
a file. a file. order.
preencoded.png
Linux User
Commands
The su command provides administrative access to another user. In
other words, it allows access of the Linux shell to another user. Syntax:
$ su < user name >. The id command is used to display the user ID (UID)
and group ID (GID). Syntax:
1id. su
$ 2 id a user on a Linux
The useradd command is used to add or remove
server.Provides
Syntax:administrative
$ useradd username.
access to The passwd command
Displays is used
the user to
ID (UID) and group ID
another user. (GID).
create and change the password for a user. Syntax: $ passwd <
3 useradd
username >. The groupadd command is used to 4 passwd
create a user group.
Syntax: $ groupadd
Adds or removes<a group
user onname
a Linux>. Creates and changes the password for
server. a user.
preencoded.png
Linux Filter
Commands
The cat command is also used as a filter. To filter a file, it is used inside pipes. Syntax: Output: . The cut command is used to select a specific column of a file. The '-d' option is used as a delimiter, and it can be a space (' '),
a slash (/), a hyphen (-), or anything else. And, the '-f' option is used to specify a column number. Syntax: $ cut -d (delimiter) -f (columnNumber) . The grep is the most powerful and used filter in a Linux system. The 'grep'
stands for "global regular expression print." It is useful for searching the content from a file. Generally, it is used with the pipe. Syntax: $ command | grep < searchWord >. The 'comm' command is used to compare two
files or streams. By default, it displays three columns, first displays non-matching items of the first file, second indicates the non-matching item of the second file, and the third column displays the matching items of both
files. Syntax: $ comm < file1 >< file2 >. The sed command is also known as stream editor. It is used to edit files using a regular expression. It does not permanently edit files; instead, the edited content remains only on
display. It does not affect the actual file. Syntax: $ Command | Sed 'S/ / / '. The tee command is quite similar to the cat command. The only difference between both filters is that it puts standard input on standard output
and also write them into a file. Syntax: $ cat < file name > | tee < new File > | cat or tac |. The tr command is used to translate the file content like from lower case to upper case. Syntax: $ command | tr < 'old' > < 'new'
>. The uniq command is used to form a sorted list in which every word will occur only once. Syntax: $ command < file name > | uniq. The wc command is used to count the lines, words, and characters in a file. Syntax: $
wc < file name >. The od command is used to display the content of a file in different s, such as hexadecimal, octal, and ASCII characters. Syntax: 1. $ od -b < file Name > // Octal format 2. $ od -t x1 < file Name > //
Hexa decimal format 3. $ od -c < file Name > // ASCII character format. The sort command is used to sort files in alphabetical order. Syntax: $ sort < file name >.
cat
C oncatenates and displays files.
cut
Extracts specific columns from
a file.
grep
Searches for patterns in
files.
comm
Compares two
files.
sed
Edits files using regular
expressions.
preencoded.png
te
Linux Utility
Commands
The find command is used to find a particular file within a directory. It also supports various options to find a file such as byname, by type, by date, and more. The following symbols
are used after the find command: ( . ): For current directory name ( / ): For root Syntax: $ find . -name "*.pdf ". The locate command is used to search a file by file name. It is quite similar
to find command; the difference is that it is a background process. It searches the file in the database, whereas the find command searches in the file system. It is faster than the find
command. To find the file with the locates command, keep your database updated. Syntax: $ locate < file Name >. The date command is used to display date, time, time zone, and
more. Syntax: $ date. The cal command is used to display the current month's calendar with the current date highlighted. Syntax: $ cal. The time command is used to display the time
to execute a command. Syntax: $ time. The sleep command is used to hold the terminal by the specified amount of time. By default, it takes time in seconds. Syntax: $ sleep < time >.
Linux clear command is used to clear the terminal screen. Syntax: $ clear . After pressing the ENTER key, it will clear the terminal screen. The mount command is used to connect an
external device file system to the system's file system. Syntax: $ mount -t type < device >. Linux exit command is used to exit from the current shell. It takes a parameter as a number
and exits the shell with a return of status number. Syntax: $ exit.
Command Description
preencoded.png
Linux networking
commands
Linux ip command is an updated version of the ipconfig command. It is
used to assign an IP address, initialize an interface, disable an interface.
Syntax: $ ip a or ip add. The ping command is used to check the
connectivity between two nodes, that is whether the server is
connected. It is a short form of "Packet Internet Groper". Syntax: $ ping <
destination >. The host command is used to display the IP address for a
given domain name and vice versa. It performs the DNS lookups for the
ip Query. Syntax: $ host
DNS ping < ip address >. Linux ssh
< domain name > Orhost
ssh command
M anages is used toTests
network create a remote connection
network through
Performs D NS the ssh Creates secure
interfaces and IP connectivity. lookups. remote
protocol. Syntax: $ ssh user_name@host(IP/Domain_name). The mail
addresses. connections.
command is used to send emails from the command line. Syntax: $ mail
preencoded.png
-s "Subject" < recipient address >.