[Linux Beginner] How to Use the Terminal - Don't Fear the Black Screen!
"A black screen with white text all over it, and I have no idea what's going on..." Are you avoiding the terminal like this? In this article, through a dialogue between Linny-senpai and Lina, let's learn the basics of terminal operations together.
Table of Contents
1. Introduction: What is a Terminal?
What is a Terminal?
A terminal is an application for sending commands to your computer using text. Instead of clicking with a mouse, you operate by typing commands (instructions) on your keyboard.
Benefits of Using Terminal
- Fast: Faster than mouse operations once you're used to it
- Automatable: Can repeat the same tasks automatically
- Precise: Can specify detailed settings exactly
- Essential for servers: Many servers don't have a GUI
2. Understanding the Prompt
user@computer:~$ displayed on the screen. What is that?
Prompt Structure
yamada@penguin-gym:~/Documents$
| Part | Meaning |
|---|---|
yamada |
Username (who's currently logged in) |
@ |
Separator |
penguin-gym |
Computer name (hostname) |
: |
Separator |
~/Documents |
Current location (directory) |
$ |
Regular user indicator (# for root) |
~ mean?
~ represents your home directory. The home directory is like your "personal room" for each user, which means /home/username.
Special Symbols to Remember
| Symbol | Meaning |
|---|---|
~ |
Home directory |
. |
Current directory |
.. |
Parent directory (one level up) |
/ |
Root directory (top level) |
3. Your First 3 Commands
pwd, ls, and cd. With these three, you can find out "where you are," "what's here," and "where to go."
pwd - Check Where You Are
pwd stands for "Print Working Directory" and displays the directory you're currently in.
$ pwd
/home/yamada
/home/yamada right now!
pwd and you'll immediately know where you are.
ls - List Files
ls stands for "list" and displays the files and folders in your current location.
$ ls
Documents Downloads Pictures file.txt
Documents, Downloads, and Pictures are folders (directories), and file.txt is a file. Add the -l option to see more details.
$ ls -l
drwxr-xr-x 2 yamada yamada 4096 Jan 24 10:00 Documents
drwxr-xr-x 2 yamada yamada 4096 Jan 24 10:00 Downloads
drwxr-xr-x 2 yamada yamada 4096 Jan 24 10:00 Pictures
-rw-r--r-- 1 yamada yamada 52 Jan 24 10:00 file.txt
cd - Change Directory
cd stands for "change directory" and moves you to a different directory.
$ cd Documents
$ pwd
/home/yamada/Documents
cd Documents got me into the Documents folder!
cd ... To return to your home directory, use cd ~ or just cd.
$ cd .. # Go up one level
$ cd ~ # Return to home
$ cd # Return to home (short form)
4. Useful Shortcuts
Tab Completion (Super Important)
$ cd Doc[Tab]
# Completes to: cd Documents/
Commonly Used Shortcuts
| Shortcut | Function |
|---|---|
| Tab | Auto-completion |
| Up Arrow / Down Arrow | Browse command history |
| Ctrl + C | Cancel running command |
| Ctrl + A | Move to beginning of line |
| Ctrl + E | Move to end of line |
| Ctrl + U | Delete from cursor to beginning of line |
| Ctrl + L | Clear screen (same as clear) |
5. Common Errors and Solutions
cd Documents and got "No such file or directory"...
Error 1: No such file or directory
$ cd Documents
bash: cd: Documents: No such file or directory
Causes and Solutions
- Typo: Case matters.
documentsandDocumentsare different - Doesn't exist: First check with
lsto confirm it exists - Wrong location: Check where you are with
pwd
Error 2: command not found
$ lss
bash: lss: command not found
ls, not lss.
Error 3: Permission denied
$ cd /root
bash: cd: /root: Permission denied
/root is an admin-only area, so regular users can't enter. We'll explain permissions in detail in another article.
Troubleshooting Steps
- Check where you are with
pwd - Check contents with
ls - Verify command spelling (watch for case sensitivity)
- View help with
man command-name
Mini Exercises
Exercise 1: Check Your Location
Run pwd to check your current directory. Did you find out where you are?
Exercise 2: View File List
Run ls to see the files and folders in your current location. Then try ls -l for detailed view.
Exercise 3: Move Between Directories
Use cd to move to an existing directory, then verify with pwd. After that, return with cd ...
ls before using cd, I can prevent errors.
Review
pwd for current location, ls for contents, and cd for moving!
3-Line Summary
pwdfor location,lsfor contents,cdfor moving - these 3 are the basics- When in trouble: Ctrl + C to cancel, Tab for auto-completion
- When errors occur, start by checking with
pwdandls
Next Steps
Now that you understand the basics of the terminal, let's practice with actual commands!