You are on page 1of 32

Networks and Operating Systems CS5001NA

Module Code & Module Title

CS5001NA Networks and Operating Systems

Assessment Weightage & Type

10% Individual Coursework

Year and Semester

2020-21 Autumn

Student Name: Madhusudan Subedi

London Met ID: 19033784

College ID: np01nt4s200024

Assignment Due Date: Week10

Assignment Submission Date: Week22

I confirm that I understand my coursework needs to be submitted online via Google


Classroom under the relevant module page before the deadline for my assignment to
be accepted and marked. I am fully aware that late submissions will be treated as
non-submission and a mark of zero will be awarded.

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

Figure 1: Task 1....................................................................................................................... 2


Figure 2: changing to Miami directory .................................................................................. 3
Figure 3: showing absence of Miami directory by tree command ................................... 4
Figure 4: Usage of echo command ...................................................................................... 4
Figure 5: changing to Lakers directory from NBA .............................................................. 5
Figure 6: pwd; cd; pwd command......................................................................................... 5
Figure 7: suppling multiple arguments on single line command ...................................... 6
Figure 8: cd; pwd command usage ...................................................................................... 6
Figure 9: Usage of ls command ............................................................................................ 7
Figure 10: Usage of "ls -a" command .................................................................................. 7
Figure 11: usage of "ls -al" command ................................................................................. 7
Figure 12: cd;pwd; cd cw2; pwd utility ................................................................................. 8
Figure 13: Usage of "ls -R" command.................................................................................. 8
Figure 14: TestX and its content ........................................................................................... 9
Figure 15; TestY and its content. ........................................................................................ 10
Figure 16: TestZ and its content. ........................................................................................ 10
Figure 17: cat testX testY testZ command ........................................................................ 11
Figure 18: Usage of cat testX testY testZ>testResult ..................................................... 11
Figure 19: cat test [XYZ] command .................................................................................... 12
Figure 20: Displaying access permission for files in Chicago Bulls .............................. 13
Figure 21: Removing permission for testX ........................................................................ 13
Figure 22: giving access permission to the testX ............................................................. 14
Figure 23: reading testX file using cat utility ..................................................................... 14
Figure 24: writing in the testX file ....................................................................................... 15
Figure 25: Giving write and read permission to user ....................................................... 15
Figure 26: reading file using cat utility. .............................................................................. 16
Figure 27: writing in the file using nano utility. .................................................................. 16
Figure 28: Display access permission for Chicago Bulls. ............................................... 17
Figure 29: Displaying access permission for the Chicago Bulls. ................................... 17
Figure 30: Usage of grep bb testX command. .................................................................. 18
Figure 31: usage of grep -v bb testX .................................................................................. 19
Figure 32: Usage of grep -n bb testX utility. ..................................................................... 19
Figure 33: Usage of the grep -l bb * ................................................................................... 19
Figure 34: Usages of grep-i bb * ......................................................................................... 20
Figure 35: Usage of grep -i BB * command ...................................................................... 20
Figure 36: USage of grep -c bb* utility. .............................................................................. 20
Figure 37: Usage of grep '^A' * command ......................................................................... 21
Figure 38: grep -n '^' testX command usage .................................................................... 22
Figure 39: Creating alias and showing them. ................................................................... 22
Figure 40: using lsal alias in home directory..................................................................... 23
Madhusudan Subedi
Networks and Operating Systems CS5001NA

Figure 41: usage of lsa alias in home directory ................................................................ 23


Figure 42: showing our system doesn't store them. ........................................................ 24
Figure 43: saving the aliases for next session ................................................................. 24
Figure 44: noAllf Command ................................................................................................. 26
Figure 45: Usage of noAsubsir command ......................................................................... 26
Figure 46: Usage of noAcs command. .............................................................................. 26

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.

Linux is an open source operating system, which is a popular version of UNIX


operating systems. It is like other os such as windows mac Microsoft and many more.
Different IT professional, astronauts and scientist because of easiness use it. Like in
other operating system, Linux also has GUI and same types of software, which we see
in other operating systems. In Linux os shell is the GUI between the user and the os.
Linux allows user to do various task with few lines of command which is its best part.
It is easy and fast to use, so whenever we talk to a Linux user he/she prefer Linux over
other operating system.

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:

For starting the script:

1. madhusudan_subedi@suheart:~$ script 19033784CW2part1

1. Script started on 2021-03-29 02:58:19-07:00 [TERM="xterm-256color"


TTY="/dev/tty1" COLUMNS="120" LINES="30"]

1. madhusudan_subedi@suheart:~$ export PS1="\`pwd\`$"

Madhusudan Subedi Page | 1


Networks and Operating Systems CS5001NA

Question1. Creating new directories:

#Task1

Command: Creating the NBA directory.

1. /home/madhusudan_subedi$ mkdir -p NBA/{Lakers,Miami,"Chicago


Bulls","Brooklyn nets","Dallas Maveric"}

Command: Showing the directory structure

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

Madhusudan Subedi Page | 2


Networks and Operating Systems CS5001NA

Question 2. Removing Existing Files and directories

#Task2

Command: Changing to Miami directory

1. /home/madhusudan_subedi$ cd NBA/Miami/

Command: showing we are in Miami directory

1. /home/madhusudan_subedi/NBA/Miami$ pwd
2. /home/madhusudan_subedi/NBA/Miami

Screenshot

Figure 2: changing to Miami directory

Command: Create two files in Miami

1. /home/madhusudan_subedi/NBA/Miami$ touch file1 file2

#Task3

Command: Change to the NBA directory.

1. /home/madhusudan_subedi/NBA/Miami$ cd ..

Command: Removing both files

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

Command: Removing Miami directory

Madhusudan Subedi Page | 3


Networks and Operating Systems CS5001NA

1. /home/madhusudan_subedi/NBA$rmdir Miami

Screenshot

Figure 3: showing absence of Miami directory by tree command

Question3. Usage of the echo command

#Task4

Command: Print the string in one echo command

1. /home/madhusudan_subedi/NBA$ echo "Hello! I am big fan of NBA finals."


2. Hello! I am big fan of NBA finals.
3. /home/madhusudan_subedi/NBA$ echo "14<(2+2)"
4. 14<(2+2)

Screenshot

Figure 4: Usage of echo command

Command: showing current working directories

1. /home/madhusudan_subedi/NBA$pwd
2. /home/madhusudan_subedi/NBA

Madhusudan Subedi Page | 4


Networks and Operating Systems CS5001NA

Command: Changing directory to Lakers

1. /home/madhusudan_subedi/NBA$cd Lakers/
2. /home/madhusudan_subedi/NBA/Lakers$

Screenshot

Figure 5: changing to Lakers directory from NBA

#Task5: explanation of pwd; cd; pwd

Command: pwd; cd; pwd

1. /home/madhusudan_subedi/NBA/Lakers$pwd; cd; pwd

Screenshot

Figure 6: pwd; cd; pwd command


Explanation: The pwd; cd; pwd command has three arguments in a single line
command each command is separate by the semicolon. Here, first pwd; is executed
and print the current working directory (which is /NBA/Lakers)and then cd; command
is executed which bring us to the home directory and again pwd prints our current
working directory (which is /home/madhusudan_subedi)

#Task6

Command: Changing again to the Lakers using relative pathname

1. /home/madhusudan_subedi$ cd NBA/Lakers/
2. Command: pwd; cd ..; pwd; cd ..; pwd

Madhusudan Subedi Page | 5


Networks and Operating Systems CS5001NA

3. /home/madhusudan_subedi/NBA/Lakers$pwd; cd ..; pwd; cd ..; pwd


4. /home/madhusudan_subedi/NBA/Lakers
5. /home/madhusudan_subedi/NBA
6. /home/madhusudan_subedi
7. /home/madhusudan_subedi$

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

Figure 7: suppling multiple arguments on single line command

Question 4. Usage of the ls command

#Task7

Command: cd; pwd

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:

Figure 8: cd; pwd command usage

Madhusudan Subedi Page | 6


Networks and Operating Systems CS5001NA

Command: ls

Explanation: This ‘ls’ commands refers for list which show all the directories and file
inside the folder.

Screenshot:

Figure 9: Usage of ls command


Command: ls –a

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

Figure 10: Usage of "ls -a" command


Command: ls –al

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:

Figure 11: usage of "ls -al" command

#Task8

Madhusudan Subedi Page | 7


Networks and Operating Systems CS5001NA

Command: cd; pwd; cd cw2; pwd

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:

Figure 12: cd;pwd; cd cw2; pwd utility

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:

Figure 13: Usage of "ls -R" command


Question 5. Usage of cat command

Command: Change to the Chicago Bulls directory

1. /home/madhusudan_subedi$cd NBA/"Chicago Bulls"

#Task9

Command: for creating testX

1. /home/madhusudan_subedi/NBA/Chicago Bulls$cat>testX
2. aaabb Aaaaa
3. AAAAA
4. bbbcc Bbbbb

Madhusudan Subedi Page | 8


Networks and Operating Systems CS5001NA

5. BBBBB
6. ff-ff Ccccc
7. CCCCC
8. cccdd Ddddd
9. DDDDD

Command: for creating testY

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

Command: for creating testZ

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

Screenshot of testX, testY and testZ respectively,

Figure 14: TestX and its content

Madhusudan Subedi Page | 9


Networks and Operating Systems CS5001NA

Figure 15; TestY and its content.

Figure 16: TestZ and its content.

#Task 11: Copy these files to the Brooklyn nets directory typing a relative
pathname.

Command: Copying the files from Chicago Bulls to Brooklyn nets

1. /home/madhusudan_subedi/NBA/Chicago Bulls$cp testX testY testZ


/home/madhusudan_subedi/NBA/Brooklyn\ nets/

#Task12: Concatenate the files using following commands.

Command: cat testX testY testZ

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.

Madhusudan Subedi Page | 10


Networks and Operating Systems CS5001NA

Screenshot:

Figure 17: cat testX testY testZ command


Command: cat testX testY testZ > testResult

1. /home/madhusudan_subedi/NBA/Chicago Bulls$cat testX testY


testZ>testResults
2. /home/madhusudan_subedi/NBA/Chicago Bulls$

Screenshot:

Figure 18: Usage of cat testX testY testZ>testResult


Explanation:

This command has run but didn’t give any output, which we can see in the figure 17
above.

#Task13:

Command: cat test[XYZ]

Screenshot:

Madhusudan Subedi Page | 11


Networks and Operating Systems CS5001NA

Figure 19: cat test [XYZ] command


Explanation: This cat command enables us to print the content of the file in
respective orders. As we had first given cat command which read the given file, and
after that there is mentioned common part in the name of the files after that name of
file is given in respective orders. The command first look for the file in the system
and if the file is there it read and display the file otherwise it shows error message.

Question6. Usage of the chmod command.

#Task14

Command: Displaying the access permission for files in Chicago Bulls

1. /home/madhusudan_subedi/NBA/Chicago Bulls$chmod ugo+x testX testY


testZ testResult

Displaying access permission:

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:

Madhusudan Subedi Page | 12


Networks and Operating Systems CS5001NA

Figure 20: Displaying access permission for files in Chicago Bulls


Command: Remove all access permission for the test file

1. /home/madhusudan_subedi/NBA/Chicago Bulls$chmod ugo-rwx testX

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:

Figure 21: Removing permission for testX


Command: Display access permission for the testX file

1. /home/madhusudan_subedi/NBA/Chicago Bulls$chmod u+rwx testX

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:

Madhusudan Subedi Page | 13


Networks and Operating Systems CS5001NA

Figure 22: giving access permission to the testX


Command: Try to read testX file using any utility

1. /home/madhusudan_subedi/NBA/Chicago Bulls$ cat testX

Response

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

Screenshot:

Figure 23: reading testX file using cat utility

Command: Try to write in file using any utility

1. /home/madhusudan_subedi/NBA/Chicago Bulls$nano testX

Madhusudan Subedi Page | 14


Networks and Operating Systems CS5001NA

Screenshot:

Figure 24: writing in the testX file

Command: Add read and write access permissions for yourself for the testX
file.

1. /home/madhusudan_subedi/NBA/Chicago Bulls$chmod u+rw testX

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:

Figure 25: Giving write and read permission to user

Command: Read the file using cat utility

1. /home/madhusudan_subedi/NBA/Chicago Bulls$cat testX

Madhusudan Subedi Page | 15


Networks and Operating Systems CS5001NA

Screenshot:

Figure 26: reading file using cat utility.


Command: Write into the file using any utility

1. /home/madhusudan_subedi/NBA/Chicago Bulls$nano testX

Screenshot:

Figure 27: writing in the file using nano utility.


#Task15

Command: Changing to NBA directory.

1. /home/madhusudan_subedi/NBA/Chicago Bulls$cd ..

Command: Display access permission for Chicago Bulls directory:

1. /home/madhusudan_subedi/NBA$ ls -l

Command: Remove all permission for the Chicago Bulls directory.

1. /home/madhusudan_subedi/NBA$chmod u-rwx Chicago\ Bulls

Command: Display access permission for the Chicago Bulls directory.

1. /home/madhusudan_subedi/NBA$ ls -l

Screenshot:

Madhusudan Subedi Page | 16


Networks and Operating Systems CS5001NA

Figure 28: Display access permission for Chicago Bulls.

Command: Try to read a file from Chicago Bulls using any utility

/home/madhusudan_subedi/NBA$ cd Chicago\ Bulls; cat testX

Command: Try to put a file into Chicago Bulls using any utility.

1. /home/madhusudan_subedi/NBA$ cat NBA/Chicago\ Bulls/ file

Command: Try to search in 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$chmod u+rwx Chicago\ Bulls

Command: Display the access permission for the Chicago Bulls.

1. /home/madhusudan_subedi/NBA$ ls –l

Screenshot:

Figure 29: Displaying access permission for the Chicago Bulls.

Command: read a file from Chicago Bulls using any utility.

Madhusudan Subedi Page | 17


Networks and Operating Systems CS5001NA

1. /home/madhusudan_subedi/NBA$cd Chicago\ Bulls; cat testX

Command: Put a file in Chicago Bulls.

1. /home/madhusudan_subedi/NBA/Chicago Bulls$cat>>file

Command: Search in Chicago Bulls using any utility.

1. /home/madhusudan_subedi/NBA/Chicago Bulls$ls

Question7: Usage of the grep command.

Command: Change to Brooklyn nets directory

1. /home/madhusudan_subedi/NBA/Chicago Bulls$cd ..; cd Brooklyn\ nets

#Task16

Command: grep bb testX

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:

Figure 30: Usage of grep bb testX command.


Command: grep –v bb testX

Madhusudan Subedi Page | 18


Networks and Operating Systems CS5001NA

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.

Figure 31: usage of grep -v bb testX

Command: grep –n bb testX

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.

Figure 32: Usage of grep -n bb testX utility.


Command: Usage of grep –l bb *

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:

Figure 33: Usage of the grep -l bb *


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)

Madhusudan Subedi Page | 19


Networks and Operating Systems CS5001NA

Screenshot:

Figure 34: Usages of grep-i bb *

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:

Figure 35: Usage of grep -i BB * command


Command: grep -c bb *

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:

Figure 36: USage of grep -c bb* utility.

Madhusudan Subedi Page | 20


Networks and Operating Systems CS5001NA

Command: grep ‘^A’*

1. /home/madhusudan_subedi/NBA/Brooklyn nets$grep '^A' *


2. testX:AAAAA
3. testY:AAAAA
4. testZ:AAAAA

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

Figure 37: Usage of grep '^A' * command

Command: grep –n ‘^’testX

1. /home/madhusudan_subedi/NBA/Brooklyn nets$grep -n '^' testX

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:

Madhusudan Subedi Page | 21


Networks and Operating Systems CS5001NA

Figure 38: grep -n '^' testX command usage

Question.8 Aliasing

#Task17: Define two aliases for the ls command: lsal for the ls -al command
and lsa for ls -a command.

Command:

alias lsal=’ls -al’

alias lsa=’ls –a’

Command: Showing that our system stores this alias

Screenshot:

Figure 39: Creating alias and showing them.

Command: Use them in our home directory.

/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

Madhusudan Subedi Page | 22


Networks and Operating Systems CS5001NA

7. -rw-r--r-- 1 madhusudan_subedi madhusudan_subedi 3072 Mar 28 04:04


19033784cw2part1
8. drwxr-xr-x 1 madhusudan_subedi madhusudan_subedi 512 Mar 27 18:41
NBA

Screenshot:

Figure 40: using lsal alias in home directory

Command: Using the lsa alias in home directory

/home/madhusudan_subedi$lsa

Output:

1. /home/madhusudan_subedi$lsa
2. . .. .bash_history .local 19033784cw2part1 NBA

Screenshot:

Figure 41: usage of lsa alias in home directory

#Task18

Command removing the aliases

1. /home/madhusudan_subedi$unalias lsa
2. /home/madhusudan_subedi$unalias lsal

Screenshot: Showing our system doesn’t store those aliases

Madhusudan Subedi Page | 23


Networks and Operating Systems CS5001NA

Figure 42: showing our system doesn't store them.


#Task19

Command defining the aliases again and preserving for next session:

1. /home/madhusudan_subedi$alias lsa='ls -a'


2. /home/madhusudan_subedi$alias lsal='ls -al'
3. /home/madhusudan_subedi$cat>nano .alias
4.

1. Ctrl + s
2. Ctrl + x

Command:

1. /home/madhusudan_subedi$ nano .bashrc


2.

Screenshot:

Figure 43: saving the aliases for next session

#Task20

Command: defining the noAllf alias for a group of command

1. /home/madhusudan_subedi$ alias noAllf='ls -al | wc -l'


2. /home/madhusudan_subedi$nano NBA/Brooklyn\ nets/.alias

alias noAllf='ls -al | wc -l'

Ctrl S

Ctrl X

Madhusudan Subedi Page | 24


Networks and Operating Systems CS5001NA

#Task21

Command: Define noasubsir alias

1. /home/madhusudan_subedi$alias noAsubsir='ls -laR | grep "^d" | wc -l'


2. /home/madhusudan_subedi$nano NBA/Brooklyn\ nets/.alias

alias noAsubsir='ls -laR | grep "^d" | wc -l'

Ctrl S

Ctrl X

#Task22

Command: Defining noAcs alias

1. /home/madhusudan_subedi$alias noAcs='ls -a | grep "^[gtw]" | wc -l'


2. /home/madhusudan_subedi$nano NBA/Brooklyn\ nets/.alias

alias noAcs='ls -a | grep "^[gtw]" | wc -l'

Ctrl S

Ctrl X

Command: Display all aliases:

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'

Question9. Usage of your own command

#Task23

Command

1. /home/madhusudan_subedi$noAllf

Output: 11

Madhusudan Subedi Page | 25


Networks and Operating Systems CS5001NA

Screenshot:

Figure 44: noAllf Command

#Task24

Command

1. /home/madhusudan_subedi$noAsubsir

Output: 26

Screenshot:

Figure 45: Usage of noAsubsir command

#Task25

Command:

1. /home/madhusudan_subedi$noAcs

Output: 0

Screenshot:

Figure 46: Usage of noAcs command.

Question10. Command history

#Task26

Command: list the last commands executed giving any history command

1. /home/madhusudan_subedi$fc –l
2. 93 nano .alias

Madhusudan Subedi Page | 26


Networks and Operating Systems CS5001NA

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:

Command: reexecute the command given 8 command ago

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"}

Madhusudan Subedi Page | 27


Networks and Operating Systems CS5001NA

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.

Madhusudan Subedi Page | 28

You might also like