Basics of System Administration on a Unix System Contents
Total Page:16
File Type:pdf, Size:1020Kb
Basics of system administration on a Unix system Contents Introduction 3 Unix 9 User environment: the shell 10 File management: starting from / 11 Text editing 12 Package management 13 User management 14 Process management 15 Networking services 16 Web 17 Database 18 Mail 19 Users 20 Files 21 DNS 22 Printing 23 Credits 24 This is a development version of the text that should be considered a work-in-progress. Copyright © 2011 Dara Adib. This is a freely licensed work, as explained in the Definition of Free Cultural Works (freedomdefined.org). It is licensed under the Creative Commons Attribution- Share Alike 3.0 United States License. To view a copy of this license, visit: http://creativecommons.org/licenses/by-sa/3.0/ 2 Introduction What is a computer? A computer is a combination of hardware and software that can store, retrieve, and process infor- mation. Hardware Hardware is the physical electronics of a computer, which include one or more processors (“the brain”), random-access memory (“short-term memory”), disk (“long-term memory”), input/output devices (“sense/motor organs”), power supply, and complex circuitry and buses which connect components. Software Software is the conceptual instructions that run on hardware, including system programs and application programs. An operating system is an essential software component. What is an operating system? An operating system (OS) is a collection of system programs (and depending on definition, application programs) that accomplish User abstraction through hardware, file, process, and user manage- ment (and depending again on definition, by providing a user Application environment). Operating System Hardware management An operating system deals with the physical complexity of initial- Hardware izing, calibrating, polling, and resetting hardware components. It provides a uniform interface to hardware components that is in- Figure 0.1: What is an OS? dependent of physical technicalities. Hardware components can fail or have temporary (transient) errors, which an operating sys- tem should detect and account for to prevent downtime or data corruption as much as possible. 3 File management An operating system provides, with the help of a file system, a uniform interface to storing, re- trieving, and modifying programs and data with hierarchical organization (for example, files are organized in directories or folders). Most changes made by other programs in a file system are written to physical disk at intervals and journaled for recovery in the case of disk or power fail- ure. A file system may also include special files like references to other files, interfaces to running programs, and interfaces to physical or virtual devices. Process management In a modern operating system, many programs appear to be running “simultaneously”. In real- ity, each processor (for simplicity, each processing core represents a processor) is only capable of handling one thread of execution at a time. Since each running program (known as a process) represents at least one thread, an operating system must switch between running threads as opti- mal and in a way that is least disruptive to the processes. In multiprocessor systems, an operating system must also effectively distribute threads between processors. There are also security concerns, which are of special importance in a multi-user system, where users do not all trust each other. All processes are allocated space in random-access memory (RAM) where they store and manipulate data. They need to be prevented from gaining access to space reserved for other processes. Not all processes are of equal importance. For example, a typical process should not be able to terminate or kill other processes, particularly those belonging to other users. Nevertheless, processes may need to communicate with each other through signals or interfaces. User management An operating system needs to provide a way for a user to, well, use a computer. Generally this involves the user authenticating with a username and password, and having some degree of secu- rity and privacy with his1 files and processes. There may be limitations on how much disk space and processing time he can use. He might also have other privileges or restrictions depending on security policy. Modern operating systems are multi-user, which means that multiple users can co-exist and can usually time-share resources at the same time (for example, multiple user logged in). There is often an administrator or superuser who can bypass restrictions for system administration tasks. User environment A user environment (the software a user interacts with to use the computer) is often considered part of the operating system. A user environment can be graphical (GUI, for graphical user in- terface) or text-based (CLI, for command line interface, also known as terminal, command line, and command prompt). With a text-based environment, there is usually a prompt which waits for commands to be entered and after a command is entered, outputs some result and waits for the 1For the purposes of simplicity, the masculine pronoun is used in this text, but gender is not specified. 4 next command. With a graphical environment, the user is usually encouraged to point and click the mouse. Graphical environments are often called “user-friendly” because they require less knowledge to use, but text-based environments often offer more flexibility and power at the expense of some knowledge and experience. Networking Most computers today are connected to a network, over wired or wireless connections. A network can be small, such as a home network connected by a small router, medium-sized, such as a uni- versity or corporate network, or large, such as the Internet which is connected by many gateways with high bandwidth and throughput. Modern operating systems include features specifically designed for networked applications. Hardware management • communicating with other computers, gateways, and switches through a network interface like ethernet (wired or wireless) File management • networked file systems (access data over network) • distributed file systems (split data over multiple computers) Process management • computing distributed over a cluster of nodes (physically distinct machines) User management • remote user access • remote authentication mechanisms (for example, an institution may have many machines that authenticate to the same database of users) What is Unix? UNIX is an operating system originally developed in 1969 by AT&T at Bell Labs. It was re- written in 1972 in the programming language C, which allowed it to be portable, i.e. work on different hardware. For simplicity, Unix will be used to refer to the family of operating systems that have been (mostly) designed as UNIX-compatible or UNIX-compatible-compatible, which include, among many others, variants of the Berkeley Software Distribution (such as FreeBSD, NetBSD, OpenBSD, and Mac OS X), GNU/Linux (such as Debian, Ubuntu, Red Hat, Fedora, Gen- too, and Arch), and Solaris. 5 1970 1980 1990 2000 Time FreeBSD 7.2 BSD family NetBSD 5.0 OpenBSD 4.5 BSD (Berkeley Software Distribution) Bill Joy SunOS (Stanford) Solaris (SUN) 10 5/09 Darwin NextStep 3.3 MacOS X 5.7 Xenix OS Microsoft/SCO GNU/Hurd K16 GNU Project Richard Stallman GNU/Linux 2.6.30.1 Minix Linus Torvalds 3.1.3a Andrew S. Tanenbaum Unix Time-Sharing System (Bell Labs) 10 Ken Thompson Dennis Ritchie (C language) HP-UX 11i v3 AIX (IBM) 6.1 UnixWare (Univel/SCO) 7.1.4 MP4 IRIX (SGI) 6.5.30 System III & V family Figure 0.2: What is Unix? Unix is a multi-user time-sharing network operating system, making it one of the original mod- ern operating systems. According to the so-called Unix philosophy, it is implemented with: • programs that do one thing and do them well • programs that communicate well with other programs Though many user environments have been developed for Unix, both text-based and graphical, the text-based shell is strongly associated with Unix. Perhaps this is because of how well the shell allows a user to exploit the features of Unix. Even Apple, associated with hip and aestheti- cally pleasing computers, implements Mac OS X on Unix (BSD) and includes the GNU Bash shell (GNU/Linux). What is system administration? System administration is the maintenance and operation of a computer system. It usually involves installing, maintaining, and supporting servers, and responding to services outages when they occur. It can also include a broader range of associated tasks, such as planning, scripting, training, consulting, and perhaps most importantly, problem solving. A system administrator (sysadmin) must not only be technically skilled, but also responsible and trustworthy. Sysadmins need to be responsible for the availability and security of services that a computer system provides. He must also use his power wisely2. 2See The Bastard Operator From Hell (Plan Nine, ISBN 1-929462-17-4). 6 Figure 0.3: System administration What is free software / open source software? Free software is software that can be freely run, studied, modified, adapted, improved, copied, distributed, and redistributed. For both ethical and practical reasons, developers of free software give access to the software source code that determines how a program functions and release the software under liberal licenses that impose few restrictions. Free software directly contrasts with proprietary software, where copyright and contracts impose restrictions. Definition Richard Stallman, founder of the GNU Project, lists four essential freedoms that must all be present for a piece of software to be considered free. 1. The freedom to run the program, for any purpose. 2. The freedom to study how the program works, and adapt it to your needs. Access to the source code is a precondition for this. 3. The freedom to redistribute copies so you can help your neighbor. 4. The freedom to improve the program, and release your improvements (and modified ver- sions in general) to the public, so that the whole community benefits.