exit How to enable root user in Ubuntu?īy now you know that the root user is locked by default in Ubuntu based distributions. You can go back to being the normal user by using the exit command. If you try to use the su command without sudo, you’ll encounter ‘su authentication failure’ error. You can use it with sudo to temporarly switch to root user: sudo su You can use su command to switch users in Ubuntu. Though I have showed you how to become the root user, I must warn you that you should avoid using the system as root. This makes me crack a (lame) joke that pound is stronger than dollar. You’ll notice that when you switch to root, the shell command prompt changes from $ (dollar key sign) to # (pound key sign). The sudo command allows you to simulate a root login shell with this command: sudo -i :~$ sudo -i However, in situations, where you have to run several commands as root and you keep forgetting to add sudo before the commands, you may switch to root user temporarily. You can use sudo to run the commands as root. Just keep on typing the password and press enter. When you type the password on the screen, nothing is visible. When asked for password, enter your account’s password. To run commands as root in Ubuntu, add sudo before the command. This is perfectly normal because as the default security feature, nothing is displayed on the screen. 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. The thing with sudo is that running sudo doesn’t require root password but the user’s own password.Īnd this is why when you run a command with sudo, it asks for the password of the user who is running the sudo command: :~$ sudo apt updateĪs you can see in the example above, user abhishek was trying to run the ‘apt update’ command with sudo and the system asked the password for abhishek. This user account works as the admin on your system and as per the default sudo policy in Ubuntu, it can run any command on your system with root privileges. It’s an extensive topic and maybe I’ll discuss it in details in another article.įor the moment, you should know that when you install Ubuntu, you are forced to create a user account. You can also configure to run sudo without password. You may configure it run only a selected few commands as root. It can be configured to allow a user to run all commands as root. Sudo is a program that controls access to running commands as root (or other users). Ubuntu and many other Linux distributions use a special mechanism called sudo. 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. W: Problem unlinking the file /var/cache/apt/srcpkgcache.bin - RemoveCaches (13: Permission denied) W: Problem unlinking the file /var/cache/apt/pkgcache.bin - RemoveCaches (13: Permission denied) apt updateĮ: Could not open lock file /var/lib/apt/lists/lock - open (13: Permission denied)Į: Unable to lock directory /var/lib/apt/lists/ It will give you permission denied error or show ‘are you root’ error. For example, if you want to update Ubuntu via command line, you cannot run the command as a regular user. You’ll need root privileges for some system specific tasks. How to run commands as root user in Ubuntu? You can still run specific commands with root. This is why it is not recommended to use root all the time. Root user is too powerful to be used for regular tasks. Now, you may use the saw to cut fruits but that’s not wise, is it?ĭoes 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). If you have to cut down a tree, you have to use a saw. If you have to cut a fruit, you use a kitchen knife. Take this analogy for understanding it better. 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. This is why Ubuntu and other Ubuntu-based distributions lock the root user by default to save you from accidental disasters. And hence, an incorrect command may destroy the system. Root user can access system files and run commands to make changes to the system configuration. Root user gives you complete power over the system and hence it should be used with great cautious. With great power comes great responsibility. It can access any file and run any command on your Linux system. This is the super admin account that can do anything and everything with the system. In Linux, there is always a super user called root.
0 Comments
Leave a Reply. |
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |