Documente Academic
Documente Profesional
Documente Cultură
in/
Linux Introduction
IBM : AIX
SGI : IRIX
Sun : Solaris
Features:
Advantages:
Virus Proof
Crash Proof
Economical
Multiuser, Multi-Tasking and Multi processing capacity
Login Modes:
Two modes:
Linux Architecture
Windows Linux
BASH Features
when you login to the Server using any CLI based tool OR login to the CLI
mode you can see as like below screen.
shells List
Command Line History: Command line history will be saved, when you
execute any command in terminal.
$ history - this command will display all the previous executed
commands
Example: rm f a* - it will remove all the files which are starting with
a
Redirecting input and output from standard stream to user defined place
1. Input RD -0 <
3. Error RD -2 >
$ history > f2
$mkdir d1 2> e1
sort Command Output
| pipe
pipe Symbol
More: we cant go upward downward, just see the output fit to the
screen
Overview
Everything in Linux can be reduced to a file. Partitions are associated with
files such as /dev/hda1. Hardware components are associated with files such as
/dev/modem. The Filesystem Hierarchy Standard (FHS) is the official way to
organize files in Unix and Linux directories.
Linux file system and directory structure
Several major directories are associated with all modern Unix/Linux operating
systems. These directories organize user files, drivers, kernels, logs, programs,
utilities, and more into different categories. The standardization of the FHS makes it
easier for users of other Unix-based operating systems to understand the basics of
Linux. All of the other directories shown in Table are subdirectories of the root
directory, unless they are mounted separately.
Direct
ory Description
The root directory, the top-level directory in the FHS. All other directories
are subdirectories of root, which is always mounted on some partition. All
/
directories that are not mounted on a separate partition are included in the
root directorys partition.
Essential command line utilities. Should not be mounted separately;
/bin otherwise, it could be difficult to get to these utilities when using a rescue
disk.
Includes Linux startup files, including the Linux kernel. Can be small; 16MB
is usually adequate for a typical modular kernel. If you use multiple
/boot
kernels, such as for testing a kernel upgrade, increase the size of this
partition accordingly.
/etc Most basic configuration files.
Hardware and software device drivers for everything from floppy drives to
/dev
terminals. Do not mount this directory on a separate partition.
/home Home directories for almost every user.
Program libraries for the kernel and various command line utilities. Do not
/lib
mount this directory on a separate partition.
The mount point for removable media, including floppy drives, CD-ROMs,
/mnt
and Zip disks.
/opt Applications such as WordPerfect or Star Office.
Currently running kernel-related processes, including device assignments
/proc
such as IRQ ports, I/O addresses, and DMA channels.
/root The home directory of the root user.
/sbin System administration commands. Don't mount this directory separately.
Temporary files. By default, Red Hat Linux deletes all files in this directory
/tmp
periodically.
Small programs accessible to all users. Includes many system
/usr
administration commands and utilities.
/var Variable data, including log files and printer spools.
Linux Booting procedure
The stages involved in Linux Booting Process are:
1. BIOS
2. Boot Loader
- MBR
- GRUB
3. Kernel
4. Init
5. Runlevel scripts
6. User Interface
STEP 1. 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 instruction which tells the
CPU to bring up the BIOS
BIOS determine all the list of bootable devices available in the system.
Operating System tries to boot from Hard Disk where the MBR contains
primary boot loader.
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 file system
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 file system in
/boot/grub.conf and file system drivers
GRUB (Grand Unified Boot loader)
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.
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 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:
The original file is /etc/grub.conf of which you can observe a symlink file at
/boot/grub/grub.conf
STEP 3. Kernel
This can be considered the heart of operating system responsible for handling all
system processes.
Kernel is loaded in the following stages:
2. Next it uncompresses the initrd image (compressed using zlib into zImage
or bzImage formats) and mounts it and loads all the necessary drivers.
3. Loading and unloading of kernel modules is done with the help of programs
like insmod, and rmmod present in the initrd image.
5. Unmounts initrd image and frees up all the memory occupied by the disk
image.
Executes the system to boot into the run level as specified in /etc/inittab
You can check current runlevel details of your system using below command on the
terminal
# who -r
Next as per the fstab entry file system's integrity is checked and root
partition is re-mounted as read-write (earlier it was mounted as read-
only).
For more details on scripts inside /etc/rc.d follow the below link
What are the s and k scripts in the etc rcx.d directories
NOTE: rc.local is not used in all the distros as for example Debian .
Before you turn over to the next chapter where you are going to meet a
plethora of commands, remember a few things that apply to all UNIX
commands.
Between the command name and the options that may be available with
the command there must always be a space or a tab, for example, ls l.
Here is the command whereas l is the option and the two have been
separated by space. The option is usually preceded by a minus (-) sign.
The option available with a command are often known as switches
Two or more options available with command can usually be combined, for
example, the command ls l a is same as ls la
To cancel the entire command before you press Enter, press ctrl+c Or del
key
Basic Commands :
~]$ date #To see the date of the system.
~]$ date +%d-%Y-%H-%M #To see particular date format you always
use date options
ls -l Command output
~]$ pwd #Print working directory
~]$ who am I #To see from which user you have logged in
who am i command output
~]$ who #To see all who is logged in yet this point of time from
which IP
~]$ w #More details about user related info
Options:
~]$ touch am #it will change a file time to current time
~]$ touch r file1 B 30 file2 #it will create two files with 30 seconds time
difference
~]$ cat /dev/null > file #To empty the data file
~]$ cat > <File Name> #Create an single file with text
Options:
-R, -r, #copy directories recursively
-v #verbose to see progress of copy job
-p #preserve
-f #forcefully
-I #interactive: Ask before overwriting file
cp -v Command Output
Copying directory must use R to copy directories
mv Command Output
~]$ last #Check who logged in and when logged in duration