ubunru 进不了超级用户_【部分解决】Ubuntu中提升当前普通用户的权限使其变成sudo超级用户...

【问题】

已安装一个Ubuntu虚拟机。

在其中想要折腾开发方面的事情。

需要去到opt下建立文件夹,结果竟然说没权限:crifan@ubuntu:~/develop$ pwd

/home/crifan/develop

crifan@ubuntu:~/develop$ cd /opt/

crifan@ubuntu:/opt$ ls

crifan@ubuntu:/opt$ mkdir crosscompile

mkdir: cannot create directory ‘crosscompile’: Permission denied

crifan@ubuntu:/opt$ users

crifan crifan

crifan@ubuntu:/opt$

所以,现在希望:

每次,使用当前的普通用户,登陆后,即可具有超级用户sudo的权限。

不希望再每次输入sudo,直接用。

即把当前用户,提升权限,变成超级用户。

【折腾过程】

1.网上搜了一堆,都是开启Ubuntu的root用户的,对我此处没啥意义。

2.参考:

去看了看,感觉不适合我。

其只是,将用户变成对于某些东西有sudo 的权限,但是用起来,还是需要输入sudo的,还是很麻烦。

3.继续参考上面的解释,说是可以把当前用户加到wheel or admin group。

不太懂wheel是啥。以及如何添加。

关于为何管理员组,被叫做wheel,这里有解释:

4.然后去想办法,把当前用户加到管理员组里面。

搜:

ubuntu Add user to the wheel group

找到

然后去修改

/etc/sudoers

但是:

一是没有%wheel

二是要加的:

# usermod -G10 user1

也看起来不对:#明显是注释掉了此行而已

所以,放弃此人的教程。

5.搜:

ubuntu Add user to the root group

参考:

去看看这些相关的命令:crifan@ubuntu:/opt$ su -

Password:

su: Authentication failure

crifan@ubuntu:/opt$ sudo -s

root@ubuntu:/opt# usermode --help

No command 'usermode' found, did you mean:

Command 'usermod' from package 'passwd' (main)

usermode: command not found

root@ubuntu:/opt# usermod --help

Usage: usermod [options] LOGIN

Options:

-c, --comment COMMENT new value of the GECOS field

-d, --home HOME_DIR new home directory for the user account

-e, --expiredate EXPIRE_DATE set account expiration date to EXPIRE_DATE

-f, --inactive INACTIVE set password inactive after expiration

to INACTIVE

-g, --gid GROUP force use GROUP as new primary group

-G, --groups GROUPS new list of supplementary GROUPS

-a, --append append the user to the supplemental GROUPS

mentioned by the -G option without removing

him/her from other groups

-h, --help display this help message and exit

-l, --login NEW_LOGIN new value of the login name

-L, --lock lock the user account

-m, --move-home move contents of the home directory to the

new location (use only with -d)

-o, --non-unique allow using duplicate (non-unique) UID

-p, --password PASSWORD use encrypted password for the new password

-R, --root CHROOT_DIR directory to chroot into

-s, --shell SHELL new login shell for the user account

-u, --uid UID new UID for the user account

-U, --unlock unlock the user account

-Z, --selinux-user SEUSER new SELinux user mapping for the user account

root@ubuntu:/opt#

6.但是仍旧不知道当前,存在哪些group。

参考:

貌似默认的是root这个group。

7.所以,可以去试试:root@ubuntu:/opt# usermod -a -G root crifan

8.然后再退出当前root用户:root@ubuntu:/opt# exit

exit

去使用crifan,看看能否创建文件夹,结果还是不行:crifan@ubuntu:/opt$ mkdir cros

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值