Linux and Command-Line Basics
On many Linux systems, "ls -l /usr/bin/passwd" shows "-rwsr-xr-x 1 root root ...". Which of the following is the meaning of the "s" in the owner's execute position?
- Asetuid is set, so whoever runs it, the program runs with the privileges of the file's owner (here root)
- BThe sticky bit is set, so users other than the owner and root cannot delete or rename this file
- CIt indicates that this file is a shared library, which is only called from other programs and cannot be run directly as a command
Show answer and explanation
Answer: A. setuid is set, so whoever runs it, the program runs with the privileges of the file's owner (here root)
s means that both the setuid (set user ID) bit and execute permission are set, and the program runs with the privileges of the file's owner rather than of the user who ran it. passwd must update /etc/shadow, which only root can write, when an ordinary user changes their own password, so it is a setuid-root program. A flaw in a setuid program can become a foothold for an ordinary user to gain root privileges, so the bit must not be set carelessly. In octal it is the 4000 place, and chmod 4755 gives -rwsr-xr-x.
- A. Correct. It runs with the privileges of the owner, root, rather than of the user who ran it.
- B. The sticky bit is shown as "t" in the others' execute position (drwxrwxrwt for /tmp, for example). Set on a directory, it lets only the owner and a few others delete files in it.
- C. Whether a file is a shared library does not appear in the permission notation. s is a mark about the privileges used when the file is run.