Practical 1
Practical 1
Practical No. 1:
Executing Basic Commands, General Purpose Commands , File Management
Commands, Word Count Commands on Linux Machine ,Process Renice and kill
commands GUI of Red Hat Enterprise Linux
Open terminal
● tty command:
The tty command in Linux is a built-in utility that displays the file name of the terminal
connected to the standard input. It is used with the syntax, tty .
TY.BSc.IT(SEM V) Linux System Administration Roll No : 46
● pwd command:
The "pwd" command prints the full name (the full path) of the current/working directory.
● whoami command:
The 'whoami' command in Linux is a built-in utility that displays the username of the
current user. It is used with the syntax, whoami [option] .
● who command:
who command is a tool to print information about users who are currently logged in. who
command will only see a real user who logged in.
● users command:
users command
in Linux system is used to show the usernames of users currently logged in to the current
host. It will display who is currently logged in according to FILE.
TY.BSc.IT(SEM V) Linux System Administration Roll No : 46
● hostname command:
The hostname command displays the name of the current host system. Only users with
root user authority can set the hostname.
● date command:
The 'date' command in Linux is used to display and set the system date and time.
● cal command:
The cal command displays a calendar.
● cal -n command:
The cal -n command displays a calendar with the specified month number.
● uname -a command:
The uname command prints system information.
● watch command:
The Linux watch command is a built-in command-line tool that runs user-defined
commands at regular intervals.
● history command:
The 'history' command in Linux is a built-in shell command that displays your command
line history.
TY.BSc.IT(SEM V) Linux System Administration Roll No : 46
● history n command:
The 'history n' command in Linux will display last n number of commands in the
command history.
● ls -lh command:
ls -lh will list out the directories and files with their details, present in the current
directory in human readable form.
● ls dirname command:
ls dirname command will display directories and files present in the specified directory.
mkdir path/dirname1 command will create a directory in some other directory with the
specified directory name.
➔ mkdir path/dirname path/dirname command:
mkdir path/dirname1 path/dirname2 command will create multiple directories in some
other directories with the specified directory names.
● rmdir
rmdir command is used to remove an empty directory. To forcefully remove a directory
that contains some data we can use the rm -rf command
TY.BSc.IT(SEM V) Linux System Administration Roll No : 46
● touch command:
touch command is used to create an empty file.
● cat command:
cat command is used to display content in a file. When used with single > we can
overwrite in a file. When used with double >> we can concatenate or append content in a
file.
TY.BSc.IT(SEM V) Linux System Administration Roll No : 46
When removing a file that has some content in it, the system will ask for permission to
“remove regular file?” press enter to remove.
● mv command:
mv command is used to move one directory content to some other directory. It has two
parameters: source and destination. The destination directory can be a new directory
name for the source directory so this command can be also used for renaming a directory.
● tac command:
tac command is used to display contents of two files in reverse order.
● sort command:
sort command is used to sort content in file in ascending order.
➔ sort -r command is used to sort the content of a file in reverse or descending order.
TY.BSc.IT(SEM V) Linux System Administration Roll No : 46
➔ sort -n command:
This command is used to sort numbers in a file in ascending order.
➔ sort -r command:
This command is used to sort numbers in a file in reverse or descending order.
TY.BSc.IT(SEM V) Linux System Administration Roll No : 46
● head command:
head command is used to display the top most lines in a file. head -n command is used to
display the first n number of lines in the file.
● cut command:
The cut command in linux is a command for cutting out the sections from each line of
files and writing the result to standard output. It can be used to cut parts of a line by byte
position, character, and field. It is necessary to specify an option with a command
otherwise it gives an error.
TY.BSc.IT(SEM V) Linux System Administration Roll No : 46
● grep command:
The grep command in Unix/Linux is a powerful tool used for searching and manipulating
text patterns within files.
➔ grep -i command:
grep -i command is used to turn off the case sensitive search.
➔ grep -iv command:
grep -iv command will ignore case sensitivity and display all the lines that don't contain
the specified word.
TY.BSc.IT(SEM V) Linux System Administration Roll No : 46
● Pipe operator:
The Pipe is a command in Linux that lets you use two or more commands such that
output of one command serves as input to the next.
● wc command:
wc stands for word count. It is used to find out the number of lines, word count, byte and
characters count in the files specified in the file arguments.
➔ wc -l command for displaying number of lines.
➔ wc -w command for displaying number of words.
➔ wc -c command for displaying number of characters.
➔ wc -m command for displaying number of bytes.
➔ wc -L command for displaying the size of the longest word.
TY.BSc.IT(SEM V) Linux System Administration Roll No : 46
● Redirection in Linux:
➔ >
It is used to redirect the output of the command to its left to the file on its right. This
method will overwrite content.
➔ >>
It is used to redirect the output of the command to its left to the file on its right. This
method will append content.
➔ 2>
It is used to redirect the error of the command to its left to the file on its right. This
method will overwrite content.
➔ 2>>
It is used to redirect the error of the command to its left to the file on its right. This
method will append content.
TY.BSc.IT(SEM V) Linux System Administration Roll No : 46
➔ &>
It is used to redirect both the output and error of the command to its left to the file on its
right. This method will overwrite content.
➔ &>>
It is used to redirect both the output and error of the command to its left to the file on its
right. This method will append content.
TY.BSc.IT(SEM V) Linux System Administration Roll No : 46
● find command:
The “find” command stands out as an indispensable asset, offering unparalleled
versatility in searching for files based on diverse criteria.
➔ find /etc -name “a*.conf”
finds all files in /etc starting with letter a.
● top
The ` top` command is a built-in utility in Linux that provides a real-time, dynamic view
of the system's performance.
➔ kill command
Enter k and in the top’s console enter the process id of the process you want to kill.
TY.BSc.IT(SEM V) Linux System Administration Roll No : 46
➔ renice command
The renice command alters the nice value of one or more running processes.
TY.BSc.IT(SEM V) Linux System Administration Roll No : 46