local_requirements.txt Permission denied

466 views
Skip to first unread message

Robert Otto

unread,
Apr 2, 2021, 5:09:34 PM4/2/21
to NetBox

Hello everyone,

Fresh install on Ubuntu 18.04.5 LTS up in Azure using a secondary account (not named netbox) and when I try sudo echo napalm >> /opt/netbox/local_requirements.txt I get permission denied.

I tried Googling and couldn't find anything and I tried the same for the ldap connector and got the same error.

I appreciate anyone's assistance.

João Lucas B. Macedo

unread,
Apr 2, 2021, 7:23:42 PM4/2/21
to Robert Otto, NetBox
Did you check the current permissions on that file and its directory? Remember that probably the user root don't have permission to change it but it can change permissions. 

By the way, as far as I know, Ubuntu 10.04 doesn't have the minimal version of python to run current NetBox release. You might double check it.

--
You received this message because you are subscribed to the Google Groups "NetBox" group.
To unsubscribe from this group and stop receiving emails from it, send an email to netbox-discus...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/netbox-discuss/42636e92-a635-4b7a-9d27-aadbe9a914aan%40googlegroups.com.

Brian Candler

unread,
Apr 3, 2021, 3:42:58 AM4/3/21
to NetBox
> when I try sudo echo napalm >> /opt/netbox/local_requirements.txt I get permission denied.

You will indeed get an error if you do that.  That's because the shell first tries to connect stdout to /opt/netbox/local_requirements.txt (as the current user), *before* running the command "sudo echo napalm".  However the current user doesn't have rights to open that file for write/append.

Solution 1: switch to a root shell first, before doing the redirection

sudo -s
echo napalm >>/opt/netbox/local_requirements.txt
exit

Solution 2: use "tee -a" to append to the file; this works because it doesn't open the file until after it's started.  (You'll see this used often in snippets on the web, as it's a convenient one-liner)

echo napalm | sudo tee -a /opt/netbox/local_requirements.txt

Solution 3: get a root subshell to do the redirection (converting solution 1 to a one-liner)

sudo bash -c "echo napalm >>/opt/netbox/local_requirements.txt"

Brian Candler

unread,
Apr 3, 2021, 3:45:56 AM4/3/21
to NetBox
@joaolucasmacedo: the OP said Ubuntu 18.04, not 10.04.

Ubuntu 18.04 has python 3.6, which is fine for running the current release of Netbox.  However, it's likely that 3.7 will become the minimum requirement soon.  To avoid future hassle, you'd be better off installing Ubuntu 20.04.

Robert Otto

unread,
Apr 5, 2021, 12:19:44 PM4/5/21
to Brian Candler, NetBox
Thank you very much everyone sudo -s did the trick!

On Sat, Apr 3, 2021 at 3:45 AM Brian Candler <b.ca...@pobox.com> wrote:
@joaolucasmacedo: the OP said Ubuntu 18.04, not 10.04.

Ubuntu 18.04 has python 3.6, which is fine for running the current release of Netbox.  However, it's likely that 3.7 will become the minimum requirement soon.  To avoid future hassle, you'd be better off installing Ubuntu 20.04.

--
You received this message because you are subscribed to a topic in the Google Groups "NetBox" group.
To unsubscribe from this topic, visit https://groups.google.com/d/topic/netbox-discuss/ZsIe2mm34XI/unsubscribe.
To unsubscribe from this group and all its topics, send an email to netbox-discus...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/netbox-discuss/afbdea40-3fa1-4fe0-be01-8c022fc6b330n%40googlegroups.com.
Reply all
Reply to author
Forward
0 new messages