0% found this document useful (0 votes)
5 views24 pages

Practical 1

The document outlines various basic commands used in Linux System Administration, including commands for file management, user information, system date and time, and process management. It provides detailed explanations of commands like 'pwd', 'mkdir', 'rm', 'cp', and 'find', among others. Additionally, it covers command usage for output redirection and process control, including 'top', 'kill', and 'renice'.

Uploaded by

ruidemon21
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)
5 views24 pages

Practical 1

The document outlines various basic commands used in Linux System Administration, including commands for file management, user information, system date and time, and process management. It provides detailed explanations of commands like 'pwd', 'mkdir', 'rm', 'cp', and 'find', among others. Additionally, it covers command usage for output redirection and process control, including 'top', 'kill', and 'renice'.

Uploaded by

ruidemon21
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/ 24

TY.BSc.

IT(SEM V) Linux System Administration Roll No : 46

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

Login to the system with correct password:


TY.BSc.IT(SEM V) Linux System Administration Roll No : 46

Open terminal

Start executing commands

● 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.

● date -s"yyyy-mm-dd hh:mm" command:


date -s"yyyy-mm-dd hh:mm" command is used to set the system’s date and time to the
specified date and time.
TY.BSc.IT(SEM V) Linux System Administration Roll No : 46

● 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 dirname command:


mkdir dirname will create a new directory in the current directory, with the specified
name.
➔ mkdir dirname1 dirname2 command:
mkdir dirname1 dirname2 command will create multiple directories in the current
directory with the specified directory names.
➔ mkdir path/dirname command:
TY.BSc.IT(SEM V) Linux System Administration Roll No : 46

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.

➔ Using ls command to view the new directories:

● mkdir -p dirname/{newdir1, newdir2,....,newdirn} command:


mkdir -p command is used to create multiple directories in some other location. The new
directory names should be enclosed in curly brackets.

● mkdir /month/{newdir1, newdir2,....,newdirn} command:


This command is also used to create multiple directories in some other location. The new
directory names should be enclosed in curly brackets.

● 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

● rm command:rm command is used to remove a file. When removing an empty file,


system will ask for permission to “remove empty regular file?” press enter to remove.

When removing a file that has some content in it, the system will ask for permission to
“remove regular file?” press enter to remove.

● cp source destination command:


cp command is used to copy content of one file to another. It has two parameters: source
(from where we have to copy) and destination (to where we have to copy).
TY.BSc.IT(SEM V) Linux System Administration Roll No : 46

● 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

➔ Sorting numbers in a file.


sort command will sort the numbers in a file according to digits from left to right.

➔ 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

Content of /etc/paaswd file:


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.

➔ find /etc -name “[a-g]*.conf”


finds all files starting with letter ‘a to g’ in the /etc directory.
TY.BSc.IT(SEM V) Linux System Administration Roll No : 46

➔ find /etc -name “ag*.conf”


finds all files in /etc starting with letters ag.

➔ find /tmp -name “???”


TY.BSc.IT(SEM V) Linux System Administration Roll No : 46

➔ find /usr/sbin -size +4MB


finds all files in /usr/sbin which have more than 4MB file size.

➔ find /usr/sbin -size -2MB


finds all files in /usr/sbin which have less than 2MB file size.
TY.BSc.IT(SEM V) Linux System Administration Roll No : 46

➔ find /root -iname “[a-c]*”

➔ find /home -user student


finds all files in /home directory which are owned by the user student.

➔ find /home -group student


finds all files in /home directory which are owned by the group student.
TY.BSc.IT(SEM V) Linux System Administration Roll No : 46

● 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

You might also like