$
학습 Linux 안내서
ko
XP:0
L

게스트.

레벨 1 유저

XP 진행률0 / 300
완료됨0 / 150
획득한 배지0

가입 필요 없음. 진행 상황은 로컬에 자동 저장됩니다. 세이브 코드를 내보내 다른 기기에서 이어하세요.

획득한 배지 목록

온라인 리눅스 터미널 실습 — 직접 해보며 배우기

무료 배시 학습 게임과 인터랙티브 파일시스템 시뮬레이션을 통해 필수 리눅스 명령어와 명확한 터미널 목표를 마스터하세요.

온라인 리눅스 터미널150개 이상의 퀘스트 및 목표무료 온라인 터미널 실습인터랙티브 배시 학습 게임

인터랙티브 학습 경로 및 터미널 목표

체계적인 터미널 학습 목표가 포함된 완전한 리눅스 학습 경로입니다. 잠금 해제된 챌린지를 클릭하여 터미널 워크스페이스를 여세요.

1. 파일 시스템 기초

퀘스트 1잠김

수백만 권의 책이 있는 거대하고 어두운 도서관에 들어갔는데 지도도 없고 자신의 이름표도 기억할 수 없다고 상상해 보세요. 무엇이든 찾아보기 전에 자신이 누구인지, 어디에 서 있는지 알아야 합니다. Linux 셸에서는 똑같은 질문으로 시작합니다! - `whoami` 명령은 현재 로그인된 사용자 이름을 인쇄합니다. - `pwd`(작업 디렉터리 인쇄) 명령은 GPS처럼 작동하여 현재 서있는 정확한 폴더 경로를 보여줍니다.

퀘스트 2잠김

이제 자신이 어디에 있는지 알았으니 이 디지털 도서관의 다른 방을 어떻게 둘러보고 이동합니까? Linux에서는 두 가지 간단한 명령을 사용하여 이를 수행합니다. - `ls`: 방 안에 있는 모든 파일과 폴더를 보기 위해 방의 불을 켜는 것과 같습니다. - `cd <path>`: "디렉토리 변경"의 줄임말로, 문을 통해 다른 폴더로 이동할 수 있습니다. 이동하려는 위치를 지정하려면 **절대** 경로(`/var/log`과 같이 시스템의 루트 `/`에서 시작) 또는 **상대** 경로(예: `..`를 사용하여 상위 폴더로 돌아가는 것과 같이 현재 위치에 따라)를 사용할 수 있습니다.

퀘스트 3잠김

A standard `ls` lists only the names of files, giving you no indication of how large they are, who owns them, or when they were last modified. In Linux, we inspect detailed file metadata using the long listing option: - The `-l` (long) option shows permissions, link counts, file owner, group, exact size in bytes, and last modification date. - The `-h` (human-readable) option, when combined with `-l` as `ls -lh`, translates raw byte counts into intuitive units like `K` (kilobytes), `M` (megabytes), and `G` (gigabytes).

퀘스트 4잠김

책상에 서류가 잔뜩 쌓여 있고, 물건을 깔끔하게 유지하려면 물리적인 폴더가 필요하다고 상상해 보세요. Linux에서는 `mkdir`(디렉토리 만들기) 명령을 사용하여 폴더(디렉토리)를 생성하여 파일을 구성합니다. `mkdir code`을 실행하면 현재 있는 위치에 "code"라는 이름의 새로운 폴더가 생성됩니다. `mkdir`에 상대 경로 또는 절대 경로를 제공하여 파일 시스템의 어느 위치에나 폴더를 만들 수 있습니다.

퀘스트 5잠김

중첩된 인형 세트를 만들려고 하는데 내부에 작은 인형을 만들기 전에 가장 바깥쪽에 있는 인형을 만들어야 한다고 상상해 보세요. 기본적으로 `mkdir`은 이와 같습니다. 아직 존재하지 않는 폴더 내부에 폴더 생성을 거부합니다. 폴더를 하나씩 생성하는 번거로움을 건너뛰기 위해 스위치를 사용합니다. - `-p`(또는 `--parents`) 옵션은 `mkdir`에 최종 폴더로 가는 도중에 누락된 상위 폴더를 자동으로 빌드하도록 지시합니다. 예를 들어 `mkdir -p workspace/src/utils`는 단일 명령으로 `workspace`, `workspace/src` 및 `workspace/src/utils`을 모두 생성합니다. **중요한 이유**: `-p` 없이 `mkdir workspace/src/utils`을 실행하고 `workspace` 및 `workspace/src`이 아직 존재하지 않는 경우 `mkdir: cannot create directory 'workspace/src/utils': No such file or directory`이 표시됩니다. `-p` 플래그는 누락된 모든 상위 폴더를 자동으로 생성하여 이 문제를 해결합니다.

퀘스트 6잠김

When navigating complex project directories, flat listings from `ls` make it difficult to visualize nested structures. The `tree` command recursively lists directory contents in a clear, tree-like ASCII visual hierarchy with branch lines showing directory nesting. In large repositories, a full recursive tree can produce thousands of lines. To keep output manageable, use the `-L <level>` switch (e.g., `tree -L 2`) to restrict visualization depth to a specific number of directory levels.

퀘스트 7잠김

모든 Linux 시스템은 루트 디렉터리 `/`에서 시작하는 표준 파일 시스템 계층 구조를 따릅니다. `C:` 또는 `D:`와 같은 드라이브 문자를 사용하는 Windows와 달리 Linux는 모든 파일과 저장소를 `/` 아래에 통합합니다. 모든 Linux 사용자가 알아야 할 주요 시스템 디렉터리는 다음과 같습니다. - `/`(루트): 전체 시스템의 최상위 상위 폴더입니다. - `/etc`: 시스템 구성을 보유합니다(예: `/etc/hosts`, `/etc/passwd`). - `/var`: 시간이 지남에 따라 변경되는 변수 데이터(로그, 스풀, `/var/log`과 같은 캐시)를 보유합니다. - `/home`: 사용자 개인 폴더(예: `/home/learner`). - `/tmp`: 임시 파일을 위한 임시 저장 영역입니다. - `/usr`: 사용자 유틸리티, 애플리케이션 및 시스템 라이브러리.

퀘스트 8잠김

In Linux, file extensions (like `.txt` or `.png`) are merely hints for humans—the operating system does not rely on them. To identify what a file truly contains, the `file` command reads the file's binary header (magic bytes) and determines its actual format (ASCII text, ELF executable, gzip archive, etc.). To inspect deep filesystem metadata beyond what `ls -l` shows, the `stat` command displays the file's exact size in bytes, allocated blocks, filesystem inode number, octal access permissions (e.g. `0644`), and exact timestamps: Access (`atime`), Modify (`mtime`), and Change (`ctime`).

퀘스트 9잠김

책상이 지저분한 메모와 종이로 덮여 있을 때 당황한 적이 있습니까? 터미널도 복잡해질 수 있습니다. 그렇다면 이전 텍스트를 모두 제거하고 새로 시작할 수 있습니다. - `clear` 명령은 보이는 화면을 깨끗하게 닦아서 이전 출력을 보기 밖으로 밀어내어 터미널 상단에 새로운 빈 캔버스를 갖게 합니다.

퀘스트 10잠김

새 보드 게임을 구입할 때 일반적으로 어떤 동작이 허용되는지 확인하기 위해 룰북이나 참조 카드를 살펴봅니다. 터미널 에뮬레이터에는 치트 시트가 내장되어 있습니다! - `help` 명령은 이 시뮬레이터가 지원하는 모든 단일 명령과 출력 파이핑 또는 리디렉션 지원 여부에 대한 세부 정보를 나열합니다.

👑 Boss · 퀘스트 11잠김

EMERGENCY ALERT: A faulty CI/CD deployment script executed an unconstrained cleanup routine and wiped the directory tree under `/home/learner/app`. The backend production daemon refuses to start until the project directory structure is restored. To recover, you must reconstruct the missing directory hierarchy: create `/home/learner/app/logs`, `/home/learner/app/config`, and the nested module directory `/home/learner/app/src/modules`. No step-by-step hints are provided for Boss Challenges. Inspect the system, plan your approach, and verify your filesystem state.

2. 파일 조작 및 관리

퀘스트 12잠김

새 일지를 작성하고 싶지만 먼저 빈 종이가 필요하다고 상상해 보세요. Linux에서는 `touch` 명령을 사용하여 새로운 빈 텍스트 파일을 가져옵니다. - `touch` 명령은 아직 존재하지 않는 경우 새로운 빈 파일을 생성합니다(예: `draft.txt`을 생성하기 위해 `touch draft.txt` 실행). 파일이 이미 존재하는 경우 내용을 변경하지 않고 파일의 "마지막 수정" 타임스탬프만 업데이트합니다. 새 프로젝트 폴더에 파일을 넣어 보겠습니다.

퀘스트 13잠김

폴더를 열고 텍스트 페이지를 꺼내서 읽는 것을 생각해 보세요. Linux에서는 `cat`(연결) 명령을 사용하여 무거운 텍스트 편집기를 열지 않고도 즉시 파일을 읽을 수 있습니다. - `cat` 명령은 파일의 전체 내용을 터미널 화면에 직접 인쇄합니다. 예를 들어 `cat notes.txt`을 실행하면 `notes.txt` 안에 무엇이 쓰여 있는지 바로 확인할 수 있습니다.

퀘스트 14잠김

이제 `cat`을 사용하여 전체 파일을 읽을 수 있습니다. 파일에 수천 줄이 있고 위쪽이나 아래쪽만 보려면 어떻게 해야 합니까? `cat`을 사용하여 대용량 파일을 덤프하면 화면이 가득 찼습니다. 대신 `head` 및 `tail`을 사용하여 가장자리를 엿봅니다. - `head` 명령은 기본적으로 파일의 처음 10줄을 표시합니다. `-n <number>`를 사용하여 이를 변경할 수 있습니다(예: 처음 5줄의 경우 `head -n 5 log.txt`). - `tail` 명령은 기본적으로 마지막 10줄을 표시하며 동일한 `-n` 옵션을 지원합니다. - 결정적으로 `tail -f`(follow)는 파일을 실시간으로 모니터링하여 시스템에서 작성된 새 줄을 표시합니다. 이것은 실시간 로그를 보기 위해 시스템 관리자가 가장 좋아하는 도구입니다.

퀘스트 15잠김

`head` 및 `tail`을 사용하여 파일의 상단과 하단을 엿보는 것은 훌륭하지만 긴 구성 파일을 페이지별로 검색해야 하는 경우에는 어떻게 합니까? 이것이 `less` 및 `more`과 같은 호출기의 용도입니다. - 호출기는 파일을 대화형으로 로드하여 한 번에 한 페이지의 텍스트를 표시하여 대용량 파일의 시스템 속도 저하를 방지합니다. - `less`는 화살표 키를 사용하여 앞뒤로 스크롤하고, `/`로 텍스트를 검색하고, `q`을 눌러 종료할 수 있는 현대적인 선택입니다. - `more`은 앞으로만 스크롤하는 더 오래되고 간단한 호출기입니다.

퀘스트 16잠김

로봇에게 "내 침실을 파란색으로 칠해"라고 지시하는 경우 "내 침실"이 단일 장소인지 아니면 "내"와 "침실"이 두 개의 다른 명령인지 알아야 합니다. Linux는 공백을 사용하여 명령과 인수를 구분합니다. 따라서 `mkdir my folder`을 실행하면 Linux는 두 개의 별도 폴더를 생성하려고 한다고 생각합니다. 하나는 "my"라는 이름이고 다른 하나는 "folder"라는 이름입니다! - 공백이 포함된 이름이 단일 항목임을 Linux에 알리려면 이름을 따옴표(`"my folder"` 또는 `'my folder'`)로 묶거나 백슬래시를 사용하여 공백을 이스케이프해야 합니다(`my\ folder`).

퀘스트 17잠김

칠판에 메시지를 쓰려면 먼저 칠판을 완전히 깨끗이 닦은 다음 새 단어를 쓰세요. Linux에서는 `>`(출력 리디렉션) 연산자를 사용하여 파일에 메시지를 씁니다. - `echo "message"` 명령은 일반적으로 텍스트를 화면에 인쇄합니다. - `>` 기호를 추가하면 해당 텍스트가 파일로 대신 리디렉션됩니다. 예를 들어 `echo "Hi" > greeting.txt`은 `greeting.txt`에 "Hi"를 씁니다. 파일에 이미 텍스트가 있으면 `>`는 해당 텍스트를 새 메시지로 완전히 덮어씁니다.

퀘스트 18잠김

칠판을 정리하는 대신 하단에 새 줄을 추가하고 싶다면 어떻게 해야 할까요? Linux에서는 `>>`(리디렉션 추가) 연산자를 사용하여 기존 콘텐츠를 건드리지 않고 파일 끝에 텍스트를 추가합니다. - `>>` 연산자는 파일 맨 아래에 새 텍스트를 추가합니다. 예를 들어 `echo "New Line" >> logs.txt`는 모든 이전 로그를 안전하게 유지하면서 `logs.txt` 끝에 "새 줄"을 추가합니다.

퀘스트 19잠김

방을 재구성한다고 상상해 보십시오. 때로는 문서의 복사본을 만들어 다른 서랍에 보관하고 싶고, 때로는 폴더를 가져와 새 선반에 밀어 넣거나 레이블을 변경하고 싶을 때도 있습니다. Linux에서는 간단한 명령을 사용하여 이 작업을 수행합니다. - `cp <source> <destination>`은(는) 새 위치에 파일의 동일한 복사본을 생성합니다. - `mv <source> <destination>`은 파일을 새 폴더로 이동하거나 파일을 동일한 폴더에 보관하는 경우 파일 이름을 바꿉니다(예: `mv old.txt new.txt`).

퀘스트 20잠김

"log_monday", "log_tuesday" 및 "log_wednesday"라는 레이블이 붙은 폴더 스택이 있고 모든 이름을 입력하지 않고 한 번에 모든 폴더를 열고 읽고 싶다고 가정해 보세요. Linux에서는 **와일드카드**를 검색 단축키로 사용할 수 있습니다! - `*` 기호는 모든 길이의 모든 문자와 일치합니다. 예를 들어 `cat log_*`은 "log_"로 시작하는 모든 파일을 읽습니다. - `?` 기호는 단일 문자 자리 표시자 역할을 합니다. 예를 들어 `log_?.txt`은 `log_1.txt`와 일치하지만 `log_12.txt`은 무시됩니다.

퀘스트 21잠김

실제 책상을 정리할 때 실수를 했을 경우 재활용할 수 있는 오래된 종이를 재활용 쓰레기통에 버릴 수도 있습니다. Linux에는 안전망이 없습니다. 터미널에서 무언가를 삭제하면 영원히 사라지게 됩니다! - `rm` 명령은 파일을 삭제합니다. - 폴더에는 다른 파일이 포함될 수 있으므로 `rm`은 기본적으로 폴더를 삭제하지 않습니다. `-r`(재귀) 플래그를 추가하여 Linux에게 폴더에 있는 모든 항목과 함께 폴더를 삭제하도록 지시해야 합니다. **이것이 중요한 이유**: `downloads`가 폴더일 때 `-r` 없이 `rm downloads`을 실행하면 `rm: cannot remove 'downloads': Is a directory`이 표시됩니다. `-r` 플래그는 Linux에 폴더와 그 안에 있는 모든 항목을 반복적으로 삭제하도록 지시합니다.

퀘스트 22잠김

Bash **brace expansion** `{}` is a powerful productivity feature that generates arbitrary string combinations before commands run, eliminating repetitive typing: - Comma-separated lists: `mkdir -p app/{src,bin,logs}` expands to `app/src`, `app/bin`, and `app/logs` in a single command. - Numeric or alphabetic ranges: `touch file_{1..3}.txt` expands to `file_1.txt`, `file_2.txt`, and `file_3.txt`. When deleting folders, `rm -r` deletes everything recursively without safety checks. By contrast, `rmdir` provides a strict safety guarantee: it **only removes directories that are completely empty**, preventing accidental loss of files.

👑 Boss · 퀘스트 23잠김

INCIDENT REPORT: An aborted container update left messy temporary build artifacts in `/home/learner`. The leftover files `temp_install.tmp` and `old_log.txt` are creating conflicts. Furthermore, the verified staging configuration `/home/learner/staging.conf` was never promoted to production. Purge the obsolete temporary files and establish `/home/learner/production.conf` with the configuration from staging. This is a Boss Challenge: evaluate the files, execute the cleanup, and prepare the production configuration.

3. 파이프와 필터링

퀘스트 24잠김

한 작업자가 제품을 포장한 후 즉시 다음 작업자에게 전달하여 상자에 포장하는 조립 라인을 상상해 보십시오. 중간 저장 공간이 필요하지 않습니다. Linux에서는 **파이프**(`|`)를 사용하여 이와 똑같은 명령을 연결합니다. - 파이프(`|`)는 한 명령의 출력을 다음 명령의 입력으로 직접 라우팅합니다. 예를 들어, `ls | wc -l`는 파일을 나열하고 해당 목록을 즉시 `wc -l`(단어 수 - 줄)로 전달하여 임시 파일 없이도 즉시 파일 수를 계산합니다. **중요한 이유**: `-l` 없이 `wc`을 실행하면 줄, 단어, 바이트(예: ` 5 10 85`)라는 세 가지 별도의 숫자가 출력됩니다. 이로 인해 깔끔한 단일 숫자 개수가 필요한 파이프라인이나 스크립트에서 사용하기가 어렵습니다. `-l` 플래그는 출력을 줄 수로만 제한합니다.

퀘스트 25잠김

중복 항목이 여기저기 흩어져 있는 카드 덱을 정렬한다고 상상해 보세요. 중복 항목을 쉽게 찾아 제거하려면 먼저 동일한 카드를 그룹화하세요. Linux에서 `uniq` 명령은 반복되는 줄을 필터링하지만 문제가 있습니다. **서로 바로 옆에 있는 중복 항목만 감지**합니다! - 지저분한 목록에서 모든 중복 항목을 제거하려면 먼저 `sort`을 사용하여 줄을 정렬한 다음 결과를 `uniq`에 전달해야 합니다. 예를 들어 `sort raw.txt | uniq`은 목록을 한 번에 정리하고 정리합니다.

퀘스트 26잠김

을 사용한 필터링 시스템 오류가 발생할 때마다 찾기 위해 수천 페이지에 달하는 방대한 로그북을 검색한다고 상상해 보십시오. 이 작업을 수동으로 수행하려면 몇 시간이 걸릴 것입니다! Linux에서는 `grep`을 디지털 돋보기로 사용하여 특정 단어나 패턴을 즉시 검색합니다. - `grep` 명령은 파일이나 파이프로 연결된 텍스트를 필터링하여 검색어와 일치하는 줄만 인쇄합니다. 예를 들어 `grep "ERROR" logs.txt`를 실행하면 파일을 검사하고 "ERROR"가 포함된 줄만 추출합니다.

퀘스트 27잠김

In plumbing, a T-pipe splits a single water stream into two paths. In Linux, the `tee` command does the exact same thing with text streams: it reads standard input and writes it simultaneously to both the screen (stdout) and one or more files. E.g.: `cmd | tee output.log`. Furthermore, `tee` solves a classic Linux permissions pitfall: running `sudo echo "config" > /etc/app.conf` fails because redirection `>` is handled by your unprivileged shell before `sudo` executes. Piping to `sudo tee -a /etc/app.conf` (where `-a` appends) runs `tee` with superuser privileges, safely writing to protected system files.

퀘스트 28잠김

In production environments, servers fail when configuration files silently diverge over time—a problem called "configuration drift". The `diff` utility compares two text files line by line and highlights every difference: - Standard format: `diff file1.conf file2.conf` uses `<` to indicate lines from the first file and `>` for lines in the second file. - Unified format: `diff -u file1.conf file2.conf` produces unified diff output (`-` for removed lines, `+` for added lines), which is the standard format used by Git patches and modern pull requests.

퀘스트 29잠김

While basic `grep` searches for exact strings, production log analysis requires powerful matching flags: - `-i`: Case-insensitive search (matches `error`, `Error`, or `ERROR`). - `-v`: Invert match (prints lines that do **not** match the given pattern, perfect for stripping noise). - `-r` (or `-R`): Recursive directory search across all subdirectories and files. - `-E`: Extended regular expressions (supports `|` alternation for multiple patterns, `+`, and parentheses without escape backslashes).

👑 Boss · 퀘스트 30잠김

SECURITY ALERT: The server logged dozens of suspicious requests in `/home/learner/access.log`. The SOC team needs a clean, deduplicated list of attacking IP addresses to update the network firewall blocklist. Process the raw web server log to extract all unique IP addresses, sort them, and save the result into `/home/learner/banned_ips.txt`. Analyze the data pipeline and construct a command pipeline to generate the required forensic report.

4. 리다이렉션과 보안

퀘스트 31잠김

관리자만 수표에 서명할 수 있고 직원은 일정을 읽을 수 있으며 방문자는 상점 간판만 볼 수 있는 사업체를 운영한다고 상상해 보십시오. Linux에서는 숫자 보안 시스템(8진 표현이라고 함)을 사용하여 파일을 읽고, 쓰고, 실행할 수 있는 사람을 제어합니다. - `7` = 전체 액세스: 읽기 + 쓰기 + 실행(`rwx`) - `6` = 수정 액세스: 읽기 + 쓰기(`rw-`) - `5` = 읽기 및 실행 액세스: 읽기 + 실행(`r-x`) - `4` = 읽기 전용 액세스: 읽기(`r--`) `chmod <octal> <file>`을 사용하여 이러한 설정을 적용합니다. 예를 들어 `chmod 755 script.sh`을 사용하면 스크립트를 실행할 수 있지만 다른 사용자는 스크립트를 읽고 실행할 수만 있습니다. 현재 잠겨 있는 `deploy.sh`이라는 스크립트가 있습니다. 실행 가능하게 만들어 보겠습니다!

퀘스트 32잠김

기본 작업 공간을 어지럽히지 않도록 시스템 설정을 보관하는 책상 아래 비밀 서랍을 생각해 보세요. Linux에서는 이름을 점(`.`)으로 시작하여 숨김 파일을 만듭니다. - 이러한 도트 파일(예: `.bashrc` 또는 `.config`)은 사용자 기본 설정 및 구성 설정을 배후에 저장합니다. - 표준 `ls` 명령으로는 표시되지 않습니다. 이러한 숨겨진 파일을 보려면 `ls -a`를 실행하여 `-a`(모두) 플래그를 추가해야 합니다. **중요한 이유**: `-a` 없이 `ls`을 실행하면 숨겨진 파일(이름이 `.`로 시작하는 파일)이 출력에서 ​​완전히 생략됩니다. `.config_names`과 같은 중요한 파일이 표시되지 않으며 해당 파일이 누락되었다고 생각할 수도 있습니다. `-a` 플래그는 `ls`에 숨겨진 파일을 포함하여 모든 파일을 나열하도록 지시합니다.

퀘스트 33잠김

집을 구입하고 새 소유자 이름으로 증서를 공식적으로 등록해야 한다고 상상해 보십시오. Linux에서는 모든 파일과 폴더에 공식 소유자와 그룹이 있습니다. 파일의 소유권을 다른 사람(예: 시스템 관리자)에게 넘겨야 하는 경우 `chown`(소유자 변경) 명령을 사용합니다. - 파일 소유자를 변경하는 것은 민감한 보안 작업이므로 관리자 권한으로 실행하려면 앞에 `sudo`을 붙여야 합니다. 예를 들어, `sudo chown root reports.csv`는 파일을 "root" 사용자에게 할당합니다.

퀘스트 34잠김

경비원이 입구에 서서 ID를 확인하고 무단 방문자를 차단하는 안전한 아파트 건물에 살고 있다고 상상해 보십시오. Linux에서는 **방화벽**이 네트워크 포트에 대한 보안 가드 역할을 합니다. - `ufw`(복잡하지 않은 방화벽) 명령은 방화벽 규칙을 관리하기 위한 사용자 친화적인 인터페이스입니다. `sudo ufw status`을 실행하면 방화벽이 활성화되었는지 여부와 어떤 포트(예: SSH의 경우 포트 22, 웹 서버의 경우 포트 80)가 열려 있는지 표시됩니다. - `iptables` 명령은 실제로 패킷을 차단하거나 리디렉션하는 낮은 수준의 기존 Netfilter 도구입니다. `sudo iptables -L`을 실행하면 활성 보안 체인과 패킷 일치 규칙이 나열됩니다.

퀘스트 35잠김

In Linux, every process opens three standard I/O streams: - File descriptor `0`: `stdin` (Standard Input) - File descriptor `1`: `stdout` (Standard Output — where normal output goes) - File descriptor `2`: `stderr` (Standard Error — where error messages go) When you run `cmd > output.txt`, only stdout is saved; error messages still appear on your screen. To redirect errors separately, specify file descriptor 2: `cmd 2> errors.log`. To silence noisy errors completely, redirect them to the Linux null device (black hole): `cmd 2> /dev/null`. To combine both stdout and stderr into one stream or file, use `&> output.log` or `cmd > output.log 2>&1`.

퀘스트 36잠김

In automated scripts and cloud deployment routines (like Dockerfiles or cloud-init), opening an interactive text editor like nano is impossible. Instead, Bash uses **Here-Documents** (`<<EOF`) to inject multi-line blocks of text directly into commands. The syntax `cat <<EOF > config.env` tells the shell to capture all following lines into `config.env` until a line containing only the delimiter word `EOF` is reached.

퀘스트 37잠김

Whenever a program creates a new file or folder, its initial permissions are determined by the **umask** (user file-creation mode mask). The umask acts as a filter that strips away permissions from maximum defaults (`666` for files, `777` for directories): - Standard umask `022` subtracts group/other write permissions, yielding `644` (`rw-r--r--`) for files and `755` (`rwxr-xr-x`) for folders. - Running `umask 027` tightens security by stripping all permissions from "others", yielding `640` and `750`. To change only the group owner of a file without altering its user owner, use `chgrp <group> <file>`.

퀘스트 38잠김

Standard file permissions (`rwx`) have three special bits that provide advanced access models: - **Sticky Bit (`+t` or octal `1000`)**: Set on shared directories like `/tmp`. Anyone can create files, but users can only delete or rename files they own. Displayed as `t` in `ls -l` (e.g. `drwxrwxrwt`). - **SUID (Set User ID, `u+s` or octal `4000`)**: When set on an executable binary, standard users run the binary with the file owner's privileges (usually root). Displayed as `s` in owner execute position (e.g. `-rwsr-xr-x`). Essential for tools like `/usr/bin/passwd`. - **Security Auditing**: Attackers frequently abuse SUID binaries for privilege escalation. Sysadmins audit systems for SUID binaries using: `find / -perm -4000 2> /dev/null`.

퀘스트 39잠김

Standard Linux permissions only support one user owner, one group, and others. When complex enterprise collaboration requires granting distinct rights to multiple users or groups on a single file, **POSIX Access Control Lists (ACLs)** are used: - `getfacl <file>`: Reads and displays the file's extended ACL entries (user, group, mask, other). - `setfacl -m u:<username>:<perms> <file>`: Modifies the ACL to grant specific permissions (`r`, `w`, `x`) to an individual user without changing the file owner. - Notice that when a file has an ACL, `ls -l` displays a `+` symbol at the end of the permission string (e.g., `-rw-rw-r--+`).

👑 Boss · 퀘스트 40잠김

AUDIT FAILURE: An internal compliance scanner raised a critical security finding: `/etc/vault.conf` containing sensitive credentials was deployed with permissive `777` permissions and is owned by `learner` instead of `root`. Remediate the vulnerability immediately by changing the owner of `/etc/vault.conf` to `root:root` and locking down permissions to strict `600` (read/write for owner only). Inspect the file with `ls -l` before and after running your remediation.

5. 슈퍼유저와 패키지 관리

퀘스트 41잠김

중요한 운영 체제 파일을 실수로 삭제하는 것을 방지하기 위해 표준 계정으로 컴퓨터에서 작업한다고 상상해 보십시오. 소프트웨어를 설치하거나 시스템 설정을 수정해야 하는 경우 컴퓨터에서 관리자 권한을 요청합니다. Linux에서는 `sudo`("superuser do"의 약어)를 관리 키 카드로 사용합니다. - `root` 사용자는 시스템에 대한 모든 권한을 가진 마스터 관리자 계정입니다. - 표준 사용자는 민감한 파일(예: 비밀번호 데이터베이스 `/etc/shadow`)을 읽지 못하도록 차단됩니다. 명령 앞에 `sudo`을 입력하면 임시 관리자 권한으로 명령을 실행하여 이러한 블록을 우회할 수 있습니다.

퀘스트 42잠김

App Store나 Google Play Store를 사용하여 스마트폰에 앱을 설치한다고 생각해 보세요. 안전하고 선별되었으며 자동화되어 있습니다. Linux에서는 패키지 관리자라는 명령줄 앱 스토어를 사용하여 소프트웨어를 안전하게 가져오고 설치합니다. - Ubuntu/Debian 시스템에서 표준 패키지 관리자는 `apt`(고급 패키징 도구)입니다. - 소프트웨어를 설치하면 시스템 전체 폴더가 변경되므로 항상 `sudo`을 사용하여 승인해야 합니다. 예를 들어 `sudo apt install tree`는 디렉터리 시각화 도우미 "tree"를 다운로드하고 설치합니다.

퀘스트 43잠김

Linux에 소프트웨어를 설치하기 전에 저장소에서 어떤 패키지를 사용할 수 있는지 어떻게 알 수 있습니까? Linux에서는 `apt search`을 사용하여 키워드로 소프트웨어 카탈로그를 쿼리합니다. - `apt search <keyword>` 명령은 저장소 설명을 검색하고 해당 버전과 함께 일치하는 소프트웨어 패키지를 나열합니다. - `apt install`와 달리 패키지 저장소 검색은 로컬 카탈로그 인덱스 파일만 읽으며 수퍼유저(`sudo`) 권한이 필요하지 **않습니다**.

퀘스트 44잠김

Linux에서 소프트웨어를 제거할 때 표준 `apt remove`은 응용 프로그램 바이너리를 제거하지만 나중에 다시 설치할 경우를 대비해 시스템 구성 파일을 남겨 둡니다. 소프트웨어 패키지를 완전히 제거하고 관련된 모든 구성 파일을 지우려면 `apt purge`(또는 `apt remove --purge`)을 사용합니다. - `sudo apt purge <package>` 명령은 애플리케이션을 제거하고 나머지 구성 파일을 모두 지웁니다. - 제거는 시스템 전체 폴더 및 구성 파일을 수정하므로 수퍼유저(`sudo`) 권한이 필요합니다.

퀘스트 45잠김

`apt`이 리포지토리에서 패키지 종속성을 자동으로 다운로드하고 해결하는 동안 `.deb` 패키지 파일을 이미 수동으로 다운로드하여 검사하거나 설치하고 싶다면 어떻게 해야 합니까? Linux에서는 `dpkg`(Debian 패키지)를 사용하여 패키지와 직접 상호 작용합니다. - `dpkg -l` 명령은 현재 Debian/Ubuntu 시스템에 설치된 모든 패키지를 나열합니다. - `dpkg -s <package>` 명령은 특정 패키지에 대한 상태, 버전 및 아키텍처 정보를 표시합니다.

퀘스트 46잠김

모든 Linux 환경이 Debian/Ubuntu를 기반으로 하는 것은 아닙니다. RedHat, Fedora 또는 CentOS 시스템에서 작업하는 경우 `apt` 또는 `dpkg`을 찾을 수 없습니다. 대신 이전 `yum` 또는 최신 `dnf`(Dandified YUM) 패키지 관리자를 사용하여 패키지를 관리하게 됩니다. - `dnf check-update`(또는 `yum check-update`) 명령은 RedHat 리포지토리에 연결하여 사용 가능한 패키지 업데이트를 검색합니다. - `dnf install <package>` 명령은 `apt install`과 유사한 프로그램을 가져와 설치합니다.

퀘스트 47잠김

New system administrators often confuse updating and upgrading. In Debian and Ubuntu environments: - `sudo apt update`: Refreshes your local cache of package lists from upstream repository servers (`/etc/apt/sources.list`). It discovers which newer package versions exist, but **does not modify or upgrade any software** on disk. - `sudo apt upgrade`: Compares your currently installed software against the refreshed list and downloads/installs the newer package versions. Running `apt upgrade` without running `apt update` first will either install outdated versions or fail completely because your system does not know newer releases exist!

퀘스트 48잠김

In cross-distribution Linux environments, you will frequently encounter formats beyond Debian `.deb` packages: - **RPM (`rpm`)**: The native package format for RedHat, CentOS, and Fedora. Use `rpm -qa` to list every installed RPM package, and `rpm -qi <package>` to query deep metadata (version, build architecture, signature, description). - **Snap (`snap`)**: Canonical's universal containerized package system. Snaps bundle all dependencies in an isolated sandbox across any Linux distro. Inspect installed snaps with `snap list` and install new tools with `sudo snap install <package>`.

👑 Boss · 퀘스트 49잠김

INCIDENT RESPONSE: An unauthorized script dropped a suspicious unsigned package archive `/tmp/corrupt_pkg.deb` into temporary storage. Furthermore, the standard network diagnostic utility `curl` is missing or unverified in the system catalog. Cleanse the temporary directory by purging `/tmp/corrupt_pkg.deb` and ensure the package manager has `curl` installed and ready for service.

6. 디스크와 시스템 리소스

퀘스트 50잠김

거대한 비디오 게임을 다운로드하려고 하는데 "저장 공간이 가득 참" 오류가 발생하지만 병목 현상이 발생하는 디스크 드라이브가 무엇인지 확신할 수 없다고 상상해 보십시오. Linux에서는 `df`(디스크 없음) 명령을 사용하여 시스템의 저장 용량을 확인합니다. - `df` 명령은 연결된 모든 드라이브의 전체 공간, 사용된 공간, 사용 가능한 공간을 표시합니다. - `df -h`를 실행하면("사람이 읽을 수 있음"을 위해 `-h` 플래그 추가) 혼란스러운 블록 수 대신 친숙한 기가바이트(G) 및 메가바이트(M)로 저장 공간이 표시되므로 어떤 드라이브(예: `/` 또는 `/home`)가 가득 찼는지 쉽게 확인할 수 있습니다. **중요한 이유**: `-h` 없이 `df`을 실행하면 크기가 원시 1K 블록 숫자로 표시됩니다(예: `47G` 대신 `49258284`). 이는 사람이 읽고 계산하기가 매우 어렵습니다. `-h` 플래그는 이러한 크기를 인간에게 친숙한 기가바이트(G) 및 메가바이트(M)로 형식화합니다.

퀘스트 51잠김

*어느* 드라이브가 꽉 찼는지 알고 나면 모든 공간을 차지하고 있는 특정 폴더를 어떻게 찾을 수 있습니까? 다운로드 폴더인가요, 아니면 숨겨진 캐시인가요? 우리는 `du`(디스크 사용량) 명령을 사용하여 이 미스터리를 해결합니다. - `du <directory>`은 폴더와 그 안에 있는 모든 하위 폴더의 크기를 나열합니다. - `du -sh <directory>`(여기서 `-s`은 "요약"을 의미하고 `-h`는 "사람이 읽을 수 있음"을 의미)는 해당 특정 폴더에 대해 단일하고 명확한 총 크기를 계산하고 인쇄합니다. **중요한 이유**: `-s` 없이 `du`을 실행하면 단일 요약을 제공하는 대신 모든 개별 하위 디렉터리와 파일을 반복적으로 나열하는 거대한 텍스트 벽을 덤프하게 됩니다. `-s` 플래그는 폴더의 전체 크기를 요약하고 `-h`은 이를 사람이 읽을 수 있도록 만듭니다.

퀘스트 52잠김

노트북이 지연되기 시작하고, 웹 페이지가 정지되고, 앱 전환이 고통스러울 정도로 느리게 느껴진다고 상상해 보세요. 이는 일반적으로 컴퓨터에 활성 메모리(RAM)가 부족함을 의미합니다. Linux에서는 `free` 명령을 사용하여 시스템에 숨쉴 공간이 얼마나 있는지 확인할 수 있습니다. - `free` 명령은 총 메모리, 사용된 메모리, 사용 가능한 물리적 메모리(RAM) 및 스왑 공간을 표시합니다. - `-h` 플래그(`free -h` 실행)를 추가하면 메모리 크기가 읽기 쉬운 기가바이트(GB) 및 메가바이트(MB)로 형식화되므로 프로그램이 모든 리소스를 소모하는지 알 수 있습니다. **중요한 이유**: `-h` 없이 `free`을 실행하면 메모리 사용량이 원시 킬로바이트(예: `16G` 대신 `16323456`)로 인쇄되므로 빠르게 해석하기 어렵습니다. `-h` 플래그는 쉽게 읽을 수 있도록 숫자를 기가바이트(G) 또는 메가바이트(M)로 자동 조정합니다.

퀘스트 53잠김

오작동을 시작한 서버의 문제를 해결하고 최근에 재부팅했는지 확인해야 하거나 내부에서 실행 중인 운영 체제 버전을 정확히 확인한다고 상상해 보세요. 몇 초 안에 이러한 시스템 세부 정보를 쿼리할 수 있습니다. - `uptime` 명령은 머신이 마지막 부팅 이후 얼마나 오랫동안 실행되었는지, 그리고 얼마나 바쁜지(시스템 로드)를 정확하게 알려줍니다. - `uname -a`(유닉스 이름) 명령은 시스템 커널, 플랫폼 이름 및 기계 아키텍처에 대한 전체 보고서를 인쇄합니다. **중요한 이유**: `-a` 없이 `uname`을 실행하면 기본 운영 체제 이름(예: `Linux`)만 출력됩니다. 커널 버전, 플랫폼 이름, 프로세서 아키텍처와 같은 중요한 세부 정보는 생략됩니다. `-a` 플래그는 단일 보고서에 사용 가능한 모든 시스템 세부 정보를 인쇄합니다.

퀘스트 54잠김

시스템 성능 문제를 해결하거나 수요가 높은 응용 프로그램을 배포할 때 시스템 CPU의 성능을 알아야 합니다. Linux에서는 `lscpu` 명령을 사용하여 자세한 CPU 아키텍처 정보를 읽습니다. - `lscpu` 명령은 커널 파일 시스템에서 직접 CPU 모델, 공급업체, 클럭 속도, 코어 수, 하이퍼스레딩 세부 정보 및 캐시 크기와 같은 프로세서 세부 정보를 표시합니다.

퀘스트 55잠김

데이터베이스 또는 웹 애플리케이션이 느리게 실행되는 경우 문제가 CPU 병목 현상인지 아니면 느린 하드 드라이브인지 어떻게 판단합니까? Linux에서는 `iostat`을 사용하여 시스템 출력/입력 성능 메트릭을 모니터링합니다. - `iostat` 명령은 CPU 사용량 및 활성 장치 읽기/쓰기 처리량에 대한 보고서 통계를 표시하여 디스크 정체를 식별하는 데 도움을 줍니다.

퀘스트 56잠김

Before a disk can store files, it is divided into storage blocks and partitions formatted with filesystems. In Linux: - `lsblk`: Lists block storage devices (hard drives, NVMe SSDs, flash drives) in an intuitive tree showing parent drives (like `sda`, `sdb`), child partitions (like `sda1`, `sdb1`), sizes, and active mountpoints. Adding `-f` shows filesystem types and UUIDs. - `sudo blkid`: Queries disk headers directly to print device Universally Unique Identifiers (UUIDs), filesystem formats (such as `ext4`, `xfs`, `vfat`), and partition labels used in boot and mount configurations.

퀘스트 57잠김

In Unix systems, disk drives do not have isolated drive letters like `C:\` or `D:\`. Instead, all filesystems attach into a unified directory tree: - `sudo mount <device> <directory>`: Attaches a formatted block partition (e.g. `/dev/sdb1`) into an existing directory folder (the "mountpoint", e.g. `/mnt/data`). - `sudo umount <directory>`: Safely detaches the filesystem, committing unwritten buffers to disk before unplugging or reformatting. - `/etc/fstab`: The static filesystem table file describing which partitions automatically mount at boot time, their mount options, and dump/fsck pass priorities.

퀘스트 58잠김

When hardware devices attach, drives fail, or the Linux kernel encounters system memory exhaustion, kernel messages are written to a special memory area called the **Kernel Ring Buffer**. - `dmesg`: Dumps raw kernel boot and runtime log messages. - `dmesg -T`: Converts raw timestamps into readable date and time strings. - Pipelining `dmesg | grep -i error` or filtering for "Out of memory" reveals low-level driver failures and Out-Of-Memory (OOM) killer terminations.

👑 Boss · 퀘스트 59잠김

CRITICAL ALERT: Root filesystem capacity has hit 99%! Production monitoring reports that an unhandled core dump `/var/log/huge_core_dump.log` is suffocating system storage. Locate the runaway file, delete `/var/log/huge_core_dump.log` to reclaim space, and create a status confirmation log `/home/learner/disk_recovery.txt` containing a summary of recovered capacity.

7. 프로세스 관리

퀘스트 60잠김

운영 체제를 모든 직원(또는 실행 중인 프로그램)에 프로세스 ID(PID)라는 고유한 이름 태그가 할당되는 분주한 사무실로 생각하십시오. Linux에서는 이러한 활성 프로그램을 **프로세스**라고 부르며 `ps` 명령을 사용하여 나열합니다. - `ps`만 실행하면 현재 터미널 창 내에서 실행 중인 프로그램만 표시됩니다. - `ps aux` 실행은 전체 시스템에서 실행 중인 모든 단일 활성 프로그램, 이를 시작한 사람, 사용 중인 CPU 및 메모리 양을 나열하는 마스터 오피스 레지스트리처럼 작동합니다. **중요한 이유**: `aux` 없이 `ps`을 실행하면 현재 터미널 창에서 실행 중인 프로세스만 표시됩니다(보통 `bash` 및 `ps` 자체). 다른 사용자가 실행하는 백그라운드 서비스, 시스템 프로세스 또는 프로그램은 표시되지 않습니다. `aux` 옵션은 시스템 전체에서 실행 중인 모든 프로세스를 표시합니다.

퀘스트 61잠김

고속도로의 정적 사진을 보는 것과 실시간 교통 카메라 피드를 보는 것을 상상해 보십시오. `ps`은 현재 실행 중인 항목에 대한 빠른 스냅샷을 제공하는 반면, `top`을 사용하면 시스템 성능을 실시간으로 볼 수 있습니다. - `top` 명령은 몇 초마다 업데이트되는 대화형 실시간 대시보드를 시작합니다. CPU 사용량, 로드 평균을 표시하고 정확한 순간에 실행 중인 리소스를 가장 많이 사용하는 프로세스의 순위를 동적으로 지정합니다.

퀘스트 62잠김

Unix 계열 시스템에서는 "모든 것이 파일입니다." 이는 텍스트 파일과 폴더뿐만 아니라 네트워크 소켓, 시스템 하드웨어 및 프로세스도 파일로 처리된다는 의미입니다. 어떤 실행 프로그램이 어떤 파일에 액세스하고 있는지 확인하려면 `lsof`(열린 파일 나열)을 사용합니다. - `lsof`을 실행하면 열려 있는 모든 파일의 전체 목록과 함께 해당 파일을 열었던 프로세스 ID(PID) 및 명령이 표시됩니다. - 예를 들어 `lsof -i`를 실행하면 모든 네트워크 파일/소켓이 나열됩니다. 이는 어떤 프로세스가 특정 네트워크 포트(예: 포트 80)에서 수신 대기하는지 검색하는 데 매우 유용합니다.

퀘스트 63잠김

휴대전화의 앱이 작동을 멈추고 화면이 완전히 잠긴 후 다시 원활하게 실행하려면 앱을 강제로 닫아야 한다고 상상해 보세요. Linux에서는 `kill` 명령 뒤에 프로그램의 프로세스 ID(PID)를 사용하여 프로그램의 오작동이나 정지를 중지합니다. - `kill 1234`을 실행하면 프로그램에 작업을 저장하고 종료하도록 요청하는 정중한 요청이 전송됩니다. - 정지되어 폴라이트 요청을 무시하는 경우 `kill -9 1234`는 운영 체제를 강제로 즉시 종료합니다. 지금 PID `9999`이(가) 모든 CPU를 점유하고 있는 런어웨이 프로세스가 있습니다. 종료하겠습니다!

퀘스트 64잠김

대용량 폴더를 USB 드라이브에 복사하려고 하는데 복사하는 동안 동일한 창에서 계속 작업하고 다른 명령을 입력하고 싶다고 상상해 보십시오. Linux에서는 시간이 많이 걸리는 작업을 "백그라운드"에서 실행하여 명령줄이 잠기지 않도록 할 수 있습니다. - 명령 끝에 앰퍼샌드 `&`을 추가하면(예: `sleep 100 &`) 터미널이 해당 명령을 백그라운드에서 실행하고 즉시 프롬프트를 표시합니다. - `jobs` 명령은 현재 백그라운드에서 실행 중인 내용을 보여줍니다. - `fg`(전경) 명령은 백그라운드 작업을 다시 중앙 스테이지로 가져옵니다.

퀘스트 65잠김

바쁜 사무실에서는 우선순위가 낮은 일부 작업(예: 영수증 제출)이 기다릴 수 있지만 우선순위가 높은 요청은 즉시 처리해야 합니다. Linux는 -20(가장 높은 우선순위)부터 19(가장 낮은 우선순위)까지의 **niceness** 값을 사용하여 프로세스 우선순위를 관리합니다. - `nice` 명령은 사용자 정의된 우선순위로 프로세스를 시작합니다. 예: `nice -n 10 sleep 5`은 폴라이트 우선순위 10으로 절전 명령을 시작합니다. - `renice` 명령은 이미 실행 중인 프로세스의 예약 우선순위를 변경합니다. 예를 들어 `sudo renice +5 9999`은 프로세스 9999의 우선순위를 낮춥니다.

퀘스트 66잠김

우리는 이미 `&`을 사용하여 백그라운드에서 작업을 시작하고 `fg`을 사용하여 다시 가져오는 방법을 살펴보았습니다. 하지만 `&` 없이 명령을 시작했거나 `Ctrl+Z`을 사용하여 일시 중지했다면 어떻게 될까요? `bg`를 사용하여 백그라운드에서 재개할 수 있습니다! - `bg` 명령은 일시 중지된 작업을 재개하여 터미널 프롬프트를 차단하지 않고 백그라운드에서 실행할 수 있도록 합니다.

퀘스트 67잠김

In fast-paced system operations, looking up process IDs with `ps aux | grep name` just to pass a numerical PID into `kill` is slow and error-prone. Linux provides process lookup and signal tools that operate directly by process name: - `pgrep <pattern>`: Scans active processes and returns matching PIDs. Adding `-a` outputs the full command line alongside the PID. - `pkill <pattern>`: Sends termination signals directly to all processes matching the pattern (e.g. `pkill -9 miner`). - `killall <name>`: Kills processes matching the exact binary executable name.

퀘스트 68잠김

Long-running tasks need two critical abilities: surviving unexpected network disconnects, and real-time execution monitoring without manual re-typing: - `nohup <command> &`: Runs a command immune to SIGHUP (hangup signals). If your SSH session drops or terminal closes, the program continues executing in the background, redirecting stdout/stderr into `nohup.out`. - `watch -n <seconds> <command>`: Repeatedly executes a command at a set interval (default 2s), clearing the screen to display a live updating dashboard of system state.

👑 Boss · 퀘스트 69잠김

SERVER THROTTLED: CPU load average has spiked above 25.0. An unauthenticated background script (PID 9999 running `rogue_process.sh`) is monopolizing 99.1% of processor cycles and starving application threads. Inspect the active process table to discover the rogue PID, determine its signal tolerance, and kill the process immediately so it ceases execution.

8. 네트워크 문제 해결

퀘스트 70잠김

웹페이지를 로드하려고 하는데 브라우저가 끝없이 회전하여 집 Wi-Fi 연결이 끊어졌는지 또는 웹사이트 자체가 충돌했는지 궁금해 한다고 상상해 보십시오. Linux에서는 `ping` 명령을 사용하여 기본 네트워크 연결을 테스트합니다. - `ping` 명령은 작은 데이터 패킷을 서버(예: `google.com`)로 보내고 응답을 받는 데 걸리는 시간을 측정합니다. - Linux에서는 `ping`이 기본적으로 영원히 계속 실행됩니다. 몇 번의 시도 후에 중지하려면 `ping -c 3 google.com`를 실행하는 `-c`(count) 플래그를 사용합니다. **이것이 중요한 이유**: `-c` 없이 `ping google.com`을 실행하면 계속해서 패킷을 보내고 출력을 무한정 인쇄합니다. 다른 명령을 실행하려면 `Ctrl+C`을 사용하여 수동으로 중단해야 합니다. `-c 3` 플래그는 정확히 3개의 패킷을 보낸 후 자동으로 명령을 중지합니다.

퀘스트 71잠김

네트워크 프린터를 설정하거나 동일한 Wi-Fi에서 친구의 컴퓨터와 파일을 공유하고 컴퓨터의 로컬 IP 주소를 알아야 한다고 상상해 보십시오. Linux에서는 `ip` 명령을 사용하여 네트워크 하드웨어와 IP를 검사합니다. - `ip addr`(또는 간단하게 `ip a`)을 실행하면 할당된 로컬 IP 주소와 함께 모든 네트워크 인터페이스 장치(예: 유선 이더넷의 경우 `eth0`, 무선의 경우 `wlan0`) 목록이 인쇄됩니다.

퀘스트 72잠김

최신 `ip` 명령 모음이 표준이 되기 전에 Linux 시스템 관리자는 `ifconfig`(인터페이스 구성자)을 사용하여 네트워크 인터페이스를 보고 관리했습니다. - `ifconfig` 명령은 활성 네트워크 인터페이스, 로컬 IP 구성, 넷마스크 세부 정보 및 MAC 하드웨어 주소를 표시합니다. 일부 최신 배포판에서는 더 이상 사용되지 않지만 레거시 서버에서는 여전히 널리 사용됩니다.

퀘스트 73잠김

최신 Linux 워크스테이션 및 서버에서 네트워크 인터페이스는 NetworkManager라는 시스템 데몬에 의해 관리됩니다. 구성 파일을 수동으로 편집하는 대신 `nmcli`을 사용하여 네트워크 세부 정보를 구성합니다. - `nmcli`(NetworkManager CLI) 명령을 사용하면 하드웨어 연결, 장치 상태 및 활성 Wi-Fi 네트워크를 검사할 수 있습니다.

퀘스트 74잠김

데이터베이스나 웹 서버를 설정할 때 서비스가 올바른 포트에서 실행되고 수신 대기 중인지 확인하고 승인되지 않은 연결이 설정되었는지 확인해야 합니다. `netstat` 또는 `ss`을 사용하여 이를 수행합니다. - `netstat`(네트워크 통계) 명령은 TCP 연결 및 수신 포트를 표시하는 고전적인 도구입니다. 예: `netstat -tuln`은 TCP/UDP 수신 포트를 나열합니다. - `ss`(소켓 통계) 명령은 커널 네임스페이스에서 직접 소켓 연결 세부 정보를 표시하는 `netstat`에 대한 현대적이고 빠른 대안입니다.

퀘스트 75잠김

웹 페이지 로드에 실패할 때 홈 라우터, 인터넷 서비스 공급자(ISP) 또는 대상 서버에 문제가 있는지 어떻게 식별합니까? Linux에서는 `traceroute`을 사용하여 패킷을 추적합니다. - `traceroute` 명령은 각 홉에 대한 응답 대기 시간과 함께 패킷이 원격 서버로 이동하는 동안 통과하는 모든 라우터 게이트웨이(홉)를 나열합니다.

퀘스트 76잠김

브라우저를 열거나 "다운로드" 버튼을 클릭하지 않고 웹 서버에서 직접 파일을 다운로드하거나 설정 스크립트의 코드를 가져오고 싶다고 상상해 보십시오. Linux에서는 `curl`("클라이언트 URL"의 약자)을 사용하여 웹 데이터를 가져옵니다. - `curl <url>`을 실행하면 페이지 콘텐츠가 다운로드되어 화면에 바로 인쇄됩니다. - 다운로드한 콘텐츠를 표시하는 대신 파일로 저장하려면 `>` 리디렉션 또는 `-o` 출력 플래그와 페어링합니다.

퀘스트 77잠김

When your machine translates a human-readable domain name like `example.com` into an IP address like `93.184.216.34`, it queries DNS nameservers configured in `/etc/resolv.conf`. - `/etc/resolv.conf`: Contains your system's primary and fallback DNS nameservers. - `dig <domain>`: The de-facto standard administrator tool for testing DNS queries, returning response headers, query latency, and record TTLs. Adding `+short` prints only the final IP answer. - `nslookup <domain>` and `host <domain>`: Lightweight queries for checking A/AAAA and MX mail exchange records.

퀘스트 78잠김

When your server sends a packet to an IP address outside its local subnet, how does the kernel know which router or network card interface to send it through? It consults the **Kernel IP Routing Table**. - `ip route` (or `ip r` / `ip ro`): Displays active routing table entries. - The line starting with `default via <IP> dev <interface>` defines your **Default Gateway** (your router), which handles all internet traffic not addressed to a local subnet.

퀘스트 79잠김

Two everyday network maintenance tasks are testing whether remote ports are open and downloading files without browsers: - `nc` (Netcat): Often called the "Swiss Army Knife" of TCP/IP. Running `nc -zv <host> <port>` scans a target port without sending application data (`-z` for zero-I/O port scanning, `-v` for verbose output), instantly confirming if a firewall or service is responding. - `wget`: The robust non-interactive network downloader. Running `wget -O <output-file> <url>` downloads files reliably, resuming broken connections.

퀘스트 80잠김

Every computer on a network possesses a hostname that identifies it to other machines and shell prompts (e.g., `learner@bashquest:~$`). In modern systemd environments: - `hostname`: Displays the current simple system hostname. - `hostnamectl`: Displays complete system identification metadata, including operating system release, kernel build version, hardware chassis, and virtualization hypervisor. - `sudo hostnamectl set-hostname <name>`: Persistently updates the hostname across reboots by modifying `/etc/hostname` and updating the systemd hostnamed daemon.

👑 Boss · 퀘스트 81잠김

SECURITY COMPROMISE: An attacker injected a DNS poisoning entry `0.0.0.0 evil-tracker.local` directly into `/etc/hosts`, corrupting internal hostname resolution. Remediate the threat: edit or clean `/etc/hosts` to remove all references to `evil-tracker.local`, and record `evil-tracker.local` in `/etc/blocked_hosts.conf` so the domain is permanently logged for network blacklisting.

9. 파일 및 명령어 검색

퀘스트 82잠김

사용자 폴더 어딘가에 중요한 텍스트 파일이 잘못 배치되어 수십 개의 중첩된 디렉터리를 하나씩 검색해야 한다고 상상해 보세요. Linux에서는 초고속 시스템 전체 검색 엔진인 `find` 유틸리티를 사용하여 수동 파기를 우회합니다. - `find` 명령은 이름, 크기, 유형 또는 날짜를 기준으로 디렉토리 트리를 검색합니다. - 구문은 `find <where> -name "<pattern>"`입니다. 예를 들어 `find . -name "*.txt"`은 현재 디렉터리와 모든 하위 폴더에서 `.txt`로 끝나는 파일을 검색합니다. **이것이 중요한 이유**: `-name` 없이 `find . "*.log"`을 실행하면 `find: paths must precede expression: '*.log'` 오류가 발생합니다. 후속 패턴이 파일 이름과 일치해야 함을 지정하려면 `-name` 플래그가 필요합니다.

퀘스트 83잠김

10분 전에 길고 복잡한 네트워크 진단 명령을 입력했는데 이제 다시 실행해야 하는데 정확한 옵션이나 구문을 기억할 수 없다고 가정해 보세요. 머리를 긁거나 다 입력하는 대신 Linux가 이를 기억합니다! - `history` 명령은 최근에 실행한 모든 명령의 번호가 매겨진 목록을 표시합니다. - 느낌표와 목록 번호를 차례로 입력하여 항목을 빠르게 다시 실행할 수 있습니다(예: 명령 #42를 다시 실행하려면 `!42`).

퀘스트 84잠김

새 명령을 사용하려고 시도하지만 해당 명령이 지원하는 플래그가 무엇인지, 입력 형식을 어떻게 지정해야 하는지 확신할 수 없다고 상상해 보십시오. 온라인으로 검색하는 대신 Linux에는 공식적이고 포괄적인 사용자 설명서가 터미널에 내장되어 있습니다! - `man`(수동) 명령 뒤에 유틸리티 이름(예: `man ls`)을 입력하면 자세한 참조 가이드가 열립니다. - 가이드 내에서 화살표 키로 스크롤하고 "/"로 검색한 다음 `q`를 눌러 매뉴얼을 닫고 프롬프트로 돌아갑니다.

퀘스트 85잠김

Beyond basic filename queries, `find` is a powerhouse filter engine for automated system cleanup and log rotation: - `-size +50M`: Filters for files strictly larger than 50 Megabytes (`+` for greater than, `-` for less than). - `-mtime -7`: Filters for files modified within the last 7 days. - `-exec <cmd> {} +`: Passes all matched files directly into a command in batches, replacing `{}` with matched file paths. Combining these allows single-line system maintenance, such as finding and purging runaway logs: `find /var/log -size +50M -exec rm {} +`.

퀘스트 86잠김

When `find` is too slow because it scans the live disk tree, and you need to inspect command binaries vs shell builtins: - `sudo updatedb`: Crawls the entire filesystem and builds a high-speed precomputed search index database (`mlocate.db`). - `locate <name>`: Instantly searches the indexed database in milliseconds instead of seconds. - `whereis <cmd>`: Locates binary executables, source files, and man pages in standard system paths. - `type <name>`: Identifies whether a command is a shell builtin (e.g. `cd`, `umask`), an alias (e.g. `ll`), or an external binary disk file (e.g. `/bin/ls`).

퀘스트 87잠김

When you know what task you want to achieve, but don't remember the exact Linux command name, or when you need a quick one-line summary of what an unfamiliar command does: - `apropos <keyword>`: Searches through the short one-line description summaries of **all manual pages** on the system, returning any command related to that concept (e.g. `apropos partition`, `apropos process`). - `whatis <cmd>`: Displays the exact single-line summary from section 1 or 8 of that specific tool's manual page (e.g. `whatis ls`, `whatis grep`).

👑 Boss · 퀘스트 88잠김

DISASTER RECOVERY: Before an unexpected reboot, a database administrator saved an encrypted backup archive named `db_backup_secure.tar.gz`, but failed to document its path. It is lost somewhere on the filesystem. Locate the misplaced archive file anywhere across the system hierarchy, and restore it to its designated safe haven: copy it to `/home/learner/backups/db_backup_secure.tar.gz`.

10. 서비스와 Systemd

퀘스트 89잠김

컴퓨터에서 웹 사이트를 호스팅하지만 백그라운드 웹 서버 프로그램이 실행되지 않아 방문자에게 "사이트에 연결할 수 없습니다"라는 오류가 표시된다고 상상해 보세요. Linux에서는 자동으로 시작되어 백그라운드에서 실행되는 백그라운드 프로세스(예: 데이터베이스, 방화벽 또는 웹 서버)를 **서비스**라고 하며 `systemctl`을 사용하여 관리합니다. - `systemctl status <service>` 명령은 서비스가 활성 상태인지 중지되었는지 확인합니다. - 서비스를 시작하거나 중지하면 모든 사용자와 시스템 보안에 영향을 미치므로 `sudo systemctl start <service>` 또는 `sudo systemctl stop <service>`와 같은 명령을 실행하려면 `sudo`을 사용해야 합니다.

퀘스트 90잠김

이제 `systemctl`을 사용하여 백그라운드 서비스를 시작하고 중지할 수 있습니다. 서비스가 실패할 경우 어떻게 문제를 해결합니까? `journalctl` 유틸리티를 사용하면 systemd가 관리하는 서비스에서 생성된 시스템 로그를 검사할 수 있습니다. - 기본적으로 `journalctl`는 모든 시스템 로그를 표시합니다. 이는 규모가 클 수 있으므로 집중할 수 있도록 필터링합니다. - `-u <service>` 옵션은 특정 서비스(예: `journalctl -u apache2`)의 메시지만 표시하도록 로그를 필터링합니다. - `-n <number>` 옵션은 가장 최근 항목만 표시합니다(예: 마지막 5개 로그의 경우 `journalctl -n 5`). - `-f`(follow) 플래그는 로그가 기록되는 대로 실시간으로 표시합니다.

퀘스트 91잠김

Starting a service with `systemctl start` only launches it for the current session. If the server reboots, the service will stay offline unless you configure it to start automatically on system initialization. - To start a service at boot, run `sudo systemctl enable <service>`. - To verify whether a service is scheduled to launch at boot, run `systemctl is-enabled <service>`. - When creating or editing systemd unit files, always notify systemd to reload its configuration cache with `sudo systemctl daemon-reload`. - To disable a service from starting at boot, run `sudo systemctl disable <service>`.

퀘스트 92잠김

Accurate system time is critical for log auditing, authentication protocols (Kerberos, TLS certificates), and scheduled database backups. - The `timedatectl` utility queries and changes the system clock and its timezone. - View the current time settings, RTC, and active timezone with `timedatectl status` (or simply `timedatectl`). - Set the system timezone using superuser rights: `sudo timedatectl set-timezone UTC`. - When shutting down or restarting production servers, use the `shutdown` command with safety delays and broadcast notices: `sudo shutdown -r now` (reboots immediately) or `sudo shutdown -c` (cancels scheduled shutdowns).

👑 Boss · 퀘스트 93잠김

OUTAGE REPORT: The primary HTTP frontend service `apache2.service` crashed and is currently in an `inactive (dead)` state. Client web requests are timing out. Inspect the service status with your service management tools, discover the problem, and use `systemctl` with superuser privileges to restart or start `apache2` so it returns to `active (running)`.

11. 터미널 텍스트 편집

퀘스트 94잠김

그래픽 데스크탑이나 커서가 없고 구성 파일의 한 줄을 신속하게 수정해야 하는 원격 클라우드 서버에 SSH를 사용한다고 상상해 보십시오. 이러한 시나리오에서는 `nano`과 같은 터미널 텍스트 편집기를 사용해야 합니다. - `nano <filename>`을 실행하면 쉘 창 내부에 직접 간단하고 가벼운 텍스트 편집기가 로드됩니다. - 단축키는 항상 화면 하단에 표시됩니다. 변경 사항을 기록(저장)하려면 `Ctrl+O`를 누르고 편집기를 종료하려면 `Ctrl+X`을 누르세요.

퀘스트 95잠김

Vim is one of the most powerful and ubiquitous terminal text editors in Linux. Unlike traditional graphical editors, Vim is **modal**: - **Normal Mode**: The default mode used for navigation, deleting, and issuing commands. - **Insert Mode**: The mode used for typing text. Press `i` from Normal Mode to start typing. - **Return to Normal Mode**: Press `Esc` at any time to leave Insert Mode. - **Command-Line Mode**: From Normal Mode, press `:` to type commands at the bottom prompt: - `:w` writes (saves) the file. - `:q` quits the editor. - `:wq` (or `:x`) saves and exits in one step. - `:q!` quits immediately, discarding all unsaved changes.

퀘스트 96잠김

Once you master Normal mode commands, Vim allows lightning-fast text manipulation without touching a mouse: - `dd`: Delete (cut) the entire current line into the yank buffer. - `yy`: Yank (copy) the current line. - `p`: Paste the yank buffer on the line below the cursor. - `/pattern`: Search forward through the file for text matching `pattern`. - `:%s/old/new/g`: Global search and replace throughout the entire file without manual edits.

👑 Boss · 퀘스트 97잠김

CONFIGURATION CORRUPTION: A late-night config commit broke `/home/learner/server.conf`. The file contains invalid directives: `host=0.0.0.0.0` (malformed IP) and `port=99999` (outside the 1-65535 port range). Open `/home/learner/server.conf` with your text editor (nano, vim, or shell tools) and correct the file so that `host=127.0.0.1`, `port=80`, and `max_connections=500` are set.

12. 셸 스크립트와 자동화

퀘스트 98잠김

매일 아침 실행해야 하는 20개의 작업 목록이 있다고 상상해 보세요. 수동으로 입력하는 것은 지루하고 오타가 발생할 여지가 있습니다. Linux에서는 명령을 쉘 스크립트라는 파일에 묶어서 한꺼번에 실행할 수 있습니다! - 모든 스크립트는 첫 번째 줄에 "shebang"(`#!/bin/bash`)으로 시작하여 파일을 실행하는 데 사용할 쉘 해석기를 시스템에 알려줍니다. - 스크립트를 저장한 후 `chmod 755 script.sh`을 통해 실행 권한을 부여한 다음 `./script.sh`로 실행하여 스크립트를 실행 가능하게 만듭니다.

퀘스트 99잠김

웹사이트에 대한 개인화된 환영 메시지를 생성한다고 상상해 보십시오. 모든 고객의 이름에 대해 별도의 스크립트를 작성하고 싶지는 않을 것입니다! 대신 실행 시 이름을 입력으로 사용하는 하나의 스크립트를 작성합니다. - Bash 스크립트에서 `$1`, `$2` 등과 같은 변수는 명령줄에서 전달하는 "인수" 또는 입력을 보유합니다. - 예를 들어 `./greet.sh Alice`를 실행하면 스크립트 내의 `$1`에 자동으로 "Alice"라는 텍스트가 포함됩니다. 마찬가지로 `$#`는 사용자가 제공한 입력 수를 추적합니다.

퀘스트 100잠김

CSV 보고서를 처리하는 스크립트를 작성하는데 보고서 파일이 실제로 디스크에 없으면 충돌이 발생한다고 상상해 보십시오. 오류를 방지하기 위해 `if/else` 조건부 논리를 사용하여 결정을 내리는 스크립트를 작성합니다. - 괄호를 사용하여 조건을 확인합니다: `if [ -f "$1" ]; then ... fi`. - `-f` 플래그는 경로가 파일을 가리키는지 확인하고, `-d`은 디렉터리인지 확인합니다. 스크립트는 조건이 true 또는 false로 평가되는지에 따라 작업을 분기합니다.

퀘스트 101잠김

100개의 로그 파일 폴더가 있고 모든 파일의 백업 복사본을 만들어야 한다고 상상해 보십시오. 개별적으로 복사하는 것은 지칠 것입니다. Linux에서는 `for` 루프를 사용하여 전체 항목 목록에 대해 동일한 작업을 자동으로 반복합니다! - `for` 루프(예: `for file in *.txt; do ... done`)는 패턴과 일치하는 모든 항목을 반복하여 순식간에 하나씩 처리합니다.

퀘스트 102잠김

스크립트에서 작업을 자동화하기 위해 루프와 조건문을 작성했습니다. 그러나 스크립트가 커짐에 따라 동일한 논리를 계속해서 복사하여 붙여넣으면 유지 관리가 어려워집니다. Bash에서는 명령을 재사용 가능한 기능으로 그룹화할 수 있습니다. - 함수를 정의하려면 이름 뒤에 괄호와 중괄호를 사용하여 선언합니다(`log_msg() { echo "msg"; }`). - 함수는 함수 본문 내에서 로컬 위치 매개변수 `$1`, `$2` 등을 사용하여 액세스되는 쉘 스크립트와 마찬가지로 인수를 받을 수 있습니다. - 함수를 호출하려면 다른 명령과 마찬가지로 해당 이름(`log_msg "Backup started"`)을 사용하면 됩니다.

퀘스트 103잠김

이제 강력한 쉘 스크립트를 작성했으므로 백업 도우미를 실행하기 위해 자정에 로그인하고 싶지 않을 것입니다. Linux는 특정 시간에 자동으로 명령이나 스크립트를 실행하는 `cron` 서비스를 제공합니다. - cron 서비스는 `crontab`이라는 예약 테이블을 확인합니다. - 각 cron 일정에는 시간을 나타내는 5개의 필드가 있습니다: `minute hour day-of-month month day-of-week` 뒤에 명령이 옵니다. - 예를 들어 `30 2 * * * /path/to/script.sh`은 매일 오전 2시 30분에 스크립트를 실행합니다. - `crontab -l`를 사용하여 활성 cron 작업을 나열하고 `crontab <filename>`를 사용하여 파일에서 일정을 로드합니다.

퀘스트 104잠김

Every command executed in Linux returns an **exit status code** between 0 and 255 upon completion: - `0`: Success (no errors occurred). - `1-255`: Failure or error code. - The special shell parameter `$?` stores the exit code of the immediately preceding command: `echo $?`. Shell logic operators chain commands based on exit codes: - `cmd1 && cmd2`: Logical AND. Runs `cmd2` **only if** `cmd1` succeeds (exit code 0). - `cmd1 || cmd2`: Logical OR. Runs `cmd2` **only if** `cmd1` fails (non-zero exit code). Combining them creates clean resilient commands: `mkdir backup && cp app.db backup/ || echo "Backup failed"`.

퀘스트 105잠김

Interactive and automated scripts rely on two essential shell capabilities: 1. **User Input (`read`)**: Prompts the user to enter data and stores the response in a shell variable. The `-p` flag prints a custom prompt string: `read -p "Enter username: " USERNAME` 2. **Command Substitution (`$(...)`)**: Executes a command in a subshell and substitutes its standard output into the variable or command line: `TODAY=$(date +%F)` This lets you create dynamic timestamped filenames and automated reports.

퀘스트 106잠김

Two of the most common control structures in systems engineering scripts are file-reading loops and case branches: 1. **File-reading `while` loop**: Reads input line by line safely using `read -r` without interpreting escape characters: `while read -r line; do echo "Processing: $line"; done < names.txt` 2. **`case` statement**: Matches a variable against multiple patterns cleaner than multiple `if/elif` blocks: `case $1 in start) systemctl start app ;; stop) systemctl stop app ;; *) echo "Usage: $0 {start|stop}" ;; esac`

👑 Boss · 퀘스트 107잠김

OPERATIONAL REQUIREMENT: Deploy an automated system health-check script at `/home/learner/healthcheck.sh`. The script must be a valid executable Bash script containing the `#!/bin/bash` shebang on line 1, must output the token `SYSTEM_OK`, and must have executable permissions (`755` or `rwxr-xr-x`) so monitoring agents can invoke it directly without errors.

13. 고급 텍스트 처리

퀘스트 108잠김

을 사용한 스트림 편집 거대한 데이터베이스 덤프 파일이 있고 이전 서버 IP 주소의 모든 항목을 새 주소로 바꿔야 한다고 가정해 보세요. 편집기에서 열면 컴퓨터가 정지될 수 있습니다. Linux에서는 `sed`("스트림 편집기"의 약자)을 사용하여 텍스트 스트림을 즉시 편집합니다. - 텍스트를 찾고 바꾸는 기본 구문은 `sed "s/old/new/g" file.txt`입니다. - `-i`(내부) 플래그를 추가하면 수정된 텍스트를 화면에 인쇄하는 대신 대체 항목을 파일 자체에 직접 다시 저장합니다. **이것이 중요한 이유**: `-i` 없이 `sed "s/port=80/port=8080/g" server.conf`을 실행하면 수정된 텍스트만 터미널 화면에 인쇄됩니다. 실제 파일은 완전히 변경되지 않은 상태로 유지됩니다. 변경 사항을 파일에 직접 저장하려면 `-i`(내부) 플래그가 필요합니다.

퀘스트 109잠김

을 사용한 데이터 추출 열이 쉼표나 공백으로 구분되어 있고 데이터의 첫 번째 열만 추출하면 되는 일반 텍스트로 저장된 큰 스프레드시트를 받았다고 상상해 보세요. Linux에서는 강력한 언어인 `awk`을 사용하여 구조화된 텍스트 열을 구문 분석합니다. - 기본적으로 `awk`은 줄을 공백으로 분할하여 열 1을 `$1`에 할당하고 열 2를 `$2`에 할당하는 식으로 진행합니다. - `-F` 플래그를 사용하면 사용자 정의 구분 기호(예: 콜론의 경우 `-F:`)를 지정할 수 있습니다. 예를 들어 `awk -F: '{print $1}' /etc/passwd`은 콜론으로 구분된 목록에서 사용자 이름만 추출합니다. **중요한 이유**: `-F:` 없이 `awk '{print $1}' /etc/shadow`을 실행하면 `awk`은 콜론이 아닌 공백(기본값)으로 줄을 분할합니다. 섀도우 파일 줄에는 공백이 없으므로 전체 줄이 단일 필드로 처리되어 모든 사용자의 전체 해시 세부 정보가 인쇄됩니다. `-F:` 플래그는 `awk`이 대신 콜론으로 열을 분할하도록 강제합니다.

퀘스트 110잠김

거래 날짜와 이름이 포함된 CSV 스프레드시트로 작업한다고 상상해 보세요. 일관성을 위해 첫 번째 열(날짜)만 추출하고 모든 텍스트를 대문자로 변환하려고 합니다. Linux에서는 파이프라인에 경량 구문 분석 도구를 결합할 수 있습니다. - `cut` 명령은 구조화된 텍스트에서 특정 열을 분할합니다. 예를 들어 `cut -d, -f1`은 줄을 쉼표(`-d,`)로 나누고 첫 번째 열(`-f1`)을 추출합니다. - `tr`(번역) 명령은 소문자를 대문자(`tr "a-z" "A-Z"`)로 바꾸는 것과 같이 표준 입력의 문자를 변환합니다. **이것이 중요한 이유**: `-d,` 및 `-f1` 없이 `cut reports.csv`을 실행하면 `cut: you must specify a list of bytes, characters, or fields`이 표시됩니다. `-f1`을 지정하고 `-d,`을 생략하면 기본값은 탭으로 설정됩니다. 즉, CSV 파일을 분할하지 않고 전체 줄만 인쇄한다는 의미입니다. `-d,` 플래그는 쉼표를 열 구분 기호로 정의하고 `-f1`은 첫 번째 열만 추출하도록 지시합니다.

퀘스트 111잠김

Modern cloud infrastructure, Kubernetes, Docker, and REST APIs all communicate in JSON. The `jq` command-line JSON processor is the industry standard tool for slicing, filtering, and mapping structured JSON data in terminal pipelines. - Pretty-print and syntax validate JSON: `cat api.json | jq '.'` (or `jq '.' api.json`). - Extract specific keys: `jq '.version' api.json`. - Access array items and nested object fields: `jq '.users[0].name' api.json`. - Output unquoted raw strings (ideal for shell variables): `jq -r '.users[0].name' api.json`.

퀘스트 112잠김

When troubleshooting DDoS attacks, brute force login attempts, or high-traffic API endpoints, sysadmins rely on one classic pipeline composed of `sort`, `uniq -c`, and `sort -nr`. 1. `sort access.log`: Groups identical lines together (a mandatory prerequisite for `uniq`). 2. `uniq -c`: Counts the number of duplicate occurrences for each unique line, prefixing each line with its tally count. 3. `sort -nr`: Sorts the tally lines **numerically** (`-n`) and in **reverse** (`-r`) order so the most frequent occurrences appear at the top. 4. `head -n 5`: Isolates the top 5 most frequent entries.

퀘스트 113잠김

Binary executables and database files cannot be read with `cat` or text editors without corrupting the terminal display. Linux provides dedicated tools for inspecting compiled binaries and memory dumps: - `strings <file>`: Scans binary files and extracts continuous human-readable ASCII/UTF-8 character sequences (defaulting to 4+ characters). Essential for finding hardcoded URLs, secret keys, version strings, or embedded error messages in compiled software. - `xxd <file>` or `hexdump -C <file>`: Creates a canonical two-column hexadecimal and ASCII dump of binary files to inspect magic bytes (like `ELF` headers) and binary data offsets.

👑 Boss · 퀘스트 114잠김

ETL DATA INCIDENT: A legacy mainframe exported `/home/learner/messy_data.csv` using unconventional formatting: fields are separated by colons and rows end with semicolons (`alice:dev:engineering;`). The analytics ingestion engine rejects this format. Transform the file into clean CSV format at `/home/learner/clean_users.csv`, containing only the user and department (fields 1 and 3) separated by commas (`alice,engineering`), with semicolons stripped.

14. 환경 변수 및 셸 설정

퀘스트 115잠김

웹 응용 프로그램을 배포하고 안전한 로컬 "개발" 샌드박스에서 실행할지 아니면 라이브 "프로덕션" 데이터베이스에 연결할지 알아야 한다고 가정해 보겠습니다. Linux에서는 **환경 변수**를 사용하여 이와 같은 구성을 실행 중인 프로그램에 전달합니다. - `export` 명령을 사용하여 쉘에서 시작한 모든 프로그램이 변수를 읽을 수 있도록 변수를 정의합니다. 예: `export APP_ENV=production`. - 변수 값을 확인하거나 표시하려면 이름 앞에 달러 기호(`echo $APP_ENV`)를 붙입니다.

퀘스트 116잠김

프로그램 경로를 찾을 수 없기 때문에 계속 실패하는 스크립트를 디버깅하려고 하거나 이 터미널에서 어떤 사용자 계정이 활성화되어 있는지 확인하려고 한다고 상상해 보십시오. Linux에서는 이러한 모든 세션 전체 구성이 함께 저장됩니다. - `env` 명령은 현재 활성 세션에 로드된 모든 환경 변수의 전체 디렉터리를 인쇄하므로 구성을 한 번에 확인할 수 있습니다.

퀘스트 117잠김

이제 `PATH`(Linux가 명령을 찾는 디렉터리를 저장하는)과 같은 활성 환경 변수에 익숙해졌으므로 `ls` 또는 `grep`를 입력할 때 실행되는 프로그램의 정확한 파일 경로를 어떻게 찾을 수 있습니까? `which`을 사용하여 명령 바이너리를 찾습니다. - `which` 명령은 `$PATH` 변수에 나열된 폴더를 검색하고 명령이 실행될 때 실행된 바이너리의 절대 경로를 인쇄합니다(예: `which ls`은 `/bin/ls`을 출력합니다). - 도구가 설치된 위치를 찾거나 동일한 도구의 여러 버전 간의 충돌을 해결하는 데 유용합니다.

퀘스트 118잠김

여러 플래그를 사용하여 긴 명령을 입력하면 지칠 수 있습니다. Linux에서는 별칭이라는 사용자 정의 바로가기를 만들 수 있습니다. 예를 들어 `ll`을 매핑하여 `ls -la`을 자동으로 실행할 수 있습니다. - 임시 별칭을 만들려면 `alias name='command'`(예: `alias ll='ls -la'`)를 실행하세요. - 인수 없이 `alias`을 실행하면 현재 세션의 모든 활성 별칭이 나열됩니다. - 재부팅 시 별칭을 영구적으로 만들기 위해 일반적으로 `.bashrc` 또는 `.bash_profile` 구성 파일에 기록됩니다.

퀘스트 119잠김

When you edit your startup scripts like `~/.bashrc` to add new environment variables or aliases, those changes do not automatically affect your current shell session. Traditionally, users had to log out and log back in. In Linux, we use the `source` command (or its POSIX shorthand `.`) to read and execute commands from a file directly in the current shell context. - Syntax: `source ~/.bashrc` or `. ~/.bashrc` - This loads newly defined variables, updated `$PATH` directories, and aliases immediately without killing your session.

퀘스트 120잠김

During debugging or deployment, you may temporarily export sensitive API keys, database credentials, or create test shortcuts. Leaving these variables active in your environment can cause security leaks or unintended script behavior. Linux provides `unset` to delete variables and `unalias` to delete custom command shortcuts. - `unset SECRET_KEY`: Permanently deletes the `SECRET_KEY` variable from the current environment. - `unalias la`: Removes the shortcut `la` so typing `la` no longer executes `ls -a`.

👑 Boss · 퀘스트 121잠김

SECURITY BREACH: A malicious session injected a backdoor path `/tmp/evil_bin` into `/home/learner/.bashrc`, attempting to hijack user commands. Eradicate the persistence mechanism: clean `/home/learner/.bashrc` by removing all references to `evil_bin`, and delete the `/tmp/evil_bin` directory entirely from the system.

15. 아카이빙, 백업 및 체크섬

퀘스트 122잠김

500개의 서버 로그가 포함된 폴더가 있고 이를 동료에게 이메일로 보내거나 클라우드 스토리지에 백업한다고 가정해 보세요. 500개의 개별 파일을 보내는 것은 느리고 비효율적입니다. Linux에서는 `tar`("테이프 아카이브"의 약자)을 사용하여 압축된 단일 zip 형식 파일로 압축합니다. - `-c`(생성), `-z`(gzip으로 압축), `-v`(자세한 파일 목록) 및 `-f`(파일 이름 지정) 플래그를 사용하여 압축된 아카이브를 생성합니다. 예를 들어 `tar -czvf backup.tar.gz folder/`는 디렉터리를 묶고 압축합니다. **이것이 중요한 이유**: `-f` 없이 `tar -cz logs.tar.gz logs`을 실행하면 `tar: Refusing to write archive contents to terminal`이 표시됩니다. `-f` 플래그는 원시 바이너리 아카이브 데이터를 터미널에 직접 보내는 대신 파일에 출력을 쓰도록 `tar`에 지시하기 때문에 중요합니다. 아카이브를 각각 생성하고 압축하려면 `-c` 및 `-z` 플래그도 필요합니다.

퀘스트 123잠김

대규모 데이터 세트가 포함된 단일 텍스트 파일이 있고 디스크 공간을 절약하거나 공유 속도를 높이기 위해 크기를 줄이고 싶다고 가정해 보십시오. Linux에서는 `gzip`을 사용하여 개별 파일을 압축하고 `gunzip`을 사용하여 복원합니다. - `gzip <filename>` 명령은 파일을 압축하여 `.gz`으로 끝나는 압축 버전으로 바꿉니다(예: `backup.txt`는 `backup.txt.gz`가 됩니다). - `gunzip <filename.gz>` 명령은 파일의 압축을 풀어 원래 버전을 복원합니다.

퀘스트 124잠김

`tar` 및 `gzip`은 Linux에서 표준이지만 `zip`는 크로스 플랫폼 세계(Windows/macOS)에서 가장 일반적인 보관 형식입니다. Linux에서는 `zip`을 사용하여 파일을 zip 파일로 패키징하고 압축한 다음 `unzip`를 사용하여 추출합니다. - `zip <archive.zip> <files>` 명령은 zip 아카이브를 생성합니다. - `unzip <archive.zip>` 명령은 아카이브에서 파일을 추출합니다.

퀘스트 125잠김

`gzip` 및 `zip` 외에도 Linux는 CPU 속도를 희생하면서 더 높은 압축 비율에 최적화된 다른 압축 형식을 지원합니다. 이는 `bzip2`(bz2) 및 `xz`(xz)입니다. - `bzip2 <file>` 명령은 파일을 압축하여 `<file>.bz2`을 출력합니다. - `xz <file>` 명령은 무손실 LZMA 압축을 사용하여 `<file>.xz`을 생성합니다. 이는 매우 작은 파일 크기를 생성하므로 Linux 커널 릴리스에 이상적입니다.

퀘스트 126잠김

`/var/www/html/configs/app/settings.conf`과 같은 중첩 폴더에 구성 파일이 깊이 묻혀 있지만 이를 지속적으로 편집해야 한다고 가정해 보십시오. 매번 긴 폴더 경로를 입력하는 대신 빠른 바탕 화면 바로 가기가 필요합니다. Linux에서는 링크를 생성하여 이를 수행합니다. - **하드 링크**: 원시 파일 데이터를 가리키는 직접 복제입니다. 원본 파일을 삭제해도 링크는 계속 작동합니다. - **심볼릭 링크(소프트 링크)**: 경로 기반 단축키(Windows 단축키와 동일)입니다. 원본파일을 삭제하시면 링크가 깨집니다. `ln -s target link_name`을 사용하여 생성합니다. **이것이 중요한 이유**: `-s` 없이 `ln logs/app.log app_link.log`을 실행하면 기호 바로가기 대신 하드 링크가 생성됩니다. 파일이 다른 디스크 파티션에 있는 경우 `ln: failed to create hard link: Invalid cross-device link`이 표시됩니다. `-s` 플래그는 다양한 드라이브와 디렉터리에서 작동하는 유연한 기호 링크(바로가기)를 생성합니다.

퀘스트 127잠김

100개의 임시 파일을 반환하는 검색을 실행했는데 이제 모든 파일을 삭제하려고 한다고 가정해 보겠습니다. 검색 출력은 화면에 표시된 텍스트 이름 목록일 뿐입니다. 이러한 이름을 삭제 명령에 직접 입력하려면 어떻게 해야 할까요? Linux에서는 `xargs`을 사용하여 이 격차를 해소합니다. - `xargs`(인수 실행) 명령은 표준 입력(`find`의 파일 목록과 같은) 행을 가져와서 이를 다른 명령에 대한 인수로 하나씩 제공합니다. - 예를 들어 `find . -name "*.tmp" | xargs rm`은 모든 임시 파일을 찾아 한 번에 모두 제거합니다.

퀘스트 128잠김

DANGLING LINK ALERT: Following a log consolidation migration, the operational link at `/home/learner/links/current_log` became dangling because its original target was moved. Repair the link farm: update the symbolic link `/home/learner/links/current_log` so it points directly to the real system logging destination `/var/log/syslog`.

퀘스트 129잠김

While `cp` blindly copies entire files every time, `rsync` (remote sync) uses a delta-transfer algorithm to copy only files and bytes that have changed. It is the gold standard for server migrations, incremental directory backups, and continuous mirroring. - `-a` (archive): Preserves timestamps, symlinks, permissions, and operates recursively. - `-v` (verbose): Shows which files are being copied. - `-z` (compress): Compresses file data during transmission. - Notice trailing slashes: `rsync -avz src/ backup/` copies the contents of `src/` inside `backup/`.

퀘스트 130잠김

When downloading critical software, ISO images, or backup tarballs over the network, files can become corrupted by transmission errors or tampered with by malicious actors. In Linux, cryptographic checksums verify file integrity bit-for-bit. - `sha256sum <file>`: Computes a 256-bit SHA-2 cryptographic hash. - `md5sum <file>`: Computes a 128-bit MD5 digest. - If a single bit in the file changes, the entire hash string changes completely (the avalanche effect).

퀘스트 131잠김

Sometimes system administrators need to manipulate raw disk blocks rather than regular filesystem files—such as creating empty swapfiles, zeroing out drives, or writing ISO images directly to USB disks. We use `dd` (dataset definition). - `dd if=<source> of=<destination> bs=<block_size> count=<number>` clones raw blocks. - E.g. `dd if=/dev/zero of=disk.img bs=1M count=1` creates a 1MB dummy disk file filled with null bytes. - When automation scripts require scratch files without race conditions or overwriting existing user data, `mktemp` creates uniquely named files under `/tmp`.

👑 Boss · 퀘스트 132잠김

DATA INTEGRITY INCIDENT: The nightly backup pipeline flagged a corrupted archive in `/home/learner/backups/data_backup.tar.gz`. The mission-critical archive failed integrity checks. 1. Run `sha256sum -c checksums.sha256` inside `/home/learner/backups` (or `sha256sum -c /home/learner/backups/checksums.sha256`) to confirm the corrupted file (`FAILED`). 2. Overwrite the corrupted archive by copying the pristine valid backup from the system cache at `/var/backups/data_backup.tar.gz` into `/home/learner/backups/data_backup.tar.gz`. 3. Re-verify the backup using `sha256sum -c checksums.sha256` to confirm integrity (`data_backup.tar.gz: OK`).

16. 원격 접속 및 사용자 관리

퀘스트 133잠김

지금까지 `learner` 사용자로 작업했습니다. 그러나 실제 서버에서는 시스템 관리자가 여러 계정을 관리해야 합니다. 새로운 사용자를 추가하고 비밀번호를 설정하는 방법을 알아보세요. - `useradd` 명령은 새로운 사용자 계정을 생성합니다. 계정 생성은 시스템 보안에 영향을 미치므로 수퍼유저 권한(예: `sudo useradd deployer`)으로 실행해야 합니다. - `passwd` 명령은 사용자의 비밀번호를 설정하거나 변경합니다. 배포자 사용자의 비밀번호를 설정하려면 `sudo passwd deployer`로 실행하세요.

퀘스트 134잠김

`useradd`은 단순히 시스템 구성 파일에 사용자 세부 정보를 등록하는 하위 수준 유틸리티인 반면, Debian/Ubuntu 시스템은 홈 폴더 생성, 암호 설정 및 셸 환경 초기화를 자동화하는 `adduser`이라는 상위 수준 대화형 스크립트를 제공합니다. 반대로 `userdel`는 사용자 계정을 완전히 삭제합니다. - `sudo adduser tester`을 실행하면 사용자 구성을 대화형으로 안내합니다. - `sudo userdel tester`을 실행하면 사용자 계정이 삭제됩니다.

퀘스트 135잠김

권한 오류 문제를 해결할 때 실행 중인 정확한 사용자 및 그룹 식별자 컨텍스트를 확인해야 합니다. `id`을 사용하여 이 작업을 수행합니다. - `id`을 실행하면 현재 사용자의 사용자 ID(UID), 기본 그룹 ID(GID) 및 모든 보조 그룹 목록이 인쇄됩니다. - `id <username>`를 실행하면 특정 사용자에 대한 정보를 쿼리합니다.

퀘스트 136잠김

Linux에서는 사용자가 **그룹**으로 구성되어 권한을 쉽게 공유할 수 있습니다. 예를 들어 모든 개발자는 `developers`이라는 그룹에 속할 수 있습니다. 이를 통해 팀 전체와 동시에 파일을 공유할 수 있습니다. - `groupadd` 명령은 새 그룹을 생성합니다. 이는 시스템 구성이므로 슈퍼유저 권한(예: `sudo groupadd developers`)이 필요합니다. - `groups [username]` 명령은 사용자가 속한 모든 그룹을 나열합니다. 인수 없이 실행하면 현재 사용자에 대한 그룹이 표시됩니다.

퀘스트 137잠김

프로젝트 팀이 서비스를 재구성하거나 서비스를 해제할 때 해당 보안 그룹을 정리해야 합니다. Linux에서는 `groupdel`을 사용하여 그룹을 삭제합니다. - `groupdel <group_name>` 명령은 시스템 구성 파일에서 그룹을 영구적으로 삭제하므로 수퍼유저 권한이 필요합니다.

퀘스트 138잠김

이제 `deployer` 계정을 생성했으므로 해당 계정에 로컬로 로그인하여 환경을 테스트하려면 어떻게 해야 합니까? Linux에서는 로그아웃하지 않고 계정을 전환하려면 `su`(사용자 대체) 명령을 사용합니다. - `su <username>` 명령은 현재 터미널 쉘을 해당 사용자의 세션으로 전환합니다. - 전환 시 `whoami`을 실행하면 새 사용자 이름이 반영됩니다. - 원래 사용자 계정 세션으로 돌아가려면 `exit`을 입력하거나 `Ctrl+D`를 누르십시오.

퀘스트 139잠김

사용자를 로컬로 전환하는 것은 유용하지만 클라우드 컴퓨팅에서는 서버가 원격 데이터 센터에 있습니다. 네트워크를 통해 안전하게 연결하기 위해 `ssh`(Secure Shell)을 사용합니다. - `ssh` 명령은 도청을 방지하기 위해 시스템과 원격 호스트 간의 연결을 암호화합니다. - 구문: `ssh user@hostname` 또는 `ssh user@ip_address`(예: `ssh admin@192.168.1.100`). - 첫 번째 연결에서는 고유한 ECDSA 지문을 표시하여 원격 호스트의 신뢰성을 확인하라는 메시지가 표시됩니다. **참고:** 이는 브라우저 기반 샌드박스이므로 연결할 실제 원격 서버가 없습니다. 이 명령을 실행하면 실제 라이브 대화형 세션이 아닌 예상되는 실제 출력 패턴(호스트 확인, 연결, 세션)이 즉시 표시됩니다. 실제 터미널에서 ssh는 `exit`를 입력할 때까지 완전히 별도의 원격 셸로 이동합니다.

퀘스트 140잠김

이제 SSH를 통해 원격 서버에 로그인하는 방법을 알았으니 로컬 파일(예: 백업 아카이브)을 어떻게 복사합니까? `scp`(보안 복사) 명령은 내부적으로 SSH를 사용하여 호스트 간에 파일을 안전하게 복사합니다. - 구문은 `scp source_path user@host:destination_path`입니다. - 예를 들어 `scp log.txt admin@192.168.1.100:/tmp/`는 로컬 `log.txt` 파일을 원격 `/tmp/` 폴더에 복사합니다. **참고:** SSH와 마찬가지로 여기에는 실제 원격 서버가 없습니다. 이 명령을 실행하면 로컬 파일이 존재하는지 확인하고 예상되는 전송 출력이 표시되지만 실제로 데이터를 어디로도 보내지는 않습니다.

퀘스트 141잠김

When onboarding engineers or automation service accounts, you must configure their supplementary group memberships and default login shells. In Linux, `usermod` modifies existing accounts in `/etc/passwd` and `/etc/group`. - `-aG <group>`: Appends the user to supplementary groups without removing them from existing groups. (CRITICAL: omitting `-a` would replace all existing secondary groups!). - `-s <shell>`: Specifies the new login shell (e.g. `/bin/bash` or `/usr/sbin/nologin`).

퀘스트 142잠김

Password authentication on remote SSH servers is vulnerable to brute-force attacks and credential stuffing. Production infrastructure relies on asymmetric SSH keypair authentication. - `ssh-keygen -t ed25519`: Generates a high-security Ed25519 public/private keypair (`~/.ssh/id_ed25519` and `~/.ssh/id_ed25519.pub`). - `ssh-copy-id deployer@192.168.1.50`: Automatically appends your local public key to the remote user's `~/.ssh/authorized_keys` file, enabling passwordless login.

퀘스트 143잠김

When investigating unexpected system load or performing security audits on multi-tenant servers, you must know who is logged in and what commands they are executing. - `who`: Prints logged-in usernames, terminal devices (TTY/PTS), and login timestamps. - `w`: Comprehensive snapshot showing system uptime, load averages, logged-in users, and their currently running processes. - `last`: Parses `/var/log/wtmp` to show recent system reboot and user login history.

퀘스트 144잠김

When working over SSH, closing your laptop lid or losing Wi-Fi sends a hangup signal (SIGHUP) that immediately terminates your long-running builds, database dumps, and tests. A terminal multiplexer like `tmux` runs persistent virtual terminals on the server independent of your SSH connection. - `tmux new -s <name>`: Starts a new persistent session. - `tmux ls`: Lists all running sessions. - `tmux attach -t <name>`: Re-attaches to a running session from any computer at any time.

👑 Boss · 퀘스트 145잠김

FINAL SECURITY AUDIT: An intrusion detection audit revealed that an unauthorized user account `backdoor` was quietly added to `/etc/passwd`, and an unauthorized administrative group `rogue_admins` was added to `/etc/group`. Audit and cleanse the authentication databases: inspect the files with `cat` or `grep`, safely remove the `backdoor` user using `sudo userdel backdoor`, and delete the `rogue_admins` group using `sudo groupdel rogue_admins`. Verify that both unauthorized entries have been completely eradicated.

17. Git 및 리눅스 컨테이너

퀘스트 146잠김

Modern Linux servers and cloud infrastructure rely on Git for version control, continuous integration, and infrastructure-as-code deployments. Let's master the core introspection commands. - `git status`: Checks working tree and staging area state, revealing modified, untracked, and staged files. - `git diff`: Shows line-by-line differences between modified files and the last commit. - `git log`: Displays commit hashes, author metadata, and change messages.

퀘스트 147잠김

Docker encapsulates applications inside isolated Linux cgroups and namespaces (containers). As a DevOps engineer or sysadmin, troubleshooting containerized workloads requires inspecting running containers and executing commands within their namespaces. - `docker ps`: Lists running containers, container IDs, images, uptime, and mapped network ports. - `docker logs <container>`: Streams standard output and error logs generated by the containerized service. - `docker exec -it <container> <command>`: Executes an interactive or diagnostic command directly inside the container namespace.

퀘스트 148잠김

In Git version control, modifications made to working files must be staged before they can be committed into repository history. - `git add <file>`: Stages modified files into the index (e.g., `git add server.js`), preparing them for commit. - `git commit -m "<message>"`: Records a permanent snapshot of staged changes with a descriptive message (e.g., `git commit -m "Fix config"`). - `git branch`: Lists all local repository branches and indicates the currently active branch with an asterisk.

퀘스트 149잠김

Managing microservices in production requires controlling container lifecycle states when restarting services after configuration changes or stopping unneeded containers. - `docker restart <name>`: Gracefully stops and immediately starts a running container (e.g., `docker restart web-api`). - `docker stop <name>`: Stops an actively running container (e.g., `docker stop web-api`). - `docker start <name>`: Boots up an existing stopped container without creating a new instance (e.g., `docker start web-api`).

👑 Boss · 퀘스트 150잠김

PRODUCTION OUTAGE: The production web service in container `web-api` is failing health checks because `server.js` was modified with the wrong port. 1. Check the failure logs using `docker logs web-api`. 2. Inspect the repository changes using `git status` and `git diff`. 3. Stage the fix by running `git add server.js`. 4. Commit the fix with `git commit -m "Fix port binding for production"`. 5. Restart the containerized service using `docker restart web-api` to apply the hotfix.