Professional Documents
Culture Documents
2020-21 Autumn
Madhusudan Subedi
Networks and Operating Systems CS5001NA
Contents
Introduction ................................................................................................................ 1
Transcript ................................................................................................................... 1
Question1. Creating new directories: ...................................................................... 2
Question 2. Removing Exisng Files and directories ................................................ 3
Question3. Usage of the echo command ................................................................ 4
Question 4. Usage of the ls command .................................................................... 6
Question 5. Usage of cat command ........................................................................ 8
Question6. Usage of the chmod command. .......................................................... 12
Question7 : Usage of the grep command. ............................................................ 18
Question.8 Aliasing ............................................................................................... 22
Question9. Usage of your own command ............................................................. 25
Question10. Command history.............................................................................. 26
Conclusion: .............................................................................................................. 28
Madhusudan Subedi
Networks and Operating Systems CS5001NA
Madhusudan Subedi
Networks and Operating Systems CS5001NA
Introduction
This is our second course of the module and first course of fourth semester. This
course work was given on week 10 which we need to submit on the Week 22. This
coursework aims for introducing us to some of the relevant UNIX command and their
uses. This coursework part 1 holds 10% of our total module so it is going to be short.
In this course work, we will be learning and organize research on UNIX system its
utilities and commands and their uses.
There are various forms of Linux, which are easily available today. Some of the various
Linux are Debian, Kali Linux, Ubuntu, Red hat Linux, Suse Linux and many more.
In this coursework we are going to learn about different UNIX command like as making
directories, using multiple command at a time and many more. There are 28 tasks
given and each of those tasks holds specific mark. In addition, we need to make a
report file for the coursework, which include the steps that we had run. This
coursework requires a lot of practice and research.
Transcript
First, we need to start the Debian and on the terminal, we are asked to give following
set of commands:
#Task1
1. /home/madhusudan_subedi$ ls -R NBA
Output
1. NBA:
2. 'Brooklyn nets' 'Chicago Bulls' 'Dallas Maveric' Lakers Miami
3.
4. 'NBA/Brooklyn nets':
5.
6. 'NBA/Chicago Bulls':
7.
8. 'NBA/Dallas Maveric':
9.
10. NBA/Lakers:
11.
12. NBA/Miami:
Screenshot
Figure 1: Task 1
#Task2
1. /home/madhusudan_subedi$ cd NBA/Miami/
1. /home/madhusudan_subedi/NBA/Miami$ pwd
2. /home/madhusudan_subedi/NBA/Miami
Screenshot
#Task3
1. /home/madhusudan_subedi/NBA/Miami$ cd ..
1. /home/madhusudan_subedi/NBA$cd Miami; rm -i *; cd ..
2. rm: remove regular empty file 'file1'? y
3. rm: remove regular empty file 'file2'? y
1. /home/madhusudan_subedi/NBA$rmdir Miami
Screenshot
#Task4
Screenshot
1. /home/madhusudan_subedi/NBA$pwd
2. /home/madhusudan_subedi/NBA
1. /home/madhusudan_subedi/NBA$cd Lakers/
2. /home/madhusudan_subedi/NBA/Lakers$
Screenshot
Screenshot
#Task6
1. /home/madhusudan_subedi$ cd NBA/Lakers/
2. Command: pwd; cd ..; pwd; cd ..; pwd
Explanation: This pwd; cd ..; pwd; cd ..; pwd command is a different set of
arguments which is passed on single line. First of all pwd; prints the working
directory after that cd ..; is executed and bring user to one directory up (from
/NBA/Lakers to /NBA/) then, again pwd ..; command is executed which print the
current working directory and after that again cd ..; Is executed and at last pwd
command is executed which print the current working directory of the user.
Screenshot
#Task7
Explanation: This cd; pwd command is executed on a way that first cd; command is
executed which bring user to the home directory and then pwd command is run
which shows us our current working directory.
Screenshot:
Command: ls
Explanation: This ‘ls’ commands refers for list which show all the directories and file
inside the folder.
Screenshot:
Explanation: As we know ls prints the all files and folders inside a directory similarly if
we need to see the hidden files then we use “ls -a”. After giving ls –a command we
can see the files which are hidden. These hidden files starts from dot(.)
Screenshot
Explanation: command “ls –al ” is used to see the detailed information about files
are directories. We can use this command to look when the file or folder is created,
either it is file or directory and what type of permissions are given to the user reader
and group. And it display the hidden files and directory and also shows what
permission do we have for those files or directories.
Screenshot:
#Task8
Explanation: This command has multiple arguments on the single line command in
this command first of all cd; is executed and after that pwd is executed. After that cd
cw2 command is run but as we don’t have any cw2 directory here so this command
gives an error message and the command is stoped.
Screenshot:
Command: ls –R
Explanation: The command “ls –R” is used, when we need to see the files and
directories inside the folder. It is just like as tree command. It list all the directories
first and then keep on showing the other relevant files and folders in an ordered
manner.
Screenshot:
#Task9
1. /home/madhusudan_subedi/NBA/Chicago Bulls$cat>testX
2. aaabb Aaaaa
3. AAAAA
4. bbbcc Bbbbb
5. BBBBB
6. ff-ff Ccccc
7. CCCCC
8. cccdd Ddddd
9. DDDDD
1. /home/madhusudan_subedi/NBA/Chicago Bulls$cat>testY
2. aaabb Aaaaa
3. AAAAA
4. bbbcc Bbbbb
5. BBBBB
6. ff-ff Ccccc
7. CCCCC
8. cccdd Ddddd
9. DDDDD
1. /home/madhusudan_subedi/NBA/Chicago Bulls$cat>testZ
2. aaabb Aaaaa
3. AAAAA
4. bbbcc Bbbbb
5. BBBBB
6. ff-ff Ccccc
7. CCCCC
8. cccdd Ddddd
9. DDDDD
#Task10
#Task 11: Copy these files to the Brooklyn nets directory typing a relative
pathname.
Explanation: As we know cat command is used to display the files. Here we are
using cat command to display the 3 files at a same time. Firstly it displays the
content of testX and testY and then testZ.
Screenshot:
Screenshot:
This command has run but didn’t give any output, which we can see in the figure 17
above.
#Task13:
Screenshot:
#Task14
1. /home/madhusudan_subedi/NBA/Chicago Bulls$ls -l
2. total 0
3. -rwxr-xr-x 1 madhusudan_subedi madhusudan_subedi 210 Mar 23 20:03
testResult
4. -rwxr-xr-x 1 madhusudan_subedi madhusudan_subedi 72 Mar 23 06:34 testX
5. -rwxr-xr-x 1 madhusudan_subedi madhusudan_subedi 72 Mar 23 06:35 testY
6. -rwxr-xr-x 1 madhusudan_subedi madhusudan_subedi 66 Mar 23 06:36 testZ
Screenshot:
Result:
1. /home/madhusudan_subedi/NBA/Chicago Bulls$ls -l
2. total 0
3. -rwxr-xr-x 1 madhusudan_subedi madhusudan_subedi 210 Mar 23 20:03
testResult
4. ---------- 1 madhusudan_subedi madhusudan_subedi 72 Mar 23 06:34 testX
5. -rwxr-xr-x 1 madhusudan_subedi madhusudan_subedi 72 Mar 23 06:35 testY
6. -rwxr-xr-x 1 madhusudan_subedi madhusudan_subedi 66 Mar 23 06:36 testZ
Screenshot:
Result:
1. /home/madhusudan_subedi/NBA/Chicago Bulls$ls -l
2. total 0
3. -rwxr-xr-x 1 madhusudan_subedi madhusudan_subedi 210 Mar 23 20:03
testResult
4. -rwx------ 1 madhusudan_subedi madhusudan_subedi 72 Mar 23 06:34 testX
5. -rwxr-xr-x 1 madhusudan_subedi madhusudan_subedi 72 Mar 23 06:35 testY
6. -rwxr-xr-x 1 madhusudan_subedi madhusudan_subedi 66 Mar 23 06:36 testZ
Screenshot:
Response
Screenshot:
Screenshot:
Command: Add read and write access permissions for yourself for the testX
file.
Result:
1. /home/madhusudan_subedi/NBA/Chicago Bulls$ls -l
2. total 0
3. -rwxr-xr-x 1 madhusudan_subedi madhusudan_subedi 210 Mar 23 20:03
testResult
4. -rwx------ 1 madhusudan_subedi madhusudan_subedi 19 Mar 24 00:48 testX
5. -rwxr-xr-x 1 madhusudan_subedi madhusudan_subedi 72 Mar 23 06:35 testY
6. -rwxr-xr-x 1 madhusudan_subedi madhusudan_subedi 66 Mar 23 06:36 testZ
Screenshot:
Screenshot:
Screenshot:
1. /home/madhusudan_subedi/NBA/Chicago Bulls$cd ..
1. /home/madhusudan_subedi/NBA$ ls -l
1. /home/madhusudan_subedi/NBA$ ls -l
Screenshot:
Command: Try to read a file from Chicago Bulls using any utility
Command: Try to put a file into Chicago Bulls using any utility.
1. /home/madhusudan_subedi/NBA$ ls
Command: Add read, write and execute permission for yourself for the
Chicago Bulls directory.
1. /home/madhusudan_subedi/NBA$ ls –l
Screenshot:
1. /home/madhusudan_subedi/NBA/Chicago Bulls$cat>>file
1. /home/madhusudan_subedi/NBA/Chicago Bulls$ls
#Task16
Explanation: Grep command is used to find the content of the file. It is used for
finding a search patterns in the content of the mentioned files. Here grep bb testX, is
used to find the bb content on the file name testX whose output is given in the figure
below.
Screenshot:
Explanation: This command is use to show the content of the file, as we can see –v
is mentioned on the command which is used for excluding the bb content of the file.
When we run the command it exclude all the line and sentence which include bb in
their sentence.
Screenshot.
Explanation: This ommand enable us to find the lines and sentence, which only
include the bb word int the sentence. –n command is used when we need to find
certain part of the file and show in which line they are present.
Screenshot.
Explanation: This command enable us to find all the files inside the directory which
contain the bb word inside them. This command enable us to check the presence of
the word in the file inside the directory and after running the command we are able to
see in which file our matching word is present.
Screenshot:
Explanation: This command enable user to find the particular content in all the files
which is present inside the directory. We are running the command from Brooklyn
nets directory and when we give the command it reads all the files and it shows user
with the matching data which is present inside the files. (For now we are searching
bb inside the directory)
Screenshot:
Command: grep -i BB *
Explanation: This command enable user to find the particular content in all the files
which is present inside the directory. We are running the command from Brooklyn
nets directory and when we give the command it reads all the files and it shows user
with the matching data which is present inside the files.(For now we are searching
BB inside the directory)
Screenshot:
Explanation: This command is used to find how much time the content of the file is is
repeated on the file. Grep –c bb * command shows us, how much time the selected
or inserted portion of the file is repeated in the file it print the number how much time
the portion of the file is repeated.
Screenshot:
Explanation: The command above filters out and display all the liens which contain
upper case A in all file present in the current working directory.
Screenshot
Output:
1. 1:aaabb Aaaaa
2. 2:AAAAA
3. 3:bbbcc Bbbbb
4. 4:BBBBB
5. 5:ff–ff Ccccc
6. 6:CCCCC
7. 7:cccdd Ddddd
Explanation:
The above command filters out and display all of the lines which is included in
the testX file inside the Brooklyn nets directory
Screenshot:
Question.8 Aliasing
#Task17: Define two aliases for the ls command: lsal for the ls -al command
and lsa for ls -a command.
Command:
Screenshot:
/home/madhusudan_subedi$lsal
Output:
1. /home/madhusudan_subedi$lsal
2. total 12
3. drwxr-xr-x 1 madhusudan_subedi madhusudan_subedi 512 Mar 27 20:50 .
4. drwxr-xr-x 1 root root 512 Mar 23 02:33 ..
5. -rw------- 1 madhusudan_subedi madhusudan_subedi 324 Mar 28 04:03
.bash_history
6. drwxr-xr-x 1 madhusudan_subedi madhusudan_subedi 512 Mar 27 20:04
.local
Screenshot:
/home/madhusudan_subedi$lsa
Output:
1. /home/madhusudan_subedi$lsa
2. . .. .bash_history .local 19033784cw2part1 NBA
Screenshot:
#Task18
1. /home/madhusudan_subedi$unalias lsa
2. /home/madhusudan_subedi$unalias lsal
Command defining the aliases again and preserving for next session:
1. Ctrl + s
2. Ctrl + x
Command:
Screenshot:
#Task20
Ctrl S
Ctrl X
#Task21
Ctrl S
Ctrl X
#Task22
Ctrl S
Ctrl X
1. /home/madhusudan_subedi$alias
2. alias lsa='ls -a'
3. alias lsal='ls -al'
4. alias noAcs='ls -a | grep "^[gtw]" | wc -l'
5. alias noAllf='ls -al | wc -l'
6. alias noAsubsir='ls -laR | grep "^d" | wc -l'
#Task23
Command
1. /home/madhusudan_subedi$noAllf
Output: 11
Screenshot:
#Task24
Command
1. /home/madhusudan_subedi$noAsubsir
Output: 26
Screenshot:
#Task25
Command:
1. /home/madhusudan_subedi$noAcs
Output: 0
Screenshot:
#Task26
Command: list the last commands executed giving any history command
1. /home/madhusudan_subedi$fc –l
2. 93 nano .alias
3. 94 .bashrc
4. 95 nano .bashrc
5. 96 alias noAllf='ls -al | wc -l'
6. 97 nano NBA/Brooklyn\ nets/.alias
7. 98 nano NBA/Brooklyn\ nets/.alias
8. 99 alias noAsubsir='ls -laR | grep "^d" | wc -l'
9. 100 nano NBA/Brooklyn\ nets/.alias
10. 101 alias noAcs='ls -a | grep "^[gtw]" | wc -l'
11. 102 nano NBA/Brooklyn\ nets/.alias
12. 103 alias
13. 104 noAllf
14. 105 noAsubsir
15. 106 noAcs
#Task27:
1. /home/madhusudan_subedi$fc -e- -8
2. nano NBA/Brooklyn\ nets/.alias
#Task28
Command:
1. /home/madhusudan_subedi$fc -e- m
2. mkdir -p NBA/{Lakers,Miami,"Chicago Bulls","Brooklyn nets","Dallas Maveric"}
Conclusion:
Finally, the work is completed with a lot of research and practice. It is the second
coursework of Network and Operating System, which is about Linux operating system.
In this coursework, we were asked to run a UNIX operating system and run various
task on it. In beginning, it was about difficult to understand about it but when I start
practicing, I knew that it is not so hard content.
This course teaches students about basic Linux and UNIX command. It make them
more and more familiar to UNIX operating system. This coursework requires a lot of
patience hard work and research for its completion.
I would like to thank our Module leader for providing us with lecture videos and slides,
which help me throughout the coursework and I like thank our tutor for making us able
to complete the coursework and make us understand and clear about the topic.