how to edit a file in railway console
bruceh29
FREEOP

3 hours ago

I will occasionally need to edit a file in my project console. The console seems to be a fairly standard Linux shell, so I was surprised to find that vi is not present. How can I edit a text file?

Solved

1 Replies

Railway
BOT

3 hours ago

The console opens a shell inside your service's container, so it only has the tools your image ships with. Many slim base images leave out vi.

The easiest way to edit a file is to copy it to your machine, change it locally, and copy it back. Our SSH endpoint supports scp and sftp: register a key with railway ssh keys add, then run scp myapp.up.railway.app@ssh.railway.com:/app/file.txt ./file.txt, edit the file, and copy it back the same way with the source and destination swapped. Use your service's domain as the username, or its service instance ID if it has no domain. You can also open an interactive session with sftp myapp.up.railway.app@ssh.railway.com. The full details are in the railway ssh docs.

If you'd rather edit in place, add an editor such as vim or nano to your image. Interactive tools like vim work in a railway ssh session.

Keep in mind that files you change in the container filesystem are lost on the next redeploy unless they are on a mounted volume.


Status changed to Awaiting User Response Railway • about 3 hours ago


Status changed to Solved bruceh29 • about 3 hours ago


Welcome!

Sign in to your Railway account to join the conversation.

Loading...