General TC > General TC Talk
sudo'd out
jpeters:
I would like to have a dime for every time I have typed "sudo" in the last two weeks.....and yet I still frequently forget to type it yet once again. This generally happens before I do a long edit using vi, and then try to save it. I sure am greatful for all the protection against myself, but wonder if it isnt adding to rapid onset dementia.
^thehatsrule^:
If you're using full vim, you can use ":w /path/to/filename"
In busybox's vi, you need to manually override the read-only, ie ":w! /path/to/filename"
jpeters:
--- Quote from: ^thehatsrule^ on January 27, 2009, 01:17:31 AM ---If you're using full vim, you can use ":w /path/to/filename"
In busybox's vi, you need to manually override the read-only, ie ":w! /path/to/filename"
--- End quote ---
The problem is one of permissions, in which case w! doesn't work for either vim or vi. (ie.,root:root)
It seems that after losing a few edits by not using "sudo vi", I begin to use "sudo" for everything...including writing the initial file. (i.e., sudo vi /dir/new_file) or even "sudo mkdir". Now everything is root:root, and if I fail to use "sudo" when editing, I lose it. This serves to once again increase my use of "sudo" for everything....since then I never have to know what the underlying permissions are for the file I just opened.
It gets further complicated if I write a new file without sudo within a root:staff or root:root folder. Now I can't save what I wrote, because I would have had to initiate the new file with "sudo'. Once again, I start using
sudo for everything. :(
EDIT: the work around, of course, is to change the permissions from the terminal,,,which allows
me to save what I wrote. Chown is fast becoming one of my other favorite words. (( finally figured this out after rewriting edits several times). Other incentives for "sudo" include trying to remove a folder without it, and having to go through a questionaire regarding every file inside it. "Sudo" effectively dumps the whole thing instantly....and I'm hooked!
Juanito:
--- Quote from: jpeters on January 27, 2009, 03:09:34 AM ---..."Sudo" effectively dumps the whole thing instantly....and I'm hooked!
--- End quote ---
How does that saying go - "don't take the name root in vain..." :)
mikshaw:
--- Quote ---The problem is one of permissions, in which case w! doesn't work for either vim or vi. (ie.,root:root)
--- End quote ---
I think what he meant by ":w /path/to/filename" was to use a different, writable path. Then, as root, move the new file over the old & change its ownership back to root. It's still an inconvenience, but at least you keep your edits.
Simple rule: For anything outside of /home/tc, be root.
My preferred practice is to start a root terminal if I plan to do any system configuration. There's just one sudo command involved (or none if you open the term from desktop menu), and after that you don't have to think about sudo. Just make sure you remember this is a root session so you don't accidentally misuse your power. I have root's PS1 in bright red to keep me aware.
--- Quote ---EDIT: the work around, of course, is to change the permissions from the terminal
--- End quote ---
I would call this dangerous behavior, unless you change the permissions back after the edit. File permissions outside of /home/tc really should be editable only by root (that includes /opt, in my opinion). When you start breaking down those permissions, you are destroying one of the primary aspects of your system's security.
--- Quote ---Other incentives for "sudo" include trying to remove a folder without it, and having to go through a questionaire regarding every file inside it. "Sudo" effectively dumps the whole thing instantly....and I'm hooked!
--- End quote ---
You can also do "rm -rf folder". Using sudo with the "rm" command can easily become hazardous....just a simple accidental keypress at the wrong second can destroy ocean liners and devastate planets....or at least delete some important stuff your system needs to live.
Navigation
[0] Message Index
[#] Next page
Go to full version