linux2
linux2
LINUX BASICS
SAMANTI SARKAR
SC-E, ISSD
• linux at a glance
The linux operating system is a set of programs that
acts as a link between the computer and the user.
• The computer programs that allocate the system resources
and coordinate all the details of the computer's internals is
called the operating system or the kernel.
• Users communicate with the kernel through a program
known as the shell. The shell is a command line interpreter;
it translates commands entered by the user and converts
them into a language that is understood by the kernel.
• Several people can use a linux computer at the same time;
hence linux is called a multiuser system.
• A user can also run multiple programs at the same time;
hence linux is a multitasking environment.
1
04-02-2022
Basic Features
• Following are some of the important features of Linux Operating System.
• Portable − Portability means so ware can work on different types of hardware in
same way. Linux kernel and application programs supports their installation on any
kind of hardware platform.
• Open Source − Linux source code is freely available and it is community based
development project. Multiple teams work in collaboration to enhance the
capability of Linux operating system and it is continuously evolving.
• Multi-User − Linux is a mul user system means mul ple users can access system
resources like memory/ ram/ application programs at the same time.
• Multiprogramming − Linux is a mul programming system means mul ple
applications can run at same time.
• Hierarchical File System − Linux provides a standard file structure in which system
files/ user files are arranged.
• Shell − Linux provides a special interpreter program which can be used to execute
commands of the operating system. It can be used to do various types of
operations, call application programs. etc.
• Security − Linux provides user security using authen ca on features like password
protection/ controlled access to specific files/ encryption of data.
The main concept that unites all the versions of linux are the following four
basics −
Kernel − The kernel is the heart of the opera ng system. It interacts with the
hardware and most of the tasks like memory management, task scheduling and
file management.
Shell − The shell is the u lity that processes your requests. When you type in a
command at your terminal, the shell interprets the command and calls the
program that you want. The shell uses standard syntax for all commands. C Shell,
Bourne Shell and Korn Shell are the most famous shells which are available with
most of the linux variants.
Commands and Utilities − There are various commands and u li es which you
can make use of in your day to day activities. cp, mv, cat and grep, etc. are few
examples of commands and utilities. There are over 250 standard commands
plus numerous others provided through 3rd party software. All the commands
come along with various options.
Files and Directories − All the data of linux is organized into files. All files are
then organized into directories. These directories are further organized into a
tree-like structure called the filesystem.
2
04-02-2022
CPU,RAM,I/O etc.,
3
04-02-2022
• The BIOS tests the system and checks peripherals and system integrity. It checks for
the available bootable device , depending on the setting, it checks for CD, USB stick
and hard drive. The BIOS looks for a Master Boot Record (MBR) starting at the first
sector on the first hard drive, loads its contents into memory, then passes control to
it.
4
04-02-2022
• Runlevel:
• The init command then runs the /etc/inittab script to decide which run level OS has to come up.
• Default run levels are as follows :
• # 0 – halt (Do NOT set init default to this)
• # 1 – Single user mode
• # 2 – Multiuser, without NFS
• # (The same as 3, if you do not have networking)
• # 3 – Full multiuser mode
• # 4 – unused
• # 5 – X11
• # 6 – reboot (Do NOT set init default to this)
• The init program starts all of the background processes by looking in the appropriate rc directory for
the runlevel specified as default in /etc/inittab. The rc directories are numbered to corresponds to the
runlevel they represent. For instance, /etc/rc.d/rc5.d/ is the directory for runlevel 5.
• In /etc/rc.d/rc5.d/ directory what are all files starting with “K” those responsible for Kill the process
when system is rebooting or shouting down. And Starting “S” those responsible for Start the process.
• After this the system finished Booting and you can login to system.
• Fresh Installation:
• In this method you can format the computer’s hard drive and install Linux from
Bootable CD/DVD or Bootable USB drive. In this method Linux is the only
Operating system in your computer.
• Dual Boot System:
• One of the things that make Linux special is that it can play nice with other
operating systems. You can run Linux alongside of other operating systems quite
easily. Running Linux along with other operating system like windows is called
“Dual Boot” system. It means that you have a system with two different operating
systems, and during the boot process you will need to decide which one you
would like to boot into.
5
04-02-2022
• Live CD/DVD:
• Many Linux distributors provide the option to try it without
installing. In that Linux runs as a completely bootable operating
system from the CD/DVD. The files are loaded into your computer's
memory, rather than being run for a hard disk drive. So you can run
Linux from a CD/DVD, and when you reboot your PC, and remove
the CD/DVD, it will boot back into its old operating system without
any difference to your PC. This gives you an easy way to try out
several distributions of Linux.
• Virtual Installation:
• You can install Linux inside Virtual Machine also. This method is
preferred by many peoples in these days. There are a number of
ways to do this, the simplest one is to download and install a Virtual
Server application, and then install your Linux distribution under
that host software.
GNOME 3
6
04-02-2022
• UNITY:
• Unity is Ubuntu’s own default desktop environment. If you’ve installed Ubuntu using
the standard installer, you’re probably using the Unity desktop right now
because Unity is probably synonymous with Ubuntu. From its searchable Dash
(which also searches online sources) to its application dock that functions similarly to
Windows 7′s taskbar, Unity has its own identity as a desktop. Prior to Unity, Ubuntu
used GNOME — many of these GNOME programs, like the Nautilus file manager, are
still used on Unity today.
• KDE:
• KDE and GNOME are the two most popular Linux desktop environments. KDE has always been
more complex than GNOME, packing in many more configuration options and
features. KDE software consists of a large number of individual applications and a desktop
workspace as a shell to run these applications. It’s a bit more Windows-like than the other
desktop environments here, coming with a single taskbar on the bottom of the screen that
includes a menu, quick launch-type icons, a taskbar, a notification area, and a clock. You can
run KDE applications just fine on any desktop environment as they are built to integrate well with
your system's components. By also using the KDE workspace, you get even better integration of
your applications with the working environment while lowering system resource demands.
7
04-02-2022
• Xfce:
• Xfce is a famous for its lightweight Desktop environment. Xfce embodies the traditional UNIX
philosophy of modularity and re-usability. It consists of a number of components that provide
the full functionality one can expect of a modern desktop environment, while remaining
relatively light. Xfce is a great choice for older computers and it is still a full-fledged desktop
environment that offers a great deal to the user. Xfce provides a nice balance between
functionality and conservation of system resources, while still having a beautiful desktop. It
was once very similar to GNOME, but with GNOME 3 striking out in a different direction, Xfce
now has its own identity as a more traditional Linux desktop environment that’s quite similar
to GNOME 2.
• LXDE:
• LXDE more lightweight than Xfce. LXDE is focused on being as lightweight as
possible and is especially designed for older computers, netbooks, and other
systems with low hardware resources. It comes with a beautiful interface, multi-
language support, standard keyboard short cuts and additional features like
tabbed file browsing. Fundamentally designed to be lightweight, LXDE uses less
CPU and RAM than other environments. It is especially beneficial for cloud
computers with low hardware specifications, such as netbooks, mobile devices or
older computers. While it’s a lightweight desktop, it includes all the standard
desktop features — some lightweight desktops omit the taskbar entirely, but LXDE
doesn’t.
8
04-02-2022
• Cinnamon:
• Cinnamon was developed for Linux Mint. Cinnamon is based on GNOME
3, so it uses up-to-date libraries and other software, but it takes that
software and tries to create a more traditional-looking desktop with it.
amon is a fork of GNOME 3. Cinnamon strives to provide a traditional user
experience, similar to GNOME 2.
• MATE:
• MATE is fork of the original GNOME 2 that aims to preserve GNOME 2, continually updating it
so it will continue to work on modern Linux distributions. Mate provides an intuitive and
attractive desktop to Linux users using traditional metaphors. MATE has also seen some new
features, but the main purpose of MATE is to give people who desperately miss GNOME 2 the
opportunity to install it on new Linux distributions. This desktop environment is ideal for
people who really miss GNOME 2.
9
04-02-2022
• Enlightenment:
• Enlightenment is a window manager, it can also be considered a desktop environment. One very nice feature
of Enlightenment is its flexibility, which among other things allows it to run on a wide variety of devices that
includes mobile phones, game systems, laptops, and powerful desktop computers. Enlightenment requires
less system resources than the GNOME, KDE. The Enlightenment desktop is somewhat unique in its
appearance, and users can simply click anywhere on it to access the menu.
• Pantheon:
• Pantheon is the default desktop environment originally created for the elementary OS distribution. It is
written from scratch using Vala and the GTK3 toolkit. With regards to usability and appearance, the desktop
has some similarities with GNOME Shell and Mac OS X.
• Razor-qt:
• Razor-qt is an advanced, easy-to-use, and fast desktop environment based on Qt technologies. It is tailored
for users who value simplicity, speed, and an intuitive interface. A nice feature of Razor-qt is its ability to run
with a variety of window managers such as Openbox, Metacity, or KWin. Razor-qt does not yet have its own
file manager or other applications, but perhaps it will have more applications in the future. It has been
tailored for users who value simplicity, speed, and an intuitive interface. While still a new project, Razor-qt
already contains all the key DE components.
• ROX:
• ROX is a fast, user friendly desktop which makes extensive use of drag-and-drop. The interface revolves
around the file manager, following the traditional UNIX view that 'everything is a file' rather than trying to
hide the filesystem beneath start menus, wizards, or druids. The aim is to make a system that is well designed
and clearly presented.
Before Installation
• Platform:
• Which Platform or flavor (Distribution) you want to install. As I have already discussed there are many flavours of
Linux are available in market. So first choose you Flavour. If you are a beginner and you don't know which is best
for you then you can try Ubuntu. It is very user-friendly and good for beginners. For servers CentOS is best and if
you can invest then you can choose Red Hat.
Version:
• After choosing the Platform or Flavor you have to decide which version you want to install. There are many
versions are available like Desktop version or for Server. If your system support 64 bit then you can choose 64 bit
installation.
Desktop Environment:
• There are lots of desktop environment available for Linux. Linux users have a choice of many different desktop
environments, all with their own styles and strengths. You can install one of these desktop environments after
installing your Linux distribution and switch between desktop environments from the login screen. You can also
choose to install a Linux distribution that comes with the desktop environment. Some popular Desktop
Environment are Unity, GNOME, KDE, XFCE, LXDE, Cinnamon, MATE and many more.
Medium of Installation:
• Choose the right medium of Installation. You can install via CD, DVD, Bootable USB drive, or through networking.
Type of Installation:
• Are you installing it as personal use or for servers? And do you want to install it as a single Operating system
(Linux is only Operating system in that computer) or along with Windows or other Operating System. So Choose
type of Installation Dual Boot, Live CD, Fresh Install or Virtual Install.
Hardware Support:
• Finally check the compatibility of your hardware. you can check with the respective Linux Distributors website for
hardware compatibility.
10
04-02-2022
Each of the above directory (which is a file, at the first place) contains important
information, required for booting to device drivers, configuration files, etc.
Let’s start hierarchically for describing briefly the purpose of each directory:
/bin : All the executable binary programs (file) required during booting, repairing, files
required to run into single-user-mode, and other important, basic commands viz., cat,
du, df, tar, rpm, wc, history, etc.
/boot : Holds important files during boot-up process, including Linux Kernel.
/dev : Contains device files for all the hardware devices on the machine e.g., cdrom,
cpu, etc
/etc : Contains Application’s configuration files, startup, shutdown, start, stop script
for every individual program.
/home : Home directory of the users. Every time a new user is created, a directory in
the name of user is created within home directory which contains other directories
like Desktop, Downloads, Documents, etc.
/lib : The Lib directory contains kernel modules and shared library images required to
boot the system and run commands in root file system.
/lost+found : This Directory is installed during installation of Linux, useful for
recovering files which may be broken due to unexpected shut-down.
11
04-02-2022
12
04-02-2022
13
04-02-2022
VirtualBox is an open source cross-platform virtualization software, it can be installed on any operating system and
enable you to install and run multiple guest operating systems on same computer.
Unified Extensible Firmware Interface (UEFI) is a specification for a software program that connects a computer's
firmware to its operating system (OS). UEFI is expected to eventually replace BIOS. Like BIOS, UEFI is installed at the
time of manufacturing and is the first program that runs when a computer is turned on. The UEFI settings screen
allows you to disable Secure Boot, a useful security feature that prevents malware from hijacking Windows or
another installed operating system.
14
04-02-2022
GRUB contd.
• The example above shows GRUB displaying the "no such partition" error
before displaying the grub rescue prompt. Another common GRUB error is
"unknown filesystem", followed by the same prompt.
GRUB contd.
Command Description Example
insmod
insmod Load a module.
(hd0,1)/boot/grub/normal.mod
loopback loop0
loopback Mount an image file as a device.
(hd0,1)/iso/image.iso
Display the contents of a directory or
ls ls (hd0,1)
partition.
The command is issued without
lsmod Display a list of loaded modules.
arguments.
The command is issued without
normal Activate the normal module.
arguments.
Search for devices. Option --
file searches for files, --label searches
search search -file [filename]
for labels, --fs-uuid searches for
filesystem UUID.
Set an environment variable. If issued
with no arguments, the command
set set [variable-name]=[value]
prints the list of all environment
variables and their values.
15
04-02-2022
Use the ls command to find the partition containing the boot directory.
$ ls [partition-name]
The example shows the boot directory in the (hd0,msdos1) partition
3. Set the boot partition as the value of the root variable. The example uses the partition
named (hd0,msdos1).
$set root=(hd0,msdos1)
4. Load the normal boot mode.
$insmod normal
5. Start the normal boot mode.
$normal
The normal mode enables you to issue more complex commands.
6. Load the Linux kernel using the linux command.
$linux /boot/vmlinuz-4.2.0-16-generic root=/dev/sda1 ro
7. Issue the boot command.
$boot
The system now boots properly.
16
04-02-2022
17
04-02-2022
• Reinstalling GRUB
• Follow the steps below to reinstall GRUB on your Linux system.
• 1. Mount the partition containing the OS installation. The example mounts the
/dev/sda1 partition to the /mnt directory.
• $sudo mount /dev/sda1 /mnt
• 2. Bind the /dev, /dev/pts, /proc, and /sys directories to the corresponding
directories in the /mnt folder.
• sudo mount --bind /dev /mnt/dev &&
• sudo mount --bind /dev/pts /mnt/dev/pts &&
• sudo mount --bind /proc /mnt/proc &&
• sudo mount --bind /sys /mnt/sys
• 3. Install GRUB.
18
04-02-2022
• First Column − Represents the file type and the permission given on the file. Below is the
description of all type of files.
• Second Column − Represents the number of memory blocks taken by the file or directory.
• Third Column − Represents the owner of the file. This is the linux user who created this file.
• Fourth Column − Represents the group of the owner. Every linux user will have an associated group.
• Sixth Column − Represents the date and the me when this file was created or modified for the last
time.
19
04-02-2022
# ls -R
total 1384
-rw-------. 1 root root 33408 Aug 8 17:25 anaconda.log
-rw-------. 1 root root 30508 Aug 8 17:25 anaconda.program.log
./httpd:
total 132
-rw-r--r-- 1 root root 0 Aug 19 03:14 access_log
-rw-r--r--. 1 root root 61916 Aug 10 17:55 access_log-20120812
./lighttpd:
total 68
-rw-r--r-- 1 lighttpd lighttpd 7858 Aug 21 15:26 access.log
-rw-r--r--. 1 lighttpd lighttpd 37531 Aug 17 18:21 access.log-20120819
20
04-02-2022
# ls -lS
total 176
-rw-r--r--. 1 root root 48867 Jul 31 02:17 install.log
-rw-r--r--. 1 root root 46701 Jul 31 09:58 index.html
-rw-r--r--. 1 root root 21262 Aug 12 12:42 fbcmd_update.php
-rw-r--r--. 1 root root 11439 Jul 31 02:13 install.log.syslog
drwxr-xr-x. 2 root root 4096 Jul 31 02:48 Desktop
10. Display Inode number of File or Directory
We can see some number printed before file / directory name. With -i options list
file / directory with inode number.
# ls -i
20112 0001.pcap 23610 Documents 23793 index.html 23611 Music 23597
Templates 23564 anaconda-ks.cfg 23595 Downloads 22 install.log 23612 Pictures
236
21
04-02-2022
Metacharacters
Metacharacters have a special meaning in linux. For example, * and ? are
metacharacters. We use * to match 0 or more characters, a question mark (?)
matches with a single character.
For Example −
# ls ch*.doc
Displays all the files, the names of which start with ch and end with .doc −
22