標籤:centos7
安裝完centos 7 minimal後,無力吐槽,變化之大,發現以前常用的一些命令都沒有。
一、常用命令安裝
查看anaconda-ks.cfg,原來是沒裝base group的包
[[email protected] ~]# cat anaconda-ks.cfg #version=RHEL7# System authorization informationauth --enableshadow --passalgo=sha512# Use CDROM installation mediacdrom# Run the Setup Agent on first bootfirstboot --enableignoredisk --only-use=sda# Keyboard layoutskeyboard --vckeymap=us --xlayouts=‘us‘# System languagelang en_US.UTF-8 --addsupport=zh_CN.UTF-8# Network informationnetwork --bootproto=dhcp --device=eno16777736 --onboot=off --ipv6=autonetwork --hostname=localhost.localdomain# Root passwordrootpw --iscrypted $6$Zz5VMf1HPPRm0YRL$QSoaU9pAUApXMj9BXuK5qlUFGAfCv9Y/ylVGUcDYv.lrxfNodTiI/7DO1UR7carvL1EdgwQpuiwDt524f6.GR.# System timezonetimezone Asia/Chongqing --isUtc --nontp# System bootloader configurationbootloader --location=mbr --boot-drive=sdaautopart --type=lvm# Partition clearing informationclearpart --none --initlabel %packages@core # 這裡只有core%end
[[email protected] ~]# yum groupinstall base # 安裝完後ifconfig、service、chkconfig等命令就都有了
二、運行層級切換
[[email protected] ~]# 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這裡寫的很明白了,做個軟鏈修改預設運行層級
[[email protected] 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.targetlrwxrwxrwx 1 root root 13 Oct 11 03:51 /lib/systemd/system/runlevel1.target -> rescue.targetlrwxrwxrwx 1 root root 17 Oct 11 03:51 /lib/systemd/system/runlevel2.target -> multi-user.targetlrwxrwxrwx 1 root root 17 Oct 11 03:51 /lib/systemd/system/runlevel3.target -> multi-user.targetlrwxrwxrwx 1 root root 17 Oct 11 03:51 /lib/systemd/system/runlevel4.target -> multi-user.targetlrwxrwxrwx 1 root root 16 Oct 11 03:51 /lib/systemd/system/runlevel5.target -> graphical.targetlrwxrwxrwx 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介紹 https://www.huzs.net/?p=2180
本文出自 “the-way-to-cloud” 部落格,請務必保留此出處http://iceyao.blog.51cto.com/9426658/1562564
Centos 7 - 入門級操作