-
Creating file and Directory
Creating file and Directory:
- Creating file:
The ‘cat’ command is used to create a file
Syntax:
# cat > filename
example:
# cat > abc.txt
(Ctrl +D) is used to save the file.
- View the content of file
Syntax:
# cat filename
Example:
#cat abc.txt
#cat –b abc.txt
- Creating Directory
The ‘mkdir’ command is used to create directory
Syntax:
Mkdir [directory_name]
Example:
# mkdir rohan
Option used:
cd : To change directory
cd .. : To come out from directory
cd : to jump to root directory
cd - : to jump to previous directory
Deleting Files and directory:
Syntax:
For file:
rm
example:
rm abc.txt
for directory
syntax:
rmdir
Note: Only empty directory will be deleted)
If we want to delete the tree structure of directory then we need to use the following command
Syntax:
rm –rf
where
r = recursively
f= force
in order to remove non empty directory
Syntax:
rm –r
example;
rm –r rohan
this will remove directory step by step ,first remove sub directory and then finally main directory.
Another method of creating file :
Touch : this command is used to create a blank file with size zero.
# touch
Example:
#touch abc
- Creating file:
0 comments: