16.05.2015 Views

Working with the Unix OS

Working with the Unix OS

Working with the Unix OS

SHOW MORE
SHOW LESS

You also want an ePaper? Increase the reach of your titles

YUMPU automatically turns print PDFs into web optimized ePapers that Google loves.

Introduction to <strong>Unix</strong><br />

! Special Device Files<br />

Each physical device hard disc, line printer, terminals, memory is assigned to a "special file".<br />

! Directory Structure<br />

(root)<br />

/<br />

/ -------------------- / ------------------------- \ ------------------------- \<br />

bin etc home/users dev<br />

| | / --------------- \ |<br />

chmod passwd john mark tty0l<br />

/ ---- \ |<br />

mail src text<br />

The inverted tree structured<br />

directory hierarchy<br />

! User Directory<br />

Within <strong>the</strong> users "home" directory, a user may have o<strong>the</strong>r subdirectories that he/she own and control.<br />

! Filenames<br />

A sequence of 1 to 14 (or 256) characters consisting of letters, digits and o<strong>the</strong>r special characters. When a<br />

filename contains an initial period, it is hidden.<br />

The following characters should never be used in filenames because <strong>the</strong>y have special meaning to <strong>the</strong> shell: ?,<br />

*, [, ], ", ' and -.<br />

! Pathnames<br />

A pathname is a sequence of directory names followed by a simple filename, each separated by a slash "/". If<br />

<strong>the</strong> pathname begins <strong>with</strong> a slash it specifies a file that can be found by search from "root", o<strong>the</strong>rwise by search<br />

from user's current directory (found by <strong>the</strong> command "pwd" -path of working directory). All files and<br />

directories except root have parent directories.<br />

. shorthand name of current directory, e.g. ./filename<br />

.. shorthand name of parent directory, e.g. cd..<br />

! Special Characters<br />

* match zero or more characters, e.g. ls chap*<br />

[] matches any character inside brackets, e.g. ls chap[1-9]*<br />

? matches any single character, e.g. ls chap?l<br />

! Notational Convention<br />

^d hold down control key and press <strong>the</strong> d key<br />

ESC <strong>the</strong> escape key<br />

! Some Commands<br />

ls display directory contents<br />

lp file print files<br />

cat file display file contents commands are executable programs<br />

! Command Syntax<br />

cmd [option] [arguments] [filename]<br />

options are always preceded by a dash "-".<br />

e.g. ls -1<br />

grep "string of text" filename<br />

! Command Line<br />

The command line can be edited <strong>with</strong> ^h (erase/backspace) and ^u (kill). You cc also edit <strong>the</strong> command line<br />

<strong>with</strong> <strong>the</strong> Korn shell using vi commands (activated by ESC key).<br />

12

Hooray! Your file is uploaded and ready to be published.

Saved successfully!

Ooh no, something went wrong!