Take the 2-minute tour ×
Unix & Linux Stack Exchange is a question and answer site for users of Linux, FreeBSD and other Un*x-like operating systems.. It's 100% free, no registration required.

How does Linux knows that it has to give euid 0 (uid of root) to only certain process like passwd, setuid, etc.

If a process can gain root user's permissions, will it not lead to security breach in Linux platform? For example, if I write a program that can gain root user permissions like passwd, I may corrupt important system files like /etc/passwd, /etc/groups.

How still Linux manages to be secure?

share|improve this question

migrated from stackoverflow.com Nov 17 '13 at 7:19

This question came from our site for professional and enthusiast programmers.

Flag this question and ask for moderator attention to migrate it to the other SE site. –  Gumbo Nov 11 '13 at 17:05

1 Answer 1

The passwd program has the setuid bit set, which you can see with ls -l:

-rwsr-xr-x 1 root root 39104 2009-12-06 05:35 /usr/bin/passwd

It's the s (the fourth character of the line).

All programs that have this permission bit set run as the owner of that program. In this example, the user is root (third word of the line).

These setuid programs need to make sure that they don't damage anything, since every user of the system can run them with effective root privileges. That's why you can only change your own password. Linux and other similar operating systems are still secure because the authors of these setuid programs take a lot of care.

See for example suexec.c from the Apache Web Server, which is a popular setuid program. There are unusually many comments in that source code.

share|improve this answer

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.