linux_硬件及系统命令

本文详细介绍了一系列CentOS系统常用的基础命令,包括显示系统信息、查看硬盘情况、内存使用状况、CPU信息、网卡及网络配置等。适用于系统管理员及初学者快速掌握系统管理技能。

摘要生成于 C知道 ,由 DeepSeek-R1 满血版支持, 前往体验 >

1. 显示计算机的基本信息

显示系统信息:

uname

显示所有内容:(内核版本)

uname -a

 

2. 查看硬盘

fdisk -l 

 

df -h

 

3. 查看某一个文件夹占用空间

du –h –max-depth=N

N为遍历文件夹的深度)

 

4. 查看内存

free

 

5. 查cpu

cat /proc/cpuinfo | grep name | cut -f2 -d: | uniq c

 

见有2核,酷睿的型号。

 

6. 查看网卡信息

dmesg | grep -i eth


7. 查看网关

route -n

 

8. 查ip

Ifconfig -a

 

9. 查看主机名

hostname

 

10. 修改主机名

在/etc/sysconfig目录下有个文件:network。内容如下:

NETWORKING=yes

HOSTNAME=localhost.localdomain

直接改为:

NETWORKING=yes

HOSTNAME=zoo1.localdomain

在/etc目录下hosts文件,内容如下:

127.0.0.1   localhost localhost.localdomain localhost4 localhost4.localdomain4

::1         localhost localhost.localdomain localhost6 localhost6.localdomain6

为:

127.0.0.1   localhost zoo1.localdomain localhost4 localhost4.localdomain4

::1         localhost zoo1.localdomain localhost6 localhost6.localdomain6

次输入hostname,查看结果:

 

 

Centos7上面的方法不管用,使用如下命令:

hostnamectl set-hostname zoo1

 

11. 修改hosts文件

 

 

12. 关闭防火

sudo service iptables stop

sudo chkconfig iptables off

    第一条命令表示关闭防火墙服务,第二条命令表示系统启动时不需要启动防火墙服务.由于是系统命令,所以需要添加sudo关键字。

看防火墙状态:

service iptables status

 

-------------------------------------------------------------------------------------------------------------------------------

上面是centos6中的命令,安装centos7后使用不了,提示:

 

查看本机的 iptables 的版本:rpm -qa iptables

 

发现有这个包,可能是没有安装,安装一下(或者卸载后从网上重下一个相同版本的安装)

注:

卸载 iptables : rpm -e --nodeps iptables-1.4.21-xxx.xx  这里需要加上 --nodeps 不考虑依赖,强制卸载。

卸载完毕,安装: rpm -ivh iptables-1.4.21-xxx.xx.rpm

这里没有使用上面的“注”。

安装:yum install iptables-services

设置开机启动:systemctl enable iptables

重启iptablessystemctl restart iptables.service

查看iptables状态:systemctl status iptables.service

 ------------------------------------------------------------------------------------------------

忽略上面那一段,centos7使用如下命令操作防火墙:

#查看firewall

systemctl status firewalld.service

#启动firewall

systemctl start firewalld.service

#停止firewall

systemctl stop firewalld.service

#禁止firewall开机启动

systemctl disable firewalld.service

 

13. 查看时区

timedatectl

 

 

14. 修改时区

timedatectl set -timezone Asia/Shanghai

 

15. 同步时间

timedatectl set -ntp yes

 

16. 中英文操作界面互换

 

 

17. 常见网络服务命令

18. 查看端口占用

netstat -lntup

netstat -antp

 

查看某个进程占用了哪些端口:

netstat -nap | grep pid 

 

 Windows下:

netstat -aon|findstr "443"

 

19. 当前时间

date

 

20. 日历

cal

全年日历

cal -y



评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值