💻 Programming

Linux

Linux

An open-source operating system. The server standard. Ubuntu, CentOS, Alpine. A Unix-like kernel-based OS developed by Linus Torvalds in 1991.

📖 Detailed Explanation

Linux is an open-source operating system kernel that Finnish university student Linus Torvalds began developing in 1991. While carrying on the UNIX philosophy, it was designed so that anyone can freely use and modify it. It has now grown into the largest collaborative software project in history, with thousands of developers around the world participating.

Linux is a representative open-source project distributed under the GNU General Public License (GPL). The GPL guarantees the free use, modification, and redistribution of source code, and derivative works must also be released under the same license. This "copyleft" philosophy drove the explosive growth of the Linux ecosystem.

Major Linux distributions include Ubuntu (beginner-friendly, for both desktop and server), CentOS/Rocky Linux (for enterprise servers, RHEL-compatible), Debian (stability-focused, server standard), and Alpine (ultra-lightweight, optimized for containers). Each distribution differs in its package manager (apt, yum, apk, etc.) and default settings, so you should choose one that fits your use case.

Linux is used on more than 90% of the world's servers and as the core OS of cloud infrastructure (AWS, GCP, Azure). Linux is also the standard in Android smartphones, embedded systems such as Raspberry Pi, AI/ML workloads, and supercomputers (100% of the TOP500). Docker containers and Kubernetes are also based on Linux kernel technologies (cgroups, namespaces).

💻 Code Example

# ========================================
# Linux 기본 명령어 예제
# ========================================

# 1. 파일/디렉토리 조회 (ls)
ls -la /var/log           # 숨김 파일 포함, 상세 정보 표시
ls -lh                      # 파일 크기를 읽기 쉽게 표시 (KB, MB)
ls -lt                      # 수정 시간순 정렬

# 2. 텍스트 검색 (grep)
grep -r "error" /var/log    # 디렉토리 내 재귀 검색
grep -i "warning" app.log   # 대소문자 구분 없이 검색
grep -n "TODO" *.py         # 줄 번호와 함께 출력
grep -v "^#" config.conf    # 주석 제외한 라인만 출력

# 파이프와 함께 사용
cat /var/log/syslog | grep "failed" | tail -20

# 3. 파일 권한 변경 (chmod)
chmod 755 script.sh         # rwxr-xr-x (실행 스크립트용)
chmod 644 config.json       # rw-r--r-- (설정 파일용)
chmod 600 id_rsa            # rw------- (SSH 키, 소유자만)
chmod +x deploy.sh          # 실행 권한 추가
chmod -R 755 /var/www       # 디렉토리 재귀 적용

# 4. 시스템 서비스 관리 (systemctl)
systemctl status nginx      # 서비스 상태 확인
systemctl start nginx       # 서비스 시작
systemctl stop nginx        # 서비스 중지
systemctl restart nginx     # 서비스 재시작
systemctl enable nginx      # 부팅시 자동 시작
systemctl disable nginx     # 자동 시작 해제

# 서비스 로그 확인
journalctl -u nginx -f      # 실시간 로그 스트리밍
journalctl -u nginx --since "1 hour ago"

# 5. 실무 필수 추가 명령어
ps aux | grep python       # 프로세스 확인
top -c                      # CPU/메모리 실시간 모니터링
df -h                       # 디스크 사용량
free -h                     # 메모리 사용량
netstat -tulpn              # 열린 포트 확인
tail -f /var/log/syslog    # 실시간 로그 모니터링

🗣️ Examples of Practical Conversations

In an infrastructure setup meeting - Choosing a distribution

"Let's standardize production servers on Ubuntu LTS 22.04. It has 5 years of long-term support, so there's no need to worry about security patches, and most clouds provide official images. Since CentOS has moved to Stream and there is controversy over its stability, we should consider Rocky Linux or AlmaLinux as alternatives. If we use Alpine for the container base image, the size is around 5MB, so build speed gets much faster."

In a technical interview - Process vs. thread

"In Linux, a process is an execution unit with its own independent memory space, and a thread is a lightweight execution unit that shares memory within the same process. When you create a process with fork(), memory is duplicated using COW (Copy-on-Write), and when you create a thread with pthread_create(), the heap and global variables are shared. Threads have lower context-switching cost, but a bug in one thread can kill the entire process, so use processes when isolation is needed."

During incident response - Server troubleshooting

"The server is responding slowly. First, let's check CPU and memory with top, and look for kernel errors with dmesg | tail. We also need to check with df -h whether the disk is full. Log files have filled up the disk before. If it's a network problem, check the number of connections with netstat -an | grep ESTABLISHED, and we should also look at I/O bottlenecks with iotop. With strace -p [PID], we can trace down to the system call level."

Infrastructure code review - Dockerfile optimization

"If you use Alpine instead of an Ubuntu base image in this Dockerfile, the image size drops from 800MB to 50MB. Also, merge the RUN commands into one and clean up the cache at the end with apt-get clean && rm -rf /var/lib/apt/lists/*. Use a multi-stage build to exclude build tools from the final image. For security, please also add running as a regular user instead of root."

Take a mock interview on this topic → WIA SOOM AI Interview · Start for free

📊 Comparison of Major Distributions

Distribution Package Management Features Use case
Ubuntu apt Beginner-friendly, 5-year LTS support 🏆 General-purpose (recommended)
Debian apt Extreme stability, slow updates Servers, security-focused
Rocky/Alma dnf/yum RHEL-compatible, enterprise-grade Enterprise servers, finance
Alpine apk 5MB ultra-lightweight, musl libc 🐳 Container base
Arch pacman Rolling release, latest packages Developer desktop

💡 Practical tip: Start with Ubuntu LTS; for production servers, Debian/Ubuntu LTS; for containers, Alpine; for enterprise, Rocky Linux is recommended. Package manager commands differ, so you need to learn them according to your distribution.

⚠️ Cautions

1
Do not abuse root privileges

Logging in directly as root or adding sudo to every command is a risky habit. A single mistake like rm -rf / can destroy the system. Work with a regular user account and use sudo only when truly necessary. Disabling SSH root login is a security baseline.

2
Firewall configuration is essential

When exposing a server to the internet, be sure to configure a firewall (ufw, firewalld, iptables). Open only the necessary ports (22, 80, 443, etc.) and block the rest. In the cloud, it is safer to configure it in two layers together with Security Groups.

3
Systematize log monitoring

Check the logs in the /var/log directory regularly, and set up log rotation with logrotate. If log files fill up the disk, the server will stop. For critical servers, it is advisable to build a centralized log collection system (ELK, Loki) and set up real-time monitoring and alerts.

🔗 Related Terms

📚 Learn More