You are on page 1of 29

LAB FILE OPERATING SYSTEM (LINUX)

2013-14

SUBMITTED TO: Miss. Pooja Nemani

SUBMITTED BY: Sakshi Arora 11712401911 BBA(CAM) 4th semester-[2nd year]

DELHI INSTITUTE OF RURAL DEVELOPMENT

INDEX
1. To study about Linux/Unix Introduction to Linux
Architecture of Unix Shells of Unix Similarities between Linux and Unix Difference between Linux and Unix

2. General Purpose Utilities


Calendar To Display System Date Knowing your Terminal and machine name Changing passwords

3. File Directory Commands


Creating a file Listing a file Moving a file Copying a file Deleting a file Creating Directory Moving Directory Deleting Directory

4. Introduction to VI editor

5. Commands in VI Editor
Adding Text Navigation Replacing Text Deleting Text

6. Shell Programs
Program for performing arithmetic operations. Shell program to find factorial of a given number Shell program to find Fibonacci series of a number.

1.To study about Unix /Linux


Unix (officially trademarked as UNIX, sometimes also written as UNIX in small caps) is a multitasking, multi-user computer operating system originally developed in 1969 by a group of AT&T employees at Bell Labs, including Ken Thompson, Dennis Ritchie,Brian

Kernighan, Douglas McIlroy, Michael Lesk and Joe Ossanna The Unix operating system was first developed in assembly language, but by 1973 had been almost entirely recoded in C, greatly facilitating its further development and porting to other hardware. In 1974, UNIX was first licensed to an outside institution, the University of Illinois at Urbana Champaign, by Greg Chesson and Donald B. Gillies. Today's Unix system evolution is split into various branches, developed over time by AT&T as well as various commercial vendors, universities (such as University of California, Berkeley's BSD), and non-profit organizations.

Linux is a Unix-like computer operating system assembled under the model of free and open source software development and distribution. The defining component of Linux is the Linux kernel, an operating system kernel first released 5 October 1991 by Linus Torvalds with the assistance of developers from around the globe. Since the main supporting user space system tools and libraries originated in the GNU Project, initiated in 1983 by Richard Stallman, the Free Software Foundation prefers the nameGNU/Linux. Linux is free to download, edit and distribute. Linux is a very powerful operating system and it is gradually becoming popular throughout the world. Linux was originally developed as a free operating system for Intel x86-based personal computers. It has since been ported to more computer hardware platforms than any other operating system. It is a leading operating system on servers and other big iron systems such as mainframe computers and supercomputers: more than 90% of today's 500 fastest

supercomputers run some variant of Linux, including the 10 fastest Linux also runs on embedded systems (devices where the operating system is typically built into the firmware and highly tailored to the system) such as mobile phones, tablet, network routers, televisions and video game consoles; the Android system in wide use on mobile devices is built on the Linux kernel.

Architecture of Unix

OS interacts directly with the hardware Such OS is called system kernel

A Unix architecture is a computer operating system system architecture that embodies the Unix philosophy. It may adhere to standards such as the Single UNIX Specification (SUS) or similar POSIX IEEE standard. No single published standard describes all Unix architecture computer operating systems this is in part a legacy of the Unix wars. A Unix kernel the core or key components of the operating system consists of many kernel subsystems like process management, memory management, file management, device management and network management

Similarities between Linux and Unix


Linux and Unix have many similarities, but Linux has many features that most
Unix do not have, and some current Unix implementations (like Solaris) have some features that have yet to be implemented in Linux (like dtrace). Some ways that Linux and unix are functionally similar:

Both are capable of true multitasking. Both run on a variety of hardware platforms. Both are well-known for security and reliability. Both are highly modular (one piece can easily be removed and replaced without breaking the whole system)

Both are capable of using both a command line and a GUI. Both support multiple users, and support different privileges between users.

Difference between Linux and Unix


Linux is a graphical user interface OS which provides two basic types of GUIs Gnome and KDE while UNIX was established initially by using command code. UNIX was also converted to the GUI by looking at the consumer market. The famous X Windows was created for UNIX by AT&T. Linux is considered very efficient in terms of threat detection. This because of two facts Linux is a community OS and whenever any user encounters any specific virus he reports to the community and OS developers start to help him/her. Secondly it is an open source OS and allows for code changes. On the other hand UNIX is an operating system any user has to wait for the anti virus patches from the manufacturers. Thus we can say that in terms of security Linux can be rated more than UNIX. The cost structure of UNIX is also different for different models. On the contrary Linux can be distributed and downloaded freely. Though Linux is considered more secure but it has so far been reported to capture only 60 viruses while UNIX has reported more than 80 viruses. Even if we consider this fact Linux is regarded more responsive towards bugs and viruses. A widely used Open Source Unix-like operating system kernel. Linux was first released by its inventor Linus Torvalds in 1991. Unix is the foundation for a number of operating systems, with Linux being the most popular one. UNIX is an operating system created in the early days of computers. More recently, Linux was created as an open-source, freeware operating system. (note: Linux is free software, not freeware. UNIX is a closed-source, proprietary operating system which you need to purchase a license for, Linux is open-source and available to anyone for free. Unix is used by Apple Mac and Banks as it is virtually impossible to get virus's or hackers. Linux is also one of the original platforms and still widely used, and also virus free.

2.General Purpose Utilities


Calendar
To get the calendar in the screen just type cal and the year which you want to see in the terminal:

To Display System Date


To display the system date, just type date in the terminal.

Knowing your Terminal and machine name


By typing who am I, the terminal/machine name will display with the present date and time.

Changing passwords
If we want to change the password under linux then you need to use password command to change password under linux. For example to change your own password type command: Password To change password of other user, you need to use password command as follows: o password username o You must be a root or equivalent user to change other user password.

o Here is the sample snapshot of changing the password of a user.

3.File Directory Commands


Creating a file
Create a file with the cat command

Type the command cat > name_of_file Now type in your text. Press the <Return> key to start a new line. When you have finished typing in your text, enter Ctrl-d (Press and hold down the Ctrl key and type a "d"). This stops the cat command and returns you to the system prompt. The touch command is the easiest way to create new, empty files. It is also used to change the timestamps (i.e., dates and times of the most recent access and modification) on existing files and directories. touch's syntax is touch [option] file_name(s)

Listing a file
You can use the ls command to list the files in any directory to which you have access. For a simple directory listing, at the Unix prompt, enter:

o Ls

This command will list the names of all the files and directories in the current working directory. As the directory does not have any files, the screenshot below is indicating only the main directory.

Moving a file
The mv command in Unix "moves" files and directories from one location (or name) to another.

The move command mv is safer and more precise. It's safer because if Unix cannot create the new file, it will not remove the old one. It's more precise because it preserves the original creation date of the file.

Copying a file
The Unix command to "copy" files is cp. The cp comand takes the names of two files as arguments: cp filefrom fileto

Deleting a file
The rm command deletes files in a directory.

The rm command will usually not produce an output unless you have made an error.

Creating Directory
You can create a directory by using the mkdir command. For example, to create a directory named mayhem within the current working directory: mkdir mayhem

Moving Directory
If you wish to "move" all of the files from directory into another directory, use the mv command exactly as you do for files. Again, mv works just like the copy command. Yet since subdirectories are always moved, there is no recursive -r option. For example, here we rename of the

/development/prog/backup directory to development/prog/bu:

Deleting Directory
You need to use rmdir command to remove a directory. It will remove the directory entry specified by each dirname operand, which must refer to an empty directory. For example, to remove a directory called "cppcode", enter: rmdir cppcode

4.Introduction to VI Editor
o The vi editor is the classic screen editing program for Unix systems and is based on a older line editor called ex. It can be used from any type of terminal because it doesnt depend on arrow and function keys. It uses standard alphabetic keys for command as well as arrow keys. o There are number of enhanced version of vi exists. Some of them are nvi, vim, vile and elvis. In Linux, the vi command is a link to one of these programs. Most

likely it will be vim. Most of the Linux distributions have vi and emacs text editor already installed. o In Linux, configuration files are written in plain English. Hence, text editors are required to make changes to these files. The editing capabilities can be invoked within vi by pressing the colon (:), entering ex command and then pressing the Return key. ex commands are still important part of vi and is sometimes called hex in Linux. o Learning vi or emacs is must for every Linux or Unix user. There are some GUI based text editors available. But, there are some situations when you cant access GUI desktop. In that case, vi or emacs can only save you. o The version which people use normally now a days is Vi iMproved (VIM). Vi was enhanced by Bram Moolenaar and are called vim editor. o The vi editor has three modes, command mode, insert mode and command line mode. o 1.Command mode: by default, the vi editor opens in command mode. You can use commands to move cursor, delete. cut, copy, paste and save changes. Commands are case sensitive. The ESC key is used to end a command. o 2. Insert mode: Insert mode is what we work in most of the time and text is inserted into the file in this mode only. You can enter the insert mode by pressing I key. The newer vi versions will show INSERT word on the bottom line. You can also enter a (insert after), A (insert at end of line), o (open new line after current line) or O (Open line above current line) commands apart from I command. The ESC key ends insert mode and returns you to command mode.

o 3.Command line mode: You can enter this mode by typing : which displays the command line entry at the bottom of the screen.

Note: In broad sense, there are only two modes, one for editing text (i.e. Insert mode) and the other (i.e. command mode) for giving commands. To switch between the two modes you use the I and Esc keys

5. Commands in VI Editor
Adding Text
The following commands allow you to insert and add text. Each of these commands puts the vi editor into insert mode; thus, the <Esc> key must be pressed to terminate the entry of text and to put the vi editor back into command mode.

Replacing Text
By pressing capital R, the text in which the cursor is placed can be replaced.

Deleting Text
The following commands allow you to delete text.

Screenshot after deleting the inserted text:

6. SHELL PROGRAMS
Some of the shell programs are discussed below with the input and output screenshots: PROGRAM FOR PERFORMING ARITHMETIC OPERATIONS Here is the input snap:

The output of Arithmetic operation program:

SHELL PROGRAM TO FIND FACTORIAL OF A GIVEN NUMBER Input snap:

The output snap of factorial program is:

SHELL PROGRAM TO FIND FIBONACCI SERIES OF A NUMBER Input snap:

Output of the Fibonacci program:

You might also like