Terminal (Command Line) Basics
When you hear "terminal" or "command line," do you think of it as a difficult black screen where you type text? Actually, the terminal is the most important and very convenient tool for using Linux once you get used to it. This article explains from basics to practice in beginner-friendly terms.
📋 Table of Contents
1. What is a Terminal?
💻 In Simple Terms
A terminal is an application for sending text commands to your computer. Also called the command line, you operate your computer by typing commands (instructions) with your keyboard.
🎭 Let's Understand with an Analogy
🍽️ Ordering at a Restaurant...
🖱️ GUI (Mouse Operation)
Point at menu to order
"I'll have that dish" - pointing at a picture
⌨️ CUI (Terminal)
Order verbally with exact dish name
"Pescatore, large size, with extra cheese" - specific details
🔧 Technical Definition
Technically, a terminal consists of the following elements:
- Terminal Emulator: Screen application that displays text
- Shell: Program that interprets and executes commands
- Command Line Interface (CLI): Text-based operation method
💡 What a Terminal Looks Like
yamada@penguin-gym:~$ ls -la
total 24
drwxr-xr-x 2 yamada yamada 4096 Sep 14 10:30 .
drwxr-xr-x 3 root root 4096 Sep 14 10:25 ..
-rw-r--r-- 1 yamada yamada 220 Sep 14 10:25 .bash_logout
-rw-r--r-- 1 yamada yamada 3771 Sep 14 10:25 .bashrc
-rw-r--r-- 1 yamada yamada 807 Sep 14 10:25 .profile
This is an actual terminal screen. Text is displayed on a black (or white) background, and you enter and execute commands.
2. Why Use a Terminal?
You might think, "Why bother typing text commands when clicking with a mouse is easy?" Actually, the terminal has many advantages that GUI doesn't have.
⚡ Speed and Efficiency
🖱️ GUI (Mouse Operation)
- Open file manager
- Click and navigate to target folder
- Open right-click menu
- Select "New Folder"
- Enter folder name
- Press Enter key
⏱️ Time required: ~10-15 seconds
⌨️ Terminal
mkdir new-folder
⏱️ Time required: ~2-3 seconds
🔄 Automation and Repetitive Processing
Example: Renaming 100 files
🖱️ GUI
Right-click → Rename → Type 100 times
⏱️ ~30-60 minutes
⌨️ Terminal
for i in {1..100}; do mv "file$i.txt" "new_file$i.txt"; done
⏱️ ~1-2 seconds
🎯 Precise Control
- Option Specification: Can specify detailed settings precisely
- Pipe Processing: Combine multiple commands for sequential execution
- Conditional Branching: Can do "if...then..." processing
- Log Recording: Automatically save history of executed operations
💼 Professional Necessity
Essential Skill in IT Industry
- Server Management: Many servers don't have GUI
- Programming: Development environment setup and management
- Data Analysis: Efficient processing of large datasets
- DevOps: Automation and continuous integration
3. Difference Between GUI and CUI
🎨 GUI (Graphical User Interface)
Characteristics
- Visual: Operate with icons, windows, and menus
- Intuitive: Easy to understand what to do visually
- Mouse-focused: Centered on click and drag operations
Advantages
- Easy to understand for beginners
- Visual feedback available
- Less prone to mistakes
Disadvantages
- Repetitive tasks are inefficient
- Difficult to control precisely
- High resource consumption
📝 CUI (Character User Interface)
Characteristics
- Text-based: Operate with text commands
- Accuracy-focused: Enter specific instructions as text
- Keyboard-focused: Centered on typing
Advantages
- Fast and efficient operation
- Easy to automate and script
- Low resource consumption
- Precise control possible
Disadvantages
- High learning cost
- Need to memorize commands
- Typos easily cause errors
🎯 Which Should You Use?
Choosing the right tool for the task is important:
- GUI: Image editing, video viewing, document creation, etc.
- CUI: File management, system settings, programming, etc.
Professional engineers use both appropriately for the right situation.
4. About Shell
The shell is a program that mediates between the user and the Linux kernel (OS core). It understands the commands you enter and executes them appropriately.
🐚 Shell's Role
1. Receive Command
Receives command input from user
2. Interpret & Parse
Understands command meaning and converts to executable form
3. Execute
Sends command to Linux kernel for execution
4. Display Results
Shows execution results to user in understandable format
🔧 Main Shell Types
🔵 Bash (Bourne Again Shell)
The most common shell. Standard on most Linux distributions.
⚡ Zsh (Z Shell)
High-powered shell extending Bash functionality. Excellent auto-completion and theming features.
🐟 Fish (Friendly Interactive Shell)
Modern shell focused on usability. Features real-time completion.
💡 How to Check Current Shell
echo $SHELL
# Example result: /bin/bash
This command checks which shell you're currently using.
5. Terminal Structure and How to Read It
The text string displayed when you open a terminal contains important information. Understanding each element helps you accurately grasp the current situation.
🔍 Prompt Structure
yamada@penguin-gym:~/Documents$ _
🔍 Meaning of Prompt Symbols
$ (Dollar Sign)
Indicates you're logged in as a regular user. This is displayed during normal operations.
# (Hash Sign)
Indicates you're logged in as administrator (root). You have permission to change important system settings.
⚠️ Caution: Root privileges are too powerful, so avoid using them except when necessary.
📂 Understanding Path Notation
Absolute Path vs Relative Path
🗺️ Absolute Path
Complete path starting from root directory (/)
/home/yamada/Documents/report.txt
📍 Relative Path
Path from current location
./Documents/report.txt
../Desktop/image.png
🏠 Special Directory Symbols
~
Home directory
(/home/username)
.
Current directory
..
Parent directory
(one level up)
/
Root directory
(top level)
6. Basic Operations and Shortcuts
To use the terminal efficiently, it's important to learn basic operation methods and shortcut keys.
⌨️ Basic Key Operations
📝 Text Input & Editing
Execute command
Delete one character (left)
Delete one character (right)
Auto-completion
🔄 History Operations
Previous command
Next command
History search
Display history list
🚀 Useful Shortcut Keys
⚡ Cursor Movement
✂️ Text Operations
🛑 Process Control
🎯 Tab Completion Feature
Tab completion is one of the terminal's most powerful features. Pressing Tab mid-input automatically displays and completes possible candidates.
💡 Tab Completion Example
Input:
cd Doc[Tab]
Result:
cd Documents/
Type "Doc" and press Tab to auto-complete to "Documents".
7. Basic Command Structure
Linux commands have a defined structure. Understanding this structure makes new commands easier to understand.
🏗️ Basic Structure
ls -la /home/user
Specifies process to execute
Detailed command settings
Target files or directories for processing
🔧 Option Types
🔤 Short Form Options
One hyphen + one letter
ls -l -a -h
Multiple options can be combined:
ls -lah
📝 Long Form Options
Two hyphens + word
ls --list --all --human-readable
High readability, easy to understand what the option does
📋 Argument Types
📁 File/Directory Arguments
cat file.txt
cd /home/user/Documents
📝 String Arguments
echo "Hello World"
grep "error" logfile.txt
🔢 Numeric Arguments
head -10 file.txt
chmod 755 script.sh
💡 Command Combinations
🔗 Pipe (|)
Pass output of previous command as input to next command
ls -l | grep ".txt"
Show only lines containing ".txt" from "ls -l" results
🔀 Redirect (>, >>)
Save command output to a file
ls -l > filelist.txt
Save "ls -l" results to filelist.txt file
8. Common Mistakes and Solutions
Here are common mistakes terminal beginners often make and how to fix them.
🚫 Common Mistakes
❌ Command Not Found
bash: command not found: lst
🔧 Cause and Solution
- Typo: Fix "lst" → "ls"
- Command not installed: Install if needed
- Path not set: Specify full path or set path
❌ No Permission
Permission denied
🔧 Solutions
- Use sudo:
sudo command - Change permissions:
chmod +x filename - Check owner:
ls -l filename
❌ File or Directory Not Found
No such file or directory
🔧 Solutions
- Check path:
pwdto confirm current location - Confirm file existence:
lsto display file list - Use absolute path: Specify complete path
🛟 What to Do When in Trouble
📖 man Command
Display detailed command manual
man ls
Press q to exit
❓ --help Option
Display brief command usage
ls --help
🔍 which/whereis Commands
Check command location
which ls
whereis ls
🚨 Emergency Commands
Force stop running command
Exit terminal
Reset terminal
Clear screen
9. Next Steps
Now that you understand terminal basics, let's learn actual Linux commands!
💡 Efficient Learning Tips
- A little every day: Even 15 minutes - consistency is key
- Actually practice: Not just reading, but doing
- Don't fear mistakes: Errors are part of learning
- Take notes: Record frequently used commands
🎉 Summary
The terminal (command line) may seem difficult at first, but once you get used to it, it becomes a very powerful and efficient tool. It enables high-speed processing and automation impossible with GUI operations, and your IT skills will improve dramatically.
📝 Key Points
- Terminal = Tool to operate computer with text
- Current situation can be read from prompt
- Efficient operation possible with shortcut keys
- Understanding command structure enables application
- Don't fear mistakes, prioritize practice