640 likes | 767 Views
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. Controls the relationship between all applications and hardware.
E N D
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. • Controls the relationship between all applications and hardware. • Controls the relationship among applications.
Command Line Operating Systems • 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.
GUI 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.
So, What Does an OS Do? • Controls the INPUT, OUTPUT, and PROCESSING activities for the computer • High-quality O/S can make your computer more effective and efficient • A good OS makes the computer easier to use.
The Roles of an OS • A Traffic Cop • A Communication System • A Box of Tools • A Self-Starter
A Traffic Cop • Controls the resources of the computer, including memory, file storage, and CPU. • Multitasking (the ability for more than one application to “run” at once) is possible on new computers.
A Communications System • Helps all of the hardware components communicate with each other. • Helps applications communicate with the hardware. • Helps applications communicate with one another.
A Toolbox • Several utility programs are included with an O/S including File Management, Memory Management, and Networking Tools.
A Self-Starter • The OS takes over just after booting. • Checks to see all hardware is present. • “Hard Boot” – turning off the computer and then back on • “Soft Boot” – restarting the computer without turning it off first.
Unix • Developed by Bell Labs in 1969 • Command-Line OS • Offered File Sharing • Offered Process-Sharing
Introducing Unix Commands • Issue commands from a command prompt:/: • Unix is case sensitive! • Commands are typed in lowercase:cp (copy) is NOT the same as Cp or CP
Unix Shells • Unix has a number of shells which help the user interact with the Operating System Kernel (the main program that stays resident in memory and executes OS commands). • Some shells include the Bourne shell, Korn, Bash, TCSH and Csh.
Command Syntax • Case sensitive! All commands are lowercase • General Format:command [switches] arg1 arg2 Switch Command Arguments
Command Example • Example:ls –l *.html Switch Command Argument
Correcting Typographical Errors • DEL key removes the character to the left (in some Telnet clients, BACKSPACE will also do this) • To erase: • C-w – Erases previous word • C-u – Erases an entire line
Directory Structures • Unix paths begin with a forward slash • The initial forward slash (/) represents the root directory • Typically, only the system administer has full privileges to the root directory
Directory Paths • An absolute path begins at the root:/home/bhecker/public_html/ • A relative path indicates location relative to your present working directory:../images/
More on Directories • The command pwd will return the directory name in which you are currently working • The directory that represents your personal section of the server is called your home directory
Directory Notation • / - represents a directory • /. – represents the current directory • /.. – represents the parent directory • /~ - represents a user’s home directory
Creating Directories • Don’t use spaces in directory names. • Use _ (underscore character) or camelCasing to name directories. • Directory names are case sensitive (usually in lowercase, with camel casing).
Creating a Directory • Use the mkdir command:mkdir campingImages Name of the directory Command
File & Directory Permissions • ls –l command will show full details, including file name, owner name, modification date, size and permission sequence.
Unix Permissions • Permission sequence found at the beginning of a directory listing (first 10 characters): d rwx r-x r-x Owner’s Permissions Group’s Permissions World’s Permissions Directory
Unix Permissions • The first character represents whether the listing is a directory. If it is a directory, a “d” will appear in the first character; otherwise, you should normally see a dash (-). d rwx r-x r-x
Unix Permissions • The remaining nine characters are divided into three triplets. • The first triplet represents the owner’s permissions. • The second is the group’s permissions. • The third triplet represents the World’s permissions.
Read Permission • 1st position in a triplet: r stands for Read; grants permission to view the contents of a file or directory (Value is ‘r’ or ‘-’).
Write Permission • 2nd position in a triplet: w stands for Write; grants permission to modify a file or the contents of a directory (Value is ‘w’ or ‘-’).
Execute Permission • 3rd position in a triplet: x stands for eXecute; grants permission to run an application or open a directory (Value is ‘x’ or ‘-’).
Unix Permissions • When changing permissions, we must first decide what number will represent the permissions for a triplet. • We can do this by determining whether or not a permission is turned on or off. • If turned on, a permission gets a value of 1; if turned off, it gets a value of 0.
Unix Permissions • After deciding whether the three permissions in a triplet are on or off, we will have a binary number • We can convert the binary number to its octal equivalent
The chmod Command • Once you’ve established the octal number representing the permission for each triplet, you can then use the change mode (chmod) command to give a directory or file proper permissions
chmod Syntax & Example • Syntax:chmod permissionMask file/dir • Example:chmod 755 public_html • Typically, directories and executable files are given “755” permissions, while other files are given “644” permissions
Navigating Unix • To move from directory to directory, we use the cd command • Syntax:cd path/
Navigating Unix • To move from a child to a parent directory:cd ..
Navigating Unix • To move from a grandchild to a parent directory:cd ../..
Navigating Unix • To move from one child to a sibling directory:cd ../child2
The List Command • The list command (ls) shows the contents of a directory • We can add switches to the list command to modify what the command can do • To use more than one switch, concatenate them:ls -lt
List Command Switches • ls –l shows files in long format, including permissions • ls –a shows hidden files • ls –c shows file listings in a column format • ls –t sorts file listings by last modified date
Using Wildcards with ls • ls a* Wildcard, All files starting with 'a' • ls *a* All filenames with 'a' in them • ls *a*html All filenames with 'a' in them and ending with html • ls ????? - All 5 character filenames
Using Wildcards with ls • ls [abc]* - All filenames starting with a, b, or c • ls [a-c]* - Same as above but done as a range • ls [^a-c]* - All filenames not starting with a, b, or c
The Unix Copy Command • cp can be used to make a copy of a file, leaving the original file untouched • Syntax:cp oldfile [path/]newfile
The Unix Copy Command • To make a copy of a file while both the original and copy are in the same directory: cp index.html home.html
The Unix Copy Command • To make a copy of a file that results in the copy retaining the original’s name, but is housed in a different directory: cp index.html ../academic/
The Unix Copy Command • To make a copy of a file that results in the copy having a new name and is housed in a different directory: cp index.html ../academic/home.html
The Unix Move Command • The mv command has two purposes: • To move files from one directory to another • To rename files • Syntax:mv oldfile newpath/[newfilename]
The Unix Move Command • To move a file from one directory to another: mv index.html ../friends/