just enough unix

27
1 Just Enough UNIX

Upload: kalil

Post on 02-Feb-2016

68 views

Category:

Documents


1 download

DESCRIPTION

Just Enough UNIX. UNIX Operating System. Generally operates from a command-line. After logging on, met with command-prompt: grid x : In labs, you will be using X-windows on X-terminals. UNIX commands. All UNIX commands are actually programs. - PowerPoint PPT Presentation

TRANSCRIPT

Page 1: Just Enough UNIX

1

Just Enough UNIX

Page 2: Just Enough UNIX

UNIX Operating System

• Generally operates from a command-line.

• After logging on, met with command-prompt:– gridx:

• In labs, you will be using X-windows on X-terminals.

Page 3: Just Enough UNIX

UNIX commands

• All UNIX commands are actually programs.

• You “run” a program by typing its name at the command prompt.

• Generally, the output of a program goes to the screen and if the program requires any input, it gets it from the keyboard.

• These are called:– stdout & stdin

Page 4: Just Enough UNIX

File navigation and manipulation

• UNIX uses a hierarchical file structure.

• Very similar to Windows and Macintosh.

• Directories not folders.

• Move about with typed commands rather than mouse-clicks.

Page 5: Just Enough UNIX

ls• list

• Displays the names of the files in the current directory.

• Flags:– -a: shows all the files, including hidden ones– -F: puts a / after directories, an * after

executables, and an @ after links– -l: displays a long listing of files

Page 6: Just Enough UNIX

pwd

• print working directory

• Displays the full path of the current directory you are in.– e.g.: /home/CS/cs153/801/skea1234/programs

Page 7: Just Enough UNIX

cd• change directory

• Changes your working directory to whatever you specify. – cd [name of directory]

• Without any directory (just cd) you will be taken to your home directory.– cd

• With .. you will be taken to the parent of the working directory– cd ..

Page 8: Just Enough UNIX

cp

• copy

• Copies the contents of one file to another. – cp [file to copy] [new file name]

• Copies a file from one directory to the working directory– cp [path of file to copy] .

Page 9: Just Enough UNIX

mv

• move

• Better name could be the rename command.

• Changes the name of one file to another. – mv [old file name] [new file name]

• Note that the [new file name] could be a directory, which will effectively move the file to the new directory keeping the original name.

Page 10: Just Enough UNIX

rm

• remove

• Deletes the specified file or files.

• This is destructive!

• They are gone!

• They cannot be retrieved!!!– rm [file name]

• Note: this does not generally work with directories.

Page 11: Just Enough UNIX

mkdir

• make directory

• This creates a directory.– mkdir [new directory name]

• Does not automatically change to the new directory after it is created.

Page 12: Just Enough UNIX

rmdir

• remove directory

• This deletes a directory (as opposed to the rm command above).

• The directory must be empty otherwise you will get an error.

Page 13: Just Enough UNIX

man

• UNIX reference manual

• Gives usage, options, examples for UNIX commands and applications

• man [command name]– $: man pwd

– $: man man

• Option –k searches the manual pages by keyword– $: man –k “working directory”

Page 14: Just Enough UNIX

Access privileges

• All UNIX files have privileges associated with them.

• These privileges determine who can access the file.

• These privileges determine how people can access the file.

Page 15: Just Enough UNIX

Viewing access privileges

• Use the ls -l command.

drwx------ 2 jimd 8192 Jul 12 12:26 nsmail/-rw-r--r-- 1 jimd 945 Mar 15 16:01 old.cshrc-rwxrwxrwx 1 jimd 168 Jan 13 1998 file.exe-rw-rw-rw- 1 nobody 382 Nov 18 1998 old.profile-rw------- 1 jimd 652 Jul 12 12:16 old.xsessiondrwx------ 2 jimd 8192 Jun 23 13:21 thesis/-rw-r--r-- 1 jimd 1186776 Jul 13 15:07 win32tutorial.ps

Page 16: Just Enough UNIX

Types of file access - rwx

• Read — person can look at the contents of the file.

• Write — person can change the file.

• eXecute — person can execute the file (applies only to directories and program).

Page 17: Just Enough UNIX

Types of users - ugo

• User/owner -- the person who owns/created the file.

• Group — UNIX allows for the creation of groups.

• Others/world -- everyone else in the world that has access to that computer.

Page 18: Just Enough UNIX

To change permissions

• chmod — changes the access mode of a file.

• Two methods exist– symbolic– absolute

Page 19: Just Enough UNIX

chmod - absolute

• Absolute - you specify a numeric equivalent for a set of permissions.

• You specify all permissions at once.

Page 20: Just Enough UNIX

chmod - absolute

• chmod [xxx] [file]

• Where each x is some number from 0 - 7.

• Each number specifies a level of privileges for a specific group.

Page 21: Just Enough UNIX

chmod - absolute

• e.g.,

chmod 644 index.html

User permission

Group permission

World permission

Page 22: Just Enough UNIX

chmod - absolute

• Permissions:– Read = 4– Write = 2– Execute = 1

• Set permissions by adding the values of all the permissions you wish to set.

Page 23: Just Enough UNIX

chmod - examples

• To give yourself read & write permission and no permission to anyone else:– chmod 600 foobar.txt

• To give yourself read & write permission and everyone else read permission only:– chmod 644 index.html

• To give yourself full access to a directory, and everyone else read & execute permission only: – chmod 755 images

Page 24: Just Enough UNIX

chmod - symbolic

• symbolic - you specify only the changes to be made to the permissions

• You specify changes for only one user-type.

Page 25: Just Enough UNIX

chmod - symbolic

• chmod [user-type + or – rwx]

• Where + signifies adding permission and - signifies removing permission

• rwx - include only the permissions to by updated.

Page 26: Just Enough UNIX

chmod - symbolic

• e.g.,• e.g.,

chmod g+rw index.html

User-type

Change to be made

Permissions changed

Page 27: Just Enough UNIX

chmod - examples

• To add read & write permissions for yourself:– chmod u+rw foobar.txt

• To remove write and execute permissions for everyone who is not user or group:– chmod o-wx images

• To add write permissions for the group: – chmod g+w index.html