linux basics 1/2

36
Linux Basics - 1/2 [email protected] Jul 2013 Saturday, July 27, 13

Upload: claudio-montoya

Post on 15-May-2015

340 views

Category:

Technology


0 download

DESCRIPTION

Linux Basics tutorial 1 / 2

TRANSCRIPT

Page 1: Linux basics 1/2

Linux Basics - 1/[email protected]

Jul 2013

Saturday, July 27, 13

Page 2: Linux basics 1/2

LinuxIs a Unix-like operating system (OS) created by Linus Torvalds. He developed Linux because he wasn't happy with the currently available options in Unix and felt he could improve it. So he did what anybody else would do, and created his own operating system.

Saturday, July 27, 13

Page 3: Linux basics 1/2

LinuxWhen Linus finished building a working version of Linux, he freely distributed the OS, which helped it gain popularity. Today, Linux is used by millions of people around the world. Many computer hobbyists (a.k.a. nerds) like the operating system because it is highly customizable. Programmers can even modify the source code and create their own unique version of the Linux operating system.

Saturday, July 27, 13

Page 6: Linux basics 1/2

Linux DistrosA Linux distribution (often called distro for short) is a member of the family of Unix-like operating systems built on top of the Linux kernel. Such distributions are operating systems including a large collection of software applications such as word processors, spreadsheets, media players, and database applications.

Saturday, July 27, 13

Page 7: Linux basics 1/2

Linux DistrosPopular main distros

• Debian

• RedHat

• Suse

• Gentoo

• Slackware*

Saturday, July 27, 13

Page 8: Linux basics 1/2

Linux DistrosPopular child distros

• Ubuntu (Debian based)

• Fedora (RedHat)

• Centos (RedHat)

http://upload.wikimedia.org/wikipedia/commons/1/1b/Linux_Distribution_Timeline.svg

Saturday, July 27, 13

Page 9: Linux basics 1/2

Which Distro?It depends on

• Software requirements

• Team or staff knowledge

• The one that makes you happy

Saturday, July 27, 13

Page 10: Linux basics 1/2

Uses

• Desktop

• Phones

• Tablets

• TV’s

• Servers

Saturday, July 27, 13

Page 11: Linux basics 1/2

How it works?1. System startup - BIOS / BootMonitor

2. Stage #1 bootloader (master boot record)

3. Stage #2 bootloader (LILO GRUB)

4. Kernel

5. Init

6. Runlevel

Saturday, July 27, 13

Page 12: Linux basics 1/2

How it works?1. BIOS

• BIOS stands for Basic Input/Output System

• Performs some system integrity checks

• Searches, loads, and executes the boot loader program.

• It looks for boot loader in floppy, cd-rom, or hard drive. You can press a key (typically F12 of F2, but it depends on your system) during the BIOS startup to change the boot sequence.

• Once the boot loader program is detected and loaded into the memory, BIOS gives the control to it.

• So, in simple terms BIOS loads and executes the MBR boot loader

Saturday, July 27, 13

Page 13: Linux basics 1/2

How it works?2. MBR

• MBR stands for Master Boot Record.

• It is located in the 1st sector of the bootable disk. Typically /dev/hda, or /dev/sda

• MBR is less than 512 bytes in size. This has three components 1) primary boot loader info in 1st 446 bytes 2) partition table info in next 64 bytes 3) mbr validation check in last 2 bytes.

• It contains information about GRUB (or LILO in old systems).

• So, in simple terms MBR loads and executes the GRUB boot loader.

Saturday, July 27, 13

Page 14: Linux basics 1/2

How it works?3. GRUB

• GRUB stands for Grand Unified Bootloader.

• If you have multiple kernel images installed on your system, you can choose which one to be executed.

• GRUB displays a splash screen, waits for few seconds, if you don’t enter anything, it loads the default kernel image as specified in the grub configuration file.

• GRUB has the knowledge of the filesystem (the older Linux loader LILO didn’t understand filesystem).

• Grub configuration file is /boot/grub/grub.conf (/etc/grub.conf is a link to this).

• So, in simple terms GRUB just loads and executes Kernel and initrd images.

Saturday, July 27, 13

Page 15: Linux basics 1/2

How it works?4. Kernel

• Mounts the root file system as specified in the “root=” in grub.conf

• Kernel executes the /sbin/init program

• Since init was the 1st program to be executed by Linux Kernel, it has the process id (PID) of 1. Do a ‘ps -ef | grep init’ and check the pid.

• initrd stands for Initial RAM Disk.

• initrd is used by kernel as temporary root file system until kernel is booted and the real root file system is mounted. It also contains necessary drivers compiled inside, which helps it to access the hard drive partitions, and other hardware.

Saturday, July 27, 13

Page 16: Linux basics 1/2

How it works?5. Init

• Looks at the /etc/inittab file to decide the Linux run level.

• Following are the available run levels

• 0 – halt

• 1 – Single user mode

• 2 – Multiuser, without NFS

• 3 – Full multiuser mode

• 4 – unused

• 5 – X11

• 6 – reboot

• Init identifies the default initlevel from /etc/inittab and uses that to load all appropriate program.

• Execute ‘grep initdefault /etc/inittab’ on your system to identify the default run level

• If you want to get into trouble, you can set the default run level to 0 or 6. Since you know what 0 and 6 means, probably you might not do that.

• Typically you would set the default run level to either 3 or 5.

Saturday, July 27, 13

Page 17: Linux basics 1/2

How it works?6. Runlevel

• When the Linux system is booting up, you might see various services getting started. For example, it might say “starting sendmail …. OK”. Those are the runlevel programs, executed from the run level directory as defined by your run level.

• Depending on your default init level setting, the system will execute the programs from one of the following directories.

• Run level 0 – /etc/rc.d/rc0.d/

• Run level 1 – /etc/rc.d/rc1.d/

• Run level 2 – /etc/rc.d/rc2.d/

• Run level 3 – /etc/rc.d/rc3.d/

• Run level 4 – /etc/rc.d/rc4.d/

• Run level 5 – /etc/rc.d/rc5.d/

• Run level 6 – /etc/rc.d/rc6.d/

Saturday, July 27, 13

Page 18: Linux basics 1/2

How it works?6. Runlevel

• Please note that there are also symbolic links available for these directory under /etc directly. So, /etc/rc0.d is linked to /etc/rc.d/rc0.d.

• Under the /etc/rc.d/rc*.d/ directories, you would see programs that start with S and K.

• Programs starts with S are used during startup. S for startup.

• Programs starts with K are used during shutdown. K for kill.

• There are numbers right next to S and K in the program names. Those are the sequence number in which the programs should be started or killed.

• For example, S12syslog is to start the syslog deamon, which has the sequence number of 12. S80sendmail is to start the sendmail daemon, which has the sequence number of 80. So, syslog program will be started before sendmail.

Saturday, July 27, 13

Page 19: Linux basics 1/2

How it works?

Saturday, July 27, 13

Page 20: Linux basics 1/2

Installation Methods

• CD or DVD

• Normal

• Live

• USB installer

• Network installation

• Virtual installation (iso file)

Saturday, July 27, 13

Page 21: Linux basics 1/2

System Requirements Desktop

• 700Mhz processor

• 512Mb RAM

• 5Gb hard-drive space

• VGA 1024x768

• CD/DVD or USB port for installer media

• Internet access (not required but helpful)

Saturday, July 27, 13

Page 22: Linux basics 1/2

System Requirements Server CLI

• 300Mhz processor

• 128Mb RAM

• 1Gb hard-drive space

• VGA 640x480

• CD

Saturday, July 27, 13

Page 23: Linux basics 1/2

Workshop1. Internet access required.

2. Create a new virtual machine on Oracle VirtualBox with the following settings.

1. 512Mb RAM

2. 5Gb hard disk

3. Use debian iso image

3. Star the virtual machine

Saturday, July 27, 13

Page 24: Linux basics 1/2

Workshop4. Choose the installation language

5. Choose the country or territory

6. Choose the locale settings

7. Choose the keymap to use

8. Type the hostname (linux-#x)

9. Type the domain name

Saturday, July 27, 13

Page 25: Linux basics 1/2

Workshop10.Type the root password (twice)

11.Create a new user

• Name, username and password

12.Choose the timezone

13.Chose the partition method (Guided - entire disk)

14.Select the hard disk to use

Saturday, July 27, 13

Page 26: Linux basics 1/2

Workshop15.Select partition scheme (all files in one partition)

16.Finish partitioning

17.Write changes to disk

18.Choose debian mirror (Mexico)

19.Choose archive mirror (ftp.mx.debian.org)

20.Use proxy? No

21.

Saturday, July 27, 13

Page 27: Linux basics 1/2

Installation facts• Language?

• Locale settings?

• Territory?

• Hostname and domainame?

• Root user?

• Hard disk to use?

• Partition scheme?

• Mirror?

• Packages?

Saturday, July 27, 13

Page 28: Linux basics 1/2

root or superuserIn computing, the superuser is a special user account used for system administration. Depending on the operating system, the actual name of this account might be: root, administrator, admin or supervisor. In some cases the actual name is not significant, rather an authorization flag in the user's profile determines if administrative functions can be performed.

In operating systems which have the concept of a superuser, it is generally recommended that most application work be done using an ordinary account which does not have the ability to make system-wide changes.

Saturday, July 27, 13

Page 29: Linux basics 1/2

hostnameA hostname is a label that is assigned to a device connected to a computer network and that is used to identify the device in various forms of electronic communication such as the World Wide Web, e-mail or Usenet. Hostnames may be simple names consisting of a single word or phrase.

Saturday, July 27, 13

Page 30: Linux basics 1/2

domainameA domain name is an identification string that defines a realm of administrative autonomy, authority, or control on the Internet. Domain names are formed by the rules and procedures of the Domain Name System (DNS).

Saturday, July 27, 13

Page 31: Linux basics 1/2

Hard disk

• Linux identified the hard disk with a OS resource. Typically this are the resources.

• IDE

• SCCI

Saturday, July 27, 13

Page 32: Linux basics 1/2

PartitionsPartitions are divisions in the formatting of the hard disk.  It’s a logical – as opposed to a physical – division, so you can edit and manipulate them for various purposes.  Think breaking a disk into two configuration parts.  Partitions are really handy because they act as a sandbox. f you have a 1 TB hard drive partitioned into a 250 GB partition and a 750 GB partition, what you have on the latter will not affect the other, and vice versa.  You can share one of those partitions on the network and never worry about people accessing information on the other.

Saturday, July 27, 13

Page 33: Linux basics 1/2

Partition SchemesIt depends on the using of the SO and the size of the hard disk

• Desktop

• All files in one partition

• Server

• Split the data in multiple partitions

Saturday, July 27, 13

Page 34: Linux basics 1/2

Partition SchemesServer partition scheme

Saturday, July 27, 13

Page 35: Linux basics 1/2

Partition types• Foreign partitions (other SO)

• Primary partitions

• The number of partitions on an Intel-based system was limited from the very beginning: The original partition table was installed as part of the boot sector and held space for only four partition entries. These partitions are now called primary partitions.

• Logical partitions

• One primary partition of a hard drive may be subpartitioned. These are logical partitions. This effectively allows us to skirt the historical four partition limitation.

• Swap partitions

• If you have too many processes running on a machine, the kernel will try to free up RAM by writing pages to disk. This is what swap space is for. It effectively increases the amount of memory you have available. However, disk I/O is about a hundred times slower than reading from and writing to RAM. Consider this emergency memory and not extra memory.

Saturday, July 27, 13

Page 36: Linux basics 1/2

Partition - File Systems/ - root partition

/var - This fs contains spool directories such as those for mail and printing. In addition, it contains the error log directory. If your machine is a server and develops a chronic error, those msgs can fill the partition. Server computers ought to have /var in a different partition than /.

/usr - This is where most executable binaries go. In addition, the kernel source tree goes here, and much documentation.

/tmp - Some programs write temporary data files here. Usually, they are quite small. However, if you run computationally intensive jobs, like science or engineering applications, hundreds of megabytes could be required for brief periods of time. In this case, keep /tmp in a different partition than /.

/home - This is where users home directories go. If you do not impose quotas on your users, this ought to be in its own partition.

/boot - This is where your kernel images go. See discussion above for placement on old systems.

Saturday, July 27, 13