0Pricing
Linux Command Line Mastery · 강의

프로세스 관리: `kill`, `bg`, `fg`

명령줄에서 프로세스를 효과적으로 종료하고 일시 중지하고 재개하는 방법을 배웁니다.

프로세스 관리: `kill`, `bg`, `fg`은(는) CoddyKit의 무료 Linux Command Line Mastery 강의입니다. 이것은 4개 중 2번째 강의입니다. 아래에서 전체 강의를 무료로 읽을 수 있으며, 내장 코드 에디터와 24/7 AI 튜터와 함께 브라우저에서 직접 실습할 수 있습니다. 이 강의는 Linux Command Line Mastery 학습 경로의 일부이며, 진행 상황이 웹과 CoddyKit 앱에 동기화됩니다. Linux Command Line Mastery 강의에는 총 4개의 강의가 포함되어 있습니다.

이 강의의 일부는 아직 번역되지 않았으며 영어로 표시됩니다.

Introduction to Process Control

In Linux, every running program is called a process. Managing these processes is essential for system efficiency and troubleshooting.

This lesson teaches you how to take control of processes: suspending them, sending them to the background, bringing them forward, and even terminating them when they misbehave.

The `kill` Command Basics

The kill command is used to send signals to processes. Its primary use is to terminate processes.

To use kill, you need the Process ID (PID) of the target process. You can find PIDs using commands like ps (covered in a previous lesson).

ps aux | grep sleep

Graceful Termination: `SIGTERM`

By default, kill sends the SIGTERM (signal 15) signal. This is a polite request for a process to terminate.

A well-behaved program will catch SIGTERM, perform any necessary cleanup (like saving files), and then exit gracefully.

sleep 30 &
# Use 'ps' to find the PID of 'sleep 30'
# Example: kill <PID_OF_SLEEP>

Forceful Termination: `SIGKILL` (-9)

Sometimes, a process might ignore SIGTERM, becoming unresponsive or 'frozen'. In such cases, you need to use a stronger signal: SIGKILL (signal 9).

SIGKILL immediately terminates the process without allowing it to clean up. Use it as a last resort!

sleep 60 &
# Use 'ps' to find the PID of 'sleep 60'
# Example: kill -9 <PID_OF_SLEEP>

Suspending Processes with Ctrl+Z

You can temporarily pause a running foreground process using the keyboard shortcut Ctrl+Z.

This sends a SIGSTOP signal, suspending the process and returning control to your shell. The process is still in memory but not executing.

sleep 120
# Type 'sleep 120' and then press Ctrl+Z
# You will see '[1]+  Stopped  sleep 120'

Listing Jobs with `jobs`

When you suspend a process or send it to the background, it becomes a 'job'. You can list all current jobs managed by your shell using the jobs command.

Each job is assigned a job number, which is useful for referring to it with other commands.

sleep 30
# Press Ctrl+Z
jobs

Backgrounding a Job: `bg`

A suspended process isn't running. To make it run in the background (without occupying your terminal), use the bg command.

You can refer to the job by its job number (e.g., bg %1). The process will continue running silently.

sleep 60
# Press Ctrl+Z
jobs
bg %1
jobs

Foregrounding a Job: `fg`

If you have a process running in the background or a suspended one, you can bring it back to the foreground to interact with it using the fg command.

Like bg, you specify the job number (e.g., fg %1) to bring that specific job to the front.

sleep 60 &
jobs
fg %1
# Press Ctrl+C to stop it or Ctrl+Z to suspend it again.

Combining Process Control

These commands work together to give you full control over processes:

  • Start a task: nano
  • Suspend it: Ctrl+Z
  • Move to background: bg %1
  • Start another task: sleep 100
  • Suspend it: Ctrl+Z
  • List all jobs: jobs
  • Bring nano to foreground: fg %1
  • Terminate nano: Ctrl+C
  • Kill sleep: kill %2

Quick Check

You've started a program, and it's completely unresponsive. You can't even close it with Ctrl+C. You know its Process ID (PID).

What is the most effective command to immediately terminate this stubborn process?

Recap: Process Control

Great job! You've learned how to manage processes effectively:

  • kill: Send signals to terminate processes.
  • kill -9: Forcefully terminate a process.
  • Ctrl+Z: Suspend a foreground process.
  • jobs: List background and suspended jobs.
  • bg: Send a suspended job to the background.
  • fg: Bring a background job to the foreground.

These commands are crucial for maintaining control over your Linux environment.

자주 묻는 질문

“프로세스 관리: `kill`, `bg`, `fg`” 강의는 무료인가요?

네 — “프로세스 관리: `kill`, `bg`, `fg`” 전체 내용을 이 웹사이트에서 무료로 읽을 수 있습니다. 인터랙티브하게 실습하려면(내장 코드 에디터와 24/7 AI 튜터), CoddyKit PRO로 업그레이드하면 Linux Command Line Mastery 강의 전체를 잠금 해제할 수 있습니다. Linux Command Line Mastery 강의에는 총 4개의 강의가 포함되어 있습니다.

“프로세스 관리: `kill`, `bg`, `fg`”에서 뭘 배우나요?

명령줄에서 프로세스를 효과적으로 종료하고 일시 중지하고 재개하는 방법을 배웁니다. 브라우저에서 직접 실행하는 실습 코드로 Linux Command Line Mastery을(를) 배우며, 24/7 AI 튜터가 강의를 진행하면서 질문에 답변해줍니다.

Linux Command Line Mastery을(를) 시작하는 데 경험이 필요한가요?

사전 경험은 필요하지 않습니다. CoddyKit의 Linux Command Line Mastery은(는) 초급자부터 고급 학습자까지를 위해 구성되어 있으므로, 여기서 시작하거나 처음부터 시작할 수 있으며 자신의 속도대로 진행할 수 있습니다. 이것은 4개 중 2번째 강의입니다.

“프로세스 관리: `kill`, `bg`, `fg`” 강의는 얼마나 걸리나요?

대부분의 CoddyKit 강의는 약 5~10분이 소요됩니다. 각 강의는 간결하고 인터랙티브하여 꾸준한 진행이 가능하며, 웹과 앱에서 중단한 부분부터 바로 시작할 수 있습니다.

이 Linux Command Line Mastery 강의에서 코드를 작성하고 실행할 수 있나요?

네. 모든 Linux Command Line Mastery 강의에는 내장 코드 에디터가 포함되어 있으므로, 브라우저에서 바로 실제 코드를 작성하고 실행한 후 즉시 AI 피드백을 받을 수 있습니다 — 로컬 설정이 필요 없습니다.

이 강의의 모든 강의

  1. 프로세스 이해하기: `ps`, `top`, `htop`
  2. 프로세스 관리: `kill`, `bg`, `fg`
  3. 시스템 리소스 모니터링: `df`, `du`, `free`
  4. nice, renice, 시그널로 프로세스 우선순위 관리하기
← Linux Command Line Mastery(으)로 돌아가기