Day 2 - Linux

Day 2 - Linux

Basic Linux Commands

ยท

2 min read

  • Listing commands

    ls option_flag arguments --> List the subdirectories and files available in the present directory

    • 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 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 directory to the provided path

    • cd ~ or just cd --> Change 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 --> Use 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

ย