Do not run Composer as root/super user

忙着安装composer ,执行后,查看版本,报了这样一个提示:

[root@izuf60gbaaaq66y42r6y2fz ~]# composer --version
Do not run Composer as root/super user! See https://getcomposer.org/root for details
Composer version 1.6.5 2018-05-04 11:44:59
[root@izuf60gbaaaq66y42r6y2fz ~]# whoami
root
[root@izuf60gbaaaq66y42r6y2fz ~]#

大惊,怎么在root用户下执行了这一系列操作,确实很不像话,很不专业。于是,添加个普通用户:

adduser Abble
passwd

但,个人用户的权限有时远远满足不了开发需求。它只在home目录下有完整的权限,在其它目录下取决于root的授权。由于是个人开发,我希望Abble可以得到root的权限。于是,想起了sudo -s

[root@izuf60gbaaaq66y42r6y2fz ~]# su Abble
[Abble@izuf60gbaaaq66y42r6y2fz root]$ whoami
Abble
[Abble@izuf60gbaaaq66y42r6y2fz root]$ sudo -s

We trust you have received the usual lecture from the local System
Administrator. It usually boils down to these three things:

    #1) Respect the privacy of others.
    #2) Think before you type.
    #3) With great power comes great responsibility.

[sudo] password for Abble: 
Abble 不在 sudoers 文件中。此事将被报告。

很明显,执行失败。我们要在sudoers中配置一下:

[root@izuf60gbaaaq66y42r6y2fz ~]# whereis sudoers
sudoers: /etc/sudoers /etc/sudoers.d /usr/libexec/sudoers.so /usr/share/man/man5/sudoers.5.gz
[root@izuf60gbaaaq66y42r6y2fz ~]# vim /etc/sudoers
[root@izuf60gbaaaq66y42r6y2fz ~]# 
## Allow root to run any commands anywhere 
root    ALL=(ALL)       ALL
# Abble ALL=(ALL)       ALL # 个人新增的一个用户,并且给它权限做事
Abble   ALL=(ALL)       NOPASSWD:ALL # 个人新增的一个用户,并且给它权限做事

如此,两个用户可以快速转化:

[Abble@izuf60gbaaaq66y42r6y2fz root]$ whoami
Abble
[Abble@izuf60gbaaaq66y42r6y2fz root]$ sudo -s
[root@izuf60gbaaaq66y42r6y2fz ~]# whoami
root
[root@izuf60gbaaaq66y42r6y2fz ~]# su Abble
[Abble@izuf60gbaaaq66y42r6y2fz root]$ whoami
Abble
[Abble@izuf60gbaaaq66y42r6y2fz root]$ 
    原文作者:developerAbble
    原文地址: https://www.jianshu.com/p/3533e3238478
    本文转自网络文章,转载此文章仅为分享知识,如有侵权,请联系博主进行删除。
点赞