What permissions must be set on a directory to allow one to append data to a file in that directory, but not...
up vote
-1
down vote
favorite
"What permissions must be set on a directory to allow one to append data to a file in that directory, but not to remove that file?"
From my understanding, you need the 'w' write permission to append data to a file, but that will also give you the ability to remove the file but the question is asking for the permissions that should be set for one to be able to append data to a file BUT not remove it.
linux
New contributor
Mandingo is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.
add a comment |
up vote
-1
down vote
favorite
"What permissions must be set on a directory to allow one to append data to a file in that directory, but not to remove that file?"
From my understanding, you need the 'w' write permission to append data to a file, but that will also give you the ability to remove the file but the question is asking for the permissions that should be set for one to be able to append data to a file BUT not remove it.
linux
New contributor
Mandingo is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.
add a comment |
up vote
-1
down vote
favorite
up vote
-1
down vote
favorite
"What permissions must be set on a directory to allow one to append data to a file in that directory, but not to remove that file?"
From my understanding, you need the 'w' write permission to append data to a file, but that will also give you the ability to remove the file but the question is asking for the permissions that should be set for one to be able to append data to a file BUT not remove it.
linux
New contributor
Mandingo is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.
"What permissions must be set on a directory to allow one to append data to a file in that directory, but not to remove that file?"
From my understanding, you need the 'w' write permission to append data to a file, but that will also give you the ability to remove the file but the question is asking for the permissions that should be set for one to be able to append data to a file BUT not remove it.
linux
linux
New contributor
Mandingo is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.
New contributor
Mandingo is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.
edited Nov 23 at 11:10
Rui F Ribeiro
38.3k1475127
38.3k1475127
New contributor
Mandingo is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.
asked Nov 23 at 4:21
Mandingo
225
225
New contributor
Mandingo is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.
New contributor
Mandingo is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.
Mandingo is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.
add a comment |
add a comment |
2 Answers
2
active
oldest
votes
up vote
3
down vote
accepted
Appending data to a file requires write permission on the file itself. Removing a file requires write permission on the directory containing a file.
For example, I have a directory called testdir, for which I have removed write permissions:
[haxiel@testvm1 ~]$ ls -ld testdir/
dr-xr-xr-x. 2 haxiel haxiel 26 Nov 23 10:09 testdir/
Inside the directory, I had created a file called testfile.txt (this was done before removing the write permission on the directory).
[haxiel@testvm1 testdir]$ ls -l testfile.txt
-rw-rw-r--. 1 haxiel haxiel 12 Nov 23 10:11 testfile.txt
Now, I am able to append data to the file, since I have write permission on it:
[haxiel@testvm1 testdir]$ echo "Line1" >> testfile.txt
[haxiel@testvm1 testdir]$ echo "Line2" >> testfile.txt
[haxiel@testvm1 testdir]$ cat testfile.txt
Line1
Line2
But I cannot remove the file since I do not have write permissions on its parent directory.
[haxiel@testvm1 testdir]$ rm testfile.txt
rm: cannot remove ‘testfile.txt’: Permission denied
You can look at this question for more details on directory permissions: Execute vs Read bit. How do directory permissions in Linux work?
1
Yes, but one could still make the file empty. Thus sercumventing the whole reason for the question. All the data would still be gone. @Haxiel
– Michael Prokopec
Nov 23 at 5:11
add a comment |
up vote
1
down vote
The Directory has nothing to do with the files permissions. The file, if it can be written too, can also be deleted. You could try ACLs, like here: How to give permissions to read write but not delete the file , but that is easily sercumvented.
Here is a explination of file permissions:
(rwx------) This area is for owner.
(---rwx---) This area is for group owner.
(------rwx) This area is for others.
(-rwx------) The preceding - indicates a directory.
Value | Meaning
|
==========================================================================================================================================================================================================
|
777 (rwxrwxrwx) | No restrictions on permissions. Anybody may do anything. Generally not a desirable setting.
755 (rwxr-xr-x) | The file's owner may read, write, and execute the file. All others may read and execute the file. This setting is common for programs that are used by all users.
700 (rwx------) | The file's owner may read, write, and execute the file. Nobody else has any rights. This setting is useful for programs that only the owner may use and must be kept private from others.
666 (rw-rw-rw-) | All users may read and write the file.
644 (rw-r--r--) | The owner may read and write a file, while all others may only read the file. A common setting for data files that everybody may read, but only the owner may change.
600 (rw-------) | The owner may read and write a file. All others have no rights. A common setting for data files that the owner wants to keep private.
New contributor
Michael Prokopec is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.
add a comment |
2 Answers
2
active
oldest
votes
2 Answers
2
active
oldest
votes
active
oldest
votes
active
oldest
votes
up vote
3
down vote
accepted
Appending data to a file requires write permission on the file itself. Removing a file requires write permission on the directory containing a file.
For example, I have a directory called testdir, for which I have removed write permissions:
[haxiel@testvm1 ~]$ ls -ld testdir/
dr-xr-xr-x. 2 haxiel haxiel 26 Nov 23 10:09 testdir/
Inside the directory, I had created a file called testfile.txt (this was done before removing the write permission on the directory).
[haxiel@testvm1 testdir]$ ls -l testfile.txt
-rw-rw-r--. 1 haxiel haxiel 12 Nov 23 10:11 testfile.txt
Now, I am able to append data to the file, since I have write permission on it:
[haxiel@testvm1 testdir]$ echo "Line1" >> testfile.txt
[haxiel@testvm1 testdir]$ echo "Line2" >> testfile.txt
[haxiel@testvm1 testdir]$ cat testfile.txt
Line1
Line2
But I cannot remove the file since I do not have write permissions on its parent directory.
[haxiel@testvm1 testdir]$ rm testfile.txt
rm: cannot remove ‘testfile.txt’: Permission denied
You can look at this question for more details on directory permissions: Execute vs Read bit. How do directory permissions in Linux work?
1
Yes, but one could still make the file empty. Thus sercumventing the whole reason for the question. All the data would still be gone. @Haxiel
– Michael Prokopec
Nov 23 at 5:11
add a comment |
up vote
3
down vote
accepted
Appending data to a file requires write permission on the file itself. Removing a file requires write permission on the directory containing a file.
For example, I have a directory called testdir, for which I have removed write permissions:
[haxiel@testvm1 ~]$ ls -ld testdir/
dr-xr-xr-x. 2 haxiel haxiel 26 Nov 23 10:09 testdir/
Inside the directory, I had created a file called testfile.txt (this was done before removing the write permission on the directory).
[haxiel@testvm1 testdir]$ ls -l testfile.txt
-rw-rw-r--. 1 haxiel haxiel 12 Nov 23 10:11 testfile.txt
Now, I am able to append data to the file, since I have write permission on it:
[haxiel@testvm1 testdir]$ echo "Line1" >> testfile.txt
[haxiel@testvm1 testdir]$ echo "Line2" >> testfile.txt
[haxiel@testvm1 testdir]$ cat testfile.txt
Line1
Line2
But I cannot remove the file since I do not have write permissions on its parent directory.
[haxiel@testvm1 testdir]$ rm testfile.txt
rm: cannot remove ‘testfile.txt’: Permission denied
You can look at this question for more details on directory permissions: Execute vs Read bit. How do directory permissions in Linux work?
1
Yes, but one could still make the file empty. Thus sercumventing the whole reason for the question. All the data would still be gone. @Haxiel
– Michael Prokopec
Nov 23 at 5:11
add a comment |
up vote
3
down vote
accepted
up vote
3
down vote
accepted
Appending data to a file requires write permission on the file itself. Removing a file requires write permission on the directory containing a file.
For example, I have a directory called testdir, for which I have removed write permissions:
[haxiel@testvm1 ~]$ ls -ld testdir/
dr-xr-xr-x. 2 haxiel haxiel 26 Nov 23 10:09 testdir/
Inside the directory, I had created a file called testfile.txt (this was done before removing the write permission on the directory).
[haxiel@testvm1 testdir]$ ls -l testfile.txt
-rw-rw-r--. 1 haxiel haxiel 12 Nov 23 10:11 testfile.txt
Now, I am able to append data to the file, since I have write permission on it:
[haxiel@testvm1 testdir]$ echo "Line1" >> testfile.txt
[haxiel@testvm1 testdir]$ echo "Line2" >> testfile.txt
[haxiel@testvm1 testdir]$ cat testfile.txt
Line1
Line2
But I cannot remove the file since I do not have write permissions on its parent directory.
[haxiel@testvm1 testdir]$ rm testfile.txt
rm: cannot remove ‘testfile.txt’: Permission denied
You can look at this question for more details on directory permissions: Execute vs Read bit. How do directory permissions in Linux work?
Appending data to a file requires write permission on the file itself. Removing a file requires write permission on the directory containing a file.
For example, I have a directory called testdir, for which I have removed write permissions:
[haxiel@testvm1 ~]$ ls -ld testdir/
dr-xr-xr-x. 2 haxiel haxiel 26 Nov 23 10:09 testdir/
Inside the directory, I had created a file called testfile.txt (this was done before removing the write permission on the directory).
[haxiel@testvm1 testdir]$ ls -l testfile.txt
-rw-rw-r--. 1 haxiel haxiel 12 Nov 23 10:11 testfile.txt
Now, I am able to append data to the file, since I have write permission on it:
[haxiel@testvm1 testdir]$ echo "Line1" >> testfile.txt
[haxiel@testvm1 testdir]$ echo "Line2" >> testfile.txt
[haxiel@testvm1 testdir]$ cat testfile.txt
Line1
Line2
But I cannot remove the file since I do not have write permissions on its parent directory.
[haxiel@testvm1 testdir]$ rm testfile.txt
rm: cannot remove ‘testfile.txt’: Permission denied
You can look at this question for more details on directory permissions: Execute vs Read bit. How do directory permissions in Linux work?
answered Nov 23 at 4:47
Haxiel
51138
51138
1
Yes, but one could still make the file empty. Thus sercumventing the whole reason for the question. All the data would still be gone. @Haxiel
– Michael Prokopec
Nov 23 at 5:11
add a comment |
1
Yes, but one could still make the file empty. Thus sercumventing the whole reason for the question. All the data would still be gone. @Haxiel
– Michael Prokopec
Nov 23 at 5:11
1
1
Yes, but one could still make the file empty. Thus sercumventing the whole reason for the question. All the data would still be gone. @Haxiel
– Michael Prokopec
Nov 23 at 5:11
Yes, but one could still make the file empty. Thus sercumventing the whole reason for the question. All the data would still be gone. @Haxiel
– Michael Prokopec
Nov 23 at 5:11
add a comment |
up vote
1
down vote
The Directory has nothing to do with the files permissions. The file, if it can be written too, can also be deleted. You could try ACLs, like here: How to give permissions to read write but not delete the file , but that is easily sercumvented.
Here is a explination of file permissions:
(rwx------) This area is for owner.
(---rwx---) This area is for group owner.
(------rwx) This area is for others.
(-rwx------) The preceding - indicates a directory.
Value | Meaning
|
==========================================================================================================================================================================================================
|
777 (rwxrwxrwx) | No restrictions on permissions. Anybody may do anything. Generally not a desirable setting.
755 (rwxr-xr-x) | The file's owner may read, write, and execute the file. All others may read and execute the file. This setting is common for programs that are used by all users.
700 (rwx------) | The file's owner may read, write, and execute the file. Nobody else has any rights. This setting is useful for programs that only the owner may use and must be kept private from others.
666 (rw-rw-rw-) | All users may read and write the file.
644 (rw-r--r--) | The owner may read and write a file, while all others may only read the file. A common setting for data files that everybody may read, but only the owner may change.
600 (rw-------) | The owner may read and write a file. All others have no rights. A common setting for data files that the owner wants to keep private.
New contributor
Michael Prokopec is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.
add a comment |
up vote
1
down vote
The Directory has nothing to do with the files permissions. The file, if it can be written too, can also be deleted. You could try ACLs, like here: How to give permissions to read write but not delete the file , but that is easily sercumvented.
Here is a explination of file permissions:
(rwx------) This area is for owner.
(---rwx---) This area is for group owner.
(------rwx) This area is for others.
(-rwx------) The preceding - indicates a directory.
Value | Meaning
|
==========================================================================================================================================================================================================
|
777 (rwxrwxrwx) | No restrictions on permissions. Anybody may do anything. Generally not a desirable setting.
755 (rwxr-xr-x) | The file's owner may read, write, and execute the file. All others may read and execute the file. This setting is common for programs that are used by all users.
700 (rwx------) | The file's owner may read, write, and execute the file. Nobody else has any rights. This setting is useful for programs that only the owner may use and must be kept private from others.
666 (rw-rw-rw-) | All users may read and write the file.
644 (rw-r--r--) | The owner may read and write a file, while all others may only read the file. A common setting for data files that everybody may read, but only the owner may change.
600 (rw-------) | The owner may read and write a file. All others have no rights. A common setting for data files that the owner wants to keep private.
New contributor
Michael Prokopec is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.
add a comment |
up vote
1
down vote
up vote
1
down vote
The Directory has nothing to do with the files permissions. The file, if it can be written too, can also be deleted. You could try ACLs, like here: How to give permissions to read write but not delete the file , but that is easily sercumvented.
Here is a explination of file permissions:
(rwx------) This area is for owner.
(---rwx---) This area is for group owner.
(------rwx) This area is for others.
(-rwx------) The preceding - indicates a directory.
Value | Meaning
|
==========================================================================================================================================================================================================
|
777 (rwxrwxrwx) | No restrictions on permissions. Anybody may do anything. Generally not a desirable setting.
755 (rwxr-xr-x) | The file's owner may read, write, and execute the file. All others may read and execute the file. This setting is common for programs that are used by all users.
700 (rwx------) | The file's owner may read, write, and execute the file. Nobody else has any rights. This setting is useful for programs that only the owner may use and must be kept private from others.
666 (rw-rw-rw-) | All users may read and write the file.
644 (rw-r--r--) | The owner may read and write a file, while all others may only read the file. A common setting for data files that everybody may read, but only the owner may change.
600 (rw-------) | The owner may read and write a file. All others have no rights. A common setting for data files that the owner wants to keep private.
New contributor
Michael Prokopec is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.
The Directory has nothing to do with the files permissions. The file, if it can be written too, can also be deleted. You could try ACLs, like here: How to give permissions to read write but not delete the file , but that is easily sercumvented.
Here is a explination of file permissions:
(rwx------) This area is for owner.
(---rwx---) This area is for group owner.
(------rwx) This area is for others.
(-rwx------) The preceding - indicates a directory.
Value | Meaning
|
==========================================================================================================================================================================================================
|
777 (rwxrwxrwx) | No restrictions on permissions. Anybody may do anything. Generally not a desirable setting.
755 (rwxr-xr-x) | The file's owner may read, write, and execute the file. All others may read and execute the file. This setting is common for programs that are used by all users.
700 (rwx------) | The file's owner may read, write, and execute the file. Nobody else has any rights. This setting is useful for programs that only the owner may use and must be kept private from others.
666 (rw-rw-rw-) | All users may read and write the file.
644 (rw-r--r--) | The owner may read and write a file, while all others may only read the file. A common setting for data files that everybody may read, but only the owner may change.
600 (rw-------) | The owner may read and write a file. All others have no rights. A common setting for data files that the owner wants to keep private.
New contributor
Michael Prokopec is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.
New contributor
Michael Prokopec is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.
answered Nov 23 at 5:06
Michael Prokopec
62115
62115
New contributor
Michael Prokopec is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.
New contributor
Michael Prokopec is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.
Michael Prokopec is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.
add a comment |
add a comment |
Mandingo is a new contributor. Be nice, and check out our Code of Conduct.
Mandingo is a new contributor. Be nice, and check out our Code of Conduct.
Mandingo is a new contributor. Be nice, and check out our Code of Conduct.
Mandingo is a new contributor. Be nice, and check out our Code of Conduct.
Thanks for contributing an answer to Unix & Linux Stack Exchange!
- Please be sure to answer the question. Provide details and share your research!
But avoid …
- Asking for help, clarification, or responding to other answers.
- Making statements based on opinion; back them up with references or personal experience.
To learn more, see our tips on writing great answers.
Some of your past answers have not been well-received, and you're in danger of being blocked from answering.
Please pay close attention to the following guidance:
- Please be sure to answer the question. Provide details and share your research!
But avoid …
- Asking for help, clarification, or responding to other answers.
- Making statements based on opinion; back them up with references or personal experience.
To learn more, see our tips on writing great answers.
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2funix.stackexchange.com%2fquestions%2f483585%2fwhat-permissions-must-be-set-on-a-directory-to-allow-one-to-append-data-to-a-fil%23new-answer', 'question_page');
}
);
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown