Hidden files 🕶️

On a linux filesystem, every file and directory whose name starts with a dot . will be hidden.

Such files will not be displayed when using a regular ls.

You can actually see hidden files and directories using ls -a for “all” though.

This command will also display a single dot . which means “the current directory” in Linux and two dots .. which means “the directory above this one in the arborescence”.

Observe the difference between :

$> ls .
$> ls -a .
$> ls ..

Advanced ls

ls can give you even more useful information about files and directories!

Using ls -l on the challenges/command_line_101 directory will print the following list :

$> ls -l challenges/command_line_101/
total 28
drwxrwxr-x    3 root     root          4096 Jan 11 21:59 .
drwxr-xr-x    3 root     root          4096 Jan 11 21:59 ..
-rw-rw-r--    1 root     root            96 Jan 11 21:59 .challenge_4
-rw-rw-r--    1 root     root           276 Jan 11 21:59 challenge5.sh
-rw-rw-r--    1 root     root           111 Jan  9 15:44 challenge_0.txt
-rw-rw-r--    1 root     root            77 Jan  9 20:57 challenge_1.txt
drwxrwxr-x    3 root     root          4096 Jan 11 21:58 challenge_2

We’re going to leave some of the information printed in this list for another class, but you should already recognize the file and directories names usually displayed by ls!

The first line “total 28” means that this directory uses a total of 28 filesystem “blocks”.

A block is simply a way of counting space on a Linux filesystem, a bit like the more commonly represented Mega octets and Kilo octets. A block is equivalent to 8KB => 8000 bytes.

The hours and dates are the last modification date for each item and the number printed on the left of the month (Jan->January in this example) is the file’s size in bytes.

Also note, lines starting with d are directories!

Executing scripts 📜

About scripts

What are scripts, you’re wondering?

Scripts are files containing commands and logic which can be used to automatize mostly any task you do on a computer!

Linux and Operating Systems in general are full of scripts, some of them are used to install softwares, update files, make sure programs are not outdated, update the time, move log files, display alerts etc…

Executing your first script

In order to run a script, you just need to write its path in your terminal.

For instance, a script is located in /usr/bin/foxsay on hack.courses.

Type the following command in the terminal to run this script :

/usr/bin/foxsay hello

The output should be a fox saying “hello” in your terminal

Congrats, you just ran your first script!

Now, this is not the only way to run a script.

The path you used here is what is called an absolute path. An absolute path starts from the root of your filesystem ("/").

You can also run a script using its relative path, a relative path is, contrary to an absolute path, a path which does not start with “/”.

To run a script within the directory you are currently in, type “./” followed by the script name.

For instance, move inside the /usr/bin directory using cd /usr/bin.

Now, use the following syntax to run the same script again :

./foxsay hello

Hint : Don’t forget to type cd to go back to your home directory.

Hands-on 🤜!

Ready to take one some harder challenges? Let’s go!

Challenge 4

The challenges/command_line_101 directory contains a flag for this challenge.

But beware, it’s hidden!


Hint : Advanced ls

Challenge 5

The flag for this challenge is not hidden, it is in the same directory!

But this time, it is not a text file that you can cat, it is a script!

Run the script to get the flag.

Ready to continue? Make sure to take a break, drink some water and move on to

Command line 104