Nothing Special   »   [go: up one dir, main page]

Write Short Note On Linux and It's History?: Linux Assignment JK-ENR-CH-1721

Download as pdf or txt
Download as pdf or txt
You are on page 1of 15

Linux Assignment JK-ENR-CH-1721

Write short note on Linux and it's History?


• Evolution of Unix: In 1969, a team of developers of Bell Labs started a project to
make a common software for all the computers and named it as 'Unix'. It was simple
and elegant, used 'C' language instead of assembly language and its code was
recyclable. As it was recyclable, a part of its code now commonly called 'kernel' was
used to develop the operating system and other functions and could be used on
different systems. Also its source code was open source.Initially, Unix was only
found in large organizations like government, university, or larger financial
corporations with mainframes and minicomputers (PC is a microcomputer)

• Unix Expansion: In eighties, many organizations like IBM, HP and dozen other
companies started creating their own Unix. It result in a mess of Unix dialects. Then
in 1983, Richard Stallman developed GNU project with the goal to make it freely
available Unix like operating system and to be used by everyone. But his project
failed in gaining popularity. Many other Unix like operating system came into
existence but none of them was able to gain popularity.

• Evolution of Linux: 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 Unix 386 Intel computer but couldn't
afford it. He did it on MINIX using 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'.

• Linux Today: Today, supercomputers, smart phones, desktop, web servers, tablet,
laptops and home appliances like washing machines, DVD players, routers, modems,
cars, refrigerators, etc use Linux OS

Difference between Linux and Windows?

Basis for Linux Windows


comparison

Access In Linux user has access to the In windows every user won’t
source code of kernel and alter the have access to the source
code according to his need. It has its code, only members of the
own advantages like bugs in OS selected group will have
will fix at a rapid pace and access to it.
disadvantages like developers may
take advantage of any weakness in
OS if they found.

Flavors or Linux has various distributions Windows has very few


Variety which are highly customizable customization options
based on user needs. available.

1|Page
Linux Assignment JK-ENR-CH-1721

Licensing In Linux with GPL- Licensed In windows, with Microsoft


operating system, users are free to license, users won’t have
modify the software, can re-use in access to source code (can’t
any number of systems and even modify the software) and
they can sell the modified version. based on a number of
licenses – we can install only
on those number of
computers.

Command line In Linux, command line is a very In windows, we have


useful tool for administration and command line but can’t use
daily tasks but for end users, it as Linux command line. We
doesn’t make much difference. need to go running and enter
cmd then command line will
open.

Run level Linux has inbuilt ability to stop at In windows, if we encounter


different run levels with this we can any problem in order to fix
work using a command line and it, we need to reboot at run
GUI if anyone has an issue. level 3 as an administrator/
root to find and fix the
problem.

Usability Linux is complicated to install but Windows gives user’s a


has the ability to complete complex simple system to operate but
tasks easier. it will take a longer time to
install.

Support Linux has support via a huge Windows has support which
community of user forums/websites is easily accessible, online
and online search. forums/ websites and it has
paid support also.

Updates In Linux, users have full control of In windows, updates will


updates, we can install whenever we come at inconvenient times
needed and it will take less time such as you are giving a
without any reboot. print to the printer but
suddenly update pop up will
come which makes users
frustrate and took more time
to install.

Security Linux is more secure than windows Windows is the major target
where hackers or developers of for developers of viruses and
viruses will find difficult to break malware and it is most
through Linux. vulnerable without anti-virus
software.

2|Page
Linux Assignment JK-ENR-CH-1721

Write down the boot process of Linux?


The stages involved in Linux Booting Process are:

BIOS
Boot Loader
- MBR
- GRUB
Kernel
Init
Runlevel scripts

BIOS
• This is the first thing which loads once you power on your machine.
• When you press the power button of the machine, CPU looks out into ROM for
further instruction.
• The ROM contains JUMP function in the form of instrucion which tells the CPU to
bring up the BIOS
• BIOS determines all the list of bootable devices available in the system.
• Prompts to select bootable device which can be Hard Disk, CD/DVD-ROM, Floppy
Drive, USB Flash Memory Stick etc (optional)
• Operating System tries to boot from Hard Disk where the MBR contains primary boot
loader.

Boot Loader
To be very brief this phase includes loading of the boot loader (MBR and GRUB/LILO) into
memory to bring up the kernel.

MBR (Master Boot Record)

• It is the first sector of the Hard Disk with a size of 512 bytes.
• The first 434 - 446 bytes are the primary boot loader, 64 bytes for partition table and 6
bytes for MBR validation timestamp.

NOTE: Now MBR directly cannot load the kernel as it is unaware of the filesystem
concept and requires a boot loader with file system driver for each supported file
systems, so that they can be understood and accessed by the boot loader itself.

To overcome this situation GRUB is used with the details of the filesystem
in /boot/grub.conf and file system drivers

3|Page
Linux Assignment JK-ENR-CH-1721

GRUB (GRand Unified Boot loader)

This loads the kernel in 3 stages

GRUB stage 1:


The primary boot loader takes up less than 512 bytes of disk space in the MBR - too
small a space to contain the instructions necessary to load a complex operating
system.
• Instead the primary boot loader performs the function of loading either the stage 1.5
or stage 2 boot loader.
GRUB Stage 1.5:

• Stage 1 can load the stage 2 directly, but it is normally set up to load the stage 1.5.
• This can happen when the /boot partition is situated beyond the 1024 cylinder head of
the hard drive.
• GRUB Stage 1.5 is located in the first 30 KB of Hard Disk immediately after MBR
and before the first partition.
• This space is utilized to store file system drivers and modules.
• This enabled stage 1.5 to load stage 2 to load from any known location on the file
system i.e. /boot/grub

GRUB Stage 2:

• This is responsible for loading kernel from /boot/grub/grub.conf and any other
modules needed
• Loads a GUI interface i.e. splash image located at /grub/splash.xpm.gz with list of
available kernels where you can manually select the kernel or else after the default
timeout value the selected kernel will boot

Kernel
This can be considered the heart of operating system responsible for handling all system
processes.
Kernel is loaded in the following stages:

• Kernel as soon as it is loaded configures hardware and memory allocated to the


system.
• Next it uncompresses the initrd image (compressed using zlib into zImage or
bzImage formats) and mounts it and loads all the necessary drivers.
• Loading and unloading of kernel modules is done with the help of programs like
insmod, and rmmod present in the initrd image.
• Looks out for hard disk types be it a LVM or RAID.
• Unmounts initrd image and frees up all the memory occupied by the disk image.
• Then kernel mounts the root partition as specified in grub.conf as read-only.
• Next it runs the init process

4|Page
Linux Assignment JK-ENR-CH-1721

Init Process
• Executes the system to boot into the run level as specified in /etc/inittab

Runlevel scripts
A no. of runlevel scripts are defined inside /etc/rc.d/rcx.d

• Based on the selected runlevel, the init process then executes startup scripts located in
subdirectories of the /etc/rc.d directory.
• Scripts used for runlevels 0 to 6 are located in
subdirectories /etc/rc.d/rc0.d through /etc/rc.d/rc6.d, respectively.Lastly, init runs
whatever it finds in /etc/rc.d/rc.local (regardless of run level). rc.local is rather special
in that it is executed every time that you change run levels.

Difference between NTFS and XFS?

Maximu Max
Maximum Maximu
Maximum filenam Allowable characters m numbe
File system pathname m file
e length in directory entries volume r of
length size
size files
32,767
In Win32 namespace: Unicode
any UTF-16 code unit characters
(case-insensitive) with each
except /\:*"?<>| as path
well as NUL component
NTFS 255 characters 16 EiB 16 EiB 232
(directory
In POSIX namespace or
: any UTF-16 code filename)
unit (case-sensitive) up to 255
except / as well characters
as NUL long[f]

No limit
XFS 255 bytes Any byte except NUL 8 EiB 8 EiB ?
defined

Write any 15 commands of Linux with It's Description?


• Cat command description:

The cat command is short for concatenate files and the command will print the file contents
to the standard output (normally your PC screen), and cat also can be used to create file on
Linux system.

Create a file in Linux using cat command.

Below is an example to create using cat command to create file

5|Page
Linux Assignment JK-ENR-CH-1721

Faizan@DESKTOP-CGHISK0:~$ cat > Faizan.txt


Roses are red,
Violets are blue,
SYNTAX error at line 2;

The command above will create a file called linux-command-list and to finish your work
press Ctrl+d after the line break (press Enter key after your last line of text) to denote the end
of file. Please note that the standard symbol of redirection ' > ' (greater than) sign is
necessary to create a new file.

Appends text to file using cat command.

The example below show the cat command with the appends ' >> ' redirection symbol to add
more text to the file that we create earlier (create-linux-file.txt file).

Faizan@DESKTOP-CGHISK0:~$ cat >> Faizan.txt

Spiders are only web developers,

that are happy to find BUGS!

To finish your work press Ctrl+d after the line break. The next shell prompt supposed to
appear after you press Ctrl+d key.

Display file contents on Linux system using cat command.

There is many way to display file contents in Linux system, one of the easiest and simplest
way to display the file contents is using cat command.

Faizan@DESKTOP-CGHISK0:~$ cat Faizan.txt

6|Page
Linux Assignment JK-ENR-CH-1721

Note:
• To display the file contents you don't need any redirections sign (no '>' or '>>'), just
issue the cat command and the filename of file that you wish to display.
• All the file contents display immediately after you issue the command.
• The file contents display on the line after the command, and the file content finish
before the next shell prompt.

• File comparisons

Command line tools

1. diff
The diff command compares files line by line. It is invoked as follows:

diff Faizan.txt fmg.txt

2. cmp
The cmp command compares two files byte by byte. If the files are different then it reports
the first byte and line number where they differ.

cmp Faizan.txt fmg.txt

3. sdiff

7|Page
Linux Assignment JK-ENR-CH-1721

The sdiff command does a side by side merge of file difference.

Editors

4. vimdiff
The vim editor lets you compare files too. Use the following command to view the
differences using a side-by-side comparison:

vimdiff Faizan.txt fmg.txt

Disk related commands.

1. Display Information of df Command.


Using ‘–help‘ switch will display a list of available option that are used
with df command

8|Page
Linux Assignment JK-ENR-CH-1721

2. Check File System Disk Space Usage


The “df” command displays the information of device name, total blocks, total disk
space, used disk space, available disk space and mount points on a file system

9|Page
Linux Assignment JK-ENR-CH-1721

3. Display Information of all File System Disk Space Usage

The same as above, but it also displays information of dummy file systems along with
all the file system disk usage and their memory utilization.

4. Show Disk Space Usage in Human Readable Format

Have you noticed that above commands displays information in bytes, which is not
readable yet all, because we are in a habit of reading the sizes in megabytes, gigabytes
etc. as it makes very easy to understand and remember.
The df command provides an option to display sizes in Human Readable formats by
using ‘-h’ (prints the results in human readable format (e.g., 1K 2M 3G)).

10 | P a g e
Linux Assignment JK-ENR-CH-1721

How to View Active Processes in Linux

There are several Linux tools for viewing/listing running processes on the system, the two
traditional and well known are ps and top commands:

1. ps Command

It displays information about a selection of the active processes on the system

ps -> List processes

ps aux ->List all processes in detail running on the system, including user, Process ID (PID),
and name of process. Using this, one can view their process list and if necessary, kill
unnecessary or stalled processes.

2. top – System Monitoring Tool

top is a powerful tool that offers you a dynamic real-time view of a running system

11 | P a g e
Linux Assignment JK-ENR-CH-1721

Connecting processes with pipes

Simply put, a pipe is a method of connecting the standard output of one process to
the standard input of another. They provide a method of one-way communications (hence the
term half-duplex) between processes.

A pipe is a designated in command by the vertical bar character , which is located on the
same key as the backslash on U.S keyboards. The general syntax for pipes is:

Command_1 | command_2 | command_3 . . . ]

The chain can continue for any number of commands or programs.

example would be listing folders in a directory by ls command, though it doesn’t produce the
result in a sorted form so we’ll pipe it with sort command.

Command:ls -all

Output:

Command:ls -all | sort -f

Output:

12 | P a g e
Linux Assignment JK-ENR-CH-1721

Scheduling a program

There are basic two daemons for scheduling tasks on a Linux system:

1. at , utilizes the at daemon (atd), It’s for scheduling commands to be executed once at a
specific time.
2. corntab, utilizes the corn daemon (crond) to execute repetitive or chronic scheduled tasks.

Examples of at Command:

Example 1: Schedule task at coming 10:00 AM.


Faizan@faizan - VirtualBox ~ $ at 10:00 AM
Example 2: Schedule task at 10:00 AM on coming Sunday.
Faizan@faizan - VirtualBox ~ $ at 10:00 AM Sun
Example 3: Schedule task at 10:00 AM on coming 25’th July.
Faizan@faizan - VirtualBox ~ $ at 10:00 AM July 25
Example 4: Schedule task at 10:00 AM on coming 22’nd June 2015.
Faizan@faizan - VirtualBox ~ $ at 10:00 AM 6/22/2015
Faizan@faizan - VirtualBox ~ $ at 10:00 AM 6.22.2015
Example 5: Schedule task at 10:00 AM on same date at next month.
Faizan@faizan - VirtualBox ~ $ at 10:00 AM next month
Example 6: Schedule task at 10:00 AM tomorrow.
Faizan@faizan - VirtualBox ~ $ at 10:00 AM tomorrow
Example 7: Schedule task at 10:00 AM tomorrow.
Faizan@faizan - VirtualBox ~ $ at 10:00 AM tomorrow
Example 8: Schedule task to execute just after 1 hour.
Faizan@faizan - VirtualBox ~ $ at now + 1 hour
Example 9: Schedule task to execute just after 30 minutes.
Faizan@faizan - VirtualBox ~ $ at now + 30 minutes
Example 10: Schedule task to execute just after 1 and 2 weeks.
Faizan@faizan - VirtualBox ~ $ at now + 1 week
Faizan@faizan - VirtualBox ~ $ at now + 2 weeks
Example 11: Schedule task to execute just after 1 and 2 years.

13 | P a g e
Linux Assignment JK-ENR-CH-1721

Faizan@faizan - VirtualBox ~ $ at now + 1 year


Faizan@faizan - VirtualBox ~ $ at now + 2 years
Example 12: Schedule task to execute at mid night.
Faizan@faizan - VirtualBox ~ $ at midnight

Scheduling a ping command

Syntax:

$ at 00:41
Ping www.microsoft.com
Ctrl+d

Checking for the pings that occurred using command

ps aux | grep ping

At time 00:40

At time 00:41

Creating a file at a specific time

Syntax:

14 | P a g e
Linux Assignment JK-ENR-CH-1721

directory at time 00:36


no output1 file has been created.

Directory at time 00:37


Output1 file has been created, with time and date as content

15 | P a g e

You might also like