centos7linux菜鸟入门,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的理念基础)。

0b1331709591d260c1c78e86d0c51c18.png

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值