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 /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