The UNIX and Linux Forums  

Go Back   The UNIX and Linux Forums > Top Forums > UNIX for Dummies Questions & Answers
Google UNIX.COM


UNIX for Dummies Questions & Answers If you're not sure where to post a UNIX or Linux question, post it here. All UNIX and Linux newbies welcome !!

More UNIX and Linux Forum Topics You Might Find Helpful
Thread Thread Starter Forum Replies Last Post
An introduction to CGI scripting with Python iBot UNIX and Linux RSS News 0 06-04-2008 01:10 AM
Introduction darshakraut Shell Programming and Scripting 3 05-05-2008 04:57 AM
introduction forum shed What's on Your Mind? 1 07-19-2007 10:57 PM
Introduction, and, needing my first foot hold on Unix Rowan UNIX for Dummies Questions & Answers 2 03-17-2006 02:25 PM

Closed Thread
 
Submit Tools LinkBack Thread Tools Search this Thread Display Modes
  #1  
Old 09-19-2000
Neo's Avatar
Neo Neo is offline
Administrator
 

Join Date: Sep 2000
Location: Asia Pacific
Posts: 4,493
Red face

<font color=brown size=+3>Short Computer Course for SCI undergraduates</font><p>
<font size=+2>Introduction to UNIX</font><p>
<font size=+2>
March 28, 2000 and March 30, 2000<br>
10:30am - 12:00noon
</font>
</center>
<h2><a name=sc>Content :</h2>
<ol>
<li><a href=#s0>Introduction to UNIX</a>
<li><a href=#s1>History of UNIX</a>
<li><a href=#s2>Implementation of UNIX</a>
<li><a href=#s3>Login, logout and changing password</a>
<li><a href=#s4>UNIX file system</a>
<li><a href=#s5>UNIX shell</a>
<li><a href=#s6>UNIX editor</a>
<li><a href=#s7>Program development in UNIX</a>
<li><a href=#s8>File transfer between PC and UNIX</a>
<li><a href=#s9>UNIX command</a>
</ol>

Course Material in <a href=http://www.sci.hkbu.edu.hk/comp-course/unix/unix.pdf>pdf</a>, <a href=http://www.sci.hkbu.edu.hk/comp-course/unix/unix.ps>
postscript</a> format are available.

<hr>
<h2><a name=s0>Introduction to UNIX</h2>

UNIX is a <font color=blue>multi-tasking</font>, <font color=blue>multi-user</font> operating system. It was originated from <b>UNICS</b> and <b>MULTICS</b>
developed in Bell Laboratory, 1969. With UNIX system, many users can login
and submit many jobs at one time. In this <font color=blue>time sharing</font>
environment, the running jobs from different users can share the resources
such as CPU speed, memory and disk space effectively.
UNIX commands are always <font color=blue>reusable</font> and <font color=blue>
compact</font>. A single UNIX command can have many functions with different
options. Along with the <font color=blue>hierarchical file systems</font> and
easily manipulate <font color=blue>file permission scheme</font>, users can
actually share their programs and thus form a suitable environment for
researches and program development. In the following paragraphs, we would
like to briefly introduce the UNIX system. <p>

<a href=#sc>Back to content</a>
<hr>
<h2><a name=s1>History of UNIX</a></h2>
<table width=90%>
<tr>
<td width=50><b>Year</b><td>
</tr>
<tr>
<td valign=top><font color=red>1969</a><td>Unics, by Ken Thompson at Bell Laboratory, runs on
Digital Equipment PDP-7
</tr>
<tr>
<td> <td>Multics, developed by Bell, MIT and General Electric
</tr>
<tr>
<td>1970<td>Unics moved to PDP-11/20
</tr>
<tr>
<td> <td>Ritchie designed and wrote first C compiler for UNIX
</tr>
<tr>
<td><font color=red>1973</a><td>Ritchie and Thompson rewrote UNIX kernel in C
</tr>
<tr>
<td>1975<td>Sixth Edition (V6) was released
</tr>
<tr>
<td valign=top>1978<td>first version of BSD was built by Bill Joy, University
of California, Berkeley (UCB).
<tr>
<td valign=top>1979<td>Seventh Edition (V7) was released and implemented on
DEC PDP-11, the Interdata 8/32, and the VAX.
</tr>
<tr>
<td> <td>first VAX version of BSD (3BSD) was released
</tr>
<tr>
<td valign=top>1980<td>Bill ported the 32V version of UNIX to DEC's VAX machine
</tr>
<tr>
<td> <td>4BSD was released
</tr>
<tr>
<td valign=top>1981<td>4.1BSD was released
</tr>
<tr>
<td valign=top><font color=red>1983</font><td>System V developed by AT&T based on V7 was first released
</tr>
<tr>
<td> <td>4.2BSD was released
</tr>
<tr>
<td valign=top>1984<td>AT&T start market UNIX hardware and software<br>
System V release 2
</tr>
<tr>
<td> <td>X was developed by MIT as part of Project Athena
</tr>
<tr>
<td>1986<td>System V release 3
</tr>
<tr>
<td>1987<td>4.3BSD was released
</tr>
<tr>
<td valign=top>1988<td>BSD Networking Release 1
</tr>
<tr>
<td> <td>X Consortium was formed. The aim is to formulate
the generally accepted standard in X
</tr>
<tr>
<td valign=top><font color=red>1989</font><td>System V release 4 (SVR4) largely written by
SUN Microsystems, included many features in BSD
</tr>
<tr>
<td valign=top>1990<td>AT&T established UNIX System Laboratory (USL) for
marketing System V and handle license and further development
</tr>
<tr>
<td valign=top>1991<td>BSD Networking Release 2, led to development of
386BSD
</tr>
<tr>
<td valign=top>1993<td>USL was acquired by Novell. <br>
Novell gave the UNIX trademark to X/Open. <br> Novell add
NetWare support to System V
</tr>
</table>

<a href=#sc>Back to Content</a>

<hr>
<h2><a name=s2>Implementation of UNIX</a></h2>

Commercial UNIX based on system V<p>
<ul>
<li>IBM's AIX
<li>Hewlett-Packard's HPUX
<li>SCO's Open Server Release 5
<li>Silicon Graphics' IRIS
<li>DEC's Digital UNIX
<li>Sun Microsystems' Solaris 2
</ul>
<p>
Commercial UNIX based on BSD<p>
<ul>
<li>SunOS 4.1.X (also called solaris 1)
<li>DEC's Ultris
<li>BSD/OS, 4.4BSD
</ul>
<p>

Free UNIX<p>
<ul>
<li>Linux, written by Linus Torvalds at University of Helsinki
in Finland.
<li>FreeBSD and NetBSD, a derivative of 4.4BSD
</ul>

<a href=#sc>Back to Content</a>
<hr>
<h2><a name=s3>Login, logout and changing of passwords</h2>

To login to UNIX system, you have to find a terminal. There are two kinds of
terminal, namely ASCII terminal and graphical terminal. In ASCII terminal,
command-line input are supported while in graphical terminal, users can input
their command by mouse and keyboard and it also support graphical display.
Once you find an ASCII terminal, a login prompt like the following can be
found. <p>

<pre>
AIX Version 4
(C) Copyrights by IBM and by others 1982, 1996
login:
</pre>

Type in your <i>username</i> and press ENTER, then a password prompt will
appear, type in the correct <i>password</i> (which will not be echoed).
A command prompt will be appeared. The prompt character differs from
different shells which will be discussed in detail in section 4.

You can change your password by typing <b>passwd</b>.<p>
<a href=#sc>Back to Content</a>

<hr>
<h2><a name=s4>UNIX file system</h2>

UNIX is a file-oriented system. In UNIX, files can be regular files,
directories or special files such as devices, sockets. A hierarchical
directory structure similar to an inverted tree can be found. A typical
UNIX system can be represented in the following,<p>

<center>
<img src="http://www.sci.hkbu.edu.hk/comp-course/unix/structure.gif">
</center>


A directory can contain sub-directories or files.<p>

<hr>
<h3>File</h3>

Files are identified by their file names, file names are up to 255 character
long. Hidden files are files with name preceding with dot (.). Each file in
UNIX has its own ownership and permissions which can be shown by listing the
directory content in long format (<b>ls -l</b>). <p>

The following show a file, stafflist, 34 bytes in size, which last modified
on 19/09/97. It is owned by a user called morris which is a staff of the
Dean's Office.<p>
<pre>
-rw-rw-r-- 1 morris dean 34 Sep 19 1997 stafflist
</pre>

The ownership can be changed by the command <b>chown</b> and <b>chgrp</b>,
<pre>
chown cwyeung stafflist
chgrp math_stf stafflist
</pre>

The first field in the above example represents the permission bits of the
files. The first column shows its kind, `d' represent a directory, `-'
represent a regular file. The rest can be divided into 3 groups showing its
user permission, group permission and other permission respectively.
Each group can have read (r), write (w) and/or executable(x) permission bits.
A `-' deny the corresponding permission of the file. <p>

Refer to the last example, stafflist is a regular file which can be updated
(rw- in user bit and group bit) by morris and dean staff. It can be read
by other users (r-- in other bit). Unfortunately, the file cannot be
executed by any body since a `-' is found in each executable bit. <p>

One can change the permission bit by using <b>chmod</b>, two methods can be
used.

<ol>
<li>use u,g,o,a flag with +, - to add or delete their permission

<pre>
chmod g-rw,o-r stafflist - deny rw permission for users in same group
- deny r permission for other users
chmod a+x stafflist - add executable permission to all users
</pre>

<li>Use 3 octal numbers calculated using 4 for `r', 2 for `w' and 1 for `x'

<pre>
chmod 700 stafflist - same effect as the above
</pre>

</ol>
Use <b>ls -l</b> to check the result.

<hr>
<h3>Path</h3>

To locate a file, one should use the <font color=red>absolute path</font> or
<font color=red>relative path</font>. <font color=red>Absolute path</font> is the path describe
starting from root (/).

<pre>
/users/staff/guest/gu01/sampledir/sample.txt
</pre>

<font color=red>Relative path</font> is the path describe from the current working directory(.) .

<pre>
sampledir/sample.txt
</pre>

refer to the same file when gu01's current working directory is
/users/staff/guest/gu01. Use <b>pwd</b> to find the current
working directory.

In path definition, current directory can be described by `.'. Parent
directory can be described by `..'. Home directory can be described by
`~' or the environmental variable '$HOME'.<p>

<a href=#sc>Back to Content</a>
<hr>
<h2><a name=s5>UNIX shell</h2>

Shell is the front end for users to interact with the UNIX kernel. Commands
can be typed in from the shell prompt to do file manipulation such as file
copying, renaming and deleting, start an text editor or compile and run a
program, etc.<p>

Different shells can be found in UNIX. The most common shells are Bourne
(sh, old and standard), Korn (ksh, the default), C (csh, C like command) shell.
These shell support both foreground and background processes, pipes, filters
and other standard features in UNIX. Besides handling UNIX commands, these
shells support the executions of batch files called shell scripts.<p>

The default shell prompt for the Bourne and Korn shells is ($) and that for
the C shell is (%). Under the shell prompt, UNIX command can be entered for
processing. <p>
A typical command lines have the following syntax,
<pre>
command [-options] arg1 arg2 arg3 ...
</pre>

where arg1, arg2, arg3, etc. are argument input based on
the nature of the commands. <p>

Built-in command are interpreted directly. If the command contains a path,
the shell will only search for the command in the path. If no path is
declared, the shell will find in the search path (PATH) for the command.<p>

<hr>
<h2><a name=s6>UNIX editor</h2>

The most frequently used program in UNIX is an editor. A good choice of
editor to suit your need is crucial to most program developer. Common
editor in UNIX are,<p>
<pre>
<a href=http://www.cs.umr.edu/unixinfo/general/packages/viguide.html>vi</a> (standard UNIX full-screen editor)
<a href=http://www.emacs.org>emacs</a> (macro reach)
<a href=http://pine.cac.washington.edu/>pico</a> (command driven full-screen editor)
<a href=http://dv.go.dlr.de:8081/pdinfo_dv/joe.html>joe</a> (word star like editor)
</pre>

Since all UNIX systems have installed vi editor, UNIX experts learn
vi. Emacs editor are reached in macro for formatting text.
Therefore, it is good for program developer to write code in different
programming languages. Pico and joe editor support full
screen and cursor editing. They are good for novices. <p>

X-window editors are editors which support window and mouse editing.
Xemacs and AsWedit are two examples. <p>

<a href=#sc>Back to Content</a>
<hr>

<h2><a name=s7>Program development in UNIX</a></h2>

<h3>Programming Language support</h3>
Since UNIX is primarily written in C, therefore, almost all UNIX
system has built-in C compiler for program development.<p>
Public domain software are often packaged in C source codes and
therefore, C compiler is essential to all UNIX platform.<p>

All other programming language, such as Fortran, C++ and Pascal,
have implemented in UNIX. Compilation of such program need
specfic compilers. The command for compilation are as follows,<p>

<h3>Compiling program</h3>

<h4>C programs</h4>
<pre>
cc [-o a.exe] a.c
</pre>
Without -o option, the executable file will be named as a.out.

<h4>Fortran programs</h4>
<pre>
f77 [-o t1] a.f
</pre>
the name of the executable can be set freely.

<h4>C++ programs</h4>
<pre>
CC [-o t1] a.C
</pre>

<h3>Running program in background</h3>
Program with long running time should be placed in background.
UNIX allowed background running of programs with nohup command.
Run the program preceeding with nohup and end with an &.
<pre>
nohup abc &
</pre>
<a href=#sc>Back to Content</a>

<h2><a name=s8>File Transfer between PC and UNIX</a></h2>
File transfer between PC and UNIX can be done by starting ftp
program from PC.<p>
After running ftp in windows 95, a ftp prompt will appear<p>
<pre>
ftp>
</pre>
First, connect to a remote host by typing open <i>hostname</i>,
<pre>
<font color=black>ftp></font> open net1.hkbu.edu.hk
</pre>
then, type in your username and password.<p>
If success, the ftp prompt will be appeared.<p>
The following command will be useful to search and locate your
file and subdirectory.<p>
<pre>
ls <i>list directory content</i>
ls *.c <i>show all C files</i>
cd sci <i>change directory to sci in remote host</i>
lcd a: <i>change directory to the floppy drive in local PC</i>
</pre>
the following commands help file transfer<p>
<pre>
bin <i>prepare to transfer in binary mode</i>
ascii <i>prepare to transfer in text mode</i>
prompt <i>toggle prompt for file transfer</i>
get abc.txt <i>download abc.txt from remote host to local PC</i>
mget *.txt <i>download all files end with .txt to local PC</i>
put mail.txt <i>upload mail.txt from local PC to remote host</i>
mput *.mat <i>upload all files end with .mat to remote host</i>
</pre>

<a href=#sc>content</a>


<h2><a name=s9>UNIX command</h2>

The most popular and useful commands are discussed in detail in the
following.<p>

<h3>Command for help</h3>

To learn a command from scratch, the UNIX systems provide a detail and
self-contained man page for each of the UNIX command.
<pre>
man ls
</pre>

which list out the man page of the command 'ls'.

<pre>
man -k file
</pre>

will list out all commands related to the keyword `file'.

The following commands are categorized by its function and sorted in alphabetical order for easy reference. However, the detail description of the command line are skipped. You should refer to their man page for usage.<p>

<h3>Commands for working with files and directories</h3>

<center>
<table border=1>
<tr><th>cat<td>cat f1 f2 <td> type the content of file f1 and f2 </tr>
<tr><th>cd<td>cd HOME <td> change to home directory </tr>
<tr><th>cp<td>cp f1 f2 dir1 <td> copy file f1 and f2 into directory dir1 </tr>
<tr><th>ls<td>ls -la <td> list all files (including hidden) in long format</tr>
<tr><th>mkdir<td> mkdir abc <td>make new directory </tr>
<tr><th>more<td> more a1 a2 <td>list out files a1, a2 in pages</tr>
<tr><th>mv<td> mv f1 dir1 <td>move/rename file f1 into dir1</tr>
<tr><th>pwd<td>pwd <td>display current working directory</tr>
<tr><th>rm<td>rm -rf lab1 <td>delete all files in lab1 without confirmation</tr>
<tr><th>rmdir<td>rmdir lab1 <td>delete an empty directory</tr>
</table>
</center>

<h3>Commands for working in the shell</h3>
<center>
<table border=1>
<tr><th>cal <td> cal 11 1998 <td> display the calendar of November, 1998</tr>
<tr><th>compress <td> compress file1 <td> form a compress file file1.Z</tr>
<tr><th>date <td> date<td> display the current time and date</tr>
<tr><th>df <td> df <td> list information of space used in the system</tr>
<tr><th>diff <td> diff f1 f2 <td> compare text between two files</tr>
<tr><th>du <td> du <td> summarized disk usage of your home directory</tr>
<tr><th>find <td> find ./ -name .cshrc -print <td> search and print the file .cshrc</tr>
<tr><th>grep <td> grep student * <td> search all files with the word student</tr>
<tr><th>history <td> history 50 <td> find the last 50 commands stored in the shell</tr>
<tr><th>hostname <td> hostname <td> display the name of the current machine</tr>
<tr><th>kill <td> kill -9 2036 <td> terminate the process with pid 2036 </tr>
<tr><th>logout <td> logout <td> leave the systems</tr>
<tr><th>lpr <td> lpr -h f1 f2 <td> print f1, f2 without header page</tr>
<tr><th>mail <td> mail morris < /tmp/soft.list <td> send /tmp/soft.list to morris </tr>
<tr><th>man <td> man tar <td> displaying the manual page on-line</tr>
<tr><th>nohup <td> nohup runmatlab a <td> run matlab (a.m) without hang up after logout</tr>
<tr><th>passwd <td> passwd <td> change password</tr>
<tr><th>ps <td> ps -ef <td> find out all process run in the systems</tr>
<tr><th>sort <td> sort -r -n studno <td> sort studno in reverse numerical order</tr>
<tr><th>tar <td> tar cvf abc.tar abc <td> create archive file</tr>
<tr><th>uncompress <td> uncompress file1.Z <td> the opposite of compress</tr>
<tr><th>wc <td> wc -l f1 <td> count the number of lines in f1</tr>
<tr><th>who <td> who <td> who is on-line </tr>
<tr><th>whoami <td> whoami <td> identify yourself </tr>
<tr><th>write <td> write morris <td> sends message to morris on the same host </tr>
</table>
</center>
<hr>
Google The UNIX and Linux Forums
Forum Sponsor
Closed Thread

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes




All times are GMT -7. The time now is 09:59 PM.


Powered by: vBulletin, Copyright ©2000 - 2006, Jelsoft Enterprises Limited.
The UNIX and Linux Forums Content Copyright ©1993-2008. All Rights Reserved.Ad Management by RedTyger Visit The Complex Event Processing Blog

Content Relevant URLs by vBSEO 3.2.0