Error writing /etc/yum.repos.d/mongodb-org-4.0.repo : Permission Denied

Viewed 3165

I am trying to install mongodb on my amazon linux 2 server by following the documentation MongoDB but when I am trying to save the repo file it shows the following error

Error writing /etc/yum.repos.d/mongodb-org-4.0.repo: Permission Denied

The repo file contents are:

[mongodb-org-4.0]

name=MongoDB Repository

baseurl=https://repo.mongodb.org/yum/amazon/2/mongodb-org/4.0/x86_64/

gpgcheck=1

enabled=1

gpgkey=https://www.mongodb.org/static/pgp/server-4.0.asc

The error is displayed when I try to save my file. How can I resolve this error? Thanks in advance.

1 Answers

Are you logged in as ec2-user? If so, use sudo to edit the file.

If you're setting up several things that require root access, try: sudo su -

then make all the changes and when your finished: exit

then you'll be back on the ec2-user

Related