Linux Notes

LINUX

What is an Operating System?

  • An operating system is a control program for a computer.

  • It acts as an interface to the hardware, making efficient use of it.

  • It allocates computer resources and schedules tasks.

  • It helps create and manage the file system.

LINUX Operating System

History of Linux

  • The history of Linux began in 1991.

  • Linus Torvalds created Linux when he was a student at the University of Helsinki, studying computer science.

  • In early 1991, he purchased an IBM-compatible personal computer that came with the MS-DOS operating system.

  • Linus was not satisfied with MS-DOS and wanted to use a UNIX operating system like he was accustomed to at the University.

  • He found that the least expensive UNIX he could buy was about $5,000 USD.

  • Driven by the desire to run a UNIX-like operating system on his personal computer, he set out to create Linux.

  • In March 1994, version 1.0 of the Linux kernel was released.

LINUX Features

  • Portability: Linux runs on many hardware platforms, from dedicated networking devices to phones, personal computers, and even supercomputers. Linux was developed on PC hardware using Intel processors and has been ported to more hardware platforms than any other operating system.

  • Multi-tasking: Linux system can run more than one program at a time, allowing users to perform less urgent jobs in the background while doing more important ones in the foreground.

  • Multi-user: Linux system can support more than one user at a time, each concurrently running a different set of programs.

  • Free (Open Source software): The source code is freely available, and you can run Linux on your hardware without paying a licensing fee in many cases.

  • Hierarchical file structure: The file structure resembles an inverted tree. All directories branch from the root directory, each containing one or more files. Each user has one primary directory and as many subdirectories as required.

Linux Software Components

  • The Linux software components consist of the User, Shell, Kernel and Hardware. There are multiple instances of the User and Shell.

Utilities
  • The Linux system includes a family of several hundred built-in commands called utilities or tools.

  • These utilities perform functions that are universally required by users.

  • Examples: Text editing, spell checking, mathematical calculations, printing, etc.

Shell
  • An interface to the kernel, hiding the complexity of the kernel’s functions from the user.

  • A program that reads and interprets the commands you enter and passes them to the kernel for processing.

  • Therefore, the shell acts as an interface between the user and the Kernel, insulating the user from the knowledge of the Kernel.

Kernel
  • The core of the Linux system is called the Kernel.

  • It is a collection of programs.

  • There is only one Kernel for any system.

  • It communicates directly with the system hardware.

  • Coordinates many functions, allocates memory, and other system resources to the processes going on at any given time.

  • Decides process priorities.

  • Keeps track of the contents and locations of all the files in the file systems.

  • Once the shell has translated the user commands into instructions, it is the kernel that carries out these instructions.

Shell prompt
  • An indication from the shell that it is ready to receive the next command from the command line.

  • A typical Linux prompt looks like: [ruwan@mycomputer ruwan]$ _

Linux Distributions

  • Fedora Core (Red Hat)

  • Damn Small Linux

  • SUSE Linux

  • Knoppix

  • Ubuntu

  • Puppy

  • MEPIS

  • Vector Linux

  • Mandriva

  • PCLinuxOS

  • Gentoo

  • SLAX

  • Debian

  • Slackware

Files and Directories

  • Within Linux, a file is any source from which data can be read, or any target to which data can be written.

  • Therefore, a file refers to a repository of data like a disk file or to a physical device (example: keyboard – source of I/P, display – O/P target, printers - O/P target).

  • Linux makes very little distinction between the various types of files. Therefore, the printer or tape drive is treated as a file in much the same way as a disk file.

Linux mainly has 3 types of files:
  • Ordinary files.

  • Directory files.

  • Device files.

Ordinary file (Regular file)
  • This is the traditional definition of a file.

  • Ordinary files contain data and are stored on disk or tape.

  • These are the files you will be working with most of the time.

Directory File
  • A directory is stored on disk and contains no data but keeps an account of all the files and subdirectories that it contains.

  • A directory file contains 2 fields:

    • Name of the files

    • Pointer to separate disk area which contains the file attributes (creator, read-only flags, etc.)

Device files
  • A device file is an internal representation of a physical device (example: printer, hard disk, terminal).

  • All the devices on your system can be accessed as files.

There are two types of users:
  • Ordinary users

  • Root (super user/system administrator)

Root
  • Root is the administrative user account created during installation and has complete access to the system.

Home Directory
  • When you log in to a system, Linux automatically places you in a directory called the home directory.

  • This is also known as the login directory.

File structure
File names:
  • No two files in the same directory can have the same name.

  • Files in different directories can have the same name.

File names can have:
  • Uppercase letters, lowercase letters, numbers, underscore, period.

  • A file name can contain up to 256 characters.

File name extension
  • A file can have any number of extensions.

  • Therefore, you can use extensions freely to make the file names easy to understand.

  • Example: note.4.05.2005

Invisible file names
  • A file name beginning with a period is called an invisible file name.

  • ls does not normally display invisible files.

Directory Structure

  • / – The Root Directory

    • Everything on your Linux system is located under the / directory, known as the root directory.

    • The administrator is the owner of the primary folder, the root, and therefore has primary authority over the whole system.

  • /bin – Essential User Binaries

    • The /bin directory contains the essential user binaries (programs) that must be present when the system is mounted in single-user mode.

    • Applications such as Firefox are stored in /usr/bin, while important system programs and utilities such as the bash shell are located in /bin.

  • /boot — Static files of the boot loader

    • The /boot directory contains the files needed to boot the system – for example, the GRUB boot loader’s files and your Linux kernels are stored here.

    • The boot loader’s configuration files aren’t located here, though – they’re in /etc with the other configuration files.

  • /dev — Device files

    • Contains references to all the CPU peripheral hardware, which are represented as files with special properties.

    • These include terminal devices, usb, or any device attached to the system.

    • Example: /dev/console, /dev/tty, /dev/ttyS0 etc.

  • /home – Home Folders

    • The /home directory contains a home folder for each user. For example, if your user name is Rumy, you have a home folder located at /home/rumy.

    • This home folder contains the user’s data files and user-specific configuration files. Each user only has write access to their own home folder and must obtain elevated permissions (become the root user) to modify other files on the system.

  • /usr – User Binaries & Read-Only Data

    • The /usr directory contains applications and files used by users, as opposed to applications and files used by the system.

    • The /usr directory also contains other directories – for example, architecture-independent files like graphics are located in /usr/share.

File system

  • The file system in Linux is a collection of all these files organized in a hierarchical (an inverted tree) structure.