Updated: Jul 23
Many aspiring hackers are unfamiliar with Linux having learned computer basics in a Windows or Mac environment. Sometimes this unfamiliarity is the single most important obstacle to mastering the essential skills to become a professional white hat hacker. For many good reasons, Linux is THE only hacking platform. That having been said, to become a hacker you will need to learn the basics of Linux. This series of articles is meant to provide the aspiring hacker the basics of Linux that every hacker needs to proceed to a professional, white hat hacker.
I will try to develop your skills in Linux slowly and in a logical manner, so that you can do the many hacks I will show you here on Hackers-Arise.
In this tutorial, I will step you through some of the basics to getting started with Kali Linux. Although my examples will all be with Kali 1.1, the principles apply to nearly every Linux distribution.
Open a Terminal
When working with Linux, usually the first step is to open a terminal. In Kali Linux, we can find the icon for the terminal at the top of the page and double click or we can simply type control+alt+t.
When you either click on the terminal or type Cntl+Alt+T, it will open a terminal like below.
This terminal defaults to open a shell. A shell is simply a command line environment that enables us to run commands on the underlying operating systems and write scripts (more on scripts later). Their are many different shell environments in Linux, but the most popular is the BASH shell or Bourne Again Shell. This is the default shell in Kali and many other Linux distributions.
Unlike Windows file system, Linux systems are not limited by the physical drive. The Linux file system has at the top of its file structure the root or /. This does not represent the physical drive, but simply to top of the logical file structure.
Notice in this diagram of the Linux file system above that at the very top of the file system is the / or root of the file system. Please don't confuse this with the "root" user, they are two different things. Here, root simply is the very base of the file structure. As a beginner, probably the most important sub-directories under / are;
1. /root this represents the home directory of the all powerful root user
2. /etc these are generally where the configuration files reside in Linux
3. /home is the home directory of a user
4. /mnt is where other file systems are attached or mounted to the filesystem
5. /bin is the where the binaries or executables in Windows language reside
6. /lib is the directory where the libraries reside. These are programs that are shared, similar to Windows DLL's.
We will come back later and spend more time with these key directories at a later tutorial, but for now, it is enough that you have a general concept of the Linux file system.
Sometimes when working in Linux, we want to know what directory we are in. The command, present working directory or pwd, returns where you are in the directory structure. This can be critical when moving through the directory structure. Let's type "pwd" and see where we are.
As you can see, Linux returned /root telling us we are in the root user's directory. If we had been in another directory, it would have returned that directory name as we will see below.
Linux allows us to login as any legitimate user. As the system administrator, you will likely be logged in as "root", but this is not recommended when doing routine tasks. This is a security precaution as anyone who hacked you when you are logged in as root, would immediately have root privileges and own the system. A better practice is to log in as a regular user.
Sometimes who may have forgotten who you logged in as. This can be remedied by typing "whoami".
If I had been logged in as another user, such as OTW, the system would have returned that name.
Navigating around the file system in the terminal is an essential skill in Linux. Similar to Windows command line systems, we can change directories with the cd or change directory command. We can change directories by typing cd followed by the directory name such as;
Now, we are in the /etc directory as the prompt indicates and we can confirm this by typing pwd.
When we want to move up one level in the file structure, we can use the cd command followed by .. such as;
kali > cd ..
If we want to move up two levels we can type cd followed by the double dot and a forward slash (../) followed by a second double dot, such as ;
kali > cd ../..
If we want to move up to the root level in the file structure we can simply type
kali > cd /
where / represents the top or the root of the file structure.
When we want to see the contents of a directory, we can use the ls command or list command.
kali > ls
As you can see in the screenshot above, the files AND directories are listed when using the ls command. If we need more information about the files and directories such as permissions, owner, size and when it was modified, we can add the -l switch after the ls such as;
kali > ls -l
I typically always add the -l switch when doing a listing in Linux, but to each their own.
Finally, some files are hidden in Linux and won't be revealed by a simple ls or ls -l command. If we add a lower case a (-a), the hidden files will be shown.
kali > ls -la
Nearly every command has a help file. These help files provide a cursory help screen to assist your understanding of the command, utility or application. For instance, if I needed help using the best wireless cracking tool, aircrack-ng, I could simply type the command followed by the --help. Please note the double dash (--). The convention in Linux (although not always adhered to) is to use the double dash (--) before word options such as help and single (-) before single letter options. Look at the help screen for aircrack-ng for examples.
kali > aircrack-ng --help
In some cases, you can use either the -h or ? to get help file. For instance, if I needed help using the best port scanning tool, nmap, i would type;
kali > nmap -h
Note that I used the single dash before the h as in nmap -h.
In addition to the help switch available for most commands and applications, you can find more information about a particular application or command by going to its manual page. Nearly every Linux distribution maintains a manual for all utilities, commands and applications. You can view the manual by simply typing man before the command, utility or application such as;
kali > man aircrack-ng
This opens the manual for aircarck-ng giving us more complete information than the --help screen. With man, Linux opens the manual with the more commands, a file display command that we will look at a bit later. We can scroll through this manual file by using the Enter key or page down using the PGDN or PGUP key. To exit, we simply type "q".
That is your first lesson in Linux Basics my aspiring hackers. I hope I made everything clear, but if not, please feel free to ask question here in the forum or email me at firstname.lastname@example.org.
For Lesson 2 click here!
For more on using Linux for hacking, check out my book "Linux Basics for Hackers" now available here on Amazon.