[problem]
You are quite happily editing away, then you come to save … oh dear, permission denied.
Either the file is set to readable, or it is owned by another user.
But you have write permission to the directory, either by user or group!
[/problem]
[solution]
If it is just a simple case of the file being unwritable and you own it, if in vi following the first example.
If you are not the owner, write the file to /tmp. Then follow the second example.
[/solution]
[example]
Allow write permission to a file you are currently vi editing – but the file is not writable.
:!chmod u+w %
If you are not the owner, no need to worry, even without root we can change the owner if you have write access to the directory! 🙂
:!zsh
mv -i your_filename /tmp/your_filename.mv
cp -i /tmp/your_filename.mv your_filename
Obviously if not in vi, you’ll need to break out to a shell using the mechanism in your editor. Also you may not have zsh, so ksh – bash, etc will do.
I tend to do all this on the command line, with a semi-colon between the mv and cp – so I can use command line expansion (the move has not happened yet!).
mv -i thefile[tab] /tmp/thefileXXXX;cp -i /tmp/thefileXXXX . [return]
[/example]
[reference]
[tags]Unix permission denied, chown owner without root, Unix Coding School[/tags]
- Linux Man Pages – vi command
- Linux Man Pages – chmod command
- Linux Man Pages – chown command
- Linux Man Pages – mv command
- Linux Man Pages – cp command
[/reference]
If you have found my website useful, please consider buying me a coffee below 😉