如何在Deepin15.11中创建Sudo用户
sudo 命令允许我们以系统管理员运行任何 命令或选定的命令。 |
环境
Deepin 15.11
10余年的定边网站建设经验,针对设计、前端、开发、售后、文案、推广等六对一服务,响应快,48小时及时工作处理。营销型网站建设的优势是能够根据用户设备显示端的尺寸不同,自动调整定边建站的显示方式,使网站能够适用不同显示终端,在浏览器中调整网站的宽度,无论在任何一种浏览器上浏览网站,都能展现优雅布局与设计,从而大程度地提升浏览体验。创新互联建站从事“定边网站设计”,“定边网站推广”以来,每个客户项目都认真落实执行。
创建一个新用户
使用 adduser创建一个用户,用户名为 user01
bob@bob-PC:~$ sudo adduser user01 Adding user `user01' ... Adding new group `user01' (1001) ... Adding new user `user01' (1001) with group `user01' ... Creating home directory `/home/user01' ... Copying files from `/etc/skel' ... Enter new UNIX password: Retype new UNIX password: passwd: password updated successfully Changing the user information for user01 Enter the new value, or press ENTER for the default Full Name []: user01 Room Number []: Work Phone []: Home Phone []: Other []: Is the information correct? [Y/n] Y
添加user01这个用户到sudo组里面
sudo组的所有成员都在Deepin系统上授予sudo和root访问权限。因此,要将刚刚创建的user01用户添加到sudo组,请运行以下命令:
bob@bob-PC:~$ sudo adduser user01 sudo Adding user `user01' to group `sudo' ... Adding user user01 to group sudo Done.
使用 id命令查看一下用户是否添加到sudo组了
bob@bob-PC:~$ id user01 uid=1001(user01) gid=1001(user01) groups=1001(user01),27(sudo)
测试sudo用户账号
现在user01用户使用ssh登录到本机测试
bob@bob-PC:~$ ssh user01@localhost The authenticity of host 'localhost (127.0.0.1)' can't be established. ECDSA key fingerprint is SHA256:TKkqZwt9OzPaVSwSkFoLXtAFwnU4aKMG7T8QyF2fPKw. Are you sure you want to continue connecting (yes/no)? yes Warning: Permanently added 'localhost' (ECDSA) to the list of known hosts. user01@localhost's password: Welcome to Deepin 15.11 GNU/Linux * Homepage:https://www.deepin.org/ * Bugreport:https://feedback.deepin.org/feedback/ * Community:https://bbs.deepin.org/ user01@bob-PC:~$
检验一下sudo是否好用:
user01@bob-PC:~$ ls -l /root ls: cannot open directory '/root': Permission denied user01@bob-PC:~$ sudo ls -l /root [sudo] password for user01: total 4 drwxr-xr-x 2 root root 4096 Mar 6 18:05 模板
如何使用sudo执行命令
使用例子:
sudo [option] command sudo -i sudo -s sudo systemctl restart networking sudo tail -f /var/log/boot.log
如何从sudo组里删掉指定的用户
user01@bob-PC:~$ sudo deluser user01 sudo Removing user `user01' from group `sudo' ... Done. # 查看一下用户是否不在sudo组里面了 user01@bob-PC:~$ id user01 uid=1001(user01) gid=1001(user01) groups=1001(user01)
如何删除一个用户:
bob@bob-PC:~$ sudo deluser --remove-home user01 Looking for files to backup/remove ... Removing files ... Removing user `user01' ... Warning: group `user01' has no more members. Done.
总结
sudo命令允许我们以系统管理员运行任何命令或选定的命令。
原文地址: https://www.linuxprobe.com/deepin-create-sudo-user.html
网站题目:如何在Deepin15.11中创建Sudo用户
网页URL:http://scyanting.com/article/psgcjh.html