Language
日本語
English

Caution

JavaScript is disabled in your browser.
This site uses JavaScript for features such as search.
For the best experience, please enable JavaScript before browsing this site.

Linux & Mac & Bash Command Dictionary

  1. Home
  2. Linux & Mac & Bash Command Dictionary
  3. Linux Basics

Linux Basics

Linux is an operating system with a clear separation between the kernel and user space. The kernel directly controls hardware and handles process management, memory management, file systems, and device drivers. Programs running in user space can only request kernel operations through system calls. Processes are either foreground processes that run in the terminal or daemons that run continuously in the background — each with a different role and startup method.

Syntax

# -----------------------------------------------
#  Relationship between the kernel and the shell
# -----------------------------------------------

# You interact with the kernel through a shell (bash, zsh, etc.)
# The shell interprets commands and asks the kernel to execute them via system calls

#  User
#    ↓  types a command
#  Shell (/bin/bash, etc.)
#    ↓  system calls (fork / exec / read / write, etc.)
#  Kernel
#    ↓  hardware access
#  CPU / Memory / Disk / Network

# -----------------------------------------------
#  The concept of a process
# -----------------------------------------------

# Running a program creates a process
# Each process is assigned a unique PID (process ID)

# Use the ps command to list running processes
ps aux

# Example output:
#   USER       PID  %CPU %MEM    VSZ   RSS TTY      STAT START   TIME COMMAND
#   root         1   0.0  0.1  22560  4096 ?        Ss   10:00   0:01 /sbin/init
#   ginoza    1042   0.2  0.5  55320 20480 pts/0    Ss   10:01   0:00 -bash
#   kogami    1123   0.0  0.1   9216  3584 pts/0    R+   10:05   0:00 ps aux

# -----------------------------------------------
#  Difference between daemons and foreground processes
# -----------------------------------------------

# Foreground process:
#   - Attached to a terminal
#   - Exits when the terminal is closed
#   - Standard I/O is connected to the terminal

# Daemon:
#   - Runs continuously in the background
#   - Detached from any terminal (no controlling terminal)
#   - Often has a name ending in "d" (sshd / httpd / crond, etc.)
#   - Managed and monitored by systemd

# -----------------------------------------------
#  Types of shells and how to check them
# -----------------------------------------------

# Check which shell you are currently using
echo $SHELL

# List all installed shells
cat /etc/shells

# Example output:
#   /bin/sh
#   /bin/bash
#   /bin/zsh
#   /usr/bin/fish

Syntax reference

ConceptKeywordDescription
KernelkernelThe core of the OS that directly controls hardware. Responsible for process management, memory management, device drivers, and file systems.
User spaceuser spaceAn isolated environment where ordinary programs run, separate from the kernel. Programs communicate with the kernel only through system calls.
System callsyscallThe mechanism by which user-space programs request operations from the kernel. Examples include fork, exec, read, and write.
ShellshellAn interface that interprets the commands you type and passes them to the kernel. Common shells include bash, zsh, and fish.
ProcessprocessA running instance of a program. Each process has its own PID, memory space, and file descriptors.
PIDPIDShort for Process ID. The first process created at boot — init (or systemd) — is assigned PID 1.
DaemondaemonA process that runs continuously in the background. It has no controlling terminal and is managed by systemd.
Foreground processforeground processA process attached to a terminal. It receives user input, and the shell does not accept the next command until it finishes.
Background processbackground processA process started by appending & to a command. The shell accepts the next input without waiting for the process to finish.
init / systemdPID 1The first process started by the kernel. All other processes are descendants of PID 1. On modern Linux systems, systemd fills this role.
SignalsignalAn asynchronous notification sent to a process. Common signals include SIGTERM (request graceful exit), SIGKILL (force kill), and SIGHUP (reload configuration).
Zombie processzombie processA process that has finished executing but whose exit status has not yet been collected by its parent process. Shown as state Z in ps output.

Examples

Check process status and send a signal
# -----------------------------------------------
#  Checking and managing processes
# -----------------------------------------------

# List currently running processes
ps aux

# Example output:
#   USER       PID  %CPU %MEM COMMAND
#   ginoza    1234   1.5  0.8 python3 inspector_report.py
#   kogami    1235   0.0  0.1 sleep 3600
#   makishima 1236  99.9  5.2 ./anomaly_process

# Filter by process name
ps aux | grep inspector_report

# Terminate a process by PID (SIGTERM: request graceful exit)
kill 1234

# Force-kill a process (SIGKILL: immediately terminate the process)
kill -9 1236

# Terminate a process by name
pkill -f inspector_report.py

Run the following command:

$ ps aux | grep inspector_report
ginoza    1234   1.5  0.8  55320 32768 pts/0    S    10:10   0:03 python3 inspector_report.py
$ kill 1234
$ ps aux | grep inspector_report
(no output — the process has exited)
Check and control daemon status
# -----------------------------------------------
#  Basic daemon management with systemd
# -----------------------------------------------

# Check the status of the SSH daemon (sshd)
systemctl status sshd

# Start a daemon
sudo systemctl start sshd

# Stop a daemon
sudo systemctl stop sshd

# Enable a daemon to start automatically at boot
sudo systemctl enable sshd

# Disable automatic startup
sudo systemctl disable sshd

# -----------------------------------------------
#  List running daemons
# -----------------------------------------------

# List all active services
systemctl list-units --type=service --state=running

# Example output (excerpt):
#   UNIT                     LOAD   ACTIVE SUB     DESCRIPTION
#   cron.service             loaded active running Regular background program processing daemon
#   nginx.service            loaded active running A high performance web server and a reverse proxy server
#   sshd.service             loaded active running OpenBSD Secure Shell server
#   systemd-journald.service loaded active running Journal Service

Run the following command:

$ systemctl status sshd
● ssh.service - OpenBSD Secure Shell server
     Loaded: loaded (/lib/systemd/system/ssh.service; enabled; vendor preset: enabled)
     Active: active (running) since Wed 2026-03-25 10:00:00 JST; 1h 5min ago
       Docs: man:sshd(8)
             man:sshd_config(5)
   Main PID: 512 (sshd)
      Tasks: 1 (limit: 4915)
     Memory: 2.1M
        CPU: 85ms
     CGroup: /system.slice/ssh.service
             └─512 sshd: /usr/sbin/sshd -D [listener] 0 of 10-100 startups
Check the kernel version and system information
# -----------------------------------------------
#  Commands for checking kernel and system info
# -----------------------------------------------

# Check the current kernel version
uname -r

# Display full system information
uname -a

# Show OS distribution information (Debian / Ubuntu)
cat /etc/os-release

# Show system uptime and load average
uptime

# -----------------------------------------------
#  Read kernel information from the /proc filesystem
# -----------------------------------------------

# Display CPU information
cat /proc/cpuinfo | grep "model name" | head -3

# Display memory information
cat /proc/meminfo | grep -E "MemTotal|MemFree|MemAvailable"

# Count the number of currently running processes
ls /proc | grep -E '^[0-9]+$' | wc -l

Run the following command:

$ uname -r
6.1.0-28-amd64
$ uname -a
Linux sybilsystem 6.1.0-28-amd64 #1 SMP PREEMPT_DYNAMIC Debian 6.1.119-1 (2024-11-22) x86_64 GNU/Linux
$ uptime
 11:05:43 up  1:05,  2 users,  load average: 0.12, 0.08, 0.05
$ cat /proc/meminfo | grep -E "MemTotal|MemFree|MemAvailable"
MemTotal:        8192000 kB
MemFree:         4096512 kB
MemAvailable:    6291456 kB
Switch a process between foreground and background
# -----------------------------------------------
#  Basic job control operations
# -----------------------------------------------

# Start a program in the background (append & to the command)
python3 dominator_simulation.py &

# Example output:
#   [1] 2048
#   ([job number] PID is displayed)

# List current jobs
jobs

# Example output:
#   [1]+  Running    python3 dominator_simulation.py &

# Bring a background job to the foreground
fg %1

# Suspend a foreground process (Ctrl+Z), then resume it in the background
bg %1

# -----------------------------------------------
#  Use nohup to keep a process running after the terminal closes
# -----------------------------------------------

# With nohup, the process continues even after the terminal exits
# Output is saved to nohup.out by default
nohup python3 dominator_simulation.py > /var/log/dominator.log 2>&1 &

Run the following command:

$ python3 dominator_simulation.py &
[1] 2048
$ jobs
[1]+  Running                 python3 dominator_simulation.py &
$ fg %1
python3 dominator_simulation.py
^Z
[1]+  Stopped                 python3 dominator_simulation.py
$ bg %1
[1]+ python3 dominator_simulation.py &

Overview

The separation of the kernel and user space in Linux is a fundamental design choice that underpins system stability and security. By preventing user-space programs from accessing hardware directly, the risk of a single malfunctioning process destabilizing the entire system is greatly reduced. The shell acts as the gateway at this boundary, translating your commands into system calls and passing them to the kernel. Processes are broadly divided into foreground processes and background processes. Daemons — processes that run continuously in the background — are managed and monitored by systemd (PID 1). Daemon names often end in d (such as sshd, nginx, and crond), and the key distinction from foreground processes is that they have no controlling terminal. For managing services, see systemctl (managing services). For reviewing startup logs, see journalctl (viewing logs).

If you find any errors or copyright issues, please .