Centos 7前奏

前端之家收集整理的这篇文章主要介绍了Centos 7前奏前端之家小编觉得挺不错的,现在分享给大家,也给大家做个参考。


Centos 6与7区别

https://zhidao.baidu.com/question/716660948565551765.html

http://www.jb51.cc/article/p-nijepqnk-zv.html

http://www.cnblogs.com/Csir/p/6746667.html


IP配置

自动获取ip命令:dhclient

ip address和 ifconfig 区别 http://www.jb51.cc/article/p-qfvedtww-zw.html

配置静态ip地址文件:vim /etc/sysconfig/network-scripts/ifcfg-ens33


更改系统启动级别:centos7的运行级别都定义在/lib/systemd/system下. 不再是之前的/etc/inittab文件

以下是/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 /usr/lib/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 view current default target,run:

  • # systemctl get-default

  • # To set a default target,192);"># systemctl set-default TARGET.target

[root@localhost ~]# ls -ltr /lib/systemd/system/runlevel*.target

lrwxrwxrwx. 1 root root 16 9月 10 20:58 /lib/systemd/system/default.target -> graphical.target

lrwxrwxrwx. 1 root root 13 9月 10 20:58 /lib/systemd/system/runlevel1.target -> rescue.target

lrwxrwxrwx. 1 root root 15 9月 10 20:58 /lib/systemd/system/runlevel0.target -> poweroff.target

lrwxrwxrwx. 1 root root 17 9月 10 20:58 /lib/systemd/system/runlevel4.target -> multi-user.target

lrwxrwxrwx. 1 root root 17 9月 10 20:58 /lib/systemd/system/runlevel3.target -> multi-user.target

lrwxrwxrwx. 1 root root 17 9月 10 20:58 /lib/systemd/system/runlevel2.target -> multi-user.target

lrwxrwxrwx. 1 root root 16 9月 10 20:58 /lib/systemd/system/runlevel5.target -> graphical.target

lrwxrwxrwx. 1 root root 13 9月 10 20:58 /lib/systemd/system/runlevel6.target -> reboot.target


可以针对不同需要设置不同的运行级别,创建对应的target软链接

设置命令行级别(init 3)方法:

[root@localhost ~]# ln -svf /lib/systemd/system/runlevel3.target /etc/systemd/system/default.target

[root@localhost ~]# ln -svf /lib/systemd/system/multi-user.target /etc/systemd/system/default.target

[root@localhost ~]#systemctl set-default multi-user.target

设置窗口级别(init 5)方法:

[root@localhost ~]# ln -svf /lib/systemd/system/runlevel5.target /etc/systemd/system/default.target

[root@localhost ~]# ln -svf /lib/systemd/system/graphical.target /etc/systemd/system/default.target

[root@localhost ~]#systemctl set-default graphical.target

关机命令:init 0 、shutdowm -r now 、poweroff

用户模式:开机进入选择系统模式,按e键进入单用户编辑模式,光标移动到下图,修改ro(只读)值为rw(可读可写),添加 启动路径:init=/sysroot/bin/sh.按ctrl+x保存启动

切换原系统用户下:chrooot /sysroot/

切换后可以完成更改root用户密码等操作。

出现小方块是因为系统为中文,需要指定语言:LANG=en

用户更改密码后必须生效selinux:touch /.autorelabel

救援模式

挂载光驱开机启动,选择Troubleshooting选项

spacer.gif

进入后,选择Rescue a Centos Linux system

spacer.gif

此时有几个选项:继续、只读、跳过shell、离开。选择1继续。

spacer.gif

进入shell后,需要切换回原操作系统用户下:chroot /mnt/sysimage,需要注意的是在进入单用户模式下,切换回原操作系统用户:chroot /sysroot/。切换后才能找到原系统下的相关目录和文件。切换后可以进行更改密码、更改配置文件等操作。

spacer.gif

更改主机名:hostnamectl set-hostname centos7

主机名配置文件: /etc/hostname

远程连接另一台linux:ssh -p 端口 用户名@Ip

使用ssh-keygen密钥登陆:

A ――远程――>B

A机器:ssh-keygen生成公钥和私钥,复制公钥内容

B机器:/root/.ssh/创建authorized_keys文件,将复制的公钥内容粘贴至该文件中。

原文链接:https://www.f2er.com/centos/377429.html

猜你在找的CentOS相关文章