Linux Basics
Learn the basics of operating a Linux-based operating system (OS) and take your first steps in exploitation in a Linux environment!
Easy
Linux_Basics::Introduction
What is Linux?
When we talk about Linux, we think about OSes like Ubuntu, Fedora, Arch. They all run on the Linux kernel, so although they look different, under the hood they behave almost the same. We will skip the details for now, and learn more about Linux through this module.
Why use Linux?
Linux is great because it is free and open source. Not only the OS is free, all programs on them are also free. It is easy to setup, good for learning the various concepts in the subsequent modules.
How to use Linux?
Obviously, to use Linux, we need to install it, just like any operating system. However, normally laptops ship with Windows, or in the case of MacBooks, macOS. So it is unlikely people would have a laptop running Linux by default, unless you have Chromebook, a System 76 laptop, Dell XPS, or some other rare system...
The alternative ways are to:
- Dual-boot
- Install WSL
- Setup a virtual machine (VM)
Unless you are planning to use Linux for your daily activities, dual-booting is most likely not what you want, as you have to share disk space between both OSes, and you can only use one operating system at a time.
WSL (Windows Subsystem for Linux) is an amazing effort by Microsoft to include the Linux kernel in Windows (WSL2), so that now we can run Linux program on Windows, very naturally as if we're on a Linux machine.
However, virtual machines (VMs) are our recommendation. VM software allows us to run an entire operating system just like a normal program, with a virtual filesystem and virtual hardware resources. For beginners, this is our recommended approach as we tend to download unsafe software while learning about security or mess up some configurations while learning about Linux. If you make any horrible mistakes, you can simply delete the entire VM and try again!
Using a VM is rather straightforward. Just download a virtualization software like VirtualBox (free!), VMWare Workstation or Parallels, then a Linux installation disk or VM image, and you are ready to go.
In our trainings, we will be making use of Docker. Docker is not as sandboxed as a true virtual machine on all systems, however, we believe it's the easiest to set-up and distribute. We have prepared a docker container with all the tools and helpers scripts to allow you to have the best experience with our modules. Even if you already have an existing Linux set-up, we encourage using our docker container for the most seamless experience.
Bento
To start, head over and download Docker and Docker Compose. For macOS/Windows users, downloading Docker will come bundled with Docker Compose already so you just need one step. Once Docker is installed, we need to touch the command line a little. Don't worry, just a little. On Windows, Windows Terminal running WSL is most recommended. On macOS, Terminal or iTerm2, whichever you prefer.
Run the following commands to download the challenge environment for this module.
git clone https://github.com/chickenRCE/omu-linux-basics.git
cd omu-linux-basics
git
, follow some tutorials to download it and come back here after you've cloned the repository.
At this point, you can start the challenge environment by running the following commands inside the omu-linux-basics
directory.
docker-compose up -d
Your first run should be slow, but eventually should successfully end like so:
$ docker-compose up -d
...
Creating network "linux-basics_default" with the default driver
Creating linux-basics_cat_flag_1 ... done
Creating linux-basics_dog_flag_1 ... done
Creating linux-basics_bento_1 ... done
Creating linux-basics_peekaboo_column_1 ... done
Creating linux-basics_no_touch_no_see_1 ... done
Creating linux-basics_touch_no_see_1 ... done
Creating linux-basics_peekaboo_line_1 ... done
Creating linux-basics_catch_the_thiefs_1 ... done
Future runs of this command will be much faster, so just persevere through the first delay.
First steps in Linux!
If you've set-up everything properly (locally), run the following commands:
Linux/macOS
./connect
Windows
./connect.ps1
This command will let you connect into the challenge environment. If successful, you should see a similar prompt to below.
root@153ee55c9ccf:/#
bento
. You can do so by pressing Ctrl+D
or entering exit
into the terminal.
What you're looking at here is referred to commonly as the shell, this in particular is the Bash
shell. A shell is a simple text program that allows you to interact with the computer. But as you'll find out throughout this module, with exception of graphic-intensive tasks like drawing or playing games, almost anything you need to do can be done through the shell alone.
The shell is text-based and will wait for commands from you, the user, in order to understand what to do.
The command to execute is determined by the first word on a line of input sent to the shell, let's try it out with some simple examples.
Try typing the following commands one at a time, pressing <Enter>
to send your command to the shell.
ls
...
id
...
Congrats! You've had your first taste of the command shell. We'll be introducing more commands to you as we progress through the lessons, but most will be executed with the following format:
<command> <argument 1> <argument 2> ... <argument n>
If you're ever confused about how a particular command works, try reading it's manual using the man
command.
man <command>
For example, to learn about the ls
command:
man ls
If you're feeling confused at this point because you've been typing commands you don't understand, don't fret. We'll introduce many useful commands as we progress through this module. However, we hope that you've understood how to set-up the Docker container, and roughly understand how commands can be sent to interact with a Linux system.
Quiz
What is the name of the command shell we are using in bento?
What is the command to read the manual for the command id
?
Finish
If you wish to stop the challenge environment, type the following command while in the omu-linux-basics
directory.
docker-compose down
You can always come back another day and run
docker-compose up
./connect
To start the challenges again and continue your learning!