Linux Basics – Level 1 Day 1

Linux Basics – Level 1:

What is Unix?

Multi-task and multi-user Operating System

Developed in 1969 at AT&T’s Bell Labs by

Ken Thompson (Unix)

Dennis Ritchie (C)

Douglas Mcllroy (Pipes – Do one thing, do it well)

Some other variants: System V, Solaris, SCO Unix, SunOS, 4.4BSD, FreeBSD, NetBSD, OpenBSD, BSDI,IBM AIX,

Linux

A clone of Unix

Developed in 1991 by Linus Torvalds, a Finnish graduate student

Inspired by and replacement of Minix

Linus’ Minix became Linux

Consist of

Linux Kernel

GNU (GNU is Not Unix) Software

Software Package management

Others

Which Linux Distribution is better?

300 Linux Distributions

Redhat

RHEL (commercially support)

Fedora (free)

CentOS (free RHEL, based in England)

SuSe ( based in German)

Scientific Linux

Arch Linux

Debian (one of the few called GNU/Linux)

Ubuntu (based in South Africa)

Knoppix (first LiveCD distro.)

System Boot up:

Power on, POST(Power on Self test), hardware initialization

Boot device selected by BIOS/user interaction

Master boot record of boot device read

Initializes the bootloader

lilo (Linux Loader)

grub (Grand Unified Bootloader)

Boot loader selects and loads an OS kernel

Kernel stored as an compiled image file

Kernel loads modules for hardware and software functions

Interrupts, device management, memory management, paging

Last thing kernel does is call init

init:

First non-kernel code loaded

Process number 1

Acts as parent to all other processes on system

Handles starting services and programs

Based on runlevel, runs the appropriate scripts

A set of defined system states that init can bring the system into (varies on distro)

0: Halt/shutdown

1: Single user mode

2: Multiuser mode

3: Multiuser mode with networking

4: Not used

5: Multiuser mode with networking and GUI

6: Reboot

On boot, init checks /etc/inittab to see what runlevel to bring system to

Any time the runlevel changes, init consults a set of scripts to determine what to stop/start

Init works with run command (rc) scripts

Found in /etc/rc.d

All scripts housed in /etc/rc.d/init.d

Each script takes a parameter for changing operation (start/stop/halt/reboot)

Each runlevel has it’s own directory

/etc/rc.d/rcN.d

In each runlevel directory, there are symbolic links to scripts in /etc/rc.d/init.d

The name of the link is crucial

Starting with S means start in this runlevel

Starting with K means kill in this runlevel

After S/K, there is an order number

Start ascending

Kill descending

Single User Mode

Runlevel 1

Console only – no terminals

Very minimal environment

Some filesystems might not be mounted

Maintenance of filesystems

Fixing configuration errors

Disaster recovery

Multiuser Mode

Runlevels 2-5

Runlevel 2 allows terminal logins

Runlevel 3 allows remote terminal logins

Runlevel 5 enable X11 graphical environment

Runlevels 3 and 5 are the most common levels for day-to-day operations

Shutting Down the System:

Syntax: shutdown [options] time [message]

Time: XX:XX or +X or NOW

-k: don’t really shutdown, just send message

-r: reboot

-h: halt

-c: cancel a shutdown

Schedule the system to shut down at 8 A.M.

#shutdown 08:00

halt: calls shutdown –h

reboot: calls shutdown -r

Scheduling:

Linux systems uses the Cron system for time-based job scheduling

Allows users to schedule jobs to run

Allows sysadmins to run jobs and batch processes

Different distros implement the structures differently

Most use /etc/crontab as primary set of instructions

Sometimes other files are used, like /var/spool/cron/*

Each line schedules a job

Syntax: * * * * * command

First field is minutes (0-59)

Second field is hours (0-23)

Third is day of the month (1-31)

Fourth is month of year (1-12)

Fifth is day of week (0-6, starting with Sun)

#crontab -e

30 08 10 06 * /home/vijay/full-backup

30 – 30th Minute

08 – 08 AM

10 – 10th Day

06 – 6th Month (June)

* – Every day of the week

To list jobs Scheduled:

#crontab -l