su与sudo的区别

        su切换用户身份
            /etc/profile --->登录级别的所有用户
            /etc/profile.d/*.sh
            /etc/bashrc
            ~/.bash_profile
            ~/.bashrc
            登录级别shell        /etc/profile->/etc/profile.d/*.sh->~/.bash_profile->~/.bashrc->/etc/bashrc
                su - 用户名
            非登录级别shell     ~/.bashrc->/etc/bashrc->/etc/profile.d/*.sh
                su 用户名
        sudo提权
            visudo -c #检查语法
            vim /etc/sudoers
            用户 主机IP或主机名(主机别名、组别名、用户别名)    =    (转成的用户身份) 管理命令
            cfy             ALL    =    (ALL)            /usr/sbin/ifconfig 
            cfy             ALL    =    (ALL)            NOPASSWD:/usr/sbin/ifconfig 
            cfy             ALL    =    (ALL)            NOPASSWD:别名
posted @ 2025-12-30 16:18  Dog17  阅读(2)  评论(0)    收藏  举报