Friday, 16 February 2018

How to unzip a zip file using the Linux and Unix bash shell terminal

LPI Tutorials and Materials, LPI Guides, LPI Certifications, LPI Learning

You can use the unzip or tar command to extract (unzip) the file on Linux or Unix-like operating system. Unzip is a program to unpack, list, test, and compressed (extract) files and it may not be installed by default.

Use tar command to unzip a zip file

The syntax is:

tar xvf {file.zip}
tar -xvf {file.zip}

Use the following syntax if you want to extract/unzip to a particular destination directory:

tar xvf {file.zip} -C /dest/directory/
tar -xvf {file.zip} -C /dest/directory/

For example, unzip a zip file named master.zip using tar command:

tar xvf master.zip

To unzip a zip file named master.zip using tar command to a /tmp/data/ directory:

tar xvf master.zip -C /tmp/data/
ls -l /tmp/data/
cd /tmp/data/
ls -l

Sample session:

LPI Tutorials and Materials, LPI Guides, LPI Certifications, LPI Learning

Fig.01: How to use a tar command to unzip a file on Linux/Unix-like terminal

Use unzip command to unzip a zip file

The syntax is:

unzip {file.zip}

Use the following syntax if you want to extract/unzip to a particular destination directory:

unzip -d /dest/directory/ {file.zip}

For example, unzip a zip file named master.zip using zip command:

unzip master.zip

To unzip a zip file named master.zip using zip command to a /tmp/data/ directory:

unzip -d /tmp/data/ master.zip

Sample session:

LPI Tutorials and Materials, LPI Guides, LPI Certifications, LPI Learning

Fig.02: How to unzip a zip file from the Terminal using unzip command

A note about bash: unzip: command not found

If the unzip command NOT installed on your Linux or Unix box, then run any one of the following commands as per your Linux distribution to install the unzip command.

Install unzip on Debian/Ubuntu Linux


Use the apt-get command or apt command to install unzip command:

sudo apt-get install unzip

OR

sudo apt install unzip

Install unzip on Arch Linux


Use the pacman command to install unzip command:

pacman -S unzip

Install unzip on CentOS/RHEL/Scientific/Oracle Linux


Use the yum command to install unzip command:

yum install unzip

Install unzip on Fedora Linux


Use the dnf command to install unzip command:

dnf install unzip

Install unzip on Suse/OpenSUSE Linux


Use the dnf command to install unzip command:

zypper install unzip

Install unzip on FreeBSD unix


To install the unzip port, run:

# cd /usr/ports/archivers/unzip/ && make install clean

To add the package rung pkg command:

# pkg install unzip

Install unzip on OpenBSD unix


Type the following pkg_add command to install unzip package:

# pkg_add -v unzip

Wednesday, 14 February 2018

Creating a high availability setup for Linux on Power

This article describes high availability (HA), disaster recovery (DR), and fail-over for Linux on Power virtual machines (VMs) or logical partitions (LPARs). The solution described in this article works for all Linux distributions available for IBM® POWER8® and later processor-based servers. Open sources used in this solution are Distributed Replicated Block Device (DRBD) and heartbeat, which are available for all supported distributions. We have used Ubuntu v16.04, supported on IBM Power® servers, to explain and verify the solution.

We are using DRBD for this solution, as it is a software-based, shared-nothing, replicated storage solution mirroring the content of block devices (such as hard disks, partitions, logical volumes and so on) between hosts. DRBD mirrors data in real time. Replication occurs continuously while applications modify the data on the device transparently. Mirroring happens synchronously or asynchronously. With synchronous mirroring, applications are notified of write completions after the write operations have been carried out on all (connected) hosts. With asynchronous mirroring, applications are notified of write completions when the write operations have completed locally, which usually is before they have propagated to the other hosts.

Heartbeat is an open source program that provides cluster infrastructure capabilities—cluster membership and messaging - to client servers, which is a critical component in a HA server infrastructure. Heartbeat is typically used in conjunction with a cluster manager, such as DRBD, to achieve a complete HA setup.

This article demonstrates how to create a HA cluster with two nodes by using DRBD, heartbeat, and a floating IP.

Goal


After reading through this article you can successfully set up a HA environment consisting of two Ubuntu 16.04 servers in an active/passive configuration. This can be accomplished by pointing a floating IP, which is how our users will access their services or websites, to point to the primary or active server unless a failure is detected. In the event of a failure, the heartbeat service detects that the primary server is unavailable, and the secondary server will automatically run a script to reassign the floating IP to itself. Thus, subsequent network traffic to the floating IP will be directed to your secondary server, which will act as the active server until the primary server becomes available again (at which point, the primary server will reassign the floating IP to itself. We can disable the primary node to take over the role by disabling the Auto Fallback option).

Requirement


We need the following setup to be in place before we proceed with failover:

◈ Two servers/VMs installed with Ubuntu 16.04 installed. These will act as the primary and secondary servers for the application and web services.
◈ One floating IP that will act as IP for the application and web services
◈ One additional disk for each VMs, for installing the application and web services. Need not be shared.

Installing DRBD


First, we need to install DRBD on both the servers and create resource groups on free disks, which need not be shared between VMs. In this way, we can use local disks also for this solution and storage area network (SAN) disks are not required.

We can install DRBD packages along with its dependent packages. You need to run the following commands to install DRBD on the servers.

apt-get install drbd* -y

Figure 1. Install DRBD

LPI Certification, LPI Guides, LPI Tutorials and Materials, LPI Learning, Linux

apt-get install "linux-image-extra-`uname -r`"

This is a dependent package to enable the kernel module of DRBD

Figure 2. Install kernel extra packages

LPI Certification, LPI Guides, LPI Tutorials and Materials, LPI Learning, Linux

Installing heartbeat


The next step is to install heartbeat on both servers. The simplest way to install heartbeat is to use the apt-get command.

apt-get install heartbeat

Figure 3. Install heartbeat package

LPI Certification, LPI Guides, LPI Tutorials and Materials, LPI Learning, Linux

After successfully installing the heartbeat package, you need to configure it for high availability.

Now that we have installed the packages required for DRDB and HA, we can begin with DR and HA configuration. First, we will configure DRBD and then configure heartbeat.

Configuring DRBD


To configure DRBD, you need a storage resource (a disk, directory, or a mount point), which will be defined as a DRBD resource group (in our example referred as r0). This resource contains all the data, which need to be moved from the primary to the secondary node when failover happens.

We need to define the resource group r0, under the /etc/drbd.d/r0.res file. The r0.res file should look as shown below:

resource r0 {
     device    /dev/drbd1;
     disk      /dev/sdc;
     meta-disk internal;
     on drbdnode1 {
          address   172.29.160.151:7789;
     }
     on drbdnode2 {
          address   172.29.160.51:7789;
     }
}

We need to define the resource as a device name /dev/drbd1, and in our case, we are using a disk, /dev/sdc, as the storage device. Note that all the nodes involved in HA setup (in our case 2), need to be defined in the r0.res file.

After the file is created on both the participating nodes, we need to run the following command. In our example, we are making drbdnode1 as primary node and drbdnode2 as backup node initially. So, whenever drbdnode1 fails, drbdnode2 should take over as the primary.

Run the following command on both nodes.

modprobe drbd
/etc/init.d/drbd start

Figure 4. Creating kernel module for DRBD

LPI Certification, LPI Guides, LPI Tutorials and Materials, LPI Learning, Linux

Now, initialize the r0 resource group on drbdnode1 using the following command:

drbdadm create-md r0

Figure 5. Creating metadata

LPI Certification, LPI Guides, LPI Tutorials and Materials, LPI Learning, Linux

Then, define drbdnode1 as the primary node and drbdnode2 as the secondary node by running the following commands on the respective nodes:

drbdadm primary r0
drbdadm secondary r0

Figure 6. Overview of primary node

LPI Certification, LPI Guides, LPI Tutorials and Materials, LPI Learning, Linux

Figure 7. Overview of secondary node

LPI Certification, LPI Guides, LPI Tutorials and Materials, LPI Learning, Linux

After, setting the nodes as primary and secondary, start the drbd resource group. We need to do this to make the drbd resource active and ready-to-use.

Create a file system on the primary node using the following command:

root@drbdnode1:~# mkfs.ext4 /dev/drbd1

Then, mount the disk on the primary node.

root@drbdnode1~# mount /dev/drbd1 /data

Figure 8. Check if file system is mounted

LPI Certification, LPI Guides, LPI Tutorials and Materials, LPI Learning, Linux

Now, we completed DRBD configuration. Next, we need to configure heartbeat. We need heartbeat to automate our failover, in case of any disaster.

Configuring heartbeat


In order to get the required cluster up and running, we must set up the following heartbeat configuration files in /etc/ha.d, identically on both servers:

◈ ha.cf: Contains the global configuration of the heartbeat cluster, including its member nodes. This file is needed to make both the nodes aware of the network interfaces and the floating IP that need to be monitored for heartbeat purpose.
◈ authkeys: Contains a security key that provides nodes a way to authenticate to cluster.
◈ haresources: Specifies the services that are managed by the cluster and the node that is the preferred owner of the services. Note that this file is not used in a setup that uses a DRBD resource group.

Create the ha.cf file

On both servers, open /etc/ha.d/ha.cf:

vi /etc/ha.d/ha.cf

We need to add the details of each node in our cluster as shown in Figure 9.

Figure 9. Review ha.cf file

LPI Certification, LPI Guides, LPI Tutorials and Materials, LPI Learning, Linux

Next, we'll set up the cluster's authorization key.

Create the authkeys file

The authorization key is used to allow cluster members to join a cluster. We can just generate a random key for this purpose.

On the primary node, run the following commands to generate a suitable authorization key in an environment variable, named AUTH_KEY:

if [ -z "${AUTH_KEY}" ]; then
  export AUTH_KEY="$(command dd if='/dev/urandom' bs=512 count=1 2>'/dev/null' \
      | command openssl sha1 \
      | command cut --delimiter=' ' --fields=2)"
fi

Then create the /etc/ha.d/authkeysfile using the following commands:

auth1
1 sha1 $AUTH_KEY

Figure 10. Generating authkeys

LPI Certification, LPI Guides, LPI Tutorials and Materials, LPI Learning, Linux

Ensure that the file is only readable by root user:

chmod 600 /etc/ha.d/authkeys

Now, copy the /etc/ha.d/authkeys file from your primary node to your secondary node.

On the secondary server, make sure to set the permissions of the authkeys file:

chmod 600 /etc/ha.d/authkeys

Both servers should have an identical /etc/ha.d/authkeys file.

Create the haresources file

The haresources file should contain details of hosts participating in the cluster. The preferred host is the node that should run the associated services if the node is available. If the preferred host is not available, that is, it is not reachable by the cluster, one of the other nodes will take over. In other words, the secondary server takes over if the primary server goes down.

On both servers, open the haresources file in your favorite editor. We'll use vi.

vi /etc/ha.d/haresources

Now add the following line to the file, substituting in your primary node's name:

primary floatip

This configures the primary server as the preferred host for the floatip service, which is currently undefined.

Figure 11. Review haresources file

LPI Certification, LPI Guides, LPI Tutorials and Materials, LPI Learning, Linux

Configuring floating IP

Now we will configure floating IP on the primary VMs, where we will have the service running for the first time. Floating IP should only be active on one server at a time. This IP is where we are going to host our application or webservice and in case of a failover, we will be moving this IP to another server. In the following example, we will configure the floating IP on drbdnode1 and in case of failover, it will need to move to drbdnode2.

ifconfig ibmeth0:0 9.126.160.53 netmask 255.255.192.0 up

Figure 12. Confirm floating IP is assigned

LPI Certification, LPI Guides, LPI Tutorials and Materials, LPI Learning, Linux

Testing high availability


The next step is to start DRBD and heartbeat services one after the other one, in the following order.

Run the following command on the primary node:

drbdadm primary r0

Run the following command on the secondary node:

drbdadm secondary r0

Start heartbeat services on both cluster nodes using the following command:

service heartbeat start

Now to check for primary and secondary VMs, run the drbd-overview command on both the VMs.

Figure 13. Check DRBD status

LPI Certification, LPI Guides, LPI Tutorials and Materials, LPI Learning, Linux

After completing the primary and secondary set up, and verifying that our services are working as intended, initiate the failover test.

You can perform the failover test in the following scenarios:

◈ Reboot primary node using reboot or shutdown –r command.
◈ Halt primary node using halt command.
◈ Stop the heartbeat service on the primary node using the service heartbeat stop command.

After running one of these scenarios, you should monitor the fail over using the drbd-overview command, and within a few seconds, you can notice that the secondary node has taken over the primary role, and all the services are up on this node. Your floating IP will also be moved along with fail over of the services.

Figure 14. Successful fail over

LPI Certification, LPI Guides, LPI Tutorials and Materials, LPI Learning, Linux

Figure 14 shows that drbdnode2 has taken over as the primary node, and this indicates successful failover.

Sunday, 11 February 2018

How To Display The Date And Time Using Linux Command Line

Linux Command Line, LPI Tutorials and Materials, LPI Certifications, LPI Guides, LPI Learning

In this guide, I will show you how to print the date and time using the Linux command line in various formats.

How To Display The Date And Time


You could probably have guessed the command to display the date and time using the Linux command line. It is quite simply this:

date

By default the output will be something like this:

Wed Apr 20 19:19:21 BST 2016

You can get the date to display any or all of the following elements:

◈ %a - abbreviated day name (i.e. mon, tue, wed)
◈ %A - full day name (i.e. Monday, Tuesday, Wednesday)
◈ %b or %h - abbreviated month name (i.e. jan, feb, mar)
◈ %B - full month name (January, February, March)
◈ %c - locales date and time (full date and time)
◈ %C - short year (i.e 14, 15, 16)
◈ %d - day of month (i.e. 01, 02, 03)
◈ %D - same as M/D/Y (i.e. 04/20/16)
◈ %e - day of month padded (i.e. ' 1', ' 2')
◈ %F - full date, same as yyyy-mm-dd
◈ %H - hour (00, 01, 02, 21, 22, 23)
◈ %I - hour (1,2,3,10,11,12)
◈ %j - day of year (i.e. 243)
◈ %k - hour padded (i.e. '1' becomes ' 1')
◈ %l - hour padded (12 hour clock)
◈ %m - month number (1,2,3)
◈ %M - minute (1,2,3,57,58,59)
◈ %n - new line
◈ %N - nanoseconds
◈ %p - AM or PM
◈ %P - like %p but lowercase (ironically)
◈ %r - locales 12 hour clock time
◈ %R - 24 hour version of hour and minute
◈ %s - seconds since 1970-01-01 00:00:00
◈ %S - second (01,02,03, 57, 58, 59)
◈ %t - a tab
◈ %T - time same as %H:%M:%S
◈ %u - day of week (1 is Monday, 2 is Tuesday etc)
◈ %U - week number of year (assuming Sunday as first day of the week)
◈ %V - ISO week number with Monday as the first day of the week
◈ %w - day of week (0 is Sunday)
◈ %W - week number of the year with Monday as the first day of the week
◈ %x - locales date representation (12/31/2015)
◈ %X - locales time representation (14:44:44)
◈ %y - last two digits of year
◈ %Y - year
◈ %z - numeric time zone (i.e. -0400)
◈ %:z - numeric time zone as follows (i.e. -04:00)
◈ %::z - numeric time zone as follows (i.e. -04:00:00)
◈ %Z - alphabetic time zone abbreviation (GMT)
◈ - - a single hyphen prevents zero padding
◈ _ - a single underscore pads with spaces
◈ 0 - pads with zeroes
◈ ^ - use uppercase if possible
◈ # - use opposite case if possible

That is a huge number of options and I suspect the date command is the one most people try to add something to when they first want to contribute to Linux and compile their first program.

Essentially if you want to display just the time you can use the following:

date +%T

This will output 19:45:00. (i.e. hours, minutes then seconds)

You can also achieve the above by using the following:

date +%H:%M:%S

You can attach the date as well using the above command:

date +%d/%m/%Y%t%H:%M:%S

Basically you can use any combination of the above switches after the plus symbol to output the date as you so wish. If you want to add spaces you can use quotes around the date.

date +'%d/%m/%Y %H:%M:%S'

How To Show The UTC Date

You can view the UTC date for your computer using the following command:

date -u

If you are in the UK you will notice that instead of showing "18:58:20" as the time it will show "17:58:20" as the time.

How To Show The RFC Date

You can view the RFC date for your computer using the following command:

date -r

This displays the date in the following format:

Wed, 20 Apr 2016 19:56:52 +0100

This is useful as it shows that you are an hour ahead GMT.

Some Useful Date Commands

Do you want to know the date next Monday? Try this out:

date -d "next Monday"

At the point of writing this returns "Mon 25 Apr 00:00:00 BST 2016"

The -d basically prints a date in the future.

Using the same command you can find out which day of the week your birthday or Christmas is on.

date -d 12/25/2016

The result is Sun Dec 25.

Friday, 9 February 2018

Example Uses of the Linux Command FTP

Linux Command, FTP, LPI Certifications, LPI Guides, LPI Tutorials and Materials

FTP is the simplest and most familiar file transfer protocol that exchanges files between a local computer and a remote computer or network. Linux and Unix operating systems have built-in command line prompts you can use as FTP clients for making an FTP connection.

Warning: An FTP transmission is not encrypted. Anyone who intercepts the transmission can read the data you send, including your username and password.

For a secure transmission, use SFTP.

Establish an FTP Connection


Before you can use the various FTP commands, you must establish a connection with the remote network or computer. Do this by opening a terminal window in Linux and typing ftp followed by a domain name or an IP address of the FTP server, such as ftp 192-168-0-1 or ftp domain.com. For example:

ftp abc.xyz.edu

This command attempts to connect to the ftp server at abc.xyz.edu. If it succeeds, it asks you to log in using a username and password. Public FTP servers often allow you to log in using the username anonymous and your email address as a password or with no password at all.

When you log in successfully, you see an ftp> prompt on the terminal screen. Before you go any further, get a list of the available FTP commands using the help function. It is useful because depending on your system and software, some of the FTP commands listed here may or may not work.

FTP Command Examples and Descriptions


The FTP commands used with Linux and UNIX differ from the FTP commands used with the Windows command line. Here are examples that illustrate typical uses of the Linux FTP commands for remotely copying, renaming, and deleting files.

 ftp> help

The help function lists the commands that you can use to show the directory contents, transfer files, and delete files.

The command ftp> ? accomplishes the same thing.

 ftp> ls

This command prints the names of the files and subdirectories in the current directory on the remote computer.

ftp> cd customers

This command changes the current directory to the subdirectory named customers, if it exists.

 ftp> cdup

This changes the current directory to the parent directory.

 ftp> lcd [images]

This command changes the current directory on the local computer to images, if it exists.

 ftp> ascii

This changes to ascii mode for transferring text files. ASCII is the default on most systems.

 ftp> binary

This command changes to binary mode for transferring all files that are not text files.

 ftp> get image1.jpg

This downloads the file image1.jpg from the remote computer to the local computer. Warning: If there already is a file on the local computer with the same name, it is overwritten.

 ftp> put image2.jpg

Uploads the file image2.jpg from the local computer to the remote computer. Warning: If there already is a file on the remote computer with the same name, it is overwritten.

 ftp> !ls

Add an exclamation mark in front of a command executes the specified command on the local computer. So !ls lists the file names and directory names of the current directory on the local computer.

 ftp> mget *.jpg

With the mget command. you can download multiple images. This command downloads all files that end with .jpg.

ftp> rename [from] [to]

The rename command changes the file named [from] to the new name [to] on the remote server.

ftp> put local-file [remote-file]

This command stores a local file on the remote machine. Send local-file [remote file] does the same thing.

 ftp> mput *.jpg

This command uploads all the files that end with .jpg to the active folder at the remote machine.

ftp> delete remote-file

Delete the file named remote-file on the remote machine.

 ftp> mdelete *.jpg

This deletes all files that end with .jpg in the active folder on the remote machine.

ftp> size file-name

Determine the size of a file on the remote machine with this command.

ftp> mkdir [directory-name]​

Make a new directory on the remote server.

 ftp> prompt

The prompt command turns interactive mode on or off so that commands on multiple files are executed without user confirmation.

 ftp> quit

The quit command terminates the FTP session and exits the FTP program. The commands bye and exit accomplish the same thing. 

Sunday, 4 February 2018

Run Ubuntu Within Windows Using VirtualBox

LPI Tutorials and Materials, LPI Certifications, LPI Guides, LPI Learning

Windows users looking to use Linux for the first time will find it beneficial to try it out in a virtual machine. There is plenty of great virtual machine software available on the market.

The pros for installing Linux in a virtual machine include:

◈ The ability to try a version of Linux without affecting the Windows host machine
◈ The virtual Linux operating system will perform the same way as it would when installed to the physical hard drive
◈ Software installed into the virtual machine remains intact and can be used even after a reboot.
◈ The virtual machines can be backed up and restored easily so if you mess up it isn't so much of an issue

For this guide, I have chosen Ubuntu as it is one of the most popular and easy to use Linux distributions. 

Install Oracle Virtual Box


LPI Tutorials and Materials, LPI Certifications, LPI Guides, LPI Learning

In order to follow this guide, you will need to download Ubuntu (either 32-bit or 64-bit depending on your machine)  and Virtualbox.

NOTE: If you are using Windows 10 you would be better off following this guide to running Ubuntu within Windows 10.

Install VirtualBox

Navigate to the downloads folder on your computer and double click the VirtualBox installer.

1. The first screen is a welcome screen. Click Next to move on.
2. You will be asked which components you wish to install. I recommend leaving the default options selected.
3. Click Next to go to the Custom Setup screen.
4. Choose which folder you want VirtualBox to appear in using the Windows menu structure.
5. Click Next.
6. At this point you can choose whether to create a desktop shortcut or not.
7. Click Next and you are taken to the Network Warning screen.
8. You are now ready to install Oracle VirtualBox. Click Install to start the installation.
9. During the installation, you may be asked for permission to install the application and your antivirus and firewall software may request permission to install VirtualBox. Be sure to allow those permissions.

Start VirtualBox

Leave the Start Oracle VM VirtualBox after Installation option checked to run Oracle Virtualbox when the installation is complete.

Click Finish to complete the installation.

If you left all the default options checked during installation you will also be able to run VirtualBox by clicking the desktop icon.

Oracle VirtualBox works on all versions of Microsoft Windows from Windows XP upwards including Windows 8.

Create A Virtual Machine


LPI Tutorials and Materials, LPI Certifications, LPI Guides, LPI Learning

Oracle VirtualBox has a lot of options and it is worth exploring all of these and reading the help guide but for the sake of this tutorial click the New icon on the toolbar.

The first thing you need to do is define the type of virtual machine you wish to create.

1. Enter a descriptive name into the Name box.
2. Select Linux as the Type.
3. Choose Ubuntu as the Version.
4. Click Next to continue.

Note: Make sure you choose the correct version. You must choose 32-bit if your host computer is a 32-bit machine. If you are using a 64-bit machine you can choose either 32-bit or 64-bit but obviously 64-bit is recommended

Allocate Memory To The Virtual Machine

The next screen asks you to set how much memory you wish to give over to the virtual machine.

You should not go below the minimum specified and you should also make sure you leave enough memory for the host operating system (Windows) to keep running.

512 megabytes will run sluggishly and if you have enough memory I recommend increasing the bar to 2048 megabytes.

Create A Virtual Hard Drive

The next three steps are all about allocating disk space to the virtual machine.

If you want to run Ubuntu as a live image then you do not need to create a hard drive at all but for installing Ubuntu you will need to.

1. Select Create a virtual hard drive now.
2. Click "Create"
3. You will be asked to select the type of hard drive to create. The default VDI file type is the one native to VirtualBox, so select VDI.
4. Click Next.
When deciding on the way the hard drive is created you can choose to opt for a fixed size hard drive or a dynamically sized hard drive.

It is important to note at this point that no partitioning occurs on your actual hard drive. All that happens is that a file is created on your computer which acts as the hard drive.

A fixed sized disk creates the hard drive to be the maximum size you define straight away whereas a dynamically sized disk adds space to the file as it is required up to the maximum size that you specify.

A fixed sized disk performs better because as you install software within the virtual machine it doesn't have to increase the file size on the fly. If you have enough disk space then I recommend this option.

1. Select your desired hard drive type.
2. Click Next.
3. After specifying the hard drive type and the way the disk is allocated you are asked to specify how much disk space you are going to give over to the Ubuntu Virtual Machine.Do not go below the minimum set and create enough disk space to make it worthwhile. I recommend at least 15 gigabytes.
4. Choose where you wish to save the virtual machine.
5. Specify the disk size.
6. Click Create.

Start The Virtual Machine

The Virtual Machine has now been created and you can start it by pressing the Start button on the toolbar.

The first boot requires you to select a start up disk.

◈ Click the folder icon.
◈ Navigate to the downloads folder and select Ubuntu ISO.
◈ Click Start.

Install Ubuntu Within VirtualBox


LPI Tutorials and Materials, LPI Certifications, LPI Guides, LPI Learning

Ubuntu will now boot into a live version of the operating system and a welcome message appears.

You will be asked to select your language and you will be able to choose whether to Try Ubuntu or Install Ubuntu.

If you decide to try Ubuntu first you can always run the installer by double clicking on the Install icon on the Ubuntu desktop.

Choose Your Installation Language

Now we are into the nitty gritty of installing Ubuntu.

The first step is to choose the installation language.

1. Choose a language.
2. Click Continue.
3. A screen appears showing how prepared you are for installing Ubuntu. If you are using a laptop make sure your computer is either plugged in or has enough battery life. I recommend you connect to a power source especially if you plan on installing updates as you go.
4. There are two checkboxes at the bottom of the screen. Choose whether to install updates as you go.
5. Then choose whether to install 3rd party software.

NOTE: If you have a fast enough internet connection it is worth updating as you go but if you don't I would recommend installing Ubuntu and updating later.

I would also recommend not installing the 3rd party software at this stage. This can be done post installation.

6. Click Continue.

Partitioning A Virtual Hard Drive


LPI Tutorials and Materials, LPI Certifications, LPI Guides, LPI Learning

The Installation Type screen asks you how you wish to partition the hard drive.

When installing on a real hard drive this step causes people anguish. Do not panic though as this will only touch your virtual hard drive and will not affect Windows in any way whatsoever.

1. Select Erase disk and install Ubuntu.
2. Click Install Now.
3. The installation begins and the files are copied to the virtual hard drive.

Choose Your Locations

Whilst this is going on you will be asked to choose your location. This sets the timezone for Ubuntu and makes sure the all important clock shows the right value.

1. Click the map to choose your location.
2. Click Continue.

Choose Your Keyboard Layout

A final couple of steps require you to choose your keyboard layout and create a user.

1. Choose the language for your keyboard.
2. Choose the type of keyboard.
3. Click Continue.

Create A User

From the Who are you screen:

◈ Enter your name.
◈ Choose a name for your virtual machine.
◈ Enter a username.
◈ Add a password and repeat the password.
◈ Choose whether you want to log in automatically or require a login.
◈ Choose whether to encrypt the home folder.
◈ Click Continue.

Completing The Installation

The final stage is to wait for the files to finish copying and the installation to complete.

When the process is complete you will be asked to reboot. This, of course, refers to the virtual machine and not your host Windows machine.

You can reboot in a number of ways such as clicking the icon in the top right corner of Ubuntu and choosing to restart or by using the reset option from the VirtualBox menu.

Install Guest Additions


LPI Tutorials and Materials, LPI Certifications, LPI Guides, LPI Learning

Install Guest Additions

You will notice that if you choose to view Ubuntu in full-screen mode that it doesn't necessarily scale correctly.

To get the best experience possible you will need to install Guest Additions.

This is a simple process: 

1. Just select Devices.
2. Then choose Install Guest Additions from the menu while running the virtual machine.
3. A terminal window will open and commands will run. When it has completed you will need to restart the virtual machine again.

Ubuntu is now good to go.

Thursday, 1 February 2018

Example uses of the Linux command "tar"

Introduction


In essence, a tar file is a method of creating an archive file which contains many other files.

Imagine you have a folder structure with files in it that you want to copy from one computer to another. You could write a script which performs the copy and places all the files in the correct folders on the destination machine.