How to Linux
History
To grasp the reasons behind Linux’s popularity, let’s journey back approximately three decades… Picture computers of colossal sizes, similar to houses or even stadiums. The enormity of these computers presented significant challenges, aggravated by a particular issue: each computer operated on a distinct operating system. Software was tailor-made for specific purposes, and programs designed for one system were incompatible with others. Proficiency in one system didn’t guarantee proficiency in another, creating complexities for both users and system administrators.
In 1969, a team of developers at Bell Labs set out to tackle these software-related challenges and compatibility issues. The solution they devised was named “UNIX.”
Types
There are way too many Linux Distributions but only a few to worry about. Here’s a visual representation of some in the form of a Periodic Table
But as a beginner the best options are either the “Debian” or the “Arch” family.
Some of the famous distros include Ubuntu which is based on Debian or Manjaro which is based on Arch
It doesn’t matter which one you choose as in the end they’re all Linux.
The Kernel
The Linux kernel is the main component of a Linux operating system (OS) and is the core interface between a computer’s hardware and its processes. It communicates between the 2, managing resources as efficiently as possible.
On top of this kernel run your utilities, shell, and programs.
The “Shell” is what we’ll be focusing on as it’s the most important part, it remains mostly same for all Linux Distributions.
The Shell
The shell is basically a program that takes your commands from the keyboard and sends them to the operating system to perform.
Depending on the distribution your shell prompt might change, but for the most part it should look like this
- $ is for a normal user
- ‘~’ refers to the home directory (/home/user)
If the last character of the prompt is a pound sign (“#”) rather than a dollar sign, the terminal session has superuser privileges. This means either we are logged in as the root user or we selected a terminal emulator that provides superuser (administrative) privileges.
Some Simple Commands
- date :: displays the current time and date
[param@Arch ~]$ date
Mon Dec 25 08:42:11 IST 2023- cal which, by default, displays a calendar of the current month
[param@Arch ~]$ cal
December 2023
Su Mo Tu We Th Fr Sa
1 2
3 4 5 6 7 8 9
10 11 12 13 14 15 16
17 18 19 20 21 22 23
24 25 26 27 28 29 30
31File System Tree
Linux organizes its files in what is called a hierarchical directory structure. This means they are organized in a tree-like pattern of directories (sometimes called folders in other systems), which may contain files and other directories. The first directory in the file system is called the root directory. The root directory contains files and subdirectories, which contain more files and subdirectories, and so on.
Navigation
- pwd :: Print name of current working directory
[param@Arch ~]$ pwd
/home/param- ls :: list the files and directories in the current working directory
[param@Arch ~]$ ls
Documents
Pictures
Videos
Desktop
Downloads
Music Public
Templates- cd :: change directory
[param@Arch ~]$ cd Desktop
[param@Arch Desktop]$ pwd
/home/param/Desktop
[param@Arch Desktop]$ ls
1.txt- The “.” notation refers to the working directory and the “..” notation refers to the working
directory’s parent directory
[param@Arch Desktop]$ cd ..
[param@Arch ~]$ pwd
/home/paramManipulating Files and Directories
- mkdir :: create directory
[param@Arch ~]$ mkdir test
[param@Arch ~]$ mkdir test2 test3 test4- cp :: copy files and dirs
[param@Arch ~]$ cp 1.txt test
[param@Arch ~]$ ls test
1.txtSimilarly mv will move the file instead of copying.
- rm :: delete files / dirs
[param@Arch test]$ ls
1.txt
[param@Arch test]$ rm 1.txt
[param@Arch test]$ lsMan Pages
Most executable programs intended for command line use provide a formal piece of documentation called a manual or man page. A special paging program called man is used to view them.
man programScripting
SheBang
#!/bin/bash at the top makes sure that bash is used as the interpreter.
e.g :: 1.sh
#!/bin/bash
echo "hello world"- Make the file executable
chmod +x 1.sh[param@Arch ~]$ chmod +x 1.sh
[param@Arch ~]$ ./1.sh
hello worldVariables
#!/bin/bash
name="param"
echo "Hello, $name!"User Input
- read
#!/bin/bash
echo "What's your name?"
read name
echo "Hello, $name!"Conditionals
Use if, else, and fi for conditional statements:
#!/bin/bash
read -p "Enter a number: " num
if [ $num -gt 6 ]; then
echo "The number is greater than 6."
else
echo "The number is 6 or less."
fiLoops
for and while loops for iteration
#!/bin/bash
# For loop
for i in {1..5}; do
echo "Iteration $i"
done
# While loop
count=1
while [ $count -le 5 ]; do
echo "Iteration $count"
((count++))
doneFunctions
#!/bin/bash
# Function definition
newFunc() {
echo "Hello, $1!"
}
# Function call
newFunc "Param"CLI Arguments
#!/bin/bash
echo "First arg: $1"
echo "Second arg: $2"Piping
Send the output of one command as the input to another command. It’s represented by the | symbol.
e.g Filtering the output with grep
ls | grep "txt"ps aux | grep "firefox"Redirection
Get ACM Manipal’s stories in your inbox
Join Medium for free to get updates from this writer.
>, >>, <
Change the input source or output destination of a command.
echo "Hello, World!" > test.txt>> is used to append
echo "Additional text" >> test.txt< input redirection :: shell is opening the input file and writing its contents to the standard input of another process.
cat < test.txtFurther Reading
Moving on to practice labs
We have come across a few sets of commands and a reference to a lot more for us to go through and learn. Moving on, theory and practice are inseparable companions, and true learning unfolds by getting hands-on experience.
Active engagement with the CLI will eventually lead us to scripting for the kernel, keys to the field of cybersecurity, or solving CTF’s. While many know about Capture the Flag (CTF) competitions, wargames are less often heard of. But wargames are actually like practice rounds for CTFs, helping people get ready for the real thing.
Wargames?
These are by no means competitive cyber-warfare exercises. Rather, it provides a platform for us to learn and practice security topics through creatively designed games that test your skills. Players can practice these whenever they like; they are neither competitive nor time-bound. There is no team versus team, which is an extra bonus. One person can play this alone.
It is advised to play a few wargames to have an understanding of the abilities or mindset required to gather flags, rather than directly attempting CTFs.
OverTheWire/bandit
One of the best ways to test our Linux skills is by playing the OverTheWire game “Bandit.”
These games are divided into levels, with each level storing the information for the next one to come. To proceed, we apply our skills and look for the key that exists hidden somewhere in the level, and so forth.
I became fascinated with Bandit’s concept and application the day I first came across it. Plus, it felt really awesome.
Speaking about my experience, I didn’t spend much time learning the commands. I prepared a list of the most commonly used Linux commands and started playing Bandit and figured out the use cases of the commands as I rose the levels. I documented my progress on GitHub for the people of the internet to go through if they were stuck at a level. Although the makers of the game strictly preach that there should not be any documentation made and it should be solved and enjoyed on our own, still people record their progress and share it online.
Starting with the “how to start”
NOTE: We should manually save each password because OverTheWire does not offer an option to save our progress.
Breakdown of the ssh login username and link
Establish an SSH connection with Bandit.
What is ssh?
Secured Shell or SSH is a secure protocol for sending commands to a computer over an unsecured network. It uses cryptography to authenticate and encrypt connections between devices. SSH is commonly used for remote server control, infrastructure management, and file transfer.
ssh user_name@hostname(IP/Domain Name)
What is port?
Port number is a way to identify a process to which a process or the internet needs to be forwarded to. The port in SSH is used to specify the port number that the SSH server is listening on. The default port number for SSH is 22, but it can be changed.
The port is used for Secure Shell (SSH) communication and allows remote administration access to the VM. In general, traffic is encrypted using password authentication.
ssh user_name@hostname(IP/Domain name) -p [port number]
setting up the connection
Begin executing Linux commands.
Now that we are on Level 0, we use ls and cat to list all of the files and directories in order to search for the hidden key string.
We exit the current level and connect to Level 1 by copying and pasting the password.
The screen displays a lengthy number of details, but the final sentence is what cheers us up. You can notice that we are currently within Bandit’s Level 1.
We can apply the hints found on each level of Bandit as a guide. Furthermore, reading man pages can be very helpful.
While some stages are simple to complete, others will require us to use our creativity to solve problems. Do not forget to take notes. They are useful as cheat sheets for tasks with a similar appearance.
Documenting on Github
In my Bandit journey, I jotted down every challenge, plan, and Linux command I used. Keeping things organized helped me track my progress and created a handy guide for others. Whether I was dealing with simple stuff like using ‘cat’ and ‘grep’ for passwords or tackling trickier tasks with ‘find’ and ‘ssh’ in complicated folders, my notes became a helpful roadmap. Whenever I hit a snag, going back to my documentation sorted me out. Turns out, taking good notes not only helped me solve puzzles but also showed me how nifty Linux commands can be in this ever-exciting world of wargaming.
How to structure your Github for Bandit?
There are various games on OverTheWire and there’s a strong possibility that users might try out other games as well. So it becomes important to organize and set up different repositories. In setting up the GitHub repository for the Bandit wargame on OverTheWire, begin by creating a new repository with a clear and concise name, such as “Bandit-Wargame-Documentation.”
- Organize the README.md
- Explain in detail or briefly about your repository’s objective. I organized in a way that showed me the most used commands. This gave me an instant jog of memory whenever I opened the repository.
2. Structuring
- Bandit has 34 levels and some of the levels refer to and relate to the previous ones. What worked for me was clubbing five levels in a file but ultimately it’s on the user who has their own style of structuring.
3. Process & Strategy Breakdown
- Provide a section dedicated to the overall strategy employed. Include your thoughts that led to the solution. That would help anyone viewing it to build the mindset of problem-solving.
- Include the code snippets as well. That would help in clearing any doubts about syntax issues.
Below is an attached snapshot of my notes on GitHub. I assume that this will provide a step up for users to think about their organizational skills.
By maintaining this structured approach, the user ensures a well-organized and easily navigable repository that serves as a valuable resource for both personal reference and potential collaboration with others.
Keeping up
During our journey, one thing to keep in mind is that some levels are challenging and we need to be open to learning and exposing ourselves to new tools like the Bash Academy. The commands will come to us gradually and eventually but the technique lies in processing the information. There are a lot of solutions documented online that can be used as a reference if one gets stuck somewhere. The point here is that there are hundreds of solutions and the only prerequisite is that we have the knowledge to understand the outcome. This mindset will take us forward rather than the commands.
Most beginner games do not require prior coding experience, but they will certainly become useful as you advance. Each shell game has its own SSH port, and these Wargames are a great way to familiarize yourself with the command-line and general concepts of network security.
A small note on CTFs
Any given game on OverTheWire is based on a distinct concept, such as binary exploitation or web exploitation. After playing a few games, we’ll be prepared to tackle CTFs!
Capture the Flag games, or CTFs for short, require us to locate a key string that is kept in a purposefully vulnerable program, website, or piece of hardware. The increasing demand for cybersecurity has led to an enormous surge in the popularity of CTFs in the educational field. Typically, teams fight to take flags (attack/defense style) or uncover weaknesses in a hosted server (jeopardy type).
Here is a list of the most famous and rated list of CTF competitions around the world. Check it out!
Amongst these, one lauded event is DEF CON which is held in Las Vegas, USA every year. It is attended by every tough guy there is in this field.
What does this field hold for you?
For someone aspiring to be the unseen hero responsible for groundbreaking triumphs in cyber-warfare, fascinated by the technicalities of the architecture and security of virtual worlds, this line of interest provides an ideal opportunity to fulfill our ambitions. All it requires is eagerness and patience to keep cracking!
After acquiring expertise in various domains by solving many CTFs in competitions, practitioners often attract the attention of tech giants and become potential candidates for employment. Employers are always hiring for good security analysts and someone hardworking can easily pop up on their radar. Companies like Google, Facebook, and others frequently participate in or sponsor CTF events, using them as a talent pool for recruiting top cybersecurity professionals.
Rerouting to the most essential point there is, this domain demands expertise across diverse topics. Therefore, making teamwork crucial. Keep practicing and keep learning, together.
Authors
Param Arora & Gaurav Gupta
Led by
Kashin Mittal







