Getting Started with the Linux Command Line
NicolasBrondinBernard
Command-line prompts scare you? Come discover the basics, to get started slowly but surely!

Article published on 22/03/2022, last updated on 10/08/2026
This is a guest article, written by Imrane Dessai from the newsletter "Sysadmin for Developers"
One of the things you don't necessarily learn early on in your programming journey is how to use terminals/command consoles. Sometimes we think that as a dev, we write code... and the command line is for Ops folks...
Except in real life, there always comes a moment when you have to connect to a Linux machine (without a graphical interface). And there, you find yourself thrown into the deep end, without a lifebuoy.
So let's learn together the basic concepts of using a terminal, so we don't drown in the system!
The basics
The rest of this article assumes you already know how to get to a command terminal (via SSH on a server or by launching a local terminal).
It often looks like this:
username@hostname:location$
- username: the name of the user connected to the machine
- hostname: the name of the machine you're on (very handy for not making mistakes on the wrong server)
- location: the current folder
- $: indicates that you don't have administrator rights (otherwise it's a # when you're root/admin)
In the command line, we're going to call/invoke commands to perform actions:
- Administer your server
- Configure services
- Investigate failures
- Deploy source code to production
Roughly speaking, anything you could do on your own machine with a mouse... except here, everything happens on the keyboard.
Commands are like functions in code. A function takes parameters (or not), performs actions (prints, calculations, etc.) and returns a result.
To use a function, it needs to be defined and exist. Commands are pretty much the same thing. The command line is therefore an interpreter that will execute commands based on the parameters and variables you use.
A command often looks like this:
command [-argument] [--long-argument]
A few examples
It's recommended to try out the commands as you go along, so you can follow along and see the results live! There's nothing dangerous here.
Let's start with simple information retrieval:
pwd # Shows where you are in the
# file system (by default the base folder called home)
ls # Lists the files in the current folder
ls -l # Same list but with more details
date # Retrieve the system date and time
ps # List the processes currently running
Now, we can start exploring:
cd /tmp # Move to the /tmp folder
cd # Brings you back to the base folder (when used without an argument)
cat .bashrc # Displays the contents of the .bashrc file
history # Displays the history of the last commands executed
echo hello # Displays "hello" in the command prompt
Note that when a file/folder is preceded by a . like ".bashrc", this indicates that it is a hidden element by default.
And let's go a bit further:
touch example.txt # Creates a file example.txt
mkdir dossier # Creates a directory named "dossier"
echo “echo hello” > tryme # Injects the string "echo hello" into a new
# file which will be named "tryme"
chmod 700 tryme # Changes the file's access rights and
# allows it to be executed like a command
./tryme # Runs the file as a command
Normally, when running your last command, you should see the word "hello" appear in the console.
Congratulations, you've generated your first executable shell script!
Navigating more easily
Now that we've covered the basics, let's discover how to move around more naturally by revisiting more advanced uses of the "cd" command
pwd # Don't forget this command every time to check the current folder
cd / # Brings you back to the root of the file system, it's the first folder, the topmost one.
# There's nothing above it
cd /tmp # Jumps directly into the tmp folder located at the root
cd /var/log # Jumps directly into the log folder located inside var which itself is located at the root
# Note: You don't have to go back into a parent folder to go into child folders.
# This is called moving by absolute path, like teleportation
cd .. # Goes up to the parent folder
# (Following the examples in order, you should now be in /var)
cd log # Go into the log folder (if it exists)
cd ../.. # Goes up two parents (so to the root)
# Here we're moving by relative path. We don't give the full path, we give the path relative to your current location
cd - # a little trick to go back to the last folder
# (Normally /var/log now)
cd ../../tmp # Goes up two parents (so to the root), then goes back down into tmp
cd ~ # The ~ is equivalent to the base folder
cd ~/Desktop # Takes you to your desktop (Desktop folder contained within the base folder)
Now that we know how to navigate through folders, we can create and manipulate folders and files:
cd # Let's go back to our base folder to run some tests
mkdir folder1 # Creates a folder named folder1
ls -l # To check that it's properly listed
mkdir d1 d2 # Creates both folders d1 and d2 at once
mkdir folder1/d3 # Creates a folder d3 inside folder1
mkdir -p f2/d4 # Creates a folder d4 inside f2 (if it doesn't exist, creates it on the fly)
touch un.txt # Creates an empty file in the current folder
touch d1/deux.txt # Creates an empty file in the d1 folder
cp un.txt trois.txt # Copies the UN file and the copy is called TROI
mv un.txt d1 # Moves the file into the d1 folder
mv d1/* d2 # Moves everything (files and folders) found in d1 to d2
ls -l d2 # Lists what's in d2
rm d1/un.txt # Deletes the un.txt file located in the d1 folder
rmdir d1 # Deletes the d1 folder (only if it's empty, otherwise there will be an error)
Now you're no longer afraid of drowning in a command terminal, and better yet, you know how to navigate around, and you can start enjoying the view!
Going further
As you'll have understood, this article is an introduction, so here are all the avenues you can explore right now:
- The 40 basic commands to know: https://imrane.substack.com/p/interro-surprise-linux-cli-
- The "pipe" operator: https://imrane.substack.com/p/pipe-shell
- Operators: if, for... and variables
- Outputs and inputs (redirection symbols, echo, cat...)
- Concepts around permissions - Creating scripts that run like commands
- Customizing your command line with aliases and/or functions
No spam. Only free content, news, and ever more resources to level up your skills!
Join +1500 developers
No comments yet