-
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.
-
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
useradd
the command andpasswd
set the password using the command. - To modify and delete user accounts, you can use
usermod
the anduserdel
commands.
-
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
,pwd
to browse and manage files and directories.
-
File permissions and ownership :
- Each file and directory has permission settings, including read (r), write (w), and execute (x) permissions.
chmod
These permissions can be modified using commands. - Ownership is defined by users and groups, and
chown
commands can be used to change the ownership of files and directories.
- Each file and directory has permission settings, including read (r), write (w), and execute (x) permissions.
-
Package management :
- Use package management tools to install, update, and remove software packages. For example, used by Debian and Ubuntu
apt
, used by CentOSyum
. - Ensure the security and stability of software packages through signature verification and source management.
- Use package management tools to install, update, and remove software packages. For example, used by Debian and Ubuntu
-
Process management :
- Use
ps
commands to view the list of running processes andtop
monitor system resource usage in real time. - Use
kill
the command to kill a process, either by process ID (PID) or name. - Use
&
the operator to run the command in the background, or usenohup
the command to keep the process running after the user exits.
- Use
-
System logs and troubleshooting :
- Linux systems generate various log files, located
/var/log
in directories. For example,/var/log/syslog
and/var/log/auth.log
. - Use commands such as
tail
andgrep
to view and analyze logs to diagnose problems.
- Linux systems generate various log files, located
-
Network configuration and management :
- To configure the network interface, IP address and subnet mask, you can use
ifconfig
the ,ip
and configuration files (such as/etc/network/interfaces
). - Use commands such as
netstat
andss
to view and manage network connections.
- To configure the network interface, IP address and subnet mask, you can use
-
safety :
- Configure the firewall to control inbound and outbound traffic, common firewall tools include
iptables
andfirewalld
. - 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.
- Configure the firewall to control inbound and outbound traffic, common firewall tools include
-
Backup and restore :
- Create and manage backups to ensure data security. Commonly used backup tools include
rsync
andtar
. - Use a regular backup strategy, including full and incremental backups.
- Create and manage backups to ensure data security. Commonly used backup tools include
-
Performance monitoring and optimization :
- Use tools such as
top
,htop
,iostat
andvmstat
to monitor system performance. - Optimizing system resource allocation to improve performance can be achieved by adjusting kernel parameters and process priorities.
- Use tools such as
-
Automated tasks :
- Use cron jobs to run tasks regularly and
crontab
manage them by editing files. - Write shell scripts to automate common tasks such as backups, log cleaning, and monitoring.
- Use cron jobs to run tasks regularly and
-
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) andyum update
(for CentOS) are used to update the system.
- Regularly update operating systems and software packages to ensure security and performance. Commands like
-
Hardware management :
- To monitor hardware status, such as disk space, memory usage, and CPU load, you can use commands such as
df
,free
and .top
- Adding and configuring hardware devices such as disks, network adapters, etc. can be
udev
automatically detected and configured using.
- To monitor hardware status, such as disk space, memory usage, and CPU load, you can use commands such as
-
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
-
-
File system and directory structure :
- Browse and manage files and directories:
ls # 列出当前目录的内容 cd # 切换目录 pwd # 显示当前工作目录的路径
- Browse and manage files and directories:
-
File permissions and ownership :
-
Modify file permissions:
chmod permissions filename
-
Change file ownership:
chown owner:group filename
-
-
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
-
-
-
Process management :
-
View a list of running processes:
ps aux
-
Terminate the process:
kill PID
-
Running process in the background:
command &
-
-
System logs and troubleshooting :
-
Check the system log:
tail /var/log/syslog
-
Use grep to filter the logs:
grep "search_string" /var/log/syslog
-
-
Network configuration and management :
-
Configure network interface and IP address:
sudo ifconfig eth0 192.168.1.100
-
Check the network connection:
netstat -tuln
-
-
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
-
-
Backup and restore :
-
Create a backup:
rsync -av /source_directory /backup_directory
-
Restore backup:
rsync -av /backup_directory /restore_directory
-
-
Performance monitoring and optimization :
-
Monitor system performance:
top
-
Optimize system resource allocation:
sysctl -w parameter=value
-
-
Automated tasks :
-
Use cron job:
crontab -e
-
Write a shell script:
#!/bin/bash # Your script commands here
-
-
System updates and upgrades :
-
Update system and packages (Debian/Ubuntu):
sudo apt update && sudo apt upgrade
-
Update system and packages (CentOS):
sudo yum update
-
-
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
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.