Getting Started With the Terminal

I'm a full-stack developer from South Africa 🇿🇦. I love writing about JavaScript, HTML and CSS.
Search for a command to run...

I'm a full-stack developer from South Africa 🇿🇦. I love writing about JavaScript, HTML and CSS.
No comments yet. Be the first to comment.
Most of you know me for my consistency, a golden arrow in my blog series. I've written 1000 articles in 1008 days! Almost an article a day, and my honeymoon was the only holiday I ever took. I'm super proud of this achievement; it has been a fantasti...

It's not the first time I'll be talking about community. I think it's an essential aspect of any successful tool. This shows in my previous explorations of Astro, Medusa, and now Vendure as well. All these products thrive in a super open, welcoming, ...

The cool part about Vendure is how easy it is to set up and how abstract each layer is. Basically, we get the following elements: External database Server Worker Admin UI Frontend While this is amazing, it also brings a bit of complexity when it co...

The previous article looked at customizing Vendure on a data and process level. In this article, we'll look at customizing emails, as they are often a big part of a webshop system. We'll be looking at two different layers of customization for customi...

Even though Vendure is a pretty significant project out of the box, in some cases, we might want to go in and modify some elements to work to our specific use case. In this article, I'll take a high-level look at some elements we can customize within...

The other day Carl made a useful comment:
Terminals and command lines scare me. Do you have any dev tips on getting started with these or know any good resources?
And it made me realize, I also was scared to use the Terminal at one point. It is one of these things wherein the beginning, you just don't know what's happening.
So let's walk through some basic commands today, which will make us more comfortable in using the Terminal.
Perhaps a good starting point is which Terminal to use, to be honest, it's much of a preferred choice than actually making a difference. But I use iTerm2 which works beautiful!
If you rather stick to another choice or the default Terminal, be my guest, it won't make a difference in what we are going to do today.
Oke, let's get cracking on some commands.
cd command means change-directory, and it is the same as clicking on a folder on your regular desktop.
For instance:
cd Desktop // move into the desktop "folder"
We can also go up one level by using ..
cd ..
// Or even multiple levels
cd ../../
We can always go back to the starting point by using cd without arguments.
cd
Every now and then, you forgot where you are, and you want to know what the current folder is.
You can use the pwd command Print Working Directory
pwd // Return something like: /Users/chrisbongers/Desktop
Another handy command is ls it means list and can we used to show folders inside the directory we are in.
ls // Show current directory
ls .. // Show parent directory
ls Desktop // Show specific directory
Sometimes it's easier to create a folder in the Terminal because you are already there.
We can use mkdir make directory for this.
mkdir NewApp
Be careful when using remove commands. The Terminal is strong and can remove system files, so use these with care.
We can use rmdir Remove Directory to remove a folder
rmdir NewApp
Or we can use rm Remove in general
rm testfile.txt
For the rm command we can give it the -r parameter which stands for recursive it will delete everything inside the folder you pass
rm -r NewApp
We can also copy folders and files with the Terminal by using the cp Copy command
cp testfile.txt test2.csv
Where the first argument is the source and the second the destination file.
We can also copy a complete folder and contents:
cp -r NewApp TestApp
Another excellent command is mv Move. It works the same as the cp one but will move the elements instead of copying them.
mv testfile.txt Desktop/testfile2.txt
As you can see, we can even move and rename.
Perhaps the most interesting one is the ability to create files.
There are multiple ways of creating files, the most common is touch, but my personal favorite is nano.
Nano works great because it's generic, it can create but also edit a file at the same time.
nano testfile.txt // Will create the file and open it!
Once you opened a file in nano you can type whatever you want, and once your done, use CTRL+X to close and save the file.
I hope these Terminal commands were helpful, and I challenge you to have a play around with these.
Let me know in the comments if there are any really good ones I might have missed.
Thank you for reading my blog. Feel free to subscribe to my email newsletter and connect on Facebook or Twitter