Basics Linux command
Listing commands
ls option_flag arguments
--> list the subdirectories and files available in the present directory
Examples:
ls -l
--> list the files and directories in long list format with extra informationls -a
--> list all including hidden files and directoryls *.sh
--> list all the files having .sh extension.ls -i
--> list the files and directories with index numbers inodesls -d */
--> list only directories.(we can also specify a pattern)
Directory commands
pwd
--> print work directory. Gives the present working directory.cd path_to_directory
--> change directory to the provided pathcd ~
or justcd
--> change directory to the home directorycd -
--> Go to the last working directory.cd ..
--> change directory to one step back.cd ../..
--> Change directory to 2 levels back.mkdir directoryName
--> to make a directory in a specific location
Examples:
mkdir newFolder # make a new folder 'newFolder'
mkdir .NewFolder # make a hidden directory (also . before a file to make it hidden)
mkdir A B C D #make multiple directories at the same time
mkdir /home/user/Mydirectory # make a new folder in a specific location
mkdir -p A/B/C/D # make a nested directory
Check your present working directory.
pwd
--> Print work directory.
abhi@ubandupc:~$ pwd
/home/abhi
List all the files or directories including hidden files.
abhi@ubandupc:~/Desktop$ ls -la
total 17372
drwxr-xr-x 12 abhi abhi 4096 Mar 20 13:59 .
drwxr-xr-x 27 abhi abhi 4096 Mar 17 17:17 ..
drwxrwxr-x 2 abhi abhi 4096 Jul 20 2022 Ansible
-rw-rw-r-- 1 abhi abhi 17209836 Feb 15 13:41 'Ansible Hand Written Notes.pdf'
drwxrwxr-x 2 abhi abhi 4096 Feb 15 13:45 AWS
drwxrwxr-x 2 abhi abhi 4096 Dec 5 10:29 'Azure Full Course'
Create a nested directory A/B/C/D/E
abhi@ubandupc:~/Desktop/day2$ mkdir -p A/B/C/D/E
abhi@ubandupc:~/Desktop/day2$ tree
.
└── A
└── B
└── C
└── D
└── E