Linux System Administrator Lesson 1

Page 1

SA1 LECTURE 1 LINUX BASICS: UNIX Standards:

BSD SYSTEM V (system 5)

BSD:

Free BSD Open BSD Net BSD

SYSTEM V:

Solaris (Developed by SUN Microsystems) HP-UX (Developed by HP) SCO

There are some UNIX versions that follow some good features from BSD standard and some from System v standard they can be named as Hybrid Unix Like:

LINUX AIX

FILE TYPES IN LINUX: In Linux/Unix every thing is treated as a file and every thing is represented by a file. Even devices are represented by device files. There are four types files in Linux/Unix 1. Normal File: Every file that contains data in it is called normal file. E.g. execute able files, Text files, movie files, audio files and Virus files etc.etc. 2. Directory File: These are container files that hold other file and directories. 3. Link File : These are like short cuts in windows. These just point towards the actual file. 4. Device File: These represent devices. When ever we need to access a device we use these files and these files gets the job done for us. These are present in /dev directories.

THREE ROOTs IN LINUX/UNIX: Word root is used for three entities in Linux/Unix root user: /root directory: /:

Admin user of Unix/Linux systems is root user. Home directory of root user. / is like my computer in Windows. It is the parent directory of all linux system. Every thing is present under this directory

Note: Linux/Unix is case sensitive in every thing from username and password to parameters of file


and command options.

DEVICE NAMES: General Device Names COM 1 COM 2 COM 3 COM 4 Parallel Port 1 / Lpt port 1 First NIC (Network Interface Card) / LAN Card Second NIC (Network Interface Card) / LAN Card Hard Drive Name

Linux Names /dev/ttyS0 /dev/ttyS1 /dev/ttyS2 /dev/ttyS3 /dev/lp0 /dev/eth0 /dev/eth1 Linux Names Primary Master Primary Slave Secondary Master Secondary Slave

hda hdb hdc hdd

SCSI Type SCSI Type SCSI Type

First SCSI Drive Second SCSI Drive Third SCSI Drive

sda sdb sdc

SATA Type SATA Type SATA Type

First SATA Drive Second SATA Drive Third SATA Drive

sda sdb sdc

USB Flash Drive

First USB

sda

IDE IDE IDE IDE

Type Type Type Type

Note: If a hard drive has a SATA and / or a SCSI drive and you plug in a USB device in it then system will assign letters to them in the sequence as system find them during boot processes. Suppose during boot process Linux system detects SCSI first then SATA and then USB then SCSI drive will be given “sda” name SATA will be given “sdb” and USB Flash drive will be assigned “sdc” name. There are two types of partitions 1. Main Partition Types of Main Partition a. Primary Partitions b. Extended Partitions 2. Logical Partitions Logical partitions are created inside the Extended partition. Note: First 4 (1-4) letters are reserved for Main Partitions and from 5 to onward all letters are reserved for Logical partitions.

IDE IDE IDE IDE IDE

Type Type Type Type Type

Disk Primary Primary Primary Primary Primary

Master Master Master Master Master

Partitions First Main (Pri / Ext) Partition Second Main (Pri / Ext) Partition Third Main (Pri / Ext) Partition Fourth Main (Pri / Ext) Partition First Logical Partition

Linux Names hda1 hda2 hda3 hda4 hda5


IDE Type Primary Master

Second Logical Partition

hda6

Different Combinations IDE Type Secondary Master IDE Type Primary Slave IDE Type Secondary Slave SCSI Type Second Hard Drive USB Flash Drive

Partitions Third logical Partition

Linux Names hdc7

Second Main (Pri / Ext) Partition Second logical Partition Fourth logical Partition

hdb2 Hdb6 sdb8

-

Sda1

Boot Loader, MBR & First Sector of a Hard Drive: Boot Loader: It is a very small program, during boot process BIOS executes this program and this

program loads /boots operating system. During installation of an operating system, depending upon our provided settings the operating system writes boot loader program either in the MBR (first sector of hard drive) in first sector of the partition in which operating system is being installed. When we tell operating system to write Boot Loader program in first sector of the partition then we have to set that partition active. Master Boot Record is very first record of a hard drive. Where the operating system normally keeps Boot Loader program. When we create partitions on a hard drive then tools like fdisk keep Partition Table in MBR.

MBR:

First Sector of a Hard Drive: We can force Linux to keep its Boot Loader program in first sector of the partition in which we are installing Linux. But if we install Boot Loader program in first sector of a partition then we have to make that partition ACTIVE.

Initial Boot Process: -

-

During boot process BIOS after Power On Self Test (POST) checks Boot Priority and goes to the first sector (MBR) of the first boot device and tries to load Boot Loader program. If it does not find Boot Loader there then it checks the active partition of the hard drive and tries to find Boot Loader program on first sector of Active partition. Therefore when we keep Boot Loader program in first sector of a partition then we have to make that partition active. Boot Loader tells where the kernel is present and starts to load kernel. And then kernel finally loads complete operating system.

Registry Concept in Linux: Registry is a centralized place where windows operating system keeps current system, services and application configuration information. BUT in Linux we do not have centralize registry concept. For each task of the system and for each service and application we have separate configuration information (registry). These files are called configuration files. Most of the system and services’ configuration files are present in /etc directory. Directory and File Location: / | |_boot |

Parent of all directories. Contains files that are required to boot Linux system like kernel, boot loader files etc. Path: /boot


| |_etc Contains System, Services’ and application configuration files. | Path: /etc | |_home Contains home directories of all users created with default settings. Home directories | are given same name as user name. A home directory for a user is a place where user | have full rights. And can create files directories etc. | Path: /home | |_lost+found Similar to Recyclebin in windows | Path: / lost+found |_bin Contains user level commands that are found in almost all Uinux. | Path: /bin | |_sbin Contains admin level commands that are almost found in all Uinux. | Path: /sbin | |_lib Contains library files that are required by many commands | Path: /lib | |_dev Contains device files | Path: /dev | |_usr Volume wise it is the biggest directory of Linux operating system some of its sub | | directories are important. | | Path: /usr | | | |_bin Contains Linux specific user level commands. | | Path: /usr/bin | | | |_sbin Contains Linux specific admin level commands. Specially service related files are | | present in it. | | Path: /usr/sbin | | | |_src A main directory for keeping all kind of source codes for compilation. | Path: /usr/src | |_var var is for variable. Contents of this directories keep changing. | | Path: /var | | | |_log Main log directory for system, application and service log. It contains many sub | | directories. | | Path: /var/log | | | |_spool Main spool directories that contain separate spool directories for separate applications | | and services. Path: /var/spool | | | |_mail Contains Mail boxes of all users. | | Path: /var/spool/mail | |_mqueue Mail queue directories. Users’ incoming and out going mails are kept | | here before sending them out or delivering them to user’s mailboxes. In | | this directories we can process emails for iruses and Spam. | | Path: /var/spool/mqueue | | | |_cups Holds print jobs before printing. It is print spool directory. | Path: /var/spool/cups


| |_mnt | | |_tmp | |_opt | | |_proc

Default mount point. (will be explained later in “Mounting Process” section) Path: /mnt Temp directory to hold temporary files created during installation of software etc. Default location for third party software installation like Oracle etc. Path: /opt Keeps system, service and application status information. It is volatile it is populated as system boots and its contents are deleted in shutdown process.

Note: There are certain other directories but their function is not important especially at this stage. Mounting Process: In Linux we cannot access a medium (a device that hold data line hard drive, floppy, Cdrom and USB. To access these we have to mount them on an Empty directory (mount point). Then that directory / mount point is acts as the mounted medium. Suppose you have mounted /dev/hda1 partition on /mnt directory. Then /mnt will become that partition and what ever you copy in /mnt is actually goes to /dev/hda1. Mount command creates link between device file and mount point. After we umount /mnt it will become a normal directory again. Note: Mounted partitions can be viewed in “df” & “mount” command.

Linux / Unix Commands: Redhat Linux Command Prompt: Prompt is a place where we type commands. [root@ES4 etc]# root: represents user name ES3: Computer name / Host name etc: Present working directory Basic Structure of Unix/Linux Commands: [root@ES4 root]#COMMAND [-options] [operand] …. [operand] COMMAND: A command tells Linux/Unix system what task to do? Options:

Options tells Linux/Unix system How to perform that task? There are two forms of options in which we write them in commands.

1. Long Form: 2. Short Form:

Operand:

Long form is written with “–-“ and after it complete name like, --all Short form is written with “-“ and after it a single letter of the word –a

Operand tells where OR on what entity, to do this task?

In Linux Unix command manuals What ever inside [ ] is optional. Therefore in general saying for all commands “Options” and Operands are optional part of a command they may or may not be present in a command. Example:


[root@ES4 root]#ls ls command displays file and directories present in current directory [root@ES4 root]#ls –a -a is an option here tells Linux system to display files and directories and even display hidden files and directories. [root@ES4 root]#ls –a /etc /etc is an operand here. Above command tells Linux system to display all (even hidden) file and directories of /etc. Means apply command on /etc. Some Commands: ls [-ailR] ls: displays file and directories present in current or specified directory -a: Tells ls to display all files and directories -i: Tells ls to display inode number with file name -l: Tells ls to display long/detailed list -R: Tells ls to display recursively contents of sub directories as well. cd cd:

cd is used to change working directory.

pwd pwd:

To check present working directory.

hostname hostname:

displays computer name.

whoami whoami:

displays that you are logged in with this name.

Wc wc: -w -l -c

[-lcw] is used to calculate words, lines and characters in a file. Tells wc to count words Tells wc to display number of lines in given a file. Tells wc to calculate number of characters in given a file.


Turn static files into dynamic content formats.

Create a flipbook
Issuu converts static files into: digital portfolios, online yearbooks, online catalogs, digital photo albums and more. Sign up and create your flipbook.