Linux Basics For Hackers: Getting Started with Networking, Scripting, and Security in Kali - Part 1 — The Basics
We Are looking forward into the Linux and learn about linux concepts.
At first we just need to setup Kali Linux or other Debian based operating systems in virtualbox. You can refer some youtube videos or websites to setup kali Linux in Virtualbox . I Just took some notes from the book.
Introductory Terms and Concepts
- Binaries:- This term refers to files that can be executed, similar to executables in Windows.
- Case sensitivity:- Unlike Windows, the Linux filesystem is case sensitive. This means that Desktop is different from desktop, which is different from Desktop. Each of these would represent a different file or directory name.
- Directory:- This is the same as a folder in Windows. A directory provides a way of organizing files, usually in a hierarchical manner.
- Home:- Each user has their own /home directory, and this is generally where files you create will be saved by default.
- Kali:- Kali Linux is a distribution of Linux specifically designed for penetration testing. It has hundreds of tools preinstalled, saving you the hours it would take to download and install them yourself.
- root:- Like nearly every operating system, Linux has an administrator or superuser account, designed for use by a trusted person who can do nearly anything on the system. This would include such things as reconfiguring the system, adding users, and changing passwords.
- Script:- This is a series of commands run in an interpretive environment that converts each line to source code. Many hacking tools are simply scripts. Scripts can be run with the bash interpreter or any of the other scripting language interpreters, such as Python, Perl, or Ruby.
- Shell:- This is an environment and interpreter for running commands in Linux. The most widely used shell is bash, which stands for Bourne again shell, but other popular shells include the C shell and Z shell.
- Terminal:- This is a command line interface (CLI).
The Linux File System
The Linux filesystem structure is somewhat different from that of Windows. Linux doesn’t have a physical drive (such as the C: drive) at the base of the filesystem but uses a logical filesystem instead. At the very top of the filesystem structure is /, which is often referred to as the root of the filesystem, as if it were an upside-down tree. Keep in mind that this is different from the root user. These terms may seem confusing at first, but they will become easier to differentiate once you get used to Linux.
The root (/) of the filesystem is at the top of the tree, and the following are the most important subdirectories to know:
- /root :The home directory of the all-powerful root user .
- /etc :Generally contains the Linux configuration files — files that control when and how programs start up
- /home :The user’s home directory
- /mnt :Where other filesystems are attached or mounted to the filesystem
- /media :Where CDs and USB devices are usually attached or mounted to the filesystem
- /bin :Where application binaries (the equivalent of executables in Microsoft Windows or applications in macOS) reside
- /lib :Where you’ll find libraries (shared programs that are similar to Windows DLLs)
Basic Commands in Linux
- Finding Yourself with pwd:-
Unlike when you’re working in a graphical user interface (GUI) environment like Windows or macOS, the command line in Linux does not always make it apparent which directory you’re presently in. To navigate to a new directory, you usually need to know where you are currently. The present working directory (or print working directory) command, pwd, returns your location within the directory structure.
- Checking Your Login with whoami:-
If you’ve forgotten whether you’re logged in as root or another user, you can use the whoami command to see which user you’re logged in as:
- Navigating the File System:-
- cd — Changing Directories
- You would use .. to move up one level.
- You would use ../.. to move up two levels.
- You would use ../../.. to move up three levels, and so on
2. ls — Listing the Contents of a Directory
This command lists both the files and directories contained in the directory.
To get more information about the files and directories, such as their permissions, owner, size, and when they were last modified, you can add the -l switch after ls (the l stands for long). This is often referred to as long listing. Let’s try this.
3. Getting Help
Nearly every command, application, or utility has a dedicated help file in Linux that provides guidance for its use. For instance, if I needed help using the best wireless cracking tool, aircrack-ng, I could simply type the aircrack-ng command followed by the — help command:
Note the double dash here. The convention in Linux is to use a double dash ( — ) before word options, such as help, and a single dash (-) before single-letter options, such as –h.
3. Referencing Manual Pages with man
Most commands and applications have a manual (man) page with more information, such as a description and synopsis of the command or application.
4. Searching using locate
This command will go through your entire filesystem and locate every occurrence of that word.
5. Finding Binaries with whereis
This command returns not only the location of the binary but also its source and man page if they are available.
6. Finding Binaries in the PATH Variable with which
The which command is even more specific: it only returns the location of the binaries in the PATH variable in Linux. PATH holds the directories in which the operating system looks for the commands you execute at the command line. when I enter aircrack-ng on the command line, the operating system looks to the PATH variable to see in which directories it should look for aircrack-ng:
7. Performing More Powerful Searches with find
The find command is the most powerful and flexible of the searching utilities. It is capable of beginning your search in any designated directory and looking for a number of different parameters, including, of course, the filename but also the date of creation or modification, the owner, the group, permissions, and the size. Basic Syntax is shown below:-
So, if I wanted to search for a file with the name apache2 (an open source web server) starting in the root directory, I would enter the following:
First I state the directory in which to start the search, in this case / . Then I specify which type of file to search for, in this case f for an ordinary file . Last, I give the name of the file I’m searching for, in this case apache2. result is shown below:
8. Filtering with grep
when using the command line, you’ll want to search for a particular keyword. For this, you can use the grep command as a filter to search for keywords.
9. Creating a Directory
The command for creating a directory in Linux is mkdir, a contraction of make directory.
To navigate to this newly created directory, simply enter this:
10. Removing a File/Directory
To remove a file, you can simply use the rm command.
The command for removing a directory is similar to the rm command for removing files but with dir (for directory).
It’s important to note that rmdir will not remove a directory that is not empty, but will give you a warning message that the “directory is not empty,” as you can see in this example. You must first remove all the contents of the directory before removing it. This is to stop you from accidentally deleting objects you didn’t intend to delete. If you do want to remove a directory and its content all in one go, you can use the -r switch after rm, like so:
“Linux Basics for Hackers” successfully achieves its goal of providing a security-focused introduction to Linux. It serves as an excellent starting point for anyone interested in cybersecurity, particularly those who want to understand the underlying Linux system they’ll be working with.
This isn’t just another Linux manual — it’s a thoughtfully crafted roadmap for aspiring security professionals. While it may not cover everything you need to know about hacking, it certainly provides the solid foundation required to pursue more advanced security studies.
Lets look forward for more about Linux environment…