An Introduction to the Unix Operating System
by John R. Carlsen
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 command | functional description | similar DOS/Windows command |
bash | GNU Bourne-Again SHell: a command interpreter (like csh, ksh, sh, tcsh) | cmd, command, start |
cat | concatenate files and display their contents | type |
cd | change working directory to a specified directory (a shell "builtin" command) | cd, chdir |
chmod | change file modes (read, write, execute permissions) | attrib |
chown | change file owner and group | cacls |
clear | clear the terminal screen | cls |
cp | copy files | copy, diskcopy, replace, xcopy |
cron | daemon to schedule command execution | at |
csh | a shell (command interpreter) with C-like syntax (like bash, ksh, sh, tcsh) | cmd, command, start |
date | display or set date and time | date, time |
diff | find differences between two files | comp, diskcomp, fc |
echo | write arguments to the standard output | echo |
exit | exit the shell (end session, a shell "builtin" command) | exit |
find | find file(s) matching specified name | dir |
fsck | file system consistency check and interactive repair | chkdsk |
ftp | file 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 † |
get | copy a specified file from the remote machine to the local machine | |
help | display commands and other helpful information |
put | copy a specified file from the local machine to the remote machine |
quit | exit and end the program |
grep | GNU 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 |
help | print a list of commands (see also info, man) | help |
info | display information for specified command or program (see also help, man) | help |
ksh | Korn SHell: a command interpreter (like bash, csh, sh, tcsh) | cmd, command, start |
less | display file in screen-sized pages (like more) | more |
ln | make links | subst |
lpr | print files | print |
ls | list directory contents | dir, tree, vol |
man | display 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 |
mkdir | create the directory specified | md, mkdir |
more | display file in screen-sized pages (like less) | more |
mv | move files | move, ren or rename |
ping | test network hosts and connections by sending echo-request packets | ping † |
pwd | print the name of the working directory | cd |
rm | remove the file(s) specified from directory | del or erase ‡ |
rmdir | remove the subdirectory specified from directory | rd, rmdir |
sh | shell (command interpreter; like bash, csh, ksh, tcsh) | cmd, command, start |
sort | sort lines of text files | sort |
stty | set the options for a terminal device interface | mode |
tcsh | C shell (command interpreter) with file name completion and command line editing (like bash, csh, ksh, sh) | cmd, command, start |
telnet | Telnet protocol remote login program (when possible, use ssh instead) | telnet † |
vi | visual text editor | edit †† or edlin |
(control-d) | scroll down a page | |
(control-u) | scroll up a page |
d | delete line(s) |
i | enter insert mode |
(escape) | exit insert mode |
x | delete character(s) |
G | go to end of file |
: | enter command |
help | help; may be followed by a command to get help on (as in ":help ZZ") |
q | exit and end the program |
w | write (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 command | functional description |
apachectl | Apache h.t.t.p. (Web) server control interface (see also httpd) |
cc | C and C++ compiler (see also gcc, make) |
curl | transfer a specified uniform resource locator (u.r.l.; now called universal resource identifier, or u.r.i.) |
cvs | Concurrent Versions System: control and share versions of files (especially useful in collaborative development environments) |
finger | lookup information about specified user |
gcc | GNU C and C++ compiler (see also cc, make) |
hexdump | displays ("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) |
httpd | Apache hypertext transfer protocol (Web) server (executes as a "daemon", returning control back to the shell while running; see also apachectl) |
kill | terminate or signal a process |
make | GNU make utility to build groups of program files (see also cc, gcc) |
od | displays ("dumps") each byte in a file using its ASCII, decimal, hexadecimal and/or octal representations (deprecated by hexdump; see also strings) |
ps | show status of processes |
sftp | secure file transfer program (like ftp; see its commands in the table above) |
ssh | secure shell remote login program (like telnet; see its commands in the table above) |
strings | find the printable strings in a binary file (see also hexdump, od) |
sudo | execute a command as another user (use sparingly) |
top | display and update sorted information about processes |
tr | translate 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) |
wc | word (or line, character, or byte) count |
which | locate a program file in the user's path |
whois | Internet domain name and network number directory service |
yacc | Yet 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 Display |
% cd mynewcontentdir |
% pwd |
/Users/chris/mynewcontentdir |
% sftp publisher@webtestserver |
Connecting to webtestserver... |
publisher@webtestserver's password: |
sftp> cd www |
sftp> put index.html |
Uploading index.html to /publisher/www/index.html |
index.html 100% 27KB 26.6KB/s 00:01 |
sftp> quit |
% |
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.
|