Skip to main content

Basic Configuration

Navigation bar

This chapter introduces the basic configuration of Linux systems, including software installation, vim configuration, SSH security configuration, user management, hostname and timezone settings, and hard drive mounting.


Configure vim Copy Functionality​

Edit the vim default configuration file to disable mouse mode for better copy-paste support:

vim /usr/share/vim/vim90/defaults.vim

Change set mouse=a to:

set mouse-=a

Secure SSH Configuration​

Edit the SSH configuration file to enhance security:

vim /etc/ssh/sshd_config
  1. Open an additional backup port:

    Port 22
    Port 2222
  2. Use only the secure ED25519 key:

    HostKey /etc/ssh/ssh_host_ed25519_key
  3. Disable root password login:

    PermitRootLogin prohibit-password
  4. Allow key-based login, disable password login:

    PubkeyAuthentication yes
    PasswordAuthentication no
  5. Configure client response interval and maximum counts:

    ClientAliveInterval 30
    ClientAliveCountMax 8
    UseDNS no
  6. Restart the SSH service to apply the configuration:

    systemctl restart sshd

User Management​

Delete unnecessary users and add a custom user:

# Delete an unwanted user (e.g., ubuntu)
deluser ubuntu --remove-all-files

# Add user roy
adduser roy

# Add user roy to the sudo group
sudo usermod -aG sudo roy

# Verify roy is in the sudo group
groups roy
# or
id roy

Change Hostname and Timezone​

  1. Set the hostname:

    hostnamectl set-hostname Debian-E5-2686-HK
  2. Set the timezone:

    timedatectl set-timezone Asia/Macau
    echo "Asia/Macau" > /etc/timezone
  3. Install NTP service:

    apt install ntp
  4. Verify the hostname:

    cat /etc/hostname

Mount Hard Drive at Boot​

Edit the /etc/fstab file to automatically mount a hard drive at boot:

vim /etc/fstab

Example configuration:

# Use blkid to check the UUID
# First number: 0 means no disk check at boot, 1 means check the disk at boot
# Second number: 0 means swap partition, 1 means boot partition (Linux), 2 means regular partition
UUID=4F05D3D42790EB40 /opt/static ntfs-3g defaults 0 0
UUID=4F05D3D42790EB40 /opt/static ext4 defaults 0 2

After completing the above configurations, the system will be more secure, efficient, and meet personalized needs.

AI Translation Notice

This page was translated into English by AI and is provided for reference only. The original document is written in Chinese. If there is any discrepancy, the Chinese version prevails.

本页英文内容由 AI 自动翻译生成,仅供参考;原文为中文,如有差异请以中文原文为准。

查看中文原文 / View the Chinese original →