Lesson 1, Topic 1
In Progress

Operating Running Systems

1. System Boot and Shutdown Procedures

a. Boot, Reboot, and Shutdown

To operate a system efficiently, it’s crucial to know how to manage its state.

  • Boot: To start a system.
  • Reboot: To restart a system.
  • Shutdown: To turn off a system safely.

Example:

# To shut down the system
shutdown -h now

# To reboot the system
shutdown -r now


Summary

  • Understanding these commands ensures you can control the system’s power state safely.

Key Points

  1. Always shut down or reboot a system gracefully to prevent data loss.
  2. The -h flag in shutdown means halt after shutting down.

Practical Exercise

  1. Practice safely shutting down and rebooting your system.

2. Booting into Different Targets

Systemd uses ‘targets’ instead of run-levels. Each target corresponds to a specific state.

Example:

# To change to rescue mode (similar to single-user mode)
systemctl isolate rescue.target


Summary

  • Targets are named configurations for sets of systemd services.

Key Points

  1. Familiar targets include multi-user.target and graphical.target.
  2. Use systemctl get-default to check the default target.

Practical Exercise

  1. Identify your current target and change to a multi-user target.

3. Interrupting Boot Process

Sometimes you might need to interrupt the boot process for troubleshooting.

Example: Upon booting, at the GRUB menu, select the kernel entry you wish to edit, press ‘e’, and append init=/bin/bash to the kernel line to gain root shell access.


Summary

  • Interrupting the boot process is a powerful tool but should be used cautiously.

Key Points

  1. This method is mainly for recovery purposes.
  2. Always ensure you know the implications of interrupting the boot process.

Practical Exercise

  1. Safely practice interrupting the boot process and entering rescue mode.

4. Managing Processes

a. Identifying CPU/Memory Intensive Processes

Use tools like top or htop to monitor system processes.

b. Killing Processes

If a process isn’t responding, you might need to terminate it.

Example:

# To kill a process with PID 1234
kill -9 1234


Summary

  • Efficient system operation requires process management.

Key Points

  1. Use ps aux | grep [process_name] to find a process’s PID.
  2. The -9 signal in kill is SIGKILL, which forcefully terminates the process.

Practical Exercise

  1. Start a long-running process, identify its PID, and then kill it.

5. Adjusting Process Scheduling

The nice and renice commands adjust process priorities.

Example:

# Start a command with a nice value of 5
nice -n 5 [command]

# Change the priority of a running process with PID 1234 to 5
renice 5 -p 1234


Summary

  • Adjusting priorities ensures critical tasks get adequate resources.

Key Points

  1. Nice values range from -20 (highest priority) to 19 (lowest).
  2. Regular users can only assign positive nice values.

Practical Exercise

  1. Start two CPU-intensive tasks, adjust their priorities, and observe the differences.

6. Managing Tuning Profiles

Use tuned-adm to adjust system tuning profiles.

Example:

# To list available profiles
tuned-adm list

# To activate a profile
tuned-adm profile [profile-name]


Summary

  • Tuning profiles optimize the system for specific tasks.

Key Points

  1. Common profiles include throughput-performance and latency-performance.
  2. The active profile is applied on boot.

Practical Exercise

  1. Explore available tuning profiles and activate a different one.

7. System Logs and Journals

a. Locating and Interpreting Logs

System logs, usually in /var/log/, provide a history of system events.

Example:

# To view system messages
cat /var/log/messages

b. System Journals with systemd

Systemd’s journalctl provides system logs with filtering options.

Example:

# To view the entire system journal
journalctl


Summary

  • Logs provide insights into system operations and issues.

Key Points

  1. Logs are crucial for troubleshooting.
  2. The systemd journal is binary and requires journalctl to read.

Practical Exercise

  1. Retrieve logs related to the SSH service using journalctl.

8. Preserving System Journals

By default, the journal is stored in /run/log/journal/ and is volatile. To make it persistent:

  1. Create /var/log/journal/.
  2. Set appropriate permissions.
  3. Restart the journald service.

Summary

  • Making journals persistent aids in long-term troubleshooting.

Key Points

  1. Persistent journals consume disk space; monitor usage.
  2. Journals are rotated; old entries are removed.

Practical Exercise

  1. Convert your journal storage to persistent and check its contents after a reboot.

9. Network Services Management

a. Start, Stop, and Check Network Services

Systemd controls services, including network ones.

Example:

# To start the SSH service
systemctl start sshd

# To check its status
systemctl status sshd

b. Securely Transfer Files Between Systems

scp is a tool for secure file transfer.

Example:

# To copy a file to a remote system
scp file.txt user@remote_host:/path/


Summary

  • Managing network services is key for system administrators.

Key Points

  1. Always ensure necessary services are active and unnecessary ones are stopped.
  2. Use scp with caution, especially when transferring sensitive files.

Practical Exercise

  1. Transfer a file between two systems using scp.
🔥 We’re part of the biggest IT certification deal in history
This is default text for notification bar