Create directory "/dotenv" on MacOs, Read-only file system

Viewed 6669

I tried to create a directory under root (the directory when I open terminal)

sudo mkdir /dotenv

But the system says:

mkdir: /dotenv: Read-only file system

My OS is Catalina 10.15.2

Is there any way to create the dir? I need to run a node.js server locally which requires .env file in the /dotenv dir

2 Answers

You'll need to use mkdir dotenv if you are at your profile root (which it appears you are). That was the only way I could get it to work (I am on Catalina 10.15.3).

Using mkdir /dotenv (notice the /) I got the same error as you.

If you really want to, you can disable the read-only file system in Catalina by following these steps (which are also listed below).

Problem because of Read-only file system in mac os catalina

  • Boot you mac system into recovery mode. (by bootup system with holding CMD+R).

  • Open terminal (Present in "Utilities" in the top left menu).

  • Just run command

    • csrutil disable
  • Restart your system and Bootup normally

  • Before doing any activity open terminal and run command.

    • sudo mount -uw /

Once this all done you can do write in root location

  1. Require the result in command: csrutil status
  2. If result is enabled, you need to restart machine and press command + R, open the terminal in the recovery, so input csrutil diabled.
  3. Restart, and check the status: csrutil status.

Here are two methods:

  1. you are root.

    sudo mount -uw / so, you could mkdir or touch new file.

  2. If you still can't read or write any, you maybe try this:

    cd ~ # cd home directory sudo vim /etc/synthetic.conf # create new file if this doesn't exist

In the conf files, add new line

dotenv /User/xx/dotenv # Notice: the space between this two strings is tab

Restart, and you will find a link named /dotenv in the root.

Related