DEV Community

Cover image for 3 Ways to Manage Files in CloudShell
Sean Boult for AWS

Posted on

3 Ways to Manage Files in CloudShell

So you've probably had to open CloudShell from time to time to poke at something quickly. Say I wanted to test pulling down an artifact from a private CodeArtifact registry. To do that, I'd need to tweak my ~/.npmrc so npm points at the right registry.

Which raises the question: what's the best way to edit a file once you're in CloudShell? Let's look at a few options.

Using vim

I use Neovim btw (sorry emacs users), so naturally I'm starting with vim.

vim ~/.npmrc
Enter fullscreen mode Exit fullscreen mode

If you're already comfortable with Vim, this is probably the fastest option. You're already in the terminal, you get all the navigation and search you're used to, and there's nothing else to open.

Make your changes, hit ESC, and :wq (write + quit) to save the file.

Using nano

Ah the old classic. I've been using this for decades to edit files on remote boxes.

nano ~/.npmrc
Enter fullscreen mode Exit fullscreen mode

Unlike Vim, there's not much to learn before you can start typing. Nano even shows you the important shortcuts at the bottom of the screen.

Make your changes, hit CTRL+O to write them to disk, and CTRL+X to exit.

If you just need to make a quick edit and get out, nano is hard to beat.

Using edit

Okay, but what if you don't want to use a terminal editor at all?

CloudShell has an edit command that opens the file directly in its built-in editor.

edit ~/.npmrc
Enter fullscreen mode Exit fullscreen mode

Instead of editing inside the terminal, CloudShell opens the file in a familiar graphical editor where you can point, click, type, and save with CMD+S (CTRL+S on Windows/Linux) or the save icon.

If you're used to editing files in VS Code or another graphical editor, this is probably going to feel the most familiar.

No Vim modes. No terminal keybindings to remember.

Which one should you use?

Honestly, whichever gets you back to solving the actual problem fastest.

Editor Use it when...
vim You're comfortable with Vim and want to stay in the terminal
nano You want a simple terminal editor without learning Vim
edit You'd rather use a familiar graphical editor

So the next time you find yourself debugging something from CloudShell, you've got a few ways to quickly read or edit a file without leaving your browser.


As always, happy coding 😄!

Follow AWS for more articles like this and follow me for all things tech.

Top comments (0)