# How to add user to sudoers

**URL:** <https://help.nextcloud.com/t/how-to-add-user-to-sudoers/147655>\
**Category:** ℹ️ Support\
**Tags:** ncp\
**Created:** [October 17, 2022, 10:16pm UTC](https://help.nextcloud.com/t/how-to-add-user-to-sudoers/147655 "2022-10-17T22:16:12Z")\
**Posts on this page:** 13\
**Page:** 1

<div class="post-metadata">

**Author:** ![sn2018](https://help.nextcloud.com/letter_avatar/sn2018/32/6_22734026db12803ebb3e059622ac3534.png) [@sn2018](https://help.nextcloud.com/u/sn2018)\
**Post date:** [October 17, 2022, 10:16pm UTC](https://help.nextcloud.com/t/how-to-add-user-to-sudoers/147655/1 "2022-10-17T22:16:12Z")

</div>

I downloaded and installed the latest NCP and enabled SSH through the NCP panel. I am able to log in but I can’t do anything with sudo because the account I added is not in sudoers. How can I add an account to sudoers?

---

<div class="post-metadata">

**Author:** ![anon75456558](https://help.nextcloud.com/letter_avatar/anon75456558/32/6_22734026db12803ebb3e059622ac3534.png) [@anon75456558](https://help.nextcloud.com/u/anon75456558)\
**Post date:** [October 17, 2022, 10:18pm UTC](https://help.nextcloud.com/t/how-to-add-user-to-sudoers/147655/2 "2022-10-17T22:18:13Z")

</div>

With which method did you install NCP? Please run `ncp-report` and add the output here. Or, check `nc-info` from :4443 interface or `ncp-config` and share that here.

---

<div class="post-metadata">

**Author:** ![sn2018](https://help.nextcloud.com/letter_avatar/sn2018/32/6_22734026db12803ebb3e059622ac3534.png) [@sn2018](https://help.nextcloud.com/u/sn2018)\
**Post date:** [October 17, 2022, 10:24pm UTC](https://help.nextcloud.com/t/how-to-add-user-to-sudoers/147655/3 "2022-10-17T22:24:43Z")

</div>

I installed NCP by writing the img file to a SD.

```auto
System Info
‣ You should run Lets Encrypt for trusted encrypted access

‣ You should use nc-datadir to move your files to your plugged in USB drive

‣ You should enable automount to use your plugged in USB drive

NextCloudPi version	v1.50.3
NextCloudPi image	NextCloudPi_RaspberryPi_v1.50.3.img
OS	Debian GNU/Linux 11. 5.10.92-v8+ (aarch64)
automount	no
USB devices	sda
datadir	/var/www/nextcloud/data
data in SD	yes
data filesystem	ext2/ext3
data disk usage	2.3G/14G
rootfs usage	2.3G/14G
swapfile	/var/swap
dbdir	/var/lib/mysql
Nextcloud check	ok
Nextcloud version	24.0.5.1
HTTPD service	up
PHP service	up
MariaDB service	up
Redis service	up
HPB service	up
Postfix service	up
Internet check	ok
public IPv4	68.101.xxx.xx
public IPv6	not found
Port check 80	closed
Port check 443	closed
IP	192.168.1.xx
gateway	192.168.1.1
Interface	eth0
certificates	none
NAT loopback	no
Uptime	50min

```

---

<div class="post-metadata">

**Author:** ![anon75456558](https://help.nextcloud.com/letter_avatar/anon75456558/32/6_22734026db12803ebb3e059622ac3534.png) [@anon75456558](https://help.nextcloud.com/u/anon75456558)\
**Post date:** [October 17, 2022, 10:28pm UTC](https://help.nextcloud.com/t/how-to-add-user-to-sudoers/147655/4 "2022-10-17T22:28:25Z")

</div>

Thanks, here is a guide to add user to sudoers. There are lots available online for adding sudo user in Debian.

> **[How to Add User to Sudoers in Debian](https://linuxize.com/post/how-to-add-user-to-sudoers-in-debian/)**
>
> The sudoers file contains a set of rules that determines which users or groups are granted with sudo privileges as well as the level of the privileges.

---

<div class="post-metadata">

**Author:** ![sn2018](https://help.nextcloud.com/letter_avatar/sn2018/32/6_22734026db12803ebb3e059622ac3534.png) [@sn2018](https://help.nextcloud.com/u/sn2018)\
**Post date:** [October 17, 2022, 10:31pm UTC](https://help.nextcloud.com/t/how-to-add-user-to-sudoers/147655/5 "2022-10-17T22:31:41Z")

</div>

with usermod, I got

usermod: Permission denied.  
usermod: cannot lock /etc/passwd; try again later.

---

<div class="post-metadata">

**Author:** ![sn2018](https://help.nextcloud.com/letter_avatar/sn2018/32/6_22734026db12803ebb3e059622ac3534.png) [@sn2018](https://help.nextcloud.com/u/sn2018)\
**Post date:** [October 18, 2022, 12:04am UTC](https://help.nextcloud.com/t/how-to-add-user-to-sudoers/147655/6 "2022-10-18T00:04:15Z")

</div>

Seems like one has to add pi as user when enabling SSH from the NCP panel. The reason is that even though pi is removed as the default user, it is still in the sodoers.

---

<div class="post-metadata">

**Author:** ![anon75456558](https://help.nextcloud.com/letter_avatar/anon75456558/32/6_22734026db12803ebb3e059622ac3534.png) [@anon75456558](https://help.nextcloud.com/u/anon75456558)\
**Post date:** [October 18, 2022, 12:17am UTC](https://help.nextcloud.com/t/how-to-add-user-to-sudoers/147655/7 "2022-10-18T00:17:31Z")

</div>

Unsure, never encountered this issue ever (when using ncp). I’ll let someone else advise. You should be able to boot into your boot menu and change the root user password in Debian since you don’t know it.

> **[How To Change Root Password on Debian 10 – devconnected](https://devconnected.com/how-to-change-root-password-on-debian-10/#Change_root_password_using_single_user_mode)**
>
> Change root password on Debian 10 using the passwd command or the su utility. Change root password with single user mode.

---

<div class="post-metadata">

**Author:** ![schoetju](https://help.nextcloud.com/user_avatar/help.nextcloud.com/schoetju/32/44547_2.png) [@schoetju](https://help.nextcloud.com/u/schoetju)\
**Post date:** [October 18, 2022, 4:51pm UTC](https://help.nextcloud.com/t/how-to-add-user-to-sudoers/147655/8 "2022-10-18T16:51:59Z")

</div>

Hi sn2018,

please use the web-ui and activate SSH for user pi as described in

> [@How to enable SSH using ncp-config or ncp-web](https://help.nextcloud.com/t/how-to-enable-ssh-using-ncp-config-or-ncp-web/126317):
>
> Depending on your access Web, from a browser visit [https://nextcloudpi.local:4443](https://nextcloudpi.local:4443) username : ncp Password : Generated at activation [Watch a short video demonstrating enable ssh in ncp-web](https://youtu.be/mjt9wTef5AA) To have access through the terminal you need to enable SSH first in the web interface, set a username and password. Once logged in: sudo ncp-config Scroll down ncp-config screen and select SSH [nextcloudpi-config screenshot] Use arrow keys for up and…

(Its currently possible via Web-UI only!!)

This will activate the user pi again (which is part of sudoers)

Afterwards you can logon with user pi from terminal/console (physically keyboard/display connected to your device) as well as using ssh.

Crazy workaround, however the only one i am aware of for now.

Best regards  
schoetju

---

<div class="post-metadata">

**Author:** ![vascocb](https://help.nextcloud.com/user_avatar/help.nextcloud.com/vascocb/32/27457_2.png) [@vascocb](https://help.nextcloud.com/u/vascocb)\
**Post date:** [October 18, 2022, 6:00pm UTC](https://help.nextcloud.com/t/how-to-add-user-to-sudoers/147655/9 "2022-10-18T18:00:08Z")

</div>

I believe that problem will be related with this:

> **[An update to Raspberry Pi OS Bullseye - Raspberry Pi](https://www.raspberrypi.com/news/raspberry-pi-bullseye-update-april-2022/)**
>
> Over the years, we have gradually ramped up the security of Raspberry Pi OS. Here's Simon Long to tell you what has changed.

---

<div class="post-metadata">

**Author:** ![sn2018](https://help.nextcloud.com/letter_avatar/sn2018/32/6_22734026db12803ebb3e059622ac3534.png) [@sn2018](https://help.nextcloud.com/u/sn2018)\
**Post date:** [October 21, 2022, 1:26am UTC](https://help.nextcloud.com/t/how-to-add-user-to-sudoers/147655/10 "2022-10-21T01:26:07Z")

</div>

Thank you for confirming. See my previous post.

---

<div class="post-metadata">

**Author:** ![vascocb](https://help.nextcloud.com/user_avatar/help.nextcloud.com/vascocb/32/27457_2.png) [@vascocb](https://help.nextcloud.com/u/vascocb)\
**Post date:** [October 21, 2022, 1:53am UTC](https://help.nextcloud.com/t/how-to-add-user-to-sudoers/147655/11 "2022-10-21T01:53:54Z")

</div>

If you flash the card with using Raspberry Pi Imager you can add the user correctly as explained in the Headless setup of the post.

---

<div class="post-metadata">

**Author:** ![sn2018](https://help.nextcloud.com/letter_avatar/sn2018/32/6_22734026db12803ebb3e059622ac3534.png) [@sn2018](https://help.nextcloud.com/u/sn2018)\
**Post date:** [October 21, 2022, 2:20am UTC](https://help.nextcloud.com/t/how-to-add-user-to-sudoers/147655/12 "2022-10-21T02:20:50Z")

</div>

Yes, that will work too as long as you add pi in userconf or userconf.txt

---

<div class="post-metadata">

**Author:** ![wwe](https://help.nextcloud.com/user_avatar/help.nextcloud.com/wwe/32/72963_2.png) [@wwe](https://help.nextcloud.com/u/wwe)\
**Post date:** [December 14, 2024, 11:24am UTC](https://help.nextcloud.com/t/how-to-add-user-to-sudoers/147655/13 "2024-12-14T11:24:00Z")

</div>


