Linux 常用命令(1):系统基本结构
系统与硬件
lspci查看系统 PCI 设备lspci -v查看系统 PCI 设备详细信息
more /proc/cpuinfo查看 CPU 信息cat /proc/cpuinfo | grep "physical id" | sort | uniq | wc -l查看系统物理 CPU 的个数cat /proc/cpuinfo | grep "cpu cores"查看每个物理 CPU 中内核的个数cat /proc/cpuinfo | grep "processor" | wc -l查看系统所有逻辑 CPU 个数(所有物理 CPU 中内核的个数加上超线程个数)
more /proc/meminfo查看系统内存信息fdisk -l查看磁盘分区信息mount -t 文件系统类型 设备名 挂载点挂载设备mount -t msdos /dev/fd0 /mnt/floppy挂载软盘mount -t vfat /dev/sda1 /mnt/usb挂载 U 盘mount -t iso9660 /dev/hda /mnt/cdrom或mount /dev/cdrom /mnt/cdrom挂载光盘
umount 挂载目录卸载设备umount /mnt/usb卸载 U 盘umount /mnt/cdrom卸载光盘
文件系统
- /etc:存放系统管理相关的配置文件
- /usr:存放应用程序和文件
- /var:存放系统运行以及软件运行的日志信息
- /dev:包含系统所有的设备文件
- /proc:一个虚拟目录,目录中所有信息都是内存的映射。存在于内存中。
- /boot:存放启动 Linux 时的一些核心文件
- /bin & /sbin:存放可执行的二进制文件
- /sbin:Super User 只有超级用户才能执行这些命令
- /home:每个用户的工作目录
- /lib:存放共享程序库和映射文件,可供很多程序使用
- /root:Linux 超级用户 root 的默认目录
- /run:外在设备的自动挂载点目录
- /lost+found:该目录用于保存丢失的文件
- /tmp:临时文件目录
运行机制
ll /lib/systemd/system/runlevel*.target运行级别和 target 的关系shutdown关机shutdown [-fFhknrc(参数名称)] [-t 秒数] 时间 [警告信息]shutdown -r now立即关机重启shutdown -h now立即关机shutdown +5 "System will shutdown after 5 minutes"5 分钟后关机,同时发出警告信息给登录的 Linux 用户
halt关机halt [-finp]
reboot重启init切换系统运行级init 0切换到 0,也就是关机init 6切换到 6,也就是重启
系统服务管理工具 systemd
systemctl start httpd.service启动 httpd 服务systemctl stop httpd.service停止 httpd 服务systemctl restart httpd.service重启 httpd 服务systemctl try-restart httpd.service只在程序已经运行的情况下重启服务systemctl reload httpd.service重新加载配置文件systemctl enable httpd.service启用 httpd 服务systemctl disable httpd.service禁用 httpd 服务systemctl status httpd.service查看 httpd 服务状态systemctl poweroff关闭系统systemctl reboot重启系统systemctl suspend进入待机模式systemctl hibernate进入休眠模式systemctl hybird-sleep进入混合休眠模式apt install lrzsz安装 lrzsz 软件包rz上传sz 需要下载文件的路径下载- 默认保存在当前用户主目录下的 Downloads 目录