You are on page 1of 13

1

1
2
2
Basic Commands
Print Working Directory
[root@comp1 ~]# pwd
Print Working Directory
[root@comp1 ~]# pwd
Shows list of files & directories
[root@comp1 ~]# ls <options> <arguments>
Shows list of files & directories
[root@comp1 ~]# ls <options> <arguments>
3
3
ls Command
Listing of files and directories along with the attributes
[root@comp1 ~]# ls l or
[root@comp1 ~]# ll
Listing of files and directories along with the attributes
[root@comp1 ~]# ls l or
[root@comp1 ~]# ll
Listing of all files and directories including the hidden
root@comp1 ~]# ls -a
Listing of all files and directories including the hidden
root@comp1 ~]# ls -a
Listing of all files and directories in reverse order
[root@comp1 ~]# ls -r
Listing of all files and directories in reverse order
[root@comp1 ~]# ls -r
4
4
ls Command
Listing of files and directories along with the i node numbers
[root@comp1 ~]# ls il
Listing of files and directories along with the inode numbers
[root@comp1 ~]# ls il
Listing of the attributes of a particular file or directory
[root@comp1 ~]# ls -ld <directory>
Listing of the attributes of a particular file or directory
[root@comp1 ~]# ls -ld <directory>
Shows the list of files in Tree structure
[root@comp1 ~]# ls -R <directory>
Shows the list of files in Tree structure
[root@comp1 ~]# ls -R <directory>
5
5
By using three methods we can create files
cat command
touch command
vi editor
Creation of Files
Displaying & Creating Text Files
[root@comp1 ~]# cat <options> <arguments>
Displaying & Creating Text Files
[root@comp1 ~]# cat <options> <arguments>
6
6
cat command
To create a file
[root@comp1 ~]# cat > <filename>
To create a file
[root@comp1 ~]# cat > <filename>
To view the content of a file
[root@comp1 ~]# cat <filename>
To view the content of a file
[root@comp1 ~]# cat <filename>
To append a file
[root@comp1 ~]# cat >> <filename>
To append a file
[root@comp1 ~]# cat >> <filename>
To transfer the contents of file1 & file2 to file3
[root@comp1 ~]# cat <file1> <file2> >> <file3>
To transfer the contents of file1 & file2 to file3
[root@comp1 ~]# cat <file1> <file2> >> <file3>
7
7
touch command
To create a file with zero bytes as well as to change the time
stamp of file or directory.
[root@comp1 ~]# touch <filename>
To create a file with zero bytes as well as to change the time
stamp of file or directory.
[root@comp1 ~]# touch <filename>
To create multiple files
[root@comp1 ~]# touch <file1> <file2> <file3>
To create multiple files
[root@comp1 ~]# touch <file1> <file2> <file3>
8
8
Creating Directories
To create a directory
[root@comp1 ~]# mkdir <directory name>
To create a directory
[root@comp1 ~]# mkdir <directory name>
To create multiple directories
[root@comp1 ~]# mkdir <dir1> <dir2> <dir3>
To create multiple directories
[root@comp1 ~]# mkdir <dir1> <dir2> <dir3>
To create nested directories
[root@comp1 ~]# mkdir -p <dir1>/<dir2>/<dir3>
To create nested directories
[root@comp1 ~]# mkdir -p <dir1>/<dir2>/<dir3>
9
9
Navigation of Directories
To change the directory
[root@comp1 ~]# cd <path of the directory>
To change the directory
[root@comp1 ~]# cd <path of the directory>
To change directory one level back
[root@comp1 ~]# cd ..
To change directory one level back
[root@comp1 ~]# cd ..
To change directory two levels back
[root@comp1 ~]# cd ../..
To change directory two levels back
[root@comp1 ~]# cd ../..
10
10
Navigation of Directories
To change directory to last working directory
[root@comp1 ~]# cd
To change directory to last working directory
[root@comp1 ~]# cd
To change directory to home directory
[root@comp1 ~]# cd or
[root@comp1 ~]# cd ~
To change directory to home directory
[root@comp1 ~]# cd or
[root@comp1 ~]# cd ~
11
11
Removing a File or Directory
To remove a file
[root@comp1 ~]# rm <filename>
To remove a file
[root@comp1 ~]# rm <filename>
To remove empty directory
[root@comp1 ~]# rmdir <directory name>
To remove empty directory
[root@comp1 ~]# rmdir <directory name>
To remove directory recursively and forcefully
[root@comp1 ~]# rm rf <directory name>
To remove directory recursively and forcefully
[root@comp1 ~]# rm rf <directory name>
12
12
Copying a File or Directory
To copy a file
[root@comp1 ~]# cp <source file path> <destination file path>
To copy a file
[root@comp1 ~]# cp <source file path> <destination file path>
To copy a directory
[root@comp1 ~]# cp r <source dir path> <destination dir path>
To copy a directory
[root@comp1 ~]# cp r <source dir path> <destination dir path>
13
13
Moving / Renaming a File or Directory
To rename file/dir move at same location
[root@comp1 ~]# mv <old name> <new name>
To rename file/dir move at same location
[root@comp1 ~]# mv <old name> <new name>
To move a file/dir to a different location
[root@comp1 ~]# mv <source path> <destination path>
To move a file/dir to a different location
[root@comp1 ~]# mv <source path> <destination path>

You might also like