tools of web development 1: module c: using unix

64
CSCI N241: Fundamentals of Web Design Copyright ©2004 Department of Computer & Information Science Tools of Web Tools of Web Development 1: Development 1: Module C: Using Unix Module C: Using Unix

Upload: robyn

Post on 16-Jan-2016

21 views

Category:

Documents


0 download

DESCRIPTION

Tools of Web Development 1: Module C: Using Unix. Goals. Understand the roles of an operating system. Understand the difference between command-line and GUI. Understand some basic Unix commands. What is an Operating System?. It is software. - PowerPoint PPT Presentation

TRANSCRIPT

Page 1: Tools of Web Development 1: Module C: Using Unix

CSCI N241: Fundamentals of Web Design

Copyright ©2004 Department of Computer & Information Science

Tools of Web Development Tools of Web Development 1:1:Module C: Using UnixModule C: Using Unix

Page 2: Tools of Web Development 1: Module C: Using Unix

N241: Fundamentals of Web DevelopmentN241: Fundamentals of Web DevelopmentCopyright Copyright ©2004 ©2004 Department of Computer & Information ScienceDepartment of Computer & Information Science

GoalsGoals

• Understand the roles of an Understand the roles of an operating system.operating system.

• Understand the difference Understand the difference between command-line and GUI.between command-line and GUI.

• Understand some basic Unix Understand some basic Unix commands.commands.

Page 3: Tools of Web Development 1: Module C: Using Unix

N241: Fundamentals of Web DevelopmentN241: Fundamentals of Web DevelopmentCopyright Copyright ©2004 ©2004 Department of Computer & Information ScienceDepartment of Computer & Information Science

What is an Operating What is an Operating System?System?

• It is software.It is software.• Controls the relationship Controls the relationship

between all applications and between all applications and hardware.hardware.

• Controls the relationship among Controls the relationship among applications.applications.

Page 4: Tools of Web Development 1: Module C: Using Unix

N241: Fundamentals of Web DevelopmentN241: Fundamentals of Web DevelopmentCopyright Copyright ©2004 ©2004 Department of Computer & Information ScienceDepartment of Computer & Information Science

Command Line Operating Command Line Operating SystemsSystems

• Use letters with symbols, such as C:\>.

• Instructions must be typed. • High rate of error – typos!• Some examples of command line

operating systems include DOS and Unix.

Page 5: Tools of Web Development 1: Module C: Using Unix

N241: Fundamentals of Web DevelopmentN241: Fundamentals of Web DevelopmentCopyright Copyright ©2004 ©2004 Department of Computer & Information ScienceDepartment of Computer & Information Science

GUI Operating SystemsGUI Operating Systems

• GUI - Graphic User Interface• Include pictures with descriptive

words (icons)• Much easier to move the pointer with

the mouse and click on a picture, than to remember commands.

• Examples of GUI operating systems include Windows and MAC OS.

Page 6: Tools of Web Development 1: Module C: Using Unix

N241: Fundamentals of Web DevelopmentN241: Fundamentals of Web DevelopmentCopyright Copyright ©2004 ©2004 Department of Computer & Information ScienceDepartment of Computer & Information Science

So, What Does an OS Do?So, What Does an OS Do?

• Controls the INPUT, OUTPUT, and Controls the INPUT, OUTPUT, and PROCESSING activities for the PROCESSING activities for the computercomputer

• High-quality O/S can make your High-quality O/S can make your computer more effective and computer more effective and efficient efficient

• A good OS makes the computer A good OS makes the computer easier to use.easier to use.

Page 7: Tools of Web Development 1: Module C: Using Unix

N241: Fundamentals of Web DevelopmentN241: Fundamentals of Web DevelopmentCopyright Copyright ©2004 ©2004 Department of Computer & Information ScienceDepartment of Computer & Information Science

The Roles of an OSThe Roles of an OS

• A Traffic CopA Traffic Cop• A Communication SystemA Communication System• A Box of ToolsA Box of Tools• A Self-StarterA Self-Starter

Page 8: Tools of Web Development 1: Module C: Using Unix

N241: Fundamentals of Web DevelopmentN241: Fundamentals of Web DevelopmentCopyright Copyright ©2004 ©2004 Department of Computer & Information ScienceDepartment of Computer & Information Science

A Traffic CopA Traffic Cop

• Controls the resources of the Controls the resources of the computer, including memory, file computer, including memory, file storage, and CPU. storage, and CPU.

• Multitasking (the ability for more Multitasking (the ability for more than one application to “run” at than one application to “run” at once) is possible on new once) is possible on new computers. computers.

Page 9: Tools of Web Development 1: Module C: Using Unix

N241: Fundamentals of Web DevelopmentN241: Fundamentals of Web DevelopmentCopyright Copyright ©2004 ©2004 Department of Computer & Information ScienceDepartment of Computer & Information Science

A Communications SystemA Communications System

• Helps all of the hardware Helps all of the hardware components communicate with components communicate with each other. each other.

• Helps applications communicate Helps applications communicate with the hardware.with the hardware.

• Helps applications communicate Helps applications communicate with one another.with one another.

Page 10: Tools of Web Development 1: Module C: Using Unix

N241: Fundamentals of Web DevelopmentN241: Fundamentals of Web DevelopmentCopyright Copyright ©2004 ©2004 Department of Computer & Information ScienceDepartment of Computer & Information Science

A ToolboxA Toolbox

• Several utility programs are Several utility programs are included with an O/S including included with an O/S including File Management, Memory File Management, Memory Management, and Networking Management, and Networking Tools.Tools.

Page 11: Tools of Web Development 1: Module C: Using Unix

N241: Fundamentals of Web DevelopmentN241: Fundamentals of Web DevelopmentCopyright Copyright ©2004 ©2004 Department of Computer & Information ScienceDepartment of Computer & Information Science

A Self-StarterA Self-Starter

• The OS takes over just after booting.The OS takes over just after booting.• Checks to see all hardware is present.Checks to see all hardware is present.• ““Hard Boot” – turning off the Hard Boot” – turning off the

computer and then back oncomputer and then back on• ““Soft Boot” – restarting the computer Soft Boot” – restarting the computer

without turning it off first.without turning it off first.

Page 12: Tools of Web Development 1: Module C: Using Unix

N241: Fundamentals of Web DevelopmentN241: Fundamentals of Web DevelopmentCopyright Copyright ©2004 ©2004 Department of Computer & Information ScienceDepartment of Computer & Information Science

UnixUnix

• Developed by Bell Labs in 1969Developed by Bell Labs in 1969• Command-Line OSCommand-Line OS• Offered File Sharing Offered File Sharing • Offered Process-SharingOffered Process-Sharing

Page 13: Tools of Web Development 1: Module C: Using Unix

N241: Fundamentals of Web DevelopmentN241: Fundamentals of Web DevelopmentCopyright Copyright ©2004 ©2004 Department of Computer & Information ScienceDepartment of Computer & Information Science

Introducing Unix CommandsIntroducing Unix Commands

• Issue commands from a command Issue commands from a command prompt:prompt:phoenix{jstudent}/:phoenix{jstudent}/:

• Unix is case sensitive!Unix is case sensitive!• Commands are typed in lowercase:Commands are typed in lowercase:cpcp (copy) is NOT the same as (copy) is NOT the same as CpCp or or CPCP

Page 14: Tools of Web Development 1: Module C: Using Unix

N241: Fundamentals of Web DevelopmentN241: Fundamentals of Web DevelopmentCopyright Copyright ©2004 ©2004 Department of Computer & Information ScienceDepartment of Computer & Information Science

Unix ShellsUnix Shells

• Unix has a number of shells which help Unix has a number of shells which help the user interact with the Operating the user interact with the Operating System Kernel (the main program that System Kernel (the main program that stays resident in memory and executes stays resident in memory and executes OS commands).OS commands).

• Some shells include the Bourne shell, Some shells include the Bourne shell, Korn, Bash, TCSH and Csh (“C-schell”, Korn, Bash, TCSH and Csh (“C-schell”, used on the CS Phoenix Server).used on the CS Phoenix Server).

Page 15: Tools of Web Development 1: Module C: Using Unix

N241: Fundamentals of Web DevelopmentN241: Fundamentals of Web DevelopmentCopyright Copyright ©2004 ©2004 Department of Computer & Information ScienceDepartment of Computer & Information Science

Command SyntaxCommand Syntax

• Case sensitive! All commands Case sensitive! All commands are lowercaseare lowercase

• General Format:General Format:command [switches] arg1 arg2command [switches] arg1 arg2

Command SwitchArguments

Page 16: Tools of Web Development 1: Module C: Using Unix

N241: Fundamentals of Web DevelopmentN241: Fundamentals of Web DevelopmentCopyright Copyright ©2004 ©2004 Department of Computer & Information ScienceDepartment of Computer & Information Science

Command ExampleCommand Example

• Example:Example:

ls –l *.htmlls –l *.html

Command

Switch

Argument

Page 17: Tools of Web Development 1: Module C: Using Unix

N241: Fundamentals of Web DevelopmentN241: Fundamentals of Web DevelopmentCopyright Copyright ©2004 ©2004 Department of Computer & Information ScienceDepartment of Computer & Information Science

Correcting Typographical Correcting Typographical ErrorsErrors

• DEL key removes the character DEL key removes the character to the left (in some Telnet to the left (in some Telnet clients, BACKSPACE will also do clients, BACKSPACE will also do this)this)

• To erase:To erase:– C-w – Erases previous wordC-w – Erases previous word– C-u – Erases an entire lineC-u – Erases an entire line

Page 18: Tools of Web Development 1: Module C: Using Unix

N241: Fundamentals of Web DevelopmentN241: Fundamentals of Web DevelopmentCopyright Copyright ©2004 ©2004 Department of Computer & Information ScienceDepartment of Computer & Information Science

Directory StructuresDirectory Structures

• Unix paths begin with a forward Unix paths begin with a forward slashslash

• The initial forward slash (/) The initial forward slash (/) represents the root directoryrepresents the root directory

• Typically, only the system Typically, only the system administer has full privileges to administer has full privileges to the root directorythe root directory

Page 19: Tools of Web Development 1: Module C: Using Unix

N241: Fundamentals of Web DevelopmentN241: Fundamentals of Web DevelopmentCopyright Copyright ©2004 ©2004 Department of Computer & Information ScienceDepartment of Computer & Information Science

Directory PathsDirectory Paths

• An absolute path begins at the An absolute path begins at the root:root:/home/jstudent/public_html//home/jstudent/public_html/

• A relative path indicates location A relative path indicates location relativerelative to your present working to your present working directory:directory:../images/../images/

Page 20: Tools of Web Development 1: Module C: Using Unix

N241: Fundamentals of Web DevelopmentN241: Fundamentals of Web DevelopmentCopyright Copyright ©2004 ©2004 Department of Computer & Information ScienceDepartment of Computer & Information Science

More on DirectoriesMore on Directories

• The command The command pwdpwd will return the will return the directory name in which you are directory name in which you are currently workingcurrently working

• The directory that represents The directory that represents your personal section of the your personal section of the server is called your home server is called your home directorydirectory

Page 21: Tools of Web Development 1: Module C: Using Unix

N241: Fundamentals of Web DevelopmentN241: Fundamentals of Web DevelopmentCopyright Copyright ©2004 ©2004 Department of Computer & Information ScienceDepartment of Computer & Information Science

Directory NotationDirectory Notation

• / / - represents a directory- represents a directory• /. /. – represents the current directory– represents the current directory• /../.. – represents the parent directory – represents the parent directory• /~ /~ - represents a user’s home - represents a user’s home

directorydirectory

Page 22: Tools of Web Development 1: Module C: Using Unix

N241: Fundamentals of Web DevelopmentN241: Fundamentals of Web DevelopmentCopyright Copyright ©2004 ©2004 Department of Computer & Information ScienceDepartment of Computer & Information Science

Creating DirectoriesCreating Directories

• Don’t use spaces in directory Don’t use spaces in directory names.names.

• Use _ (underscore character) or Use _ (underscore character) or camelCasing to name directories.camelCasing to name directories.

• Directory names are case Directory names are case sensitive (usually in lowercase, sensitive (usually in lowercase, with camel casing).with camel casing).

Page 23: Tools of Web Development 1: Module C: Using Unix

N241: Fundamentals of Web DevelopmentN241: Fundamentals of Web DevelopmentCopyright Copyright ©2004 ©2004 Department of Computer & Information ScienceDepartment of Computer & Information Science

Creating a DirectoryCreating a Directory

• Use the mkdir command:Use the mkdir command:mkdir campingImagesmkdir campingImages

Command

Name of the directory

Page 24: Tools of Web Development 1: Module C: Using Unix

N241: Fundamentals of Web DevelopmentN241: Fundamentals of Web DevelopmentCopyright Copyright ©2004 ©2004 Department of Computer & Information ScienceDepartment of Computer & Information Science

File & Directory PermissionsFile & Directory Permissions

• ls –lls –l command will show full command will show full details, including file name, details, including file name, owner name, modification date, owner name, modification date, size and permission sequence.size and permission sequence.

Page 25: Tools of Web Development 1: Module C: Using Unix

N241: Fundamentals of Web DevelopmentN241: Fundamentals of Web DevelopmentCopyright Copyright ©2004 ©2004 Department of Computer & Information ScienceDepartment of Computer & Information Science

Unix PermissionsUnix Permissions

• Permission sequence found at Permission sequence found at the beginning of a directory the beginning of a directory listing (first 10 characters):listing (first 10 characters):

dd rwxrwx r-xr-x r-xr-x

Dir

ecto

ry?

Dir

ecto

ry?

Ow

ner

’s

Ow

ner

’s

Per

mis

sio

ns

Per

mis

sio

ns

Gro

up

’s

Gro

up

’s

Per

mis

sio

ns

Per

mis

sio

ns

Wo

rld

’s

Wo

rld

’s

Per

mis

sio

ns

Per

mis

sio

ns

Page 26: Tools of Web Development 1: Module C: Using Unix

N241: Fundamentals of Web DevelopmentN241: Fundamentals of Web DevelopmentCopyright Copyright ©2004 ©2004 Department of Computer & Information ScienceDepartment of Computer & Information Science

Unix PermissionsUnix Permissions

• The first character represents The first character represents whether the listing is a directory. If whether the listing is a directory. If it is a directory, a “d” will appear it is a directory, a “d” will appear in the first character; otherwise, in the first character; otherwise, you should normally see a dash (-).you should normally see a dash (-).

dd rwx rwx r-xr-x r-xr-x

Page 27: Tools of Web Development 1: Module C: Using Unix

N241: Fundamentals of Web DevelopmentN241: Fundamentals of Web DevelopmentCopyright Copyright ©2004 ©2004 Department of Computer & Information ScienceDepartment of Computer & Information Science

Unix PermissionsUnix Permissions

• The remaining nine characters are The remaining nine characters are divided into three triplets.divided into three triplets.

• The first triplet represents the owner’s The first triplet represents the owner’s permissions.permissions.

• The second is the group’s The second is the group’s permissions.permissions.

• The third triplet represents the The third triplet represents the World’s permissions.World’s permissions.

Page 28: Tools of Web Development 1: Module C: Using Unix

N241: Fundamentals of Web DevelopmentN241: Fundamentals of Web DevelopmentCopyright Copyright ©2004 ©2004 Department of Computer & Information ScienceDepartment of Computer & Information Science

Read PermissionRead Permission

• 11stst position in a triplet: position in a triplet: r r stands stands for for RRead; grants permission to ead; grants permission to view the contents of a file or view the contents of a file or directory (Value is ‘r’ or ‘-’).directory (Value is ‘r’ or ‘-’).

Page 29: Tools of Web Development 1: Module C: Using Unix

N241: Fundamentals of Web DevelopmentN241: Fundamentals of Web DevelopmentCopyright Copyright ©2004 ©2004 Department of Computer & Information ScienceDepartment of Computer & Information Science

Write PermissionWrite Permission

• 22ndnd position in a triplet: position in a triplet: w w stands stands for for WWrite; grants permission to rite; grants permission to modify a file or the contents of a modify a file or the contents of a directory (Value is ‘w’ or ‘-’).directory (Value is ‘w’ or ‘-’).

Page 30: Tools of Web Development 1: Module C: Using Unix

N241: Fundamentals of Web DevelopmentN241: Fundamentals of Web DevelopmentCopyright Copyright ©2004 ©2004 Department of Computer & Information ScienceDepartment of Computer & Information Science

Execute PermissionExecute Permission

• 33rd rd position in a triplet: position in a triplet: xx stands stands for efor eXXecute; grants permission to ecute; grants permission to run an application or open a run an application or open a directory (Value is ‘x’ or ‘-’).directory (Value is ‘x’ or ‘-’).

Page 31: Tools of Web Development 1: Module C: Using Unix

N241: Fundamentals of Web DevelopmentN241: Fundamentals of Web DevelopmentCopyright Copyright ©2004 ©2004 Department of Computer & Information ScienceDepartment of Computer & Information Science

Unix PermissionsUnix Permissions

• When changing permissions, we must When changing permissions, we must first decide what number will represent first decide what number will represent the permissions for a triplet.the permissions for a triplet.

• We can do this by determining We can do this by determining whether or not a permission is turned whether or not a permission is turned on or off.on or off.

• If turned on, a permission gets a value If turned on, a permission gets a value of 1; if turned off, it gets a value of 0.of 1; if turned off, it gets a value of 0.

Page 32: Tools of Web Development 1: Module C: Using Unix

N241: Fundamentals of Web DevelopmentN241: Fundamentals of Web DevelopmentCopyright Copyright ©2004 ©2004 Department of Computer & Information ScienceDepartment of Computer & Information Science

Unix PermissionsUnix Permissions

• After deciding whether the three After deciding whether the three permissions in a triplet are on or permissions in a triplet are on or off, we will have a binary numberoff, we will have a binary number

• We can convert the binary We can convert the binary number to its octal equivalentnumber to its octal equivalent

Page 33: Tools of Web Development 1: Module C: Using Unix

N241: Fundamentals of Web DevelopmentN241: Fundamentals of Web DevelopmentCopyright Copyright ©2004 ©2004 Department of Computer & Information ScienceDepartment of Computer & Information Science

Unix PermissionsUnix Permissions

PermissionPermissionss

BinaryBinary OctalOctal

- - -- - - 0 0 00 0 0 00

- - x- - x 0 0 10 0 1 11

- w -- w - 0 1 00 1 0 22

- w x- w x 0 1 10 1 1 33

Page 34: Tools of Web Development 1: Module C: Using Unix

N241: Fundamentals of Web DevelopmentN241: Fundamentals of Web DevelopmentCopyright Copyright ©2004 ©2004 Department of Computer & Information ScienceDepartment of Computer & Information Science

Unix PermissionsUnix Permissions

PermissionPermissionss

BinaryBinary OctalOctal

r - -r - - 1 0 01 0 0 44

r – xr – x 1 0 11 0 1 55

r w -r w - 1 1 01 1 0 66

r w xr w x 1 1 11 1 1 77

Page 35: Tools of Web Development 1: Module C: Using Unix

N241: Fundamentals of Web DevelopmentN241: Fundamentals of Web DevelopmentCopyright Copyright ©2004 ©2004 Department of Computer & Information ScienceDepartment of Computer & Information Science

The chmod CommandThe chmod Command

• Once you’ve established the octal Once you’ve established the octal number representing the permission number representing the permission for each triplet, you can then use for each triplet, you can then use the change mode (the change mode (chmodchmod) command ) command to give a directory or file proper to give a directory or file proper permissionspermissions

Page 36: Tools of Web Development 1: Module C: Using Unix

N241: Fundamentals of Web DevelopmentN241: Fundamentals of Web DevelopmentCopyright Copyright ©2004 ©2004 Department of Computer & Information ScienceDepartment of Computer & Information Science

chmod Syntax & Examplechmod Syntax & Example

• Syntax:Syntax:chmod permissionMask file/dirchmod permissionMask file/dir

• Example:Example:chmod 755 public_htmlchmod 755 public_html

• Typically, directories and Typically, directories and executable files are given “755” executable files are given “755” permissions, while other files are permissions, while other files are given “644” permissionsgiven “644” permissions

Page 37: Tools of Web Development 1: Module C: Using Unix

N241: Fundamentals of Web DevelopmentN241: Fundamentals of Web DevelopmentCopyright Copyright ©2004 ©2004 Department of Computer & Information ScienceDepartment of Computer & Information Science

Navigating UnixNavigating Unix

• To move from directory to To move from directory to directory, we use the directory, we use the cdcd commandcommand

• Syntax:Syntax:cd path/cd path/

Page 38: Tools of Web Development 1: Module C: Using Unix

N241: Fundamentals of Web DevelopmentN241: Fundamentals of Web DevelopmentCopyright Copyright ©2004 ©2004 Department of Computer & Information ScienceDepartment of Computer & Information Science

Navigating UnixNavigating Unix

•To move from a child to a To move from a child to a parent directory:parent directory:cd ..cd ..

PARENTPARENT

CHILDCHILD

Page 39: Tools of Web Development 1: Module C: Using Unix

N241: Fundamentals of Web DevelopmentN241: Fundamentals of Web DevelopmentCopyright Copyright ©2004 ©2004 Department of Computer & Information ScienceDepartment of Computer & Information Science

Navigating UnixNavigating Unix

•To move from a grandchild to To move from a grandchild to a parent directory:a parent directory:cd ../..cd ../..

PARENTPARENT

CHILDCHILD

GRANDCHILDGRANDCHILD

Page 40: Tools of Web Development 1: Module C: Using Unix

N241: Fundamentals of Web DevelopmentN241: Fundamentals of Web DevelopmentCopyright Copyright ©2004 ©2004 Department of Computer & Information ScienceDepartment of Computer & Information Science

Navigating UnixNavigating Unix

•To move from one child to a To move from one child to a sibling directory:sibling directory:cd ../child2cd ../child2

PARENTPARENT

CHILD1CHILD1 CHILD2CHILD2

Page 41: Tools of Web Development 1: Module C: Using Unix

N241: Fundamentals of Web DevelopmentN241: Fundamentals of Web DevelopmentCopyright Copyright ©2004 ©2004 Department of Computer & Information ScienceDepartment of Computer & Information Science

The List CommandThe List Command

• The list command (The list command (lsls) shows the ) shows the contents of a directorycontents of a directory

• We can add switches to the list We can add switches to the list command to modify what the command to modify what the command can docommand can do

• To use more than one switch, To use more than one switch, concatenate them:concatenate them:ls -ltls -lt

Page 42: Tools of Web Development 1: Module C: Using Unix

N241: Fundamentals of Web DevelopmentN241: Fundamentals of Web DevelopmentCopyright Copyright ©2004 ©2004 Department of Computer & Information ScienceDepartment of Computer & Information Science

List Command SwitchesList Command Switches

• ls –lls –l shows files in long format, shows files in long format, including permissions including permissions

• ls –als –a shows hidden files shows hidden files• ls –cls –c shows file listings in a shows file listings in a

column formatcolumn format• ls –tls –t sorts file listings by last sorts file listings by last

modified datemodified date

Page 43: Tools of Web Development 1: Module C: Using Unix

N241: Fundamentals of Web DevelopmentN241: Fundamentals of Web DevelopmentCopyright Copyright ©2004 ©2004 Department of Computer & Information ScienceDepartment of Computer & Information Science

Using Wildcards with Using Wildcards with lsls

• ls a*ls a* Wildcard, All files starting Wildcard, All files starting with 'a' with 'a'

• ls *a*ls *a* All filenames with 'a' in All filenames with 'a' in them them

• ls *a*htmlls *a*html All filenames with 'a' in All filenames with 'a' in them and ending with htmlthem and ending with html

• ls ?????ls ????? - All 5 character filenames - All 5 character filenames

Page 44: Tools of Web Development 1: Module C: Using Unix

N241: Fundamentals of Web DevelopmentN241: Fundamentals of Web DevelopmentCopyright Copyright ©2004 ©2004 Department of Computer & Information ScienceDepartment of Computer & Information Science

Using Wildcards with Using Wildcards with lsls

• ls [abc]*ls [abc]* - All filenames starting - All filenames starting with a, b, or c with a, b, or c

• ls [a-c]*ls [a-c]* - Same as above but - Same as above but done as a range done as a range

• ls [^a-c]*ls [^a-c]* - All filenames not - All filenames not starting with a, b, or c starting with a, b, or c

Page 45: Tools of Web Development 1: Module C: Using Unix

N241: Fundamentals of Web DevelopmentN241: Fundamentals of Web DevelopmentCopyright Copyright ©2004 ©2004 Department of Computer & Information ScienceDepartment of Computer & Information Science

The Unix Copy CommandThe Unix Copy Command

• cp cp can be used to make a copy can be used to make a copy of a file, leaving the original file of a file, leaving the original file untoucheduntouched

• Syntax:Syntax:cp oldfile [path/]newfilecp oldfile [path/]newfile

Page 46: Tools of Web Development 1: Module C: Using Unix

N241: Fundamentals of Web DevelopmentN241: Fundamentals of Web DevelopmentCopyright Copyright ©2004 ©2004 Department of Computer & Information ScienceDepartment of Computer & Information Science

The Unix Copy CommandThe Unix Copy Command

• To make a copy of a file while To make a copy of a file while both the original and copy are in both the original and copy are in the the samesame directory: directory:cp index.html home.htmlcp index.html home.html

Page 47: Tools of Web Development 1: Module C: Using Unix

N241: Fundamentals of Web DevelopmentN241: Fundamentals of Web DevelopmentCopyright Copyright ©2004 ©2004 Department of Computer & Information ScienceDepartment of Computer & Information Science

The Unix Copy CommandThe Unix Copy Command

• To make a copy of a file that To make a copy of a file that results in the copy retaining the results in the copy retaining the original’s nameoriginal’s name, but is housed in , but is housed in a different directory:a different directory:cp index.html ../academic/cp index.html ../academic/

Page 48: Tools of Web Development 1: Module C: Using Unix

N241: Fundamentals of Web DevelopmentN241: Fundamentals of Web DevelopmentCopyright Copyright ©2004 ©2004 Department of Computer & Information ScienceDepartment of Computer & Information Science

The Unix Copy CommandThe Unix Copy Command

• To make a copy of a file that To make a copy of a file that results in the copy having a results in the copy having a new new namename and is housed in a and is housed in a different directory:different directory:cp index.html cp index.html ../academic/home.html../academic/home.html

Page 49: Tools of Web Development 1: Module C: Using Unix

N241: Fundamentals of Web DevelopmentN241: Fundamentals of Web DevelopmentCopyright Copyright ©2004 ©2004 Department of Computer & Information ScienceDepartment of Computer & Information Science

The Unix Move CommandThe Unix Move Command

• The The mvmv command has two purposes: command has two purposes:– To move files from one directory to To move files from one directory to

anotheranother– To rename filesTo rename files

• Syntax:Syntax:mv oldfile mv oldfile newpath/[newfilename]newpath/[newfilename]

Page 50: Tools of Web Development 1: Module C: Using Unix

N241: Fundamentals of Web DevelopmentN241: Fundamentals of Web DevelopmentCopyright Copyright ©2004 ©2004 Department of Computer & Information ScienceDepartment of Computer & Information Science

The Unix Move CommandThe Unix Move Command

• To move a file from one directory To move a file from one directory to another:to another:mv index.html ../friends/mv index.html ../friends/

Page 51: Tools of Web Development 1: Module C: Using Unix

N241: Fundamentals of Web DevelopmentN241: Fundamentals of Web DevelopmentCopyright Copyright ©2004 ©2004 Department of Computer & Information ScienceDepartment of Computer & Information Science

The Unix Move CommandThe Unix Move Command

• To rename a file (stays in the To rename a file (stays in the same directory):same directory):mv index.html home.htmlmv index.html home.html

Page 52: Tools of Web Development 1: Module C: Using Unix

N241: Fundamentals of Web DevelopmentN241: Fundamentals of Web DevelopmentCopyright Copyright ©2004 ©2004 Department of Computer & Information ScienceDepartment of Computer & Information Science

The Unix Move CommandThe Unix Move Command

• To move a file To move a file andand rename it at rename it at the same time:the same time: mv index.html mv index.html ../friends/home.html../friends/home.html

Page 53: Tools of Web Development 1: Module C: Using Unix

N241: Fundamentals of Web DevelopmentN241: Fundamentals of Web DevelopmentCopyright Copyright ©2004 ©2004 Department of Computer & Information ScienceDepartment of Computer & Information Science

Deleting FilesDeleting Files

• Use Use rmrm to delete files to delete files• Syntax:Syntax:rm filenamerm filename

Page 54: Tools of Web Development 1: Module C: Using Unix

N241: Fundamentals of Web DevelopmentN241: Fundamentals of Web DevelopmentCopyright Copyright ©2004 ©2004 Department of Computer & Information ScienceDepartment of Computer & Information Science

Deleting FilesDeleting Files

• To delete a single file:To delete a single file:rm index.htmlrm index.html(answer Y to confirm delete)(answer Y to confirm delete)

• To delete multiple files using a To delete multiple files using a wildcard:wildcard:rm *.htmlrm *.html(answer Y to confirm delete for each (answer Y to confirm delete for each file)file)

Page 55: Tools of Web Development 1: Module C: Using Unix

N241: Fundamentals of Web DevelopmentN241: Fundamentals of Web DevelopmentCopyright Copyright ©2004 ©2004 Department of Computer & Information ScienceDepartment of Computer & Information Science

Deleting DirectoriesDeleting Directories

• Use Use rmdirrmdir to delete directories to delete directories• DIRECTORY MUST BE EMPTYDIRECTORY MUST BE EMPTY!!!!!!!!• Syntax:Syntax:rmdir directorynamermdir directoryname

• To delete a directory:To delete a directory:rmdir images/rmdir images/(answer Y to confirm delete)(answer Y to confirm delete)

Page 56: Tools of Web Development 1: Module C: Using Unix

N241: Fundamentals of Web DevelopmentN241: Fundamentals of Web DevelopmentCopyright Copyright ©2004 ©2004 Department of Computer & Information ScienceDepartment of Computer & Information Science

Other Useful CommandsOther Useful Commands

• passwd passwd – Password utility that – Password utility that allows users to update their allows users to update their passwordspasswords

• exit exit – End your Unix session – End your Unix session (you can also use (you can also use byebye on on Phoenix)Phoenix)

Page 57: Tools of Web Development 1: Module C: Using Unix

N241: Fundamentals of Web DevelopmentN241: Fundamentals of Web DevelopmentCopyright Copyright ©2004 ©2004 Department of Computer & Information ScienceDepartment of Computer & Information Science

Other Useful CommandsOther Useful Commands

• clear clear – Gives you a blank – Gives you a blank screen (you can also use screen (you can also use cls cls on on Phoenix)Phoenix)

• who who – Lists users currently – Lists users currently logged in to the serverlogged in to the server

Page 58: Tools of Web Development 1: Module C: Using Unix

N241: Fundamentals of Web DevelopmentN241: Fundamentals of Web DevelopmentCopyright Copyright ©2004 ©2004 Department of Computer & Information ScienceDepartment of Computer & Information Science

Other Useful CommandsOther Useful Commands

• finger username finger username – Retrieves – Retrieves information about a userinformation about a user

• cal cal – Displays a calendar of the – Displays a calendar of the current monthcurrent month

• date date – Displays the current – Displays the current system datesystem date

Page 59: Tools of Web Development 1: Module C: Using Unix

N241: Fundamentals of Web DevelopmentN241: Fundamentals of Web DevelopmentCopyright Copyright ©2004 ©2004 Department of Computer & Information ScienceDepartment of Computer & Information Science

Other Useful CommandsOther Useful Commands

• !! !! – (pronounced “bang bang”) – (pronounced “bang bang”) repeats the last commandrepeats the last command

• ![a..z]![a..z] – Repeats the last – Repeats the last command beginning with command beginning with selected letter (a-z)selected letter (a-z)

Page 60: Tools of Web Development 1: Module C: Using Unix

N241: Fundamentals of Web DevelopmentN241: Fundamentals of Web DevelopmentCopyright Copyright ©2004 ©2004 Department of Computer & Information ScienceDepartment of Computer & Information Science

Other Useful CommandsOther Useful Commands

• |more|more – Added to commands – Added to commands which display lists to force page which display lists to force page stops (Ex: stops (Ex: ls –lt |morels –lt |more))

• C-z C-z – Temporarily stop a process– Temporarily stop a process

Page 61: Tools of Web Development 1: Module C: Using Unix

N241: Fundamentals of Web DevelopmentN241: Fundamentals of Web DevelopmentCopyright Copyright ©2004 ©2004 Department of Computer & Information ScienceDepartment of Computer & Information Science

Other Useful CommandsOther Useful Commands

• fg fg – Bring a process to the – Bring a process to the foreground after it has been foreground after it has been stoppedstopped

• vacation vacation – Turn on the autoreply – Turn on the autoreply for e-mailfor e-mail

• pine pine – Launch the Pine E-mail – Launch the Pine E-mail clientclient

• emacs emacs – Start the Emacs editor– Start the Emacs editor

Page 62: Tools of Web Development 1: Module C: Using Unix

N241: Fundamentals of Web DevelopmentN241: Fundamentals of Web DevelopmentCopyright Copyright ©2004 ©2004 Department of Computer & Information ScienceDepartment of Computer & Information Science

Online ManualOnline Manual

• Eight SectionsEight Sections– CommandsCommands– System callsSystem calls– Library functionsLibrary functions– Devices and device Devices and device

driversdrivers

– File formatsFile formats– GamesGames– MiscellaneousMiscellaneous– System System

maintenancemaintenance

Page 63: Tools of Web Development 1: Module C: Using Unix

N241: Fundamentals of Web DevelopmentN241: Fundamentals of Web DevelopmentCopyright Copyright ©2004 ©2004 Department of Computer & Information ScienceDepartment of Computer & Information Science

Using Using manman

• man commandman command• To lookup help on the To lookup help on the cpcp command: command:man cpman cp

• To lookup help on the To lookup help on the lsls command: command:man lsman ls

• C-cC-c exits the manual. exits the manual.

Page 64: Tools of Web Development 1: Module C: Using Unix

N241: Fundamentals of Web DevelopmentN241: Fundamentals of Web DevelopmentCopyright Copyright ©2004 ©2004 Department of Computer & Information ScienceDepartment of Computer & Information Science

Questions?Questions?