Skip to content

Instantly share code, notes, and snippets.

@sahilrajput03
Last active May 1, 2026 18:48
Show Gist options
  • Select an option

  • Save sahilrajput03/da8aaa85bafb19f6e7297bf6bd3f6b0d to your computer and use it in GitHub Desktop.

Select an option

Save sahilrajput03/da8aaa85bafb19f6e7297bf6bd3f6b0d to your computer and use it in GitHub Desktop.
Terminal Mastery

Terminal Mastery Course

FAQ's

  • 👉🏻What to do if my terminal is not reponding (blocked/jammed/frozen) etc?
    • Press q
    • Presss ctrl+c
    • Presss ctrl+c multiple times.
    • Kill the terminal by:
      • 🗑️ bin icon on top of terminal (for VS Code)
      • ❌ cross button on top-right or top-left corner (for native operating system terminal)

ls

ls stands for list.

# List all files in current directory (it is also called as working directory sometimes).
ls

# Print hidden files as well
ls -a

# Print in long list format
ls -l

# Print in long list format + show hidden files
ls -al

pwd

pwd stands for Print working directory. It tell in which folder you are currently in your terminal:

pwd

cd

⚠️PLEASE RUN pwd AFTER EACH cd COMMAND BELOW TO SEE THAT YOUR CURRENT WORKING DIRECTORY HAS ACTUALLY CHANGED.

# `cd` stands for `change directory` and it used use to goto specified directory
cd ~/Documents

# If you pass no arguments to cd command it will go to ~ (i.e., your home directory)
cd

# Go to parent foler
cd ..

touch

This command is used to create empty files.

⚠️PLEASE RUN ls AFTER EACH touch COMMAND BELOW TO SEE THAT THE SPECIFIED FILE IS ACTUALLY CREATED.

touch myfile1
touch myfile2 myfile3

mkdir

cd ~/Documents

# Creates a test directory (folder) in current directory (folder)
# mkdir test

# Note: If we create test directory again using same command we get error:
mkdir test
# Output: mkdir: test: File exists
# Output: mkdir: cannot create directory 'test': File exists

# To avoid above error we can use -p option (flag) so that error is supressed.
mkdir -p test

# Also, -p option is useful to create multiple directories of the provided path as well.
# Below statement will create folder1 and create fodler2 inside that; and folder3 inside that.
mkdir -p folder1/folder2/folder3

Exercise

cd ~/Documents/

# ⚠️⚠️ NOTE: BEFORE EXECUTING COMMAND `mkdir test` (below command) PLEASE CHECK WITH `ls` COMMAND IF
#           test DIRECTORY ALREADY EXISTS OR NOT. IF test DIRECTORY ALREADY EXISTS THEN DO NOT RUN
#           BELOW COMMAND BECAUSE IT WILL THROW ERROR SAYING `file already exists`.
mkdir test

cd test

mkdir "$(date +%Y-%m-%d)" # Simply copy/paste this command, no need to remeber any syntax here.
ls
# Output: We must see a new folder with today's date.



# Tip 1: Use TAB key to auto complete folder path after typing some letters for e.g, cd 2026-<TAB> to auto complete the folder path.
# Tip 2: Replace XX-XX with the today's month and date respectively to match the folder you created using mkdir command.
cd 2026-XX-XX
ls
# Output: <See that the folder is empty>



touch file1
ls
# Output: <See that file1 is created>


rm file1
ls
# Output: <See that file1 is deleted and the folder is empty again>



touch file3 file4
ls
# Output: <See that file3 and file4 are created>



# Go to parent foler
cd ..



# Go to previous folder again
cd -
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment