Syncopated Systems
Seriously Sound Science

An Introduction to the Unix Operating System

What is Unix?

Unix is a registered trademark used to describe operating systems that comply with design standards set by The Open Group, which owns the trademark and promotes industry standardization.

Systems that are modeled after but don't (or don't yet) meet the standard are often described as Unix-like. For example, the many variants of Linux operating systems (such as Red Hat and Ubuntu distributions) are Unix-like. For brevity, this article will refer to both as Unix systems.

Why Use Unix?

In a nutshell, the best reason to use Unix is financial: the quality and completeness of the Unix design makes it easy and thus very cheap to use.

Costs of Operation

Because Microsoft Windows has so many problems in its design and implementation, the cost of supporting each Windows-based computer is roughly ten times higher than the cost of supporting a comparable computer running a Unix or Unix-like operating system. The process of patching the holes in Windows is so costly that its value added – relative to that of Unix or Linux – may actually be very negative for many users.

Due to its many serious and well-documented design flaws affecting its stability and security (some dating back roughly 25 years), Microsoft Windows ideally should not be used as the primary operating system for any computer with a network connection (Internet or not) or removable-media interface (such as U.S.B. ports or c.d.rom, d.v.d.rom or floppy disk drives), nor should other Microsoft products such as Internet Explorer and Office (including Excel, PowerPoint and Word) be used on these machines. Instead, the primary operating system of those computers should conform to (or at least approximate) The Open Group's Unix specification.

By using a machine virtualization product, one may run Microsoft Windows more securely under Linux using it's Xen, Unix (or FreeBSD or the like) using VMware Workstation, or under Apple OS X (on the Intel-based MacBook or MacBook Pro) using Parallels Desktop or VMware Fusion.

Perhaps the best value is Linux, which is very much like Unix and ultimately costs nothing, though Linux distributors may charge for media and support.

Getting Started with Unix

Microsoft DOS – the foundation on which Windows is built – was roughly modeled after Unix and its popular predecessors. So, if you know how to operate a computer that runs Windows (even if only through its graphical user interface), chances are good that you'll find Unix easy to use.

Unix, like Windows, relies on a system of commands that can be entered through a text-based interface called a command interpretter. On computers running Unix or Unix-like operating systems, a command interpretter or command interpretter window is often referred to as a shell.

If one must use a computer running only Microsoft Windows, additional Unix-like functionality may be gained by downloading and running under Windows the no-cost Minimalist GNU for Windows (MinGW) program.

Though there exist many more, most users will be served by the following common commands to Unix shells and programs executed from those shells:

Selected Unix Shell Commands with Similar DOS/Windows Commands
Unix shell commandfunctional descriptionsimilar DOS/Windows command
bashGNU Bourne-Again SHell: a command interpreter (like csh, ksh, sh, tcsh)cmd, command, start
catconcatenate files and display their contentstype
cdchange working directory to a specified directory (a shell "builtin" command)cd, chdir
chmodchange file modes (read, write, execute permissions)attrib
chownchange file owner and groupcacls
clearclear the terminal screencls
cpcopy filescopy, diskcopy, replace, xcopy
crondaemon to schedule command executionat
csha shell (command interpreter) with C-like syntax (like bash, ksh, sh, tcsh)cmd, command, start
datedisplay or set date and timedate, time
difffind differences between two filescomp, diskcomp, fc
echowrite arguments to the standard outputecho
exitexit the shell (end session, a shell "builtin" command)exit
findfind file(s) matching specified namedir
fsckfile system consistency check and interactive repairchkdsk
ftpfile transfer program (when possible, use sftp instead)
via ftp, commands cd, ls, mkdir, pwd, rm, rmdir affect remote machine; commands lcd, lls, lpwd, lmkdir affect local machine; other commands include:
ftp †
   getcopy a specified file from the remote machine to the local machine 
   helpdisplay commands and other helpful information
   putcopy a specified file from the local machine to the remote machine
   quitexit and end the program
grepGNU Regular Expression Parser: print lines matching a pattern (for example, grep -i -e "<H" index.html could be used to create an table of contents based on HTML heading tags in the file named "index.html")find, findstr
helpprint a list of commands (see also info, man)help
infodisplay information for specified command or program (see also help, man)help
kshKorn SHell: a command interpreter (like bash, csh, sh, tcsh)cmd, command, start
lessdisplay file in screen-sized pages (like more)more
lnmake linkssubst
lprprint filesprint
lslist directory contentsdir, tree, vol
mandisplay the on-line manual pages for a specified command (for example: man ls displays the manual pages for the ls command; see also help, info)help
mkdircreate the directory specifiedmd, mkdir
moredisplay file in screen-sized pages (like less)more
mvmove filesmove, ren or rename
pingtest network hosts and connections by sending echo-request packetsping †
pwdprint the name of the working directorycd
rmremove the file(s) specified from directorydel or erase ‡
rmdirremove the subdirectory specified from directoryrd, rmdir
shshell (command interpreter; like bash, csh, ksh, tcsh)cmd, command, start
sortsort lines of text filessort
sttyset the options for a terminal device interfacemode
tcshC shell (command interpreter) with file name completion and command line editing (like bash, csh, ksh, sh)cmd, command, start
telnetTelnet protocol remote login program (when possible, use ssh instead)telnet †
vivisual text editoredit †† or edlin
   (control-d)scroll down a page 
   (control-u)scroll up a page
   ddelete line(s)
   ienter insert mode
        (escape)exit insert mode
   xdelete character(s)
   Ggo to end of file
   :enter command
        helphelp; may be followed by a command to get help on (as in ":help ZZ")
        qexit and end the program
        wwrite (save)
        !force (as in ":q!", which quits without saving)
   /search text
   ?search text backward (up)
footnotes:
† : These commands were added in Microsoft Windows 2000 and possibly earlier versions.
†† : The edit command was added in Microsoft DOS 5 (1991).
‡ : The erase command was apparently added after Microsoft's Bill Gates incorrectly answered a trick question about DOS on a television game show.

More Standard Unix Functions

In addition to the above, Unix offers many more standard functions than Windows. These include:

Selected Unix Shell Commands without Similar DOS/Windows Commands
Unix shell commandfunctional description
apachectlApache h.t.t.p. (Web) server control interface (see also httpd)
ccC and C++ compiler (see also gcc, make)
curltransfer a specified uniform resource locator (u.r.l.; now called universal resource identifier, or u.r.i.)
cvsConcurrent Versions System: control and share versions of files (especially useful in collaborative development environments)
fingerlookup information about specified user
gccGNU C and C++ compiler (see also cc, make)
hexdumpdisplays ("dumps") each byte in a file using its ASCII, decimal, hexadecimal and/or octal representations (for example, hexdump -C offerltr.doc displays the hexadecimal and character representations of each byte in the file named "offerltr.doc") (deprecates od; see also strings)
httpdApache hypertext transfer protocol (Web) server (executes as a "daemon", returning control back to the shell while running; see also apachectl)
killterminate or signal a process
makeGNU make utility to build groups of program files (see also cc, gcc)
oddisplays ("dumps") each byte in a file using its ASCII, decimal, hexadecimal and/or octal representations (deprecated by hexdump; see also strings)
psshow status of processes
sftpsecure file transfer program (like ftp; see its commands in the table above)
sshsecure shell remote login program (like telnet; see its commands in the table above)
stringsfind the printable strings in a binary file (see also hexdump, od)
sudoexecute a command as another user (use sparingly)
topdisplay and update sorted information about processes
trtranslate characters (for example, cat input.txt | tr "\r" "\n" > output.txt creates an output file like the input file, but with Unix "newline" characters in place of Windows "return" characters)
wcword (or line, character, or byte) count
whichlocate a program file in the user's path
whoisInternet domain name and network number directory service
yaccYet Another Compiler Compiler: parser generator for LALR(1) context-free grammars

Copying Files Across a Network Using Unix sftp

Using some of the commands above, a user could send a copy of a Web page to a server using a command dialog like the one below.

Example of Copying a File Across a Network Using a Unix Shell sftp Program
Shell DisplayRemark
% cd mynewcontentdiruser changes the working directory to where the file to be uploaded resides
% pwduser requests the working directory be displayed
/Users/chris/mynewcontentdirlocal machine displays working directory
% sftp publisher@webtestserveruser instructs sftp program to connects to remote machine "webtestserver" as a user it recognizes as named "publisher"
Connecting to webtestserver...sftp program on local machine attempts to connect to remote machine
publisher@webtestserver's password: remote machine asks for password used by "publisher", user types password and presses return key
sftp> cd wwwuser changes remote working directory to the one used for hosting
sftp> put index.htmluser enters command to upload a copy of "index.html" from the local working directory to the remote working directory
Uploading index.html to /publisher/www/index.htmlsftp program acknowledges the command
index.html 100% 27KB 26.6KB/s 00:01sftp program transfers the file, indicating its progress as it does
sftp> quituser exits sftp program
%sftp program exits, returns control to shell command line

Through the dialog above, the home ("index") page on the machine "webtestserver" (a local-area network, not Internet domain name) would be updated with a copy from the local machine. The updated page could then be viewed on "webtestserver". If it appears as desired, the steps above could be repeated, replacing "publisher@webtestserver" with the machine or domain name of one's Internet Web server, and the name of a user account used on that machine. For example, Syncopated would replace "webtestserver" with one of the domain names Syncopated's server uses, such as "oddgods.com".

For related information, see An Introduction to the World-Wide Web.