Anime-Sanctuary

The terminal for beginners

Connected to your server, all you see is one line, waiting. About fifteen commands are enough to find your way, read, write, tidy up, and get out of any jam.

Course
Tutorial 8 of 35
Time
30 min to read
Tested with
Debian 13.7 (trixie), bash 5.2
What you will be able to do
  • Know where you are and move between folders.
  • Read a file, create one and edit it with nano.
  • Copy, rename and delete without a slip.
  • Get out of a jam with Ctrl+C, q or Ctrl+X.

Before you start: Your first SSH connection.

Contents
  1. 1. The three emergency exits
  2. 2. Where are you: pwd and ls
  3. 3. Move around with cd
  4. 4. Read: cat and less
  5. 5. Create: mkdir and nano
  6. 6. Copy and rename: cp and mv
  7. 7. Delete with care: rm
  8. 8. Get help: --help and man
  9. 9. Go faster: history and Tab
  10. 10. Tidy up
  11. If it fails
  12. What comes next
  13. Sources

You're connected to your server. In front of you, one blinking line and not a single icon. How do you find your way without a mouse? With about fifteen commands, which you learn in thirty minutes and keep for life. A command is a short instruction, typed in the terminal and sent with Enter. You'll watch each one work on your server, in a practice folder that we'll delete at the end. The connection itself is in Your first SSH connection.

1The three emergency exits

Before the first command, learn how to escape: it's easier to learn when you know the way out. Sooner or later you'll be stuck in front of a screen that stops responding, and the cause is always one of these three:

What you seeThe keyEffect
A command is running and won't give the prompt backCtrl + Cstops it
Full-screen text (less, man)the q keycloses it
The nano editorCtrl + Xquits it, after offering to save

Let's try Ctrl + C right now. The sleep command waits for the number of seconds you give it and does nothing else, which makes it a perfect victim. Type it, let it run for a second, then press Ctrl and C together.

On the server
sleep 100
Expected output
^C

The ^C is the trace of your keypress, and the prompt comes straight back. The prompt is the line that waits for you to type, for example root@mon-serveur:~#. You can now stop a command that drags on forever, which is very reassuring. What is left is knowing where you are.

2Where are you: pwd and ls

The pwd command prints the place where you are, like the red dot on a map. Its name comes from print working directory. A folder is a container that holds files and other folders. Its address is called a path, and its parts are separated by slashes.

On the server
pwd
Expected output
/root

/root is the home folder of root (the administrator account), and your starting point at every login. To see what it contains, use ls (short for "list").

On the server
ls

On a new machine nothing shows up: the folder is empty, or holds only hidden files. A hidden file has a name that starts with a dot, and ls doesn't show it. To see them, add the option -a ("all"), a setting placed after the command: ls -a. Now let's see how to leave this folder.

3Move around with cd

The cd command ("change directory") takes you into another folder, whose path you give. Try it with /etc, the folder where Linux keeps its settings. A path that starts with a slash begins at the very top of the system (the root, written /). So it works from anywhere.

On the server
cd /etc
Expected output
root@mon-serveur:/etc#

The command prints nothing, but the prompt changes. Where the ~ used to stand for your home folder, it now shows /etc. Read the prompt: it always tells you where you are. Two shortcuts get used all the time:

  • cd .. goes up one folder. The two dots stand for the parent folder.
  • cd alone, with nothing after it, takes you back to your home folder.

Try the second one, then check with pwd.

On the server
cd
Expected output
root@mon-serveur:~#

You're back home, and the prompt shows the ~ again. You can move around, so let's read what the files contain.

4Read: cat and less

The cat command prints the content of a file, and less shows it one page at a time when it's long. For a short file, cat is enough. The file /etc/hostname holds the machine's name, so let's read it.

On the server
cat /etc/hostname
Expected output
mon-serveur

For a long file, cat would dump hundreds of lines at once. Use less instead, which opens the file full screen. Try it on /etc/login.defs, a settings file over a hundred lines long.

On the server
less /etc/login.defs

Four keys are enough inside less:

  • the space bar moves forward one page, and b moves back one page;
  • / followed by a word, then Enter, searches for that word (try /LOGIN_RETRIES);
  • q closes the file and gives you the prompt back.

If you get stuck in less, press q, as in the table at the start. cat has a trap of its own: with no file name, it reads what you type on the keyboard.

On the server
cat
Expected output
coucou
coucou
^C

The first coucou is what you typed, and the second is cat repeating it back. Nothing is broken: it was waiting for some text. Ctrl + C stops it, as at the start. Ctrl + D does too, because it means "I'm done typing". Reading is only half the job, so let's write a file.

5Create: mkdir and nano

The mkdir command ("make directory") creates a folder, and nano is a small text editor that opens inside the terminal. First create a practice folder, then step into it.

On the server
mkdir exercice
On the server
cd exercice
Expected output
root@mon-serveur:~/exercice#

Now open a new file called bonjour.txt. If that name doesn't exist yet, nano creates the file when you save.

On the server
nano bonjour.txt

The screen empties, with a reminder of the shortcuts at the bottom. The ^ sign stands for the Ctrl key there: ^O means Ctrl + O. Just write Bonjour depuis mon-serveur as you would in a word processor, then do this:

  1. Press Ctrl + O to save. At the bottom, nano shows Write to File: bonjour.txt.
  2. Press Enter to keep that name. It confirms with [ Wrote 1 line ].
  3. Press Ctrl + X to quit.

If you quit without saving, nano asks Save modified buffer? ("save your changes?"). The Y key says yes, then Enter confirms the name, and N discards the text. Check that the file exists, with cat.

On the server
cat bonjour.txt
Expected output
Bonjour depuis mon-serveur

Your first file is written, and it is yours. Let's make copies of it.

6Copy and rename: cp and mv

The cp command ("copy") copies a file: give the original first, then the name of the copy. The mv command ("move") changes the name or the place of a file.

On the server
cp bonjour.txt copie.txt

Nothing shows when all goes well. That's the rule of the terminal: silence means it worked. Let's look at the folder.

On the server
ls
Expected output
bonjour.txt  copie.txt

Now rename the copy. For mv, renaming and moving are the same thing: you give the old name, then the new one.

On the server
mv copie.txt salut.txt
On the server
ls
Expected output
bonjour.txt  salut.txt

The copy is now called salut.txt. For more detail, add the option -l ("long"), which also shows each file's size and date.

On the server
ls -l
Expected output
total 8
-rw-r--r-- 1 root root 27 Nov  4 22:15 bonjour.txt
-rw-r--r-- 1 root root 27 Nov  4 22:15 salut.txt

The number before the date is the size in bytes (here one byte is one character): 27 characters, as in "Bonjour depuis mon-serveur". Your dates will be your own. You now have one file too many, and it's time for the most dangerous command.

7Delete with care: rm

The rm command ("remove") deletes a file for good. There is no trash can in the terminal: what's erased doesn't come back. One habit protects you before every rm: run ls first to see what you're about to erase.

On the server
rm salut.txt
On the server
ls
Expected output
bonjour.txt

To make the terminal ask for confirmation before each deletion, add the option -i ("interactive"). Answer n to cancel. It's a good setting to keep until you feel at ease.

On the server
rm -i bonjour.txt
Expected output
rm: remove regular file 'bonjour.txt'? n

The file stayed in place; check with ls. A folder can't be deleted with a plain rm: the terminal refuses.

On the server
cd ..
On the server
rm exercice
Expected output
rm: cannot remove 'exercice': Is a directory

You just saw the terminal say no, and that's a feature. Next, learn to ask it questions.

8Get help: --help and man

Every command explains itself: add --help after it. The text is often long, so keep only the beginning. The | sign (the vertical bar) sends one command's output to the next. Here, head -3 ("head") prints only the first three lines of that text.

On the server
ls --help | head -3
Expected output
Usage: ls [OPTION]... [FILE]...
List information about the FILEs (the current directory by default).
Sort entries alphabetically if none of -cftuvSUX nor --sort is specified.

For the full manual, run man (short for "manual") followed by the command name. It opens full screen like less: same keys, and q to leave.

On the server
man ls

These pages are dense, but they say everything. Search for an option with / as in less. By now you have typed a lot of commands, and the terminal kept track of them.

9Go faster: history and Tab

The terminal remembers the commands you typed, and two tricks save you from typing them again. The first is the up arrow: it brings back the previous command, then older ones if you keep pressing. Enter runs it again, after any fix you make. The history command shows the list, with a number on the left. Add a number to see only the last lines.

On the server
history 4
Expected output
   15  rm -i bonjour.txt
   16  cd ..
   17  rm exercice
   18  history 4

The last line is the history command itself. Your numbers will differ, and so will your commands.

The second trick is the Tab key (left of the letter Q, above Caps Lock): it completes a name for you. Type cd exe then press Tab, and the terminal writes cd exercice/ by itself. If there are several possibilities, a second Tab lists them. Tab prevents typos, and it's the key regulars press most. Let's use it to tidy up.

10Tidy up

One thing is left: the practice folder. With Tab, type ls exe then Tab, and check what it holds before erasing it. That's the habit from step 7.

On the server
ls exercice
Expected output
bonjour.txt

It holds only your test file. So you can delete the folder with the -r option from the warning.

On the server
rm -r exercice
On the server
ls

The folder is gone and ls shows nothing: you are back to the starting state. Now for the two messages you're sure to meet.

If it fails

Two messages come back almost every session: a name that can\'t be found and a missing command. The first appears as soon as one letter is wrong, a capital for example. Linux tells Exercice and exercice apart.

On the server
cat absent.txt
Expected output
cat: absent.txt: No such file or directory

The second message shows up when a program is missing on your machine, for example nano, less or man on a very minimal install.

On the server
nano essai.txt
Expected output
bash: nano: command not found

The last trap is a terminal that seems frozen while it's waiting for more. Think of the three emergency exits from the start: Ctrl + C, q and Ctrl + X. With them, you always land back on the prompt.

What comes next

You can now find your way, read, write, copy, delete and escape a jam. Yet all this work happened as root, the account with no safety net, where a typo can cost you. The next article, Users, sudo and file permissions, creates an ordinary account for you and explains sudo. It comes now because you have to know how to type commands before you limit what they can do.

Sources (accessed November 4, 2026)