Introduction to UNIX donna Bair-Mundy. What is UNIX? Applications OperatingSystem Hardware.

36
Introduction to Introduction to UNIX UNIX donna Bair-Mundy

Transcript of Introduction to UNIX donna Bair-Mundy. What is UNIX? Applications OperatingSystem Hardware.

Introduction to UNIXIntroduction to UNIX

donna Bair-Mundy

What is UNIX?

ApplicationsApplications

OperatingOperatingSystemSystem

HardwareHardware

Operating system functions

Keeps track of types and

locations of hardware

Intermediary between applications and hardware

Maintains directory of files

Manages how data is stored

Allocates memory to programs

User instructions to operating system

When to run a program

Creating and naming directories

Copying files between directories or onto disks

Setting access permissions

Unix operating system% lsmyfile.txtyourfile.txt%

Command-line interface

Utilities—programs to list files, tell who is on the system, what processes are running, etc.

Editors—use to create HTML files for Web portals

Unix environment - now

hosthostterminalsterminals

terminalsterminals

Hi!Hi!Ho!

Ho!

Unix environment - then

hosthostterminalsterminals

1subdirectory

18subdirectory

24subdirectory

UHUNIX file structure

binsubdirectory

Rootdirectory

homesubdirectory

usrsubdirectory

johndHome directory

donnabHome directory

nahlHome directory

Basic UHUNIX commandspwdpwd print working directory

tells you where you are in the file hierarchy

lsls listlists files and subdirectories

cdcd change directoryMoves you up or down in the file hierarchy

chmodchmod change modeAssigns access rights to files and directories

More UHUNIX commandsmanman manual

man + command provides access to electronic help files

cpcp copycp sourcefile destinationfile copies the source file to a file with the destination file name

rmrm remove fileDeletes a file

mkdirmkdir make directoryCreates a new directory

Where am I: pwd (print working directory)

% pwd

/home/18/donnab%

What files and directories do I have: ls (list files)

aardvark.txtmailmyfile.txtpublic_htmlwhatsup.doc%

% ls

The "all files" option: ls -a

.

..

.addressbook

.cshrc

.inbox

.login

.logout

.pinerc

% ls.signature.ssh2aardvark.txtmailmyfile.txtpublic_htmlwhatsup.doc

%

-a

The "long' option: ls -l

% ls-rw------- 1 donnab 47616 May 8 11:59 aardvark.txtdrwx------ 2 donnab 3584 Apr 10 2002 mail-rw------- 1 donnab 45927 May 8 11:59 myfile.txtdrwxr-xr-x 5 donnab 1024 Mar 20 13:51 public_html%

-l

ls -la

Changing my working directory: cd (change directory)

cd change directory% cd public_html

% pwd

/home/18/donnab/public_html

% cd fun/images

% pwd/home/18/donnab/public_html/fun/images

%

Changing my working directory: cd

cd change directory% cd public_html

fun

donnab

public_html mail

images html files

Changing my working directory: cd

cd change directory% cd fun/images

fun

donnab

public_html mail

images html files

Changing to a higher-level subdirectory: cd ..

cd ..%pwd

/home/18/donnab/public_html/fun/images

%

/home/18/donnab/public_html/fun/

%

/home/18/donnab/public_html/

% cd /bincd /bin

cd ..%pwd

Note space preceding dots

Changing my working directory: cd

cd change directory% cd ..

fun

donnab

public_html mail

images html files

Changing access rights to a file or directory: chmod (change mode, part 1)

% ls -l-rwx------ 1 donnab 47616 May 8 11:59 myfile.txt

drwxr-xr-x 5 donnab 1024 Mar 20 13:51 public_html

%- r w x r w x - - - - - -

ownerowner groupgroup publicpublic

Changing access rights to a file or directory: chmod (change mode, part 2)

% ls -l-rwx------ 1 donnab 47616 May 8 11:59 myfile.txt

drwxr-xr-x 5 donnab 1024 Mar 20 13:51 public_html

%

r w x r - x r - xr w x r - x r - xowner group public

chmod 755 myfile.txt% ls -l-rwxr-xr-x 1 donnab 47616 May 8 11:59 myfile.txt

drwxr-xr-x 5 donnab 1024 Mar 20 13:51 public_html

Binary numbers (part 1)

Base 10

110100

1 2 7

Base 2

124

1 1 181632

1 1 1164

Binary numbers (part 2)

Base 10

110

0 0

Base 2

124

0 0 08

0 1 1 111 1234 0567890 10 011 010 0 011 0

Binary numbers (part 3)

7

Base 2

124

81632

64

12

4

1 1 1

7- 4

3- 2

1+ + = 7

Decimal

Base two

Binary numbers (part 4)

6

Base 2

124

81632

64

12

4

1 1 0

6- 4

2- 2

04 + 2 + 0 = 6

Binary numbers (part 5)

5Base 2

12

4

0 1 1 1 0 0 1 0 1

SelectionA

SelectionB

SelectionC

Base 10

Oops…

5Base 2

124

0 1 1

2 + 1 = 3

Tryagain

Oops…

5Base 2

124

1 0 0

4 + 0 + 0

Tryagain

= 4

Congratulations!

5

Base 2124

1 0 1

4 + 0 + 1 = 5

Yes!Yes!

Changing access rights to a file or directory: chmod (change mode, part 3)

%

-rwxr-xr-x 1 donnab 47616 May 8 11:59 myfile.txtdrwxr-xr-x 5 donnab 1024 Mar 20 13:51 public_html

%

rwx r-x r-x

owner group public

chmod 755 myfile.txt

111 101 1017 5 5

%

Getting help: man command

manUser Commands

chmod(1)NAME chmod - change the permissions

mode of a fileDESCRIPTION chmod changes or assigns the mode

of a file. The mode of a file specifies its permissions and other attributes. …

chmod

%

Getting help: man -k

manaccess access (3f) - return access mode (r,w,x) or

existence of a filecggglm cggglm (3p) - solve a general Gauss-Markov

linear model (GLM) problem chmod chmod (3f) - change mode of a filedggglm dggglm (3p) - solve a general Gauss-Markov

linear model (GLM) problem f77_ieee_environment f77_ieee_environment (3f) -

mode, status, and signal handling for IEEE arithmeticfegetprec fesetprec (3m) - control floating point

rounding precision modes

-k mode | more

%

Making back-ups: cp (copy)

cp

% lsmyfile.txtmyfilebk.txt

my file.txtmy_file.txt

myfile.txt myfilebk.txt

%

Deleting a file: rm (remove)

rmrm

% lslsmyfile.txtmyfilebk.txt

% lsmyfile.txt

myfilebk.txtmyfilebk.txtrm: remove myfilebk.txt (yes/no)? y

%

Creating a new subdirectory: mkdir (make directory)

mkdirmkdir

% ls -lls -ldrwx------ images-rwx------ myfile.txt

% chmod 755 imageschmod 755 images

imagesimages

%

Logging out of the system: logout

logoutlogout

You are now logged out from the SunTue Jul 8 11:20:18 HST 2003