一、背景介绍:CentOS最小化安装后很多常用命令无法使用,这里简单介绍两个配置常用命令
1.CentOS最小化安装默认自带vi,功能没有vim丰富,安装vim取代vi:
输入命令:yum install vim
安装过程中,多次提示Is this ok y/N:,输入y回车即可,最后提示Complete!表示安装成功!
2. 安装ifconfig 需要输入一下命令yum install net-tools
3. 评论区可以增加 后续整理补充
4.
二、背景介绍:在安装的只配置了root 用户 没有新建用户 或者之后还想建新的用户,可以按如下方式操作
1.创建用户
(1)在root登陆状态下创建一个新用户 master
[root@localhost ~]# adduser master
(2)为新建用户设置密码
[root@localhost~]# passwd master
Changing password for user master
New password: # 输入密码
Retype new password: # 再次输入密码
passwd: all authentication tokens updated successfully.
2.授权
个人用户的权限只可以在本home下有完整权限,其他目录需要别人授权。经常需要root用户的权限,可以通过修改sudoers文件来赋予权限。
新创建的用户并不能使用sudo命令,需要给他添加授权。
(1)查找sudoers文件路径
[root@localhost~]# whereis sudoers # 查找sudoers文件路径
sudoers: /etc/sudoers /etc/sudoers.d /usr/share/man/man5/sudoers.5.gz
(2)查看权限并授权
[root@localhost~]# ls -l /etc/sudoers # 查看权限
-r--r----- 1 root root 3938 Sep 6 2017 /etc/sudoers # 只有读权限
[root@localhost~]# chmod -v u+w /etc/sudoers # 赋予读写权限
mode of ‘/etc/sudoers’ changed from 0440 (r--r-----) to 0640 (rw-r-----)
(3)修改sudoers文件
[root@localhost~]# vim /etc/sudoers #进到文件中
按下Insert 即可进行编辑,然后输入:wq 保存退出
(4)如需收回权限 即可这样操作
[root@localhost~]# chmod -v u-w /etc/sudoers
mode of ‘/etc/sudoers’ changed from 0640 (rw-r-----) to 0440 (r--r-----)