Bird
Raised Fist0
Linux CLIscripting~10 mins

First Linux commands in Linux CLI - Step-by-Step Execution

Choose your learning style10 modes available
Concept Flow - First Linux commands
Open Terminal
↓
Type Command
↓
Press Enter
↓
Shell Executes Command
↓
Output Displayed
↓
Ready for Next Command
This flow shows how you open a terminal, type a Linux command, press Enter, and see the output.
Execution Sample
Linux CLI
pwd
ls
cd /tmp
pwd
This sequence shows checking current directory, listing files, changing directory, and checking again.
Execution Table
StepCommand TypedShell ActionOutputCurrent Directory
1pwdPrint current directory/home/user/home/user
2lsList files in current directoryDocuments Downloads Music/home/user
3cd /tmpChange directory to /tmp/tmp
4pwdPrint current directory/tmp/tmp
5No more commands/tmp
💡 No more commands to execute, session waits for next input.
Variable Tracker
VariableStartAfter 1After 2After 3After 4Final
Current Directory/home/user/home/user/home/user/tmp/tmp/tmp
Key Moments - 2 Insights
Why does the output of 'pwd' change after 'cd /tmp'?
Because 'cd /tmp' changes the current directory to /tmp, so the next 'pwd' shows the new location (see execution_table rows 3 and 4).
Why does 'ls' show files only from the current directory?
'ls' lists files in the directory you are currently in, which is /home/user before 'cd /tmp' (see execution_table row 2).
Visual Quiz - 3 Questions
Test your understanding
Look at the execution table, what is the current directory after step 3?
A/tmp
B/home/user
C/root
D/var
💡 Hint
Check the 'Current Directory' column at step 3 in the execution_table.
At which step does the output of 'pwd' show '/home/user'?
AStep 1
BStep 4
CStep 3
DStep 2
💡 Hint
Look at the 'Output' column for 'pwd' commands in the execution_table.
If we run 'cd /var' instead of 'cd /tmp' at step 3, what would be the output of 'pwd' at step 4?
A/tmp
B/var
C/home/user
D/root
💡 Hint
Changing directory changes the output of 'pwd' to the new directory (see key_moments explanation).
Concept Snapshot
First Linux commands:
- Open terminal
- Type commands like pwd, ls, cd
- Press Enter to run
- pwd shows current folder
- ls lists files there
- cd changes folder
- Output shows results immediately
Full Transcript
This lesson shows how to use basic Linux commands in a terminal. First, you open the terminal and type a command like pwd to see your current folder. Then, you can list files with ls. To move to another folder, use cd followed by the folder path. After changing folders, pwd shows the new location. Each command runs when you press Enter, and the shell shows the output. This helps you navigate and see files on your computer using simple commands.

Practice

(1/5)
1. Which Linux command shows the current directory you are in?
easy
A. pwd
B. ls
C. cd
D. mkdir

Solution

  1. Step 1: Understand the purpose of pwd

    The pwd command stands for "print working directory" and shows the current folder path.
  2. Step 2: Compare with other commands

    ls lists files, cd changes directory, and mkdir creates a folder, so they don't show the current directory.
  3. Final Answer:

    pwd -> Option A
  4. Quick Check:

    Current directory command = pwd [OK]
Hint: Remember: pwd = print working directory [OK]
Common Mistakes:
  • Confusing ls with pwd
  • Using cd to show directory
  • Thinking mkdir shows current folder
2. Which of the following is the correct syntax to create a new directory named projects?
easy
A. mkdir projects
B. mk projects
C. create projects
D. newdir projects

Solution

  1. Step 1: Identify the command to create directories

    The standard Linux command to make a directory is mkdir.
  2. Step 2: Check the syntax

    The correct syntax is mkdir directory_name, so mkdir projects is correct.
  3. Final Answer:

    mkdir projects -> Option A
  4. Quick Check:

    Create directory command = mkdir [OK]
Hint: mkdir means make directory; use it to create folders [OK]
Common Mistakes:
  • Using mk instead of mkdir
  • Typing create instead of mkdir
  • Using newdir which is not a command
3. What will be the output of the following commands?
mkdir testdir
cd testdir
pwd
medium
A. /testdir
B. /home/testdir
C. /home/username/testdir
D. testdir

Solution

  1. Step 1: Understand the commands

    mkdir testdir creates a folder named testdir. cd testdir moves into that folder. pwd prints the full path of the current directory.
  2. Step 2: Determine the full path

    Assuming the user starts in their home directory (like /home/username), after changing into testdir, pwd will show /home/username/testdir.
  3. Final Answer:

    /home/username/testdir -> Option C
  4. Quick Check:

    pwd after cd into testdir = full path /home/username/testdir [OK]
Hint: pwd shows full path, not just folder name [OK]
Common Mistakes:
  • Expecting just folder name output
  • Assuming root directory path
  • Confusing relative and absolute paths
4. You run the command cd myfolder but get an error: bash: cd: myfolder: No such file or directory. What is the most likely cause?
medium
A. You do not have permission to use cd
B. The folder myfolder does not exist in the current directory
C. The cd command is misspelled
D. You need to use mkdir before cd

Solution

  1. Step 1: Analyze the error message

    The error says "No such file or directory", meaning the folder named myfolder is not found in the current location.
  2. Step 2: Check other options

    cd is a basic command and usually not misspelled here. Permissions errors give different messages. mkdir creates folders but is not required before cd if the folder exists.
  3. Final Answer:

    The folder myfolder does not exist in the current directory -> Option B
  4. Quick Check:

    cd error means folder missing [OK]
Hint: Check folder exists before cd [OK]
Common Mistakes:
  • Assuming permission error
  • Thinking cd needs mkdir first
  • Misspelling cd command
5. You want to create a new folder named backup inside your current directory and then move into it. Which sequence of commands will do this correctly?
hard
A. mkdir cd backup
B. cd backup mkdir backup
C. cd backup cd backup
D. mkdir backup cd backup

Solution

  1. Step 1: Create the folder first

    The command mkdir backup creates the folder named backup in the current directory.
  2. Step 2: Change directory into the new folder

    After creating it, cd backup moves you inside that folder.
  3. Step 3: Check other options

    cd backup mkdir backup tries to cd into backup before it exists, causing an error. mkdir cd backup misses the folder name in mkdir. cd backup cd backup tries to cd twice without creating the folder.
  4. Final Answer:

    mkdir backup cd backup -> Option D
  5. Quick Check:

    Create then cd = mkdir then cd [OK]
Hint: Always mkdir before cd into new folder [OK]
Common Mistakes:
  • Trying cd before mkdir
  • Omitting folder name in mkdir
  • Repeating cd without folder
Recommended

Ready to prove it?

Pass the test and this pattern moves unknown strong while earning +1 Grip toward your certificate.

10 questions~5 mineasy hard