Hack Like a Pro: Linux Basics for the Aspiring Hacker, Part 1 (Getting Started)

Linux Basics for the Aspiring Hacker, Part 1 (Getting Started)

Welcome back, my hacker trainees!

A number of you have written me regarding which operating system is best for hacking. I'll start by saying that nearly every professional and expert hacker uses Linux or Unix. Although some hacks can be done with Windows and Mac OS, nearly all of the hacking tools are developed specifically for Linux.

There are some exceptions, though, including software like Cain and Abel, Havij, Zenmap, and Metasploit that are developed or ported for Windows.

When these Linux apps are developed in Linux and then ported over to Windows, they often lose some of their capabilities. In addition, there are capabilities built into Linux that simply are not available in Windows. That is why hacker tools are in most cases ONLY developed for Linux.

To summarize, to be a real expert hacker, you should master a few Linux skills and work from a Linux distribution like BackTrack or Kali.

Image via wonderhowto.com

For those of you who've never used Linux, I dedicate this series on the basics of Linux with an emphasis on the skills you need for hacking. So, let's open up BackTrack or your other Linux distribution and let me show you a few things.

Step 1: Boot Up Linux

Once you've booted up BackTrack, logged in as "root" and then type:

  • bt > startx

You should have a screen that looks similar to this.

Step 2: Open a Terminal

To become proficient in Linux, you MUST master the terminal. Many things can be done now in the various Linux distributions by simply pointing and clicking, similar to Windows or Mac OS, but the expert hacker must know how to use the terminal to run most of the hacking tools.

So, let's open a terminal by clicking on the terminal icon on the bottom bar. That should give us a screen that looks similar to this.

If you've ever used the command prompt in Windows, the Linux terminal is similar, but far more powerful. Unlike the Windows command prompt, you can do EVERYTHING in Linux from the terminal and control it more precisely than in Windows.

It's important to keep in mind that unlike Windows, Linux is case-sensitive. This means that "Desktop" is different from "desktop" which is different from "DeskTop". Those who are new to Linux often find this challenging, so try to keep this in mind.

Step 3: Examine the Directory Structure

Let's start with some basic Linux. Many beginners get tripped up by the structure of the file system in Linux. Unlike Windows, Linux's file system is not linked to a physical drive like in Windows, so we don't have a c:\ at the beginning of our Linux file system, but rather a /.

The forward slash (/) represents the "root" of the file system or the very top of the file system. All other directories (folders) are beneath this directory just like folders and sub-folders are beneath the c:\ drive.

To visualize the file system, let's take a look at this diagram below.

It's important to have a basic understanding of this file structure because often we need to navigate through it from the terminal without the use of a graphical tool like Windows Explorer.

A couple key things to note in this graphical representation:

  • The /bin directory is where binaries are stored. These are the programs that make Linux run.
  • /etc is generally where the configuration files are stored. In Linux, nearly everything is configured with a text file that is stored under /etc.
  • /dev directory holds device files, similar to Windows device drivers.
  • /var is generally where log files, among other files, are stored.

Step 4: Using Pwd

When we open a terminal in BackTrack, the default directory we're in is our "home" directory. As you can see from the graphic above, it's to the right of the "root" directory or one level "below" root. We can confirm what directory we are in by typing:

  • bt > pwd

pwd stands for "present working directory" and as you can see, it returns "/root" meaning we're in the root users directory (don't confuse this with the top of the directory tree "root." This is the root users directory).

pwd is a handy command to remember as we can use it any time to tell us where we are in the directory tree.

Step 5: Using Cd Command

We can change the directory we're working in by using the cd (change directory) command. In this case, let's navigate "up" to the top of the directory structure by typing:

  • bt > cd ..

The cd command followed by the double dots (..) says, "move me up one level in the directory tree." Notice that our command prompt has changed and when we type pwd we see that Linux responds by telling us we are in the "/" or the top of the directory tree (or the root directory).

  • bt > pwd

Step 6: Using the Whoami Command

In our last lesson of this tutorial, we'll use the whoami command. This command will return the name of the user we're logged in as. Since we're the root user, we can log in to any user account and that user's name would be displayed here.

  • bt > whoami

That's it for now. In the next several tutorials, I will continue to give you the basics of Linux that you'll need to be a pro hacker, so keep coming back!

Just updated your iPhone to iOS 18? You'll find a ton of hot new features for some of your most-used Apple apps. Dive in and see for yourself:

Cover image by BotheredByBees/Flickr

132 Comments

one thing I'm wondering, why arent you just modifying your $PS1 variable in ~/.bashrc? then you don't have to constantly pwd in order to know where you are.

seriously, does anyone know how to linux?

it's not supposed to be a quote of NaugtyCriss

Excellent point, Harlan, but changing an environment variable is probably not something you want to ask students to do in the first Linux tutorial.

Great article, Keep up the good work!

Th3skYf0x

Thank you... will be waiting for the next one. Do you think it unwise to start out a program like this or should i start out on a more basic linux?

Brad:

If you want to learn to hack, start with BackTrack. There really is very little difference between BackTrack and other Linux distro's other than the hacking software installed on BackTrack.

OTW

Hello, I asked you a question about learning linux basics, is this the place you wanted me to go?
Thank you very much, hope to learn a lot here at Null Bytes!
Jared

Jared:

You are in the right place. Good luck and stay in touch along your learning adventure.

OTW

Hello again OTW,
I have three questions:
Is there any drawback in running Backtrack in a VM such as Virtual Box?
Should I install Backtrack onto the computer instead of just running it off a live CD, like shown above in the post?
and...

A rather trivial question :) ... what is the command to shut down Backtrack, besides holding down the power button on your computer. :)

Thank you for your time helping a fledgling.
Jared

any one can tell me that how i can install linux on virtual box.i have install the linux graphically on my virtual box but the problem is that it is not opening or not boot???????

I probably would have tossed in "ls" for examining directory structure as well. If anyone reads this, give it a try. Also try typing in "man COMMAND" whatever COMMAND might be at the time. You will learn things.

Bird and Bear:

I will be offering other commands in the following tutorials. Those will definitely appear in part 2.

OTW

The penguin picture - surely it isn't a photo of the large penguin in Penguin, Tasmania? I hope so. It looks like him!

a question sir OTW, i already have ubuntu 12 installed side by side windows 8...checking out this backtrack thing..it seems it will be useless having both ubuntu and backtrack..i was thinking of trial booting..but now am just thinking of removing ubuntu and substituting it with backtrack..what do you say Master OTW? thanks...one other question...is using backtrack in virtual machines as effective as running it from the hard drive? was using ubuntu b4 in virtual box...mmmm...not that much of a pleasure...but now am downloading vmware to try it..since you praise it soo much...thanks..sorry for asking soo many questions at a time

Dear King:

Welcome to Null Byte!

If you want to learn to hack, I would go with BackTrack. BackTrack is built on Ubuntu, so no need for both. Also, any operating system runs better directly off the bare metal than in a virtual machine, but if you have to run in a virtual machine, VMWare is best.

OTW

OH well..you're back OTW, for some three days you were no where to be found! I was the guest guy by name Mike, soo much precious info here, i had to register myself..thanks for the response, i already did trial install, i now have ubuntu, windows 8 and backtrack..but i think am gonna delete the ubuntu partition soon...any way keep up the very good work you are doing!!! thanks

Hi...I want to start by saying your instructions here are awesome! I love them. I am an IBM mainframe programmer and some .net programming. As such I have hacking in my blood, but never really chased it much til now, finding your tutorials. My problem is: my dvd burners are sick and not sure why yet. I have BackTrack 5r3 iso on a thumb drive. can I develop a dual-boot system using this, or do i need to get my dvd burners fixed? I really can't wait to start using your tutorials here. keep up the great work! Thanks!

Dave:

Thanks for those kudos and welcome to Null Byte!

You can create a dual boot system with your thumb drive, so let's get hacking!

Also, you could create a VM with Virtual Box or VMWare. That might be simplest.

OTW

Ok Master, whats the best way? I guess I could make the thumbdrive bootable. Whats the easiest way to do that without including Windows OS on it? I don't need a rescue thumb-drive...lol, just one I can boot from and get my iso to take over, right?

Dave:

I think creating a VM would be the best way. That way you can attack your host or other VM's without getting into trouble with the law.

OTW

But OTW, i have read often from you that it is best if running directly off hard drive. i am at home on an HP quad core with windows 8. I am not in the mainframe arena any more. I am having a neighbor burn the iso to a DVD, so hopefully i can boot from that soon. It looks like it could be a week or more if i try to set up vmware and get it running. I'm afraid of way too many new areas i would be trying to adsorb all at once...i have no knowledge of Linux/Unix yet. I want to start hacking the globe!

Dave:

When hacking in the real world, dual boot is best. When hacking for learning, VM is best as you can hack your other VM's without breaking the law.

OTW

You said, when hacking in the real world a dual boot is best. Can you elaborate on that a little bit? I have an older computer that is still powerful enough to run a nice Linux distro, but I really don't want to take the time to nit pick through the drive if I can just wipe it and install Linux only. I don't think I'd want to do that if there were significant advantages to dual booting.

Wit:

I'm sorry if I wasn't clear about this matter. I guess I should have said that a dual boot system is superior to a VM. There is no advantage of a dual boot over using the whole hard drive for Linux. The options that people were discussing were whether to do dual boot or VM and in that context, dual boot is superior.

OTW

OTW:

I really hate asking all of these silly questions, but which vmware product(s) should I download...there are a ton...do you have lessons which covers building partitions and installing BT/Linux into it?

Wh00por:

No problem asking questions! That what we are here for.

I really like VMWare workstation, but is not free. Virtual Box from Oracle is good and getting better.

The install in both cases is pretty straight forward and it makes the partition for you.

OTW

P.S. Welcome to Null Byte!

just found this website and can say it is an instant favorite
good info in this article and great job

Lars:

Welcome to Null Byte!

BackTrack is a Linux distribution with hundreds of hacker tools. It doesn't need its own hard drive. You can run it in a virtual machine or a dual boot system.

OTW

Fascinating articles here. I am learning Linux now and was wondering which is better for this - Backtrack or Kali?

Hi Jeff:

Welcome to Null Byte!

Either will work, but I use Backtrack until Kali works out some of its bugs.

OTW

Hello again OTW,
I have three questions:
What are the drawbacks in running Backtrack in a VM such as Virtual Box?

Should I install Backtrack onto the computer instead of just running it off a live CD, like shown above in the tutorial?

and...

A rather trivial question :) ... what is the command to shut down Backtrack, besides holding down the power button on your computer. :)

Thank you for your time helping a newbie.
Jared

Jared:

The drawbacks to running BT from a VM are;

  1. Its a bit slower
  2. You need to know a bit about running Vms
  3. You can't do wifi hacking without an external adapter

You should install it rather than run a live CD because it will run faster and you can't store any info from the live CD.

To shutdown BT, you can either type shutdown at the command line or if you have the GUI, there is an icon for shutting down on the menu bar.

OTW

Perfect, thank you.

But about the shut down, I did try those, but the computer would just freeze on the backtrack logo and never shut down, just sit there. I don't know if that has anything to do with me running BT on a VM or not, but I appreciate any advice. Thank you for your ridiculously prompt replies! :)

Jared

Jared:

Yes, it is a function of you running BT in a VM. When run on a physical machine, it simply closes.

Often times, if you give the physical machine more RAM and then allocate more memory to your VM, it will run much more smoothly.

OTW

hey i read your posts
can you help me in downloading kali linux
i went to its download page but got confused about what to download
there were many options so i couldn't figure right one
i want to know your recommendation
please help......

Milind:

Download the 64 bit or 32 bit ISO.

OTW

This is it! This is my Elysium! This is where I'm gonna learn something worthwhile and make a difference. This is my raison d'etre.

I wholeheartedly thank you, maestro, for this joie de vivre.

A few pointers and clarifications, maestro, if you please.

  1. This tutorial is 6 months old. Does all of this still hold true today, including the BT version, etc. You know what I mean.
  2. Where's the 'var' directory? It's not visible in the diagram. It may be nothing but I'm just curious.
  3. Could you please explain or better still, do a tutorial, on what's vmware.

It goes without saying, it should be something like "Vmware for Dummies" (yours truly! ).

  1. Right now as I don't have access to a laptop or a PC, can I start off practicing right from my Android mobile (Samsung Galaxy Grand Quattro) or should I wait till I get one?
  2. Maestro, could you please suggest any laptop or pc that'd be ideal for this noble enterprise.
  3. If it's not too much to ask, maestro, could you please collate all these wonderful tutorials in a chronological or logical order (whichever you deem best). This will be a boon for tyros like me to wade through and grasp this highly interesting subject.

Kudos and regards,

Hi there !
Thanks for your work OTW

I will read all your tutorials but first i have a question about backtrack which appears to have "hundreds of hacker tools". I have a little experience in programming and nearly none in hacking things.

Do i really need hundred of tools to get started ?

I have a dual boot with Kubuntu 13.10 and win7.
Can I have those tools on ubuntu ?

What is the risk to learn "hacking" this way ? i mean for my computer and my data on it. (i don't know anything to virtual machines, yet)

Thank you for your time and sorry for my random english ;P

Big Duke:

Welcome to Null Byte! I'm glad you found us.

As for your questions, you could download each of these tools into Ubuntu, but it would be very time consuming. I can't really think of any risks to learning hacking this way. There is no risk to your machine or data. After all, you aren't hacking yourself.

OTW

Thanks, i will try this way and i'll let you know if i hack myself ;P
Can't wait to know more about all this ! Keep going on !

hello sir
actually i wanted to know is it fine if I use Kali
while following your posts to learn linux commands
its actually because i don't know anything about programming not

even DOS I've just started with JAVA so i don't want to do mistakes right at beginning. So basically i just want to know if its alright using Kali while referring to your posts

Milind:

Yes, of course. You can use Kali. I'm using Kali now.

OTW

thanks sir ,
ave not used linux before,hopes i wil understand it better and be able to learn hacking

Dear OTW,

I have a quick question to ask. When I input 'pwd' I get back /home/clayton. I didn't think much of it, but is this okay? Also, when I input 'cd ..' it went from /home/clayton to /home. I input 'cd ..' again then it went to /. What am I doing wrong? Was it a setup problem?

Clayton:

That is what is supposed to happen. In the first case, you are in clayton's home directory. The second case, you went up one level in the directory structure to /home and then finally to the top of the directory structure at / or "root".

OTW

I uninstalled Windows on my PC and install Linux(Ubuntu)... I totally don't have any idea about terminal. Thanks to you I'm tryin' to get into it. I'm chasing you thnx for everything

Great article, keep up the good work,
it takes time to strive sth through this, I believe you have time to keep us dedicated with u!

can i ask why the attacks are from linux to windows....and what is going on if we want to hack linux via linux or linux via windows??

Nassos:

Most of the tools for hackers are developed for Linux for good reason. You can hack Linux to Linux, but many of the capabilities we need are not available from a Windows system.

You might want to read this post from me about why every hacker should know and use Linux.

OTW

What do you recommend for installing Linux on macbook pro?

Alexander:

Welcome to Null Byte!

I recommend you download Kali Linux ISO and then install it as a dual boot on your Mac or install it as a virtual machine inside your Mac. Either will work, but as a beginner, I would recommend installing it as a virtual machine.

OTW

Hi OTW,

I've got both a Kali VM and a WinXP VM installed with VMWare Player. How can I use one to hack the other?

Thanks,
Nathan

This website is really great a lot of goods knowledge and I am get too skilled. I would like to have the tutorial in sequence like a button under like w3schools style tutorial you go from one to another but here things seems to be random. You for 1 and next suggest is 4 or even 23 and you have to find out where 2 is.

Hi I'd like to know how'd I go as and sorry if this is a extremely stupid question but install Linux how'd I go do that

is there a link to all the tutorials on this getting started subject?

hi, im new to this. thank you for this tutorial OTW. hope i can be good at this as well.

great tutorial! hope I'll succed in learning more.

Dear OTW,
I am new to linux and wanted to know if I could start with ubuntu.

You can start with any Linux you want, but Kali has all the hacking tools we use.

You say that Back|Track had some tools Kali doesn't. Could you give me a list?

If you want Ubuntu, Back|Track is still available for download using UNetBootin. Back|Track is based off of Ubuntu, while Kali is based off of Debian.

I love this guide, Ive always wanted to learn linux. As i started to follow your guide. I noticed that I'm having problems with my cd.. commands. It says command not found but when i do ls, it shows cd.. grayed out. What am i doing wrong?

can you send a screenshot, so I can understand what you are doing wrong?

Going through some lessons to brush up. Thanks again for the articles OTW

I just want to ask if these will also work on Kali Linux. I'm just a newbie at this.

Yes, most things from Back|Track will work in Kali, but because Back|Track is Ubuntu-based, and Kali is Debian-based, there will be some differences.

Thank you for answering, i don't know what ubuntu-based and debian-based is for now but i will continue reading these lectures of occupytheweb. Hope to learn what the difference of ubuntu/debian based is in the future.

Ubuntu and Debian are both distributions of Linux. These are the main two distros, so many other versions are based off these two.

Just a question, for reassurance-

It is perfectly legal for me to try hacking my own home network and my own computer, right? I want to practice and see how secure my network is, but I don't want to get in trouble.

(I would assume it's allowed, but the laws can be strange sometimes.. lol)

Only if you give yourself written permission

Okay, thankyou for the fast reply!

So far I love the website, it has amazing guides and great community members who can reply fast! (And watch their own how-to's for stuff going out-of-date or needing to be fixed) That's a lot better than most other community websites of any kind I've found. :)

"Only if you give yourself written permission"

I can't tell if that was a joke or not. lol

I wasn't sure either, I thought it probably was, but (at least in my country) I can't be sure if my government won't say "Well did you have written permission" no matter how many times I tell them it's my own network and computer. xD

Yes, governments can be quite ridiculous like that.

I'm tingling just reading this... hey OTW does typing <30wpm still get me in this club?!Yes I'm a noon is it weird I find my self stuck for hours scrolling through the< info > or <--help> commands in Ubuntu its fascinating I am here to gain grandfathered knowledge. With that I'm going to sit down and shut up and have a good day everybody.

good morning , i like this hacking lessons and this website.
i am searching for how to crunch and found your website and decide to follow the lessons to know the basic and more.

thanks a lot.

Technically there are two root directories, the actual root of the filesystem, and the /root folder, a main directory sub of the actual root directory. I agree, this can be very confusing. In turn, you can type cd ~ instead of cd /root. This does help differentiate the two folders. Similarly, in the command line, you see "root@kali:~#" for the /root directory, and "root@kali:/#" to show the main root. Interesting, eh?

Does it means that we have two types of root in linux? This, i am finding very difficult to understand.

If I understand your question, there is a root user and there is root (/) directory at the top of the file system.

best article for beginners.good work.Thanks.

Backtrack is outdated and I don't want to get a third party download. Are all the commands and stuff the same for Kali?

informative, helped me a lot thxxx

hello, since you have this article and it is about starters i would like to ask you which version of Linux OS is the best for this kind of works.

I have not installed a Linux OS and i would like to do so but i know almost nothing.
thanx a lot

Thank you so much for this article, I always liked computers and tech but I never really had the knowledge about it. And recently I also got interested in becoming maybe a hacker so that's why i decided to start learning about Linux, because I'd also read that mastering Linux is a big requirement. And since I didn't knew nothing about it, this article is really useful and easy to understand. So I'm looking forward at reading and learning the other article. Thanks a lot!!!!

Ywelcome to Null Byte!

I'm so glad you found us.

OTW i have some question first what should i start learning for becoming a hacker .second what languages do you know and started to learn in your beging. Third one should i learn python for hacking please respond i am new here

Welcome to Null Byte!

First, learn Linux. Then you should follow my article "How to Use Null Byte to Study to Become a Professional Hacker".

Once you have finished all that, then proceed to learning scripting. Python, Perl and Ruby, in that order, are all important.

thank OTW you really help people

another question if you dont mind-what is the diference in backtrack with kali linux and which is the best one

OTW can i learn perfectly from your article linux basics parts

Can i learn linux from your article:linux basics for the aspiring hacker

Hello, im a newbie on this. I have windows 7, so do i have to unistall my windows and install linux backtrack o kali?

I'm just starting out my path to be a hacker but already recognized the importance of this site for aspiring hackers! The Linux tutorials was very important to everyone that will work at the security role and, of course, need a special experience with Linux.

You made a very good work, OTW!

will anyone help me about which is better because i have done quite many things on kali and now little disturbed becouse of backTrack.

i need proper info about both which is better.
Please help.

OTW .

i also know that linux work on commands so do you have any article which can help in learning the whole command line for linux.

whenever you read this please reply me soon.

i suggest you to enroll on a edX course Introduction to Linux. Don't worry, its free.

you can also look for a book called:
>The Linux Command Line by William E. Shotts, Jr.

don't forget to use manual pages to see all the commands utilities

>man command -> ex: mas ls

can anyone else
tell the difference

Can u restore your windows if this happens is it safe and restoreable?

Hi OTW and all members,
I'm new here and know a bit about programming but surely nothing still regarding the world of hacking.

I'm on holidays without my laptop and can't wait till I'm home in two days and start applying the many hours I've red about Oracle's Vbox, the process of the white hat hackers association and so on!

I want to thank all of u in advance for guiding me, and answering my questions that for sure I will have.

For now I've one;

I've red about having a VM installed on portable virtual box, and install Kali on that,, can anyone advise me if that is a wise decision?

Once again many thanks and awesome community!!

Why I can't use the cd commanf.I am usng virtual box Kali linux and when type cd.. it says command not found

It is not cd.. like in Windows there is a space. It is cd(space).. or cd ..

I'm relatively new to hacking or computer coding in general. My resources are limited to what I can find online in the short amounts of time I have to myself. I'm unable to download anything, do not own a working phone, and cannot pay to learn about programs and how they function. So, as you can see, it is difficult to find trustworthy sites to learn from; and harder to experiment on my own with any downloaded programs. But, despite these small drawbacks; I am extremely intrigued by hacking and getting into sites and systems manually. If possible, could somebody with more vast knowledge than mine, reply with a guiding statement that would suffice to aid me on my path to hacking?

It is not cd.. like in Windows there is a space. It is cd(space).. or cd ..

OTW I wanted to thank you for these tutorials. I've worked with Windows and Mac for more than a decade now so I'm not a stranger to the terminal. I'm also not an expert I fall somewhere in between. I've always wanted to learn Linux and loaded it up on my machines many times in the past. I ran Suse for awhile, Mint and now Kali. In the past however I was learning on my own and that made it daunting. Just by going through 1-5 I created a directory and moved files into it from another directory all in the terminal. It was amazing and I'm learning pretty quick. I look forward to getting through all that there is on here.

should i use kali llinux on vmware or install it on my laptop
will i get all the features of kali linux on vmware

Thanks so much for the tutorials OTW, I finally feel like I am learning something. After years years of school and many friends and family members trying to teach me something about computers. Just fair warning if I ever see you I will abduct you shrink you and keep you in my pocket. You give great advice and you are very paciente explaining about all this. Really appreciate it.

BTW, I've been trying to install backtrack but there are too many instructions and too many options. Can someone guide me a little plz.

Okay bud here's the deal .. the developers have stopped releasing any further updates of backtrack so I'd rather suggest that you go with Kali instead .. Another thing - changes coming up are pretty drastic so you don't really want to be left behind with backtrack.

P.S
Once you download the Kali Iso look up a youtube video on how to create a live USB.

okay..as my name says, um totally new to this..so i need to know where to find an authentic linux kali setup...i need a source..

i'm login here........ just for saying please ad a .pdf file of this beginner guide and others part's too.

Sir.I have question.?in lunix which type of hacking can be done can we hack Facebook account our bank accounts

thanks for this write its just what i need now

Just FWI there is an error at the end of the first paragraph in step 3 that could be potentially confusing to someone who knows nothing about linux (which seems to be basically who this tutorial is for) so may cast doubt.

In "a /" the 'a' is in bold and therefore would seem to be part of the path where in fact it is intended to be the article for the bold '/' correctly indicating the root directory.

My question may sound silly ,but can we try same steps with kali???

wont simple w command return the name of the user we're logged in as? with additional details too?

This is awesome. I really need to learn Linux. Does your book on Amazon cover most of the topics on this site?

started few days ago with kali!
your tutorials are helping me so much!

the diagram to visualize the file system cleared my mind!

ty,
keep going!

This is 6 years old, it really needs to be updated.

Share Your Thoughts

  • Hot
  • Latest