Command-Line 102 : Filesystem and more
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 $HOMEIn a Linux terminal, the $ character designates a variable. The $HOME variable has been predefined in your terminal by the operating system, such a variable is named an environment variable.
Observe the difference between your terminal’s output when you type :
$> echo $HOMEand
$> echo HOMENote : $HOME can also be replaced with the ~ character. Try to echo ~.
Manual pages 📚
Did you know that Linux comes 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 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 say you use the sleep command and type something like
$> sleep 42Your shell is going to wait 42 seconds before allowing you to type new commands, until then, you’re stuck!
That's what the sleep command does, it 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.
Note : Some programs do not accept being killed and sometimes, closing your terminal window will be the most efficient way of stopping a program.
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, worldYou can also use it to display a variable’s value, for instance :
$> echo Hello, $USER