What does the tilde (~) symbol represent in the Linux command line?
The tilde (~) symbol is a shortcut that represents the current user's home directory. For example, cd ~ takes you to your home folder.
Click to reveal answer
beginner
How can you quickly go to the home directory from anywhere in the terminal?
You can type cd ~ or simply cd without any arguments to go directly to your home directory.
Click to reveal answer
intermediate
What is the difference between ~ and ~/ in Linux commands?
~ refers to the home directory itself, while ~/ refers to the home directory followed by a slash, which is used to specify files or folders inside the home directory. For example, ~/Documents means the Documents folder inside your home.
Click to reveal answer
intermediate
What shortcut can you use to refer to the previous directory you were in?
You can use cd - to switch back to the last directory you were in before the current one. It acts like a toggle between two folders.
Click to reveal answer
beginner
How do you use shortcuts to refer to the root directory and the current directory?
The root directory is represented by /. The current directory is represented by .. For example, cd / goes to root, and ./script.sh runs a script in the current folder.
Click to reveal answer
What does the command cd ~ do?
ADeletes the home directory
BTakes you to the root directory
CLists files in the current directory
DTakes you to your home directory
✗ Incorrect
cd ~ changes the directory to your home folder, which is what the tilde (~) represents.
Which command switches you back to the previous directory you were in?
Acd -
Bcd ..
Ccd ~
Dcd /
✗ Incorrect
cd - toggles you back to the last directory you visited.
What does ~/Documents mean?
ADocuments folder inside the home directory
BDocuments folder inside the root directory
CA hidden folder named Documents
DThe current directory
✗ Incorrect
~ is your home directory, so ~/Documents points to the Documents folder inside your home.
What does the dot (.) represent in Linux paths?
AHome directory
BRoot directory
CCurrent directory
DParent directory
✗ Incorrect
A single dot (.) means the current directory you are in.
What happens if you type cd with no arguments?
AIt shows an error
BIt goes to the home directory
CIt goes to the root directory
DIt stays in the current directory
✗ Incorrect
Typing cd alone takes you to your home directory.
Explain how the tilde (~) shortcut helps you navigate in the Linux terminal.
Think about where you usually start when opening a terminal.
You got /4 concepts.
Describe the difference between the shortcuts ~, ., and / in Linux paths.
Consider the folder hierarchy and your position in it.
You got /4 concepts.
Practice
(1/5)
1. What does the ~ symbol represent in Linux command line?
easy
A. The previous directory
B. The root directory
C. The current user's home directory
D. The system's temporary folder
Solution
Step 1: Understand the meaning of ~
The tilde symbol ~ is a shortcut that always points to the current user's home directory, like /home/username.
Step 2: Compare with other directory symbols
/ is root, - is previous directory, and /tmp is temporary folder, so they don't match ~.
Final Answer:
The current user's home directory -> Option C
Quick Check:
~ = home directory [OK]
Hint: Remember: ~ always means your home folder [OK]
Common Mistakes:
Confusing ~ with root directory /
Thinking ~ means previous directory
Assuming ~ is a system folder
2. Which of the following commands correctly lists files in the user's home directory using the shortcut?
easy
A. ls ~
B. ls ./home
C. ls /home
D. ls /root
Solution
Step 1: Identify the shortcut for home directory
~ is the shortcut for the current user's home directory, so ls ~ lists files there.
Step 2: Check other options
/home is the parent folder for all users, ./home is a relative path that may not exist, and /root is root user's home, not current user.
Final Answer:
ls ~ -> Option A
Quick Check:
ls ~ lists home files [OK]
Hint: Use ls ~ to list your home files quickly [OK]
Common Mistakes:
Using absolute path /home instead of ~
Confusing relative path ./home with home directory
Trying to list /root which is for root user only
3. What is the output of the command echo ~/Documents if the user's home directory is /home/alice?
medium
A. /home/alice/Documents
B. /Documents
C. ~/Documents
D. /root/Documents
Solution
Step 1: Understand how shell expands ~
The shell replaces ~ with the full path of the user's home directory, here /home/alice.
Step 2: Combine with the rest of the path
Appending /Documents to /home/alice gives /home/alice/Documents.
Final Answer:
/home/alice/Documents -> Option A
Quick Check:
echo ~/Documents = /home/alice/Documents [OK]
Hint: Shell expands ~ to full home path before command runs [OK]
Common Mistakes:
Thinking ~ stays as literal tilde
Confusing root's home /root with user's home
Ignoring path concatenation after ~
4. A user runs cd ~username but gets an error. What is the likely cause?
medium
A. The home directory is not mounted
B. The tilde shortcut only works for current user
C. The command syntax is incorrect
D. The username does not exist on the system
Solution
Step 1: Understand ~username usage
~username expands to the home directory of the specified user if that user exists.
Step 2: Identify error cause
If the username does not exist, the shell cannot expand ~username, causing an error.
Final Answer:
The username does not exist on the system -> Option D
Quick Check:
~username needs valid user [OK]
Hint: Check if username exists before using ~username [OK]
Common Mistakes:
Assuming ~ only works for current user
Thinking syntax is wrong when it is correct
Ignoring user existence in error
5. You want to create a script that copies a file named notes.txt from your home directory to a backup folder inside your Documents. Which command correctly uses the ~ shortcut?
hard
A. cp notes.txt ~/Documents/backup/
B. cp ~/notes.txt ~/Documents/backup/
C. cp ~/notes.txt /Documents/backup/
D. cp /notes.txt ~/Documents/backup/
Solution
Step 1: Identify source file path
The file notes.txt is in the home directory, so ~/notes.txt correctly points to it.
Step 2: Identify destination folder path
The backup folder is inside Documents in home, so ~/Documents/backup/ is the correct destination path.
Step 3: Check other options
/notes.txt is root directory file (likely wrong), /Documents/backup/ is absolute path outside home, and notes.txt without path means current directory, not home.
Final Answer:
cp ~/notes.txt ~/Documents/backup/ -> Option B
Quick Check:
Use ~ for home paths in source and destination [OK]
Hint: Use ~ before filenames to refer to your home folder [OK]
Common Mistakes:
Using absolute paths outside home by mistake
Omitting ~ and assuming current directory is home
Confusing source and destination paths
Recommended
Ready to prove it?
Pass the test and this pattern moves unknownstrongwhile earning +1 Grip toward your certificate.