--Your friends at LectureNotes

Note for LINUX PROGRAMMING - LP By Prakash Poudel

  • Note
  • 14 Offline Downloads
  • Uploaded 10 months ago
0 User(s)
Download PDFOrder Printed Copy

Share it with your friends

Leave your Comments

Text from page-2

LINUX QUICK REFERENCE NOTE Developer communities can volunteer to maintain and support whole distributions, such as the Debian or Gentoo Projects. Novell and Red hat also support community-driven versions of their products, openSUSE and Fedora, respectively. Other developer communities focus on different applications and environments that run on Linux, such as Firefox, OpenOffice.org, GNOME, and KDE. History of Linux Late 1960's - Unix is developed and released in 1970's which was created by the Ken Thompson and Dennis Ritchie. It is widely adopted in business and academic circles. In 1983 - a programmer Richard Stallman creates the GNU Project. It is an attempt at creating a Unix type operating system but composed of entirely free software. In 1987 - Another programmer Andrew S. Tanenbaum creates Minix, a Unix like operating system for Academic use. In 1991 - a Finnish student Linus Torvalds creates a non-commercial version of Minix and calls it Linux. The Linu is from Linus and the x is from the 'ix' part of Minix. On 25 August, 1991, Linus posted his famous message on the MINIX Newsgroup about the development of Linux. No announcement was ever made for Linux Version 0.01. On October 5, 1991, Linus announced the first “official” version of Linux, version 0.02. The primary focus was kernel development; none of the issues of user support, documentation, distribution, and so on had even been addressed. Today, the situation is quite different—the real excitement in the Linux world deals with graphical user environments, easy-to-install distribution packages, and high-level applications such as graphics utilities and productivity suites. Why use Linux? 1. 2. 3. 4. 5. 6. 7. 8. 9. 10. It’s free. It's a lot more secure and a lot less prone to viruses and hackers than Microsoft Windows. You can do 99% of what you can do on Windows on Linux. Linux has the support of a worldwide community of developers who contribute to the source code, security fixes and system enhancements. Every Linux distribution offers regular updates of its packages and sources several times per year and security fixes as needed. Linux systems rarely crash, and when they do, the whole system normally does not go down. Linux typically does not slow down over time. Linux can breathe new life into old computers. Linux comes in all sizes and flavors, which offers a wide variety from which to choose the distro which will best suit our needs. All Linux software is available on the Internet, so we never lose it. What is Open Source? The term "open source" refers to something that can be modified and shared because its design is publicly accessible. Open source code is typically created as a collaborative effort in which programmers improve upon the code and share the changes within the community. Open Source is a certification mark owned by the Open Source Initiative (OSI). What is Open Source Software? Open source software is software whose source code is available for modification or enhancement by anyone. © Er. Prakash Poudel Jigyasu “Prepare Linux Today for Tomorrow” Page 2

Text from page-3

LINUX QUICK REFERENCE NOTE Open Source Software vs. Other software Some software has source code that cannot be modified by anyone but the person, team, or organization; that created it and maintains exclusive control over it. This kind of software is frequently called "proprietary software" or "closed source" software, because its source code is the property of its original authors, who are the only ones legally allowed to copy or modify it. Microsoft Word and Adobe Photoshop are examples of proprietary software. Open source software is different. Its authors make its source code available to others who would like to view that code, copy it, learn from it, alter it, or share it. LibreOffice and the GNU Image Manipulation Program are examples of open source software. Culture of free Software “Free software” means software that respects users' freedom and community. Roughly, it means that the users have the freedom to run, copy, distribute, study, change and improve the software. Thus, “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”. A program is free software if the program's users have the four essential freedoms:  The freedom to run the program as your wish, for any purpose (freedom 0).  The freedom to study how the program works and change it so it does your computing as you wish (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 distribute copies of your modified versions to others (freedom 3). By doing this you can give the whole community a chance to benefit from your changes. What is a command shell? A shell is an environment in which we can run our commands, programs, and shell scripts. There are different flavors of shells, just as there are different flavors of operating systems. Each flavor of shell has its own set of recognized commands and functions.  A program that interprets commands  Allows a user to execute commands by typing them manually at a terminal, or automatically in programs called shell scripts.  A shell is not an operating system. It is a way to interface with the operating system and run commands. Shell Prompt The prompt, $, which is called command prompt, is issued by the shell. While the prompt is displayed, you can type a command. The shell reads your input after you press Enter. It determines the command you want executed by looking at the first word of your input. Shell Types There are many “shells” in both Linux and Unix. Two kinds of these numerous shells are: 1. The Bourne shell. If you are using a Bourne-type shell, the default prompt is the $ character. 2. The C shell (csh)  C shell is the UNIX shell created by Bill Joy at the University of California as an alternative to UNIX's original shell, the Bourne shell .  If you are using a C-type shell, the default prompt is the % character. The C shell program name is csh.  The C shell was invented for programmers who prefer a syntax similar to that of the C programming language. © Er. Prakash Poudel Jigyasu “Prepare Linux Today for Tomorrow” Page 3

Text from page-4

LINUX QUICK REFERENCE NOTE  The other popular member of the C shell family is called tcsh (for Tab C shell) and is an extended version of C shell. Some of tcsh's added features are: enhanced history substitution , spelling correction, and word completion There are again various subcategories for Bourne Shell which are listed as follows:  Bourne shell ( sh)  Korn shell ( ksh)  The Korn shell is the UNIX shell (command execution program, often called a command interpreter ) that was developed by David Korn of Bell Labs as a comprehensive combined version of other major UNIX shells.  Incorporating all the features of C shell ( csh ) and Tab C-shell ( tcsh ) with the script language features similar to that of the Bourne shell , the Korn shell is considered the most efficient shell.  The Korn shell is considered a member of the Bourne shell family and uses as its shell prompt (character displayed to indicate readiness for user input) the $ symbol.  Because it is the easiest shell to use, inexperienced users usually prefer the Korn shell  Korn shell is developed many years before the emergence of the BASH shell. Because it is older than BASH, it has less resources, and it also attracts limited computer users.  Bourne Again shell ( bash)  POSIX shell ( sh) What is BASH?       BASH = Bourne Again SHell Bash is a shell written as a free replacement to the standard Bourne Shell (/bin/sh) Originally written by Steve Bourne for UNIX systems. It has all of the features of the original Bourne Shell, plus additions that make it easier to program with and use from the command line. Since it is Free Software, it has been adopted as the default shell on most Linux systems. Bash is a newer shell compared to the KSH shell. Bash also acts as an extension of the Korn shell. How is BASH different from the DOS command prompt? Case Sensitivity: In Linux/UNIX, commands and filenames are case sensitive, meaning that typing “EXIT” instead of the proper “exit” is a mistake. “\”vs.“/”: In DOS, the forward-slash “/” is the command argument delimiter, While the backslash “\” is a directory separator. In Linux/UNIX, the “/” is the directory separator, and the “\” is an escape character. Filenames: The DOS world uses the “eight dot three” filename convention, meaning that all files followed a format that allowed up to 8 characters in the filename, followed by a period (“dot”), followed by an option extension, up to 3 characters long (e.g. FILENAME.TXT). In UNIX/Linux, there is no such thing as a file extension. Periods can be placed at any part of the filename, and “extensions” may be interpreted differently by all programs, or not at all. © Er. Prakash Poudel Jigyasu “Prepare Linux Today for Tomorrow” Page 4

Text from page-5

LINUX QUICK REFERENCE NOTE Special Characters Before we continue to learn about Linux shell commands, it is important to know that there are many symbols and characters that the shell interprets in special ways. This means that certain typed characters: a) cannot be used in certain situations, b) may be used to perform special operations, or, c) must be “escaped” if you want to use them in a normal way. character . Description Escape character. If you want to reference a special character, you must “escape” it with a backslash first. Example: touch /tmp/filename\* Directory separator, used to separate a string of directory names. Example: /usr/src/linux Current directory. Can also “hide” files when it is the first character in a filename. .. Parent directory ~ User's home directory * Represents 0 or more characters in a filename, or by itself, all files in a directory. Example: pic*2002 can represent the files pic2002, picJanuary2002, picFeb292002, etc. Represents a single character in a filename. Example: hello?.txt can represent hello1.txt, helloz.txt, but not hello22.txt Can be used to represent a range of values, e.g. [0-9], [A-Z], etc. Example: hello[0-2].txt represents the names hello0.txt, hello1.txt, and hello2.txt “Pipe”. Redirect the output of one command into another command. Example: ls | more Redirect output of a command into a new file. If the file already exists, over-write it. Example: ls > myfiles.txt Redirect the output of a command onto the end of an existing file. Example: echo “Mary 555-1234” >> phonenumbers.txt Redirect a file as input to a program. Example: more < phonenumbers.txt Command separator. Allows you to execute multiple commands on a single line. Example: cd /var/log ; less messages Command separator as above, but only runs the second command if the first one Finished without errors. Example: cd /var/logs && less messages Execute a command in the background, and immediately get your shell back. Example: find / -name core > /tmp/corefiles.txt & \ / ? [] | > >> < ; && & Executing Commands The Command PATH:   Most common commands are located in your shell's “PATH”, meaning that you can just type the name of the program to execute it. Example: Typing “ ls” will execute the “ ls” command. Your shell's “PATH” variable includes the most common program locations, such as © Er. Prakash Poudel Jigyasu “Prepare Linux Today for Tomorrow” Page 5

Lecture Notes