I sometimes open a read-only file in vi, forgetting to do chmod +w
before opening it. Is there way to change the file from within vi?
Something like !r chmod +w [filename]
?
Is there a shortcut to refer to the currently open file without spelling it's long name?
Example: :echo getfperm("/etc/passwd") This will hopefully (from a security point of view) display the string "rw-r--r--" or even "rw-------". This adds read, write and execute permissions to the "foo. txt" file in the current directory.
Just use vi's exclamation mark suffix to the write command (:w!) to force overwriting your own READONLY file.
Change directory with cd command to the desired location under with you need to all directories to 755, and all files to 644 permissions. Then use first command to chmod 755 for all directories and sub directories. The second command will change all the files permission to 0644 (chmod 644) under the directory tree.
Just use
:!chmod +w %
in command mode. % will be replaced by the current file name.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With