You are on page 1of 65

1

This page intentionally left blank















































So which Linux is best for you? ......................................................................................................... 5


Several Linux Distributions to download ...................................................................................... 6
Installing Linux on your Desktop or Laptop system .................................................................. 9
How to partition your disk, I will show you two ways ........................................................... 10
Partition Layout .................................................................................................................................. 11
About the GUI Desktop ...................................................................................................................... 18
Working with your Desktop ............................................................................................................ 19
Are you on the Internet? ..................................................................................................................... 21
How to update your Ubuntu Linux ................................................................................................... 21
Are you ROOT? ..................................................................................................................................... 23
The Linux File Structure ................................................................................................................... 24
Init ............................................................................................................................................................ 28
Run Levels ............................................................................................................................................. 29
Windows Directory Structure ............................................................................................................ 30
Linux Directory Structure ................................................................................................................ 30
Lets install some Applications ........................................................................................................ 31
Installing Administrator tools ........................................................................................................ 33
Installing programmer tools ........................................................................................................... 33
Installing software using Apt-get .................................................................................................. 34
Installing apt-get repositories ........................................................................................................ 35
Creating and Moving Folder and files .......................................................................................... 38
Working from the Terminal Shell ................................................................................................. 41
Changing Linux Desktop Wallpaper ............................................................................................. 44
Downloading Software on Linux .................................................................................................... 45
Creating a File using Text editor on Linux ................................................................................. 46
Creating a file using vi editor .......................................................................................................... 48
Creating a file using the touch command ................................................................................... 50
Using copy on Linux command line .............................................................................................. 53
Delete a Directory on Linux ............................................................................................................. 56
Delete a non-empty directory on Linux ...................................................................................... 57
Installing ( LAMP ) on Linux computer .......................................................................................... 59
Linux Cheat Sheet (Using the Bash Shell) ................................................................................... 61
Linux Cheat Sheet (Using the Bash Shell) Continued ............................................................. 62
Linux Cheat Sheet (Using the Bash Shell) Continued ............................................................. 63

Bash vi Editor (Cheat Sheet) ........................................................................................................... 64


Bash vi Editor (Cheat Sheet) Continued .................................................................................. 65


Hello and thank you for buying my
Linux and Unix Learning the easy way book.

I hope you enjoy reading and performing the task you will be performing in this

book, as much as, I enjoyed creating them for you

I will not bore you with the Linux jargon that other books put you through.
I will just JUMP into it with you!

So who wants to install Linux?
Then lets get started.




Linux has been in the US for some time for sometime now.
A lot of companies need employees that know how to Administer Linux/Unix.
Even the pay is better if you reach the potential of being a good Linux System
Administrator.

Weather you are reading this book to learn how to install Linux or maybe you need
to have insight on what Linux is all about and want to see how to install and move
around Linux GUI or Command line Linux Shell. Either way this is a good place to
start if you have no prior experience with the Linux or Unix Operating System.

So which Linux is best for you?


Not sure?

Then ask yourself this question. What are you planning to use Linux for?
Gain insight on job training with a co-worker so you can get a pay raise or job
promotion?

Would like to change Careers and would like to get yourself hands on training using
your desktop or laptop or even a Virtual Machine.

However, if you are still not sure

Then I will just introduce you to one Linux OS Version that is very popular in the US.
One that I think will help you with learning to install and use for your learning
purposes very easily.

Then you can later search on your own and find out what Linux is right for just you
and your needs. J
For your reference later, here are a few Linux OS versions and what you can do with
them.

Several Linux Distributions to download



Ubuntu Linux:
Very easy to install and use with the beginner in mind.
You can use this Linux at home and work. Installs very easily on a desktop or
laptop. Drivers interface good from my past experience in the past to present
(this is the one we will be using for our learning Sessions through out the book)
With Ubuntu Linux you can not only install a desktop edition. You can install as a
Server or Developer workstation if you want.
Good for Media Streaming and using the email client Thunderbird. Just a few things
you can do with Ubuntu Linux.

Download at www.ubuntu.com



Centos Linux:
It is however, a little bit more hands on to install.
You will maybe need to download some third-party drivers.
During the install of Centos Linux, It will look and find hardware good but may not
work always if you have an older Desktop pc or Laptop.
You can setup as a Linux Server, Linux Desktop or even as Linux Developer
workstation.


However, I have not had any wireless issues on install or had Hard Drive issues and
also seem to find USB pen drives ok too.
Keep in mind this OS is for a more advanced user level of Linux that your everyday
System administrator is use to for Linux.
You can learn more from the Centos website and download the User Manual and
Administration Manual should you want to learn the command line.

Download at https://www.centos.org

Suse Linux:
Geared for people that have more experience than the average user.
You can setup as a Linux Server, Linux Desktop or even as Linux Developer
workstation.
And will install easy if you want to give it a try.
Drivers work great.

Download at https://www.opensuse.org/


Kali Linux
Not one to begin with to me.
Kali is a Debian-based Linux distribution aimed at advanced Penetration Testing
and Security Auditing.
Kali contains several hundred tools aimed at various information security tasks,
such as Penetration Testing, Forensics and Reverse Engineering.
Kali Linux is developed, funded and maintained by Offensive Security, a leading
information security training company.
You can download and read more at: https://www.kali.org/





OK

Lets Get Ubuntu open browser and go to: www.ubuntu.com

Click on the Download link and Select Desktop

Figure 1.1







Download Version: 15.10

Figure 1.2


Downloading

Figure 1.3





Now go to your downloads folder or where ever you saved the Ubuntu.iso file
And double click on it and burn the dvd or use it as an ISO. If you are creating a
Virtual machine Or Maybe you will be booting from a DVD or ISO OS image.

Installing Linux on your Desktop or Laptop system


Im booting from an .ISO image. Mounted during my VMware Setup

Figure 1.4

Now Select Install Ubuntu

Figure 1.5

Be sure to select install this third-party software. This will install video and other
drivers also.

Click Continue

Figure 1.6

How to partition your disk, I will show you two ways


First Option:
If you wish you can let the Operating System to create the partition
UBUNTU Linux OS will be automatically create your partition depending on the disk size.

Second Option: Manual Partition yourself


To get a more advanced look and experience installing this Layout
You can just create your own partition.
Im just going to create my own partition, using around 62 GB disk. All subject to change depending on
your disk drive.
EFI Partition 650 MB if you use UEFI Then do the following

10

Partition Layout

/(root) 30 GB ( Formatted as EXT4 journaling file system )


/var 10 GB (Formatted as EXT4 journaling file system)
Swap Partition double of RAM ( 2 GB in my case )
/home 20 GB (Formatted as EXT4 journaling file system)

Remember you are sure you want to wipe this Hard Disk if so Continue.


Figure 1.7
Ok here is what we have so far.
Showing below:
If you are sure you want to continue click Install now.

Figure 1.8

11

Select the same as below


This is our Root Partition /

Figure 1.9


Now create the SWAP Partition
(Note the /var position will be the same to create ok)

Figure 1.10

12



Remember your disk may look somewhat different but its ok you can install now.

Figure 1.11


Notice the Warning! IF you are again sure click on Continue

Figure 1.12

13

Set the time zone for the Clock. Then Continue


Figure 1.13 - Time zone

Select the language for your setup.

Figure 1.14 - Language


14

Click on Continue

Define the Systems Hostname


Define the Name of user that will be used after installation
Define the password for the user.
Set the option Require my password on Log in
Click Continue

Figure 1.15

Installation is in Progress as shown below


When we click on Continue in above step then installation will start.

Figure 1.16

15

When the Installation is completed, we need to take reboot.

Reboot the System

Figure 1.17


Now log into the System using the credentials that we set up during the above steps

Installation of Ubuntu 15 has now been completed GREAT JOB!


You also should be seeing the below Login Screen with your user id

16

Figure 1.18
OK Lets Login

Figure 1.19

17




You should be on your desktop Showing below

Figure 1.20

About the GUI Desktop

Below Figure 1.21 is showing the parts of your new Desktop.



A: Showing GUI Desktop
B: Trash Bin
C: File Explorer
D: Programs Start and Applications
E: Firefox
F: Office alternative word compatible
G: Sound
H: System Settings and User logout and Shutdown area

18

Figure 1.21

Working with your Desktop

19

OK lets change our GUI or Desktop Wallpaper J





Right click on desktop and select change background
Download your own or use one already selected below in Figure 1.21



Select the Image you wish to use and set its scale. Then when you are happy with it
close the window when finished with your selection.

Figure 1.21






20

Are you on the Internet?




Here is how to check J

Do you have your network plugged in via an Ethernet cable? Then you should be ok.
Look below in Figure 1.22 ?

Figure 1.22


OK so much for our Desktop GUI


How to update your Ubuntu Linux



21


Next we need to be sure all updates have been done
To do this we can simply use the Terminal shell

Go to Search you computer and online source icon on top left side of your screen
Then type in the name term or terminal as sheen in Figure 1.23 below


Figure 1.23

You will be using this often so right click on task bar and select
Lock to Launcher (So it will be located close by when you need it again) Showing in
Figure 1.24 below

Figure 1.24

22

Are you ROOT?


Now if you notice here is a note inside the Terminal after you opened it.

If you wish to run as the user root you must use the command
sudo <command> We will speak of this now

Whenever you use a command to run a program or install a program you must have
elevated permissions know as root on Linux systems.
Some Linux Editions dont allow you to run as root when you login. But more of a
standard user and therefore you will not be able to run certain commands or install
applications etc. So what we do instead is ask to have root permission to install it by
telling the Linux computer to authorize it by typing the command sudo then
following by the command you wish to perform.
Example: sudo apt-get update
Permission to ask is: sudo
Request we are asking: run our ( apt-get update command )
Here is the command without asking with sudo

Notice the command below: apt-get update
Notice the Permission denied
Notice the question we are being ask (Are you root?) in Figure 1.25

Figure 1.25


OK here is how you need to run the command
sudo apt-get update
Now we are being asked our user password. Enter password to continue

Figure 1.26

23

Command is now running and going to several update website to download


packages for UBUNTU LINUX

Figure 1.27



Command has now completed with no errors
This Ubuntu is now up to date in figure 1.28 below

Figure 1.28

The Linux File Structure





OK Now lets learn a bit about the Linux File Structure

Linux OS compared to Windows OS I will explain with a compare sheet below

Linux is like a Tree and the top of the Tree starts with Root or /



Root Directory
Of the Entire Linux
File System of the Hierarchy

24

Figure 1.29


Above in Figure 1.29
Contains all our important information, required for booting to device drivers,
configuration files and other things. Lets describe just a few of the above and what
they are used for. Lets start hierarchically.



1. /

Root or / is the top level directory on a Linux System. This is it is the
directory in which all other directories, including their subdirectories,
and files reside. The root directory is designed by a forward slash ( / )


2. /bin

bin is a standard subdirectory of the root directory in Unixlike operating systems that contains the executable (ready to run)
programs that must be available in order to attain minimal

25

functionality for the purposes of booting (starting) and repairing a


system.

3. /boot
In the Linux, and other Unix-like operating systems,

the /boot/ directory holds files used in booting the operating system. The
usage is standardized in the File system Hierarchy Standard

4. /dev
The /dev directory contains the special device files for all the devices.
The device files are created during installation, and later with
the /dev/MAKEDEV script. The /dev/MAKEDEV.local is a script written
by the system administrator that creates local-only device files or links

5. /etc

The /etc maintains a lot of files. You should determine which


program they belong to and read the manual page for that
program. Many networking configuration files are in /etc as well,


6. /home

The /home directory contains a home folder for each user




7. /lib
The /lib directory contains libraries needed by the essential binaries
in the /bin and /sbin folder. Libraries needed by the binaries in the
/usr/bin folder are located in /usr/lib.

26

8. /media
The /media directory contains subdirectories where removable media
devices inserted into the computer are mounted. For example, when
you insert a CD into your Linux system, a directory will automatically
be created inside the /media directory. You can access the contents
of the CD inside this directory.

9. /mnt

The /mnt directory is where system administrators usually mount


temporary file systems while using them. Like, if youre mounting a
Windows partition to perform some file recovery operations, you
might mount it at /mnt/windows dir, although, you can mount other
file systems anywhere on the system.

10. /opt
The /opt directory contains subdirectories for optional software
packages. Although commonly used by proprietary software venders
that doesnt obey the standard file system hierarchy, So a
proprietary program might dump its files in /opt/application when you
install it by default unless you change it.

11. /sbin
The /sbin directory is somewhat similar to the /bin directory. And It
contains binaries that are generally intended to be run by the root
user for system administration.

12. / root
The /root directory is the home directory of the root user. Instead of
being located at /home/root, its located at /root. This is not the
same as /, which is the system root directory.

27

13. /proc

The /proc directory is somewhat a bit similar to the /dev directory as


it doesnt contain standard files. It contains special files that
represent system and process information among other things


Init

Looks at the /etc/inittab file to decide the Linux run level.
Following are the available run levels
0 halt
1 Single user mode
2 Multiuser, without NFS
3 Full multiuser mode
4 unused
5 X11
6 reboot

Init identifies the default initlevel from /etc/inittab and uses that to
load all appropriate program.

Execute grep initdefault /etc/inittab on your system to identify the


default run level

If you want to get into trouble, you can set the default run level to 0 or
6. Since you know what 0 and 6 means, probably you might not do
that.

Typically you would set the default run level to either 3 or 5.

28


Run Levels

Example of the 6 stages of boot process the Runlevel Programs
Linux has 6 different Run Levels

Run level 0 /etc/rc.d/rc0.d/
Run level 1 /etc/rc.d/rc1.d/
Run level 2 /etc/rc.d/rc2.d/
Run level 3 /etc/rc.d/rc3.d/
Run level 4 /etc/rc.d/rc4.d/
Run level 5 /etc/rc.d/rc5.d/
Run level 6 /etc/rc.d/rc6.d/

There are also symbolic links available for these directories under /etc
directly. So, /etc/rc0.d is linked to /etc/rc.d/rc0.d.

Under the /etc/rc.d/rc*.d/ directories, you would see programs that start
with S and also K.

Programs starts that start with S are used during startup. S for startup.

Programs starts that start with a K are used during shutdown. K for kill.

29

Windows Directory Structure

Here is a windows Directory Structure to see what it is compared to Linux


Figure 1.30 below

Figure 1.30

Linux Directory Structure


Linux Directory Structure compared to Windows Figure 1.31 below shows

Figure 1.31

30

Lets install some Applications




OK
Lets install some applications or programs from within the GUI and From the
Command line

Lets install first from the GUI Desktop with the Ubuntu Software Center located on
your task bar

Figure 1.32


Lets install an alternative to Photoshop called GIMP
Search for gimp in figure 1.33 below

Figure 1.33

31

Highlight the application then click Install (Its that easy J)


Figure 1.34


It will prompt for a password
Just enter password then click Authenticate - to start the installer process

Figure 1.35

Gimp is a Free Application like hundreds of other out there just waiting to be
discovered by you and others for the finding.

Figure 1.36

32

Installing Administrator tools




OK
Lets look for another app called Putty
This utility is used to connect to other workstations and server from the command
line ssh tool

Enter putty in search (Then enter password and install)

Figure 1.37

Installing programmer tools



Are you someone that is a programmer or want to be a programmer?
Then here is a C and C++ IDE Application you can use to make programs
Again click install and enter password to start to install process

Figure 1.38

33


Installing software using Apt-get


Now what if you cant find what youre looking for in the UBUNTU Software Center?
Then you can use the Command Line Shell or Terminal

Open the Terminal we attached to the taskbar

NOTE:
Install PyCharm from PPA: PYTHON IS A PROGRAMMING Language
Theres a PPA repository for Ubuntu based users that contains both professional (30-day free trial) and
community version of PyCharm packages. So far, Ubuntu 15.04, Ubuntu 14.04, Ubuntu 12.04 and their
derivatives are supported.
1. To add the PPA, open terminal , Launcher, or via Ctrl+Alt+T shortcut keys. When it opens, run
command:
sudo add-apt-repository ppa:mystic-mirage/pycharm

Figure 1.39

Enter password

Figure 1.40

34

Enter to Continue

Figure 1.41


Installing apt-get repositories

The repository ppa has been entered

Figure 1.42

2. After adding the PPA, update system package cache and install the IDE via Synaptic Package Manager.
Or just run below commands one by one in terminal:
sudo apt-get update ( This will update the apt-get package manager to
list the pycharm for you to grab and install on next command)

35

Figure 1.43
sudo apt-get install pycharm
OR
You may replace this last command via sudo apt-get install pycharmcommunity to install the community version, which is free.
Here is the command to better understand it.
(Please allow me to install a program) SUDO
(Please get the program) Apt-get
(Please install the program) Install
(Name of program to install is called) Pycharm
So all together the command is
sudo apt-get install pycharm

Figure 1.44

36

Do you want to continue?


Enter Y for yes below in figure 1.45

Figure 1.45
Now just sit back and wait for the apt-get installer to complete your
install of pycharm thats it for installing programs for now.
Should you want ot find any other programs just search Google for it
and it will be one out there someone Im sure has installed it before.

37

OK NOTICE ALL DONE WITH NO ERRORS

Great Job!

Figure 1.46

Creating and Moving Folder and files


Now lets do a few things on the Desktop and command line like creating
and moving folders and deleting them to
Open the files explorer window from the desktop on left task bar

Figure 1.47

38

Open the Desktop Folder

Figure 1.48

Now create a folder Called Student1

Figure 1.49

39

Great job

Figure 1.50

Now create 2 more folders called Student2 and Student3


Now notice you see them on your desktop and inside the folder

Figure 1.51

40

Working from the Terminal Shell


Now what if you didnt have a desktop to work from?
Then we would have to use the command line terminal
Go to task bar and open the Terminal shell
Notice the 3 folder still located on our desktop

Figure 1.52
First we need to move to the Current Desktop Directory so we can see
what is going on as we create more folders
Lets change to the Desktop directory of our user profile.
Enter this command at your command prompt
cd Desktop
(Press the enter key to change that directory)

Figure 1.53

41

We will now add 3 more folders by using the command


Enter the command mkdir Student4

(and press enter key)

Figure 1.54
Enter the command mkdir Student5
(Now notice the new folders added on your Desktop Student4 and
Student5)

Figure 1.55

42

Now lets learn to Copy from our Desktop GUI and Desktop
Lets go to Google and find a few items that we can use for our copying
process.
Open the Firefox web browser

Figure 1.56
Go to google.com

Figure 1.57

43

Changing Linux Desktop Wallpaper


Lets look for a Linux Desktop background or wallpaper
Select the Images section

Figure 1.58

Select an image and call it wallpaper1

Figure 1.59

44

Downloading Software on Linux


Now using google.com find a program you can download that is free
I just want to grab a file so we can use it to download and move around so click on Download Filezilla
client

Figure 1.60
Download for Linux

Figure 1.61

45

Click on save file and save to Downloads Folder if asked

Figure 1.62

Creating a File using Text editor on Linux


OK now lets make our own file using the text editor
Go to Ubuntu Search and open the text editor on the Desktop

Figure 1.63

46

OK Open the Text Editor and enter anything you wish inside so we can have Information saved inside it to
use for moving purposes.

Figure 1.64
Now click on Save (Save it as NewFile1 Save to your Downloads Folder)

47

Figure 1.65

Creating a file using vi editor



OK Now lets create another type of text file using the command line.
We will be using the vi Editor, So Open your Terminal Shell
At the command prompt type this:
vi FileFile1 (or name it what you wish)

Figure 1.66
Notice what we are seeing now. We are seeing the Name at the Bottom FileFile1 [New File]

Figure 1.67

48

To save this file you need to hit the esc key. Then type the following: :wq!
This will save and exit the editor.

Figure 1.68

You should now be back at your shell prompt

Figure 1.69

49

Creating a file using the touch command

To avoid all this altogether you can just type touch myfirstfile1
At the command line enter the following command touch filename and press enter thats it.

Figure 1.70
Now and easy way to move a folder is to copy and paste it from the File explorer window

Create a new folder on your desktop and call it Lab_folder (NOTE: On Linux Systems always connect a
space.) Never have a space in a folder or file name. Like Lab Folder you need to instead name it
Lab_Folder. This makes things run smoother later when you want to copy a file or folder. From one
server to another or from one network location place to another

50

Figure 1.71
Now open up the Lab_Folder and place both the Desktop folder and Network folder open on top of one
another like below to keep things simple J All you need to do is Right Click on each file and then copy
and paste to the below folder just as you would on a windows pc
(Please place back to desktop when you are done) for the command line copy we will do next

Figure 1.72

51

Now open your Terminal Shell


First lets be sure of what director we are located in by typing at the command prompt: pwd
Notice we are in our home directory

Figure 1.73

We need to be in our Desktop Directory (remember how to get there?) cd Desktop (correct? Yes)
OK now after typing the command we are now inside our Desktop

Figure 1.74
Now lets see what all is on our Desktop by typing the ls command
Notice that the white colors are files we created and the others or folders that we created earlier

52

Figure 1.75

Using copy on Linux command line


Now lets use the copy command from the command line.
Type: cp FileFile1 Lab_Folder

Figure 1.76

53

Now lets learn to delete a file and a folder

Figure 1.77

54

From the command line its a bit of work to do J heres how


Open the Terminal Shell. Now cd to the Lab_Folder like this:
cd Lab_Folder

Figure 1.78
Then run the ls command to view all files and folders

Figure 1.79
ok lets delete the file. Type the following command: rm FileFile1 and press enter key
Then do another ls command to see if you have anything inside folder ( As showing below no )

Figure 1.80

55

Delete a Directory on Linux



OK Now lets delete a Directory (But First type cd .. to move back one Directory to our Desktop again)

Figure 1.81
This type the ls command to view contents again.

Figure 1.82

To remove a directory you need to type: rmdir Student5 then press enter key

Figure 1.83

56

Now type another ls command to see its gone now


Notice that the Folder Named Student5 has now been removed

Figure 1.84

Delete a non-empty directory on Linux

But what if the folder has a contents or files inside of it? Then you will need to issue an argument with the
ls command to remove folder and contents as follows:
rm rf Like this rm rf ( filename ) ( First copy files to the
Lab_Folder as showing below so we can perform this task please.)

Figure 1.85

57

Now lets proceed to delete a non-empty directory


Type the following: rm rf Lab_Folder then press the Enter Key to complete the command.
If you no longer see the Lab_Folder on your Desktop then you did everything correctly Great Job!

Figure 1.86

Here are a few more commands for this task.


Should the command not work be sure that you use the sudo command
sudo rm -r /path/to/folderName
You can use letters -f, -r, -v:

-f = to ignore non-existent files, never prompt


-r = to remove directories and their contents recursively
-v = to explain what is being done

58

Installing ( LAMP ) on Linux computer



Installing a Linux Apache, MySQL Database and PHP


If you are a web programmer or someone wanting to learn how to.
You will need a Linux Apache Web Server.
Here I will show you the steps needed to install a Stand-a-Lone Desktop or Laptop LAMP Web server used
for a web server or development workstation.

There are 2 ways of installing this in case one


doesnt work for you J
1st The Short way
sudo apt-get install tasksel

with out the quotes

sudo tasksel install lamp-server


It will install the entire basic LAMP stack for you, prompt for MySQL root password, etc.
It should install the following packages and their dependencies
mysql-client-core-5.1 libwrap0 apache2
libaprutil1-dbd-sqlite3 tcpd
libapache2-mod-php5 apache2.2-common
apache2-utils php5-common
libaprutil1-ldap libaprutil1
php5-mysql mysql-server-core-5.1
libdbi-perl libplrpc-perl mysql-server
apache2.2-bin libdbd-mysql-perl
libhtml-template-perl
libnet-daemon-perl libapr1
mysql-server-5.1 libmysqlclient16
ssl-cert apache2-mpm-prefork
mysql-common mysql-client-5.1

59

2nd The Long way

Install Apache
sudo apt-get install apache2
Install PHP
sudo apt-get install php5 libapache2-mod-php5
Install MySQL
sudo apt-get install mysql-server
Install phpMyAdmin
sudo apt-get install libapache2-mod-auth-mysql php5-mysql phpmyadmin

60

Linux Cheat Sheet (Using the Bash Shell)

61

Linux Cheat Sheet (Using the Bash Shell) Continued

62


Linux Cheat Sheet (Using the Bash Shell) Continued

63

Bash vi Editor (Cheat Sheet)


64


Bash vi Editor (Cheat Sheet) Continued

65

You might also like