Basic Configuration

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
-
Open an additional backup port:
Port 22
Port 2222 -
Use only the secure ED25519 key:
HostKey /etc/ssh/ssh_host_ed25519_key -
Disable root password login:
PermitRootLogin prohibit-password -
Allow key-based login, disable password login:
PubkeyAuthentication yes
PasswordAuthentication no -
Configure client response interval and maximum counts:
ClientAliveInterval 30
ClientAliveCountMax 8
UseDNS no -
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
-
Set the hostname:
hostnamectl set-hostname Debian-E5-2686-HK -
Set the timezone:
timedatectl set-timezone Asia/Macau
echo "Asia/Macau" > /etc/timezone -
Install NTP service:
apt install ntp -
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.