Basic Linux commands
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 in 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 the directory to the provided pathcd ~
or justcd
--> Change the directory to the home directorycd -
--> Go to the last working directory.cd ..
--> Change the directory to one step back.cd ../..
--> Change directory to 2 levels back.mkdir directoryName
--> to make a directory in a specific location.
Examples:
• mkdir -p A/B/C/D
-->> make a nested directory• mkdir .NewFolder
-->> make a hidden directory (also . before a file to make it hidden)• mkdir /home/user/Mydirectory
-->> make a new folder in a specific location• mkdir A B C D
-->> make multiple directories at the same time• mkdir newFolder
-->> make a new folder 'newFolder'
Task: What is the Linux commands to
- Check your present working directory.
-->> PWD
- List all the files or directories including hidden files.
-->> ls -la
- Create a nested directory A/B/C/D/E
-->> mkdir -p A/B/C/D