Linux filesystem arborescence 🌳

Let me tell you a bit about the way linux filesystems are organized.

/ is where everything starts, it’s the root of your filesystem, a little bit like your C: drive is usually where everything is stored on a Windows machine.

/home (which is located inside /, that’s why it starts with the same character) is where the user’s directories are usually stored. It is analogous to the C:\Users directory on Windows.

Each user has its own home 🏠 directory, you can see which one is yours using the following command :

$> echo $HOME

Note : New command here! Echo will print something, it's not exactly like cat, cat will print the contents of a file, echo will print variables and character strings.

In a Linux terminal, using the $ character in a command will make use of a variable. The $HOME variable has been predefined in your terminal when you started id. Such a variable is named an environment variable.

Observe the difference between your terminal’s output when you type :

$> echo $HOME

and

$> echo HOME

Note : $HOME can also be replaced with the ~ character. Try to echo ~.

Manual pages 📚

Did you know that most Linux system come with manuals for almost every command installed?

For instance,

$> man ls 

will display the manual pages for the command ls.

You can use your keyboard’s arrows to navigate inside the manpages, the space key to skip to the next page and q to quit.

Note : It’s also time to let you know that you can access those classes directly in the terminal on term.hack.courses using the classes command! Select a class with your keyboard keys and press enter to open a course’s contents. You can navigate through the files exactly like you would with a manual page.

Stopping a command 🛑

Let’s imagine that you use the sleep command (even if you don't know it yet) and type something like :

$> sleep 42

Your shell is going to wait 42 seconds before allowing you to type new commands, until then, you’re stuck and cannot write new commands!

Note : You might have guessed it, waiting is exactly what the sleep command does, it simply waits for a given number of seconds!

If at some point you get stuck in a command-line which blocks the execution of new commands, you can use the CTRL + C shortcut to force the current program to quit.

Exiting a program in such a way is called killing a program. Your terminal will send a message to the program and ask it to shut down.

Note : Some programs do not answer to such messages and sometimes, simply closing your terminal window will be the most efficient way of stopping a program. Also keep in mind that closing a terminal window does not always kills the program that runs in it... But that's a bit advanced for now.

Echo 🔉

Echo (which for some reason always reminds me of Ecco the Dolphin) is an incredibly useful Linux command!

You can use it to display character strings on your screen.

For instance if you want to print “Hello, world”, you can type :

$> echo Hello, world

You can also use it to display a variable’s value, for instance :

$> echo Hello, $USER

Note : On a Linux system, in most cases commands will be lowercase! If you type "Echo" in your terminal with a capital "E" it won't be able to recognize the echo command!

Tac

You head of cat, right? Well, there's also tac which is cat, but with its lines reversed! Tac will display the contents of a file in a reversed order.

Rev

There is another command, similar to cat and tac in a way! I will reverse not only the order of the lines in a file, but the whole contents of the files passed as a parameter.


You can now go through the challenges 2 to 5 and complete the next section with the flags you obtained on https://ex.hack.courses/q/linux101!