System Issues & Maintenance
Debian Boots into Emergency Mode / Rescue Mode
Entering emergency mode means the system encountered a critical error during boot and was unable to mount the root filesystem or start essential services. The most common cause is an incorrect configuration in the /etc/fstab file.
Troubleshooting Steps:
Read the Error Messages:
- On the emergency mode screen, you will usually be prompted to run "journalctl -xb" to view detailed logs. Read the logs carefully, especially the red error messages, which will tell you which mount point has the problem.
Check
/etc/fstab:- Most Common Cause: You manually edited the
/etc/fstabfile, but there is a syntax error, a non-existent device, or an incorrect UUID. - Solution:
- At the emergency mode prompt, enter the
rootpassword to access a maintenance shell. - The filesystem may be read-only at this point and needs to be remounted as read-write:bash
mount -o remount,rw / - Edit the fstab file:
nano /etc/fstab - Carefully check the lines you modified. If you are unsure, add
#at the beginning of the problematic line to comment it out, allowing the system to boot normally first. - Get the correct UUID: Run the
blkidcommand, which will list the UUIDs of all partitions. Verify that the UUIDs in fstab are correct. - After saving the file, reboot with
reboot.
- At the emergency mode prompt, enter the
- Most Common Cause: You manually edited the
Filesystem Corruption:
- Cause: An improper shutdown (such as a sudden power outage) can cause filesystem corruption.
- Solution:
- In emergency mode, the logs may prompt you to run
fsck(file system check) on a specific partition. - Run the command, for example:
fsck /dev/sda1(replace/dev/sda1with the partition indicated as problematic). - Follow the prompts to repair errors. Reboot after the repair is complete.
- In emergency mode, the logs may prompt you to run
How to Free Up Disk Space on Debian
When the root directory / or home directory /home is running out of space, the system may become unstable.
Cleanup Strategies:
Clean the APT Cache:
- APT caches downloaded
.debpackages. These caches can take up a significant amount of space. - Remove all cached package files:
sudo apt-get clean- This command deletes all package files in the
/var/cache/apt/archives/directory. It is safe and effective.
- This command deletes all package files in the
- Remove only obsolete packages:
sudo apt-get autoclean- This command only removes packages that are outdated and can no longer be downloaded from the repositories.
- APT caches downloaded
Remove Unnecessary "Orphan" Packages:
- These are packages that were installed as dependencies but are no longer required by any other package.
sudo apt autoremove
Clean Up Old Kernels:
- When the system is updated, old kernel versions are retained, taking up space in
/bootand/lib/modules. - Usually
apt autoremovehandles old kernels automatically, but if you need to clean them up manually, be extremely careful. Never uninstall the kernel you are currently using (uname -r).
- When the system is updated, old kernel versions are retained, taking up space in
Analyze Disk Space Usage:
- Use tools to find which files and directories are taking up the most space.
ncdu(Recommended): A very convenient interactive disk usage analyzer.bashsudo apt install ncdu # Analyze the root directory sudo ncdu / # Analyze the home directory ncdu ~du(Traditional command):bash# View the size of first-level subdirectories under /var sudo du -h --max-depth=1 /var
Clean Up Log Files:
journaldlogs can grow very large.- Check current log size:
journalctl --disk-usage - Clean up logs, keeping only the last two weeks:bash
sudo journalctl --vacuum-time=2weeks
How to View System Information on Debian
CPU Information:
lscpu: Lists detailed CPU architecture, core count, threads, frequency, etc.cat /proc/cpuinfo: Raw CPU information.
Memory Information:
free -h: Displays total, used, and available memory and swap in a human-readable format.cat /proc/meminfo: More detailed memory information.
Disk Information:
lsblk: Displays all block devices (hard drives, partitions, USB drives) in a tree structure.df -h: Shows total, used, and available space for mounted filesystems.sudo fdisk -l: Lists all hard drives and their partition table information.
Comprehensive Information Tools:
neofetchorfastfetch: Displays the system logo along with key hardware and software information in an attractive format.bashsudo apt install neofetch neofetch
How to Change the Hostname on Debian
The hostname is the name of the computer on the network.
Method 1: Using hostnamectl
This is the standard method on systemd systems. It automatically modifies all related files.
sudo hostnamectl set-hostname new-hostnameReplace new-hostname with your desired new name. This command takes effect immediately without requiring a reboot.
Method 2: Manually Editing Files (Traditional Method)
Edit
/etc/hostname:- This file contains only one line: the current hostname.
sudo nano /etc/hostname- Replace the old name with the new name.
Edit
/etc/hosts:- This file is used for local name resolution.
sudo nano /etc/hosts- Find the line similar to
127.0.1.1 old-hostnameand replaceold-hostnamewithnew-hostname.
Apply the Changes:
- Run
sudo hostname new-hostnameto update the hostname immediately in the current session. - Or simply reboot the computer.
- Run
How to Install NVIDIA Graphics Drivers on Debian?
This is a common and important question. An incorrect installation method can cause many problems.
Short Answer: Do not download the .run file from the NVIDIA website to install. Instead, use the nvidia-driver package from the official Debian repositories.
For detailed installation steps, please refer to the full tutorial in Desktop & Display -> Installing NVIDIA Drivers on Debian.
How to Install a Chinese Input Method on Debian?
Configuring the Chinese environment on Debian involves two steps: "Setting the Chinese locale" and "Installing a Chinese input method framework." The currently recommended framework is Fcitx5.
For detailed configuration steps, please refer to the full tutorial in System Configuration & Basic Usage -> How to Set Up Chinese Language and Input Method on Debian.
How to Add a New User on Debian
Using adduser (Recommended)
adduser is a user-friendly script that automatically creates a home directory, sets a password, and more when creating a user.
sudo adduser new_usernameReplace new_username with the username you want to create. After execution, it will interactively:
- Ask you to set a password for the new user.
- Ask you to enter optional information such as the user's full name (you can press Enter to skip).
- Ask you to confirm whether the information is correct.
Add the New User to the sudo Group (If Needed)
If you want the new user to be able to run sudo commands, you need to add them to the sudo group.
sudo usermod -aG sudo new_username