wiki:ubuntuinstall

Version 5 (modified by admin, 7 years ago) ( diff )

--

Linux Hands - On

Through this hands-on you will install Ubuntu Server on a vm and you will make additional two clones of the installed ubuntu server for your lab sessions in next two days.

Setting up virtualbox

Installation of virtualbox and Downloading Ubuntu iso image

  • Download and install virtualbox 5.0.x
  • Download Ubuntu image from the LEARN mirror
  • Note down the location of downloaded iso file

Creating the VM

  • Start virtualbox and Click on New button (at top-right) to create new virtual machine
  • Enter name of the VM as: linux.'your domain'.ws.learn.ac.lk. You can get your domain from here

eg: linux.user1.ws.learn.ac.lk

  • Select OS Type: Linux
  • Select Version: Ubuntu (64-bit)
  • Then click on Continue button
  • Set VM's memory size to 1024MB and click on Continue button
  • Set VM's hard disk option to Create a virtual hard disk now and then click on Continue
  • Select disk type to VDI
  • Select storage type to Fixed size and Continue
  • Make sure virtual hard disk file name in following format linux.'your domain'.ws.learn.ac.lk
  • adjust the disk size to 10.0GB and click on Create to create the VM

This might take couple of minutes

(Note down the location of vdi image file when virtualbox flashes it on the screen)

Setting up Network Interface

  • Select the VM from left panel on Virtual box, right click and open Settings
  • Click on the Network title
  • On Adapter 1 While Enable Network Adapter selected choose Attached to be Bride Adapter. This virtual interface will work as the WAN port of the firewall (Can be connect from out side).

Setting up boot device and Booting

  • Click on Storage title and select CD ROM icon under the Controller:IDE Click on CD ROM icon under the Attribute on the left side to select
  • Choose Virtual Optical Disk File
  • Locate the Ubuntu CD Image file you downloaded from the LEARN ftp
  • Right click on VM to make a Normal Start VM. You should now see a separate window with Installation screen

Installation

Initial Installation options

  • Select English as language for the installation wizard
  • Select Ubuntu Server
  • Select English for VM's OS language
  • Select location by Others->Asia->Sri Lanka
  • Keep locales as default United States
  • Press No for configure Keyboard
  • Select English (US) for country of origin for the keyboard

Now it might take sometime to detect the hardware and load the necessary Linux modules

Note that it configure network with DCHP

  • Type host name as: linux.'your domain'.ws.learn.ac.lk
  • When it asked, add a User by entering Your Name, your username, password
  • You may select No for not to encrypt home directory
  • Select Yes confirm the time-zone

Disk Configuration

Your have 10GB hard drive previously configured for your VM

  • Select Manual
  • Select the Disk SCSI3(0,0,0) (sda) - 10.0 GB ATA VBOX HARDDISK and Select Yes to create new partition table
  • Select Free Space to create following partitions and mount them as follows. Use EXT4 for all partitions except for SWAP partition
    • a primary partition for /boot 512MB - turn on Bootable flag
    • a primary partition for Linux SWAP (two times the RAM) SWAP 2GB
    • a primary partition for Linux Logical Volume for remaining disk space.
  • Then use Logical Volume Manager to create a Volume Group named as "linux" and logical volumes for followings
    • a logical volume root for / 2GB
    • a logical volume usr for /usr 3GB
    • a logical volume var for /var rest of the free space
  • Get above partitions mounted as /, /usr and /var with the file system EXT4 selected.
  • Then finish the partitioning and confirm it to write to the disk

Now it might take sometime to install the OS base.

Final Configuration

  • At the package manager, click Continue not to use any proxy settings

Again it might take times to install rest of the packages.

  • Select No automatic updates
  • Select only
    1. standard system utilities
    2. OpenSSH server

Wait until it finished the installation of software

  • Finally install/setup the GRUB boot loader by selecting Yes
  • Finish the installation of Ubuntu by selecting Continue

VM now should restart with the newly installed OS.

You may now login using your credentials

Create the Additional VMs

You will now easily create the second VM using VM cloning. This VM is for your Web Server which will be used for hands-on tomorrow.

  • First Power off/shutdown your VM
  • Right click on the VM to select Clone option
  • Assign new name as web."your domain".ws.ac.lk
  • Check "Reinitialize the MAC address for all network cards
  • And then click on Continue
  • Select Full clone

This might take sometime to create the new virtual disk image (vdi) file. Note that your new VM is same as your previous one. You have to change host name, ip addresses, etc accordingly.

  • When the cloning finished, start you new VM and do following to change the host name
  • edit /etc/hostname file and change host name to web. You may use vi or nano editor.
  • also edit /etc/hosts file to change 127.0.0.1 pc."your domain".ws.ac.lk pc to 127.0.0.1 web."your domain".ws.ac.lk

You can follow the same steps and create the third VM to use as the ldap Server. Note the following changes.

  • Assign new name as ldap."your domain".ws.ac.lk
  • edit /etc/hostname file and change host name to web. You may use vi or nano editor.
  • also edit /etc/hosts file to change 127.0.0.1 pc."your domain".ws.ac.lk pc to 127.0.0.1 ldap."your domain".ws.ac.lk

Note: For this Hands-on you only need your pc(pc."your domain.ws.ac.lk") VM. Please shut down the additional VM's

Playing with Linux

Working with directories

A brief overview of the most common commands to work with directories: pwd, cd, ls, mkdir and rmdir. These commands are available on any Linux (or Unix) system.

  • pwd : Print Working Directory (Will tell you the location you are currently working)
  • cd : You can change your current directory with the cd command
    • cd : shortcut to get back into your home directory. Just typing cd without a target directory, will put you in your home directory
    • cd .. : To go to the parent directory (the one just above your current directory in the directory tree)
    • cd - : To go to the previous directory
  • ls : You can list the contents of a directory with ls
    • ls -a : To show all files. Showing all files means including the hidden files. When a file name on a Linux file system starts with a dot, it is considered a hidden file and it doesn't show up in regular file listings.
    • ls -l : to display the contents of the directory in different formats or to display different parts of the directory.
    • ls -lh : shows the numbers (file sizes) in a more human readable format.
  • mkdir : Create new directories
  • mkdir -p: To create parent directories as needed
  • rmdir: To remove the directory. (Directory has to be empty)

Some exercise

  1. Login to your VM. and Display your current directory
  2. Change to /etc directory and display current directory
  3. Go to root directory and list the contents
  4. List a long listing of the root directory
  5. Go to your home directory
  6. Make directory named 'test'
  7. make a directory inside test directory named 'one' and make a hidden directory inside 'one' directory named '.hidden'. Make a directory inside test directory named 'one' and make a hidden directory inside 'one' directory named 'unhidden'.
  8. Go to 'one' directory and list the content.
  9. Then list all contents
  10. Remove directory 'unhidden'
  11. Go to your home and try to remove directory 'test'
dilum@DilumL:~$ pwd
/home/dilum
dilum@DilumL:~$ cd  /etc
dilum@DilumL:/etc$ pwd
/etc
dilum@DilumL:/etc$ cd ..
dilum@DilumL:/$ ls
bin   etc         lib    lost+found  opt   run   var
boot  home        lib32  media       proc  sbin  tmp       mnt 
dev   lib64       root   sys         usr
dilum@DilumL:/$ ls -l
total 88
drwxrwxr-x   2 root   root  4096 Mar  4  2016 bin
drwxr-xr-x   3 root   root  4096 Feb  9  2016 boot
drwxr-xr-x  20 root   root  3360 Nov 16 08:16 dev
drwxr-xr-x 155 root   root 12288 Aug 29 09:30 etc
drwxr-xr-x   4 root   root  4096 Aug 16 08:54 home
drwxr-xr-x  19 root   root  4096 Mar  4  2016 lib
drwxr-xr-x   2 root   root  4096 Mar  4  2016 lib32
drwxr-xr-x   2 root   root  4096 Mar  4  2016 lib64
drwx------   2 root   root 16384 Dec 15  2015 lost+found
drwxr-xr-x   4 root   root  4096 Dec 15  2015 media
drwxr-xr-x   2 root   root  4096 Dec 15  2015 mnt
drwxr-xr-x   3 root   root  4096 Jan 26  2016 opt
dr-xr-xr-x 189 root   root     0 Nov 16 08:16 proc
drwx------  12 root   root  4096 Sep  6 16:25 root
drwxr-xr-x  26 root   root   960 Nov 16 08:41 run
drwxr-xr-x   2 root   root  4096 Mar  4  2016 sbin
dr-xr-xr-x  13 root   root     0 Nov 16 08:16 sys
drwxrwxrwt  18 root   root  4096 Nov 16 12:50 tmp
drwxr-xr-x  12 root   root  4096 Nov  8 12:39 usr
drwxr-xr-x  13 root   root  4096 Dec 16  2015 var
dilum@DilumL:/$ cd
dilum@DilumL:~$ pwd
/home/dilum
dilum@DilumL:~$ mkdir test/one/.hidden
mkdir: cannot create directory ‘test/one/.hidden’: No such file or directory
dilum@DilumL:~$ mkdir -p test/one/.hidden
dilum@DilumL:~$ mkdir -p test/one/unhidden
dilum@DilumL:~$ cd test/one
dilum@DilumL:~/test/one$ ls
unhidden
dilum@DilumL:~/test/one$ ls -a
.  ..  .hidden  unhidden
dilum@DilumL:~/test/one$ rmdir unhidden/
dilum@DilumL:~/test/one$ ls -a
.  ..  .hidden
dilum@DilumL:~$ rmdir test
rmdir: failed to remove ‘test’: Directory not empty

Setting UP IP Addresses

Edit /etc/network/interfaces files to include your IP addresses in your PC Get your IP address from the IP table

iface eth0 inet static


    address 192.248.x.x 
    netmask 255.255.255.0
    network 192.248.6.0
    broadcast 192.248.6.255
    gateway 192.248.6.254
    dns-nameservers 192.248.1.161
    dns-search yourdmain 

When you completed the IP settings of the VM, restart and login to confirm correct IP settings.

Note: See TracWiki for help on using the wiki.