Linux 터미널은 처음 접하면 마치 암호 해독 같은 느낌이 듭니다. 검은 화면에 깜빡이는 커서, 알 수 없는 명령어들... 하지만 몇 가지 핵심 명령어만 이해하면, 터미널은 가장 강력한 도구가 됩니다.
The Linux terminal can feel like deciphering code when you first encounter it. A blinking cursor on a black screen, mysterious commands... But once you understand a few essential commands, the terminal becomes your most powerful tool.
이 가이드에서는 매일 사용하게 될 필수 명령어들의 작동 원리와 실무에서 자주 쓰이는 활용 패턴을 상세히 설명합니다. 단순 암기가 아닌 "왜 이렇게 작동하는지"를 이해하면, 새로운 명령어도 빠르게 익힐 수 있습니다.
This guide explains how essential commands work and practical patterns commonly used in the field. Understanding "why it works this way" rather than simple memorization helps you quickly learn new commands.
디렉토리 탐색: ls와 cd Directory Navigation: ls and cd
파일 시스템을 탐색하는 것은 터미널 사용의 가장 기본입니다.
GUI 환경에서 폴더를 클릭하는 것처럼, 터미널에서는 ls와 cd로 동일한 작업을 수행합니다.
Navigating the file system is the most fundamental aspect of terminal use.
Just like clicking folders in a GUI, terminal uses ls and cd to perform
the same tasks.
ls (List)
현재 디렉토리의 파일과 폴더 목록을 표시합니다.
Displays files and folders in the current directory.
$ ls
Documents Downloads Pictures Videos
# 상세 정보 표시 (-l: long format)
$ ls -l
drwxr-xr-x 2 user user 4096 Dec 30 10:00 Documents
-rw-r--r-- 1 user user 1234 Dec 30 09:30 readme.txt
# 숨김 파일 포함 (-a: all)
$ ls -la
.bashrc .config Documents Downloads
$ ls
Documents Downloads Pictures Videos
# Detailed info (-l: long format)
$ ls -l
drwxr-xr-x 2 user user 4096 Dec 30 10:00 Documents
-rw-r--r-- 1 user user 1234 Dec 30 09:30 readme.txt
# Include hidden files (-a: all)
$ ls -la
.bashrc .config Documents Downloads
| 옵션 | 의미 | 설명 |
|---|---|---|
-l |
Long format | 권한, 소유자, 크기, 수정일 등 상세 정보 표시 |
-a |
All | 숨김 파일(.으로 시작)까지 모두 표시 |
-h |
Human-readable | 파일 크기를 KB, MB 단위로 읽기 쉽게 표시 |
-t |
Time | 수정 시간 순으로 정렬 |
-R |
Recursive | 하위 디렉토리까지 재귀적으로 표시 |
| Option | Meaning | Description |
|---|---|---|
-l |
Long format | Shows permissions, owner, size, date, etc. |
-a |
All | Shows all files including hidden (starting with .) |
-h |
Human-readable | Displays file sizes in KB, MB units |
-t |
Time | Sort by modification time |
-R |
Recursive | List subdirectories recursively |
💡 실무 팁: 가장 자주 쓰는 조합 💡 Pro Tip: Most Common Combination
ls -lah를 alias로 등록해두면 편합니다. 숨김 파일을 포함한 상세 정보를 사람이 읽기 쉬운 형태로 보여줍니다.
Register ls -lah as an alias for convenience. It shows detailed info
including hidden files in human-readable format.
alias ll='ls -lah'
cd (Change Directory)
작업 디렉토리를 변경합니다.
Changes the working directory.
$ cd /home/user/Documents
# 홈 디렉토리로 이동 (3가지 방법)
$ cd
$ cd ~
$ cd $HOME
# 상위 디렉토리로 이동
$ cd ..
# 이전 디렉토리로 돌아가기
$ cd -
$ cd /home/user/Documents
# Go to home directory (3 ways)
$ cd
$ cd ~
$ cd $HOME
# Move to parent directory
$ cd ..
# Return to previous directory
$ cd -
권한 관리: chmod Permission Management: chmod
Linux에서 모든 파일과 디렉토리는 권한(Permission)을 가지고 있습니다. 누가 읽을 수 있는지, 쓸 수 있는지, 실행할 수 있는지를 제어합니다. 이 개념을 이해하지 못하면 "Permission denied" 에러와 끊임없이 싸우게 됩니다.
In Linux, all files and directories have permissions. They control who can read, write, or execute. Without understanding this concept, you'll constantly battle "Permission denied" errors.
권한 구조 이해하기 Understanding Permission Structure
- r (read, 4): 파일을 읽거나 디렉토리 내용을 볼 수 있음
- w (write, 2): 파일을 수정하거나 디렉토리에 파일 생성/삭제 가능
- x (execute, 1): 파일을 실행하거나 디렉토리에 진입 가능
- r (read, 4): Can read file or view directory contents
- w (write, 2): Can modify file or create/delete files in directory
- x (execute, 1): Can execute file or enter directory
chmod (Change Mode)
파일이나 디렉토리의 접근 권한을 변경합니다.
Changes access permissions of files or directories.
$ chmod 755 script.sh
# 기호 모드: 소유자에게 실행 권한 추가
$ chmod u+x script.sh
# 모든 사용자에게 읽기 권한만
$ chmod 644 document.txt
# 재귀적으로 하위 폴더까지 적용
$ chmod -R 755 ./project
$ chmod 755 script.sh
# Symbolic mode: Add execute permission for owner
$ chmod u+x script.sh
# Read-only for all users
$ chmod 644 document.txt
# Apply recursively to subdirectories
$ chmod -R 755 ./project
| 숫자 | 권한 | 일반적인 용도 |
|---|---|---|
755 |
rwxr-xr-x | 실행 가능한 스크립트, 디렉토리 |
644 |
rw-r--r-- | 일반 파일 (HTML, 설정 파일) |
600 |
rw------- | 민감한 파일 (SSH 키, 비밀번호) |
777 |
rwxrwxrwx | ⚠️ 보안상 권장하지 않음 |
| Number | Permission | Common Use |
|---|---|---|
755 |
rwxr-xr-x | Executable scripts, directories |
644 |
rw-r--r-- | Regular files (HTML, config) |
600 |
rw------- | Sensitive files (SSH keys, passwords) |
777 |
rwxrwxrwx | ⚠️ Not recommended for security |
⚠️ 주의: chmod 777의 위험성 ⚠️ Warning: Dangers of chmod 777
"동작하게 하려고" 777을 사용하는 것은 매우 위험합니다. 누구나 파일을 수정하거나 실행할 수 있게 되어 보안 취약점이 됩니다. 정확히 필요한 권한만 부여하세요.
Using 777 "just to make it work" is extremely dangerous. Anyone can modify or execute the file, creating security vulnerabilities. Grant only the permissions that are actually needed.
소유권 관리: chown Ownership Management: chown
권한(chmod)이 "무엇을 할 수 있는가"라면, 소유권(chown)은 "누구의 것인가"를 정의합니다. Linux에서 모든 파일은 소유자(owner)와 그룹(group)에 속합니다.
If permissions (chmod) define "what can be done," ownership (chown) defines "who owns it." In Linux, every file belongs to an owner and a group.
chown (Change Owner)
파일이나 디렉토리의 소유자와 그룹을 변경합니다.
Changes the owner and group of files or directories.
$ sudo chown nginx /var/www/html
# 소유자와 그룹 동시 변경
$ sudo chown nginx:www-data /var/www/html
# 그룹만 변경
$ sudo chown :www-data /var/www/html
# 재귀적으로 하위 폴더까지
$ sudo chown -R user:group ./project
$ sudo chown nginx /var/www/html
# Change owner and group together
$ sudo chown nginx:www-data /var/www/html
# Change group only
$ sudo chown :www-data /var/www/html
# Apply recursively to subdirectories
$ sudo chown -R user:group ./project
💡 실무 시나리오: 웹 서버 권한 설정 💡 Real-world Scenario: Web Server Permissions
Nginx나 Apache 같은 웹 서버가 파일을 읽을 수 있도록 설정하는 일반적인 패턴입니다:
A common pattern for configuring web servers like Nginx or Apache to read files:
$ sudo chown -R www-data:www-data /var/www/mysite
$ sudo chmod -R 755 /var/www/mysite
$ sudo chmod -R 644 /var/www/mysite/*.html
핵심 정리: 자주 쓰는 조합 Summary: Common Command Combinations
| 상황 | 명령어 |
|---|---|
| 상세 목록 보기 | ls -lah |
| 스크립트 실행 권한 부여 | chmod +x script.sh |
| 설정 파일 권한 (읽기 전용) | chmod 644 config.yml |
| SSH 키 권한 | chmod 600 ~/.ssh/id_rsa |
| 디렉토리 전체 소유권 변경 | sudo chown -R user:group ./dir |
| Situation | Command |
|---|---|
| Detailed listing | ls -lah |
| Grant script execute permission | chmod +x script.sh |
| Config file permissions (read-only) | chmod 644 config.yml |
| SSH key permissions | chmod 600 ~/.ssh/id_rsa |
| Change directory ownership | sudo chown -R user:group ./dir |
이 명령어들은 Linux를 사용하는 한 매일 만나게 됩니다. 단순히 암기하는 것이 아니라, 권한 시스템의 원리를 이해하면 새로운 상황에서도 적절한 명령어를 스스로 조합할 수 있게 됩니다.
You'll encounter these commands daily as long as you use Linux. Rather than simple memorization, understanding the principles of the permission system enables you to compose appropriate commands in new situations.
처음에는 어렵게 느껴지더라도, 반복 연습을 통해 손에 익히면 터미널은 GUI보다 훨씬 빠르고 강력한 도구가 될 것입니다.
Even if it feels difficult at first, once you become familiar through practice, the terminal will become a much faster and more powerful tool than any GUI.