📜  Linux 系统管理初学者指南

📅  最后修改于: 2022-05-13 01:57:26.640000             🧑  作者: Mango

Linux 系统管理初学者指南

Linux 系统管理员管理诸如维护适当的软件、观察它们,甚至照顾备份和硬件系统等操作。建议在阅读本文之前先阅读一下什么是 Linux 系统管理一文。在这里,我们有一些 Linux 系统管理的基础知识。

一些基本配置

设置主机名:打开终端并输入以下命令以更改主机名。

sudo hostname your_hostname

将“your_hostname”替换为您要保留的主机名。

设置时区:移至 /usr/share/zoneinfo/your_zone 然后将区域文件与 /etc/localtime 链接以设置时区。

sudo ln -sf Kolkata /etc/localtime

文件系统和管理

管理文件是 Linux 中最重要的任务,因为所有设备、目录和包都只是 Linux 中的一种文件。



1.要了解文件系统,请阅读 Linux 中的文件系统一文。
2.要了解有关 Linux 文件层次结构的更多信息,您可以阅读文章 Linux 文件系统层次结构
3.要了解 Linux 和 Windows 文件系统之间的区别,请阅读文章 Windows vs Linux

下面是 Linux 中一些文件管理命令的列表:

CommandDescription
cdUsed to change the current directory
lsUsed to list the directories and files in a directory
viA good text editor to edit files
touchUsed to create new files
nanoA good text editor to edit files
cpUsed to copy files and directories.
mvUsed to move files and directories.
rmUsed to remove files and directories.
fdiskUsed to partition disks and to work with file systems
mountUsed to mount a file system or a device

您还可以从文章 https://www.geeksforgeeks.org/file-management-in-linux/ 中阅读 Linux 中的文件管理

网络命令

网络命令在系统管理中扮演着重要的角色,一个好的系统管理员必须有很好的动手网络命令。以下是在 Linux 中主要用于联网的此类命令的列表。

CommandDescription
routeused to view and manipulate ip routing tables.
pingUsed to send some packets to a server and receive them back in case of a good network connection.
tracerouteUsed to trace the path taken by the traffic.
nslookupUsed for querying the Domain Name System to obtain domain name or IP address mapping, or other DNS records.
ifconfigUsed to view and change the configuration of the network interfaces on your system
tracepathUsed to traces path to destination discovering MTU along this path
sshProvides a secure encrypted connection between two hosts over an insecure network
telnetUsed to test if a port is open and even to work with telnet protocol.
curlUsed to transfer data to or from a server, using any of the supported protocols.
scpUsed to securely copy files and directories between two locations over a network.
wProvides a quick summary of every user logged into a computer
netcatused for performing any operation in Linux related to TCP, UDP, or UNIX-domain sockets
nmapUsed for network exploration and security auditing
netstatUsed for monitoring network connections both incoming and outgoing as well as viewing routing tables, interface statistics, etc
ipUsed to assign an address to a network interface and/or configure network interface parameters on Linux operating systems

要了解有关 Linux 网络命令的更多信息,请阅读文章 Linux 网络工具

在 Linux 中管理用户和组

系统管理员必须管理在系统上工作的用户。用户是登录到您的系统或可能登录到系统的帐户。 Linux 中的每个用户都有一个唯一的 UID 来标识用户。用户的所有信息都存储在 /etc/passwd 文件中,所有哈希密码存储在 /etc/shadow 文件中。根据访问权限,Linux 中基本上有两种类型的用户。

  • 超级用户或管理员
  • 一般用户

每个用户可能是也可能不是用户集合的组的一部分。要了解有关 Linux 用户的更多信息,请参阅 Linux 系统管理中的用户一文。这是用于管理用户的命令列表。

CommandDescription
usermodUsed to modify users and their respective settings
useraddUsed to add a new user
su and sudoUsed to change the user and work with root
changeUsed to change the user’s aging/expiry information
groupdelUsed to delete a group
gpasswdUsed to change password of group
groupmodUsed to modify group and its settings
groupaddUsed to add a new group

要了解有关如何管理用户的更多信息,请阅读 Linux 中的用户管理一文

要了解有关如何管理组的更多信息,请阅读 Linux 中的组管理一文

系统诊断/监控性能

系统管理员应该能够诊断系统中的问题,甚至可以监控系统的性能,以便对其进行改进。以下是一些有用的命令列表。

CommandDescription
topUsed to display the running processes.
vmstatUsed to get information about processes, memory, paging, block IO, disk, and CPU scheduling
lsofUsed to check list of open files.
htopUsed to determine the cause of load of each process
iostatUsed to monitor IO devices loading
nmonIt displays performance about the CPU, MEMORY, NETWORK, DISKS, FILE SYSTEM, NFS, TOP PROCESSES, RESOURCES, AND POWER MICRO-PARTITION

读取和分析日志

一个优秀的系统管理员必须了解如何阅读和管理日志,因为它们提供了许多关键和必需的信息。

CommandDescription
dmesgUsed to print the message buffer of the kernel
tailUsed to print details from the log files located in the folder /var/log
journalctlUsed to read systemd logs