1 / 24

Title Slide

The UNIX Operating System (2) By Ralph B. Bisland, Jr. CSS 404/504. Title Slide. The creator of a file/directory controls what other users can do with the file/directory. There are three types of permissions: Read permission ( r) - User can "read" (or access) your file

helia
Download Presentation

Title Slide

An Image/Link below is provided (as is) to download presentation Download Policy: Content on the Website is provided to you AS IS for your information and personal use and may not be sold / licensed / shared on other websites without getting consent from its author. Content is provided to you AS IS for your information and personal use only. Download presentation by click this link. While downloading, if for some reason you are not able to download a presentation, the publisher may have deleted the file from their server. During download, if you can't get a presentation, the file might be deleted by the publisher.

E N D

Presentation Transcript


  1. The UNIX Operating System (2) By Ralph B. Bisland, Jr. CSS 404/504 Title Slide

  2. The creator of a file/directory controls what other users can do with the file/directory. There are three types of permissions: Read permission ( r) - User can "read" (or access) your file Write permission (w) - User can "write" (or change) your file Execute permission (x) - User can "execute" (for programs only) your file Note: There are both file and directory permissions. File Permissions

  3. There are three categories of users that can access your files: Other (o) - all system users Group (g) - All users within your group User (u) - You only The default file permissions are for all three groups to have all three permissions To display the permissions of a file, use the ls -l (list long) command. Categories Of Users

  4. If you do not set your file/directory permissions correctly, others will not be able to access your web pages. There are two methods of setting permissions on a file: Unmask: (umask) There is a system default (all permissions to all users) for file permissions that you may adjust. Change mode: (chmod) Used to change the mode for individual files Setting File Permissions

  5. File permissions are generally specified using a binary digits as on/off switches: Binary 0 = off, binary 1 = on First binary digit = Read permission Second binary digit = Write permission Third binary = Execute permission File Permission Settings

  6. Use an octal digit to indicate the privilege for each category: Bin Oct Permission --- --- ------------------------------------ 000 = 0 = No permission 001 = 1 = Execute permission only 010 = 2 = Write permission only 011 = 3 = Write and execute permissions only 100 = 4 = Read permission only 101 = 5 = Read and execute permissions only 110 = 6 = Read and write permissions only 111 = 7 = Read, write, and execute permissions File permissions are generally specified with three digits: owner, group, world 700 666 644 Using Octal Digits

  7. The system default for permissions is 777 (all permissions to all categories) This can be altered (and is) via the unmask (umask) command orca% umask 077 This command unmasks or turns off the default permissions for group and world. Using umask

  8. Text editors create files with permissions = 600 This can be altered with the umask command orca% umask 333 orca% umask 222 The umask command affects all files created when the mask is in effect. Any editing changes to the file do not affect the permissions. To see the current umask, enter umask without any parameters. orca% umask Using umask (ctd)

  9. Once a file has been created, permissions can be altered with the change mode (chmod) command: Format: chmod permission-mask file-name(s) Remember this command turns onpermissions, it does not turn them offlike umask. Example: orca% chmod 644 my-file.dat Changing Permissions On A File

  10. Another way to specify permissions: Specify which privilege (rwx) you wish to add or delete with a + or - orca% chmod +w my-file.dat orca% chmod -x+r my-file.dat Can even alter permissions to a file by preceding privilege with u, g, or o. orca% chmod o+r my-file.dat Changing File Permissions (ctd)

  11. If a file exists in another user’s account and you wish to access it, you can copy it to your directory. This is only allowed if the user gives you the directory and file privileges of accessing it. Assume that the other user's account is abc and the subdirectory is xyz and you wish to copy the file called foo.dat into your directory. orca% cp ~abc/xyz/foo.dat bar.dat orca% cp ~abc/xyz/foo.dat . Accessing Files From Other Users

  12. Most UNIX commands have on-line help. To get to the help, use the manual (as in reference manual) command (man) followed by the command name you wish help on. Example: orca% man ls Online Help

  13. Text files can be searched for strings. To search a file for a string use the global regular expression print command Commonly known as grep Format: grep [parameter(s)] string filename Example: orca% grep ralph my-file.dat Each line containing the string "ralph" is displayed Searching Files

  14. If the string contains a blank, the string must be enclosed in double quotes. orca grep "ralph bisland" my-file.dat Parameters: i = Ignore case v = display lines that do not match the string Searching Files (ctd)

  15. Pipe: A connection between two processes that passes the output of the first process as input to the second process. Very useful feature. The symbol used for piping is the vertical bar (|). Format: <command1> | <command2> Example: orca% ls | more Piping

  16. Redirection: A shell construct for causing a program to take its standard input from a specified file or to send its standard output to a specified file. The symbols used for redirecting are >, >> and < Use the < symbol to redirect input files (use the file specified as input to the process) Redirecting Input & Output

  17. Format: process < filename orca% cat < my-file.dat Use the > symbol to direct the output of a process into a file Format: process > filename orca% ls -l > outfile.dat The >> symbol appends the output on to a currently existing file. Redirecting Input & Output

  18. The locate command helps you find where a file is located. Format: locate string where string is a subset of a file name Warning: This command searches the entire computer for the file string. This may lead to lots of output. Searching For A File

  19. Examples • orca% locate rbb • /orca/faculty/bisland/public_html/rbb.save • /orca/faculty/jrodgers/public_html/rbb.cgi • /orca/faculty/jrodgers/public_html/rbb.dat • You may want to consider piping the • output to the grep utility • orca% locate rbb | grep bisland

  20. UNIX has a file containing approximately 45,000 words stored in its spelling dictionary. orca% wc /usr/dict/linux.words 45402 45402 409048 /usr/dict/linux.words You may search this dictionary for the spelling of words. To search the dictionary use the look command. Format: look string orca% look pneu Spelling Of A Word

  21. To find out the login names of the users currently using the system, use the who command. Format: who orca% who Who Is Currently Using The System

  22. Aliasing Any command can be aliased by using the alias command. Use aliasing to make commands shorter or easier to remember for you. Format: alias <string>=<thing to alias> Note: The = is used in the Korn shell only. Examples: $ alias q=logout $ alias lo=logout $ alias lls='ls -al' Note the use of quotes if there are embedded spaces in the alias string

  23. Calendar cal <month-number> <year> Ex. cal 9 1752 cal <year> Ex. cal 1995 Leave leave Ex: leave leave <absolute time> Ex: leave 1030 leave <+relative time> Ex: leave +30 Calculator bc Ex: bc {then enter expressions} Note: all calculations are done in integer Nifty Neat UNIX Utilities

  24. Who Am I? orca% whoami Hostname: orca% hostname Disk quota: orca% quota Date: orca% date Random Sayings: orca% fortune orca % fortune –o More Nifty Neat UNIX Utilities

More Related