Basic Commands

 


root@haktuts:~$ pwd
[pwd will show the Present working directory]
 

 

root@haktuts:~$ ls
[ls will show the list of file and directory of present working directory.]

 

 

root@haktuts:~$ ls b*
[ls b* will show the list of file and directory starting with b and end with anything.]

 

 

root@haktuts:~$ ls -l  


[Listing of all files and directory along with attributes(i.e. more detailed format like file permission,file size etc.]

 

 

root@haktuts:~$ ls -a
[Listing of all files and directory along with hidden file or file starting with periods (i.e. file stating with *  like *bashrc]

 

 

root@haktuts:~$ ls -R
[show the listing of file and directory in tree structure.]

 

 

root@haktuts:~$ cat Haktuts.txt
[user can use the command cat to see the preview of Haktuts.txt file.]

 

 

root@haktuts:~$ cat > Hak.txt
[use to create file]

 

 

root@haktuts:~$ cat Haktuts.txt Hak.txt >>new.txt
[transfer the content of Haktuts.txt and Hak.txt to new.txt file.]

 

 

root@haktuts:~$ cd
[To change the directory.]

 

 

root@haktuts:~$ cd com
[go to directory name com .]

 

 

root@haktuts:~$ cd ..
[change the directory one level back.]

 

 

root@haktuts:~$ cd ../..
[change the directory two level back.]

 

 

root@haktuts:~$ cd ~
[change the directory to home directory.]
 

 

root@haktuts:~$ Vi <filename>
[It will create a Blank file.]
 

 

root@haktuts:~$ Vi <file1> <file2> <file3>
[It will create multiple file at once.]
 

 

root@haktuts:~$ Vi file1.txt 
[to open file1.txt using Vi]
[i- to insert text in file1.txt]
[press Shift+: and then type wq  to save and quit.
            : q  to exit without any changes in file
            : x  to save changes and exit.]
 

 

root@haktuts:~$ mkdir com 
[It will create a directory name com]
 

 

root@haktuts:~$ mkdir com lap mob
[To create multiple directories]

 

 

root@haktuts:~$ mkdir -p com/lap/mob

[To create a  directory with their subdirectory]

 

 

root@haktuts:~$ cd -
[go to last working directory.]

[eg:currently user in /home/Haktuts/Desktop directory and user last working directory is /root/Desktop . so as and when user type cd - user directly go to /root/Desktop directory.]

 

 

root@haktuts:~$ rm Haktuts.txt

[rm remove the file Haktuts.txt.]

 

 

root@haktuts:~$ rmdir com
[rmdir remove the directory name called com only if the com directory is empty.]

 

 

root@haktuts:~$ rm -rf com
[rm -rf  remove the directory and also the content or data available in directory.]

 

 

root@haktuts:~$ cp Hak.txt /root/Desktop
[copy the file Hak.txt to /root/Desktop Directory.]

 

 

root@haktuts:~$ cp -r com /root/Desktop
[copy the directory com to /root/Desktop directory.]

 

 

root@haktuts:~$ mv Haktuts.txt /home
[move the file Haktuts.txt to /home directory]

 

 

root@haktuts:~$ mv Hak.txt Hak2.txt
[rename the file Hak.txt to Hak2.txt]