Professional Documents
Culture Documents
2013-14
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
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.
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
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
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.
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.
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
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.
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: