Working With the Command Line in Goorm IDE (Node.js) – Backend Web Development
If you’d like to follow along (I’m writing this as notes for my future self) then you want to head on over to goorm.io and get yourself setup on their platform. They are a “full stack” web development IDE and allow you to access various virtual environments called “containers”.
I this post I’m going to be talking about the command line, what it is, what we use it for and what commands we can use in it.
Getting setup before we start
In this instance, as this is the first time I’m working this way and with this kind of technology, I wanted to take some notes to help me solidify the information in my mind. I’ve already created an account and once done I went to my goorm.io dashboard and created a new container , selecting my nearest region (somewhere in Germany I think) and the type of environment that I wanted to work in (selecting Node.js). As I will be working with MongoDB, I also scrolled right to the bottom (had to look around for a bit) to click the option to install MongoDB into the container.
It took a little while to finish but once done I simply visited the newly created container workspace.
At this point I typed in the following into the command line to ensure node was installed:
node -v
Seeing that the return of that was a version number, I’m happy the environment is setup with Node.js and can begin to understand the command line further.
What is the command line?
Rather than invent the wheel, there is a really good article on the command line written by David Baumgold and is a very good resource on the topic. Essentially, just like on your computer you have the command prompt feature (negating the GUI and allowing you to type commands directly to the console) which allows you to easily do really powerful things (like delete everything on your computer without even questioning it) so it’s important to not just run any command to see what happens.
One reason we use the command line is because it is a lot faster than when working with a GUI (like Windows for example); or to initialise our Node.js server. The aim is to get comfortable working with command line.
// Top Tip!! When you start typing in the name of a file or folder into Goorm you can hit the “tab” button and the IDE will automatically autofill the appropriate filename for you.
The “ls” and “cd” commands
“ls” stands for “list”; as in list the items that are within a folder. “cd” stands for “change directory” and allows us to navigate through the folders in our workspace folder.
Go into file…
cd filename
Go into parent file…
cd ..
The “touch” command
The touch command allows us to create a new file within our current folder. The syntax for the command would be
touch newFileName.txt
The “mkdir” command
This allows us to make a directory in our current folder and the syntax is as follows:
mkdir newFolder
The “rm” & “rm -rf” commands
The “rm” command works by “cd-ing” into the desired folder (that contains a file you want to remove) and then simply typing in “rm” (for remove) and then the file that needs to be removed afterwards.
rm fileName.txt
The “rf” in “rm -rf” (“rm” obviously meaning remove) stands for recursive force and we will use it to delete a folder that has subfolders or files stored within it. It essentially acts as a “flag” for the “rm” command to tell it to do something slightly different.
“rm” deletes a file and “rm -rf” deletes a folder (directory).
rm -rf directoryName
// Note: If you type this command in the root directory of your computer you will delete everything on it.
// Warning!! If you type “rm -rf /” into the command line you’ll delete all the files in your workspace.