Professional Documents
Culture Documents
Installing Ubuntu On Virtual Box or Vmware: System Configuration of The Host Machine
Installing Ubuntu On Virtual Box or Vmware: System Configuration of The Host Machine
In order to install Ubuntu on Virtual Box, you should have a physical computer with at
least 4 GB of RAM (Random Access Memory), a hard disk drive with at least 30 GB of free
space (SSD is preferred due to its higher performance). Your CPU (Central Processor
Unit) must support Intel VT-x or AMD-v hardware virtualization features which must also
be enabled in UEFI/BIOS. This point is especially important if you are looking for how to
install Ubuntu 64-bit on Virtual Box.
Virtual Box
Virtual Box is a free, open-source and cross-platform software that lets you create,
run, and manage virtual machines on your system. Virtual Box was originally
developed by Innotek GmbH and released in 2007. The company was later bought by
Sun Microsystems. With Oracle VM VirtualBox you can create one or more VMs on a
single physical server. Virtual machines are computers that use the hardware
components of the host computer, each running its own operating system. VB
supports the installation of MS Windows, Linux, BDS, and MS-DOS on the installed
VMs.
TYBCA Linux
Open the Virtual Box EXE file. Go to the location to which the EXE file downloaded
and double-click the file. Doing so will open the Virtual Box installation window.
Navigate through the installation prompts.
Click next on the first three pages.
Click yes when prompted.
Click Install
Click yes when prompted.
TYBCA Linux
Downloading the Installation Image
You need to download the Ubuntu distribution for installing Ubuntu on
VirtualBox. Go to the official Ubuntu website and download the necessary
version of the Ubuntu installer. Let’s download Ubuntu 20.04.2.0 LTS – this is the
latest long term support (LTS) Ubuntu version available at this moment. Five-
year support is provided for Ubuntu LTS distributions (both Ubuntu Desktop and
Ubuntu Server). Ubuntu LTS is more widely tested, enterprise-focused and
compatible with new hardware.
Click the green Download button and save the ISO file to the custom location. In
our case, the file name is ubuntu-20.04.2.0-desktop-amd64.iso. Ubuntu 18 is
provided only as 64-bit editions.
TYBCA Linux
6. Enter a name for your virtual machine. Type whatever you want to name your
virtual machine (e.g., Ubuntu) into the "Name" text field that's near the top of
the pop-up menu.
7. Select Linux as the "Type" value. Click the "Type" drop-down box, then
click Linux in the resulting drop-down menu.
8. Select Ubuntu as the "Version" value. Ubuntu should be selected by default
after you set the "Type" value to Linux, but if it isn't, click the "Version" drop-
down box and click Ubuntu (64-bit) before proceeding.
TYBCA Linux
10. Click Next. It's at the bottom of the menu.
11. Create your virtual machine's virtual hard drive. The virtual hard drive is a
section of your computer's hard drive space which will be used to store your
virtual machine's files and programs:
Click Create
Click Next
Click Next
Select an amount of space to use.
Click Create
TYBCA Linux
Installing Ubuntu
1. Select your new virtual machine and click 'Settings' button.
2. Click on 'Storage' category and then 'Empty' under Controller:IDE. Click "CD/DVD"
icon on right hand side and select the ubuntu ISO file to mount.
12.
TYBCA Linux
3. Click Start button.
TYBCA Linux
5. Once the new VM is prepared for installing Ubuntu on VirtualBox, start the VM
(Machine > Start). The VM boots from the ISO Ubuntu installation image. The first
screen that you can see after booting is the Welcome screen.
TYBCA Linux
6. Keyboard layout. Choose your keyboard layout. Let’s select English (US).
7. Updates and other software. There are a few options to choose from on this
screen.
Normal installation. A web browser, utilities, office applications and media players
are installed.
Minimal installation. Only the main components including a web browser and basic
utilities are installed.
Let’s select the normal installation.
8. Installation type. This screen contains options for preparing a disk for Ubuntu
installation.
Erase disk and install Ubuntu. This is the default option. All disk space will be
automatically allocated to Ubuntu. If you select Erase disk and install Ubuntu on
VirtualBox VMs, one big /dev/sda1 partition is created on /dev/sda.
This /dev/sda1 partition with ext4 file system is mounted to the / directory (root
directory), though a separate swap partition is not created. Attention: All data on
the virtual disk will be erased—there is no reason to worry about it, however,
because an empty virtual disk created previously is being used for installing
Ubuntu on VirtualBox.
9. Setting up Ubuntu
Select a time zone.
Enable the on-screen keyboard
Enable the on-screen keyboard
Enter your name, enter a username, and create a password.
Wait for Ubuntu to finish installing.
Restart the virtual machine.
Log into your computer.
TYBCA Linux
TYBCA Linux
2. Basic Linux Commands
1. ls
Directory listing
2. ls –al
Formatted listing with hidden filesDirectory listing
3. cd dir
Change directory to dir
TYBCA Linux
4. ls -lt
Sorting the Formatted listing by time modification
6. Cd
Change to home directory
5. pwd
Show current working directory
TYBCA Linux
7. mkdir dir
Creating a directory dir
8. cat >file
Places the standard input into the file
9. more file
Output the contents of the file
TYBCA Linux
10. head file
Output the first 10 lines of the file
TYBCA Linux
12. tail -f
file Output the contents of file as it grows,starting with the last
10 lines
TYBCA Linux
14. touch file
Create or update file
13. rm file
Deleting the file
TYBCA Linux
15. rm -r dir
Deleting the directory
16. rm -f file
Force to remove the file
TYBCA Linux
19. cp -r dir1 dir2
Copy dir1 to dir2;create dir2 if not present
20.date
Show the current date and time
21. cal
Show this month's calender
22. uptime
Show current uptime
23.w
Display who is on line
24.whoami
Who you are logged in as
TYBCA Linux
26.uname -a
show kernel information
27. cat /proc/cpuinfo
cpu information
28.man command
show the manual for command
TYBCA Linux
TYBCA Linux
3. Advance Linux Commands
1. ps
To display the currently working processes
2. top
Display all running process
TYBCA Linux
3. kill pid
Kill the process with given pid
4. File permission
chmod octal file
Change the permission of file to octal,which can be found
separately for user,group,world by adding,
• 4-read(r)
• 2-write (w)
• 1-execute(x)
TYBCA Linux
5. Searching
grep pattern file
Search for pattern in file
TYBCA Linux
8. locate file
Find all instances of file
9. find . -name
filename Searches in the current directory (represented by a
period) and below it, for files and directories with names
starting with filename
TYBCA Linux
4. Install and work with c & c++
Requirements
Privileged access to your Ubuntu System as root or via sudo command is
required.
Conventions
# - requires given linux commands to be executed with root privileges either
directly as a root user or by use of sudo command
$ - requires given linux commands to be executed as a regular non-
privileged user
The second step would be to type the command: sudo apt -get install g+
+. It is important to note that g++ is the name of the C++ compiler.
TYBCA Linux
If you have the permission to install the g++ compiler, a set of statements
like this would appear. The installation would automatically begin.
You would get a message: “Do you want to continue?” Press ‘y’ in order to
continue. This is what your screen would look like after you press ‘y’.
TYBCA Linux
check the version of C++
The following command would help you find out the version of the g++ compiler
that you processed to install C++.
g++ — version
TYBCA Linux
compile and run C++ program
We have now created a C++ program with the program name as test.cpp. It is now
time to run and compile and run the code using the terminal.
The ‘g++’ command will help you throughout your coding journey. It is a very
important command that comes pre-installed on your latest Ubuntu version.
TYBCA Linux
Here, the g++ command is followed by the file name with the .cpp extension and ‘-
o’ and the name of the executable file, which is, ‘program’ in this case.
Key takeaway: The executable file name can be different from the source file
name
To run the program, use the command:
./program
Here, the period symbol ‘.’ followed by a backslash is followed by the name of the
executable file, that is, ‘program’ in this case.
TYBCA Linux
Compile the C program with gcc Compiler
In your Terminal, enter the following command in order to make an executable
version of the program you have written:
Syntax:
Example:
$ ./programName
Example:
$ ./text2
TYBCA Linux
5. Working with Vi, nano, gedit editors.
Command:vi filename
Eg:vi my_file.txt
TYBCA Linux
Nano Editor
explain the basic usage of the nano editor, including how to create and open a
file, edit a file, save a file, search and replace text, cut and paste text, and more.
To create new file
When you decide to exit (Ctrl+X), it will ask whether to save or discard the file.
If you press y to save the file, it will ask you to name the file. Type in a name and
press Enter.
Syntax: nano [filename]
Output :
TYBCA Linux
gedit
Text Editor (gedit) is the default GUI text editor in the Ubuntu operating system.
It is UTF-8 compatible and supports most standard text editor features as well
as many advanced features. These include multilanguage spell checking, extensive
support of syntax highlighting, and a large number of official and third party
plugins.
gedit is suited for both basic and more advanced text editing and is released
under the GNU General Public License.
Opening gedit
gedit incorporates a graphical user interface (GUI) and is opened by going
to Applications → Accessories → Text Editor or by pressing Alt+F2 and
typing gedit
TYBCA Linux
6. Working with file and directories permissions
1. Locate the file you want to examine, right-click on the icon, and select Properties.
3. There, you’ll see that the permission for each file differs according to three
categories:
TYBCA Linux
Check Permissions in Command-Line with Ls Command
If you prefer using the command line, you can easily find a file’s permission settings
with the ls command, used to list information about files/directories. You can also
add the –l option to the command to see the information in the long list format.
To check the permission configuration of a file, use the command:
ls –l [file_name]
For instance, the command for the previously mentioned file would be:
ls –l raj.txt
As seen in the image above, the output provides the following information:
file permission
1. File type. There are three possibilities for the type. It can either be a regular file
TYBCA Linux
The characters r, w, and x stand for read, write, and execute.
The categories can have all three privileges, just specific ones, or none at all
(represented by –, for denied).
Users that have reading permission can see the content of a file (or files in a
directory). However, they cannot modify it (nor add/remove files in a directory). On
the other hand, those who have writing privileges can edit (add and remove) files.
Finally, being able to execute means the user can run the file. This option is mainly
used for running scripts.
1. using symbols (alphanumerical characters)
Type the initial letter for each class, followed by the equal sign (=) and the first letter
of the read (r), write (w) and/or execute (x) privileges.
To set a file, so it is public for reading, writing, and executing, the command is:
TYBCA Linux
Use the following command:
Another way to specify permission is by using the octal/numeric format. This option is
faster, as it requires less typing, although it is not as straightforward as the previous
method.
The privileges are summed up and depicted by one number. Therefore, the
possibilities are:
7 – for read, write, and execute permission
6 – for read and write privileges
5 – for read and execute privileges
4 – for read privileges
As you have to define permission for each category (user, group, owner), the
command will include three (3) numbers (each representing the summation of
privileges).
For instance, let’s look at the test.txt file that we symbolically configured with
the chmod u=rw,g=r,o=r test.txtcommand.
The same permission settings can be defined using the octal format with the
command:
TYBCA Linux
TYBCA Linux
7. Shell Scripting
Shell Scripting is an open-source computer program designed to be run by the
Unix/Linux shell. Shell Scripting is a program to write a series of commands for the
shell to execute. It can combine lengthy and repetitive sequences of commands into
a single and simple script that can be stored and executed anytime which, reduces
programming efforts.
What is Shell?
Shell is a UNIX term for an interface between a user and an operating system service.
Shell provides users with an interface and accepts human-readable commands into
the system and executes those commands which can run automatically and give the
program’s output in a shell script.
An Operating is made of many components, but its two prime components are –
Kernel
Shell
Types of Shell
There are two main shells in Linux:
1. The Bourne Shell: The prompt for this shell is $ and its derivatives are listed below:
2. The C shell: The prompt for this shell is %, and its subcategories are:
TYBCA Linux
How to Write Shell Script in Linux/Unix
Shell Scripts are written using text editors. On your Linux system, open a text editor
program, open a new file to begin typing a shell script or shell programming, then give
the shell permission to execute your shell script and put your script at the location from
where the shell can find it.
"#!" is an operator called shebang which directs the script to the interpreter location. So,
if we use"#! /bin/sh" the script gets directed to the bourne-shell.
#!/bin/sh
ls
TYBCA Linux
Adding shell comments
Commenting is important in any program. In Shell programming, the syntax to add a
comment is
#comment
Let’s create
TYBCA Linux
Shell Variables
As discussed earlier, Variables store data in the form of characters and numbers.
Similarly, Shell variables are used to store information and they can by the shell only.
For example, the following creates a shell variable and then prints it:
variable ="Hello"
echo $variable
#!/bin/sh
echo "what is your name?"
read name
echo "How do you do, $name?"
read remark
echo "I am $remark too!"
TYBCA Linux
TYBCA Linux
8. Working with loops and conditional statements
TYBCA Linux
for statement
The for loop operate on lists of items. It repeats a set of commands for every item
in a list.
Here var is the name of a variable and word1 to wordN are sequences of
characters separated by spaces (words). Each time the for loop executes, the
value of the variable var is set to the next word in the list of words, word1 to wordN.
Syntax
TYBCA Linux
until statement
The until loop is executed as many as times the condition/command evaluates to false.
The loop terminates when the condition/command becomes true.
Syntax
until command
do
Statement to be executed until command is true
done
TYBCA Linux
Conditional Statements: There are total 5 conditional statements which can be used
in bash programming
1. if statement
2. if-else statement
3. if..elif..else..fi statement (Else If ladder)
4. if..then..else..if..then..fi..fi..(Nested if)
5. switch statement
Their description with syntax is as follows:
if-else statement
If specified condition is not true in if part then else part will be execute.
Syntax
if [ expression ]
then
statement1
else
statement2
fi
TYBCA Linux