CentOS 7入門操作基礎教程

來源:互聯網
上載者:User

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雙系統安裝

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在5個工作日內處理。

如果您發現本社區中有涉嫌抄襲的內容,歡迎發送郵件至: info-contact@alibabacloud.com 進行舉報並提供相關證據,工作人員會在 5 個工作天內聯絡您,一經查實,本站將立刻刪除涉嫌侵權內容。

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.