歡迎來到Linux教程網
Linux教程網
Linux教程網
Linux教程網
您现在的位置: Linux教程網 >> UnixLinux >  >> Linux基礎 >> Linux教程

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介紹 http://www.linuxidc.com/Linux/2014-11/109232.htm

RHEL7/CentOS7默認運行級別和終端分辨率 http://www.linuxidc.com/Linux/2014-07/104759.htm

U盤安裝CentOS 7.0圖文詳解教程 http://www.linuxidc.com/Linux/2014-10/108014.htm

U盤安裝64位CentOS 6.5方法 http://www.linuxidc.com/Linux/2014-04/100035.htm

Win7安裝64位CentOS 6.4雙系統詳細圖文教程 http://www.linuxidc.com/Linux/2014-04/100032.htm

CentOS與Windows雙系統安裝注意事項記錄 http://www.linuxidc.com/Linux/2014-05/101571.htm

UEFI+GPT安裝Windows8和CentOS雙系統 http://www.linuxidc.com/Linux/2014-05/101575.htm

Windows8.1和CentOS6.5雙系統安裝 http://www.linuxidc.com/Linux/2014-05/101581.htm

更多CentOS相關信息見CentOS 專題頁面 http://www.linuxidc.com/topicnews.aspx?tid=14

Copyright © Linux教程網 All Rights Reserved