I'm assuming you're using the nautilus file manager. I found this post in adding right click actions to nautilus: https://askubuntu.com/questions/210192/how-can-you-add-an-item-to-the-right-click-menu-in-nautilus-without-nautilus-ac#672553 You could make a bash script like shown in the post and use polkit to open the password prompt and run a command as root.
Linux
From Wikipedia, the free encyclopedia
Linux is a family of open source Unix-like operating systems based on the Linux kernel, an operating system kernel first released on September 17, 1991 by Linus Torvalds. Linux is typically packaged in a Linux distribution (or distro for short).
Distributions include the Linux kernel and supporting system software and libraries, many of which are provided by the GNU Project. Many Linux distributions use the word "Linux" in their name, but the Free Software Foundation uses the name GNU/Linux to emphasize the importance of GNU software, causing some controversy.
Rules
- Posts must be relevant to operating systems running the Linux kernel. GNU/Linux or otherwise.
- No misinformation
- No NSFW content
- No hate speech, bigotry, etc
Related Communities
Community icon by Alpár-Etele Méder, licensed under CC BY 3.0
Other threads:
You are free to do anything and everything with Linux!
ITT:
YOU CAN'T DO THAT
I don't know why everyone is getting self-righteous about this. I've used Linux since the mid-90s, and occasionally I find it easier to just run a GUI file manager as root to do some filter and deletions of things in caches and such that need root permission. Hell, I want to edit the files in /etc/wireguard for my tunnels; should I only do this at a sudo prompt in the terminal when I'm perfectly capable of pulling it up in Kate and copypasting stuff in?
Get off your high horses, there's plenty of valid use cases if you're using your head.
Manipulating large amounts of different files in terminal is a pain in the ass and everyone who disagrees is wrong.
Don't know about gnomes default file manager, but dolphin has this ability. You'll have to install the addons and enable it in the context menu however.
To repeat others opinion though, I haven't actually needed this feature outside of very specific situations (that I create myself). Linux operates a bit different and shouldn't need this for anything outside of some poorly made, or potentially malicious apps and scripts. I agree though it's still nice to have the option
For context, I answered this after your edit. First, I don't know how to add another context menu on a file manager, but I imagine if there is a way to do that, there is a command to be run when doing it. Hence, what I will answer is only the command.
For editing a file, you absolutely don't need to open the editor as root. You can however, make a temporary copy of a file that your own user has access to, edit those temporary files, and when you are done editing it just replace the old file. This is what sudoedit FILE
does.
Secondly, for manipulating a file, I agree with the other commenter that it still is a bad practice to run the file manager as root. Instead, try to add a context menu for taking ownership of a file/folder recursively. chown
does exactly that. Of course chown won't save you if that file is a network mount with some form of other access control.
Third and last, yes I agree that if a user wanted to nuke their installation it is their right to do so. However, do remember that this is also a forum and that we always remind each other the best practice since maybe another user will stumble upon this and think "oh, this is how it is in Linux". We do not have the equivalent of "Run as Administrator" here in linux as that would mess up a lot of assumptions for other programs and easily make the system unstable or outright unusable.
That's not a good idea as root isn't the same as an Administer account. Also, you might want to consider why you are running programs as root. You may have a chicken and the egg problem.
Maybe step back and give us some more context.
I do not really see hostility or taking down. More of a difference of opinion or experience.
Also, this is not a private email thread. It is a public forum. Whatever advice you get risks becoming guidance for the community. I think it is perfectly reasonable, even responsible, for people to respond with their thoughts on security.
You can ignore the advice not to implement this capability on your personal machine. That is your call. However, this should not become standard practice by Linux users.
Thank you for answering at some point in the thread the use cases that drove your question. I was very curious.
When I have needed “Run as Administrator” in Windows, it has typically been to run the command line. The reason Windows needs this is because it has lacked “sudo”. The next release of Windows is adding it as a feature ( going the other way ).
I have used Linux for decades as well and really not needed this. Partially this is because tools that require root access are typically configured to ask for it already.
Your “need to delete a file” use case made sense to me but I do not run into it. Perhaps my file systems are mounted differently. Perhaps I am not manipulating files of other users ( sounds right ). Or maybe I am more likely to be at the command line. Your “edit files as root” use cases leads me to believe I use the command line more as that is certainly something I would be doing from the terminal. I have to edit files as root everyday but it is always from the terminal. I am not encountering files that I cannot edit in my file manager though as I would have navigated to those files in the terminal to begin with. Clicking around in a file manager to get to system files is not even something that would have occurred to me. If I am using the file manager, it is to manage my own files ( mostly media and documents ).
No judgement. Do things how you want. I was just curious what you were using this for. When I use Windows, I use “Run as Administrator” all the time. In Linux, I did not even notice it was missing. Going back to Windows makes me miss “sudo” in the terminal though. I am not the only one obviously as they are now adding it to Windows too.
I see no "hostility" and "talking down" here. You shouldn't be running GUI programs with sudo, and the fact that you've been using Linux for X amount of years doesn't change that.
I think the talking down aspect comes from phrases like "you shouldn't be doing X", especially when these statements are made as absolutes, rather than contextualised with actual reasons.
Running GUI programs as root might cause security problems, or it might cause software problems. And while you might find these issues important, others might not.
In my opinion, saying something like "it's not a good idea if you care about security" or "doing so might make your PC burst into flames" gives helpful warnings for OP and future readers without talking down to them by making decisions for them what they should and should not do.