Basic Commands

  • October 2019
  • PDF

This document was uploaded by user and they confirmed that they have the permission to share it. If you are author or own the copyright of this book, please report to us by using this DMCA report form. Report DMCA


Overview

Download & View Basic Commands as PDF for free.

More details

  • Words: 601
  • Pages: 13
1

1

Basic Commands

Print PrintWorking WorkingDirectory Directory [root@comp1 ~]# pwd [root@comp1 ~]# pwd

Shows Showslist listof offiles files& &directories directories [root@comp1 ~]# ls <arguments> [root@comp1 ~]# ls <arguments>

2

2

ls Command

Listing Listingof of files filesand anddirectories directories along alongwith with the theattributes attributes [root@comp1 ~]# ls l or [root@comp1 ~]# ls l or [root@comp1 [root@comp1~]# ~]#llll

Listing Listingof ofall allfiles filesand anddirectories directories including includingthe thehidden hidden root@comp1 ~]# ls -a root@comp1 ~]# ls -a

Listing Listingof ofall allfiles filesand anddirectories directoriesin inreverse reverseorder order [root@comp1 [root@comp1~]# ~]#ls ls -r -r 3

3

ls Command

Listing Listingof offiles filesand anddirectories directoriesalong alongwith with the the inode inode numbers numbers [root@comp1 ~]# ls il [root@comp1 ~]# ls il

Listing Listingof ofthe theattributes attributesof ofaaparticular particularfile fileor or directory directory [root@comp1 ~]# ls -ld [root@comp1 ~]# ls -ld

Shows Showsthe thelist listof offiles filesin inTree Treestructure structure [root@comp1 [root@comp1~]# ~]#ls ls -R -R 4

4

Creation of Files

By using three methods we can create files cat command touch command vi editor Displaying Displaying& &Creating CreatingText TextFiles Files [root@comp1 ~]# cat <arguments> [root@comp1 ~]# cat <arguments>

5

5

cat command

To Tocreate createaafile file [root@comp1 ~]# cat > [root@comp1 ~]# cat >

To Toview viewthe thecontent contentof ofaafile file [root@comp1 [root@comp1~]# ~]#cat cat

To Toappend appendaafile file [root@comp1 ~]# cat >> [root@comp1 ~]# cat >>

To Totransfer transferthe thecontents contentsof offile1 file1& &file2 file2to tofile3 file3 [root@comp1 ~]# cat >> [root@comp1 ~]# cat >> 6

6

touch command

To Tocreate createaafile filewith withzero zerobytes bytesas aswell wellas asto tochange changethe thetime time stamp of file or directory. stamp of file or directory. [root@comp1 [root@comp1~]# ~]#touch touch

To Tocreate createmultiple multiplefiles files [root@comp1 [root@comp1~]# ~]#touch touch

7

7

Creating Directories

To Tocreate createaadirectory directory [root@comp1 ~]# mkdir name>

To Tocreate createmultiple multipledirectories directories [root@comp1 ~]# mkdir [root@comp1 ~]# mkdir

To Tocreate createnested nesteddirectories directories [root@comp1 [root@comp1~]# ~]#mkdir mkdir -p -p // // 8

8

Navigation of Directories

To Tochange changethe thedirectory directory [root@comp1 ~]# cd <path of the directory> [root@comp1 ~]# cd <path of the directory>

To Tochange changedirectory directoryone one level levelback back [root@comp1 ~]# cd .. [root@comp1 ~]# cd ..

To Tochange changedirectory directory two twolevels levelsback back [root@comp1 [root@comp1~]# ~]#cd cd../.. ../.. 9

9

Navigation of Directories

To Tochange changedirectory directory to tolast lastworking workingdirectory directory [root@comp1 ~]# cd [root@comp1 ~]# cd

To Tochange changedirectory directory to tohome home directory directory [root@comp1 [root@comp1~]# ~]#cd cd or or [root@comp1 [root@comp1~]# ~]#cd cd ~ ~

10

10

Removing a File or Directory

To Toremove removeaa file file [root@comp1 ~]# rm [root@comp1 ~]# rm

To Toremove removeempty empty directory directory [root@comp1 ~]# rmdir name>

To Toremove remove directory directoryrecursively recursively and andforcefully forcefully [root@comp1 [root@comp1~]# ~]#rm rm rf rf name> 11

11

Copying a File or Directory

To Tocopy copyaafile file [root@comp1 [root@comp1~]# ~]#cp cp <source <sourcefile filepath> path><destination <destinationfile filepath> path>

[root@comp1 [root@comp1~]# ~]#cp cp

To Tocopy copyaadirectory directory rr <source <sourcedir dirpath> path> <destination <destinationdir dirpath> path>

12

12

Moving / Renaming a File or Directory

To Tomove moveaa file/dir file/dirto toaadifferent different location location [root@comp1 ~]# mv <source path> [root@comp1 ~]# mv <source path> <destination <destinationpath> path>

To To rename rename file/dir file/dirmove moveat atsame samelocation location [root@comp1 [root@comp1~]# ~]#mv mv name> name>

13

13

Related Documents

Basic Commands
October 2019 8
Basic Commands
November 2019 9
Linux Basic Commands
June 2020 16
Basic Unix Commands
August 2019 21
Basic Unix Commands
May 2020 3