You are on page 1of 57

Linux Fundamentals

Courseware Designed & Written by P Narasimhan

Acknowledgement
Some portions of this reference documentation has been derived from various sources including the HOWTO's, Guides from the Linux Documentation Project , Man & Info pages, FAQ's and technical articles from several other sources on the World Wide Web. We are thankful to and do hereby sincerely acknowledge the creators of these documents. This courseware is given free of cost as a reference material covering the topics dealt with during the training programme(s), precisely for internal circulation only and is not intended for sale anywhere. Linux is the Trademark of Linus Torvalds and all other brand names and trademarks are properties of their respective owners. PNarasimhan

No Warranty Clause
The authors disclaim all warranties with regard to this document and the configurations covered thereto, including all implied warranties of merchantability and fitness for a certain purpose. In no even shall the authors be liable for any special, indirect or consequential damages or any damage whatsoever resulting from loss of data, or profits whether in action of contract, negligence or other tortuous action, arising out of or in connection with the use of this document or any of the software mentioned therein .

PNarasimhan

TABLE

OF

CONTENTS

LA-011 : LINUX INSIGHT


CHAPTER-I CHAPTER-II SYSTEM : AN OVERVIEW OF THE ORIGINS OF UNIX & LINUX : USER INTERFACES : THE BASH SHELL & X WINDOW LINUX INSTALLATION

CHAPTER-III : CHAPTER-IV CHAPTER-V CHAPTER-VI

:RUNNING SHELL COMMANDS & HELP-LINE :LINUX FILE SYSTEM & SHELL COMMANDS : THE VI EDITOR

PNarasimhan

CHAPTER -1 : AN OVERVIEW OF THE ORIGINS OF UNIX AND LINUX

During the early days of computing it was very difficult to interact with computers as many of the luxuries with which we are familiar today were not available those days. It was left to a few dedicated Engineers at AT&T ( Bell Laboratories) to initiate research to arrive at what is now known as an Operating System during the early 1960's. They named the project as 'MULTICS' (Multiplexed Information & Computing Systems) and the other organisations which formed part of this were General Electric Co. and MIT. As sufficient interest was not shown by the others AT&T walked out of this project and initiated a new one, UNICS later renamed as Unix. The first version was created in Bell Labs in the year 1969 initially through assembler code( Machine Level Language) and later ported to a new high level programming language called B, which was co-developed by Ken Thompson and Dennis Ritchie. The Unix operating system thus developed was ported on to PDP machines which were lying unused. It is quite interesting to note that this high-end OS along with its' source code was given away for as low a price as US $ 15-00 by AT&T. Further development took place and a higher and more powerful language C came into existence, once again at Bell Labs. The entire code of Unix was rewritten in 'C' by the year 1973. This version of Unix came to be known as System V with releases up to 4 and christened as SVR4. Moreover the AT&T Unix code was used by a PNarasimhan

research group at University of California, Berkeley known as Berkeley Software Distribution (BSD). The BSD group made significant contribution in the area of development of various applications for Unix broadly referred to as BSD tools/utilities. However, the same AT&T code was purchased by hardware giants such as IBM, HP, Sun Micro Systems who made changes to suit their hardware architecture and sold the modified OS under different brand names as AIX, UX , and Sun OS(renamed later as Solaris) respectively. Thus it is recorded that Unix became a proprietary OS and a hand maid in the hands of the companies almost to the end of 1970's, although the basic work was done by the dedicated researchers at Bell Laboratories. The basic beauty of the design methodology is that the output of one program can be the input for another. This gives the user the flexibility to combine many small programs together to perform a larger, more complex task instead of relying upon a monolithic single application. In the year 1984, Richard Stallman, a research student at MIT started the GNU Project (GNU's Not Unix), a recursive acronym to refer to an environment to develop a FREE version of a complete Unix-like operating system which is free software: the GNU system. Variants of the GNU operating system, which use the kernel called Linux, are now widely used; though these systems are often referred to as Linux, they are more accurately called GNU/Linux systems. GNU is a recursive acronym for GNU's Not Unix; it is pronounced guh-noo, like canoe. Many of the free software applications are under GNU's General Public License or GPL in short which forms the legal back bone . The current version is 2.0 but version 3.0 is already framed and goes much beyond the terms of the older one offering greater freedom to the users & developers. What is Free Software? ``Free software'' is a matter of liberty, not price. To understand the concept, you should think of ``free'' as in ``free speech,'' not as in ``free beer.'' Free software is a matter of the users' freedom to run, copy, distribute, study, change and improve the software. More precisely, it refers to four kinds of freedom, for the users of the software: PNarasimhan

The freedom to run the program, for any purpose (freedom 0). The freedom to study how the program works, and adapt it to your needs (freedom 1). Access to the source code is a precondition for this. The freedom to redistribute copies so you can help your neighbor (freedom 2). The freedom to improve the program, and release your improvements to the public, so that the whole community benefits (freedom 3). Access to the source code is a precondition for this.

He wanted the GNU Project to initially develop applications ,the ultimate goal being the design of a new 32-bit kernel when the hardware industry would be read for such an eventuality. He wanted to prevent such occurrences as seizure of software in the future and hence created a legal basis in the form of General Public License or GPL as it has come to be known as. Under the GNU GPL Act, the software is first Copyrighted by the creator of software, thereby preventing someone else from seizing control of it at a later date. Rights are granted to the public to use, copy, redistribute, and also to modify/recreate freely under certain carefully defined conditions. These developments have necessarily to carry with them the source code of the originally created one and the modified source as well. The withholding of source code will be viewed as curtailment of programmer's freedom to modify & improve software. His goal was to recreate an environment free of restrictions with utilities and tools that are totally 'Free'. The GNU ( GNU's Not Unix )Project is being administered by Free Software Foundation which was established to help raise funds for making free software. FSF is the principal organizational sponsor of the GNU Project. The FSF receives very little funding from corporations or grant-making foundations, but relies on support from individuals. Richard Stallman a formidable programmer himself, wrote an amazing amount of software which includes the GCC (GNU 'C' Compiler) and the versatile 'EMACS' editor. The Minix (Miniature Unix on Intel 386) project was initiated by that famous Professor Andrew Tannenbaum in 1989 as an educational version of Unix. PNarasimhan

Unfortunately this code could not execute bsd or gnu applications on Intel 386 based systems as it was intended to be. The MINIX project took a new turn with the involvement of a 21 year-old Finnish Computer Science Student at the University of Helsinki, named Linus Benedict Torvalds in the year 1991. He made modifications to the MINIX code with which he successfully executed a few Unix programs on Intel386 box. He posted the code on Minix Mail Group with a request to other programmers to help him build it, precisely on 25th August, 1991. The response was overwhelming and went beyond the wildest expectations. What began as a student hobby project rapidly developed into a serious efforts at developing an operating system within a short period of a couple of months.

PNarasimhan

Torvalds found everything that is required of an OS in BSD and GNU utilities with which he integrated his kernel, Linux. He put all this together and wanted to name the OS as FREAX, perhaps to denote it's freak development. However, his friends persuaded him to associate the OS with himself: Linux, Linus's Unix which he did after much hesitation. It is interesting to note that from the very inception Linux development took place on a collaborative and collective basis involving thousands of users/developers across the net. This scenario led a prominent Unix developer, Eric, S Raymond to take a fancy to this model known as an Open Source Development. He wrote an interesting article christened as The Cathedral & the Bazaar which is available at : http://www.firstmonday.dk/issues/issue3_3/raymond/ . He said : Linux overturned much of what I thought I knew. I had been preaching the Unix gospel of small tools, rapid prototyping and evolutionary programming for years. But I also believed there was a certain critical complexity above which a more centralized, a priority approach was required. Linus Torvalds' style of development release early and often, delegate as many things as you can, be open to the point of promiscuity - came as a surprise. No quiet, reverent cathedral-building here - rather, the Linux community seemed to resemble a great babbling bazaar of differing agendas and approaches (aptly symbolized by the Linux archive sites, who'd take submissions from anyone) out of which a coherent and stable system could seemingly emerge only by a succession of miracles. Linus' open development policy was the very opposite of cathedral-building. Linus seems to me to be a genius of engineering and implementation, with a sixth sense for avoiding bugs and development dead-ends and a true knack for finding the minimum-effort path from point A to point B. Indeed, the whole design of Linux breathes this quality and mirrors Linus' essentially conservative and simplifying design approach. Given a large enough beta-tester and co-developer base through the medium of the World Wide Web, almost every problem will be characterized quickly and the fix obvious to someone. Thus ran the First Law of Linus : Given enough eye balls, all bugs are shallow. Sociologists years ago discovered that the averaged opinion of a mass of quality expert (or equally ignorant) observers is quite a bit more reliable a predictor than that

PNarasimhan

of a single randomly-chosen one of the observers. They called this the "Delphi Effect". It appears that what Linus has shown is that this applies even to debugging an operating system - that the Delphi effect can tame development complexity even at the complex level of an OS kernel. LINUX : The advantages

Zero Price Point Do-it-yourself flexibility Freedom from User licensing Stability Performance Standards Compliance Interoperability Virus-proof Strong cryptography Diverse Hardware Support Linux is not to considered a cooler alternative to MS-Windows, just cheaper & more stable, virus-free etc. as a few dub that to be. It is much more than that; the original Unix qualities great expressive power combined with simplicity & elegance, remain untarnished. This approach is based on the proven track record of Unix as in the maxim divide and conquer.On Unix systems small utilities/tools such as awk, sed, find, grep are combined to give you the power to solve the problems. These are small, modular tools that can be assembled in different ways. However, Linux is not Unix, as it is written literally from scratch without a single line of code from Unix. It is Unix-like operating system or a Unix clone. Linus Torvalds based his Linux code on POSIX standards set by IEEE, and that unparalled book The Design of the Unix Operating System by Maurice J. Bach.

Linux Support The very first company to promote Linux commercially has been the company known as Walnut Creek CDROM which first released Slackware Linux based on Linux kernel version 1.0 in the year 1994. PNarasimhan

This development triggered other Linux companies to come into existence and release their own distributions of Linux,some of which are listed below :

Slackware Linux Debian Linux ( A totally community driven project) RedHat Linux SuSE Linux ( A German company now acquired by Novell) Mandriva Linux Knoppix( Developed by Dr. Knopper as a Live CD based on Debian) Ubuntu ( A Debian Derivative) Damn Small Linux ( A mini Linux distribution) Linux PPC Gentoo Linux

Fedora Project The Fedora Project is sponsored by RedHat but not supported by the said company, The first version Fedora Core-1 got released in 2003. There are core releases of Fedora with the latest being Fedora 17 released in April 2012. In between core releases there are test releases as well which are nothing but beta versions. The detailed documentation on various aspects of Fedora is available at : http://www.fedora.redhat.com http://fedoranews.org http://fedora project.org http://www.fedorafaq.org/ ThecurrentpopulardistributationofLinuxisUbuntuversion12.04releasedinApril2012.Theofficial websiteisubuntu.comandthelinkstohelpanddocumentationareallpresentthere.Itisatotallyfree softwareandcanbedownloadedfromtheirwebsite.ThereischoiceofeitherinstallingtheOSonyour harddiskorjusttryitontheLiveCD/DVD/PenDrivewithoutaninstallation.

PNarasimhan

Application Base of Linux Network Servers DNS, DHCP servers Apache Web Server ( Widely & Largely used ) Squid Proxy Server Sendmail, Qmail, Postfix Mail Servers NFS and NIS servers ( Integrating a homogeneous network) Samba Server ( Integrating a heterogeneous network) RDBMS PostgreSQL, MySQL ( Open Source Tools),DB2 from IBM, Oracle 10g Office Automation Open Office-2.0 ,StarOffice (Sun Microsystems), Koffice, Gnu Cash ( Accounting software). Internet Related

Mozilla, Firefox,Opera, - Browsers Kmail, Evolution, Mozilla-ThunderBird - Mail Clients Yahoo Messenger, Gaim, ICQ Currently Internet Telephony is available through Skype, Ekiga Softphone, and Gizmo Projects as well.

MiscellaneousApplications IBM ViaVoice : Voice Recognition software Hylafax : Fax Server Backup Utilities: BRU Backup & Restore Utility, Amanda, Arkeia Graphic tools such as GIMP (similar to Photoshop) Web Authoring tool : NVU

PNarasimhan

Desktop publishing Tool : Scribus (similar to Corel Draw) Entertainment Audio/MP3 players such as CD Player, XMMS, Banshi, Beep Video Players : Mplayer, Kplayer, Xine, Kaffeine, Totem, Real Player-10.0 (Latest), Stream Tuner, Webcam, Digital camera & Video Conferencing tools such as Gnome Meeting. Linux TV Project TV Time, Xawtv, Mtv, Zapping TV Viewer etc. Development Tools GCC, G++, Pascal, Fortran, Java, Perl, PHP, Python, Tcl /Tk, Zope, Zend IDE's GTk, KDevelop , Qt,Eclipse, Anjuta etc. Embedded Solutions UcLinux, RTLinux, EmDebian & many others. Server Antivirus Software: FProt, Panda, Sophos, ClamAV Enterprise Solutions Red Hat Enterprise Linux Server( RHEL-4) SuSE Linux Enterprise Server from Novell( SLES-10) Ubuntu Server -2006 FirewallSolutions IP Tables, Shorewall, Firestarter CADutility Varicad

PNarasimhan

CD Burning Tools Gnome Toaster, K3b, Xcdroast Server Administration Tools Webmin, SWAT, both web-based and YaST (on SuSe Linux). Clustering Tools Enhanced Cluster Tools (ECT), Enfusion, Extreme Linux, Beowulf Cluster Tools including Sclyd, Oscar. Linux Distributions are available for Intel, Sun Sparc Alpha Systems Distributions and for Apple Mac systems. Currently most popular brands of Display Adapters, Network Interface Cards(NIC), Sound Cards, Printers, Scanners, Modems, Backup devices including the more recent USB devices, Pen Drives and support for MultiProcessor Servers, Desktops, Laptops and Personal Digital Devices(PDA) are fully supported.

PNarasimhan

CHAPTER-2 : USER INTERFACES

The Default Shell in Linux : Bourne Again Shell (BASH) The shell is a program that takes your commands from the keyboard and gives them to the operating system to perform. In the old days, it was the only user interface available on a Unix computer. Nowadays, we have graphical user interfaces (GUIs) in addition to command line interfaces (CLIs) such as the shell. On most Linux systems a program called BASH(which stands for Bourne Again SHell, an enhanced version of the original Bourne shell program, sh, written by Steve Bourne) acts as the shell program. There are several additional shell programs available on a typical Linux system. These include the Bourne, Korn , and the C shells which have been in use on legacy Unix systems since long.

Bash is an sh-compatible command language interpreter that executes commands read from the standard input or from a file. Bash also incorporates useful features from the Korn and C shells (ksh and csh). The basic configuration files for bash are : bash_profile, bashrc The default shell bash provides the following basic features :

Command Interface Command Interpreter

PNarasimhan

Sets Environment Variables For example : 1) PS1=[ \u@h \w ] %; export PS1 will change the command prompt to something like this : [muralinux@galaxy ~ ] % 2) PS1= [ \d \t ] $ :export PS1 will change the command prompt to something like this : [ Thu Apr 26 22:05:45 ] $ Supports I/O redirection Job Control Command line editing is enabled It supports command repetition and completion as well It acts like a programming language (Shell Scripts)

The Graphical User Interface The X Window System

The default underlying support is provided by X Window System or X

It was developed at MIT in 1984 by the name 'Project Athena' & later renamed as Xfree86 Project X is not the Graphical User Interface by itself, but provides the base graphics infrastructure facilities It effectively replicates a Client/Server Architecture/Windowing environment with X acting as the server and desktop applications being clients. X is OS independent It is TCP aware protocol It allows remote applications to be run Top layer special client applications are window managers as they encapsulate other client applications. The Desktop Environments available on a Linux system are : PNarasimhan

K Desktop Environment (KDE) developed by German students GNOME (Gnu Network Object Model Environment) from GNU Project The other light-weight desktops are : XFCE, Flushbox, and ICEWM These applications provide the look and feel, colours, icons, panel of the system The X Window System is also known as the X Protocol. It started as "Project Athena" by a group set up at MIT in the year 1984. It culminated successfully in the year 1986 and was renamed as the XFree86 project. It is not a GUI by itself, but only provides the basic graphics infrastructure. It helps in recognizing & initializing crucial hardware such as the graphics card, monitor, and the mouse. XFree86 has now a competitor in Xorg project which is currently used by the current versions of most of Linux distributions. It is still used today because of its good and extensible modular design. It has a very flexible structure capable of being ported easily. X is OS independent and available on many platforms. It is now handled by the X Consortium and the relevant website is at www.x.org. The software is freely available, very versatile, and is suitable for a wide range of hardware platforms. Any X environment consists of two distinct parts, the X server and one or more X clients. It is important to realize the distinction between the server and the client. The server controls the display directly and is responsible for all input/output via the keyboard, mouse or display. The clients, on the other hand, do not access the screen directly - they communicate with the server, which handles all input and output. It is the clients which do the "real" computing work running applications or whatever. The clients communicate with the server, causing the server to open one or more windows to handle input and output for that client. Just as the X and xfs are required on the server side, window managers are the most essential components on the client side. This replication of client/server model is present on a single, stand-alone machine running the X protocol and not merely in a network. These applications could be referred to as the "Super Clients" as these constitute the first step towards construction of client-side applications. In short it is a window manager that provides the "look and feel" of the GUI.

PNarasimhan

The X also requires the support of the Desktop environments. Desktop refers to the presentation of windows, menus, panels, icons, and other graphical elements on the computer screen. Originally, Linux operated purely in text mode, just commands typed on the screen. But today it provides a wide range of Desktop environments, among which GNOME (GNU's Network Object Model Environment) and KDE (K Desktop Environment), are the most popular.

Starting the X Server In case you have configured the system to boot in to the text mode and later on decide to have access to the GUI, it would be necessary to invoke the same from the terminal as follows:
$ startx

It is possible to have multiple instances of X to run on a single system concurrently. This is achieved by running the command :
$ startx -- :1

By default the Gnome desktop will be provided for most of the Linux flavours. In order to switch the default desktop to KDE permanently (provided it is installed) execute the command :
$ switchdesk kde

If the system is configured to boot in to the GUI login screen through GDM is available at F7 terminal; you have a choice of choosing a desktop for example among kde and gnome (from the session label) for that session or on a permanent basis. The Application Menu To run applications on the desktop, most X window managers provide a menu, similar to the 'start' menu of Microsoft Windows, to display and select X applications. Currently the GNOME desktop has the panel on the top by default. Applications are usually organized in well-defined categories.

PNarasimhan

From the GNOME or KDE desktops in Linux, open the menu, select the category, and then select the application to run.

LINUX DESKTOP ENVIRONMENT By default, Linux gives four virtual desktops to open different

applications/windows. If you want to send an open window from one desktop to another, right-click on the window's title bar. This opens a drop-down menu. Select To Desktop and choose the desktop you want to send it to. Creation of desktop shortcuts : Right-click on the desktop and go to Create new>Link to application. In the window that pops up, in the 'General' tab, specify a name for the shortcut. Click on the wheel icon on the left to select a different icon for the shortcut. In the Execute tab, click on browse and select the application you want to run. Most applications will be in /bin or usr/bin directory (/sbin for root user). There are a number of other parameters you can specify here, which can be ignored for the moment. Your shortcut will now appear on the desktop. This way, you can create shortcuts only for applications. Another quick way of creating shortcuts is to go to the file or directory you what the shortcut for in file manager, and drag it with the mouse to the location where you want the shortcut. When you release the mouse, a menu opens up with three optionsCopy here, Move here and Link here. Select Link here to create the shortcut. This way, you can create shortcuts to any file or directory, anywhere.

If you happen to get stuck somewhere, don't worry. There are a number of ways to get help. The first of these is KDE's own help files. Clicking on your KMenu and choosing Help can access these. Here you can search for the things you are specifically looking for.

PNarasimhan

The next place is under the Documentation tab in your KMenu. Here you'll find the Linux HOW-TO articles, and lots of other useful guides.On PCQLinux, on the desktop you will find three icons-PCQuest Linux Articles, Linux@IBM, Indian Linux Community. Clicking on any of these will open up a corresponding website, where you can search for what you are looking for, and also browse through the articles that are already available there. If you get stuck with any command while working in the Terminal, (the Linux command line), then you can use the man command to get help.

Giving your desktop a familiar Windows look : There are a number of things you can do in Linux to make your desktop look and act more like the Windows desktop that you are used to. The first of these is to change the complete look and feel of your application windows. To do this, right-click anywhere on the title bar of any open window. This will open up a drop-down menu, in which you choose Decoration, and then Win 2K. If you are used to say, Solaris and not Windows, then you can choose RISC OS here. To make changes to your KPanel (similar to the Windows taskbar), right-click on anywhere on your KPanel where there is empty space, that is, not on the application icons or desktop numbers. Choose 'Setting' from the menu that comes up. Under the General tab, change the Panel size to Small, and enable the Automatic hide option. As an extra, you can also specify the time after which your panel will hide itself. You can also add volume control on your K Panel, just like in Windows or the MacOS. To do this right-click on your KPanel, select Add/Applet, and choose KMix Applet. You can also change your desktop wallpaper to any graphic you want (if it is a BMP, you will have to convert it to TIF or JPEG first). Now right-click anywhere on your desktop and select Configure Background. Click on the Wallpaper tab and browse to the location of the image file that you want to use as your Wallpaper. Like in Windows, you can choose between various wallpapers modes such as tiled, centered etc. Click Apply and you're done. PNarasimhan

As an extra, you can choose multiple wall papers here and cycle through them at fixed intervals that you set up. Also, each virtual desktop can have a different wallpaper.

Terminating Hung Applications :

Windows has the famous Ctrl+Alt+Del key combination to shutdown applications or programs that have crashed. What this does is send a 'kill' signal to the process and all its threads so as to terminate them and thus free up system resources. Win NT, 2000 and XP users would be familiar with the Task Manager from where you can do this. KDE provides a similar application called the KDE System Guard. Press 'Ctrl+Esc' to invoke the KDE System guard. You can also invoke the System guard from the KMenu, from the System menu item. The System guard gives comprehensive information about the running or sleeping processes and the amount of system resources they are using. Each running process also has a unique identifier called the PID (Process ID). A better way of understanding this is to switch to 'Tree' view in KDE System guard. Select the erring process name and right click on it. Choose 'Select all child processes' and hit the 'Kill' button in the lower part of the System guard window. And you are done.

Playing audio Cds : The CD player in KDE is located under Multimedia in your K Menu. It has most of the features which other software CD players have, and getting used to it shouldn't be a problem. It also has a configuration window, which lets you change things like LCD color, background color, docking options and more. This can be accessed by clicking on the small icon showing a hammer and a screwdriver. Once you insert the CD and close the tray, bring up the CD player and start it off. If you want it to play the CD automatically, then, click on the hammer and screwdriver icon (kscd configuratio) icon, select the kscd options tab in the window that opens, PNarasimhan

and enable the 'play on tray close option'.You need to have the CD player application
running when the tray is closed, for this to work. Audio settings :

Your audio settings can be adjusted using a simple utility called Sound Mixer. You will find it under the Multimedia tab of your KMenu. This will open up a small window, which shows you the current level of your Main volume, Microhone, LineIn, CD Audio etc., which can all be adjusted easily by simply holding and dragging. If you want a small volume icon next to your clock, click on settings and choose configure KMix.Now put a tick next to Dock into Panel.
Screen savers, desktop themes and wallpapers :

The Control Center is a central place from where you can carry out all the above functions. Fire up the Control Center from your KPanel (the fourth icon in your KPanel). Click on the Look and Feel Tab. In the sub-menu that opens up, locate Background. Here you can change your background color, and select a wallpaper. Next click on the Screen saver tab. This opens up a list of screen savers, from which you can choose the one you want. You can also set the time after which the screen saver will run, and also specify a password, which will be required to get out of a screen saver. Similarly for themes, click on the Theme Manager Tab, and choose from the list of themes. If you click on the Contents tab of a particular theme, them you can specify particular areas like icons, wallpaper which you don't want to change after the new theme takes over. Many sites (like www.kde-look.org) also let you download additional themes. These files will usually have a .ktheme extension. Once downloaded you can add it by clicking on the Add button in the Theme Manager itself. You'll have to browse to the location where you have downloaded it.
Changing the display resolution :

The resolutions that will be available to you, can be specified during your Linux installation. When your display card is being configured, choose multiple resolutions and color depths from the select video modes menu (ensure that all of them are supported, by testing them). Alternatively, you may type 'Xconfigurator' in a terminal window after installation and choose more resolutions. Once this is done, to switch PNarasimhan

resolutions, use the 'Ctrl+Alt' key combination with + or - (for increasing and decreasing resolution) from the numeric keypad.

Note however that switching to a higher resolution will increase the overall screen size rather than 'squeezing' the desktop into the available screen area. This appears more like 'zooming' your desktop, and you move to areas of the desktop outside your monitor using the mouse.
Setting the date and time :

When you login and start KDE, your clock will be at the right-hand bottom corner of your screen, in the same position where it is found in Windows, on the KPanel (similar to the task bar). If you have too many items on the panel, you may have to scroll the panel to the right to see the clock. KDE allows you not only to change your date and time, but also to choose from different styles of clocks and display formats. Right-click on your clock. This will open up a menu with five options.

Let's take a quick look at what all you can do here. The first option is type, which lets you choose between digital, analog and a fuzzy clock. The fuzzy clock shows the time in words for example as in ten past nine. The next option is preferences. This lets you make finer adjustments to the clock you have chosen. You can change its color, the fonts and choose to show the date as well. The third option 'Adjust date and time' is where you get to actually change your time and choose your time zone. For example, in India, then you would choose Asia/Calcutta (you would have already done that during installation). The next option lets you change the format in which your time and date is displayed. And finally, the last option lets you copy the present date and time to the clipboard from where it can be pasted into other applications like KWord.
Install/uninstall or upgrade Linux apps :

Once you have a Linux system running, you will sooner or later want to install more software. In Windows these tasks are performed by the Windows installer, which can be accessed through the Add/Remove Programs applet in Control Panel. Linux

PNarasimhan

applications are bundled into something called RPM (RedHat Package Manager) packages and then installed, upgraded or deleted through the KDE Package Manager.
Shutting down and restarting your Linux machine :

You can shutdown and restart your Linux machine from pretty much the same place as in Windows. Click on your KMenu button and select Logout. This can also be used to switch between users, in case multiple people use that same machine. You can now choose to either log in again as a different user, shutdown your machine, restart your machine or go into the command line mode. The last option is similar to restart in DOS mode option in Windows. Another option you get here is to restart the X Server. If you face problems with your GUI, like it not refreshing properly, then you need to restart your X Server.

CHAPTER-3:LINUX INSTALLATION

The Basic Premises Underlying the process Installation process is one of the primary steps required to understand before using any Operating System. The latest releases of Linux distributions include easy and user friendly GUI / menu guided screens which makes the installation process easier and also helps to understand the complexities involved in the process. The following document contains a brief discussion over the installation process which can be handy for the end-user to successfully install the OS and have it fully functional. Identity of Devices Before starting with the installation process it is very important to know about the devices involved in the process and as identified by the Operating System.

PNarasimhan

The following section defines some of the devices which are relevant for the installation process. An standard IDE interface will accept four devices. They are identified as follows:
IDE Devices Primary Master Primary Slave Secondary Master Secondary Slave /dev/hda /dev/hdb /dev/hdc /dev/hdd

Floppy Drives
Floppy Drive : 1 /dev/fd0 [A:\ under DOS] Floppy Drive : 2 /dev/fd1 [B:\ under DOS]

Communication port The COM ports are identified as :


COM port 1 /dev/ttyS0 COM port 2 /dev/ttyS1

Parallel Ports The parallel ports are identified as :


Port 1 Port 2 /dev/lp0 /dev/lp1

USB Ports
Any device that is connected to the USB port is invariably identified as a SCSI device in Linux. It is addressed as /dev/sda or /dev/sdb as the case may be. However, the identification of the first printer connected to the USB port is /dev/usb/lp0.

PNarasimhan

Getting started with the installation Process To begin with the installation process boot through the Linux installation CD #1. The installation process begins with a boot prompt. In case a graphical mode is preferred just press Enter. Otherwise type linux text and press Enter to begin the Installation in simple text mode. During the installation process, Linux will prompt for various options relating to the system hardware settings. It is recommended to have a check list of the available hardware on the system which helps the user to select the devices without much run around. Media Check This process will check the integrity of complete Installation CD set, to be sure that none of the CD's in the set is not damaged or corrupted Linux provides a Media Check utility. This option can be skipped if you are sure about your media. Choose language When prompted, choose your language of interaction and select OK to begin with other step of installation.

Choose keyboard Choose the keyboard Type (U.S English) & click OK. This is the general keyboard architecture used, or select accordingly if a different keyboard is present.

PNarasimhan

Choose a mouse

When prompted, indicate the type of mouse and click OK. The normal mouse types are : serial, PS/2, USB etc. Choose install type Choose a configuration, such as Personal Desktop (for laptop, home or desktop PCs), Workstation (desktop plus software development), Server (file, print, web other server software) or Custom (Allows to select both the workstation / server category packages).Among the above options selecting Custom would give the end user a better control over the selection of the packages. Partitioning 1) You may choose Auto-partitioning if a first-time user not fully aware of the partitioning schema . The installer program will provide the following options which can be selected depending on the requirements.

Remove all Linux partitions on this system Windows and other non-Linux partitions remain intact with this selection.

Remove all partitions on this system This erases all the partitions on the hard disk, including Linux and non Linux partitions.

Keep all partitions and use existing free space

PNarasimhan

This only works if you have enough free space on the hard disk that is not currently assigned to any partition.

2) Using Disk Druid Utility : All partitions will get displayed in the menu one below the other with the respective operating systems that are installed in them. You need to highlight the free space and select New to add a new partition or Edit to modify existing partition scheme. Assign a mount point which is the device access point for the particular OS with the relevant file system selected. In the above example a /boot partition of size 100 MB is added.

Configure Boot loader All boot partitions and default boot loader options are displayed. By default,the installation process will use the GRUB boot loader and will install it in the master boot record of the computer and choose Linux as the default operating system to boot. LILO is the older boot loader available in Linux. However, GRUB is the preferred one currently since it has more options & capabilities.

PNarasimhan

Master Boot Record (MBR) This is the preferred place for GRUB or LILO. It causes either GRUB or LILO to control the boot process for all the operating systems installed on the hard disk. Configure Networking At this point, the system prompts to configure the network. This applies only if the system is on a network. The figure shown below is indicative of this. Set Hostname This is the name identifying the computer within the domain, example host1.myhome.edu. Choose firewall Configuration The use of firewall has significant impact on the security of the system. Select No firewall if the system is stand alone. Select packages The package selection can be made depending on the system's configuration. Normally in case of a home PC package categories such as Desktop (both GNOME, KDE), Development tools, Office & Productivity, Multi Media, Printing, if a printer is connected to the system may be selected. Set Root password You need to choose a password for the root user at this point. The root password provides complete control of the Linux system, hence it is very important to remember the assigned password for root user and keep it confidential. Start of the Installation Process A screen tells that you are about to begin installing the OS to the selected partition of the hard disk after which the process is irreversible. Create book disk To create a boot disk, insert a blank floppy and click next to create a boot floppy.

PNarasimhan

Configure video hardware Video card should have been detected automatically and should be highlighted. If not,choose the correct video driver from the list select the amount of video RAM contained on the board. and click Next. Select Monitor Configuration

Scroll down the list to find the monitor's manufacturer;then click the plus sign to choose the model. Finish Installing Lastly the Congratulation screen will indicate the successful completion of the installation process. It then performs certain post-install operations. After this screen the system reboots to activate the installed Linux OS on the system. The process of 'First Boot' gets started wherein such parameters as the sound card, network card etc are allowed to be set up manually. In case you had selected the GUI mode as the default login you will get a screen for providing your user name and authentication by the chosen password .

PNarasimhan

CHAPTER 4 : RUNNING SHELL COMMANDS & HELP-LINE

We have studied the basic features of the default shell bash on a Linux system in an earlier chapter. Now we need to probe further and understand as to how to use the shell as users inside the system. Broadly speaking there are two categories of users going by the nature of privileges these groups enjoy or are denied. Users The most privileged user is the administrator logging - in as root

The root has complete control and has an userid (uid) of 0

Unprivileged accounts have UID's greater than 99 Normally the UID's of users start with 500 on a RedHat System. These users operate under pre-set limitations within their respective areas

On a Linux system there are two class of users; the privileged users and the nonprivileged ones. The latter class operate under severe restrictions and strictly within their respective command areas & location, whereas the user root who is the administrator of the system has unlimited access to everything in a Linux system. Linux provides for assignment of passwords at installation stage as well as after logging into the system.
$ passwd

All the users on a Linux system have certain standard utilities made available to them. These are in the form of "virtual consoles" or multiple login facility. Users could enter the system in their own personal name or in any other user name created so as to facilitate & administer databases. Every user has a home directory, typically under /home which is known by the personal name of the user. Contains user specific configuration files as well as user data. It is represented by the ~ character. PNarasimhan

As and when new users are created contents of /etc/skel are copied to their home directories by default. Local Logins and Virtual Consoles

User login on virtual console when in run-level 3

User login on GUI mode when in run-level 5 Multiple non-GUI logins are possible through the use of virtual consoles There are by default 6 virtual consoles These are invoked by pressing CTRL+ALT+F[1-6] function keys If X is running, it is available as CTRL+ALT+F7 Changing Your Password

Passwords are assigned for users created during the installation process It is desirable to change passwords after the first login

From a terminal enter:


passwd newpasswd:<exact pasword to be entered here>

The above command will prompt for the old password after which it will allow the new password to be entered and re-entered for confirmation. For example :
muralinux@Galaxy:~$ passwd Changing password for muralinux

(current) Unix password: Enter new Unix password:

Retype new Unix password:

Running Commands Commands have the following syntax:

PNarasimhan

- name [options] [arguments]

Each block is separated by a space Options modify the command's behavior

Arguments are filenames or other information such as output redirection or piping the output to another utility to obtain the required output For listing files & directories :
muralinux@Galaxy:~$ ls

The option -l with the main command will display the same in a longer format with details. There are several help lines available for executing the Linux commands from within the system itself. On the command line you may, for example execute :
muralinux@Galaxy:~ <command name> --help

Alternately the manual pages in the form of man command and info command are available. The info pages are organised with multiple sections with each section dealing with a particular command or utility. If info is invoked without any arguments it opens the complete set of help line available as part of info pages. Other Help Utilities

Linux documentation Project (LDP) HowTO's

FAQ's Several URL's with links to full-scale Linux Documentation sites .Just as you have help from within the Linux system in the form of man and info pages,there are also numerous other web sites for obtaining documentation. The Linux Documentation Project is accessible through the following link : www.tldp.org . You may also have access to RedHat-specific documentation from

www.redhat.com/docs/manuals/ where many topics are covered in an extensive manner. PNarasimhan

The Linux CD-set also contains additional documents in the form of HOWTO's & FAQ's. These documents help the Linux users to use the system with more precision.

CHAPTER- 5 : LINUX FILE SYSTEM & SHELL COMMANDS

A basic understanding of the file system is necessary for a proper study of any Operating System. This is because the file system is the prime component which is responsible for storage of data on the hard disk or for that matter on any storage media as such. This session introduces some features of the Linux file system and its structure. With this knowledge the user can issue commands to locate the files, and also get to know the importance of each directory in the existing file system . A file is represented by an index node called 'inode' whose number is unique to the file it represents.

Inode Definition An inode is a data structure on a file-system within an Unix-like OS that stores all the information about a file except its name and its actual data. When a file is created it is assigned both a name and an inode number, which is an integer that is unique within the filesystem. Both the file names and their corresponding inode numbers are stored as entries in the directory that appears to the user to contain the files. That is, the directory associates filenames with inodes. Whenever an user or a program refers to a file by name, the system uses that name to look up the corresponding inode, which then enables the system to obtain the information it needs about the file to perform further operations. That is, a file name in a Unix-like operating system is merely an entry in a table with inode numbers, rather than being associated directly with a file (in contrast to other operating systems

PNarasimhan

such as the Microsoft Windows systems). The inode numbers and their corresponding inodes are held in inode tables, which are stored in strategic locations in a filesystem, including near its beginning. Whereas a file contains only its own content and a directory holds only the names of the files that appear to the user to be contained in it and their inode numbers, an inode contains all the other information describing a file. This meta-data includes (1) the size of the file in bytes and its physical location (i.e., the addresses of the blocks of storage containing the file's data on a HDD), (2) the file's owner and group, (3) the file's access permissions (i.e., which users are permitted to read, write and/or execute the file), (4) timestamps telling when the inode was created, last modified and last accessed and (5) a reference count telling how many hard links point to the inode. Linux File System The file system on which the Linux works is named as EXT3 file system which stands for Third Extended file system. This is the latest version of time tested Ext2fs with additional features such as journaling. On various Unix flavours Everything is a file Programs, scripts, devices and configuration settings are all contained in files, and Linux treats all files in the same way, regardless of where they are located. As a Unix-like operating system, Linux also works along the same concept and it has various files like the text file,directory file, a block file, a character file, a socket file, a named pipe file etc. The directory structure here resembles that of any Unix flavour, where it is represented as an inverted tree. The top level of this tree is represented by the character forward slash (/). This is also known as the ultimate parent directory or the root directory. All the other directories are under / and can be accessed by specification of their path.

Features of ext3 File System PNarasimhan

The file name can be up to 255 characters. These characters can be alphabets, numbers and periods (.). , but cannot contain some special meta characters such as #, $, / etc. which have special meaning on a Linux system. Since the dot is also considered as a character, this can be used as a normal character in the file. Linux doesn't have the concept of extensions, i.e., dot is another character used . Therefore, it doesn't identify a directory or a file by the extension that it has; but extensions are used just for user identification or as required by a particular program. For example 'C' Programs have a .c extension which is the requirement of the C compiler rather than the underlying file system and so on. File names in Linux are case-sensitive. Hence the file names File1, FiLE1, FILE1 are all different from each other unlike in MSDOS/MSWINDOWS. Some of the features of the filesystem are as highlighted below:

5% of every partition is reserved for root user. Pre-allocation of disk data blocks to regular files.

The block size & the number of inodes in a block can be changed. Automated filesystem consistency check. Support for immutable & append-only files

File System Hierarchical Concepts

/ bin boot dev etc home lib

mnt
Ext3 Filesystem PNarasimhan

proc

root

sbin

var

usr

The block diagram above shows the default system directories beneath the root directory on a typical Linux system. We will now proceed to explore the basic nature of the above shown directories. bin : Used to store user commands. The files here are all binary executables accessible to all users on the system. boot : Contains the kernel and other files used during system startup. dev : Stores device files. They are either character or block device files. etc : Contains many configuration files and directories. home : Typical location of users' home directories. lib : Contains many library files used by programs in /bin and /sbin. media : The directory contains the mount points for devices mounted after the system is booted. By default the directories, floppy and cdrom are created to access the respective devices. mnt : It is an additional directory for allowing partitions containing other OS's to be mounted. opt : It is an optional directory normally used for downloading third-party

applications and extracting them for common usage. proc : A virtual file system indicating the complete status of the processes that run on the system. Holds information about kernel parameters and system configuration. root : The home directory of the superuser. sbin : Location of system commands. The executables under this location are binary files that are related to administration & could be invoked only by the superuser. tmp : This is a temporary directory containing some default Unix socket files and is available to all the users . usr : Contains files and directories directly relating to user applications. It has all commands, libraries, man pages, games and static files for normal operation.

PNarasimhan

We have made an exploration of the shell as well as the file system on which it is being used. Now is the time to put to practical use the base applications or running the shell commands to extract information from a Linux system. var : Contains files that change for mail, news, printers log files, man pages, temp files. Current Working Directory The very basic command that is required at the beginning is the pwd command. This command outputs the present working directory the particular user is working on.

pwd

Displays the absolute path to the current directory (present working directory)

ls List the contents of the current directory or a specified directory

The ls command has a variety of options apart from the basic one of listing the files and directories. As for example, it is used to have a long listing with additional details.
$ ls -l

drwxr-xr-x drwxr-xr-x drwxr-xr-x17 drwxr-xr-x drwxr-xr-x drwxr-xr-x drwxr-xr-x drwxr-xr-x drwxr-xr-x drwxr-xr-x

2 7 root 69 7 2 7 2 3 13

root root root root root root root root root root

root root

4096 04-22 08:42 bin 1024 08-14 19:52 boot

81920 09-29 17:44 dev root root root root root root root 8192 09-29 17:44 etc 4096 07-26 19:14 home 4096 2001-06-22 initrd 4096 04-21 23:03 lib 16384 2001-12-25 lost+found

4096 04-21 22:59 misc 4096 08-31 17:17 mnt

PNarasimhan

drwxr-xr-x dr-xr-xr-x drwxr-x-39 drwxr-xr-x drwxr-xr-x drwxrwxrwt drwxr-xr-x drwxr-xr-x

23 79

root root root

root root root root root root root root

4096 07-27 23:13 opt 0 2002-09-29 proc 8192 09-29 17:46 root 8192 2001-12-25 sbin 4096 2001-12-25 tftpboot 4096 09-29 17:47 tmp 4096 06-23 19:02 usr 4096 2002-02-16 var

2 3 19 19 26

root root root root root

File Manipulation cp-copy files mv-Move or rename files touch- create empty files or update file time stamps

rm- remove files

The copy command is cp in Linux and is used to copy files from one location to another.
$ cp cprogs /home/user1

It could also be used to create another copy of a file with the same name or another one.
$ cp cprogs cprogsnew

The command is so powerful as to allow multiple directories/sub-directories and files to be copied en bloc from location to another very swiftly and effectively. In the example given below, the directory temp with its' entire content, recursively diving in to sub-directories is copied to linuser1 directory.
$ cp -R temp/ linuser1/

The mv command is commonly used to physically move files from one location to another or to rename a file. You may now look at examples to illustrate the same. The undermentioned command would move file1 from the cwd to misc directory.

PNarasimhan

$ mv file1 /misc

To rename the file "file2" as "newfile" you may type :


$ mv file2 newfile

Changing Directories The cd command changes directories To an absolute path starting from the top level / : -$ cd/home/linuser1/projects To a relative path: -$ cd projects - $ cd ./projects -$ cd ././projects The cd command is the same as in various flavours of DOS and is used to effect change from the present working directory to another directory. The syntax "cd .." would mean that the user is going one step back in the hierarchy. Running the command as any user would that user to his home directory. Directory Manipulation
mkdirrmdirrm -rfCreate a directory Remove an empty directory Removes a directory & its contents recursively

The next set of commands deal with creation and deletion of directories and also with recursive elimination of directories and its sub-directories. To create a new directory under the current working directory :
$ mkdir newdir

To remove a directory which is empty :


$ rmdir newdir

PNarasimhan

To remove a directory which contains several sub-directories & files within it so as to recursively go down the directory structure and remove files forcibly:
$ rm -fr newdir2

CAUTION : The above command is potentially dangerous one to execute as it is capable of wiping out your system completely, uprooting the files in its' entirety and causing irreparable damage to the system.

Viewing Text Files cat, more & less provide a quick way to view text files The cat command enables viewing an entire file at the shell prompt, sequentially without any break Files display "concatenated" The more and less commands offer the display of text files page wise, but less is more powerful in the sense that it acts as a pager with a facility to scroll up or down. The head and tail commands show the first few lines of the beginning and end of text files respectively Earlier you have seen the use of the ls command. The more and less commands may be used in conjunction with ls through a pipe. The syntax is as given below:
$ ls -l /dev |more

As the contents of /dev directory is too large to be fitting into a single page, the more or less commands are used to get page-wise display. Whereas with 'more' you can only scroll down, less is a pager with the facility to scroll up or down. The cat command is very powerful and is capable of providing a lot of information. To view the contents of a file on the console like :
$ cat file1

To create a new file & write into it, you need to type :
$ cat > newfile

PNarasimhan

At this point the user is presented with the cursor wherein a few lines could be typed and the file saved by pressing CTRL+d by moving over to the next blank line. Further, the cat command could be used in conjunction with double operator(>>) to append contents of one file into another.
$ cat file1>>file2

The head and tail commands display the first & last 10 lines of a file specified, like :
$ head /home/muralinux/file1

$ tail

/home/muralinux/file1

GREP,SORT, DIFF, CUT, UNIQ The sort command sorts all kinds of text data: $ sort hello.txt You may use the option -r to sort in the descending order Another use of sort is to combine it with the grep command: $ grep bash /etc/passwd |sort -r The diff command would display the lines which differ in content : $ diff /root/install.log /root/install.log.syslog The cut command would cut the desired field and display $ cut -f2 -d: /etc/passwd The uniq command could be used with cut & sort to display unique lines: $ cut -d: -f7 /etc/passwd |sort|uniq

PASTE, TR Merge data from multiple files into one file using paste command: PNarasimhan

$ paste file1.txt file2.txt > newfile.txt Use the -d option to change output delimiter : $ paste -d: letters numbers>new.txt This would paste the numerical values from the file "numbers" in the next field delimited by a tab on to the file "letters". The tr command is used to translate or delete characters from data" $ tr A-Z a-Z <data1.txt >data2.txt (Upper case characters are translated to lower case ones) $ tr -d \r < dosfile >Unixfile This would convert DOS text files to Unix style files. ASPELL Using aspell : A very powerful intercative spell-checker $ aspell check letter.txt It offers suggestions for corrections via a simple menu driven interface.

STANDARD I/O, PIPES This section would help you understand standard i/o channels, file redirection and pipes . Linux provides three standard I/O channels to processes : Standard input : keyboard is default stdin channel 0

Standard output : terminal window by default Standard error : terminal window by default

stdout channel 1 stderr channel 2

Shell redirection operators allow standard I/O channels to be redirected to/from a file. Pipes allow standard I/O channels to be connected,i.e, sending the output of one program to be used as input for the other program. PNarasimhan

For example : $2 < error.txt redirects the error channel to error.txt file. $ find /etc -name passwd This command will search for all files named passwd in the /etc directory and its subdirectories The value returned by this command would be: /etc/passwd There are a set of commands which return values by searching the system for binary executable files and provide their location as well explanation as to what these executables do .These are :
[root@server muralinux]# which ls alias ls='ls --color=tty' /bin/ls [root@server muralinux]# whereis ls ls: /bin/ls /usr/share/man/man1/ls.1.gz /usr/share/man/man1p/ls.1p.gz

[root@server muralinux]# whatis ls ls (1) - list directory contents

Redirecting Standard Output $ find /etc -name passwd >find.txt This would redirect the standard output to the file and standard error to the terminal. Overwriting or Appending If the target file (find.txt) exists, in that case it would be overwritten. To append data to an existing file, use >> instead of >

Redirecting Standard Error

PNarasimhan

$ find /etc -name passwd 2<errors.txt In this case the standard output will be on the screen Redirecting Both Standard output and Error $ find / -name passwd >alloutput 2<&1 (or) find / -name passwd &> alloutput Redirect input with < Some commands only operate on standard input $ tr 'A-Z' 'a-z' < .bashrc This command will translate the upper case characters to lower case. PIPES Pipes ( | ) let you direct output from one command to become the input to another command as for example: $ ls /home/linuser |more Can create multiple pipelines which is a very powerful feature on any Unix system : $ cut -f2 -d: passwd |sort -r |more TEE Displays the output of a program and copies it into a file. The tee command reads standard input, then writes the output of a program to standard output and simultaneously copies it into the specified file or files. Options The following options may be used to control how tee functions. -a Appends the output to an existing file. If the file does not exist it will be created. Normally an existing file would be overwritten. -i Ignore interrupts. If you press the Delete key, tee ignores the interrupt signal sent to it and continues processing.

PNarasimhan

Examples $ ls *.txt | wc -l | tee /dev/tty count.txt In the above example the ls command would list all .txt files in the current directory, take a word count (wc) by the amount of lines (-l) and the output displayed to the /dev/tty (terminal) will be sent to the count.txt.

To take another example with multiple options and pipes : $ cp file1 file2 | tee stageone | sort | tee stagetwo | uniq -c

Hard Links : One physical file on the file system Each file references the file's inode File is present in the file system as long as one link remains

Cannot span drives or partitions

Syntax :
$ ln file1 file2

The above command creates another file 'file2' with the same contents & the same inode.

A symbolic or soft link Is a Linux file type Stores the name of another file Can span file systems

Can point to directories Syntax:

$ ln -s file1 file3

PNarasimhan

This not only creates another file 'file3' but also assigns it a fresh inode as 'file3' is only a symbolic link to the original file 'file1' . Checking Free Space df- Reports filesystem disk space usage. Use the -h option for output in kilobytes, megabytes, and gigabytes du- Estimated file space usage. Also uses the -h option. The above commands are used to find out the disk space that is free on all the mounted devices and partitions. You may now look at an example of this :
# df

Filesystem /dev/hdb3 /dev/hdb2 none /dev/hdb1

1Kblocks 5044156 31124 63320 5114684

Used 4090200 8695 0 4259832

Available 697724 20810 63320 854852

Use% Mountedon 86% 30% 0% 84% / /boot /dev/shm /mnt/dos

The du command provides the value for the disk usage of files present under the current working directory. # du /home/muralinux/ 4 4 93052 4 4 ./.mozilla-thunderbird/dizzvhq6.default/Mail/Local Folders/Inbox.sbd ./.mozilla-thunderbird/dizzvhq6.default/Mail/Local Folders/Support./.mozilla-thunderbird/dizzvhq6.default/Mail/Local Folders ./.mozilla-thunderbird/dizzvhq6.default/Mail/pop3.yahoo.com/Inbox.sbd ./.mozilla-thunderbird/dizzvhq6.default/Mail/pop3.yahoo.com/Trash.sbd Linux processes Each running application is a process & a process is an instance of a program in execution. It is a dynamic entity and has many components such as :

Services.sbd

PNarasimhan

Exec thread, PID, memory context, environment, file descriptors and security credentials. Forking When a process "forks", a copy of the process is created. Process Ancestry init is the mother of all processes being the first process started at boot time. Its PID is 1 and unlike other processes it has no parent process Like humans, process can be both a parent and a child at the same time. Process States Runnable ( on the run queue) Sleeping Stopped

Uninterruptible sleep Defunct or Zombie process

Monitoring Proceses : Each process: Has a process ID (PID) Runs under a specific security context Has an environment

The related commands are: -ps, top, pstree, kill, gtop

On a Linux system all the applications that are started relate to a process, as for example the login prompt and the commands executed therein. This may be demonstrated by the following example by using the ps command:
$ ps

PNarasimhan

PID TTY 786 tty1 845 tty1

TIME CMD 0:0 0:0 login bash

The important values returned by the above command denote the PID of the process, the virtual terminal on which it is executed, and the nature of the process/application. The top program provides a dynamic real-time view of processes running in the system. It can display system summary information as well as a list of tasks currently being managed by the Linux kernel. The types of system summary information shown and the types, order and size of information displayed for tasks are all user configurable and that configuration can be made persistent across restarts. The gtop is the graphical front-end for the top command. The kill command is utilised in terminating a process as for example :
# kill -9 786

The process with pid of 786 is the process relating to the login on tty1 and such the user will be logged out immediately. Altering Process Scheduling priority : At process invocation time - $ nice -n -1 cp file1 file2 Processes are scheduled with a default priority of 0 .Priority value can range from -20 (highest ) to 19(lowest).To alter the priority of a running process $ renice -1 -u user -p <pid> Once a priority value is raised, a non-privileged user cannot lower it. Running a Process in the Foreground : When a command is entered, the shell will not process further input until the process is complete and the shell prompt is redisplayed.The typeahead buffer allows you to type other commands, but they will not be processed until the pending process completes, or "returns" . Running a Process in the Background :

PNarasimhan

Running a process in the background allows another process to run simultaneously on the same terminal.Launch a program as a background process by appending an ampersand (&) to the end of a command as for example :
$ ./myprog.c &

Jobs that have been started in the foreground can be suspended.They can then be resumed in the background by typing :
$ mv * /home/user

Suspend a process by typing ctrl+z $ bg : will send the job to the background $ jobs : will display all suspended & background processes with their job id's $ fg < jobid> : would bring such processes to the foreground Locating Files Linux System uses the slocate utility and locate is the command which is linked to it. $ locate inittab All files created after the system boots do not find a place in the slocate database. Hence you are required to freshen the same. To update the slocate database you need to use the command: $ updatedb The find command $ find <path> <options> <expression> The locate command returns values that matches all files that have a specific pattern. Let us take an example and examine the same :
$ slocate inittab

All files with the string "inittab" in their name will be displayed A live example : PNarasimhan

$ find / -name

.bash_profile

Removable Storage Media The process of mounting actually links the removable media or a partition to the native Linux file system This provides an unified approach for viewing the contents of devices To be able to use any media it has to be mounted at some point under root (/)

This utility also enables a Linux user to unify under its native root file system, and precisely under the / directory, any other alien file system residing in other partitions, disks, either in the local system or any system in the network.

For example:
# mount -t msdos /dev/fd0 /mnt/floppy

To unlink the device :


# umount /mnt/floppy

PNarasimhan

CHAPTER- 6 : THE

VI

EDITOR

The VI editor is a screen-based editor used by many Unix users. The VI editor has powerful features to aid programmers, but many beginning users avoid using Vi because the different, complex features overwhelm them. It was created by a graduate student of University of California, Berkley called William Joy. Currently we will go through the basics of vi editor, avoiding the complex parts of it. We will also browse through the At the end of this section editing vi editor should be very simple. Vi is a preferred choice of many advanced users, mainly because it is the only editor available at the time of booting the system into a rescue mode. The Three Modes A vi session begins by invoking the command vi with or without a filename.
# vi textfile

If the file exists then the contents of the file will be displayed, otherwise a blank screen will be displayed. Of the 25 lines that can be displayed on the standard text mode terminal, only 24 lines are used for displaying text. The last line is used for displaying status information like, number of lines in the file, current position of the cursor, name of the file etc. The moment you start the vi editor, you will be placed in the so called command mode. This is the mode where you can pass commands to act on the text. Pressing a key does not appear on the screen, instead each key will be interpreted as a command by the vi editor. To enter text you have to switch to input mode. This can be done by pressing the key 'i'. While in input mode any key that is pressed on the keyboard will appear on the screen. Most of the vi session will usually be spent in this mode.

PNarasimhan

Sometimes you may have to switch to the third mode called as ex mode, where you can enter instructions to act on the whole file. For example file saving, file rewriting, find and replace operations are performed by switching to this mode of operation. To summarize the three modes we can write, Input mode Where any key pressed is entered as text. Command mode Where keys are used as commands to act on the text. ex Mode Where ex mode commands can be entered in the last line of the screen to act on text. The command to quit out of VI is :q. Once in command mode, type colon, and 'q', followed by return. If your file has been modified in any way, the editor will warn you of this, and not let you quit. To ignore this message, the command to quit out of VI without saving is :q!. This lets you exit VI without saving any of the changes. Of course, normally in an editor, you would want to save the changes you have made. The command to save the contents of the editor is :w. You can combine the above command with the quit command, or :wq. You can specify a different file name to save to by specifying the name after the :w. For example, if you wanted to save the file you were working as another filename called filename2, you would type: w filename2 and return. Another way to save your changes and exit out of VI is the ZZ command. When in command mode, type ZZ and it will do the equivalent of :wq. If any changes were made to the file, it will be saved. This is the easiest way to leave the editor, with only two keystrokes. Some of the important commands that can be used in the command mode or ex mode of vi are as follows: <ESC><SHIFT>:q! - Quit the current file and don't save the changes you just made to the file

PNarasimhan

CTRL + f - Page ahead,one page at a time. CTRL + b - Page back , one page at a time. G - Go to the last line of the file. 1G - Go to the first line of the file. (use any number to go to that line). Some Simple VI Commands Here is a simple set of commands to get a beginning VI user started. There are many other convenient commands, which will be discussed in later sections. a enter insert mode, the characters typed in will be inserted after the current cursor position. If you specify a count, all the text that had been inserted will be repeated that many times. h move the cursor to the left one character position. i enter insert mode, the characters typed in will be inserted before the current cursor position. If you specify a count, all the text that had been inserted will be repeated that many times. j move the cursor down one line. k move the cursor up one line. l move the cursor to the right one character position. r

PNarasimhan

replace one character under the cursor. Specify count to replace a number of characters u undo the last change to the file. Typing u again will re-do the change. x delete character under the cursor. Count specifies how many characters to delete. The characters will be deleted after the cursor. Cutting and Yanking The command commonly used command for cutting is d. This command deletes text from the file. The command is preceded by an optional count and followed by a movement specification. If you double the command by typing dd, it deletes the current line. Here are some combinations of these: d^ deletes from current cursor position to the beginning of the line. d$ deletes from current cursor position to the end of the line. dw deletes from current cursor position to the end of the word. 3dd deletes three lines from current cursor position downwards. There is also the y command which operates similarly to the d command which take text from the file without deleting the text. Pasting The commands to paste are p and P. They only differ in the position relative to the cursor where they paste. p pastes the specified or general buffer after the cursor

PNarasimhan

position, while P pastes the specified or general buffer before the cursor position. Specifying count before the paste command pastes text the specified number of times. Inserting New Text A Append at the end of the current line.

I Insert from the beginning of a line. O Enter insert mode in a new line above the current cursor position. a Enter insert mode, the characters typed in will be inserted after the current cursor position. A count inserts all the text that had been inserted that many times. i Enter insert mode, the characters typed in will be inserted before the current cursor position. A count inserts all the text that had been inserted that many times. o Enter insert mode in a new line below the current cursor position.

An online tutorial is available by default on Linux systems. The default location of the file is /usr/share/vim/vim64/tutor/tutor. The tutorial can be accessed by executing the command vimtutor.

PNarasimhan

emacs is another popular versatile utility for Unix platforms developed by Richard Stallman. This application can be used not only as an editor but also as a browser. This is popular among the user groups.

PNarasimhan

GUI Editors xemacs is the GUI eqvivalent of emacs in TUI. The editor is accessible on the GUI with the name xemacs. It can be invoked by going to K Menu -> Run Command -> xemacs nedit is another GUI editor available which can be used to edit text files. gvim:This particular editor is accessible on the GNOME'S desktop. The editor in turn uses the vi improved editor at the back-end and saves the data which are in the text formats. gedit: Another editor on the GNOME's desktop with a feature of opening multiple files in a single session. This is useful in case the user wants to work on the project involving editing of multiple files at a time.
KATE:

THIS

IS YET ANOTHER POPULAR TEXT EDITOR. ON

THEY

ARE OF

AVAILABLE

KDE

DESKTOPS

BY

DEFAULT.

PREVIEW

KEDIT IS GIVEN IN THE NEXT PAGE.

PNarasimhan

You might also like