Must-Know for Beginners: Linux Service Start and Stop Commands
This article introduces the basics of Linux service management, where mainstream distributions use the `systemctl` (systemd) tool to manage services. Key commands and their functions include: `start`/`stop` (start/stop), `restart` (restart), `reload` (reload configuration), `status` (check status), and `enable`/`disable` (enable/disable on boot), all requiring `root` or `sudo` privileges. Service names vary across distributions: for example, Apache is `httpd` in CentOS and `apache2` in Ubuntu; MariaDB (CentOS) or MySQL (Ubuntu) are the service names for database services. Common issues include: adding `sudo` for permission errors, using `status` or `journalctl` to troubleshoot startup failures, and searching for service names with `systemctl list-unit-files` if forgotten. Mastering core commands, service name differences, and troubleshooting methods enables proficient server service management.
Read MoreBeginner's Guide: Linux System Updates and Upgrades
Updating and upgrading the Linux system is actually straightforward for beginners. The core purposes are to fix vulnerabilities (security patches) and enhance software versions (new features/performance). Regular operations ensure the system is more secure and powerful. For beginners, follow these steps (taking Ubuntu/Debian and CentOS/RHEL as examples): 1. **Verify system information** (optional): Use `uname -a` to check the kernel and `lsb_release -a` to view the distribution. 2. **Update package lists**: For Ubuntu, run `sudo apt update`; for CentOS, use `sudo dnf check-update`. 3. **Perform system updates**: For Ubuntu, execute `sudo apt upgrade`; for CentOS, use `sudo dnf upgrade` and confirm as prompted. 4. **Resolve dependency conflicts**: Select `y` or `n` as prompted. For "keep configuration files," choose `N` to overwrite old configurations for safety. 5. **Reboot the system**: If the kernel or core components are updated, execute `sudo reboot` immediately. Pitfall avoidance: Back up data before updating; distinguish between distribution-specific commands (Ubuntu uses apt, CentOS uses dnf/yum); avoid updating during critical service operations; ensure network stability; if updates fail, check the software sources.
Read MoreBeginner's Guide: Configuring Environment Variables in Linux
This article introduces the knowledge of Linux environment variables. Environment variables are information carriers for the system or programs (e.g., PATH records command paths). Their role is to allow programs to be found by the system and to set running parameters. To view environment variables, you can use `printenv`/`env` (for all variables) or `echo $VariableName` (for a single variable). For temporary configuration, use `export VariableName=Value`, which only takes effect in the current terminal session. For permanent configuration, modify the configuration files: for the user-level, edit `~/.bashrc` or `~/.zshrc` (effective for the current user); for the system-level, edit `/etc/profile` (effective for all users). After modification, use `source` to load the changes. Verification can be done by checking the newly added path with `echo $PATH` or testing relevant tools. Common issues include: forgetting to use `source` which leads to configuration not taking effect, path errors, and requiring `sudo` privileges for system-level configurations. In summary: use `export` for temporary settings, modify configuration files for permanence, and mastering environment variables can enhance efficiency.
Read MoreEssential for Beginners: Basics of Linux Network Configuration
This article introduces the necessity and practical methods of Linux network configuration. For newcomers, mastering network configuration is fundamental for using servers and setting up services. They need to first understand four key elements: IP address (the "ID" of a device), subnet mask (network segment identifier), gateway (entrance/exit between internal and external networks), and DNS (domain name translation). Common commands to check network status include: `ip addr` to view IP addresses, `route -n` to check routes, and `ping` to test connectivity (including local loopback and external network verification). For dynamic IP configuration (DHCP), use the `nmcli` tool to modify connection parameters and activate them. For static IP configuration, prepare parameters such as IP, subnet mask, gateway, and DNS in advance. On CentOS, set static IPs in the `/etc/sysconfig/network-scripts/ifcfg-eth0` file, while Ubuntu uses `netplan` to configure the `01-netcfg.yaml` file. After configuration, verification steps include: using `ip addr` to confirm the IP, `ping` to test local/gateway/external network connectivity, and `nslookup` to test DNS. Common issues like IP conflicts or failure to ping the gateway can be troubleshooted by following the steps: "check IP → verify routes → ping tests". The core lies in understanding the four key elements and practicing commands like `ip` and `ping` regularly.
Read More