0

As shown below, on my Ubuntu system, carlo directory has the sticky bit permission set. It contains the file file1 owned by user lab.

lab@ubuntu:~$ ll | grep carlo drwxrwxr-t 2 ubuntu ubuntu 4096 Oct 31 08:09 carlo/ lab@ubuntu:~$ ll /home/ubuntu/carlo/file1 -rw-rw-r-- 1 lab ubuntu 0 Oct 31 08:09 /home/ubuntu/carlo/file1 lab@ubuntu:~$ 

As you can see user lab owns file1, yet he can't rename or delete the file.

lab@ubuntu:~$ mv /home/ubuntu/carlo/file1 /home/ubuntu/carlo/file2 mv: cannot move '/home/ubuntu/carlo/file1' to '/home/ubuntu/carlo/file2': Permission denied lab@ubuntu:~$ rm /home/ubuntu/carlo/file1 rm: cannot remove '/home/ubuntu/carlo/file1': Permission denied lab@ubuntu:~$ 

Is this an expected behavior?

1 Answer 1

2

I’m guessing lab isn’t in the ubuntu group; this means that they don’t have write permission in carlo, so they can’t create or rename files in that directory. The sticky bit isn’t relevant here.

So yes, this is expected. To get the behaviour you’re after, add write permissions for others:

chmod o+w carlo 

See Understanding UNIX permissions and file types for details.

6
  • Ah ok. I added write permission for others to carlo directory (yes, user lab isn't member of ubuntu group). lab@ubuntu:~$ ll | grep carlo drwxrwxrwt 2 ubuntu ubuntu 4096 Oct 31 16:07 carlo/. Now it works ! Commented Oct 31, 2024 at 15:10
  • However, even ubuntu user can delete file1. Why if sticky bit is set on carlo directory? Commented Oct 31, 2024 at 15:17
  • 1
    The directory’s owner can always delete files in the directory. Commented Oct 31, 2024 at 15:18
  • As directory's owner do you mean the directory's user owner? Commented Oct 31, 2024 at 15:20
  • 1
    Yes, the owner user (not group). Commented Oct 31, 2024 at 15:23

You must log in to answer this question.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.