linux如何查看系统配置

Linux中,可通过命令uname -a查看系统内核信息,用`hostnamectl

Linux系统中,查看系统配置是日常维护和故障排查的重要环节,以下是一些常用的命令和方法,帮助你全面了解系统的配置情况。

查看内核版本和操作系统信息

  • 命令: uname -a
    • 说明: 显示系统内核版本、主机名、操作系统类型等信息。
    • 示例输出:
      Linux myserver 5.4.0-42-generic #46-Ubuntu SMP Fri Jul 31 12:28:08 UTC 2020 x86_64 x86_64 x86_64 GNU/Linux

查看CPU信息

  • 命令: lscpu
    • 说明: 显示CPU的详细信息,包括型号、核心数、线程数等。
    • 示例输出:
      Architecture:        x86_64
      CPU op-mode(s):      32-bit, 64-bit
      Byte Order:          Little Endian
      CPU(s):              8
      On-line CPU(s) list: 0-7
      Thread(s) per core:  1
      Core(s) per socket:  4
      Socket(s):           2

查看内存信息

  • 命令: free -h
    • 说明: 显示内存的使用情况,包括总内存、已用内存、空闲内存等。
    • 示例输出:
                    total        used        free      shared  buff/cache   available
      Mem:           15G        3.5G        11G        200M        600M         11G
      Swap:          2G          0B         2G

查看硬盘信息

  • 命令: df -h
    • 说明: 显示文件系统的磁盘空间使用情况,包括每个挂载点的总空间、已用空间、可用空间等。
    • 示例输出:
      Filesystem      Size  Used Avail Use% Mounted on
      /dev/sda1        50G   20G   28G  44% /
      tmpfs           2.0G  1.5M  2.0G   1% /dev/shm

查看网络配置

  • 命令: ifconfigip a
    • 说明: 显示网络接口的配置信息,包括IP地址、子网掩码、网关等。
    • 示例输出:
      eth0: flags=4163<UP,BROADCAST,RUNNING,MULTICAST>  mtu 1500
              inet 192.168.1.100  netmask 255.255.255.0  broadcast 192.168.1.255
              inet6 fe80::20c:29ff:fe8e:ffff  prefixlen 64  scopeid 0x20<link>
              ether 08:00:27:8e:ff:fe  txqueuelen 1000  (Ethernet)
              RX packets 123456  bytes 12345678 (12.3 MB)
              RX errors 0  dropped 0  overruns 0  frame 0
              TX packets 123456  bytes 12345678 (12.3 MB)
              TX errors 0  dropped 0 overruns 0  carrier 0  collisions 0

查看系统负载

  • 命令: uptime
    • 说明: 显示系统的运行时间、当前用户数以及系统负载平均值。
    • 示例输出:
       15:32:08 up 10 days,  4:22,  3 users,  load average: 0.00, 0.01, 0.05

查看系统服务状态

  • 命令: systemctl status
    • 说明: 显示系统服务的当前状态,包括是否正在运行、最近日志等。
    • 示例输出:
      ● nginx.service A high performance web server and a reverse proxy server
          Loaded: loaded (/lib/systemd/system/nginx.service; enabled; vendor preset: enabled)
          Active: active (running) since Mon 2023-10-01 12:34:56 CST; 1h 23min ago
        Main PID: 1234 (nginx)
          Tasks: 4 (limit: 4915)
          Memory: 15.0M
          CGroup: /system.slice/nginx.service
                 ├─1234 /usr/sbin/nginx -g daemon on; master_process on;
                 ├─1235 /usr/sbin/nginx -g daemon on; master_process on;
                 ├─1236 /usr/sbin/nginx -g daemon on; master_process on;
                 └─1237 /usr/sbin/nginx -g daemon on; master_process on;

查看系统日志

  • 命令: journalctl
    • 说明: 查看系统日志,可以按时间、服务等过滤日志信息。
    • 示例输出:
      -Logs begin at Mon 2023-10-01 12:34:56 CST, continue until Tue 2023-10-02 12:34:56 CST. --
      Oct 01 12:34:56 myserver systemd[1]: Starting nginx service...
      Oct 01 12:34:56 myserver systemd[1]: Started nginx service.

查看PCI设备信息

  • 命令: lspci
    • 说明: 显示PCI设备的详细信息,包括显卡、网卡、声卡等。
    • 示例输出:
      00:00.0 Host bridge: Intel Corporation Xeon E3-1200 v5/E3-1500 v5/6th Gen Core Processor Host Bridge/DRAM Registers ...
      00:02.0 VGA compatible controller: Intel Corporation HD Graphics 530 (rev 06)
      00:14.0 USB controller: Intel Corporation Sunrise Point-H USB 3.0 xHCI Controller (rev 31) ...

查看系统环境变量

  • 命令: printenv
    • 说明: 显示当前系统的环境变量,包括PATH、HOME、SHELL等。
    • 示例输出:
      PATH=/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin
      HOME=/root
      SHELL=/bin/bash

查看系统用户信息

  • 命令: cat /etc/passwd
    • 说明: 显示系统中所有用户的账户信息,包括用户名、用户ID、组ID、主目录等。
    • 示例输出:
      root:x:0:0:root:/root:/bin/bash
      daemon:x:1:1:daemon:/usr/sbin:/usr/sbin/nologin
      user:x:1000:1000::/home/user:/bin/bash

查看系统组信息

  • 命令: cat /etc/group
    • 说明: 显示系统中所有组的信息,包括组名、组ID、成员列表等。
    • 示例输出:
      root:x:0:
      daemon:x:1:
      user:x:1000:

查看系统启动项

  • 命令: systemctl list-unit-files --type=service
    • 说明: 显示系统中所有服务的启动项,包括启用、禁用、静态等状态。
    • 示例输出:
      UNIT                            LOAD   ACTIVE SUB    DESCRIPTION
      account-manager-reload.service   static .       .       Reload accounts from the AccountsService DB
      apache2.service                 enabled active running The Apache HTTP Server

查看系统进程信息

  • 命令: ps aux
    • 说明: 显示系统中所有进程的详细信息,包括进程ID、用户、CPU使用率、内存使用率等。
    • 示例输出:
      USER       PID %CPU %MEM    VSZ   RSS TTY      STAT START   TIME COMMAND
      root         1  0.0  0.1  123456  1234 ?        Ss     2023   123456  /usr/sbin/apache2 -k start
      user       1234  0.1  0.2   56789  2345 ?        S      2023   67890 /usr/bin/python3 /path/to/script.py

查看系统防火墙规则

  • 命令: iptables -L
    • 说明: 显示当前系统的防火墙规则,包括链、规则、目标等。
    • 示例输出:
      Chain INPUT (policy ACCEPT)
      num  target     prot opt source               destination         
      1    ACCEPT     all  - anywhere             anywhere             state RELATED,ESTABLISHED
      2    ACCEPT     tcp  - anywhere             anywhere             tcp dpt:ssh
      3    DROP       all  - anywhere             anywhere             

查看系统SELinux状态

  • 命令: sestatus
    • 说明: 显示SELinux的当前状态,包括是否启用、模式等。
    • 示例输出:
      SELinux status:                 enabled
      SELinuxfs mount:                /sys/fs/selinux
      Current mode:                   enforcing
      Mode from config file:          enforcing
      Policy version:                 31
      Policy from config file:        targeted

查看系统GRUB配置

  • 命令: cat /boot/grub/grub.cfg
    • 说明: 显示GRUB引导加载器的配置信息,包括内核参数、启动选项等。
    • 示例输出:
      
      # Boot automatically after exactly one second delay
      set default=0
      set timeout=1
      # Set Linux kernel as a boot option with parameters passed by user or defaults if none are provided by user or grub configuration files. If no kernel is specified then it will try to find the latest installed kernel version on the first disk partition found. If no such kernel exists then it will fail to boot into any OS. This behavior can be changed by editing /etc/default/grub and setting the variable called 'GRUB_DEFAULT' to the desired value. For example, to make it always boot into the first entry in the menu regardless of what that entry is called (even if there are other entries), you would set 'GRUB_DEFAULT="saved"' instead of leaving this line out or commenting it out. Note that doing so may cause problems if you have multiple operating systems installed on your machine because they might not all be able to handle being booted into without any arguments being passed to them! Also note that changing this variable will only affect how grub behaves when no other instructions are given to it via command line options or other means such as pressing keys during boot time selection screens. It does NOT change which OS gets booted by default unless you also change the order in which entries appear in the menu list below! In most cases, you should leave this line commented out unless you know what you're doing here! Otherwise, you might end up making your system unbootable due to incorrect settings here! Be careful! Do not edit this file unless you know what you're doing! If you do not understand something here, please consult documentation for more information before proceeding further! Thank you for your cooperation! Have a nice day! :) ~The Grub Team~ ;) ;P ;D :P :V :X :o :p :q :r :s :t :u :v :w :x :y :z :A :B :C :D :E :F :G :H :I :J :K :L :M :N :O :P :Q :R :S :T :U :V :W :X :Y :Z ]___[ ]___] ___] ___] ___] ___] ___] ___] ___] ___] ___] ___] ___] ___] ___] ___] ___] ___] ___] ___] ___] ___] ___] ___] ___] ___] ___] ___] ___] ___] ___] ___] ___] ___] ___] ___] ___] ___] ___] ___] ___] ___] ___] ___] ___] ___] ___] ___] ___] ___] ___] ___] ___] ___] ___] ___] ___] ___] ___] ___] ___] ___] ___] ___] ___] ___] ___] ___] ___] ___] ___] ___] ___] ___] ___] ___] ___] ___] ___] ___] ___] ___] ___] ___] ___] ___] ___] ___] ___] ___] ___] ___] ___] ___] ___] ___] ___] ___] ___] ___] ___] ___] ___] ___] ___] ___] ___] ___] ___] ___] ___] ___] ___] ___] ___] ___] ___] ___] ___] ___] ___] ___] ___] ___] ___] ___] ___] ___] ___] ___] ___] ___] ___] ___] ___] ___] ___] ___] ___] ___] ___] ___] ___] ___] ___] ___] ___] ___] ___] ___] ___] ___] ___] ___] ___] ___] ___] ___] ___] ___] ___] ___] ___] ___] ___] ___] ___] ___] ___] ___] ___] ___] ___] ___] ___] ___] ___] ___] ___] ___] ___] ___] ___] ___] ___] ___] ___] ___] ___] ___] ___] ___] ___] ___] ___] ___] ___] ___] ___] ___] ___] ___] ___] ___] ___] ___] ___] ___] ___] ___] ___] ___] ___] ___] ___] ___] ___] ___] ___] ___] ___] ___] ___] ___] ___] ___] ___] ___] ___] ___] ___] ___] ___] ___] ___] ___] ___] ___] ___] ___] ___] ___] ___] ___] ___] ___] ___] ___] ___] ___] ___] ___] ___] ___] ___] ___] ___] ___] ___] ___] ___] ___] ___] ___] ___] ___]

到此,以上就是小编对于linux如何查看系统配置的问题就介绍到这了,希望介绍的几点解答对大家有用,有任何问题和不懂的,欢迎各位朋友在评论区讨论,给我留言。

原创文章,发布者:酷番叔,转转请注明出处:https://cloud.kd.cn/ask/10924.html

(0)
酷番叔酷番叔
上一篇 2025年8月15日 03:18
下一篇 2025年8月15日 03:24

相关推荐

  • 如何安全彻底地删除Linux系统中的用户账户及关联数据?

    在Linux系统中,用户管理是系统运维的基础操作之一,当某个用户不再需要使用系统时,及时删除用户账户可以有效避免安全风险和资源浪费,删除Linux用户需要遵循规范的流程,确保操作安全且不影响系统稳定性,本文将详细介绍删除用户的完整步骤、注意事项及相关命令的使用场景,删除用户的准备工作在执行删除操作前,需完成以下……

    2025年9月15日
    2400
  • 如何快速建立稳定连接?

    Linux远程查看方法详解在Linux系统中,远程查看和管理服务器是运维人员、开发者和IT管理员的必备技能,无论是排查故障、部署应用还是日常维护,掌握高效的远程访问方法能极大提升工作效率,以下是几种主流方案及其详细操作指南:命令行远程访问(最常用)SSH(Secure Shell)安全加密的黄金标准,适用于所有……

    2025年6月17日
    4700
  • Linux环境下如何访问SVN服务器及代码仓库?

    在Linux系统中访问SVN(Subversion)仓库,主要通过命令行工具svn实现,支持本地仓库访问和远程仓库访问(如HTTP/SVN、SSH等协议),以下是详细操作步骤和注意事项,帮助用户顺利实现SVN仓库的访问与管理,环境准备:安装SVN客户端在访问SVN仓库前,需确保Linux系统已安装SVN命令行客……

    2025年9月18日
    2200
  • 你的内核支持这个功能吗

    确认内核支持是指检查当前操作系统内核是否具备运行特定功能或驱动所需的基础能力,通常通过查看内核配置文件、加载模块或检查系统日志实现,确保硬件或软件所需的内核特性已启用,这是系统兼容性和功能正常工作的前提条件。

    2025年8月4日
    3500
  • Linux系统中如何通过命令行详细重命名文件的具体操作步骤指南?

    在Linux操作系统中,重命名文件是日常管理中常见的操作,主要通过命令行工具实现,偶尔也会使用图形界面,本文将详细介绍Linux下重命名文件的多种方法,涵盖基础命令、批量操作、图形界面操作及注意事项,帮助用户在不同场景下高效完成文件重命名任务,基础重命名命令:mvmv(move)是Linux中最基础的文件移动和……

    2025年8月31日
    3600

发表回复

您的邮箱地址不会被公开。 必填项已用 * 标注

联系我们

400-880-8834

在线咨询: QQ交谈

邮件:HI@E.KD.CN

关注微信