Description of image

Learning to hack effectively requires an understanding of the underlying technologies and operating systems you’re looking for holes in. Many of us who get started in Information Security or tech, in general, may have an idea of the tools and commands used, but maybe a little weaker in an understanding of the OS (Operating System) they’re using, and that’s fine!

In the first part of this group of blogs, I will touch on the fundamentals of the Linux operating system. This may come as a surprise to you, but the vast majority of the internet and its cloud infrastructure run on Linux! As an open-source operating system with many different useful iterations that are readily available for download and deployment, Linux is the go-to for many developers putting together complex computing systems that require a granular level of control.

I should also mention that there are quite a few “distributions” of Linux. Distributions are different Operating systems built on the Linux kernel. This Fundamentals post focuses on Debian-based distributions of Linux. If you don’t know what that means right now, no worries! This post serves to give new users and aspiring hackers a way to learn and get their feet wet.

Whether you’re an aspiring hacker, developer, or just a hobbyist, this is a good place to start to get a little bit better of an understanding of what you’re working with when it comes to Linux. Let’s go!

The Linux File System:

The Linux operating system uses the Filesystem Hierarchy Standard (Also known as FHS). This is a tree-like Hierarchy, meaning it is organized with top-level directories that, much like a tree, branch out as files or directories are added below the top-level directories.

  • / — This is what is known as the root of the file system. It contains all of the files necessary to boot the operating system. After boot, all of the other directories are mounted in root as sub-directories
  • /bin — All of your essential command binaries are stored here. We will learn more about commands later.
  • /boot — The static bootloader, Kernel executable, and other files required to boot the operating system
  • /dev — This is where Device files are located. These files grant access to all of the hardware devices that are attached to the system
  • /etc — Local system configuration files are stored here as well as configuration files for installed applications, though that is not always the case
  • /home — All users have subdirectories here for storing files etc.
  • /lib — Shared library files required for the operating system to boot
  • /media — If you plug in a USB drive or external drive they are mounted in this directory
  • /mnt — A temporary mount point for file systems
  • /opt — Third-party tools are generally saved here as well as optional files
  • /root — This is the /home directory for the root user. The root user is the most powerful user on the operating system
  • /sbin — Executables used for system administration are stored here. In other words, this is where the binary system files are stored
  • /tmp — A directory for programs or the operating system to store temporary files. On boot, this directory is generally cleaned up and could be cleaned at any time
  • /usr — Libraries, Executables, and man files (manual files, files that store manuals for binaries), etc. are stored here
  • /var — Variable data like email in-boxes, web app files, log files and more are stored here

You probably already see a trend here. Many of these top-level directories have a naming convention that generally includes a shortened version of its function. That isn’t always the case, but it’s important to remember that in FHS everything is a file.

CLI vs. GUI

When you use your computer every day, or even your phone as you click and tap your way through whatever needs doing, you are working with a Graphical User Interface (GUI). Unless you’re further along than I thought, you’re using a GUI to read this post right now!

The primary reason the GUI was created was to have a more natural way for humans to interact with and use computers. That’s why we’re presented with icons, menus, windows, and buttons. However, there is another way to interact with an operating system that’s much more efficient and powerful, the Command Line Interface (CLI).

You may hear terms like “Terminal” or “Shell” when dealing with Linux Operating Systems. These terms relate to the CLI but might refer to different tools and concepts depending on your work. At its core, the CLI is a text-based way of interacting with a computer. It provides much more granular controls and tools plus its efficiency comes from the fact that the CLI uses fewer resources to perform tasks. Instead of having to bring up a graphical window when you open a folder, some quick commands can show you that folder’s content in a text-based format.

In the next section, we’ll discover a handful of useful commands that will make you feel like the wizard you want to be when it comes to Linux!

Basic Linux Commands

Now that we’ve covered some of the basics of the Linux operating system, let’s cover a few basic commands you can use at the terminal (CLI) to manipulate files, traverse directories, and more.

  • ls — This is the “List” command. It lists the files that are in the directory you are currently in.
  • pwd — If you ever get lost and want to know what directory you’re in you can use the “Print Working Directory” command to print out the directory you are currently in
  • cp — Let’s say you want to copy a downloaded file to your home directory. You would use the ‘Copy’ command to make a copy of the file and send it to your directory. The syntax* for this command is cp <source location> <destination location>
  • mv — Maybe you want to “Move” that file instead of copy, which moves the file and does not leave a copy in the source destination. The syntax here is similar to “Copy”. mv <source> <destination>
  • rm — You have used that file and you want to get rid of it. Usually, it’s drag and drop to the trash in a GUI, but in a terminal, you use “Remove”
  • cd — Now that you’re done you want to navigate to the Downloads folder to see what you’ve downloaded recently. To do this you use the “Change Directory” command. The syntax is as follows cd <destination directory>
  • sudo — This command is called “Super User Do”. Now, you should know that this is a potent and dangerous command. As a regular user if you want to make significant changes to the files within Linux some of them may not allow you to because of permissions that dictate who can access what directory or file and who cannot. What sudo does is it elevates a regular user’s terminal session to a root session, meaning you have absolute full control over everything on the operating system. One wrong command and you could do irreparable damage to your operating system. “With great power comes great responsibility” — some guy with a superhero nephew I think.

Wrapping up

Phew! Seems like a lot to take in right? Well, you won’t get bored anytime soon learning about Linux. To summarize what we covered:

  • The Filesystem Hierarchy Standard (FHS) that organizes directories in a tree-like manner
  • Top-level Directories and their Purpose
  • The difference between the GUI and the CLI
  • Some basic terminal (CLI) commands

As I mentioned, you definitely will not be bored learning Linux. Think of it as a vast forest and all the trees are different concepts, knowledge, and core components of the Linux Operating System. Don’t be intimidated! Linux has been around since 1991 and there is a wealth of information and knowledge out there that will take you from pauper to wizard in no time!

In the next installment, we will cover some more of the basics to round off your knowledge of Linux!

Thanks for reading my post! Dropping a follow would mean everything to me, and if you’re feeling generous I could use a cup of coffee! That’s what keeps me going to provide content you can learn from. Till next time fellow hackers!