CentOS 7入門操作基礎教程
安裝完CentOS 7 minimal後,無力吐槽,變化之大,發現以前常用的一些命令都沒有。
一、常用命令安裝
查看anaconda-ks.cfg,原來是沒裝base group的包
[root@centos7 ~]# cat anaconda-ks.cfg
#version=RHEL7
# System authorization information
auth --enableshadow --passalgo=sha512
# Use CDROM installation media
cdrom
# Run the Setup Agent on first boot
firstboot --enable
ignoredisk --only-use=sda
# Keyboard layouts
keyboard --vckeymap=us --xlayouts='us'
# System language
lang en_US.UTF-8 --addsupport=zh_CN.UTF-8
# Network information
network --bootproto=dhcp --device=eno16777736 --onboot=off --ipv6=auto
network --hostname=localhost.localdomain
# Root password
rootpw --iscrypted $6$Zz5VMf1HPPRm0YRL$QSoaU9pAUApXMj9BXuK5qlUFGAfCv9Y/ylVGUcDYv.lrxfNodTiI/7DO1UR7carvL1EdgwQpuiwDt524f6.GR.
# System timezone
timezone Asia/Chongqing --isUtc --nontp
# System bootloader configuration
bootloader --location=mbr --boot-drive=sda
autopart --type=lvm
# Partition clearing information
clearpart --none --initlabel
%packages
@core # 這裡只有core
%end
[root@centos7 ~]# yum groupinstall base # 安裝完後ifconfig、service、chkconfig等命令就都有了
二、運行層級切換
[root@centos7 ~]# cat /etc/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 name>.target /etc/systemd/system/default.target
這裡寫的很明白了,做個軟鏈修改預設運行層級
[root@centos7 system]# ll /lib/systemd/system/runlevel*.target # 系統0-6 7個運行層級,2 3 4 運行指向同一個檔案
lrwxrwxrwx 1 root root 15 Oct 11 03:51 /lib/systemd/system/runlevel0.target -> poweroff.target
lrwxrwxrwx 1 root root 13 Oct 11 03:51 /lib/systemd/system/runlevel1.target -> rescue.target
lrwxrwxrwx 1 root root 17 Oct 11 03:51 /lib/systemd/system/runlevel2.target -> multi-user.target
lrwxrwxrwx 1 root root 17 Oct 11 03:51 /lib/systemd/system/runlevel3.target -> multi-user.target
lrwxrwxrwx 1 root root 17 Oct 11 03:51 /lib/systemd/system/runlevel4.target -> multi-user.target
lrwxrwxrwx 1 root root 16 Oct 11 03:51 /lib/systemd/system/runlevel5.target -> graphical.target
lrwxrwxrwx 1 root root 13 Oct 11 03:51 /lib/systemd/system/runlevel6.target -> reboot.target
三、systemctl管理系統服務
systemctl可以看作是service和chkconfig的組合
job
|
chkconfig、service |
systemctl |
| 服務開機自啟動 |
chkconfig --level 3 httpd on |
systemctl enable httpd |
| 服務不開機自啟動 |
chkconfig --level 3 httpd off |
systemctl disable httpd |
|
服務狀態 |
service httpd status |
systemctl status httpd(服務詳細資料)
systemctl is-active httpd(只顯示是否active)
|
| 所有服務的啟動狀態 |
chkconfig --list |
systemctl list-units --type=service |
| 啟動服務 |
service httpd start |
systemctl start httpd |
| 停止服務 |
service httpd stop |
systemctl stop httpd |
| 重啟服務 |
service httpd restart |
systemctl restart httpd |
centos 7之前的版本都採用Sysvinit的系統啟動進程管理體系,因為是串列的進程啟動流程,可能因為某個進程的阻塞而影響啟動過程。centos 7使用systemd。目標是儘可能啟動更少進程;儘可能將更多進程並行啟動(這是效能優於SysVinit的理念基礎)。
更詳解的systemd介紹
RHEL7/CentOS7預設運行層級和終端解析度
隨身碟安裝CentOS 7.0圖文詳解教程
隨身碟安裝64位CentOS 6.5方法
Win7安裝64位CentOS 6.4雙系統詳細圖文教程
CentOS與Windows雙系統安裝注意事項記錄
UEFI+GPT安裝Windows8和CentOS雙系統
Windows8.1和CentOS6.5雙系統安裝