一、What is a Linux Server?

A Linux server is a server system based on the Linux operating system. Unlike common operating systems like Windows or macOS, it is specifically designed for stable, efficient, and secure service scenarios. For example, most cloud servers provided by Alibaba Cloud, Tencent Cloud, etc., adopt the Linux system because it is open-source, free, has low resource consumption, strong security, and supports 24/7 uninterrupted operation.

二、Choosing a Distribution and Installation Preparation

  • Ubuntu Server: Friendly graphical interface, suitable for beginners to get started quickly, and good hardware compatibility.
  • CentOS Stream: Enterprise-level stable version, ideal for learning production environment deployment, with strong security and update support.
  • Debian: Minimalist style, suitable for in-depth study of Linux underlying principles.

2. Installation Method: Virtual Machine First

  • Why Use a Virtual Machine? Avoid installing directly on physical hardware; snapshots and rollbacks are available anytime to reduce risks.
  • Recommended Tools: VMware Workstation, VirtualBox (free).
  • Preparation: Download the ISO image of the corresponding distribution from the official website, and allocate virtual machine resources (2 CPU cores, 4GB memory, 40GB+ hard disk).

三、Installing a Linux Server

1. Virtual Machine Installation Steps (Take Ubuntu as an Example)

  1. Open the virtual machine software, create a new virtual machine, and select “Typical Installation”.
  2. Select the downloaded ISO image file and proceed to the next step.
  3. Set the username (e.g., ubuntu) and password, and check “Auto-login on login” (simplifies operations).
  4. Disk partitioning: Select “Use entire disk” and let the system automatically allocate partitions (no complex operations needed).
  5. Wait for the installation to complete, then restart the virtual machine to enter the system.

四、Getting to Know the Linux Server Interface

1. Logging into the System

  • After booting, enter the username and password to access the command-line interface (Terminal).
  • The command line is the core interaction method for Linux servers; all operations are performed via commands.

2. Quick Reference for Basic Commands

Command Function Example
ls List files in the current directory ls -l (show detailed info)
cd Change directory cd /home (enter home directory)
pwd Show current directory path pwd (shows /home/ubuntu)
mkdir Create a directory mkdir test (create test folder)
touch Create an empty file touch file.txt (create a file)
rm Delete a file/directory rm -r test (delete test directory)
sudo Temporary privilege escalation (admin rights) sudo apt update (update software sources)

五、Core Network Configuration Steps

1. Check Current Network Status

  • View IP address:
    ip addr (recommended) or ifconfig (some systems require installing net-tools).
    Look for the network card (e.g., eth0 or ens33) in the output; the number after inet is the IP (e.g., 192.168.1.100).

  • Test network connectivity:
    ping 8.8.8.8 (test public network connectivity), ping 192.168.1.1 (test gateway).

2. Set Static IP (Critical!)

For CentOS (Take CentOS 8 as an Example):

  1. Modify Configuration File:
    Open the network card configuration file with vi (network card name may be ens33):
   sudo vi /etc/sysconfig/network-scripts/ifcfg-ens33
  1. Modify Content:
   BOOTPROTO=static  # Disable DHCP, set IP manually
   IPADDR=192.168.1.100  # Static IP (customize, avoid conflicts)
   NETMASK=255.255.255.0  # Subnet mask
   GATEWAY=192.168.1.1    # Gateway (router IP, e.g., home router default 192.168.1.1)
   DNS1=8.8.8.8  # Google DNS (for domain name resolution, e.g., ping www.baidu.com)
   ONBOOT=yes    # Enable network card on boot
  1. Restart Network Service:
   sudo systemctl restart network

For Ubuntu (Take Ubuntu 20.04 as an Example):

  1. Modify Netplan Configuration:
    Open the configuration file (network card name may be ens33):
   sudo vi /etc/netplan/01-netcfg.yaml
  1. Modify Content:
   network:
     version: 2
     renderer: networkd
     ethernets:
       ens33:
         dhcp4: no  # Disable DHCP
         addresses: [192.168.1.100/24]  # IP/subnet mask
         gateway4: 192.168.1.1         # Gateway
         nameservers:
           addresses: [8.8.8.8, 114.114.114.114]  # DNS List
  1. Apply Configuration:
   sudo netplan apply

3. Verify Network

  • Check if IP is Valid: ip addr to confirm the IP is correctly displayed.
  • Test External Connectivity:
    ping www.baidu.com (requires DNS to work), ping 192.168.1.1 (gateway).
  • Open Ports (Firewall):
    If the server needs to provide web services (port 80) or SSH services (port 22), open the corresponding ports.
  • CentOS:
    sudo firewall-cmd --add-port=80/tcp --permanent  # Open port 80
    sudo firewall-cmd --reload  # Take effect immediately
  • Ubuntu:
    sudo ufw allow 22/tcp  # Open SSH port
    sudo ufw enable  # Enable firewall

六、SSH Remote Connection (Essential for Server Management)

1. Install SSH Service

  • CentOS:
  sudo yum install openssh-server -y
  sudo systemctl enable --now sshd  # Enable on boot and start the service
  • Ubuntu:
  sudo apt install openssh-server -y
  sudo systemctl enable --now ssh

2. Connect to the Server

  • Windows: Use tools like Xshell or PuTTY, enter ssh username@IP (e.g., ssh ubuntu@192.168.1.100).
  • Linux/macOS: Directly execute ssh ubuntu@192.168.1.100 in the terminal and enter the password to log in.

七、Summary and Next Steps

Key Steps Recap:
1. Choose a distribution and install Linux via a virtual machine.
2. Master basic commands (ls, cd, sudo, etc.) for quick file operations.
3. Configure static IP, gateway, and DNS to ensure network connectivity.
4. Use SSH tools to remotely manage the server.

Next Steps for Beginners:
- Learn file permission management (chmod, chown).
- Deploy basic services (e.g., Nginx web server, MySQL database).
- Monitor system resources with top, htop, and troubleshoot network issues with netstat.

The core charm of Linux servers lies in their openness and flexibility. Hands-on practice (e.g., building a personal blog, testing web services) accelerates skill acquisition. When encountering problems, use man command (e.g., man ifconfig) to check help documentation or refer to official documentation (Ubuntu/Debian/CentOS official websites).

Xiaoye