File System of Unix

Directory Creation – 1

Question:

Create the directory structure given in the image using mkdir for directory creation and touch for creating files.

Note:assume that you are inside your home directory and always specify only relative path.

Quiz for Exam - File System of Unix

Code:

directory.sh

mkdir mydir
cd mydir
mkdir colors
mkdir shape
mkdir animals
cd shape
touch circle
touch square
touch cube
cd ..
cd colors
mkdir basic
mkdir blended
cd basic
touch red 
touch blue 
touch green
cd ..
cd blended
touch yellow
touch orange
touch pink
cd ..
cd ..
cd animals
mkdir mammals
mkdir reptiles
cd mammals
touch platypus
touch bat 
touch dog
cd ..
cd reptiles
touch snakes
touch crocodile
touch lizard
cd 

Directory Creation – 2

Question:

Create the directory structure given in the image using mkdir command for directory creation and touch command for creating files.

Note: assume that you are inside your home directory and always specify only relative path.

Quiz for Exam - Directory Creation - 2

Code:

directory.sh

mkdir livingthings
cd livingthings
mkdir birds
mkdir plants 
mkdir animals
cd birds
mkdir flyingbirds
mkdir nonflyingbirds
cd flyingbirds
touch stork
touch eagle
touch eider
cd ..
cd nonflyingbirds
touch kiwi
touch ostrich
touch penguin
cd ..
cd ..
cd plants
touch carrot
touch cabbage
touch daisy
cd ..
cd animals
mkdir mammals
mkdir reptiles
cd mammals
touch jaguar
touch dog
touch tiger
cd ..
cd reptiles
touch alligator
touch skink
touch turtle
cd

Copy File 1

Question:

Copy the file red to BLENDED directory.

Note: assume that you are inside your home directory and always specify only relative path

Quiz for Exam - Copy File 1

Code:

copy.sh

cp mydir/colors/basic/red mydir/colors/blended

Copy File 3

Question:

Copy the file green to directory REPTILES

Note: assume that you are inside your home directory and always specify only relative path

Quiz for Exam - Copy File 3

Code:

copy3.sh

cp mydir/colors/basic/green mydir/animals/reptiles/

Copy File 4

Question:

Go to Non-Flying Birds directory and copy the file Penguin to Flying Birds directory using relative path.

Note: assume that you are inside your home directory and always specify only relative path.

Quiz for Exam - Copy File 4

Code:

copy4.sh

cp livingthings/birds/nonflyingbirds/penguin livingthings/birds/flyingbirds/

Copy File 5

Question:

Copy the file Eider to directory Mammals.

Note: assume that you are inside your home directory and always specify only relative path.

Quiz for Exam - Copy File 5

Code:

copy5.sh

cp livingthings/birds/flyingbirds/eider livingthings/animals/mammals

Copy File – 6

Question:

Copy the file Eagle to Non-Flying Birds directory.

Note: assume that you are inside your home directory and always specify only relative path.

Quiz for Exam - Copy File - 6

Code:

Main.sh

cp livingthings/birds/flyingbirds/eagle livingthings/birds/nonflyingbirds

Copy Directory

Question:

Copy the whole directory Birds to Plants.

Note: assume that you are inside your home directory and always specify only relative path.

Quiz for Exam - Copy Directory

Code:

copydir.sh

cp -rf livingthings/birds livingthings/plants

Copy Complete Directory

Question:

Copy all the sub-directories and the files under COLORS directory to SHAPE.

Note: assume that you are inside your home directory and always specify only relative path

Quiz for Exam - Copy Complete Directory

Code:

copydirectory.sh

cp -ir mydir/colors/basic mydir/colors/blended mydir/shape

Move File 1

Question:

Move the file dog from MAMMALS to SHAPE.

Note: assume that you are inside your home directory and always specify only relative path.

Quiz for Exam - Move File 1

Code:

movefile1.sh

mv mydir/animals/mammals/dog mydir/shape

Move File 2

Question:

Move the file snakes  to SHAPE

Note: assume that you are inside your home directory and always specify only relative path.

Quiz for Exam - Move File 1

Code:

move2.sh

mv mydir/animals/reptiles/snakes mydir/shape

Move File 3

Question:

Go to shape directory and move the file circle to mammals directory

Note:assume that you are inside your home directory and always specify only relative path.

Quiz for Exam - Move File 3

Code:

movequestion2.sh

mv mydir/shape/circle mydir/animals/mammals

Move File 4

Question:

Move the file Turtle from Reptiles to Plants.

Note: assume that you are inside your home directory and always specify only relative path.

Quiz for Exam - Move File 4

Code:

movefile1.sh

mv livingthings/animals/reptiles/turtle livingthings/plants

Move File – 5

Question:

Go to plants directory and move the file carrot to mammals directory.

Note: assume that you are inside your home directory and always specify only relative path.

Quiz for Exam - Move File - 5

Code:

mvfile.sh

mv livingthings/plants/carrot livingthings/animals/mammals

Remove File – 1

Question:

Remove the orange  file from BLENDED directory.

Note: assume that you are inside your home directory and always specify only relative path.

Quiz for Exam - Remove File - 1

Code:

remove.sh

rm mydir/colors/blended/orange

Remove Directory

Question:

Remove all the directories under Animals.

Note: assume that you are inside your home directory and always specify only relative path.

Quiz for Exam - Remove Directory

Code:

rmdir3.sh

rm -r livingthings/animals/mammals livingthings/animals/reptiles

File Permission 2

Question:

Existing permission for file dept.txt is rw- — — . Retain the same permissions for user and other category. Add write permission to group using octal notation or symbolic notation.

Code:

filepermission2.sh

chmod 620 dept.txt

File Permission 4

Question:

Existing permission for file emp.txt is rw- — —. Assign excutable permission to others and add  exceution permission for group and user using symbolic notation.

Code:

filepermission4.sh

chmod ug+x emp.txt
chmod o=x emp.txt

File Permission – 5

Question:

Existing permission for file student.txt is rw- — — .change this permission to rw- rw- rw- using octal notation or symbolic notation.

Code:

fileper1.sh

chmod go+rw student.txt

File permission – 6

Question:

Existing permission for file student.txt is rw- rw- rw-. Remove write permission from group using octal or symbolic notation.

Code:

filper2.sh

chmod g-w+r student.txt
chmod o+rw student.txt

Recommended:

  1. All programs of Introduction to Unix
  2. All programs of File System
  3. All Programs of Filters
  4. All Programs of Bourne Shell

Leave a Comment

Your email address will not be published. Required fields are marked *

x