Linux基础
Posted
tags:
篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了Linux基础相关的知识,希望对你有一定的参考价值。
救援模式
centos6启动时有7个选项0-6;
centos7
查看启动选项:ls -l /usr/lib/systemd/system/runlevel*target

开机设置bios,选择光驱启动;
centos7下救援模式为Troubleshooting;
选择此项,enter进入;

选择第二项 Rescue a Centos Linux system

输入1继续

输入chroot /mnt/sysimage,输入passwd root提示更改root 用户密码,输入新密码,再次输入密码,即可更改root密码;
关闭电源,卸载光驱即可;
克隆虚拟机
先关闭虚拟机运行的系统;
管理-克隆-下一步-创建链接克隆(节省空间)等待完成,关闭即可;
开机启动后,编辑ip地址,删除UUID这一列,保存退出;
重启网络服务即可;
vim /etc/systemconfig/network-script/if-cfg
systemctl restart network.service
hostname 查看主机名;
hostnamectl set-hostname liyang-01 更改主机名;
推出再重新进入就可以看到主机名;
主机名的配置文件在 cat /etc/hostname
保存快照

Linux主机相互登陆
标准写法:ssh [email protected]
ssh 192.168.164.130
01连02

02连01

w查看
标准写法

ssh -p 22 [email protected]
ssh -p指定端口;
ssh-keygen工具自动生成公钥私钥
直接回车(此处未设置任何密码)
公钥和私钥默认保存在/root/.ssh/目录下

cat /root/.ssh/id_rsa.pub查看公钥,复制公钥
打开01主机,vi /root/.ssh/authorized_keys
备注并粘贴,保存退出;

getenforce查看selinux状态,Enforcing状态为selinux开启状态,permissive为关闭状态;
setenforce 0 关闭selinux;
以上是关于Linux基础的主要内容,如果未能解决你的问题,请参考以下文章