Linux no password for root

How do I set the root password so I can use su instead of sudo? [duplicate]

I’d like to define a password for root so that I can use su directly, without having to prepend it with sudo . And because I’d like to log in as root as well. So how to set a password for the root user?

Why do you want to have a root password? You don’t need it; any time you need root access, you can use sudo .

@Zignd: No, sudo requires your password, not the root password. Ubuntu is designed to work without a root password. See help.ubuntu.com/community/RootSudo

@KeithThompson If systemd fails it will ask for root password to enter maintenance mode: Welcome to emergency mode! Give root password for maintenance (or press Control-D to continue):

@cheshirekow: Hmm, I’ve never run into that. I’m currently running Ubuntu 16.10. Looking at my /etc/shadow , I see that my system doesn’t have a root password, and I was never prompted to create one when I set up the system. I guess if I ever get that » Give root password for maintenance » prompt I’ll just have to press Control-D. (I haven’t looked into systemd.)

3 Answers 3

You may have noticed that you can’t log in as root on Ubuntu, this is because root doesn’t actually have a password set.

Enter the following command:

You will be prompted for your current user’s password, followed by the password you want to set for root. The messages prompted should be similar to the following:

[sudo] password for : Type new UNIX password: Retype new UNIX password:

The following message will appear after that:

passwd: password updated successfully 

If the above message showed up on your terminal, you can now enter as root from your current user entering the following command:

And you will be prompted for the root password you’ve set. That’s it!

Источник

How do I make sudo ask for the root password?

When I run sudo as a normal unprivileged user, it asks for my password, not the root password. That’s often convenient, but it reduces the amount of information someone would have to have in order to run commands as root. So how can I make sudo ask for the root password instead of the invoking user’s password? I know it’d be done with a line in /etc/sudoers , but I can never seem to properly parse the BNF grammar in the man page to figure out exactly what to write.

Читайте также:  Проверить содержимое папки linux

I recommend you restrict the commands that are permissible as the non-root user so that you need not worry about exposing arbitrary commands.

@slartibartfast: but then what happens when I need to run a command as root that is not in the preapproved list?

6 Answers 6

Ok, here it is again so you can set the checkmark.

In /etc/sudoers , add this line:

to turn on the rootpw flag, making sudo ask for the root password.

You should always use the visudo command instead of manually editing the /etc/sudoers file. visudo validates the file to make sure it’s correct before saving, so you don’t get locked out of sudo if you make a syntax error. askubuntu.com/a/81054/166411

This solution worked for me on MX Linux 21.3, since the MX Tweaks Option «Password for administrative tasks» only changes graphical calls to sudo (gksudo). e.g. Opening Synaptic, but not for terminal use of sudo. — This is specially problematic because I use sudo calls more than privileged graphical tools, so I can see any terminal output, and since my login password should be extremely large for people to remember when seen, writing it over and over is frustrating.

You need to turn the rootpw flag on.

I know this question is old, but it is the most concise question I’ve found for this use case (which is a minor percentage, true, but nonetheless legitimate and helpful in the right scenario).

After putting all the steps together from various sources — including multiple answers to this question, these steps work on Ubuntu-Gnome 16.04 LTS:

  1. Set a password for root
    • This is CRITICAL to do FIRST! (Ubuntu automatically has no password for the ROOT user due to the standard security configuration.
    • If you do not do this first, you will lock yourself out from accessing root privileges. This can be overcome by booting in with a Live Disk, mounting the hard drive, and editing the sudoers file, but it’s best to avoid that.
    • Open a terminal and enter: sudo passwd
    • Set your new password for the ROOT user.
  2. Change the SUDO configuration to require the root password
    • SUDO requires the user requesting root privileges
    • Setting the «rootpw» flag instead tells SUDO to require the password for the root user.
    • Open a terminal and enter: sudo visudo
    • This will open the «/etc/sudoers» file
    • After the other «Defaults» line, add: Defaults rootpw
    • Save it (assuming you are in nano, which is the default, this is CTRL+O)
    • Close the file (CTRL+X) & exit the terminal
  3. You’re done!

Just a quick note — I also wanted to make sure that the root user couldn’t be used to login from the graphical login, and so was looking into ways to excluded. Apparently, the root user is excluded by default, and cannot be used to login through the Gnome graphical login — which is a very good thing!

Читайте также:  Snmp agent for linux

Источник

Execute sudo without Password?

Inspired by this question. I am the sole person using my system with 12.04.
Every time I issue a sudo command; the system asks for the user password (which is good in its own way).
However I was thinking; without activating the root account; how can I execute the sudo commands which will not ask for user password to authenticate. NOTE: I want to execute sudo command without authenticating via password; only when they are executed via terminal.
I don’t want to remove this extra layer of security from other functions such a while using ‘Ubuntu software center’ or executing a bash script by drag-drop something.sh file to the terminal.

so you only want to be asked for the password in the terminal and for other things not, or the other way arround?! in both ways, I think its a high security breach

I want that system may not ask password only when in the terminal. for any other purpose the system must ask a password. This requirement is only temporary, and to be used while configuring n installing new servers.. during fresh server installations, it really take hours of configuring with sudo commands.. issuing password every 15 min. is headache. I don’t want to use root account.

For sure you can prolong the timeout. Also, if you’re frequently doing fresh server setups you should think about automating the process. You are not paid to type, you are paid to solve problems and to get sh*t done.

12 Answers 12

You can configure sudo to never ask for your password.

Open a Terminal window and type:

In the bottom of the file, add the following line:

Where $USER is your username on your system. Save and close the sudoers file (if you haven’t changed your default terminal editor (you’ll know if you have), press Ctl + x to exit nano and it’ll prompt you to save).

As of Ubuntu 19.04, the file should now look something like

# # This file MUST be edited with the 'visudo' command as root. # # Please consider adding local content in /etc/sudoers.d/ instead of # directly modifying this file. # # See the man page for details on how to write a sudoers file. # Defaults env_reset Defaults mail_badpass Defaults secure_path="/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/snap/bin" # Host alias specification # User alias specification # Cmnd alias specification # User privilege specification root ALL=(ALL:ALL) ALL # Members of the admin group may gain root privileges %admin ALL=(ALL) ALL # Allow members of group sudo to execute any command %sudo ALL=(ALL:ALL) ALL # See sudoers(5) for more information on "#include" directives: #includedir /etc/sudoers.d YOUR_USERNAME_HERE ALL=(ALL) NOPASSWD: ALL 

After this you can type sudo in a Terminal window without being prompted for the password.

This only applies, to using the sudo command in the terminal. You’ll still be prompted for your password if you (for example) try to install a package from the software center

Читайте также:  Codecs all in one linux

Источник

How to Setup Sudo No Password in Linux

When a user executes the command with the sudo privileges, it asks for the password to run it and confirms the user’s request to perform that specific function from the file sudoers.

The Sudoers is the administrator’s file used for system configuration. System administrators can give access to the users to run some specific command or all commands. It keeps all the records in it about what and when things are done by whom.

It is good to set the password when you have multiple users in a single account. But when you’re the only user of a system and use it as a root user, typing the password multiple times for sudo privileges could irritate you. So, instead of entering the password even for a single function, it is better to set sudo without a password.

You can do it using the etc/sudoers file as we will discuss below.

How to Setup Sudo No Password

To set sudo without entering the password is a straightforward way that you don’t need to worry about. Just follow the steps carefully:

Step 1:

Open the terminal and type the following command to get /etc/sudoers file:

Enter the credential i.e. password to get the file:

Step 2:

Scroll down till the end of the /etc/sudoers file and append the mentioned below line:

(The mentioned line should be written at the end of the file so the other directives couldn’t be overridden with this)

Note: wardah is the username in my Linux system. You will write your username here.

Press Ctrl+s to save the /etc/sudoers file and then Ctrl+x to exit it.

Let’s run an example that needs Sudo privileges in command.

Example1:

Run the given command in terminal to install pip package through python:

Example2:

Execute the update command to update all packages available in the Linux system:

As you can see in both of the mentioned examples, after setting no password in sudo privileges, it won’t ask you to enter the password again while executing commands.

Conclusion:

Entering a password all the time with the Sudo command is irritating when you’re the only user. We can set the Sudo without a password using the /etc/sudoers file. The sudoers is the system administration configuration file having all the information about the user, what, and when they performed in the system.

About the author

Syeda Wardah Batool

I am a Software Engineer Graduate and Self Motivated Linux writer. I also love to read latest Linux books. Moreover, in my free time, i love to read books on Personal development.

Источник

Оцените статью
Adblock
detector