You are on page 1of 10

Lab Assignment:- 1

Introduction to Linux and its


Command Line Interface
Operating System

Aayush Neelkanth
18/11/EC/048
BTech CSE
21703772
1. Install the latest version of the Ubuntu Linux either through dual boot or
virtual machine.

2. Observe the installation process and search on the Internet about the
different technical terms faced during installation. For example, what is
swap, and why and how much space should be reserved for swap, etc. Write
your observation.

● Swap:- Area of hard disk that the linux kernel uses as a temporary memory
storage area. Linux differs from Windows in that it usually requires a separate
hard disk partition in which to store files.
● SDA :- sd stands for SCSI disk i.e., Small computer System Interface disk. Sda
means the first SCSI hard disk.
● Partition:- Subdivision of hard disk into which the file system can be installed.
● BIOS:- Basic Input/Output System checks some system integrity and finds and
executes the boot loader or we can say executes the MBR.
● UEFI:- Unified Extensible Firmware Interface is a standard interface that connects
a computer firmware to its Operating System. UEFI is expected to replace BIOS in
the upcoming time.
● MBR:- Master Boot Record contains the information regarding GRUB and it
executes the GRUB loader.
● GRUB:- Grand Unified Bootloader displays a screen and waits for a few seconds if
the ṣuser does not respond to anything it selects the default kernel selected. So it
basically executes the Kernel
● SATA:- Serial Advanced Technology Attachment or Serial ATA is an interface used
to connect ATA drives to the motherboard.
● AHCI :- Advanced Host Controller Interface is an operation mode for the SATA.
● RAID ON:- Its an advanced data storage technology that we can enable to use
multiple hard drives for better performance.

3. Search on the Internet about the complete boot process in Linux, i.e., how
computers work starting from power on to login to the computer. Write all
the steps.

There are basically 5 stages of a Linux Boot process from pressing power button to login
to the computer.
I. BIOS:- Basic Input/Output System checks some system integrity and finds and
executes the boot loader or we can say executes the MBR.
II. MBR:- Master Boot Record contains the information regarding GRUB and it
executes the GRUB loader.
III. GRUB:- Grand Unified Bootloader displays a screen and waits for a few seconds if
the ṣuser does not respond to anything it selects the default kernel selected. So it
basically executes the Kernel.
IV. Kernel:- It executes the /sbin/init program. Init is the first command that is run by
Linux Kernel.
V. Systemd:- It consist of the startup process which is executed, when its is
executed, startup is complete and Login console appears on the screen
4. (a) Difference between Linux and Windows OS.

Basis LINUX WINDOWS

Source & Its and open Source and Free of Its is not an Open Source and also
Cost Cost Operating System Bot free of Cost

Case File system is case sensitive File system is case insensitive


Sensitivity

Kernel Uses Monolithic kernel Uses micro kernel

Efficiency More efficient than Windows Less efficient than Linux

Directory Uses forward slash as path Uses backslash as path separator


Separator separator between directories between directories

Security More Secure than Windows Less Secure than Linux

(b) History and evolution of Linux. Write in brief.

In 1991, Linus Torvalds, a student at the university of Helsinki, Finland, thought to have
a freely available academic version of Unix started writing its own code. Later this
project became the Linux kernel. He wrote this program specially for his own PC as he
wanted to use a Unix 386 Intel computer but couldn't afford it. He did it on MINIX using
the GNU C compiler. GNU C compiler is still the main choice to compile Linux code but
other compilers are also used like Intel C compiler. He started it just for fun but ended
up with such a large project. Firstly, he wanted to name it as 'Freax' but later it became
'Linux'. He published the Linux kernel under his own license and was restricted to use it
commercially. Linux uses most of its tools from GNU software and are under GNU
copyright. In 1992, he released the kernel under GNU General Public License.
5. What are the roles of different hierarchical root file systems in Linux such as
/bin, /sbin, /home etc. There are more than 16 such directories. Also, check
some of the files in each such directories so that the functionalities of these
directories can be understood.

● /bin :- ​ It is also known as User Binaries and the command we need for the single
user are located in this directory.
● /dev :- ​It contains all the files in the device and also includes all the external
devices attached to the computer.
● /lib :- ​It is also known as system libraries and it contains files that support
binaries
● /root :- ​All the files and directories are accessible by the root users starts from
the root directory.
● /sbin :- ​It is also known as System Binaries and the command used by system
administrators are located in this directory.
● /var :- ​It basically stands for Variable Files and the files that can be changed are
present in this directory.
● /tmp :- ​It basically stands for Temporary Files and contains the file created by
users for the temporary work which is deleted when we reboot the system.
● /usr :- ​It stands for User Programs and it has the largest share of data as it
contains all the files like binaries, documentation, libraries, etc.
● /home :-​ It is for the user to store their files i.e., suppose there is a user name
aayush then it is shown as /home/aayush.
● /boot :-​ It contains the file that is related to bootloader such as kernel, grub files.
● /media :- ​It mount the removable directories for temporary basis
● /srv :- ​It is also known as Service Data and it contains the server specific services
files or data in this directory.
● /proc :- ​ It contains the illusionary files or the information about the system
process that the kernel creates at the time of boot but it does not exist in the
device.
● /opt :- ​It contains an additional application which we have to install under opt
directory.
● /snap :- ​It is a package in Linux which developers use to create command line
tools and also desktop applications.
● /etc :- ​It contains all the files required by a program for a system configuration.
6. Learn and execute the following Linux commands in the terminal. Write
briefly about the functionality of each command.

(a) (i) Difference between $ and # appearing in the command line interface
(terminal).

Dollar Sign ( $ ) :-​ It generally means you are a normal user.


Hash Sign ( # ) :-​ It generally means you are the system administrator or we can rather
say a root user.

(ii) sudo and su commands

su :- ​Temporarily login as specified user, login as root if no user is specified,


sudo :- ​Executes all the specified commands with root privileges.

(iii) who and whoami commands

who :- ​It prints information about the user who is currently logged in.
whoami :- ​Print the username of the user that is currently logged in.

(iv) useradd, usermod, userdel and passwd commands

useradd :- ​It is used to create a new local account in Linux.


usermod :- ​It is used to modify the existing account in Linux.
userdel :- ​It is used to delete the local account in LInux.
passwd :- ​It is used to assign a password to the user.

(b) (i) cd command and its different extensions

cd ​command is used as change directory command. It is used to change the current


directory you were working in.
cd / :- ​ It is used to change the directory to the root directory. Root directory is also
known as the first directory in your file system.
cd dir_1/dir_2 :- ​It is used to move inside a directory from a directory you were
currently working.
cd or cd~ :- ​It is used to change the directory to the home directory.
cd.. :- ​It is used to go back one directory from the current directory you were working.
cd “dir name” :- ​It is used to navigate to a directory with the spaces present in the
name.

(ii) pwd and locate command

pwd :- ​It stands for print working directory, basically this command prints the complete
path of the directory you are currently working.
locate :- ​Locate command is used to find the files by the name of that file.

(iii) ls and its different extension

ls :- ​ls command is used for listing all the files and directories present in the directory
you are present.
ls -a :- ​Hidden files are also included in it or we can say file name starting with “​.​”(dot) is
also shown there.
ls -h :- ​It basically helps us to view the files in a Human Readable format.
ls -r :- ​ It views the file in a reverse alphabetical order.
ls -s :- ​This Command prints the name and size of the directories.
ls -t :- ​It sorts it by the modification time that means the latest updated directory will
come first and so on.
ls -1 :- ​This command lists files one by one in a row that means it lists one file per line.

(iv) mkdir, mv, cp, rm commands

mkdir :- ​It is used to create a new directory


mv :- ​It is used to rename a file or move a file from one directory to another.
cp :- ​It basically copies files from one location to another.
rm :- ​It deletes a file without having a confirmation or we can say without having a step
verification it deletes a file.

(c) Creation of file using following commands:


(i) Cat and its different extensions

cat​ command is one of the most used commands of linux because it reads data from the
file and gives the content of the file as output, It also helps us to create, view and
concatenate the files.
cat filename :- ​It gives the content of the file name as filename.
cat file1 file2 :- ​It gives the content of file1 as well as file2.
cat -n filename :- ​It gives us the content with the line number of file name as filename.
cat >newfile :- ​It will directly create a new file named as newfile.
cat file1>file2 :- ​It will copy the content of file1 to file2.
cat file1>>file2 :- ​ It will append the contents of file1 to the file2

(ii) gedit :- ​ ​It is the default text editor of Ubuntu OS, just write gedit in a terminal and
press enter and a GUI text editor will open.

(iii) use of > and >>

> :-​ Overwrites the file if it exist or create a new file if it doesn't exist , the output will be
stored in a file whose name is after the operator
>> :- ​Appends the data to a file or creates a new file if the file does not exist, the output
will be stored in a file whose name is after the operator.

(iv) touch command :- ​This command is used to create a new file without any content
and it can also be used to change the timestamp of the file.

(v) Work on vi and vim editors

vi :- ​vi is the universal text editor of linux, if we know how to use it we can edit every
sort of thing using vi.
vim :- ​vim is not the universal text editor, depending on your linux it is default install or
you have to install it separately again if we know how to operate we can edit all sorts of
things using vim.

(vi) less, more and | (pipe) commands

less :-​ It is used to read the contents of the text file reading one page at a time.
more :- ​This command is used to view the text file displaying one screen at a time.
pipe :- ​This command is used to run two or more commands at the same time using the
output of one command as an input of another command.

(d) mount and eject commands

mount :- ​This ​command is used to mount or we can say attach a file system or a
removable device in a particular point in a directory tree.
eject :- ​it is used to remove the device that has been mounted.

(e) chmod, chown and umask commands

chmod :- ​This command is used to change the file mods or permissions.


chown :- ​This command is used to change the ownership of the file.
umask :- ​This is the default permissions setting that is applied to the files when the file
is created.

(f) tar and gzip commands

tar :- ​This is used to create archive and extract the archive files and also it can be used to
compress or uncompress the archive files.
gzip :- ​This is used to compress or uncompress the files.

(g) free, du, df, uname commands

free :- ​This command is used to to display the RAM, swap memory , shared memory,
buffers used by the kernel.
du :- ​It displays the disk usage of each directories and its sub directories.
df :-​ It displays the amount of space available in all the mounted systems.
uname :-​ It reports the basic information about the computer software and hardware.

(h) top, ps, kill commands

top :- ​This command is used to show the linux processes and also provides a dynamic
real time view of the running system.
ps :- ​It stands for Process Status and it is used to view the information related to the
process of the system.
kill :- ​This command is used to terminate the process manually.

(i) alias command :-​ It is used to instruct the shell to replace one string with another
string while executing the commands.

(j) history command :-​ It is used to View the commands that you have recently
executed.
(k) poweroff and reboot commands

poweroff :- ​It basically poweroff the system or shutdown the system.


reboot :- ​It basically restarts or reboot the system.

(m) grep and sed command

grep :- ​It stands for Globally search for Regular Expression and Printout although
command is used to search text or string in a file and displays all the lines which have
the input text or string.
sed :- ​It stands for stream editor and it can do so many tasks such as insertion, deletion,
searching, find and replace and so on.

(n) diff and wc commands

diff :- ​It stands for difference and it is used to display the difference between two files
by comparing both the file line by line.
wc :- ​It stands for word count and it is used to find the number of lines, word count ,
bytes, characters count in the file specified in the file arguments.

---------------------------------------------------------------------------------------------------------------------

You might also like