前言
在Linux2.2前root权限简单划分为root和非root,那么root拥有全部权限,非root拥有有限的权限,如果非root用户需要安装软件,要么切换为root用户,要么使用sudo。如果我们以非root用户安装软件,会有如下提示,提示没权限。
aaa@ubuntu:/home/test$ apt-get install vim
E: Could not open lock file /var/lib/dpkg/lock-frontend - open (13: Permission denied)
E: Unable to acquire the dpkg frontend lock (/var/lib/dpkg/lock-frontend), are you root?
当我们使用setuid功能后,既让一个程序在运行时,能够获得root权限。如下所示
root@ubuntu:/home/test# chmod +s /usr/bin/apt-get
root@ubuntu:/home/test# ls -al /usr/bin/apt-get
-rwsr-sr-x 1 root root 47576 Jun 15 2021 /usr/bin/apt-get
root@ubuntu:/home/test# exit
exit
aaa@ubuntu:/home/test$ apt-get ins