1 / 23

Essential System Administration, 3rd Edition

University Of Palestine. Essential System Administration, 3rd Edition. Chapter 2 The Unix Way. Ch2. University Of Palestine. Almost every system manager has to deal with user accounts, system startup and shutdown, peripheral devices, system performance, security .

Download Presentation

Essential System Administration, 3rd Edition

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. University Of Palestine Essential System Administration, 3rd Edition Chapter 2 The Unix Way

  2. Ch2 University Of Palestine • Almost every system manager has to deal with user accounts, system startup and shutdown, peripheral devices, system performance, security. • The list could go on and on. While the commands and procedures you use in each of these areas vary widely across different computer systems • A system administrator is generally called on to be the resident guru. The Unix Way

  3. Ch2 University Of Palestine The Unix Way (Cont.) • If you're responsible for a multiuser system, you'll need to be able to answer user questions, come up with solutions to problems that are more than just band-aids, and more. • Even if you're responsible only for your own workstation, you'll find yourself dealing with aspects of the computer's operation that most ordinary users can simply ignore. • In either case, you need to know a fair amount about how Unix really works, both to manage your system.

  4. Ch2 University Of Palestine 2.1 Files • Files are central to Unix in ways that are not true for some other operating systems. • Commands are executable files, usually stored in standard locations in the directory tree. • Accordingly, the Unix view of files and its standard directory structure are among the first things a new administrator needs to know about. • Like all modern operating systems, Unix has a hierarchical (tree-structured) directory organization, know collectively as the file system.

  5. Ch2 University Of Palestine 2.1 Files (Cont.) • The base of this tree is a directory called the root directory. • The root directory has the special name / (the forward slash character). • Access to files is organized around file ownership and protection.

  6. Ch2 University Of Palestine 2.1 Files (Cont.) • 2.1.1 File Ownership: • Unix file ownership is a bit more complex than it is under some other operating systems. • Typically, The owner of such a file is the user who created it and has control over it. • On Unix systems, files have two owners: • User owner. • and a group owner. • What is unusual about Unix file ownership is that these two owners are decoupled.

  7. Ch2 University Of Palestine 2.1 Files (Cont.) • 2.1.1 File Ownership (Cont.): • The user owner of a file does need not even need to be a member of the group that owns it. • In such a case, when file access is specified for a file's group owner, it applies to members of that group and not to other members of its user owner's group. • Flexibility in owner ship .

  8. Ch2 University Of Palestine 2.1 Files (Cont.) 2.1.1 File Ownership (Cont.): To consider a more concrete example, suppose user chavez, who is in the chem group, needs access to some files usually used by the physics group. There are several ways you can give her access: Make copies of the files for her. If they change, however, her copies will need to be updated. Make the files world-readable. Make chavez a member of the physics group. This is the best alternative and also the simplest. It involves changing only the group configuration file. The file permissions don't need to be modified at all.

  9. Ch2 University Of Palestine 2.1 Files (Cont.) • 2.1.1.1 Displaying file ownership • To display a file's user and group ownership, use the long form of the ls command by including the -l option (-lg under Solaris): • $ ls -l • -rwxr-xr-x 1 root system 120 Mar 12 09:32 bronze • -r--r--r-- 1 chavez chem 84 Feb 28 21:43 gold • -rw-rw-r-- 1 chavez physics 12842 Oct 24 12:04 platinum • -rw------- 1 harvey physics 512 Jan 2 16:10 silver • Columns three and four display the user and group owners for the listed files.

  10. Ch2 University Of Palestine 2.1 Files (Cont.) • 2.1.1.2 Who owns new files? • When a new file is created, its user owner is the user who creates it. • On most Unix systems, the group owner is the current group of the user who creates the file. • However, on BSD-style systems, the group owner is the same as the group owner of the directory in which the file is created.

  11. Ch2 University Of Palestine 2.1 Files (Cont.) • 2.1.1.3 Changing file ownership • If you need to change the ownership of a file, use the chown and chgrp commands. • The chown command changes the user owner of one or more files: • # chownnew-owner files • where new-owner is the username (or user ID) of the new owner for the specified files. • For example, to change the owner of the file brass to user harvey, execute this chown command: • # chownharvey brass

  12. Ch2 University Of Palestine 2.1 Files (Cont.) • 2.1.1.3 Changing file ownership (Cont.) • On most systems, only the superuser can run the chown command. • If you need to change the ownership of an entire directory tree, you can use the -R option (R for recursive). • For example, the following command will change the user owner to harvey for the directory /home/iago/new/tgh and all files and subdirectories contained underneath it: • # chown -R harvey /home/iago/new/tgh

  13. Ch2 University Of Palestine 2.1 Files (Cont.) • 2.1.1.3 Changing file ownership (Cont.) • You can also change both the user and group owner in a single operation, using this format: • # chown new-owner:new-group files • For example, to change the user owner to chavezand the group owner to chem for chavez's home directory and all the files underneath it, use this command: • # chown -R chavez:chem /home/chavez • If you just want to change a file's group ownership, use the chgrp command: • $ chgrp new-group files

  14. Ch2 University Of Palestine 2.1 Files (Cont.) • 2.1.2 File Protection : • Once ownership is set up properly, the next natural issue to consider is how to protect files from unwanted access (or the reverse: how to allow access to those people who need it). • The protection on a file is referred to as its file mode on Unix systems. • File modes are set with the chmod command; we'll look at chmod after discussing the file protection concepts it relies on.

  15. Ch2 University Of Palestine 2.1 Files (Cont.) • 2.1.2.1 Types of file and directory access: • Unix supports three types of file access: read, write, and execute, designated by the letters r, w, and x, respectively. • The following table shows the meanings of those access types:

  16. Ch2 University Of Palestine 2.1 Files (Cont.) • we can summarize the different options for protecting directories as shown in the following table:

  17. Ch2 University Of Palestine 2.1 Files (Cont.) • 2.1.2.2 Access classes : • Unix defines three basic classes of file access for which protection may be specified separately: • User access (u)Access granted to the owner of the file. • Group access (g)Access granted to members of the same group as the group owner of the file (but does not apply to the owner himself, even if he is a member of this group). • Other access (o) Access granted to all other normal users. • Unix file protection specifies the access types available to members of each of the three access classes for the file or directory.

  18. Ch2 University Of Palestine 2.1 Files (Cont.) • 2.1.2.2 Access classes : • The long version of the ls command also displays file permissions in addition to user and group ownership: • $ ls -l • -rwxr-xr-x 1 root system 20 Mar 12 09:32 bronze • -r--r--r-- 1 chavez chem 84 Feb 28 21:43 gold • -rw-rw-r-- 1 chavez physics 12842 Oct 24 12:04 platinum • The set of letters and hyphens at the beginning of each line represents the file's mode. The 10 characters are interpreted as indicated in the following table :

  19. Ch2 University Of Palestine 2.1 Files (Cont.)

  20. Ch2 University Of Palestine 2.1 Files (Cont.) • 2.1.2.3 Setting file protection: • The chmod command is used to specify the access mode for files: • $ chmod access-string files • chmod's second argument is an access string, which states the permissions you want to set (or remove) for the listed files. It has three parts: • The code for one or more access classes, • The operator, • And the code for one or more access types.

  21. Ch2 University Of Palestine 2.1 Files (Cont.) • 2.1.2.3 Setting file protection (Cont.): • The following figure illustrates the structure of an access string. • To create an access string, you choose one or more codes from the access class column, one operator from the middle column, and one or more access types from the third column.

  22. Ch2 University Of Palestine 2.1 Files (Cont.) • 2.1.2.3 Setting file protection (Cont.): • For example, the access string u+w says to add write access for the user owner of the file. • Thus, to add write access for yourself for a file you own (lead, for example), use: • $ chmodu+w lead • To add write access for everybody, use the all access class: • $ chmoda+w lead

  23. Ch2 University Of Palestine 2.1 Files (Cont.) • 2.1.2.3 Setting file protection (Cont.): • To remove write access, use a minus sign instead of a plus sign: • $ chmod a-w lead • You can specify more than one access type and more than one access class. • You can also include more than one set of operation-access type pairs for any given access class specification. • $ chmodu+w, og+r-w bronze brass

More Related