0

Is it possible to create a sudo user who has exact privileges of a root user ? If so can you guide me through how to create one using cmd.

Ex: I have created a sudo user who can't restart for some reason. He can always do sudo -i and then restart, but is there some other way which makes the user by default have all the permissions.

I know it's vulnerable but since it runs on local network it's fine.

  • If you are aware of the vulnerabilities, you can enable root user by setting a password. – ravery Nov 08 '17 at 02:59
  • @ravery Since there is a need of multiple users accessing the system concurrently. – Hari Aakash Nov 08 '17 at 03:00
  • What happens when they try to restart? – muru Nov 08 '17 at 03:06
  • Failed to set wall message, ignoring: Interactive authentication required. Failed to reboot system via logind: Interactive authentication required. Failed to open /dev/initctl: Permission denied Failed to talk to init daemon.

    @muru The above error shows up

    – Hari Aakash Nov 08 '17 at 03:13
  • What command did they try? And how? – muru Nov 08 '17 at 03:17
  • Just reboot was the command – Hari Aakash Nov 08 '17 at 03:17
  • 2
    As far as I remember, with transition to systemd the shutdown and reboot now do not require root privilege , see https://askubuntu.com/q/789058/295286 Try to poke around polkit settings as shown in that post, maybe server settings are different from desktop. But any user that is in sudo group can just do sudo shutdown -r now. You can also edit /etc/sudoers file to run a command without requiring password, there's questions around on AskUbuntu about that,too. – Sergiy Kolodyazhnyy Nov 08 '17 at 03:29
  • Am trying to restart not shutdown – Hari Aakash Nov 08 '17 at 03:38
  • 2
    @SergiyKolodyazhnyy that's correct...when zero or one users are logged in. Sudo/Root is still required when more than one user is logged in. – user535733 Nov 08 '17 at 04:11
  • This seems like a systemd bug, rather than a Sudo/Root issue. Please take a look at the current systemd bugs at launchpad.net, and see if your problem is one of those. If not, please report the new bug. They cannot fix it if they don't know about it. – user535733 Nov 08 '17 at 04:21
  • @user535733 for me this is true under 16.04, but under 17.10 reboot has different behaviour: https://i.stack.imgur.com/EeOd6.gif – pa4080 Nov 08 '17 at 12:18
  • @pa4080 fascinating (and an excellent use of screen recording!) Please file a bug report - the systemd developers did not intend for any single user without admin privs to terminate everybody's sessions. – user535733 Nov 08 '17 at 13:14

1 Answers1

0

Create a user, let's call him myuser, grant myuser the same privileges as root and set a password for this account:

$ sudo useradd -ou 0 -g 0 myuser
$ sudo passwd myuser

If you have already had a user myuser and you want to grant him root privileges (make him a second root user):

$ grep myuser /etc/passwd
myuser:x:1001:1001::/home/myuser:/bin/bash

For this, it is required to edit the file /etc/passwd and just change UID and GID to 0.

galoget
  • 2,963
nullbyte91
  • 36
  • 2