LinuxQuestions.org
Help answer threads with 0 replies.
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 10-15-2016, 08:00 AM   #1
P.G.Krish
Member
 
Registered: Jun 2016
Distribution: Ubuntu
Posts: 64

Rep: Reputation: Disabled
Exclamation How to edit a readonly zip file using vim?


I tried to edit a zip file and change its content using the following commands
Code:
:set modifiable
:%s/xxA/..\//g
:x!
But it returned the following error
Quote:
W10: Warning: Changing a readonly file
55 substitutions on 10 lines
Press ENTER or type command to continue



I tried to edit a zip file and change its content using the following commands

:set modifiable
:%s/xxA/..\//g
:x!

But it returned the following error

W10: Warning: Changing a readonly file
55 substitutions on 10 lines
Press ENTER or type command to continue

After I pressed Enter nothing changed. Please guide me to solve this problem.
 
Old 10-15-2016, 10:54 AM   #2
jpollard
Senior Member
 
Registered: Dec 2012
Location: Washington DC area
Distribution: Fedora, CentOS, Slackware
Posts: 4,912

Rep: Reputation: 1513Reputation: 1513Reputation: 1513Reputation: 1513Reputation: 1513Reputation: 1513Reputation: 1513Reputation: 1513Reputation: 1513Reputation: 1513Reputation: 1513
A read only file is an attribute of the file. You can read the file (which is what vim did), you can make changes (which vim did), but you CANNOT write the file.

What you usually do is write to a different name.

Now a zip file has compressed contents. You really can't edit the contents without first decompressing what you are going to edit. The result of "editing" a zip file is usually garbage. Unusable by zip to decompress (the checksums/decompression fails), meaningless for any use.
 
Old 10-15-2016, 11:25 AM   #3
P.G.Krish
Member
 
Registered: Jun 2016
Distribution: Ubuntu
Posts: 64

Original Poster
Rep: Reputation: Disabled
But It possible from this tutorial,https://blog.silentsignal.eu/2014/01...-upload-unzip/
 
Old 10-15-2016, 11:33 AM   #4
jpollard
Senior Member
 
Registered: Dec 2012
Location: Washington DC area
Distribution: Fedora, CentOS, Slackware
Posts: 4,912

Rep: Reputation: 1513Reputation: 1513Reputation: 1513Reputation: 1513Reputation: 1513Reputation: 1513Reputation: 1513Reputation: 1513Reputation: 1513Reputation: 1513Reputation: 1513
Quote:
Originally Posted by P.G.Krish View Post
So you are creating a trojan?

The problem is still that the access rules to the file forbid changing the file. Change the access rules first.
 
Old 10-15-2016, 11:46 AM   #5
P.G.Krish
Member
 
Registered: Jun 2016
Distribution: Ubuntu
Posts: 64

Original Poster
Rep: Reputation: Disabled
No, I dont want to create trojan . Anyway how to change the access rules. I already change it permission. But no use
 
Old 10-15-2016, 11:50 AM   #6
jpollard
Senior Member
 
Registered: Dec 2012
Location: Washington DC area
Distribution: Fedora, CentOS, Slackware
Posts: 4,912

Rep: Reputation: 1513Reputation: 1513Reputation: 1513Reputation: 1513Reputation: 1513Reputation: 1513Reputation: 1513Reputation: 1513Reputation: 1513Reputation: 1513Reputation: 1513
Quote:
Originally Posted by P.G.Krish View Post
No, I dont want to create trojan . Anyway how to change the access rules. I already change it permission. But no use
A simple chmod command will change the access. If you aren't allowed access because someone else owns the file, then you aren't allowed to edit the file. Copy it, edit the copy. BTW, changing the zip file belonging to someone else is considered making a trojan.

Last edited by jpollard; 10-15-2016 at 11:52 AM.
 
Old 10-15-2016, 11:55 AM   #7
P.G.Krish
Member
 
Registered: Jun 2016
Distribution: Ubuntu
Posts: 64

Original Poster
Rep: Reputation: Disabled
Quote:
Originally Posted by jpollard View Post
A simple chmod command will change the access. If you aren't allowed access because someone else owns the file, then you aren't allowed to edit the file. Copy it, edit the copy.
But iam the owner of the file, i already try the chmod with 755 permissions ,

Thanks
 
Old 10-15-2016, 12:10 PM   #8
grail
LQ Guru
 
Registered: Sep 2009
Location: Perth
Distribution: Manjaro
Posts: 10,007

Rep: Reputation: 3191Reputation: 3191Reputation: 3191Reputation: 3191Reputation: 3191Reputation: 3191Reputation: 3191Reputation: 3191Reputation: 3191Reputation: 3191Reputation: 3191
And when you entered that command were you given any errors? Maybe try adding -v to get more information.

I am also confused how the link you supplied has anything to do with your topic as nowhere does it mention a read only file, zip or otherwise.
 
Old 10-15-2016, 12:42 PM   #9
P.G.Krish
Member
 
Registered: Jun 2016
Distribution: Ubuntu
Posts: 64

Original Poster
Rep: Reputation: Disabled
Quote:
Originally Posted by grail View Post
And when you entered that command were you given any errors? Maybe try adding -v to get more information.

I am also confused how the link you supplied has anything to do with your topic as nowhere does it mention a read only file, zip or otherwise.

Please read completely that third stage about editing the zip file, In that link
 
Old 10-15-2016, 01:10 PM   #10
grail
LQ Guru
 
Registered: Sep 2009
Location: Perth
Distribution: Manjaro
Posts: 10,007

Rep: Reputation: 3191Reputation: 3191Reputation: 3191Reputation: 3191Reputation: 3191Reputation: 3191Reputation: 3191Reputation: 3191Reputation: 3191Reputation: 3191Reputation: 3191
I see all the stages and the steps you have followed, however, I repeat, nowhere in the entire page does it say the zip file is read only. It only says that you are editing the zip file.
 
Old 10-15-2016, 03:21 PM   #11
jpollard
Senior Member
 
Registered: Dec 2012
Location: Washington DC area
Distribution: Fedora, CentOS, Slackware
Posts: 4,912

Rep: Reputation: 1513Reputation: 1513Reputation: 1513Reputation: 1513Reputation: 1513Reputation: 1513Reputation: 1513Reputation: 1513Reputation: 1513Reputation: 1513Reputation: 1513
Just what does "ls -l" report about "your" file?

And if you are on a RH/Centos/Fedora release, what does "ls -lZ" report about the file?
 
Old 10-17-2016, 12:12 AM   #12
P.G.Krish
Member
 
Registered: Jun 2016
Distribution: Ubuntu
Posts: 64

Original Poster
Rep: Reputation: Disabled
Quote:
Originally Posted by jpollard View Post
Just what does "ls -l" report about "your" file?

And if you are on a RH/Centos/Fedora release, what does "ls -lZ" report about the file?


This is result of
Code:
ls -l
Quote:
-rwxr-xr-x 1 krish krish 2472 Oct 17 10:38 cmd.zip
 
Old 10-17-2016, 01:41 AM   #13
spiri13
Member
 
Registered: Jun 2016
Posts: 57

Rep: Reputation: Disabled
Try to 'chattr -i file'.
 
Old 10-17-2016, 02:15 AM   #14
P.G.Krish
Member
 
Registered: Jun 2016
Distribution: Ubuntu
Posts: 64

Original Poster
Rep: Reputation: Disabled
Quote:
Originally Posted by spiri13 View Post
Try to 'chattr -i file'.
Its not working with this file, spiri13
 
Old 10-17-2016, 04:32 AM   #15
keefaz
LQ Guru
 
Registered: Mar 2004
Distribution: Slackware
Posts: 6,552

Rep: Reputation: 872Reputation: 872Reputation: 872Reputation: 872Reputation: 872Reputation: 872Reputation: 872
Maybe vim opens the file as read only if a swap file is present and option v:swapchoice = "o" is set in vimrc
You can use ' :set noro ' to exit read only mode in vim
 
  


Reply

Tags
vim



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
Trying to edit a .spec file in vim (E212: Can't open files for writing) subharaj Linux - Software 1 02-14-2012 03:14 AM
VIM: Split open same file and edit only 1 window encore4444 Programming 8 05-14-2011 10:40 PM
LXer: vimdiff - Edit two or Three versions of a file with Vim and show differences LXer Syndicated Linux News 0 04-09-2009 12:21 AM
mc(midnight commander) - using vim to edit does not change the file on ftp rlee923 Linux - Software 2 10-18-2007 05:08 AM
How to edit UTF-8 file in VIM ? naihe2010 Programming 6 09-28-2006 01:36 AM

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

All times are GMT -5. The time now is 02:21 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