LinuxQuestions.org
Latest LQ Deal: Latest LQ Deals
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Newbie
User Name
Password
Linux - Newbie This Linux forum is for members that are new to Linux.
Just starting out and have a question? If it is not in the man pages or the how-to's this is the place!

Notices


Reply
  Search this Thread
Old 11-29-2023, 03:29 PM   #1
Redjet
LQ Newbie
 
Registered: Nov 2023
Location: Europe
Posts: 2

Rep: Reputation: 0
Sticky bit enabled on a file with no permissions


Hello everyone,

I'm exploring Linux permissions, and I have a question.
Does the user 'bob' have the ability to delete 'file.txt'?
The permissions for this file are as follows:

--------T 1 bob bob 0 Nov 05 23:01 file.txt.

The presence of the capital letter 'T' at the end indicates that the sticky bit is set on the directory containing 'file.txt,' while all other permissions are absent. The user "bob" appears to be the owner of the file, does the presence of the sticky bit enable him to delete it?

Thanks in advance!
 
Old 11-29-2023, 03:34 PM   #2
rtmistler
Moderator
 
Registered: Mar 2011
Location: USA
Distribution: MINT Debian, Angstrom, SUSE, Ubuntu, Debian
Posts: 9,883
Blog Entries: 13

Rep: Reputation: 4931Reputation: 4931Reputation: 4931Reputation: 4931Reputation: 4931Reputation: 4931Reputation: 4931Reputation: 4931Reputation: 4931Reputation: 4931Reputation: 4931
Quote:
Originally Posted by Redjet View Post
Hello everyone,

I'm exploring Linux permissions, and I have a question.
Does the user 'bob' have the ability to delete 'file.txt'?
The permissions for this file are as follows:

--------T 1 bob bob 0 Nov 05 23:01 file.txt.

The presence of the capital letter 'T' at the end indicates that the sticky bit is set on the directory containing 'file.txt,' while all other permissions are absent. The user "bob" appears to be the owner of the file, does the presence of the sticky bit enable him to delete it?

Thanks in advance!
Welcome to LQ.

No. The sticky bit doesn't mean that.

Right now the permissions need to be modified to be able to delete the file.

Perhaps you should try experiments with junk files to learn better.

Last edited by rtmistler; 11-29-2023 at 03:35 PM.
 
Old 11-29-2023, 04:00 PM   #3
Redjet
LQ Newbie
 
Registered: Nov 2023
Location: Europe
Posts: 2

Original Poster
Rep: Reputation: 0
Quote:
Originally Posted by rtmistler View Post
Welcome to LQ.

No. The sticky bit doesn't mean that.

Right now the permissions need to be modified to be able to delete the file.

Perhaps you should try experiments with junk files to learn better.
Thank you for your answer.

Understood. So I still need to grant write permission to the user 'bob' for that file in order for him to be able to delete it?
 
Old 11-29-2023, 04:48 PM   #4
boughtonp
Senior Member
 
Registered: Feb 2007
Location: UK
Distribution: Debian
Posts: 3,616

Rep: Reputation: 2555Reputation: 2555Reputation: 2555Reputation: 2555Reputation: 2555Reputation: 2555Reputation: 2555Reputation: 2555Reputation: 2555Reputation: 2555Reputation: 2555

Deleting a file checks the permission on the directory, not on the file.

(There was a thread or two on the subject a few months back, but I did a few searches and couldn't find them.)

 
2 members found this post helpful.
Old 11-29-2023, 10:20 PM   #5
rknichols
Senior Member
 
Registered: Aug 2009
Distribution: Rocky Linux
Posts: 4,783

Rep: Reputation: 2214Reputation: 2214Reputation: 2214Reputation: 2214Reputation: 2214Reputation: 2214Reputation: 2214Reputation: 2214Reputation: 2214Reputation: 2214Reputation: 2214
Quote:
Originally Posted by rtmistler View Post
Right now the permissions need to be modified to be able to delete the file.
Really?? I believe you are thinking about directory permissions, not file permissions.

The rm command will ask for confirmation before removing a write-protected file, but will happily do so if you respond "y". It will remove the file without confirmation if you use the "-f" option. Many (most?) GUI file managers will happily trash or delete such a file without confirmation, at least in my experience.

Ability to delete a file requires write permission for the directory, not for the file itself. The sticky bit on a directory means that you cannot delete a file there unless you own either that file or the directory itself (or are "root", of course).
 
1 members found this post helpful.
Old 11-30-2023, 12:24 PM   #6
rtmistler
Moderator
 
Registered: Mar 2011
Location: USA
Distribution: MINT Debian, Angstrom, SUSE, Ubuntu, Debian
Posts: 9,883
Blog Entries: 13

Rep: Reputation: 4931Reputation: 4931Reputation: 4931Reputation: 4931Reputation: 4931Reputation: 4931Reputation: 4931Reputation: 4931Reputation: 4931Reputation: 4931Reputation: 4931
Quote:
Originally Posted by Redjet View Post
Thank you for your answer.

Understood. So I still need to grant write permission to the user 'bob' for that file in order for him to be able to delete it?
Sorry, my mistake, the others have it correctly.

More typically for me the files and directories I have, do not have unusual permissions. The occasions where I run into something blocking a deletion, it's typically because the file is in use. Like for me I never kill my editor but after completing a merge, I may remove the directory copy of the git workspace to create a fresh clone. An open file in my editor stops that, temporarily.

If this is just learning, all fine, but in my opinion you normally (as a user) would not have permissions like that. I can't recall any situation where I wanted or needed the sticky bit, nor had zero permissions for a file.
 
Old 11-30-2023, 04:14 PM   #7
zeebra
Senior Member
 
Registered: Dec 2011
Distribution: Slackware
Posts: 1,834
Blog Entries: 17

Rep: Reputation: 642Reputation: 642Reputation: 642Reputation: 642Reputation: 642Reputation: 642
Seems like a homework assignment..
 
Old 12-01-2023, 05:49 AM   #8
GazL
LQ Veteran
 
Registered: May 2008
Posts: 6,914

Rep: Reputation: 5032Reputation: 5032Reputation: 5032Reputation: 5032Reputation: 5032Reputation: 5032Reputation: 5032Reputation: 5032Reputation: 5032Reputation: 5032Reputation: 5032
Quote:
Originally Posted by zeebra View Post
Seems like a homework assignment..
The answer to the posted questions would be "there's no way to tell from the information provided", which is not what you'd normally expect of the answer to a homework question, at least not at this level. It could be homework, but IMO there's enough wiggle room here to let it slide.

Permissions in UNIX are a little unintuitive. That directory permissions control creation/deletion, and that the last 3 bits being 'others' rather than 'everyone', and that both user and group permissions bits can be both permissive and restrictive takes a while to get your head around. And all that's before you get into ACLs!
 
Old 12-01-2023, 06:39 AM   #9
GazL
LQ Veteran
 
Registered: May 2008
Posts: 6,914

Rep: Reputation: 5032Reputation: 5032Reputation: 5032Reputation: 5032Reputation: 5032Reputation: 5032Reputation: 5032Reputation: 5032Reputation: 5032Reputation: 5032Reputation: 5032
Quote:
Originally Posted by Redjet View Post
Hello everyone,

I'm exploring Linux permissions, and I have a question.
Does the user 'bob' have the ability to delete 'file.txt'?
The permissions for this file are as follows:

--------T 1 bob bob 0 Nov 05 23:01 file.txt.
Why not create yourself a directory and play with the permissions? It's the best way to investigate this stuff.
 
Old 12-01-2023, 11:03 AM   #10
MadeInGermany
Senior Member
 
Registered: Dec 2011
Location: Simplicity
Posts: 2,816

Rep: Reputation: 1211Reputation: 1211Reputation: 1211Reputation: 1211Reputation: 1211Reputation: 1211Reputation: 1211Reputation: 1211Reputation: 1211
In Unix the file permission controls how you can access its data (contents).
A deletion of a file is initiated by unlinking its data from the directory: you must have write permission on the directory. Then the kernel deletes the file's data (list of data blocks), unless a process still accesses it or it's linked to yet another directory. If there is no access and the link count is 0 then the kernel deletes the data (frees the data blocks.)

The t-bit ("sticky bit") on a file has no real meaning,
Some old Unixes took it as a hint to cache it longer in RAM; some other Unixes took it as a hint to not fragment it.

Last edited by MadeInGermany; 12-01-2023 at 11:10 AM.
 
  


Reply



Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
LXer: Linux permissions: SUID, SGID, and sticky bit LXer Syndicated Linux News 0 10-15-2020 10:41 PM
LXer: What is Linux sticky bit and how to set Linux sticky bit. LXer Syndicated Linux News 0 01-25-2018 01:12 AM
Sticky situation bcos of sticky bit Voyager7 Linux - Newbie 4 02-28-2011 11:29 PM
Linux File permission & the sticky bit hq4ever Linux - Newbie 8 07-02-2004 03:46 PM
file modes list i.e. what is a sticky bit? Glover Linux - Newbie 2 07-04-2002 06:41 AM

LinuxQuestions.org > Forums > Linux Forums > Linux - Newbie

All times are GMT -5. The time now is 03:00 AM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration