DEV Community

loading...
Cover image for Linux Basics for Beginners
For Community

Linux Basics for Beginners

kiransethu46 profile image Kiran Sethumadhavan Updated on ・5 min read

*Do you want to become ethical hacker and want to know how hackers hack in Real World. Join the telegram group and be a
part of us *

Telegram = https://t.me/infosecbugbounty

More often than not, certain operating systems tend to get tied to certain tasks. When it comes to penetration testing, Linux based operating systems are always mapped to it. This article will help you get comfortable with the fundamentals of Linux. So let’s start.

Why use Linux for pentesting ?

Linux offers a far higher level of control of the operating system, not to mention that it is open source. This also makes Linux transparent and easier to understand. Before we try to “hack” anything, it is a must to know how it works, this is why transparency in Linux is a huge plus.

Because Linux is very popular amongst the pen-testing community, most of the used penetration testing tools and frameworks are also then built for Linux.

Maintenance is also comparatively easy as the software can be easily installed up from its repository. It is also very stable when compared to traditional operating systems like Windows.

Basic Linux Commands

Just like how we use Windows on a daily basis, creating folders, moving files, copying things, we’re going to learn these everyday operations for Linux.

We’ll be spending most of our time in the terminal, which is the command-line interface of our operating system. This is where we type out commands to perform the operations we want.

The “pwd” Command
Before we begin, we should know which directory we are working in, and where are the files we create going to be stored. The pwd command is one way to identify the directory we’re in.

So as we did it in our case, we found that we’re in the /root directory.

The*“whoami”* Command
Using the whoami command we see which user we’re logged in as. Here, we’re logged in as root (which translates to an administrator in the windows terms)

cd: Changing directories
To change directories via the terminal, we use the cd command. Let’s change our current directory to Desktop.

cd Desktop/
1
cd Desktop/

ls: Listing the Contents
To see the contents of a directory we use the “ls” command, (very similar to the dir command in windows)

The “Help” Command
Nearly every command, application and or utility in Linux has a dedicated help file which guides its usage. If you want to learn more regarding a specific command or if you’re stuck, help (-h, –help) will be your best friend.

Let’s find out more about volatility framework.

volatility --help
1
volatility --help

man: The Manual Pages
In addition to the help file, most commands and applications also have a manual page, which can be accessed via typing man before the command.

As seen below, it provides a description and all the tags that can be used with the ls command.

man ls
1
man ls

locate: Searching keywords
When searching for a specific keyword, one of the easiest ways to do so is using locate. Type locate and then the keyword on the terminal and it will search the entire file system for the occurrence of it.

Though a few drawbacks of using locate as it provides too much information and the database it uses is updated once a day, so you can’t find files created minutes or hours ago.

Let’s search for the keyword: CTF with

locate CTF | more
1
locate CTF | more

whereis: Finding binaries
Let’s begin this section with what are binaries?

Files that can be executed, similar to .exe’s in Windows are referred to as binaries. These files generally reside in the /usr/bin or /user/sbin directories.

Utilities like ls, cd, cat, ps (we’ll cover some of these later in the article) are stored in these directories too.

When looking for a binary file, we can use the whereis command. It returns the path of the binary as well it’s man page. Finding the binary file: git.

whereis git
1
whereis git

which: Finding binaries
The which command is more specific and only return the location of the binary in the PATH variable in Linux. Finding the binary file: git.

which git
1
which git

Filtering with grep
Very often when using the command line, you’ll want to search for a particular keyword, this is where grep comes in.

Let’s search for the word: echo, in the simple_bash.sh file by typing

grep -I "echo" simple_bash.sh
1
grep -I "echo" simple_bash.sh

Thought the most common use case of grep it to pipe the output into it with the keywords to filter the output.

Here we use grep just to get the IP address of our machine, instead of all the other information that comes when running the ifconfig command. (We’ll touch on the ifconfig common in the later section)

ifconfig | grep inet
1
ifconfig | grep inet

Searching with the “find” command
The find command is the most powerful and flexible of the searching utilities. It is capable of different parameters, including, the filename (obviously), date of creation and or modification, the owner, the group, permission and the size.

Here we use -type and -name tag which tells find the type of file we are looking for as well as its name. The backslash (/) indicates the root directory, which is where we want to search the file in.

find / -type f -name hacking_articles
1
find / -type f -name hacking_articles

If your result looks like this:

It is because the find command is also searching through directories your account doesn’t have the permission to access to. Hence, for a cleaner result, we use 2>&1 which sends all the permission denied errors to /dev/null (into nothing) and then using grep filters them out of the output)

find / -type f -name hacking_articles 2>&1 | grep -v "Permission Denied"
1
find / -type f -name hacking_articles 2>&1 | grep -v "Permission Denied"

Hey Guys we just dropped our 1st video on YouTube.Please hit that subscribe button and make sure you smash that like button .Hotstar+Disney is a very famous streaming and entertainment service in India with more than 27 millon paid viewers and 300 millon monthly active users . We would love to hear your response .

https://www.youtube.com/watch?v=4pjpHUN28kk

Alt Text

Be a part of us 🚀 🚀
Telegram https://t.me/forthecommunity
Discord https://discord.com/invite/QsAqC4yKkm
Facebook https://www.facebook.com/forcommunity.tech
Youtube https://www.youtube.com/channel/UCP33irJmpa60rIuztDP2itQ

Discussion (7)

pic
Editor guide
Collapse
muzammilaalpha profile image
muzammilaalpha

Good post!

Collapse
kiransethu46 profile image
Collapse
arvindsridharan profile image
arvindsridharan

Very good explanation.

Collapse
kiransethu46 profile image
Collapse
tokendev18 profile image
Aaron

Great post man! Very well explained!

Collapse
kiransethu46 profile image
Kiran Sethumadhavan Author

Thank you bro , it would be great if you subscribe our YouTube channel and be a part of us by joining the Telegram group

Collapse
justinnn07 profile image
Justin Varghese

bdiya vro