1

Let's say I chmod 1777 a folder /opt/test and all files inside it as user user1. Hence user2 is able to update and edit files inside the /opt/test directory.

When user2 operates via sudo, he's able to delete any file from the directory, even those he does not own; is this normal? If yes, what is the purpose of setting the sticky bit?

When another user user3 operating without sudo tries to delete a file he does not own, he gets a "permission denied" error.

Note: All users belong to the default group.

3
  • 3
    The sticky bit can't prevent root from doing what root wants.
    – muru
    Apr 21, 2015 at 7:11
  • I have edited the original post as it was very unclear, please modify it if I misunderstood anything.
    – dr_
    Apr 21, 2015 at 8:21
  • @dr01, you got it correctly, thanks for rephrasing
    – Pallab
    Apr 21, 2015 at 9:12

1 Answer 1

2

When sticky bit is set, only the file's owner, the directory's owner, or root can rename or delete the file.

The sudo command is there to enable a user to impersonate another user, including root.

When user2 issues a command through sudo to become root, he's getting root's permissions, and root always has all permissions on the system.

1
  • 1
    jcbermu, it is not need to become root! If you use sudo to execute command as user1 you will have the required permissions Apr 21, 2015 at 8:34

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .