第二十一天
第二十一天
家目录特殊文件
history命令讲解
[root@master ~]# ls
1.txt anaconda-ks.cfg CentOS6-Base-163.repo hosts motd nwq1.6.sh profile test.txt
[root@master ~]# ls -a
. .1.txt.swp .bash_logout CentOS6-Base-163.repo motd .ssh .viminfo
.. anaconda-ks.cfg .bash_profile .cshrc nwq1.6.sh .tcshrc
1.txt .bash_history .bashrc hosts profile test.txt
root@master ~]# cat .bash_history
sed -i '/^SELINUX=/c SELINUX=disabled' /etc/selinux/config
systemctl disable --now firewalld
yum -y install autofs
systemctl enable --now autofs
sed -ri '/GRUB_CMDLINE_LINUX=/s#(.*)"$#\1 net.ifnames=0"#' /etc/default/grub
grub2-mkconfig -o /boot/grub2/grub.cfg
reboot
ip a
cd /etc
ip a
vi hosts
ping node
ping 10.0.0.164
vi 1.txt
ls
echo "hello world\!" > test.txt
vi test.txt
yum install cowsay
yum -y install wget
wget -O /etc/yum.repos.d/CentOS-Base.repo http://mirrors.aliyun.com/repo/Centos-7.repo
wget http://mirrors.163.com/.help/CentOS6-Base-163.repo
yum clean all
yum makecache
yum -y update
yum -y install cowsay
nano motd
yum -y install nano
nano motd
reboot
cd /etc/profile
cd /etc/profile/
cd /etc/profile
cd /etc/profile/
cd /etc
ls
vi profile
reboot
vi profile
cd /etc/
ls
vi profile
vi 1.sh
sh 1.sh
vi 1.sh
vi motd
reboot
nano /etc/motd
reboot
exit
ip a
nmtui
ip a
systemctl restart network
export LANG="en_US";export LANGUAGE="en_US";export LC_ALL="en_US";top
sudo systemctl restart network
ip a
sudo service network restart
ip a
reboot
ip a
.bash_history 历史记录命令文件,如果以后入职了,可以把这个文件拷贝出来,分析上个运维他平时操作的命令 分析他的工作流程
.bash_history 这个里面全都是执行过的历史命令,历史记录命令文件
保存方式
1.保存到内存中
1.实战演示普通用户如何像root用户一些操作管理系统演示下 因为入职做运维基本都是普通用户登录的系统
自己创建it账号
结果实现 it账号只能 创建用户权限 和删除用户权限 cp mv 其他都没有权限
试用期过了 领导想给你rm 权限如何配置
useradd it
passwd it
useradd it;echo 1 |passwd --studin it
此命令虽然可能报错,但仍然会创建成功
1.创建it用户
useradd it
passwd it
2.修改用户权限配置sudoers文件
visudo
或vi /etc/sudoers
添加这行useradd、userdel、cp、mv 不知道命令可以用which查询
it ALL=(ALL) NOPASSWD:/usr/sbin/useradd, /usr/sbin/userdel, /bin/cp, /bin/mv
3.试用期过了,再给rm权限
visudo
或
vi /etc/sudoers
添加这行
it ALL=(ALL) NOPASSWD:/usr/sbin/useradd, /usr/sbin/userdel, /bin/cp, /bin/mv,/usr/bin/rm
4.保存退出,测试
2 创建一个lijun用户 不创建家目录不能登录系统
sudo useradd -M -s /sbin/nologin lijun
命令注解:
useradd: 添加新用户的命令。
-M: 不创建用户的主目录。默认情况下,useradd会为新用户创建一个位于/home/目录下的主目录,其名称与用户名相同。使用-M选项将阻止创建这个目录。
-s /sbin/nologin: 设置用户的登录shell为/sbin/nologin,这将防止用户通过shell登录系统。
lijun: 要创建的新用户的用户名
3 先创建一个kaifa组 ,把lijun 用户 加入 kaifa组
groupadd kaifa
usermod -a -G kaofa lijun
命令注解
usermod -a -G kaofa lijun
这条命令会将 lijun 用户追加到 kaifa 组中。如果 lijun 用户之前已经是其他组的成员,使用 -a 选项可以确保他不会从这些组中移除,而只是被添加到 kaifa 组中作为附加组的成员
4 增加用户、 删除用户 改变用户权限 改变属主属组 修改用户信息 命令都 写下
增加用户
useradd
删除用户
userdel
改变用户权限
chmod
改变属主属组
chown
修改用户信息
usermod