Day 2 : Basic Linux Commands

Day 2 : Basic Linux Commands

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 information

  • ls -a --> List all including hidden files and directory

  • ls *.sh --> List all the files having .sh extension.

  • ls -I --> List the files and directories with index numbers in inodes

  • ls -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 path

  • cd ~ or just cd --> Change the directory to the home directory

  • cd - --> 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

  1. Check your present working directory.

-->> PWD

  1. List all the files or directories including hidden files.

-->> ls -la

  1. Create a nested directory A/B/C/D/E

-->> mkdir -p A/B/C/D