首页 / CENTOS / centos7 常用的命令
centos7 常用的命令
内容导读
互联网集市收集整理的这篇技术教程文章主要介绍了centos7 常用的命令,小编现在分享给大家,供广大互联网技能从业者学习和参考。文章包含3292字,纯文字阅读大概需要5分钟。
内容图文
![centos7 常用的命令](/upload/InfoBanner/zyjiaocheng/1116/49c028cdc7c541d6a369ab8823bf9703.jpg)
-
主机名相关
-
查看主机名hostnamectl 或者hostnamectl status
[root@node82 ~]# hostnamectl status Static hostname: node82 Icon name: computer-server Chassis: server Machine ID: 19f1daaf52fa447dbba66317f374819e Boot ID: b87d00015a854c789cc758f68dc95418 Operating System: CentOS Linux 7 (Core) CPE OS Name: cpe:/o:centos:centos:7 Kernel: Linux 3.10.0-327.el7.x86_64 Architecture: x86-64
-
设置主机名
# hostnamectl set-hostname testname
详细:请参考 http://www.cnblogs.com/linuxprobe/p/5377836.html
2. 查看内核信息
[root@node82 ~]# uname -r 3.10.0-327.el7.x86_64 [root@node82 ~]# uname -a Linux node82 3.10.0-327.el7.x86_64 #1 SMP Thu Nov 19 22:10:57 UTC 2015 x86_64 x86_64 x86_64 GNU/Linux
3. 查看发行版本信息
[root@node82 ~]# cat /etc/centos-release CentOS Linux release 7.2.1511 (Core) [root@node82 ~]# cat /etc/redhat-release CentOS Linux release 7.2.1511 (Core)
4. 语言相关
-
查看当前系统使用的语言
[root@node77 ~]# localectl System Locale: LANG=en_US.UTF-8 VC Keymap: us X11 Layout: us You have mail in /var/spool/mail/root [root@node77 ~]# cat /etc/locale.conf LANG="en_US.UTF-8"
-
查看系统支持的区域语言
[root@node77 ~]# localectl list-locales |grep CN bo_CN bo_CN.utf8 ug_CN ug_CN.utf8 zh_CN zh_CN.gb18030 zh_CN.gb2312 zh_CN.gbk zh_CN.utf8
-
设置区域语言
localectl set-locale LANG=zh_CN.utf8
详情参考:
https://wenku.baidu.com/view/da4887174693daef5ff73dc3.html
http://www.jb51.net/os/RedHat/525830.html
5. 设置网络
-
习惯关闭NetworkManager 服务
如果开启该服务,在/etc/resolv.conf(域名解析)里的配置重启后失效
-
手动修改网卡配置文件(永久生效)/etc/sysconfig/network-scripts/
例如:
vi ifcfg-em1
NAME=em1
DEVICE=em1
ONBOOT=yes
BOOTPROTO=static
TYPE=Ethernet
IPADDR=192.168.100.10
NETMASK=255.255.255.0
GATEWAY=192.168.100.1
修改完成后重启网络服务 systemctl restart network
-
临时修改(立马生效,重启设备失效)
ifconfig 网卡名 ip地址 netmask 子网掩码 例如:ifconfig em1 192.168.0.11 netmask 255.255.255.0 临时禁用/启用网卡 ifconfig em2 down/up
6. 服务相关systemctl
-
查看开机启动的服务
systemctl list-unit-files |grep enabled
-
列出当前使用的运行等级
systemctl get-default
-
列出所有服务(包括启用的和禁用的)
systemctl list-unit-files --type=service
-
修改运行级别
systemd使用比sysvinit的运行级更为自由的 target 概念作为替代。 第 3 运行级用 multi-user.target替代。第 5 运行级用graphical.target替代。 runlevel3.target 和 runlevel5.target 分别是指向 multi-user.target和graphical.target的符号链接。
systemctl isolate multi-user.target (or) systemctl isolate runlevel3.target systemctl isolate graphical.target (or) systemctl isolate runlevel5.target
-
设置多用户模式或图形模式为默认运行等级
# systemctl set-default runlevel3.target # systemctl set-default runlevel5.target
systemd使用链接来指向默认的运行级别。在创建新的链接前,你可以通过下面命令删除存在的链接: rm /etc/systemd/system/default.target
默认切换到运行级 3 :
ln -sf /lib/systemd/system/multi-user.target /etc/systemd/system/default.target
默认切换到运行级 5 :
ln -sf /lib/systemd/system/graphical.target/etc/systemd/system/default.target
-
启动/重启/停止/重载/查看服务状态
# systemctl start httpd.service # systemctl restart httpd.service # systemctl stop httpd.service # systemctl reload httpd.service # systemctl status httpd.service
-
开机自启/禁用/查看开机自启
systemctl enable httpd.service systemctl disable httpd.service systemctl is-enabled httpd.service
详情参考:http://www.linuxidc.com/Linux/2015-07/120833.htm
7. 时间相关设置
timedatectl #查看系统时间方面的各种状态 timedatectl list-timezones # 列出所有时区 timedatectl set-local-rtc 1 # 将硬件时钟调整为与本地时钟一致, 0 为设置为 UTC 时间 timedatectl set-timezone Asia/Shanghai # 设置系统时区为上海
本文出自 “小叶” 博客,请务必保留此出处http://muyuluo.blog.51cto.com/3246561/1914676
原文:http://muyuluo.blog.51cto.com/3246561/1914676
内容总结
以上是互联网集市为您收集整理的centos7 常用的命令全部内容,希望文章能够帮你解决centos7 常用的命令所遇到的程序开发问题。 如果觉得互联网集市技术教程内容还不错,欢迎将互联网集市网站推荐给程序员好友。
内容备注
版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 gblab@vip.qq.com 举报,一经查实,本站将立刻删除。
内容手机端
扫描二维码推送至手机访问。