Directory: -
Part – 1: - (Creation of Directory)
Q) How to create an empty directory ?
Ans - $ mkdir <Directory_Name><Enter – Key>
<Directory_Name>
1. Directory Name should start with characters, not number
and special characters.
Example –
d1, hira, D123 (Allowed)
1d, 123a, @dir (Not Allowed)
2. There is no space in the directory name.
Q) How to create multiple directories in same level ?
Ans - $ mkdir <1st Directory Name> <2nd
Directory Name> <3rd Directory Name><Enter – Key>
Example - $ mkdir d1 d2 d3 d4
Q) How to create multiple directories in hierarchical
structure ?
Ans - $ mkdir –p <1st Directory Name>/<2nd
Directory Name>/<3rd Directory Name><Enter – Key>
Example - $ mkdir –p d1/d2/d3/d4
Q) How to create directory in home directory ?
Ans - $ mkdir ~/< Directory Name><Enter – key>
Example - $ mkdir ~/d1
Q) How to create a directory with a permission 742 ?
Ans - $ mkdir –m 742 <Directory Name><Enter –
key>
Example - $ mkdir – m 742 d1
Part – 2: - (Changing Directory)
Q) How you know which directory you currently working?
Ans - $ pwd<Enter – Key>
Where pwd – Present Working Directory
Q) Which command is used to change directory ?
Ans – cd
Q) How to change directory to root directory from any
directory ?
Ans - $ cd /<Enter – Key>
Q) How to change directory to home directory from any
directory ?
Ans - $ cd ~<Enter – Key>
Q) How to change directory from current directory to one
layer up ?
Ans - $ cd ..<Enter – Key>
Q) How to change directory from current directory to two
layers up ?
Ans - $ cd ../..<Enter – Key>
Q) How to change directory from current directory to three
layers up ?
Ans - $ cd ../../..<Enter – Key>
Q) How to change directory from current directory to which
directory you come from ?
Ans - $ cd -<Enter – Key>
It behaves as reversible.
Part – 3: - (Removing Directory)
Q) How to remove an empty directory ?
Ans - $ rmdir <Directory_Name><Enter – Key>
Example - $ rmdir d1
Q) How to remove an non – empty directory ?
Ans - $ rm –r <Directory_Name><Enter – Key>
Where r – recrusively process
In this process, you can roll back your deleted directory by
Unix Admin Team.
Q) How to remove an non – empty directory forcefully ?
Ans - $ rm –rf <Directory_Name><Enter – Key>
Where r – recrusively process, f - forcefully
In this process, you cannot roll back your deleted
directory.
No comments:
Post a Comment