Ubuntu: A DIY Admin File Manager
As I mentioned in a previous post, one of my key annoyances with Ubuntu was its lack of an easy way to slip into Super User mode to perform administrative tasks. And, no, I don't consider opening up a terminal and typing "sudo whatever" easy. I recall, for instance, that during my most recent usage of a distro in the Red Hat family, there used to be a way to launch the file manager in SU mode directly, no CLI. Another distro had had a right-click menu option in the normal file manager to open a folder in SU mode. Either way, from there, I could right click launch a file in my editor of choice, also in SU mode, and do what needed doing. But Debian and all it's progeny decided that end users should be protected from the dangers of root account usage by making it a pain to get to. Of course, the best intentions of security architects are hardly a match for a determined yet ultimately lazy end-user.
If you don't know what I'm talking about, imagine yourself logged into Ubuntu, looking at the desktop, and wanting to edit a configuration file that's maybe in the "/etc" folder somewhere, or possibly "/opt". So you could pop open your rfile manager, maybe sort through a couple likely places, and eventually find the file in the
/really/super/deep/hidden folder. You could right-click and choose "Open with gedit" from the contextual menu, and the file would open up in gEdit. However, once you made your changes, you would realize that the "Save" button was grayed out because you don't have access to modify the file.
So then, you would close that window and open up a terminal window and type:
sudo gedit /really/supr/deep/hidden/config
...then get an error, see what you did and type:
sudo gedit /really/super/deep/hidden/config
The editor would launch (with the CLI spitting out random noise in the background) and merrily make your changes. You would then hit save and close the editor. Then you close the CLI, and you'd be done.
I guess that's easy. But I prefer easiER.
My desktop sports a nifty little Nautilus button on the top toolbar that launches Nautilus in SU mode. To perform the same task, I would pick up once I found the file by right-click opening it in gEdit as before, only this time, the save button works, and I'd be done.
Now, I'll be the first to grant that such small conveniences aren't a big deal to most people, and if you're one of them, I'm amazed you've read this far. All I can say is, I've found it to be immensely useful. YMMV. Here's how you do it.
Since Ubuntu does not appear to provide a superuser filemanager (without launching it by CLI), I put together a couple scripts to perform the various permissions and windows management tasks for me. The first script would look something like this:
All this does is launch Nautilus. The "&" acts as a sort of EOL/Line Return to let the window know you are done so it can close.
The next script would look like this:
Here, we run the previous script with the "nohup" prefix, which essentially "releases" it to run on its own, independent of the launching terminal window. This allows the window to close without taking the Nautilus session with it.
Make sure you make both of these scripts executable.
Finally, we have the trigger command:
sudo /scripts/directory/nautilus.wrap > /dev/null
"sudo", of course, is the magic ingredient that makes Nautilus run in superuser mode. The "> /dev/null" suffix sends the unnecessary CLI feedback you get to the bit bucket so that it doesn't create useless output files.
I put the trigger code in a Gnome launcher. Right click on the top panel and select "Add to Panel...", then choose "Custom Application Launcher". Set "Type" to "Application in Terminal", "Name" to something like "Admin Nautilus", and enter the trigger code into the command field. You can even find a suitable icon at "/usr/share/icons/hicolor/scalable/apps/nautilus.svg".
You could also put the trigger in yet another shell script, on your desktop or similar place, although I wouldn't consider that optimal.
To launch, double click the trigger (wherever you put it). A terminal window will launch to request your sudo password, if you haven't entered it recently. Once you hit enter, the window will close, and Nautilus will launch in the root folder. You are now cooking with Crisco.
A word about the three different commands and 2-3 scripts required. An observant person might note that of these could be strung together in a single line like this:
sudo nohup nautilus > /dev/null &
You'd be right, of course. There's no good reason why that shouldn't work. Unfortunately, my experience tells me it manages to fail anyway. Maybe you'll have better luck than me and, if so, this should be much easier for you. Otherwise, once you create these scripts, you'll never have to enter enter these commands again, so the apparent inefficiency becomes irrelevant.
So there you go. Root file management at the click of a button. Make sure you have good back-ups.