Root User in Ubuntu- Important Things You Should Know

If you are using GUI, some Debian based distributions such as Linux Mint; provide an option to open as root. In Ubuntu 20.04 and its some previous versions this option is disabled by default. In this article, we will discuss to enable this option in Ubuntu 20.04 and Xubuntu 20.04 LTS.

Here’s the simplest way to access a file or directory as root in GNOME Files.

Root User in Ubuntu- Important Things You Should Know

That feature is part of the File manager, i.e. for Windows; it’s part of Windows Explorer. However, it is executed by the operating system and its permission control modules.

In Linux distributions and file managers, the situation is a little different. The different desktop has their way of handling this.

For example, KDE Plasma’s default file manager Dolphin recently added this feature so that when a root privilege is required, it will ask for you with a PolicyKit KDE Agent (polkit) window – as shown below. Not the other way around. You want to open/execute something via root from the file manager.

It’s worth mentioning that you can not use “sudo dolphin” to run the file manager itself with root privilege.

Dolphin root access after KIO with Polkit implementation
Dolphin root access after KIO with Polkit implementation

If you want to open or edit a file as root, you can always do that in the terminal. I know a few people don’t feel too comfortable with the command line.

The desktop Linux often provides ways to avoid the command line for terminal-fearing people.

If you are in a situation where you have to access a folder as root or edit a file with root privilege, you can do that graphically in Nautilus file manager.

Add ‘open as administrator’ option in right click context menu in Nautilus file manager

A word of warning! Please don’t go around opening and editing random files as root as you might mess up with wrong files and end up with a broken system. Use it only in the cases where it is required.

I am showing the installation steps for Ubuntu. You can change it as per your distribution’s package manager.

Дополнительно:  Как исправить ошибку 0x000000ed на windows

You’ll have to use terminal (even if you don’t like it) for installing the Nautilus plugin. Please make sure that you have the universe repository enabled:

sudo apt install nautilus-admin

Close and open Nautilus file manager again to see the changes in effect.

Open Folder As Administrator Ubuntu
Right click to see the “Open as Administrator” option
Edit Files As Root Ubuntu
Edit Files As Root Ubuntu

In both cases, you’ll be prompted to enter your account’s password:

Authentication Pop Up Ubuntu
You need to enter your password, of course

That’s pretty much it. You can enjoy the comfort of GUI.

In case you don’t want to run Nautilus as root anymore, you can remove this plugin. It’s always good to remove additional things you installed but you don’t use anymore.

sudo apt remove nautilus-admin

I hope you find this quick tip helpful. Questions and suggestions are always welcome.

Either you run commands with root privilege like this:

sudo any_command
sudo su

What is root user? Why is it locked in Ubuntu?

Root User Ubuntu

You don’t need to have root privilege for your daily tasks like moving file in your home directory, downloading files from internet, creating documents etc.

Take this analogy for understanding it better. If you have to cut a fruit, you use a kitchen knife. If you have to cut down a tree, you have to use a saw. Now, you may use the saw to cut fruits but that’s not wise, is it?

Does this mean that you cannot be root in Ubuntu or use the system with root privileges? No, you can still have root access with the help of ‘sudo’ (explained in the next section).

How to run commands as root user in Ubuntu?

apt update
Reading package lists... Done
E: Could not open lock file /var/lib/apt/lists/lock - open (13: Permission denied)
E: Unable to lock directory /var/lib/apt/lists/
W: Problem unlinking the file /var/cache/apt/pkgcache.bin - RemoveCaches (13: Permission denied)
W: Problem unlinking the file /var/cache/apt/srcpkgcache.bin - RemoveCaches (13: Permission denied)

So, how do you run commands as root? The simple answer is to add sudo before the commands that require to be run as root.

sudo apt update
[email protected]:~$ sudo apt update
[sudo] password for abhishek: 

If you are absolutely new to Linux, you might be surprised that when you start typing your password in the terminal, nothing happens on the screen. This is perfectly normal because as the default security feature, nothing is displayed on the screen. Not even the asterisks (*). You type your password and press enter.

Bottom line:
To run commands as root in Ubuntu, add sudo before the command.
When asked for password, enter your account’s password.
When you type the password on the screen, nothing is visible. Just keep on typing the password and press enter.

Дополнительно:  How to root the android smartphone

How to become root user in Ubuntu?

The sudo command allows you to simulate a root login shell with this command:

sudo -i
[email protected]:~$ sudo -i
[sudo] password for abhishek: 
[email protected]:~# whoami
root
[email protected]:~# 

You’ll notice that when you switch to root, the shell command prompt changes from $ (dollar key sign) to # (pound key sign). This makes me crack a (lame) joke that pound is stronger than dollar.

sudo su

If you try to use the su command without sudo, you’ll encounter ‘su authentication failure’ error.

exit

How to enable root user in Ubuntu?

sudo passwd root

Again, this is not recommended and I won’t encourage you to do that on your desktop. If you forgot it, you won’t be able to change the root password in Ubuntu again.

sudo passwd -dl root

I hope you have a slightly better understanding of the root concept now. If you still have some confusion and questions about it, please let me know in the comments. I’ll try to answer your questions and might update the article as well.

What is root folder in Linux?

In a computer file system, and primarily used in the Unix and Unix-like operating systems, the root directory is the first or top-most directory in a hierarchy. It can be likened to the trunk of a tree, as the starting point where all branches originate from.

Installing the nautilus admin tool

First, update the apt package index –

sudo apt update

And then use –

sudo apt install nautilus-admin
nautilus -q

How do I open file manager as Sudo?

Open Ubuntu Nautilus File Manager as root

  1. Open command terminal either from Applications or using keyboard shortcut- Ctrl+Alt+T.
  2. Run Nautilus file manager with sudo. …
  3. It will ask for your current non-root user’s password that is present in the sudo group.
  4. Ubuntu File manager will open under administrative rights.

How do I run a script without Sudo?

  1. cd /PATH/TO/FOLDER.
  2. chmod u+x ./filename (u — user, +x — execute permissions)
  3. if you want to execute it without .sh, add the following shebang line to the first line of the file: #!/bin/bash.
  4. If you want to execute it from anywhere on your system add the path of the folder to the $PATH variable.

How do I open a root file in Linux?

How to Open Root Terminal in Linux Mint

  1. Open your terminal app.
  2. Type the following command: sudo su.
  3. Enter your password when prompted.
  4. From now, the current instance will be the root terminal.
Дополнительно:  Zingiber Officinale Root Extract

Using nautilus admin tool

Root User in Ubuntu- Important Things You Should Know

Root User in Ubuntu- Important Things You Should Know

How to open a directory as root in Xubuntu 20. 04 LTS

Xubuntu comes with the Xfce desktop environment which is a stable, light, and configurable desktop environment. Opening directory as root in Xubuntu is a little bit different from the Ubuntu because it uses DR Thunar as a default file manager instead of Nautilus.

Now to open a directory as root first, open the terminal by pressing  ctrl+alt+t

And then execute the given command –

thunar admin://%f

Once this command gets executed you will be prompted for the authentication as given in the image below –

Root User in Ubuntu- Important Things You Should Know

Enter your password and click on authenticate. This will open the filesystem as root now you can perform tasks such as creating, moving, or deleting a file or directory that requires root permission.

Root User in Ubuntu- Important Things You Should Know

pkexec thunar

This will also prompt you to enter your password, once it gets successfully authenticated it will open the filesystem as root.

Root User in Ubuntu- Important Things You Should Know

How do I open a file as root in Ubuntu?

Adding a contextual menu to right click open files as root:

  1. Open the Terminal.
  2. Type sudo su and press enter.
  3. Provide your password and press enter.
  4. Then type apt-get install -y nautilus-admin and press enter.
  5. Now type nautilus -q and press enter.
  6. Finally type exit and press enter, and close the terminal window.

How do I run a file as root?

You need to do two things; both from a Terminal prompt:

  1. Change to the directory where you have the . run file stored.
  2. Type: chmod 755 filename. run.
  3. Type: sudo ./filename. run.

How do I open the root directory in Ubuntu terminal?

In terminal type «gksu nautilus». (the gksu command can be used instead of sudo when wishing to run gui apps as root, though you should be cautious about what apps you run as root). In terminal type «sudo -i» then «nautilus». In terminal type «sudo nautilus».

GNOME Files (Nautilus) and root access to files, directories

That being said, GNOME Files (aka Nautilus) has a way to open files and folders via root.

  • Open GNOME Files or Nautilus.
  • Then click on other locations at the left pane.
  • Press CTRL+L to bring up the address bar.
  • In the address bar, type in below and hit enter.
admin:///
  • It would ask for the admin password; once you authenticate yourself successfully, you get the system open for you as admin.
  • Now, here onwards, whatever you do, it’s as admin or root.
Enter the location address as admin
Enter the location address as admin
Give admin password
Give admin password
Opening GNOME Files as root
Opening GNOME Files as root

Оцените статью
Master Hi-technology
Добавить комментарий