Linux Practical 2 To 7
Linux Practical 2 To 7
: 6208
Practical No. 2
IT
To create the above directory structure, we need to follow the steps given below:
i) We are creating this directory structure inside Desktop so we will move the prompt to Desktop using
‘cd’ command.
ii) After getting inside Desktop, we will create a directory named IT using ‘mkdir’ command.
iii) We will change directory to IT using ‘cd’ command and inside IT directory we will create three new
directories FYIT, SYIT and TYIT namely using ‘mkdir’ command.
iv) We get inside FYIT directory and inside it we will again two more directories using ‘mkdir’ command
SemI and SemII namely.
v) Using ‘cd’ command we will get inside SemI directory and create P1.txt file using ‘cat >’ command and
check the file using ‘cat’ command.
vi) After creating P1.txt file, we will now go back to above directory FYIT using ‘cd ..’ command and the
change the directory to SemII directory and inside it creates a P2.c file using vi editor to write and
execute a C program to find factorial of a number and after writing the program, to close the vi editor
Name: Sumi Dhara Practical No.: 2 Roll no.: 6208
environment we will press Esc + :wq! and then to compile a C program we will use ‘gcc’ command and
to execute the output we will use ./P2.out.
vii) Now to change our current directory from SemII to SYIT, we will use ‘cd ../..’ to directly jump two
directories above which is FYIT.
viii) After coming to FYIT we will use ‘cd’ command to change the current directory to SYIT.
ix) Inside SYIT, we will create two new directories SemIII and SemIV using ‘mkdir’ command. (Then
repeat the same steps)
x) Using ‘cd’ command we will get inside SemIII directory and create P3.txt file using ‘cat >’ command
and check the file using ‘cat’ command.
xi) After creating P3.txt file, we will now go back to above directory SYIT using ‘cd ..’ command and the
change the directory to SemIV directory and inside it creates a P4.cpp file using vi editor to write and
execute a C++ program to perform addition of two numbers and after writing the program, to close the
Name: Sumi Dhara Practical No.: 2 Roll no.: 6208
vi editor environment we will press Esc + :wq! and then to compile a C++ program we will use ‘g++’
command and to execute the output we will use ./P4.out.
xii) Now to change our current directory from SemIV to TYIT, we will use ‘cd ../..’ to directly jump two
directories above which is SYIT.
xiii) After coming to SYIT we will use ‘cd’ command to change the current directory to TYIT.
xiv) Inside TYIT, we will create two new directories SemV and SemVI using ‘mkdir’ command. (Then
again repeat the same steps)
xv) Using ‘cd’ command we will get inside SemV directory and create P5.txt file using ‘cat >’ command
and check the file using ‘cat’ command.
xvi) After creating P5.txt file, we will now go back to above directory TYIT using ‘cd ..’ command and the
change the directory to SemVI directory and inside it creates a P6.java file using vi editor to write and
execute a Java program to even numbers from 1 to 10 and after writing the program, to close the vi
editor environment we will press Esc + :wq! and then to compile a Java program we will use ‘javac’
command and to execute the output we will use java P6.
xvii) To close the command prompt, we will use ‘exit’ command.
Name: Sumi Dhara Practical No.: 2 Roll no.: 6208
Practical No. 3
Define the use of all the basic Linux commands and implement them:
Basic Linux commands and their uses:
i) pwd
pwd (print working directory) : Displays the current directory you're in. It's useful for confirming your present location
within the directory structure.
ii) mkdir
mkdir (make directory) : Creates a new directory with the specified name.
iii) cd
cd (change directory) : Changes the current directory to the specified directory.
a) cd .. : Moves up one directory level.
b) cd – : Switches to the previous directory you were in.
c) cd ~ : Moves to the home directory of the current user.
iv) touch
touch : Creates an empty file with the specified name. If the file already exists, it updates the file's access and modification
timestamps.
v) cat
cat (concatenate): Displays the content of a file or concatenates multiple files and displays the output.
a) cat > filename : Creates or overwrites a file with the specified name and allows the user to input text to the file until they
press Ctrl+D.
vi) tac
tac : Displays the content of a file in reverse order (last line first).
a) tac > filename : Similar to ‘cat >’, but the input will be reversed and then written to the file.
vii) head
head : Displays the first 10 lines of a file by default. You can specify the number of lines to display using ‘-n’.
viii) tail
tail : Displays the last 10 lines of a file by default. You can specify the number of lines to display using ‘-n’.
ix) more
more : Displays the content of a file one screen at a time. You can navigate through the file using the spacebar to scroll down.
x) less
less : Similar to ‘more’, but with more functionality. It allows for both forward and backward navigation through the file.
xi) cp
cp (copy) : Copies files or directories from one location to another.
xii) mv
mv (move) : Moves or renames files or directories.
xiii) ls
ls (list) : Lists the contents of a directory.
a) ls -l : Lists the contents in long format, showing detailed information like permissions, number of links, owner, group, size,
and time of last modification.
b) ls -a : Lists all contents, including hidden files (those starting with a dot).
c) ls -d : Lists directories themselves rather than their contents.
xiv) rm
rm (remove) : Deletes files or directories. Use with caution, as this command can permanently remove data.
a) rm -r : Recursively deletes directories and their contents.
xv) rmdir
rmdir (remove directory) : Deletes empty directories. It will not remove directories that contain files or other directories.
Name: Sumi Dhara Practical No.: 3 Roll no.: 6208
Practical No. 4
a) Create both the links(hard link & soft/symbolic link) for a file and show its management:
b) Create a backup file for files and directories and compress the size of it:
Steps to create and compress a backup file for different files and directories:
(Note: ‘-cvf’ along with ‘tar’ is used to create a backup file and ‘-xvf’ along with ‘tar’ is used to restore
original files or directories)
Practical No. 5
a) Create a repository using yum(Yellowdog Updater Modified) command and check the
repository list :
Practical No. 6
Practical No. 6
Practical No. 7
a) Configure server for file sharing to client using NFS: (Server side)
o Implementation:
Name: Sumi Dhara Practical No.: 7 Roll no.: 6208
(Inside vi editor)
Name: Sumi Dhara Practical No.: 7 Roll no.: 6208
Practical No. 7
b) Configure client for accepting file from server and checking shared file using NFS: (Client
side)
(Here, we have to install nfs packages and then follow the step (i) of server nfs.
i) mkdir clientnfs
(Create a directory in /home)
ii) mount -t nfs ip address of server :/home/servernfs/ /home/clientnfs/
(Now go to clientnfs directory and check shared file.
iii) cd clientnfs
iv) ls
(Check the content of shared file in clientnfs)
v) cat shared filename
o Implementation: