
Introduction to the Command Line The Fat-Free Guide to Unix and Linux Commands Second Edition Introduction to the Command Line The Fat-Free Guide to Unix and Linux Commands Second Edition Copyright © 2010 Nicholas Marsh All rights reserved. ISBN: 1450588301 EAN-13: 9781450588300 www.DontFearTheCommandLine.com AIX® is a registered trademark of IBM Corp. BSD® is a registered trademark of the University of California, Berkeley CentOS is property of CentOS Ltd. Debian® is a registered trademark of Software in the Public Interest, Inc Fedora® is a registered trademark of Red Hat, Inc. FreeBSD® is a registered trademark of The FreeBSD Foundation Gentoo® is a registered trademark of The Gentoo Foundation HP-UX® and Tru-64® are registered trademarks of Hewlett-Packard Company IRIX® is a registered trademark of Silicon Graphics, Inc. Linux® is the registered trademark of Linus Torvalds. Mac OS X® is a registered trademark of Apple, Inc. Windows® is a registered trademark of Microsoft Corporation NetBSD® is a registered trademark of The NetBSD Foundation OpenBSD® is a registered trademark of Theo DeRaadt Red Hat® is a registered trademark of Red Hat, Inc. Solaris® and OpenSolaris are registered trademarks of Sun Microsystems SUSE® is a trademark of Novell, Inc. Ubuntu® is a registered trademark of Canonical Ltd. UNIX® is a registered trademark of The Open Group UnixWare® and OpenServer® are registered trademarks of The SCO Group All other trademarks used in this book are the property of their respective owners. Use of any trademark in this book does not constitute an affiliation with or endorsement from the trademark holder. All information in this book is presented on an "as-is" basis. No warranty or guarantee is provided and the author and/or publisher shall not be held liable for any loss or damage. Contents at a Glance Introduction .................................................................................. 6 Section 1: Overview of Unix, Linux and BSD Architecture ............. 10 Section 2: Command Line Basics .................................................. 18 Section 3: Advanced Shell Features and Commands .................... 38 Section 4: Text Editing and Extraction .......................................... 60 Section 5: Users, Groups, and Security ......................................... 81 Section 6: Process Control and Scheduling .................................. 106 Section 7: Startup and Shutdown .............................................. 122 Section 8: Network Commands ................................................. 139 Section 9: Hardware Management Commands .......................... 167 Section 10: File Systems ............................................................ 177 Section 11: Backup and Restore Commands .............................. 192 Section 12: Monitoring and Troubleshooting ............................. 200 Section 13: Printing Commands ................................................. 224 Section 14: Software Installation ............................................... 231 Section 15: System Administration Utilities ................................ 245 Appendix A: Bash Shortcut Keys ................................................ 248 "UNIX is basically a simple operating system, but you have to be a genius to understand the simplicity." – Dennis Ritchie Creator of the C programming language and co-creator of UNIX Introduction The command line can be an intimidating and unforgiving environment. Unlike working in graphical environments, it's not entirely clear what commands one must execute in a terminal to accomplish a given task. Couple this with the fact that the command line does not prevent you from doing things that might cause irreparable damage to your system, and it becomes clear why many people never take the time to learn how to use it. Despite the hidden dangers and uncertainty faced by new users (known jokingly as "newbies" in the technology industry), you shouldn't fear the command line. Armed with the information in this book you will acquire the skills necessary to become more proficient in the command line environment. You will discover that most Unix, Linux, and BSD systems share the same core architecture, with only a few subtle differences. After learning the basic architecture and commands of Unix, Linux, and BSD systems you will easily be able to transition between the different platforms. To aid the learning process, I recommend downloading one or more of the free operating systems listed below to practice the commands in this guide. Operating System Type Website Ubuntu Linux www.ubuntu.com Fedora Linux www.fedoraproject.org CentOS Linux www.centos.org openSUSE Linux www.opensuse.org OpenSolaris Unix www.opensolaris.org FreeBSD BSD www.freebsd.org It's a worthwhile experience to experiment with multiple Unix, Linux, and BSD distributions to get a broader knowledge of the various platforms. This will help expand your knowledge of the various Unix-like operating systems and give you the skills necessary to work in any command line environment. Linux is the recommended starting point for beginners. It has support for all the latest hardware and provides a user-friendly installation process. The OpenSolaris Unix platform is also a good starting point, as it is one of the most newbie-friendly Unix-based systems. BSD installation is a bit more challenging and requires advanced technical knowledge or previous experience with Unix and Linux systems. I highly recommend Ubuntu Server Edition. It provides an easy install experience and an excellent command line learning environment. Visit Tip www.ubuntu.com for more information about the Ubuntu Server Linux distribution. If you are a Microsoft Windows user, you may already have some command line experience. If you have ever opened a DOS prompt and executed a command such as ping, nslookup, or ipconfig then you know these can be immensely helpful. Unix, Linux, and BSD systems offer similar commands. For example, the ping and nslookup commands work the same on Unix/Linux as they do in DOS. You should note, however, that the DOS ipconfig command's counterpart in the Unix/Linux/BSD world is ifconfig. If you're not a DOS veteran, don't worry - we will cover all of these topics throughout this guide. Are you running Mac OS X? If so, then you are already running a Unix-based operating system. Behind the shiny graphical user interface of Mac OS X is a solid Unix core. To access the command line in Mac OS X simply launch the Terminal application (located in Applications > Utilities > Terminal). From there you will have access to all the standard Unix command line utilities discussed in this guide. Brief History of Unix, Linux, and BSD Unix was created in 1969 at Bell Laboratories which was, at the time, a research and development division of AT&T. Since that time, Unix has branched into many different commercial and open source implementations, most of which are based on the original AT&T standard. Modern Unix-based systems are typically classified into one of the following groups: Unix Commercial implementations derived from the original AT&T code base BSD Open source operating system derived from the original Unix code base Linux Open source Unix compatible clone written from scratch In the 1970s, researchers at the University of California, Berkeley began developing BSD (short for Berkeley Software Distribution). BSD was originally based on the AT&T Unix codebase, but has been rewritten over time to remove AT&T copyrighted code from the system. This allows BSD to be distributed with minimal restrictions. Since that time, the BSD code-base has split to form a number of popular operating systems including FreeBSD, OpenBSD, and NetBSD. BSD code can also be found in proprietary proprietary operating systems created by Microsoft, Apple, and Sun Microsystems. Commercial Unix systems began to appear in the early 1980s. These systems combined various amounts of Unix and BSD code along with vendor-specific enhancements to create new platforms such as AIX, HP-UX, and Sun Solaris. Today, commercial Unix systems can be found in data centers at many large companies running mission critical applications. In 1991, a computer science student at the University of Helsinki in Finland named Linus Torvalds created the Linux operating system. While Linux shares much of the core concepts of Unix, it contains no Unix code. This means it can be freely distributed in the same manner as BSD (although under a different license). The first commercial Linux distributions hit the market in the mid 1990s. Since then hundreds of Linux variants have been developed. The open nature of the Linux operating system has contributed to its success and helped make it one of the most popular server operating systems in use today. The Unix platform has been around since long before graphical user interfaces were invented. The fact that Unix-based systems are still a commanding force in modern computing is a testament to the industrial design of the platform. With Unix, Linux, and BSD popularity at an all time high, now is the perfect time to explore these platforms and join the movement. Conventions Used in This Book /path/to/file File and directory paths are displayed in a fixed width font command Commands are displayed in a bold fixed width font [FILE], [DIRECTORY], [ETC] Items enclosed in brackets represent a variable parameter to be specified by the user (such as a file or directory) $ ping 192.168.1.1 Examples using the $ shell prompt are executed with a non-privileged
Details
-
File Typepdf
-
Upload Time-
-
Content LanguagesEnglish
-
Upload UserAnonymous/Not logged-in
-
File Pages248 Page
-
File Size-