Skip to main content
edited tags
Link
Gilles 'SO- stop being evil'
  • 865.9k
  • 205
  • 1.8k
  • 2.3k
added 17 characters in body
Source Link
Mat
  • 54.9k
  • 11
  • 164
  • 143

I created dir testdirectory test, created a file 1.txt1.txt in the test. dirtest, wrote 'Before' in this file. thenThen I went

cd .. 

and used the command:

tar -cvzf ./test.tgz ./test 

Then I entered the test dir again. Opened the 1.txt1.txt file again. Changed content to "After". I saved the file and changed chmod to read only by executing:

chmod -w ./1.txt 

So for now my 1.txt1.txt is read only. Then I go up

cd .. 

and extract the test.tgztest.tgz archive.

tar -xvzf ./test.tgz 

Then I go again to test dir, do

cat 1.txt 

and get "Before".

IsIt is not logical, that itthis happens  ,since since the file was set to be read-only. Why does it happen?

I created dir test, created a file 1.txt in the test. dir, wrote 'Before' in this file. then I went

cd .. 

used the command

tar-cvzf ./test.tgz ./test 

Then I entered the test dir again. Opened the 1.txt file again. Changed content to "After". I saved the file and changed chmod to read only by executing:

chmod -w ./1.txt 

So for now my 1.txt is read only. Then I go up

cd .. 

and extract the test.tgz archive.

tar-xvzf ./test.tgz 

Then I go again to test dir, do

cat 1.txt 

and get "Before".

Is not logical, that it happens  ,since the file was set to be read-only. Why does it happen?

I created directory test, created file 1.txt in test, wrote 'Before' in this file. Then I went

cd .. 

and used the command:

tar -cvzf ./test.tgz ./test 

Then I entered the test dir again. Opened the 1.txt file again. Changed content to "After". I saved the file and changed chmod to read only by executing:

chmod -w ./1.txt 

So for now my 1.txt is read only. Then I go up

cd .. 

and extract the test.tgz archive.

tar -xvzf ./test.tgz 

Then I go again to test dir, do

cat 1.txt 

and get "Before".

It is not logical that this happens, since the file was set to be read-only. Why does it happen?

Source Link
Jakub
  • 195
  • 1
  • 1
  • 5

Tar overwrites read only files

I created dir test, created a file 1.txt in the test. dir, wrote 'Before' in this file. then I went

cd .. 

used the command

tar-cvzf ./test.tgz ./test 

Then I entered the test dir again. Opened the 1.txt file again. Changed content to "After". I saved the file and changed chmod to read only by executing:

chmod -w ./1.txt 

So for now my 1.txt is read only. Then I go up

cd .. 

and extract the test.tgz archive.

tar-xvzf ./test.tgz 

Then I go again to test dir, do

cat 1.txt 

and get "Before".

Is not logical, that it happens ,since the file was set to be read-only. Why does it happen?