How to Use the Terminal - Linux Command Line Basics
"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.
1. Introduction: What is a Terminal?
Lina: Linny-senpai, I opened the terminal, but... there's a black screen with some text displayed, and I don't know what to do...
Linny-senpai: Don't worry, everyone feels that way at first. Let me explain what a terminal is.
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.
Lina: It seems harder than using a mouse...
Linny-senpai: You might feel that way at first. But once you get used to it, you can work faster and more accurately than with mouse operations. For example, when renaming 100 files, what takes an hour with a mouse can be done in seconds with the terminal.
Lina: Wow, that's such a big difference!
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
Lina: There's
user@computer:~$ displayed on the screen. What is that?Linny-senpai: That's called a prompt. It's a signal saying "please enter a command." The prompt contains important information, so let's learn how to read it.
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) |
Lina: What does
~ mean?Linny-senpai:
~ 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
Lina: There seems to be so many commands to learn, I'm worried...
Linny-senpai: Just learn 3 commands at first.
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
Linny-senpai:
pwd stands for "Print Working Directory" and displays the directory you're currently in.$ pwd /home/yamada
Lina: Oh, so I'm in
/home/yamada right now!Linny-senpai: Exactly. If you ever get lost, just type
pwd and you'll immediately know where you are.ls - List Files
Linny-senpai:
ls stands for "list" and displays the files and folders in your current location.$ ls Documents Downloads Pictures file.txt
Lina: Does this mean there are 4 folders?
Linny-senpai:
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
Linny-senpai:
cd stands for "change directory" and moves you to a different directory.$ cd Documents $ pwd /home/yamada/Documents
Lina: So
cd Documents got me into the Documents folder!Linny-senpai: That's right. To go back up one directory, use
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
Lina: Isn't it tedious to type the full command every time?
Linny-senpai: Great question! The terminal has convenient shortcuts. Tab completion and history navigation are essential.
Tab Completion (Super Important)
Linny-senpai: If you type part of a command and press Tab, it will auto-complete for you.
$ cd Doc[Tab] # Completes to: cd Documents/
Lina: Wow, that's convenient! It will also reduce typos.
Linny-senpai: Exactly. When there are multiple options, press Tab twice to see a list.
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) |
Lina: Should I remember
Ctrl + C?Linny-senpai: Absolutely! It's the emergency escape button when a command won't stop. Remember: when in trouble, press
Ctrl + C.5. Common Errors and Solutions
Lina: I typed
cd Documents and got "No such file or directory"...Linny-senpai: That's a common error. There are several possible causes, so let's look at them together.
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
Linny-senpai: This is a typo in the command name. The correct command is
ls, not lss.Error 3: Permission denied
$ cd /root bash: cd: /root: Permission denied
Lina: What does this mean?
Linny-senpai: It means "you don't have permission."
/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
Linny-senpai: Now let's do some mini exercises to confirm what you learned today!
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 ...
Lina: Done! If I check with
ls before using cd, I can prevent errors.Linny-senpai: Perfect! That's the basic flow of terminal operations.
Review
Lina: Today I learned the basics of the terminal.
pwd for current location, ls for contents, and cd for moving!Linny-senpai: Exactly! And when in trouble,
Ctrl + C to cancel, and Tab for completion. With these basics down, you can keep learning more commands.Lina: The black screen doesn't seem so scary anymore!
Linny-senpai: Wonderful! Next, let's learn commands for creating and deleting files!
3-Line Summary
pwdfor location,lsfor contents,cdfor moving - these 3 are the basics- When in trouble:
Ctrl + Cto cancel,Tabfor auto-completion - When errors occur, start by checking with
pwdandls