stop force save on a file with read only permission Announcing the arrival of Valued Associate...
Why was the term "discrete" used in discrete logarithm?
If Jon Snow became King of the Seven Kingdoms what would his regnal number be?
Can a non-EU citizen traveling with me come with me through the EU passport line?
Did Xerox really develop the first LAN?
If a contract sometimes uses the wrong name, is it still valid?
Bonus calculation: Am I making a mountain out of a molehill?
What do you call a plan that's an alternative plan in case your initial plan fails?
3 doors, three guards, one stone
Is the Standard Deduction better than Itemized when both are the same amount?
What causes the vertical darker bands in my photo?
What is the longest distance a 13th-level monk can jump while attacking on the same turn?
Letter Boxed validator
Why is "Consequences inflicted." not a sentence?
Is it possible to boil a liquid by just mixing many immiscible liquids together?
How to bypass password on Windows XP account?
What is the correct way to use the pinch test for dehydration?
How do I keep my slimes from escaping their pens?
What's the purpose of writing one's academic bio in 3rd person?
Is above average number of years spent on PhD considered a red flag in future academia or industry positions?
When to stop saving and start investing?
Is there a concise way to say "all of the X, one of each"?
Right-skewed distribution with mean equals to mode?
Why are there no cargo aircraft with "flying wing" design?
Is there a service that would inform me whenever a new direct route is scheduled from a given airport?
stop force save on a file with read only permission
Announcing the arrival of Valued Associate #679: Cesar Manara
Planned maintenance scheduled April 17/18, 2019 at 00:00UTC (8:00pm US/Eastern)
2019 Community Moderator Election Results
Why I closed the “Why is Kali so hard” questionMake all files under a directory read-only without changing permissions?Is NTFS under linux able to save a linux file, with its chown and chmod settings?CentOS - Issue with write permissionsChanging permission from read only in linux?Issued chmod 666 * in home directory, permissions problems resulted with all filesHow can a user Edit a file even when Write bit is off on a fileHow to skip a directory when I am setting up permissions using find?Prevent already running process to write to an existing fileAllow non root user to change file permissionsHow to create a file that only sudo can read?
.everyoneloves__top-leaderboard:empty,.everyoneloves__mid-leaderboard:empty,.everyoneloves__bot-mid-leaderboard:empty{ margin-bottom:0;
}
So I have a script file that is currently in sudoers, and for security I want this file to be read only... so I issued the following chmod:
chmod 555 test.sh
Now the permissions on this file is
-r-xr-xr-x
However, when I go to vi this file, even though it says " W10: Warning: Changing a readonly file", I can still do "w!" to force save it. How can I also disable force saving so that a regular user wont be able to write to this file at all?
Thanks
linux permissions sudo chmod
add a comment |
So I have a script file that is currently in sudoers, and for security I want this file to be read only... so I issued the following chmod:
chmod 555 test.sh
Now the permissions on this file is
-r-xr-xr-x
However, when I go to vi this file, even though it says " W10: Warning: Changing a readonly file", I can still do "w!" to force save it. How can I also disable force saving so that a regular user wont be able to write to this file at all?
Thanks
linux permissions sudo chmod
1
Force saving effectively deletes and recreates the file. The user needs write permissions on the parent directory to force save.
– jordanm
3 hours ago
So I have a script file that is currently in sudoers What exactly do you mean by that? If you just want users to be able to read the file, I can't see why you'd needsudo
for that. And if you don't want users to be able to modify the file, you likely don't want to enablesudo
editing of the file.
– Andrew Henle
3 hours ago
add a comment |
So I have a script file that is currently in sudoers, and for security I want this file to be read only... so I issued the following chmod:
chmod 555 test.sh
Now the permissions on this file is
-r-xr-xr-x
However, when I go to vi this file, even though it says " W10: Warning: Changing a readonly file", I can still do "w!" to force save it. How can I also disable force saving so that a regular user wont be able to write to this file at all?
Thanks
linux permissions sudo chmod
So I have a script file that is currently in sudoers, and for security I want this file to be read only... so I issued the following chmod:
chmod 555 test.sh
Now the permissions on this file is
-r-xr-xr-x
However, when I go to vi this file, even though it says " W10: Warning: Changing a readonly file", I can still do "w!" to force save it. How can I also disable force saving so that a regular user wont be able to write to this file at all?
Thanks
linux permissions sudo chmod
linux permissions sudo chmod
asked 3 hours ago
user3128077user3128077
62
62
1
Force saving effectively deletes and recreates the file. The user needs write permissions on the parent directory to force save.
– jordanm
3 hours ago
So I have a script file that is currently in sudoers What exactly do you mean by that? If you just want users to be able to read the file, I can't see why you'd needsudo
for that. And if you don't want users to be able to modify the file, you likely don't want to enablesudo
editing of the file.
– Andrew Henle
3 hours ago
add a comment |
1
Force saving effectively deletes and recreates the file. The user needs write permissions on the parent directory to force save.
– jordanm
3 hours ago
So I have a script file that is currently in sudoers What exactly do you mean by that? If you just want users to be able to read the file, I can't see why you'd needsudo
for that. And if you don't want users to be able to modify the file, you likely don't want to enablesudo
editing of the file.
– Andrew Henle
3 hours ago
1
1
Force saving effectively deletes and recreates the file. The user needs write permissions on the parent directory to force save.
– jordanm
3 hours ago
Force saving effectively deletes and recreates the file. The user needs write permissions on the parent directory to force save.
– jordanm
3 hours ago
So I have a script file that is currently in sudoers What exactly do you mean by that? If you just want users to be able to read the file, I can't see why you'd need
sudo
for that. And if you don't want users to be able to modify the file, you likely don't want to enable sudo
editing of the file.– Andrew Henle
3 hours ago
So I have a script file that is currently in sudoers What exactly do you mean by that? If you just want users to be able to read the file, I can't see why you'd need
sudo
for that. And if you don't want users to be able to modify the file, you likely don't want to enable sudo
editing of the file.– Andrew Henle
3 hours ago
add a comment |
1 Answer
1
active
oldest
votes
Set the immutable file attribute with chattr.
sudo chattr +i file
A file with the 'i' attribute cannot be modified: it cannot be deleted or renamed, no link can be created to this file, most of the file's metadata can not be modified, and the file can not be opened in write mode. Only the superuser or a process possessing the
CAP_LINUX_IMMUTABLE capability can set or clear this attribute.
The downside of doing this is that you won't be able to write to the file even as the superuser (root). You will need to remove the immutable attribute first:
sudo chattr -i file
add a comment |
Your Answer
StackExchange.ready(function() {
var channelOptions = {
tags: "".split(" "),
id: "106"
};
initTagRenderer("".split(" "), "".split(" "), channelOptions);
StackExchange.using("externalEditor", function() {
// Have to fire editor after snippets, if snippets enabled
if (StackExchange.settings.snippets.snippetsEnabled) {
StackExchange.using("snippets", function() {
createEditor();
});
}
else {
createEditor();
}
});
function createEditor() {
StackExchange.prepareEditor({
heartbeatType: 'answer',
autoActivateHeartbeat: false,
convertImagesToLinks: false,
noModals: true,
showLowRepImageUploadWarning: true,
reputationToPostImages: null,
bindNavPrevention: true,
postfix: "",
imageUploader: {
brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
allowUrls: true
},
onDemand: true,
discardSelector: ".discard-answer"
,immediatelyShowMarkdownHelp:true
});
}
});
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%2f512658%2fstop-force-save-on-a-file-with-read-only-permission%23new-answer', 'question_page');
}
);
Post as a guest
Required, but never shown
1 Answer
1
active
oldest
votes
1 Answer
1
active
oldest
votes
active
oldest
votes
active
oldest
votes
Set the immutable file attribute with chattr.
sudo chattr +i file
A file with the 'i' attribute cannot be modified: it cannot be deleted or renamed, no link can be created to this file, most of the file's metadata can not be modified, and the file can not be opened in write mode. Only the superuser or a process possessing the
CAP_LINUX_IMMUTABLE capability can set or clear this attribute.
The downside of doing this is that you won't be able to write to the file even as the superuser (root). You will need to remove the immutable attribute first:
sudo chattr -i file
add a comment |
Set the immutable file attribute with chattr.
sudo chattr +i file
A file with the 'i' attribute cannot be modified: it cannot be deleted or renamed, no link can be created to this file, most of the file's metadata can not be modified, and the file can not be opened in write mode. Only the superuser or a process possessing the
CAP_LINUX_IMMUTABLE capability can set or clear this attribute.
The downside of doing this is that you won't be able to write to the file even as the superuser (root). You will need to remove the immutable attribute first:
sudo chattr -i file
add a comment |
Set the immutable file attribute with chattr.
sudo chattr +i file
A file with the 'i' attribute cannot be modified: it cannot be deleted or renamed, no link can be created to this file, most of the file's metadata can not be modified, and the file can not be opened in write mode. Only the superuser or a process possessing the
CAP_LINUX_IMMUTABLE capability can set or clear this attribute.
The downside of doing this is that you won't be able to write to the file even as the superuser (root). You will need to remove the immutable attribute first:
sudo chattr -i file
Set the immutable file attribute with chattr.
sudo chattr +i file
A file with the 'i' attribute cannot be modified: it cannot be deleted or renamed, no link can be created to this file, most of the file's metadata can not be modified, and the file can not be opened in write mode. Only the superuser or a process possessing the
CAP_LINUX_IMMUTABLE capability can set or clear this attribute.
The downside of doing this is that you won't be able to write to the file even as the superuser (root). You will need to remove the immutable attribute first:
sudo chattr -i file
answered 1 hour ago
JRFergusonJRFerguson
10.4k32632
10.4k32632
add a comment |
add a comment |
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.
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%2f512658%2fstop-force-save-on-a-file-with-read-only-permission%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
1
Force saving effectively deletes and recreates the file. The user needs write permissions on the parent directory to force save.
– jordanm
3 hours ago
So I have a script file that is currently in sudoers What exactly do you mean by that? If you just want users to be able to read the file, I can't see why you'd need
sudo
for that. And if you don't want users to be able to modify the file, you likely don't want to enablesudo
editing of the file.– Andrew Henle
3 hours ago