CNT 5605, Spring 2017: Introduction
Introduction to Unix
- Unix is now 48 years old
- It began in 1969
Introduction to Unix
- Started at AT&T's Bell Labs, and it was derived from MULTICS.
- Initial hardware was a DEC PDP-7, and the filesystem
was hierarchical but did not have pathnames
- I.e., there was no equivalent to a pathname such as /etc/hosts, it would just be hosts; directory information was kept in a special file called dd.
Introduction to Unix
- Rather than a product from a manufacturer, Unix began as collaboration with these goals:
- Simplicity
- Multi-user support
- Portability
- Universities could get source code easily
- Users shared ideas, programs, bug fixes
A History of Unix
In the beginning, processes were very different
- Originally, each terminal only could have one active process
- When creating a ``child'' process, the parent first closed all of its open files
- Then the parent linked to the executable and opened it
- Then the parent copied a bootstrap to the top of memory and jumped into the bootstrap
- The bootstrap copied the code for the new process over the parent's code and then jumped into it
- When the child did an exit, it first copied in the parent process code into its code area, and then jumped back into
the parent code at the beginning
Old Unix
Today the parent uses a fork/exec/wait model:
- fork(2) (to create a new child process)
- exec*(2) (to have the child process start executing a new program)
- wait*(2) (to wait on the child (or at least check on its status if non-blocking))
- exit(2) (exit a process)
Linux
- Runs on huge array of hardware, from IBM's biggest machines down to commodity routers such as, say, a commodity SOHO router using OpenWRT
- Is the kernel begun by Linus Torvalds. (He is still in charge of kernel development (4.7.2 is the current stable release — see http://www.kernel.org), though now *many* people work on the kernel.)
- But there's lots more!
Linux: a complete Unix-compatible operating system
System administration duties
- Installing new hardware and software
- Updating and upgrading hardware and software
- Monitoring for problems
- Resolving problems
- Planning for growth and obsolence
- Making backups
- Recovering data from backups
System administration responsibilities (AIC)
System administrators are stewards, who take care of other people's data and the technology that they use to access it. The system administrator's credo is "AIC", which breaks down into
- Availability of services and data
- Integrity of services and data
- Confidentiality and security
System administration responsibilities: Availability
- Lack of availability can have a large dollar impact on many businesses
- The most common dangers to availability are SPOFs (single points of failure)
- SPOFs are generally cured by redundancy. Redundancy models:
- Cold → Good points: ``guarantees'' availability, but (1) typically most expensive (2) tends to require frequent testing (3) typically slow to bring live
- Warm dual-use hardware that is powered up and used for related but non-production purposes such as development or q/a) → Typically good availability and less expensive than cold since the hardware has day-to-day use, but (1) tends to be one-offish and (2) tends to require frequent testing of switchover
- Hot (redundant hardware in production) typically least expensive since it is in active production use and testing requirements tend to be less but more likely to have capacity problems in the event of partial failure
System administration responsibilities: Integrity of data
- For system administration purposes, often data integrity is implicitly enforced both at the hardware and the
operating system level, such as CRCs for disk reads, parity in RAID-5 controllers, and so forth. Even programming languages can be constructed
that help provide security, though lamentably such languages have not become popular.
- Data integrity can also be an explicit issue, such as with naming issues.
System administration responsibilities: Data security
- This is a big topic, even from a pure system administration point of view.
- Passive security: design your systems with security in mind. (Fail2ban is one of the better intrusion prevention packages available.)
- Active security: (1) Proactively searching for problems. (2) Forensically researching problems, but digital forensics is a separate science on its own.
Mechanics of Unix/Linux administration: editors, scripting, and compilation
- Editors: A lot of Unix/Linux system administration tasks revolve around editing various files. The best
two choices for editing are probably vi/vim and emacs, although there are many, many editors available. Certainly nano is quite popular.
- Scripting: In addition to simple configuration files, another important subset of tasks that require editors
are scripts. These scripts are used for various purposes, and often automating routine tasks such as running
programs such as updatedb.
- Compilation: Generally on Unix/Linux machines, gcc or clang are good choices for compilation. While gcc is not perfect, and the various generations of gcc can be somewhat frustrating to deal with, clang also suffers from some issues. However, both are FOSS. Glibc is even less perfect.
Unix/Linux system administration: editors &mdash looking at vi
While the standard editor in Unix is traditionally considered to be
ed, its offspring
vi is far more commonly used for interactive editing (and
sed is more common for non-interactive editing):
- vi: vi is almost always found somewhere on a Unix/Linux machine, often in the form of vim.
- vi advantage: It is simple to learn. It has two modes, ``motion'' and ``insert''. In the ``motion'' mode,
the most important keys are just
- h: Move the cursor left.
- l: Move the cursor right.
- j: Move the cursor down.
- k: Move the cursor up.
- i: Go into ``insert'' mode.
- :: Execute an internal vi command of some sort. The most popular are w for "write",
q for "quit", and quit! for "quit without saving anything".
You can see a larger summary of vi/vim commands here.
Unix/Linux system administration: editors &mdash still looking at vi
- vi/vim disadvantage: While original vi is quite simple, it also is not very featureful. This isn't as much of a problem with vim, an updated version of vi. Vim extensions are not as logical as those of
emacs since they were created as an afterthought.
Unix/Linux system administration: editors &mdash looking at emacs
emacs: Not always installed by default. In fact, in the last few years, default installation of Emacs in Unix/Linux distributions has become less common.
- emacs advantages: As computer scientists, emacs is quite intuitive: each sequence of keystrokes can be mapped to an arbitrary Emacs Lisp function. For instance, by default in TeX mode, the key a is just mapped to a function which inserts
an a, but the double quote key is mapped to insert first a pair of `` and then the second time to insert a pair of closing '' in accord with TeX's expectations.
- emacs is also quite good with UTF-8 files.
- emacs disadvantage: It's not found on every machine.
- emacs disadvantage: It's big. Doing an install via repositories can occasionally entail many more packages than you might expect!
You can see a larger summer of emacs default keybindings here.
Unix/Linux system administration: scripting languages
- bash: The ``Bourne-Again SHell''. Introduced the ``readline'' library. A comprehensive overhaul of the original Bourne shell.
- perl5: The ``Practical Extraction and Report Language''. An amazing language in its own right; originally, it could be mistaken for line noise, much as the old TECO editor commands.
- perl6: Currently, version 5 is very useful. Version 6 is now official, but it's not clear that there has been much excitement around it.
- python: An increasingly popular programming language for system administration tasks.
- Some additional notes on scripting.
Unix/Linux system administration: scripting languages
- Scripts in the Unix/Linux world are most commonly written in shell, Perl, and Python. (We still occasionally find some AWK scripts, but it's been fading fast over the last few years.)