4 min read
In this article, I’ll go over the fundamentals you need to understand the terminal. The aim of this article is not to explain all the possibilities, rather it is to give you a foundation from which you can build on.
The commands I will use in this article work on MacOS and other Unix base operating systems. However, the same principles should apply to any other command line interface (e.g. Windows).
You may be already familiar with the graphical user interface (GUI), that is one way of telling your computer what to do.
The terminal is another. It is mostly text-based and can feel more primitive, but it is also often more powerful.
To open your terminal, you can just search for an application called terminal and open it. It will likely look like a blank box, with a cursor and the name of your computer
It can look quite scary but it really isn’t. Let’s jump into it and run a few commands.
To use a terminal, we type out a command and press enter to send it as our input, then the computer runs the command and sends out an output.
A very common command is ls
. This will list out the contents of the current directory.
That may look a little familiar, that is because it is the same as this:
Another command you will likely use very often is cd
. What that does is to change directory. Meaning, if we want to look inside the desktop folder, we would type cd Desktop
and then press enter. We can then list the files inside the Desktop folder by using the ls
command.
To see some more details about the files, for example when the file was last modified, we can run ls -l
.
Now that you’re getting a feel for it, let’s break it down.
Commands are generally made up of 3 parts.
cd
or ls
.cd
when we ran cd Desktop
.-l
flag to the ls
command to make it print more details when we ran ls -l
.At this point, you may have some questions:
If you want to learn how to do a new thing, you can search for it through google. I assure you there will be tons of examples and recommendations.
The commands you will interact with most often are not too many, and you will likely get the hang of those pretty quickly. Here are a few
touch
: Used to create a new filemkdir
: To create a new directoryrm
: To delete files of directoriescp
: To copy files or directoriesmv
: To move(i.e. rename) files or directoriesIt is possible that you will install other command line programs on your computer, such as git
, homebrew
, docker
and so on.
Most inbuilt programs come with a manual that you can access using the command man
, which is fittingly a command-line tool itself. For example, to view the manual of the ls
command, we would run man ls
.
A convention among most external tools is to use the —help
flag to display the help for the command. As an example, see git
:
Google, Google, Google!
Search for how to do something, and try it out. If you encounter an error, search for the error and figure out what is wrong.
Don’t try to memorize things. The commands you use frequently will become second nature pretty quickly, and the ones you don’t you can always find when you need it.
Docker volumes are very useful when we need to persist data in Docker containers or share data between containers. Docker volumes are important becau...
4 min read
In a previous article, we talked about Docker images but we could only use a small section to talk about Docker containers. Now, let’s go deeper. D...
8 min read
Comments