piyushp_20
Geekologist
Read this article first *www.itwire.com/content/view/20861/1141/
Introduction to Linux
Linux is a UNIX like operating system which runs on a variety of platforms, especially personal computer with Intel 80386 processors or better.
It supports a wide range of software, from TEX, to the XWindow system, to the GNU C/C++ compiler, to TCP/IP. It’s a versatile implementation of UNIX, and freely distributed under the terms of the GNU General Public Lisence.
Linux can turn any 80386 or better personal computer into a workstation that puts the full power of system to manage financial and hospital records, distributed computing environments, and telecommunications.
Universities worldwide use Linux to teach courses on operating system programming and design.
Computing enthusiasts everywhere use Linux at home for programming, productivity and all-around hacking.
What makes Linux so different is that it is a free implementation of UNIX. It was and still is developed cooperatively by a group of volunteers, primarily on the Internet, who exchange code, report bugs, and fix problems in an open-ended environment.
Architecture
*img396.imageshack.us/img396/7313/architectureuw0.png
Linux OS is a modular system, which means that the components can function without one another. Because of its modular nature, you can create a highly customized Linux OS based on you individual requirements. Some of the typical Linux modules are explained below:
Kernel
It is the core component of the OS.
It coordinates communication between the hardware and other software components.
It is the only component that is technically Linux. All other components are add-ons that turn the system into a fully-functional OS.
Shell
It is the user interace that accepts and interprets commands (either from a command prompt or a script) and forwards them to the kernel.
A Linux shell is comparable to the DOS interpreter/DOS prompt.
The most common shell is bash (Bourne-Again Shell).
Graphical User Interface (GUI)
The GUI is responsible for drawing graphical elements on the computer screen.
The Linux GUI was designed to work the same way regardless of the video hardware on the computer system.
The most common GUI is the X-Windows system.
Window Manager / Desktop Environment
It modifies the GUI output that comes from X-Windows.
To change or modify the X-Windows output, you can simply change the window manager.
You can also use a desktop environment with a window manager.
A desktop environment provides software (e.g. web browsers and file managers) and gives users access to common tasks.
KDE (Kommon Desktop Environment) uses K window manager and GNOME (GNU Object Model Environment) uses Metacity window manager.
Windows Emulator
A Windows emulator is an implementation of the Microsoft Windows API.
The emulator lets you run Windows applications on Linux without running the Windows OS.
Wine is the best example of the Windows Emulator.
Boot Loader
A boot loader runs after the system executes the BIOS ROM and POST functions.
It loads the Linux kernel from the boot partition on the hard disk.
It is also used to boot other OS present on the computer.
Applications and Utilities
Utilities are special programs that help you manage the system.
Applications that let you use the computer for specific tasks (such as word processing, listening to music, or managing data).
Daemons (services)
Daemons are programs that run in the background, providing additional functionality to a system.
The Windows equivalent of a daemon is a service.
Linux Hierarchy
Directory - Description
/ - The / character represents the root directory of the Linux system. All directories are below the / (root directory) of the system.
/bin - The /bin directory contains binary commands that are available to all users.
/boot - The /boot directory contains the kernel and boot loader files.
/dev - The /dev directory contains device files.
/etc - The /etc directory contains configuration files specific to the system.
/home - The /home directory contains by default the user home directories.
/intitrd - The /initrd directory is used during the boot process to hold the initial RAM drive image.
/lib - The /lib directory contains shared program libraries and kernel modules.
/media - The /media directory contains the /cdrom and /floppy directories. It is the point where CD-ROM and floppy drives can be mounted according to the FHS (Filesystem Hierarchy Standard) v2.3
/mnt - The /mnt directory is an empty directory. This was the mount point for CD-ROM and floppy drives prior to FHS v2.3
/opt-The /opt directory contains the additional programs.
/proc - The /proc directory contains information about the system state and processes.
/root - The /root directory is the root user’s home directory. Do not confuse /root with the root of the system (/).
/sbin - The /sbin directory contains system binary commands.
/srv - The /srv directory contains files for services like the FTP and Web servers.
/sys - The /sys directory is new with release 2.6. It takes some of the system state date that was previously contained in /proc.
/tmp - The /tmp directory contains temporary files created by programs during system use.
/usr - The /usr directory contains system commands and utilities. /usr holds the following directories:
·/usr/bin
·/usr/lib
·/usr/local
·/usr/sbin
·/usr/X11R6 (for the X-Windows system)
Depending on the implementation, the /usr directory might also include the /usr/doc subdirectory (or /usr/share/doc subdirectory) to hold documentation accessible to all users.
/var - The /var directory contains data files that change constantly. Standard subdirectories include:
·/var/mail (holds e-mail in boxes)
·/var/spool (holds files waiting for processing, such as print jobs or scheduled jobs)
·/var/www (holds www or proxy cache files)
Linux Distribution
A Linux distribution is a collection of components packaged to work together as a complete system. A package is the collection of components (tools, software, utilities, devices, etc) put together to make a distribution.
Each package (distribution) can use a package manager, which is a tool that installs and maintains a Linux package.
Distribution - Characteristics.
Example :-
RPM - RPM distribution uses Red Hat package manager. These are most common commercially available distributions.
Example :- Red Hat, SUSE, Mandrake.
Debian - It uses Debian package manager. It contains largest collection of packages.
Example :- Ubuntu, Xandros.
.tar.gz/.tgz/Slackware - This doesn’t use a package manager.
Example :- College Linux, SLAX.
Source-based - These are designed to work from source code. User compiles the source code and then installs it.
Example :- Gentoo.
Installation
Note: Installation process of all the distribution differs in some or the other manner, so the following step-by-step guide gives the general process.
·Identify network requirements, select a distribution, verify that all hardware meets system requirements.
·Select an Installation file location (*) and Installation method (**).
·Start the installation.
·Choose the installation language and the system keyboard and mouse.
·Partition the hard disk.
·Configure the boot loader.
·Choose a system language and time zone.
·Create user accounts and configure authentication.
(*)
(**)Installation file location - Description
CD-ROM or Removable media - Installation files are on a disk or other removable media such as USB.
Network - Installation files are located on a shared directory on the network.
Disk image - Using disk image, to install Linux on one system and then use imaging tools to replicate installation on other computers.
Installation method - Description
GUI - You make choices using the mouse and the keyboard from Graphical screens. It is the default install on most distributions.
Text - It gives the basic text screens bypassing the GUI. We use this when the system is really old.
Scripted - You answer all the installation questions. Responses are stored in a file that is then read by the install program. Otherwise known as fully automated installation
Part - II Shell and some commands
The most common shells which you will come across are
Bourne Shells – It use syntax and conventions similar to a UNIX shell. The bash (bourne-again shell) includes many improvements and is the default shell for new Linux installations.
C-Shell - it uses syntax which is similar to the C programming language.
In linux shell is just a component so you can easily choose the shell which you want to use or can have multiple shells at a same time.
Terminology used in this guide
NOTE:- please make sure that linux is case sensitive, even spaces matter.
Path – It is the location of an object in the file system.
Path variable – It stored the list of directories that are searched to execute a command without a absolute or relative path.
Working Directory – It is the directory a user is currently in. (to know in which directory are you than just type the command “pwd”.)
File system commands
Command - Description
lsorls path - View a list of files in a directory
ls –l - View a long listing of files, including file type, permissions, owners, file size and access time.
ls –a - View a listing of all files, including hidden files.
ls –aR - View a listing of files, including hidden files, and including files in all subdirectories (recursive).
cd /path - When used with a relative path, moves down the directory structure from the current working directory.
cd .. - Move up one level in the directory structure from the current working directory.
cd or cd ~ - Change the working directory to the user’s home directory.
pwd - Shows the current working directory as screen output (stands for print working directory).
Some facts:
·The file name of a hidden file begins with a period “.” (dot). There is no hidden attribute in Linux.
·To move directly to the root directory, simply type cd /
·If the output from a command scrolls, than in that case add | more with the command and the screen will show as one screen at a time.
·To run a file from the current directory than add ./ before the filename.
File viewing and searching commands
Command - Description
Example:-
| - Redirect the output of one command to use it as input for another command. The pipe (|) is one of several redirectors.
Example:- ls –l | less redirects the output of the ls command into the less paging program.
> - Redirect the output of a command into a file. This is the single redirector, which overwrites the files contents.
Example:- echo ‘This has been overwritten’ > filename redirects the output of the echo command to the file ‘filename’ overwriting the data.
< - Redirect a file to the standard input of a command.
Example:- cat </etc/hosts redirects /hosts file to act as input for the cat command.
>> - Redirect the output of a command into a file. This is the double redirector, which appends the redirected output to the end of the file.
Example:- echo ‘bla bla bla’ >> filename redirects the output of the echo command to the file ‘filename’ appending the text.
cat filename - Display the contents of a file. You can use a second filename parameter with cat to concatenate two files.
Example:- cat /etc/lilo.conf displays the contents of the lilo.conf file.
cat filename filename2 - Append filename2 to the end of filename and display the result on the screen.
Example:- cat /etc/lilo.conf /etc/passwd appends the passed file to the end of the lilo.conf file and displays the results on screen.
cat filename | more - Show the contents of a file, one screen at a time.
Example:- cat /etc/passwd | more displays the passwd file one line at a time.
cut options filename
- View the selected columns or fields from one or more files.common options:
-b Show bytes as a list.
-c Show characters as a list.
-d Set field delimiter
-f Show fields
Example:- cut –d: -f /etc/passwd displays usernames(in the first colon-delimited from the passwd file).
echo ‘text’ - Display the text as output.
Example:- echo ‘This is some text’ displays the message on the screen.
findpath options ‘string’ - Descend through directories searching for files with certain attributes or executing commands.
Example:- find /etc –name ‘*.conf’ finds all files in the /etc directory that end in .conf
grep ‘text string’ filename - Search for the text string and display lines from text
files that match the text string.
Example:- grep ‘root’ /etc/passwd finds and displays all lines in the passwd file containing the text string root.
head filename - View the first ten lines of a file.
Example:- head /etc/passwd displays the first ten lines of the passwd file.
locate filename - Locate files with the designated filename.
Example:- locate usr displays all files matching the usr filename.
tail filename - View the last ten lines of a file.
Example:- tail /etc/passwd displays the last ten lines of passwd file.
Whereis options filename
- Locate the binary, source, or manuals (man) files for the designated file name.Common options:
-b binary
-s source
-m manual
-u usual
Example:- whereis passwd displays the paths to the source, binary, and man pages of the passwd file.
which commandname - Find and display the pathname for the designated command’s executable file.
Example:- which vi displays the path for the vi program executable.
To be continued......
Last edited: