Anda di halaman 1dari 3

1) Write commands for the below structure

Currently you are in P2ChildDir2,


a) How do you copy the File2from this directory to P1ChildDir1
b) How do you copy the File2from this directory to HomeDirthen
c) How do youcopy the File2from this directory to P2ChildDir2 then

Ans :-

[u1352325@INTVMAO01 ~]$ mkdir HomeDir


[u1352325@INTVMAO01 ~]$ cd HomeDir
[u1352325@INTVMAO01 HomeDir]$ mkdir ParentDir1
[u1352325@INTVMAO01 HomeDir]$ mkdir ParentDir2
[u1352325@INTVMAO01 HomeDir]$ cd ParentDir1
[u1352325@INTVMAO01 ParentDir1]$ mkdir P1ChildDir1
[u1352325@INTVMAO01 ParentDir1]$ mkdir P1ChildDir2
[u1352325@INTVMAO01 ParentDir1]$ cd ..
[u1352325@INTVMAO01 HomeDir]$ cd ParentDir2
[u1352325@INTVMAO01 ParentDir2]$ mkdir P2ChildDir1
[u1352325@INTVMAO01 ParentDir2]$ mkdir P2ChildDir2
[u1352325@INTVMAO01 ParentDir2]$ cd ..
[u1352325@INTVMAO01 HomeDir]$ cd ParentDir1
[u1352325@INTVMAO01 ParentDir1]$ cd P1ChildDir2
[u1352325@INTVMAO01 P1ChildDir2]$ touch File2

a)How do you copy the File2 from this directory to P1ChildDir1

[u1352325@INTVMAO01 P2ChildDir2]$ cd ..
[u1352325@INTVMAO01 ParentDir2]$ cd ..
[u1352325@INTVMAO01 HomeDir]$ cd ParentDir1
[u1352325@INTVMAO01 ParentDir1]$ cd P1ChildDir2
[u1352325@INTVMAO01 P1ChildDir2]$ ls
File2
[u1352325@INTVMAO01 P1ChildDir2]$ cd ..
[u1352325@INTVMAO01 ParentDir1]$ cp P1ChildDir2/File2 P1ChildDir1/.
[u1352325@INTVMAO01 ParentDir1]$ cd P1ChildDir1
[u1352325@INTVMAO01 P1ChildDir1]$ ls
File2

b)How do you copy the File2from this directory to HomeDirthen


[u1352325@INTVMAO01 P2ChildDir2]$ cd ..
[u1352325@INTVMAO01 ParentDir2]$ cd ..
[u1352325@INTVMAO01 HomeDir]$ cd ParentDir1
[u1352325@INTVMAO01 ParentDir1]$ cd P1ChildDir2
[u1352325@INTVMAO01 P1ChildDir2]$ ls
File2
[u1352325@INTVMAO01 P1ChildDir2]$ cd ..
[u1352325@INTVMAO01 ParentDir1]$ cd ..
[u1352325@INTVMAO01 HomeDir]$ cd ..
[u1352325@INTVMAO01 ~]$ cp HomeDir/ParentDir1/P1ChildDir2/File2 HomeDir/.
[u1352325@INTVMAO01 ~]$ cd HomeDir
[u1352325@INTVMAO01 HomeDir]$ ls
File2 ParentDir1 ParentDir2
[u1352325@INTVMAO01 HomeDir]$

c) How do youcopy the File2from this directory to P2ChildDir2then


[u1352325@INTVMAO01 P2ChildDir2]$ cd ..
[u1352325@INTVMAO01 ParentDir2]$ cd ..
[u1352325@INTVMAO01 HomeDir]$ cd ParentDir1
[u1352325@INTVMAO01 ParentDir1]$ cd P1ChildDir2
[u1352325@INTVMAO01 P1ChildDir2]$ ls
File2
[u1352325@INTVMAO01 P1ChildDir2]$ cd ..
[u1352325@INTVMAO01 ParentDir1]$ cd ..
[u1352325@INTVMAO01 HomeDir]$ cd ..
[u1352325@INTVMAO01 HomeDir]$ cp ParentDir1/P1ChildDir2/File2
ParentDir2/P2ChildDir2/.
[u1352325@INTVMAO01 HomeDir]$ cd ParentDir2
[u1352325@INTVMAO01 ParentDir2]$ cd P2ChildDir2
[u1352325@INTVMAO01 P2ChildDir2]$ ls
File2

2) Write a command to List all the CPPfiles in your file system and grant below
permissions

[u1352325@INTVMAO01 ~]$ find*.cpp


a.cpp
b.cpp

a. Write and execute Permissions to the owner of the file.

[u1352325@INTVMAO01 ~]$ ls -l a.cpp


-rw-rw-r--. 1 u1352325 fac 5 Sep 28 13:53 a.cpp
[u1352325@INTVMAO01 ~]$ chmod u+x-r a.cpp

b. Only Execute permissions for the group.

[u1352325@INTVMAO01 ~]$ ls -l a.cpp


-rw-rw-r--. 1 u1352325 fac 5 Sep 28 13:55 a.cpp
[u1352325@INTVMAO01 ~]$ chmod g+x-rw a.cpp

3) Write the commands for the below scenarios wrt VI Editor,


[u1352325@INTVMAO01 ~]$ vi Editor1

a. Search a 'String/Pattern' in Forward direction and backwarddirection.

Forward direction - ?'String/Pattern'

backwarddirection - /'String/Pattern'

b. How to search and replace 'String/Pattern' in all the Occurrences with


confirmation.

:%s/Old_String_Pattern/New_String_Pattern/g

c. In Which mode the above Operations can be performed.

Ex Mode

d. How to Cut 10 lines from VI editor.

10dd

e. How to paste the copied content (wrt point No:d) ,10 times at one shot in vi
editor.
10p

g. In which mode the above Operations (d,e) can be performed

Command Mode