CentOS7 修改主机名
时间:2014-12-28 00:21 来源:linux.it.net.cn 作者:IT
CentOS 7.0的正式发布有不小的变动,比如不在内置net-tools,移除了service改用systemctl…以及Grub引导
修改主机名
#查看当前主机名#
[root@localhost ~]# hostname
localhost.localdomain
#修改主机名#
[root@localhost ~]# cat /etc/hostname
#new hostname#
ipython.me
#重载环境#
[root@localhost ~]# su -
Last login: Sun Jul 13 14:54:08 EDT 2014 on pts/0
[root@ipython ~]#
systemd
systemctl是systemd服务管理工具最主要的工具,它结合了service和chkconfig功能
##列出服务##
[root@ipython ~]# systemctl
....
UNIT LOAD ACTIVE SUB DESCRIPTION
proc-sys...t_misc.automount loaded active waiting Arbitrary Executable File Fo
dev-mqueue.mount loaded active mounted POSIX Message Queue File Sys
sys-kernel-config.mount loaded active mounted Configuration File System
sys-kernel-debug.mount loaded active mounted Debug File System
....
#以前常用service操作#
[root@ipython ~]# systemctl start postfix.service
[root@ipython ~]# systemctl stop postfix.service
[root@ipython ~]# systemctl restart postfix.service
[root@ipython ~]# systemctl status postfix.service
postfix.service - Postfix Mail Transport Agent
Loaded: loaded (/usr/lib/systemd/system/postfix.service; enabled)
Active: active (running) since Sun 2014-07-13 14:58:34 EDT; 32s ago
....
#以前chkconfig off|on#
[root@ipython ~]# systemctl enable postfix.service
[root@ipython ~]# systemctl disable postfix.service
#查看服务是否自启#
[root@ipython ~]# systemctl is-enabled postfix.service
disabled
#服务运行级别#
#init 3#
[root@ipython ~]# systemctl isolate multi-user.target
[root@ipython ~]# systemctl isolate runlevel3.target
#init 5#
[root@ipython ~]# systemctl isolate graphical.target
[root@ipython ~]# systemctl isolate runlevel5.target
##centos7 不再使用inittab文件来控制运行级别,但该文件仍然存在,并提供了索引##
# inittab is no longer used when using systemd.
#
# ADDING CONFIGURATION HERE WILL HAVE NO EFFECT ON YOUR SYSTEM.
#
# Ctrl-Alt-Delete is handled by /etc/systemd/system/ctrl-alt-del.target
#
# systemd uses 'targets' instead of runlevels. By default, there are two main targets:
#
# multi-user.target: analogous to runlevel 3
# graphical.target: analogous to runlevel 5
#
# To set a default target, run:
#
# ln -sf /lib/systemd/system/.target /etc/systemd/system/default.target
#
(责任编辑:IT)
CentOS 7.0的正式发布有不小的变动,比如不在内置net-tools,移除了service改用systemctl…以及Grub引导
修改主机名
#查看当前主机名#
[root@localhost ~]# hostname
localhost.localdomain
#修改主机名#
[root@localhost ~]# cat /etc/hostname
#new hostname#
ipython.me
#重载环境#
[root@localhost ~]# su -
Last login: Sun Jul 13 14:54:08 EDT 2014 on pts/0
[root@ipython ~]#
systemd
systemctl是systemd服务管理工具最主要的工具,它结合了service和chkconfig功能
##列出服务##
[root@ipython ~]# systemctl
....
UNIT LOAD ACTIVE SUB DESCRIPTION
proc-sys...t_misc.automount loaded active waiting Arbitrary Executable File Fo
dev-mqueue.mount loaded active mounted POSIX Message Queue File Sys
sys-kernel-config.mount loaded active mounted Configuration File System
sys-kernel-debug.mount loaded active mounted Debug File System
....
#以前常用service操作#
[root@ipython ~]# systemctl start postfix.service
[root@ipython ~]# systemctl stop postfix.service
[root@ipython ~]# systemctl restart postfix.service
[root@ipython ~]# systemctl status postfix.service
postfix.service - Postfix Mail Transport Agent
Loaded: loaded (/usr/lib/systemd/system/postfix.service; enabled)
Active: active (running) since Sun 2014-07-13 14:58:34 EDT; 32s ago
....
#以前chkconfig off|on#
[root@ipython ~]# systemctl enable postfix.service
[root@ipython ~]# systemctl disable postfix.service
#查看服务是否自启#
[root@ipython ~]# systemctl is-enabled postfix.service
disabled
#服务运行级别#
#init 3#
[root@ipython ~]# systemctl isolate multi-user.target
[root@ipython ~]# systemctl isolate runlevel3.target
#init 5#
[root@ipython ~]# systemctl isolate graphical.target
[root@ipython ~]# systemctl isolate runlevel5.target
##centos7 不再使用inittab文件来控制运行级别,但该文件仍然存在,并提供了索引##
# inittab is no longer used when using systemd.
#
# ADDING CONFIGURATION HERE WILL HAVE NO EFFECT ON YOUR SYSTEM.
#
# Ctrl-Alt-Delete is handled by /etc/systemd/system/ctrl-alt-del.target
#
# systemd uses 'targets' instead of runlevels. By default, there are two main targets:
#
# multi-user.target: analogous to runlevel 3
# graphical.target: analogous to runlevel 5
#
# To set a default target, run:
#
# ln -sf /lib/systemd/system/.target /etc/systemd/system/default.target
#
(责任编辑:IT) |