Welcome to Trix' with Linux, the first installment of this series! In this series you will become my trainee command-line ninjas and in this guide we will be covering basic Linux use. I will cover Ubuntu/Mint (these will also work for Kali). If you're using another distro and want help, just comment and I'll be happy to help you out as will many others here.
Firstly, now you've fired up your new Linux distro, you first must get comfortable and familar with your terminal, open up your terminal application, this can usually be found in a menu or on Mint/Ubuntu by pressing CTRL-ALT-T. Once you are there, you will be presented with a small line of text and a blinking cursor. This line of text is your PS1. On my Arch Linux machine, my PS1 looks like this
[email protected] ~
pry is my username, and the current user I am logged in as.
ghostpro is the hostname of my machine
~ is the current directory, in Linux
~ (pronounced tilda) represents your home directory. So my documents folder would be located at
~/Documents/, however in actual fact, is located in
/home/pry/Documents/, but because I am logged in as pry, the
/home/pry/ is replaced with
In most shells, there will be a
$ or a
# before the cursor, this is used to represent whether you're logged in as root or a normal user.
# represents root, and
$ represents ordinary user. Root is like admin. An all powerful superuser who can do whatever he likes. This can be dangerous, so don't log in as root regularly. This will be covered later on...
If your PS1 doesn't show your current directory, then you can use the
pwd command to see what directory you're in. If I run it on my machine I get this response
/home/pry because I haven't gone anywhere. To see what files are in this directory/folder, I just need to run
ls, the response I get is:
Bin Desktop Documents Downloads Music Pictures
This is the same as opening a file manager and going to my home folder. Now, lets say I want to go into my Documents directory, all I need to do is execute
cd stands for change directory. Note cd is case sensitive.
Now, if that executed fine, you just now be in
~/Documents/, I like to think of file paths like web paths in URL's. You start in the home directory, or the home page, and as you click links you can move around them. If you want to verify you have changed directory, quickly run
pwd again to see. You should get a response like this
/home/pry/Documents. Again, you can run
ls to see whats in that folder. If you want to go backward, say back to home, you have two choices, the first is to hand
cd an absolute path so:
cd /home/pry/ or
cd ~/, both will have the same outcome, or, you can simply go back a level with
.. in Linux is generally referred to as the parent directory, the level above you. You can also get back to your home directory by just executing
cd with no arguments.
Installing packages is literally one of the best things about Linux based systems. The use of repositories completely obliterates the old fashioned method of downloading executables and installing them with a wizard. If I want to install a package on Ubuntu/Mint, I will need to use an application called apt-get, or apt in modern versions. To use apt-get I will need root privedges, but remember I said earlier that we shouldn't be logged in as root often? Because of this fatal dilemma, some smart guy (Todd C. Miller) wrote a program called
sudo, which means super-user do. This program allows you to escalate privileges for a single command and then return back to your normal safe user privileges. If you try running apt-get without sudo, and by a normal user, then you will get an error message.
So lets say I want to install a package like say
pv, for measuring the progress of my file sharing, I would first update the local repository database:
sudo apt-get update
sudo is the privilege escalation command to allow apt-get to run as superuser
apt-get is the application used to install packages on Debian/Ubuntu/Mint machines.
update is the argument I have passed to apt-get, telling it to update its local respository database.
This command will run for a while, and then finish. Now you are good to go! Simply run:
sudo apt-get install pv
install is the argument passed to apt-get, telling it to install
pv is the package we want to install.
This command will run through and ask you if you would like to install it, answer with y, and then enter, and it will install it! Easy huh?
Now that you're familar with your new shiny Linux install, lets get right on to the basics of Networking in Linux. Two commands you will come to know and use a lot are
ifconfig tell you a lot about your current networking setup, and are useful for many things (including mac spoofing).
If you run
ip link, you will get a small overview of your networking devices. My wireless networking devices is wlp3s0b1, yours might be wlan0, it will differ on computer to computer. If I want to see the IP address assigned to my wireless card, all I need to run is
ifconfig wlp3s0b1 or
ifconfig wlan0, and it will output with several lines showing me infomation about my networking enviornment. The second line of the output is the most important to me right now:
inet 192.168.1.78 netmask 255.255.255.0 broadcast 192.168.1.255
inet 192.168.1.78 is telling me that my internet networking address is 192.168.1.78
netmask 255.255.255.0 is telling me that the network I'm connected to is using a 255.255.255.0 subnet mask, or that I'm connected to a Class C network with 254 possible hosts, more infomation on netmasks/subnets can be found here.
broadcast 192.168.1.255 is telling me that the broadcast address for this network is 192.168.1.1.255
I can also control my networking devices with
ip link and
ifconfig, to put your devices down, you can use either:
ip link set wlp3s0b1 down
ifconfig wlp3s0b1 down
And the same works for putting it up, but you replace down with up :stuck_out_tongue
So that's all for today my trainee command-line ninjas! Hope you enjoyed this edition of Trix' with Linux, and as always, bai!