Unix and Linux System Administration and Shell Programming
Total Page:16
File Type:pdf, Size:1020Kb
Unix and Linux System Administration and Shell Programming Unix and Linux System Administration and Shell Programming version 56 of August 12, 2014 Copyright © 1998, 1999, 2000, 2001, 2002, 2003, 2004, 2005, 2006, 2007, 2009, 2010, 2011, 2012, 2013, 2014 Milo This book includes material from the http://www.osdata.com/ website and the text book on computer programming. Distributed on the honor system. Print and read free for personal, non-profit, and/or educational purposes. If you like the book, you are encouraged to send a donation (U.S dollars) to Milo, PO Box 5237, Balboa Island, California, USA 92662. This is a work in progress. For the most up to date version, visit the website http://www.osdata.com/ and http://www.osdata.com/programming/shell/unixbook.pdf — Please add links from your website or Facebook page. Professors and Teachers: Feel free to take a copy of this PDF and make it available to your class (possibly through your academic website). This way everyone in your class will have the same copy (with the same page numbers) despite my continual updates. Please try to avoid posting it to the public internet (to avoid old copies confusing things) and take it down when the class ends. You can post the same or a newer version for each succeeding class. Please remove old copies after the class ends to prevent confusing the search engines. You can contact me with a specific version number and class end date and I will put it on my website. version 56 page 1 Unix and Linux System Administration and Shell Programming Unix and Linux Administration and Shell Programming chapter 0 This book looks at Unix (and Linux) shell programming and system administration. This book covers the basic materials needed for you to understand how to administer your own Linux or Unix server, as well as how to run your own personal desktop version of Linux or Mac OS X. This book goes beyond the typical material in a shell scripting class and presents material related to either downloading and compiling existing software (including ports to new hardware and/or operating systems) or for preparing your own software for release via the internet. requirements You need a willingness to learn. You need a working computer or server or access to one. The computer needs a working version of Unix, Linux, Mac OS X, AIX, HP/UX, Solaris, etc. (it can be a dual boot computer). The new version of Mac OS X 10.9 (Mavericks) is now available on the Mac App Store at www.apple.com as of October 22, 2013. The new version of Mac OS X 10.8.1 (Mountain Lion) is now available on the Mac App Store at www.apple.com as of August 23, 2012. The new version of Mac OS X 10.8 (Mountain Lion) is now available on the Mac App Store at www.apple.com as of July 25th, 2012. Tell them you heard about it from www.osdata.com when you register your new copy. A working connection to the internet is recommended, but not required, preferably a high speed connection. You may use LAMP on Linux, MAMP on Mac OS X, or WAMP on WIndows to set up and experiment with a local web server. You may want to have a domain name of your own and web hosting to try out controlling a server. You can use GoDaddy or HostGator or most any other major hosting provider to obtain these servcies for low cost with great telephone tech support. The OSdata.com website where this book is offered to the public is hosted by Host Gator. You may use any other hosting service you want. options Almost anyone can learn this material. It isn’t complicated. It really helps if you enjoy doing this kind of thing. You will learn faster and you will enjoy the work. If you don’t enjoy this kind of computer activity, please think carefully about whether or not you want to spend decades at a job you hate. Almost anyone can slog through and learn at least some of this material, but an aptitude for this material greatly helps learning. If you are strong at grammar, then you will probably be able to master. This material. mathematical ability is useful, but not necessary. Many portions of this book require root or administrator access. While you learn better if you can actually try out each command for yourself, you can just read about root material if you don’t have root or administrator access. version 56 page 2 Unix and Linux System Administration and Shell Programming Some portions of this book require special software. Most of the software can be downloaded for free. Those with Mac OS X should have the Developer Tools installed. These are available for free on either the install DVD/CD or from Apple at http://connect.apple.com/ A static IP address is in general useful and is required for some portions of this book. proletarian This book is intentionally proletarian and is specifically intended to allow anyone, regardless of socio-economic position, to have access to the basic information and the power against the established authorities that such knowledge provides. This subversive intent is consistent with Linux, which was created by a college student who couldn’t afford the dominant tools of the time. This contrasts strongly with Apple’s Macintosh, Mac OS X, and iOS, all of which are specifically targeted for sales to the trendiest members of the wealthy class. Apple does offer a discount to school children, but that discount is smaller than the discount Apple offers to large corporations. This also contrasts with Microsoft’s Windows, which is specifically targeted for sales to large corporations and their employees. And this contrasts with Google’s Android, which is specifically targeted for businesses. The users of Android products are part of Google’s product, not the customer. The customers are businesses who want detailed information on the masses for purposes of advertising. This book is intended to make knowledge available to everyone, especially those who are increasingly being shut out of the mainstream education system. goals Please note that at the time this paragraph was written, these goals are not yet implemented in the text. Now is a good time to make suggestions on modifications of the goals. The reader will understand the Unix computing environment and history. The reader will be able to access the Unix system and perform basic operations, including using help features. The reader will be able to access and manipulate files and directories, including basic and advanced directory and file management. The reader will be able to use file system utilities. The reader will be able to design and implement file system security. The reader will be able to print documents. The reader will be able to perform system backups and restores. The reader will be able to troubleshoot system processes. The reader will be able to perform environment customization. The reader will become acquainted with networks, web servers, web clients, transaction security, and other basic network concepts. The reader will learn how to create a web page that accepts input, program the server response, and interface the input with a database. version 56 page 3 Unix and Linux System Administration and Shell Programming The reader will understand web server functionailty and be able to install and configure Apache. The reader will be able to work with, understand, and configure DNS functionality. The reader will be able to set up and maintain his or her own general purpose server, including hosting, server administration, security, user interactivity, and database integration. The reader will be familiar with SQL Server architecture and able to efficiently administer and maintain SQL Server instances and databases. The reader will be able to secure a web server and its websites. personal reference book I strongly recommend that each reader print out this PDF and the manual pages from your computer and place the resulting pages into a looseleaf binder. That will allow you to organize the chapters in the order that makes the most sense for you. It will also allow you to make notes in the margins. It will allow you to easily add materials from other sources. The resulting binder will be personalized to meet your individual needs. If you have a limited printing budget (ink is expensive), print out portions of this PDF as needed. chapter contents 1. cool shell tricks 2. basics of computers 3. Unix/Linux history 4. choice of shells 5. connecting to a shell (Telnet and SSH; terminal emulator) 6. shell basics (book conventions; root or superuser; starting your shell; login and password; prompt; command example) 7. login/logout (login; select system; account name; password; terminal type; logout; exit) 8. passwd (setting password; local password; periodic changes; 100 most common passwords; secure passwords; superuser) 9. command structure (single command; who; failed command; date; options, switches, or flags; universal time; arguments; options and arguments; operators and special characters) 10. quick tour of shell commands 11. man (using man for help; man sections) 12. cat (creating files; example files for this book; viewing files; combining files) 13. command separator (semicolon) 14. less, more, pg 15. file system basics (graphics examples; directory tree; important directories; home directory; parent and child directories; absolute paths; relative paths; dots, tildes, and slashes) 16. pwd 17. command history 18. built-in commands 19. ls 20. cd 21. cp 22. mv 23. rm (recursive) 24. shred 25. mkdir 26. alias version 56 page 4 Unix and Linux System Administration and Shell Programming 27.