Prevent accidental file overwrite
![Creative The name of the picture](https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgO9GURib1T8z7lCwjOGLQaGtrueEthgQ8LO42ZX8cOfTqDK4jvDDpKkLFwf2J49kYCMNW7d4ABih_XCb_2UXdq5fPJDkoyg7-8g_YfRUot-XnaXkNYycsNp7lA5_TW9td0FFpLQ2APzKcZ/s1600/1.jpg)
![Creative The name of the picture](https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhYQ0N5W1qAOxLP7t7iOM6O6AzbZnkXUy16s7P_CWfOb5UbTQY_aDsc727chyphenhyphen5W4IppVNernMMQeaUFTB_rFzAd95_CDt-tnwN-nBx6JyUp2duGjPaL5-VgNO41AVsA_vu30EJcipdDG409/s400/Clash+Royale+CLAN+TAG%2523URR8PPP.png)
up vote
1
down vote
favorite
Is there a way to prevent files to be overwritten, if the file with the same name already exists?
Either it should ask for root password to confirm or simply save it with a new name, like windows does, adding numbers to names.
16.04 permissions files filesystem filemanager
add a comment |Â
up vote
1
down vote
favorite
Is there a way to prevent files to be overwritten, if the file with the same name already exists?
Either it should ask for root password to confirm or simply save it with a new name, like windows does, adding numbers to names.
16.04 permissions files filesystem filemanager
Well, you could set the permissions to400
â Android Dev
Mar 14 at 15:29
... or 444. See serverfault.com/questions/648573/â¦
â RoVo
Mar 14 at 15:29
you can prevent file from being overwritten but asking for root password or automatic renaming is not available out-of-the-box.
â Manoj Sawai
Mar 14 at 15:32
add a comment |Â
up vote
1
down vote
favorite
up vote
1
down vote
favorite
Is there a way to prevent files to be overwritten, if the file with the same name already exists?
Either it should ask for root password to confirm or simply save it with a new name, like windows does, adding numbers to names.
16.04 permissions files filesystem filemanager
Is there a way to prevent files to be overwritten, if the file with the same name already exists?
Either it should ask for root password to confirm or simply save it with a new name, like windows does, adding numbers to names.
16.04 permissions files filesystem filemanager
16.04 permissions files filesystem filemanager
asked Mar 14 at 15:23
arjun
207111
207111
Well, you could set the permissions to400
â Android Dev
Mar 14 at 15:29
... or 444. See serverfault.com/questions/648573/â¦
â RoVo
Mar 14 at 15:29
you can prevent file from being overwritten but asking for root password or automatic renaming is not available out-of-the-box.
â Manoj Sawai
Mar 14 at 15:32
add a comment |Â
Well, you could set the permissions to400
â Android Dev
Mar 14 at 15:29
... or 444. See serverfault.com/questions/648573/â¦
â RoVo
Mar 14 at 15:29
you can prevent file from being overwritten but asking for root password or automatic renaming is not available out-of-the-box.
â Manoj Sawai
Mar 14 at 15:32
Well, you could set the permissions to
400
â Android Dev
Mar 14 at 15:29
Well, you could set the permissions to
400
â Android Dev
Mar 14 at 15:29
... or 444. See serverfault.com/questions/648573/â¦
â RoVo
Mar 14 at 15:29
... or 444. See serverfault.com/questions/648573/â¦
â RoVo
Mar 14 at 15:29
you can prevent file from being overwritten but asking for root password or automatic renaming is not available out-of-the-box.
â Manoj Sawai
Mar 14 at 15:32
you can prevent file from being overwritten but asking for root password or automatic renaming is not available out-of-the-box.
â Manoj Sawai
Mar 14 at 15:32
add a comment |Â
1 Answer
1
active
oldest
votes
up vote
1
down vote
The best method would be for you to learn to create a copy yourself before editing a file.
That said ...
Is there a way to prevent files to be overwritten
Yes. From command line set the "immutable" attribute (only the admin can remove that option) and nobody will be able to alter the file (edit, remove, move etc.). You do that with ...
sudo -i
password
chattr +i file
(-i
to remove it)
Either it should ask for root password
Ubuntu does not have a use able root password.
You can modify a file (even if it's read-only) if you own it and have write access to the directory. See for instance Why can I modify a read-only file? on how to save from vim. It will then complain that you need to take an extra action before you can save it.
Not exactly what you asked but it is a method to get some sort of notification before you overwrite it.
or simply save it with a new name, like windows does, adding numbers to names.
You will need a script for that when doing that on command line. Here are some examples: https://stackoverflow.com/questions/12187859/create-new-file-but-add-number-if-filename-already-exists-in-bash
I find myself saving documents from web. Some times i have accidentally overwritten them, if it was already saved or the name was same. That script assumes only single file would be considered. Is there any other way? Can it be automated?
â arjun
Mar 14 at 17:55
And thechattr
command, is it safe to do it system wide for all user files or specific folder? Can it be done?
â arjun
Mar 14 at 17:58
add a comment |Â
1 Answer
1
active
oldest
votes
1 Answer
1
active
oldest
votes
active
oldest
votes
active
oldest
votes
up vote
1
down vote
The best method would be for you to learn to create a copy yourself before editing a file.
That said ...
Is there a way to prevent files to be overwritten
Yes. From command line set the "immutable" attribute (only the admin can remove that option) and nobody will be able to alter the file (edit, remove, move etc.). You do that with ...
sudo -i
password
chattr +i file
(-i
to remove it)
Either it should ask for root password
Ubuntu does not have a use able root password.
You can modify a file (even if it's read-only) if you own it and have write access to the directory. See for instance Why can I modify a read-only file? on how to save from vim. It will then complain that you need to take an extra action before you can save it.
Not exactly what you asked but it is a method to get some sort of notification before you overwrite it.
or simply save it with a new name, like windows does, adding numbers to names.
You will need a script for that when doing that on command line. Here are some examples: https://stackoverflow.com/questions/12187859/create-new-file-but-add-number-if-filename-already-exists-in-bash
I find myself saving documents from web. Some times i have accidentally overwritten them, if it was already saved or the name was same. That script assumes only single file would be considered. Is there any other way? Can it be automated?
â arjun
Mar 14 at 17:55
And thechattr
command, is it safe to do it system wide for all user files or specific folder? Can it be done?
â arjun
Mar 14 at 17:58
add a comment |Â
up vote
1
down vote
The best method would be for you to learn to create a copy yourself before editing a file.
That said ...
Is there a way to prevent files to be overwritten
Yes. From command line set the "immutable" attribute (only the admin can remove that option) and nobody will be able to alter the file (edit, remove, move etc.). You do that with ...
sudo -i
password
chattr +i file
(-i
to remove it)
Either it should ask for root password
Ubuntu does not have a use able root password.
You can modify a file (even if it's read-only) if you own it and have write access to the directory. See for instance Why can I modify a read-only file? on how to save from vim. It will then complain that you need to take an extra action before you can save it.
Not exactly what you asked but it is a method to get some sort of notification before you overwrite it.
or simply save it with a new name, like windows does, adding numbers to names.
You will need a script for that when doing that on command line. Here are some examples: https://stackoverflow.com/questions/12187859/create-new-file-but-add-number-if-filename-already-exists-in-bash
I find myself saving documents from web. Some times i have accidentally overwritten them, if it was already saved or the name was same. That script assumes only single file would be considered. Is there any other way? Can it be automated?
â arjun
Mar 14 at 17:55
And thechattr
command, is it safe to do it system wide for all user files or specific folder? Can it be done?
â arjun
Mar 14 at 17:58
add a comment |Â
up vote
1
down vote
up vote
1
down vote
The best method would be for you to learn to create a copy yourself before editing a file.
That said ...
Is there a way to prevent files to be overwritten
Yes. From command line set the "immutable" attribute (only the admin can remove that option) and nobody will be able to alter the file (edit, remove, move etc.). You do that with ...
sudo -i
password
chattr +i file
(-i
to remove it)
Either it should ask for root password
Ubuntu does not have a use able root password.
You can modify a file (even if it's read-only) if you own it and have write access to the directory. See for instance Why can I modify a read-only file? on how to save from vim. It will then complain that you need to take an extra action before you can save it.
Not exactly what you asked but it is a method to get some sort of notification before you overwrite it.
or simply save it with a new name, like windows does, adding numbers to names.
You will need a script for that when doing that on command line. Here are some examples: https://stackoverflow.com/questions/12187859/create-new-file-but-add-number-if-filename-already-exists-in-bash
The best method would be for you to learn to create a copy yourself before editing a file.
That said ...
Is there a way to prevent files to be overwritten
Yes. From command line set the "immutable" attribute (only the admin can remove that option) and nobody will be able to alter the file (edit, remove, move etc.). You do that with ...
sudo -i
password
chattr +i file
(-i
to remove it)
Either it should ask for root password
Ubuntu does not have a use able root password.
You can modify a file (even if it's read-only) if you own it and have write access to the directory. See for instance Why can I modify a read-only file? on how to save from vim. It will then complain that you need to take an extra action before you can save it.
Not exactly what you asked but it is a method to get some sort of notification before you overwrite it.
or simply save it with a new name, like windows does, adding numbers to names.
You will need a script for that when doing that on command line. Here are some examples: https://stackoverflow.com/questions/12187859/create-new-file-but-add-number-if-filename-already-exists-in-bash
edited Mar 14 at 15:41
answered Mar 14 at 15:36
Rinzwind
197k25378510
197k25378510
I find myself saving documents from web. Some times i have accidentally overwritten them, if it was already saved or the name was same. That script assumes only single file would be considered. Is there any other way? Can it be automated?
â arjun
Mar 14 at 17:55
And thechattr
command, is it safe to do it system wide for all user files or specific folder? Can it be done?
â arjun
Mar 14 at 17:58
add a comment |Â
I find myself saving documents from web. Some times i have accidentally overwritten them, if it was already saved or the name was same. That script assumes only single file would be considered. Is there any other way? Can it be automated?
â arjun
Mar 14 at 17:55
And thechattr
command, is it safe to do it system wide for all user files or specific folder? Can it be done?
â arjun
Mar 14 at 17:58
I find myself saving documents from web. Some times i have accidentally overwritten them, if it was already saved or the name was same. That script assumes only single file would be considered. Is there any other way? Can it be automated?
â arjun
Mar 14 at 17:55
I find myself saving documents from web. Some times i have accidentally overwritten them, if it was already saved or the name was same. That script assumes only single file would be considered. Is there any other way? Can it be automated?
â arjun
Mar 14 at 17:55
And the
chattr
command, is it safe to do it system wide for all user files or specific folder? Can it be done?â arjun
Mar 14 at 17:58
And the
chattr
command, is it safe to do it system wide for all user files or specific folder? Can it be done?â arjun
Mar 14 at 17:58
add a comment |Â
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
var $window = $(window),
onScroll = function(e)
var $elem = $('.new-login-left'),
docViewTop = $window.scrollTop(),
docViewBottom = docViewTop + $window.height(),
elemTop = $elem.offset().top,
elemBottom = elemTop + $elem.height();
if ((docViewTop elemBottom))
StackExchange.using('gps', function() StackExchange.gps.track('embedded_signup_form.view', location: 'question_page' ); );
$window.unbind('scroll', onScroll);
;
$window.on('scroll', onScroll);
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
StackExchange.ready(
function ()
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2faskubuntu.com%2fquestions%2f1014917%2fprevent-accidental-file-overwrite%23new-answer', 'question_page');
);
Post as a guest
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
var $window = $(window),
onScroll = function(e)
var $elem = $('.new-login-left'),
docViewTop = $window.scrollTop(),
docViewBottom = docViewTop + $window.height(),
elemTop = $elem.offset().top,
elemBottom = elemTop + $elem.height();
if ((docViewTop elemBottom))
StackExchange.using('gps', function() StackExchange.gps.track('embedded_signup_form.view', location: 'question_page' ); );
$window.unbind('scroll', onScroll);
;
$window.on('scroll', onScroll);
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
var $window = $(window),
onScroll = function(e)
var $elem = $('.new-login-left'),
docViewTop = $window.scrollTop(),
docViewBottom = docViewTop + $window.height(),
elemTop = $elem.offset().top,
elemBottom = elemTop + $elem.height();
if ((docViewTop elemBottom))
StackExchange.using('gps', function() StackExchange.gps.track('embedded_signup_form.view', location: 'question_page' ); );
$window.unbind('scroll', onScroll);
;
$window.on('scroll', onScroll);
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
var $window = $(window),
onScroll = function(e)
var $elem = $('.new-login-left'),
docViewTop = $window.scrollTop(),
docViewBottom = docViewTop + $window.height(),
elemTop = $elem.offset().top,
elemBottom = elemTop + $elem.height();
if ((docViewTop elemBottom))
StackExchange.using('gps', function() StackExchange.gps.track('embedded_signup_form.view', location: 'question_page' ); );
$window.unbind('scroll', onScroll);
;
$window.on('scroll', onScroll);
);
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
Well, you could set the permissions to
400
â Android Dev
Mar 14 at 15:29
... or 444. See serverfault.com/questions/648573/â¦
â RoVo
Mar 14 at 15:29
you can prevent file from being overwritten but asking for root password or automatic renaming is not available out-of-the-box.
â Manoj Sawai
Mar 14 at 15:32