Вы находитесь на странице: 1из 37

Module Code & Module Title

CS5001NA Networks and Operating Systems

Assessment Weightage & Type

10% Individual Coursework

Year and Semester

2019-20 Autumn

Student Name: Tabsum Khadka

London Met ID: 18030084

College ID: np01cp4a180237

Assignment Due Date: 29th May 2020

Assignment Submission Date:29th May 2020

Title (Where Required):

Word Count (Where Required):


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.

Contents
Table of figure...................................................................................................................................4
Introduction........................................................................................................................................1
Main objectives:............................................................................................................................1
Transcript...........................................................................................................................................2
Assignment Tasks............................................................................................................................2
1) Creating new Directories........................................................................................................2
Task 1:.........................................................................................................................................2
2 ) Removing existing files and directories............................................................................3
Task 2:.........................................................................................................................................3
Task 3:.........................................................................................................................................3
4) Usages of echo command.....................................................................................................4
Task 4:.........................................................................................................................................4
Task 5:.........................................................................................................................................5
Task 6:.........................................................................................................................................5
4. Usage of the ls command.......................................................................................................5
Task 7 :........................................................................................................................................6
Task 8 :........................................................................................................................................7
5. Usage of the cat command....................................................................................................8
Task 9:.........................................................................................................................................8
Task 10:.......................................................................................................................................9
Task 11:.....................................................................................................................................11
Task 12:.....................................................................................................................................11
Task 13:.....................................................................................................................................13
6. Usage of the chmod command..........................................................................................15
Task 14:.....................................................................................................................................15
Task 15:.....................................................................................................................................17
7. Usage of the grep command...............................................................................................19
Task 16:.....................................................................................................................................19
8) Aliasing.....................................................................................................................................24
Task 17:.....................................................................................................................................24
Task 18:.....................................................................................................................................25
Task 19:.....................................................................................................................................25
Task 20:.....................................................................................................................................27
Task 21:.....................................................................................................................................28
Task 22:.....................................................................................................................................29
9) Usage of your own commands...........................................................................................29
Task 23 :....................................................................................................................................29
Task 24:.....................................................................................................................................30
Task 25 :....................................................................................................................................30
10. Command History................................................................................................................30
Task 26:.....................................................................................................................................30
Task 27:.....................................................................................................................................30
Task 28:.....................................................................................................................................31
Conclusion.......................................................................................................................................32
References.......................................................................................................................................33
Table of figure
Figure 1 Structure Needed For this CourseWork.........................................................2
Figure 2Using alias command #ttask 19....................................................................26
Figure 3 Using nano .task20 to definetask.20 in bashrc............................................28
Figure 4 Using nano .task21 noAsubsir alias in .bashrc...........................................28
Figure 5 Using nano .task22 to define noAcs alias in .bashrc...................................29
Network Operating System CS5001NA

Introduction
(Pronounced yoo-niks) UNIX is a popular multi-user, multitasking operating system (OS)
developed at Bell Labs in the early 1970s. Created by just a handful of programmers, UNIX
was designed to be a small, flexible system used exclusively by programmers. [ CITATION
Ban12 \l 1033 ]

Due to its portability, flexibility, and power, UNIX has become a leading operating system for
workstations. Historically, it has been less popular in the personal computer market.
UNIX was one of the first operating systems to be written in a high-level programming
language, namely C. This meant that it could be installed on virtually any computer for which
a C compiler existed. This natural portability combined with its low price made it a popular
choice among universities. It was inexpensive because antitrust regulations prohibited Bell
Labs from marketing it as a full-scale product. [ CITATION web12 \l 1033 ]

Main objectives:

The main objectives of this course work are as follows:

• To introduce students some relevant UNIX interface details by practicing UNIX


commands.
• To perform some simple file-based operation by putting commands step by step.

1
Tabsum Khadka
Network Operating System CS5001NA

Transcript

Assignment Tasks

tabsumkhadkaa@DESKTOP-6H6TTJ6:~$ PS1='$PWD> '

1) Creating new Directories.

Task 1: Starting from your home directory, create the directory structure shown in Figure 1,
staying in your home directory using relative pathnames.
Show the structure
Stay in your home directory.

Cricket

Home Bangladesh

India
Pakistan
Australia England

Figure 1 Structure Needed For this CourseWork

2
Tabsum Khadka
Network Operating System CS5001NA

Command :
/home/tabsumkhadkaa> mkdir -p Cricket/{India,Australia,England,Pakistan,Bangladesh}
/home/tabsumkhadkaa> tree

Output
.
├── 18030084cw2paart1
└── Cricket
├── Australia
├── Bangladesh
├── England
├── India
└── Pakistan

2 ) Removing existing files and directories.

Task 2: Change to the India directory typing a relative pathname.


Show that you are in this directory.
Create two files in the India directory using any UNIX utility.
Command :
/home/tabsumkhadkaa> cd Cricket/India
/home/tabsumkhadkaa/Cricket/India> touch file1 file2
/home/tabsumkhadkaa/Cricket/India> ls
Output : File1 File2

Task 3: Change to the Cricket directory. Remove both files of the India directory and then
the India directory using the corresponding command(s) with the Interactive Mode (-i) option
for the rm command respectively.
Show absence of these files and the directory.
Command :
/home/tabsumkhadkaa/Cricket/India> cd ..

3
Tabsum Khadka
Network Operating System CS5001NA

/home/tabsumkhadkaa/Cricket> rm -i India/file1
rm: remove regular empty file 'India/file1'? y
/home/tabsumkhadkaa/Cricket> rm -i India/file2
rm: remove regular empty file 'India/file2'? y
/home/tabsumkhadkaa/Cricket> ls

Output : Australia Bangladesh England India Pakistan

/home/tabsumkhadkaa/Cricket> ls India
/home/tabsumkhadkaa/Cricket> rm -r India
/home/tabsumkhadkaa/Cricket> ls
Output : Australia Bangladesh England Pakistan

4) Usages of echo command.

You know that the echo command can be used to print the argument of the command.
Show that you can do it.

Task 4: Print the following strings each in one echo command


• Cricket is a bat and ball game played between two teams.
• 14 < (2+2)

Command :
/home/tabsumkhadkaa/Cricket> echo -e 'Cricket is a bat and ball game played between two
teams.\n14<(2+2)
Output : Cricket is a bat and ball game played between two teams. 14 < (2+2)

Now you are still in the Cricket directory. Give the pwd command. Change to the Australia
directory typing a relative pathname. Show that you are in this directory.
Command :
/home/tabsumkhadkaa/Cricket> pwd
/home/tabsumkhadkaa/Cricket
/home/tabsumkhadkaa/Cricket> cd Australia

4
Tabsum Khadka
Network Operating System CS5001NA

/home/tabsumkhadkaa/Cricket/Australia> pwd
/home/tabsumkhadkaa/Cricket/Australia
/home/tabsumkhadkaa/Cricket/Australia>

Task 5: Give the group of the following commands: pwd; cd; pwd Give a short explanation
of the group.
Command :
/home/tabsumkhadkaa> echo -e "Pwd first displays the new directory, which is Australia
directory, and then returns to the home directory using the cd command. The new directory,
which is the home directory is shown againby pwd at last."

Output : Pwd first displays the new directory, which is Australia directory, and then returns
to the home directory using the cd command. The new directory, which is the home directory
is shown againby pwd at last.

Task 6: Change to the Australia directory again typing a relative pathname.


Give the group of the following commands:
pwd; cd ..; pwd; cd ..; pwd
Give a short explanation of the group
Command :
/home/tabsumkhadkaa> cd Cricket/Australia
/home/tabsumkhadkaa/Cricket/Australia> pwd; cd ..; pwd; cd ..; pwd
/home/tabsumkhadkaa/Cricket/Australia
/home/tabsumkhadkaa/Cricket
/home/tabsumkhadkaa
/home/tabsumkhadkaa> echo -e " First pwd shows the new working directory which is
Australia nad then goes back to the Cricket directory using cd command. Once again pwd
command is used to show the new directory which is the Cricket directory. Cd command is
used to view the home directory and eventuallt the current directory is displayed, which is
home directory with pwd command. "
Output : First pwd shows the new working directory which is Australia nad then goes back
to the Cricket directory using cd command. Once again pwd command is used to show the
new directory which is the Cricket directory. Cd command is used to view the home directory
and eventuallt the current directory is displayed, which is home directory with pwd command.

5
Tabsum Khadka
Network Operating System CS5001NA

4. Usage of the ls command


Give the following commands and then give a short explanation for each ls command

Task 7 :
- Cd;pwd

/home/tabsumkhadkaa> cd;pwd
/home/tabsumkhadkaa
/home/tabsumkhadkaa> echo -e "Since that we are in home directory this command
will be showing our home directory."
Since that we are in home directory this command will be showing our home
directory.

- Ls
/home/tabsumkhadkaa> ls

Output : 18030084cw2paart1 Cricket

/home/tabsumkhadkaa> echo -e " This command is used to list information about


files and directories within the file system."

Output : This command is used to list information about files and directories within
the file system.

- Ls -a

/home/tabsumkhadkaa> ls -a

Output : . .. 18030084cw2paart1 .bash_logout .bashrc Cricket .profile

/home/tabsumkhadkaa> echo -e "This command here is used to show the unhidden


or the hidden files."

Output : This command here is used to show the unhidden or the hidden files.

Ls -al

/home/tabsumkhadkaa> ls -al
total 24
Output : drwxr-xr-x 1 tabsumkhadkaa tabsumkhadkaa 4096 Apr 12 14:48 .
drwxr-xr-x 1 root root 4096 Apr 12 14:44 ..
-rw-rw-rw- 1 tabsumkhadkaa tabsumkhadkaa 8192 Apr 12 15:18
18030084cw2paart1
-rw-r--r-- 1 tabsumkhadkaa tabsumkhadkaa 220 Apr 12 14:44 .bash_logout
-rw-r--r-- 1 tabsumkhadkaa tabsumkhadkaa 3526 Apr 12 14:44 .bashrc
drwxrwxrwx 1 tabsumkhadkaa tabsumkhadkaa 4096 Apr 12 15:00 Cricket
-rw-r--r-- 1 tabsumkhadkaa tabsumkhadkaa 807 Apr 12 14:44 .profile

/home/tabsumkhadkaa> echo -e "ls -al command is used to show the description of


hidden and unhidden files."

6
Tabsum Khadka
Network Operating System CS5001NA

Output : ls -al command is used to show the description of hidden and unhidden
files.

Task 8 :
cd; pwd; cd Cricket; pwd
/home/tabsumkhadkaa> cd; pwd; cd Cricket; pwd
/home/tabsumkhadkaa
/home/tabsumkhadkaa/Cricket
/home/tabsumkhadkaa/Cricket> echo -e " At first, cd or change directory command is used
which remains to the home directory.The pwd command then shows the latest working
directory which is home directory. After that cd Cricket changes the directory to Cricket from
home and pwd as we said shows the working directory,so we are still in Cricket directory
after pwd command."

Output : At first, cd or change directory command is used which remains to the home
directory.The pwd command then shows the latest working directory which is home
directory. After that cd Cricket changes the directory to Cricket from home and pwd as we
said shows the working directory,so we are still in Cricket directory after pwd command.

Ls -R
/home/tabsumkhadkaa/Cricket> ls -R

Output :
.:
Australia Bangladesh England Pakistan

./Australia:

./Bangladesh:

./England:

./Pakistan:
/home/tabsumkhadkaa/Cricket> echo -e "This cpmmand is used to show the files recursively
which means we will list folders and thier contents."

7
Tabsum Khadka
Network Operating System CS5001NA

Output : This cpmmand is used to show the files recursively which means we will list folders
and thier contents.

5. Usage of the cat command


Change to the Australia directory.

Task 9: Create three following files using the cat utility:


File name testX testY testZ

Contents aaabb Aaaaa aaabb Aaaaa aaabb Aaaaa


of the files
AAAAA AAAAA AAAAA

bbbcc Bbbbb bbbcc Bbbbb bbbcc Bbbbb

BBBBB BBBBB BBBBB

ff-ff Ccccc ff-ff Ccccc ff-ff Ccccc

CCCCC CCCCC CCCCC

cccdd Ddddd cccdd Ddddd cccdd Ddddd

DDDDD DDDDD DDDDD

Command :

/home/tabsumkhadkaa/Cricket/Australia> cat > testX


aaabb Aaaaa
AAAAA
bbbcc Bbbbb
BBBBB
ff-ff Ccccc
CCCCC
cccdd Ddddd
DDDDD
^C

8
Tabsum Khadka
Network Operating System CS5001NA

/home/tabsumkhadkaa/Cricket/Australia> cat > testY


aaabb Aaaaa
AAAAA
bbbcc Bbbbb
BBBBB
ff-ff Ccccc
CCCCC
cccdd Ddddd
DDDDD
^C

/home/tabsumkhadkaa/Cricket/Australia> cat>testZ
aaabb Aaaaa
AAAAA
bbbcc Bbbbb
BBBBB
ff-ff Ccccc
CCCCC
cccdd Ddddd
DDDD
^C

Task 10: Display each of these files using the cat utility.

Command :
/home/tabsumkhadkaa/Cricket/Australia> cat testX

Output
aaabb Aaaaa

9
Tabsum Khadka
Network Operating System CS5001NA

AAAAA
bbbcc Bbbbb
BBBBB
ff-ff Ccccc
CCCCC
cccdd Ddddd
DDDDD

Command :

/home/tabsumkhadkaa/Cricket/Australia> cat testY


Output :
aaabb Aaaaa
AAAAA
bbbcc Bbbbb
BBBBB
ff-ff Ccccc
CCCCC
cccdd Ddddd
DDDDD

Command :

/home/tabsumkhadkaa/Cricket/Australia> cat testZ

Output :
aaabb Aaaaa
AAAAA
bbbcc Bbbbb
BBBBB
ff-ff Ccccc
CCCCC

10
Tabsum Khadka
Network Operating System CS5001NA

cccdd Ddddd
DDDD

Task 11: Copy these files to the Bangladesh directory typing a relative pathname.
/home/tabsumkhadkaa/Cricket/Australia> cp testX ../Bangladesh/
/home/tabsumkhadkaa/Cricket/Australia> cp testY ../Bangladesh/
/home/tabsumkhadkaa/Cricket/Australia> cp testZ ../Bangladesh/

Task 12: Concatenate the files using the following commands (put 2–3 lines with
reasonable contents during the execution of the third command):

- Cat testX testY testZ

/home/tabsumkhadkaa/Cricket/Australia> cat testX testY testZ

Output :
aaabb Aaaaa
AAAAA
bbbcc Bbbbb
BBBBB
ff-ff Ccccc
CCCCC
cccdd Ddddd
DDDDD
aaabb Aaaaa
AAAAA
bbbcc Bbbbb
BBBBB
ff-ff Ccccc
CCCCC
cccdd Ddddd
DDDDD
aaabb Aaaaa
AAAAA
bbbcc Bbbbb
BBBBB
ff-ff Ccccc
CCCCC
cccdd Ddddd
DDDD

- Cat testX testy testZ> testResult

/home/tabsumkhadkaa/Cricket/Australia> cat testX testY testZ > testResult


/home/tabsumkhadkaa/Cricket> cat testResult

11
Tabsum Khadka
Network Operating System CS5001NA

Output :

aaabb Aaaaa
AAAAA
bbbcc Bbbbb
BBBBB
ff-ff Ccccc
CCCCC
cccdd Ddddd
DDDDD
aaabb Aaaaa
AAAAA
bbbcc Bbbbb
BBBBB
ff-ff Ccccc
CCCCC
cccdd Ddddd
DDDDD
aaabb Aaaaa
AAAAA
bbbcc Bbbbb
BBBBB
ff-ff Ccccc
CCCCC
cccdd Ddddd
DDDD

Cat testx – testY >> testResult

/home/tabsumkhadkaa/Cricket/Australia> cat testX - testY >> testResult


I am Tabsum Khadka
I Study in Islington College

Display testResult using cat. Consider if it is correct…

Commad : cat testResult

Output :

aaabb Aaaaa
AAAAA
bbbcc Bbbbb

12
Tabsum Khadka
Network Operating System CS5001NA

BBBBB
ff-ff Ccccc
CCCCC
cccdd Ddddd
DDDDD
aaabb Aaaaa
AAAAA
bbbcc Bbbbb
BBBBB
ff-ff Ccccc
CCCCC
cccdd Ddddd
DDDDD
aaabb Aaaaa
AAAAA
bbbcc Bbbbb
BBBBB
ff-ff Ccccc
CCCCC
cccdd Ddddd
DDDD
aaabb Aaaaa
AAAAA
bbbcc Bbbbb
BBBBB
ff-ff Ccccc
CCCCC
cccdd Ddddd
DDDDD
I am Tabsum Khadka
I Study in Islington College

13
Tabsum Khadka
Network Operating System CS5001NA

Task 13: Give the following


Command :
cat test[XYZ]
Give a short explanation of the result.
Command :cat test[XYZ]

Output :

aaabb Aaaaa
AAAAA
bbbcc Bbbbb
BBBBB
ff-ff Ccccc
CCCCC
cccdd Ddddd
DDDDD
aaabb Aaaaa
AAAAA
bbbcc Bbbbb
BBBBB
ff-ff Ccccc
CCCCC
cccdd Ddddd
DDDDD
aaabb Aaaaa
AAAAA
bbbcc Bbbbb
BBBBB
ff-ff Ccccc
CCCCC
cccdd Ddddd
DDDD

14
Tabsum Khadka
Network Operating System CS5001NA

6. Usage of the chmod command

Task 14: Do the following sequence of actions. Remember that any action costs 7/9 mark...

Display access permissions for files in Australia


Command :

/home/tabsumkhadkaa/Cricket/Australia> cd ../
/home/tabsumkhadkaa/Cricket> ls -l Australia

Output :
total 0
-rw-rw-rw- 1 tabsumkhadkaa tabsumkhadkaa 338 Apr 13 14:50 testResult
-rw-rw-rw- 1 tabsumkhadkaa tabsumkhadkaa 72 Apr 13 14:43 testX
-rw-rw-rw- 1 tabsumkhadkaa tabsumkhadkaa 72 Apr 13 14:44 testY
-rw-rw-rw- 1 tabsumkhadkaa tabsumkhadkaa 72 Apr 13 14:45 testZ

Remove all access permissions for the testX file.


Command :

/home/tabsumkhadkaa/Cricket> chmod 000 Australia/testX

Display access permissions for the testX file.


Command :

/home/tabsumkhadkaa/Cricket> ls -l Australia

Output :
total 0
-rw-rw-rw- 1 tabsumkhadkaa tabsumkhadkaa 338 Apr 13 14:50 testResult
---------- 1 tabsumkhadkaa tabsumkhadkaa 72 Apr 13 14:43 testX

15
Tabsum Khadka
Network Operating System CS5001NA

-rw-rw-rw- 1 tabsumkhadkaa tabsumkhadkaa 72 Apr 13 14:44 testY


-rw-rw-rw- 1 tabsumkhadkaa tabsumkhadkaa 72 Apr 13 14:45 testZ

Try to read this file using any utility.


Command :

/home/tabsumkhadkaa/Cricket> cat Australia/testX


Output :
cat: Australia/testX: Permission denied

Try to write into this file using any utility


Command :
/home/tabsumkhadkaa/Cricket> cat > Australia/testX

Output :
bash: Australia/testX: Permission denied

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

/home/tabsumkhadkaa/Cricket> chmod u=rw Australia/testX

Display access permissions for the testX file.


Command :
/home/tabsumkhadkaa/Cricket> ls -l Australia/testX

Output :
-rw------- 1 tabsumkhadkaa tabsumkhadkaa 13 Apr 13 14:56 Australia/testX

Try to read this file using any utility.

16
Tabsum Khadka
Network Operating System CS5001NA

Command :
/home/tabsumkhadkaa/Cricket> cat Australia/testX

Output :
aaabb Aaaaa
AAAAA
bbbcc Bbbbb
BBBBB
ff-ff Ccccc
CCCCC
cccdd Ddddd
DDDDD

Try to write into this file using any utility

/home/tabsumkhadkaa/Cricket> cat > Australia/testX


I am Tabsum.

/home/tabsumkhadkaa/Cricket> cat Australia/testX


Output : I am Tabsum.

Task 15: Do the following sequence of actions. Remember that any action costs 9/12
mark...
Change to the Cricket directory.
Command :
/home/tabsumkhadkaa/Cricket/Australia> cd ../

Display access permissions for Australia.


Command :
/home/tabsumkhadkaa/Cricket> ls -ld Australia
Output

17
Tabsum Khadka
Network Operating System CS5001NA

drwxrwxrwx 1 tabsumkhadkaa tabsumkhadkaa 4096 Apr 13 14:49 Australia


Remove all access permissions for the Australia directory.
Command :
/home/tabsumkhadkaa/Cricket> chmod 000 Australia

Display access permissions for Australia.


Command :
/home/tabsumkhadkaa/Cricket> ls -ld Australia
Output :
d--------- 1 tabsumkhadkaa tabsumkhadkaa 4096 Apr 13 14:49 Australia

Try to read a file from Australia using any utility.


Command :
/home/tabsumkhadkaa/Cricket> cat Australia/testX
Output :
cat: Australia/testX: Permission denied

Try to put a file into Australia using any utility.


Command :
/home/tabsumkhadkaa/Cricket> Australia/testXY
Output :
bash: Australia/testXY: Permission denied

Try to search in Australia using any command (e.g., the ls command).


Command :
/home/tabsumkhadkaa/Cricket> ls Australia

Output :
ls: cannot open directory 'Australia': Permission denied

Add read, write, and execute access permissions for yourself for the Australia directory.
Command :

18
Tabsum Khadka
Network Operating System CS5001NA

/home/tabsumkhadkaa/Cricket> chmod u+rwx Australia

Display access permissions for Australia.


Command :
/home/tabsumkhadkaa/Cricket> ls -ld Australia.

Output :
drwx------ 1 tabsumkhadkaa tabsumkhadkaa 4096 Apr 13 14:49 Australia

Try to read a file from Australia using any utility.


Command :
/home/tabsumkhadkaa/Cricket> cat Australia/testX
Output : I am Tabsum.

Try to put a file into Australia using any utility.


Command :
/home/tabsumkhadkaa/Cricket> touch Australia/abcd

Try to search in Australia using any command (e.g., the ls command).


Command
/home/tabsumkhadkaa/Cricket> ls Australia
Output : abcd testResult testX testY testZ

7. Usage of the grep command

Change to the Bangladesh directory.


/home/tabsumkhadkaa/Cricket> cd Bangladesh

Task 16: Give the following commands and give the explanation of each of the command.
No marks without the comparison or an explanation!

-Grep bb testX
/home/tabsumkhadkaa/Cricket/Bangladesh> grep bb testX

19
Tabsum Khadka
Network Operating System CS5001NA

Output :
aaabb Aaaaa
bbbcc Bbbbb

Command :
/home/tabsumkhadkaa/Cricket/Bangladesh> echo -e " The text that contains bb
from the testX file is displayed with the help of this command."

Output :
The text that contains bb from the testX file is displayed with the help of this command.

-grep -v bb testX
/home/tabsumkhadkaa/Cricket/Bangladesh> grep -v bb testX
Output :

AAAAA
BBBBB
ff-ff Ccccc
CCCCC
cccdd Ddddd
DDDDD

/home/tabsumkhadkaa/Cricket/Bangladesh> echo -e " All the text line that contains the text
is displayed from testX except the test containing bb "

Output :
All the text line that contains the text is displayed from testX except the test containing bb

-grep -n bb testX

/home/tabsumkhadkaa/Cricket/Bangladesh> grep -n bb testX

20
Tabsum Khadka
Network Operating System CS5001NA

Output :
1:aaabb Aaaaa
3:bbbcc Bbbbb

/home/tabsumkhadkaa/Cricket/Bangladesh> echo -e " Texts conatining bb from the file testX


is displayed along with thier line number using this command."

Output :
Texts conatining bb from the file testX is displayed along with thier line number using this
command.

-grep -l bb *

/home/tabsumkhadkaa/Cricket/Bangladesh> grep -l bb

Output :
/home/tabsumkhadkaa/Cricket/Bangladesh> grep -l bb *
testX
testY
testZ

/home/tabsumkhadkaa/Cricket/Bangladesh> echo -e " The files that contains text bb is listed


using this command. "
Output :
The files that contains text bb is listed using this command.

-grep -i bb *

/home/tabsumkhadkaa/Cricket/Bangladesh> grep -i bb *

Output :
testX:aaabb Aaaaa
testX:bbbcc Bbbbb

21
Tabsum Khadka
Network Operating System CS5001NA

testX:BBBBB
testY:aaabb Aaaaa
testY:bbbcc Bbbbb
testY:BBBBB
testZ:aaabb Aaaaa
testZ:bbbcc Bbbbb
testZ:BBBBB
/home/tabsumkhadkaa/Cricket/Bangladesh> echo -e " This command ignores case sensitive
which means it shows all texts conatinng both bb and BB in it with its file name.”

Output

This command ignores case sensitive which means it shows all texts conatinng both bb and
BB in it with its file name.

-grep -I BB*

/home/tabsumkhadkaa/Cricket/Bangladesh> grep -i BB *

Output
testX:aaabb Aaaaa
testX:bbbcc Bbbbb
testX:BBBBB
testY:aaabb Aaaaa
testY:bbbcc Bbbbb
testY:BBBBB
testZ:aaabb Aaaaa
testZ:bbbcc Bbbbb
testZ:BBBBB

/home/tabsumkhadkaa/Cricket/Bangladesh> echo -e " This command here ignores case


sensitive which means it shows all texts containing both BB and bb in it with its file name."
Output :

22
Tabsum Khadka
Network Operating System CS5001NA

This command here ignores case sensitive which means it shows all texts containing both
BB and bb in it with its file name.

-grep -c bb*

/home/tabsumkhadkaa/Cricket/Bangladesh> grep -c bb *

Output

testX:2
testY:2
testZ:2
/home/tabsumkhadkaa/Cricket/Bangladesh> echo -e " The command above shows the
number of
lines where the pattern matches with the file name in the working directory."
Output :
The command above shows the number of lines where the pattern matches with the file
name in the working directory.

-grep ‘^A’*

/home/tabsumkhadkaa/Cricket/Bangladesh> grep '^A' *

Output :

testX:AAAAA
testY:AAAAA
testZ:AAAAA
/home/tabsumkhadkaa/Cricket/Bangladesh> echo -e "All the texts starting with 'A' along with
thier files is displayed by this command ."
Output :
All the texts starting with 'A' along with thier files is displayed by this command .

23
Tabsum Khadka
Network Operating System CS5001NA

-grep -n ‘^’testX
/home/tabsumkhadkaa/Cricket/Bangladesh> grep -n '^' testX
Output :
1:aaabb Aaaaa
2:AAAAA
3:bbbcc Bbbbb
4:BBBBB
5:ff-ff Ccccc
6:CCCCC
7:cccdd Ddddd
8:DDDDD

/home/tabsumkhadkaa/Cricket/Bangladesh> echo -e "This command is used to display the


lines in a file, proceded by thier line numbers."
Output :
This command is used to display the lines in a file, proceded by thier line numbers.

8) Aliasing

Task 17:
Define two aliases for the ls Command : lsaR for the ls -aR command and lsa
for ls -a command.
Show that your system stores them (giving the correspondent command)  Use them in
your home directory

ls -aR to lsar

Command :
/home/tabsumkhadkaa> alias lsar="ls -ar"
/home/tabsumkhadkaa> lsar

Output :

24
Tabsum Khadka
Network Operating System CS5001NA

.profile Cricket .bashrc .bash_logout 18030084cw2paart1 .. .

ls -a to lsa
Command :
/home/tabsumkhadkaa> alias lsa="ls -a"
/home/tabsumkhadkaa> lsa

Output :
. .. 18030084cw2paart1 .bash_logout .bashrc Cricket .profile

Task 18: Remove these aliases.


Show that your system does not store these aliases.

Command :
/home/tabsumkhadkaa> unalias lsa
/home/tabsumkhadkaa> lsa

Output :
bash: lsa: command not found

Task 19: Define the aliases again preserving them for the next session. Stop the session
exiting from the UNIX operating system (log out) and log in again. Show that the system
keeps these aliases

/home/tabsumkhadkaa> nano .bashrc

25
Tabsum Khadka
Network Operating System CS5001NA

Figure 2Using alias command #ttask 19

/home/tabsumkhadkaa> . .bashrc
tabsumkhadkaa@DESKTOP-6H6TTJ6:~$ script 18030084cw2paart1
Output : Script started, file is 18030084cw2paart1

tabsumkhadkaa@DESKTOP-6H6TTJ6:~$ PS1='$PWD> '


/home/tabsumkhadkaa> lsaR

Output :
.:
. .. 18030084cw2paart1 .bash_logout .bashrc Cricket .local .profile

./Cricket:
. .. Australia Bangladesh England Pakistan testResult

./Cricket/Australia:
. .. abcd testResult testX testY testZ

./Cricket/Bangladesh:

26
Tabsum Khadka
Network Operating System CS5001NA

. .. testX testY testZ

./Cricket/England:
. ..

./Cricket/Pakistan:
. ..

./.local:
. .. share

./.local/share:
. .. nano

./.local/share/nano:
. ..

/home/tabsumkhadkaa> lsa

Output :
. .. 18030084cw2paart1 .bash_logout .bashrc Cricket .local .profile

Task 20: Define the noAllf alias for a group of commands counting and displaying the
number of all files and directories in any working directory (including ones with invisible file
and directory names) and put the alias in your environmental file.

/home/tabsumkhadkaa> nano .task20

27
Tabsum Khadka
Network Operating System CS5001NA

Figure 3 Using nano .task20 to definetask.20 in bashrc

Task 21: Define the noAsubsir alias for a group of commands counting recursively and
displaying the number of all sub-directories encountered for any working directory (including
ones with invisible file and directory names) and put the alias in your environmental file.

/home/tabsumkhadkaa> nano .task21


/home/tabsumkhadkaa> nano .bashrc

Figure 4 Using nano .task21 noAsubsir alias in .bashrc

28
Tabsum Khadka
Network Operating System CS5001NA

Task 22: Define the noAcs alias for a group of commands counting and displaying the
number of all files and directories in your account’s space with the names starting with g, t,
and w and put the alias in your environmental file. Display all your aliases.

/home/tabsumkhadkaa> nano .task22


/home/tabsumkhadkaa> nano .bashrc

Figure 5 Using nano .task22 to define noAcs alias in .bashrc

9) Usage of your own commands


Task 23 :

/home/tabsumkhadkaa> noAllf
Output : 8

29
Tabsum Khadka
Network Operating System CS5001NA

Task 24:

/home/tabsumkhadkaa> noAsubsir
Output : 26

Task 25 :

/home/tabsumkhadkaa> noAcs
Output : 8

10. Command History


Task 26: List your last commands executed giving the any history command.
/home/tabsumkhadkaa> fc -l

Output :
559 nano .bashrc
560 unalias lsaR
561 unalias lsa
562 lsaR
563 lsa
564 cat > .bash_aliases
565 . .bashrc
566 PS1='$PWD> '
567 lsaR
568 lsa
569 nano .task20
570 nano .task21
571 nano .task22
572 noAllf
573 noAsubsir
574 noAcs

Task 27: Re execute the command given eight commands ago

30
Tabsum Khadka
Network Operating System CS5001NA

/home/tabsumkhadkaa> fc -e- -8

Output :
Lsa

Task 28: Re execute the last command which name begins with ‘c’.

/home/tabsumkhadkaa> fc -e- c

Output : cd
/home/tabsumkhadkaa> exit
exit
Script done, file is 18030084cw2paart1

31
Tabsum Khadka
Network Operating System CS5001NA

Conclusion

This Coursework wasn’t very difficult, It was an excellent way to develop out UNIX
awareness and its different resources such as shell scripting. I took the help of the lecture
slides as a reference. The main purpose of this coursework is to help us studenrs
understand the UNIX operating system.
All the given task are completed successfully without errors and are recorded in the script file
named 18030084cw2paart1. Now with this , some rubbish is also cleaned before finalizing
the report.

32
Tabsum Khadka
Network Operating System CS5001NA

References
Beal, B., 2012. Unix Os, s.l.: s.n.

webopedia, 2012. Unix History, s.l.: webopedia.

33
Tabsum Khadka

Вам также может понравиться