[Linux] Basics of Linux operation and maintenance

  1. Introduction to Linux :

    • Linux is an open source operating system kernel originally created by Linus Torvalds. It is often used with GNU tools to create a complete operating system.
    • There are many kernel-based distributions of the Linux operating system, such as Ubuntu, CentOS, Debian, etc. Each distribution has its own unique features and package management tools.
  2. Login and user management :

    • Use the SSH (Secure Shell) protocol to remotely log in to the Linux server to ensure secure remote access.
    • To add a new user, you can use useraddthe command and passwdset the password using the command.
    • To modify and delete user accounts, you can use usermodthe and userdelcommands.
  3. File system and directory structure :

    • The Linux file system uses a hierarchical structure, and the root directory (/) is the top-level directory of the entire file system.
    • Some important directories include: /home (user home directory), /tmp (temporary file directory), /var (variable data), etc.
    • Use commands such as ls, cd, pwdto browse and manage files and directories.
  4. File permissions and ownership :

    • Each file and directory has permission settings, including read (r), write (w), and execute (x) permissions. chmodThese permissions can be modified using commands.
    • Ownership is defined by users and groups, and chowncommands can be used to change the ownership of files and directories.
  5. Package management :

    • Use package management tools to install, update, and remove software packages. For example, used by Debian and Ubuntu apt, used by CentOS yum.
    • Ensure the security and stability of software packages through signature verification and source management.
  6. Process management :

    • Use pscommands to view the list of running processes and topmonitor system resource usage in real time.
    • Use killthe command to kill a process, either by process ID (PID) or name.
    • Use &the operator to run the command in the background, or use nohupthe command to keep the process running after the user exits.
  7. System logs and troubleshooting :

    • Linux systems generate various log files, located /var/login directories. For example, /var/log/syslogand /var/log/auth.log.
    • Use commands such as tailand grepto view and analyze logs to diagnose problems.
  8. Network configuration and management :

    • To configure the network interface, IP address and subnet mask, you can use ifconfigthe , ipand configuration files (such as /etc/network/interfaces).
    • Use commands such as netstatand ssto view and manage network connections.
  9. safety :

    • Configure the firewall to control inbound and outbound traffic, common firewall tools include iptablesand firewalld.
    • Regularly update systems and software packages to close security vulnerabilities.
    • Use an SSH key pair instead of a password to log in for increased security.
  10. Backup and restore :

    • Create and manage backups to ensure data security. Commonly used backup tools include rsyncand tar.
    • Use a regular backup strategy, including full and incremental backups.
  11. Performance monitoring and optimization :

    • Use tools such as top, htop, iostatand vmstatto monitor system performance.
    • Optimizing system resource allocation to improve performance can be achieved by adjusting kernel parameters and process priorities.
  12. Automated tasks :

    • Use cron jobs to run tasks regularly and crontabmanage them by editing files.
    • Write shell scripts to automate common tasks such as backups, log cleaning, and monitoring.
  13. System updates and upgrades :

    • Regularly update operating systems and software packages to ensure security and performance. Commands like apt update && apt upgrade(for Debian/Ubuntu) and yum update(for CentOS) are used to update the system.
  14. Hardware management :

    • To monitor hardware status, such as disk space, memory usage, and CPU load, you can use commands such as df, freeand .top
    • Adding and configuring hardware devices such as disks, network adapters, etc. can be udevautomatically detected and configured using.

  1. Login and user management :

    • Use SSH to remotely log in to the Linux server:

      ssh username@hostname
      
    • Add new user:

      sudo useradd newuser
      
    • Set user password:

      sudo passwd newuser
      
    • Modify and delete user accounts:

      sudo usermod -aG groupname username
      sudo userdel username
      
  2. File system and directory structure :

    • Browse and manage files and directories:
      ls        # 列出当前目录的内容
      cd        # 切换目录
      pwd       # 显示当前工作目录的路径
      
  3. File permissions and ownership :

    • Modify file permissions:

      chmod permissions filename
      
    • Change file ownership:

      chown owner:group filename
      
  4. Package management :

    • Use package management tools to install, update, and remove packages:

      • Using APT on Debian/Ubuntu:

        sudo apt-get install package_name
        sudo apt-get update
        sudo apt-get upgrade
        sudo apt-get remove package_name
        
      • Using YUM on CentOS:

        sudo yum install package_name
        sudo yum update
        sudo yum remove package_name
        
  5. Process management :

    • View a list of running processes:

      ps aux
      
    • Terminate the process:

      kill PID
      
    • Running process in the background:

      command &
      
  6. System logs and troubleshooting :

    • Check the system log:

      tail /var/log/syslog
      
    • Use grep to filter the logs:

      grep "search_string" /var/log/syslog
      
  7. Network configuration and management :

    • Configure network interface and IP address:

      sudo ifconfig eth0 192.168.1.100
      
    • Check the network connection:

      netstat -tuln
      
  8. safety :

    • Configure firewall:

      sudo iptables -A INPUT -p tcp --dport 80 -j ACCEPT
      
    • Update system and packages:

      sudo apt-get update
      sudo apt-get upgrade
      
    • Use SSH key pair:

      ssh-keygen -t rsa
      
  9. Backup and restore :

    • Create a backup:

      rsync -av /source_directory /backup_directory
      
    • Restore backup:

      rsync -av /backup_directory /restore_directory
      
  10. Performance monitoring and optimization :

    • Monitor system performance:

      top
      
    • Optimize system resource allocation:

      sysctl -w parameter=value
      
  11. Automated tasks :

    • Use cron job:

      crontab -e
      
    • Write a shell script:

      #!/bin/bash
      # Your script commands here
      
  12. System updates and upgrades :

    • Update system and packages (Debian/Ubuntu):

      sudo apt update && sudo apt upgrade
      
    • Update system and packages (CentOS):

      sudo yum update
      
  13. Hardware management :

    • Monitor hardware status:

      df -h     # 磁盘空间
      free -m   # 内存使用
      top       # CPU负载
      
    • Add hardware device:

      sudo udevadm trigger
      

Good book recommendations in this issue

Order link: https://item.jd.com/14199216.html

Insert image description here


brief introduction

"Linux Operation and Maintenance from Beginner to Mastery" starts from the perspective of beginners, through easy-to-understand language and clear operation steps, and introduces in detail the technologies related to Linux system management and operation and maintenance. The book is divided into 3 parts with a total of 19 chapters, including operation and maintenance work, servers, Linux systems, Linux file directory commands, Linux software installation, Linux text editing, users and user groups, file management and processes, Linux file systems, and Linux disk management. , Linux network, firewall, FTP server construction and application, NFS server construction and application, building Tomcat application server, enterprise-level Nginx application server construction, building services based on LAMP architecture, Linux data services, Linux shell scripts, etc. All the knowledge in this book is introduced based on specific application scenarios and operation steps, allowing readers to easily understand the essence of Linux system operation and maintenance and quickly improve their operation and maintenance skills.
This book can be used as a self-study book for beginners in system operation and maintenance, as well as a teaching reference book for related majors in colleges and universities, and can also be used as a reference for developers.

Guess you like

Origin blog.csdn.net/weixin_44244190/article/details/135070800