File 'containers/app.yml' is unwritable

AI-generated summary

A user, rajesh.saharan, encountered an issue with a file being unwritable (File 'containers/app.yml' is unwritable) while trying to edit their app.yml file on an AWS EC2 instance. fzngagan suggested checking the file’s ownership, which rajesh.saharan didn’t know how to do.

fzngagan provided Unix commands to find the owner, and rajesh.saharan requested clarification. After running the commands, rajesh.saharan found that the file belonged to the root user, while they were logged in as ubuntu. fzngagan explained that this was the cause of the issue and suggested using sudo su - to gain root access.

However, rajesh.saharan found an alternative solution by using sudo nano app.yml, which allowed them to make changes to the file. fzngagan advised rajesh.saharan to remember to use this method every time they need to make changes on their instance.

I am following this guide to install discourse on AWS EC2 instance.

Completed all the steps except Elasticache (not using separate Redis).

After finishing the discourse setup, I need to edit my app.yml for change in RDS and SMTP settings.

But it’s showing that File ‘containers/app.yml’ is unwritable.

Has anyone faced this issue? How to resolve this?

Have you checked the owner of the app.yml file?

No, How to find out this?

from your command line, cd to the containers folder and type ls -l

Sorry I don’t know much about Unix commands. Can you give me full command that I should enter to find out the owner of the app.yml file?

cd /var/discourse/containers && ls -l

then

run whoami

Showing this : -rw-r–r-- 1 root root 3819 Jul 30 10:21 app.yml

run whoami
It’s : ubuntu

There you go. You aren’t logged in as root. And the file belongs to the root user. That’s why you aren’t able to write to that file.

Actually, with EC2, you cannot login as root directly. Now, you’re logged in as ubuntu user.

type in sudo su -

Okay. Actually initially I followed the commands given here.

Just tried this : sudo nano app.yml

And now I can make changes!

Thats great. You’ll have to remember to do this everytime you need to make changes on your instance