212 215 HEW36S2O4SJCA5TM2IH3NGBYKD4CW5IRLQUJFRY




Linux Configuration and Installation:Basic Linux Tools






-->

















Previous
Table of Contents
Next




Changing Ownerships and Permissions
In the act of creating a file or directory, you automatically assign permissions to the file or directory. To see what permissions are the default, use the umask command:


$ umask
744


This means that the owner of the file has full privileges, while your group and the world have the ability to read the file. To change this permission, you’ll again use the umask command, listing a new permission on the command line:


$ umask 007


This may look odd, and indeed it is odd. The umask command changes permissions relative to a baseline of 777. The input to the umask command is therefore subtracted from the baseline 777, leaving you with the total of 770, meaning that the owner of the file and the group have full permissions to the file, while the rest of the world has no permissions at all.
In the same way, you’re automatically the owner of a file when you create it, but there may be times when you want to transfer this ownership to another user. You can do so with the chown command, provided you’re logged in the system as the root user. (You didn’t think you could change the ownership logged in as an ordinary user, did you? If anyone could change the ownership of a file, security in the UNIX operating system would be nonexistent.) When using the chown (short for change ownership, by the way) command, you list the new owner of the command and the file in question:


gilbert:~$ chown pat report


You can also transfer ownership of an entire directory by using the -R option to the chown command:


gilbert:~$ chown -R pat reports_1996


Similarly, the chgrp command changes group ownership of a file, listing the new group membership and the file in question:


gilbert:~$ chgrp linux_book chap4


The Sticky Bit
In our continuing obsession with security, we present information about the sticky bit. In the past, UNIX hackers used to get around file permissions by messing with entire directories, as most system administrators would forget to set restrictive permissions for the directory itself.

The sticky bit was a response to this security problem. Linux allows you to set the sticky bit, which makes a directory impregnable to everyone but the owner of a directory and the root user. To set the sticky bit, use the chmod command in the following manner:


gilbert:/$ chmod +t directoryname


Once the sticky bit is set, no one (except the root user and the owner of the directory) has the ability to move or delete files in a directory, no matter what permissions are associated with a file.

Dealing with Files and Directories
We’ve thrown around the term command a great deal without ever really defining it (our copy editor is probably gnawing her red pen by this point), but we’re assuming you know what a command is and how you give a command to the computer. And you also know that the combination of a command and any options is called a command line.

NOTE:  Under Linux, commands can be run at a command line or under the X Window System in an xterm window (which we covered in Chapter 3). However, there are some cases when there’s an X Window version of the UNIX command; for example, there’s a version of man for the X Window System, called xman, that you should use instead. In this chapter, we’ll also note the X Window version.

If you’ve used MS-DOS for any extended period, you’ll instantly recognize the Linux counterparts presented here. If you’ve used Microsoft Windows for an extended period and have been hidden from the command line, you may be somewhat confused initially when you run through this series of Linux commands. And if you’re a UNIX workstation user, you’ll find that there might be slight differences between the commands/options and the version of UNIX you’re used to working with. (If you’re a Cray supercomputer user, you’re really slumming.)

NOTE:  This section will touch only on the most basic and useful Linux commands. For a more complete listing of Linux commands, check out Linux in Plain English—coming out shortly—or teach yourself . . . UNIX, Third Edition (MIS:Press) both listed in Appendix A.

You’ve already learned about the cd and pwd commands, which are used to move between directories and print the working directory, respectively. There are many more Linux commands used to deal with directories and files.



Previous
Table of Contents
Next














Wyszukiwarka

Podobne podstrony:
212 215
20 (212)
208 212
215 Bibliografia załącznikowa II
212 BD7FG2PG3WI2FKCEC3EBULZ7L6WKMMSAJULJFGY
Dz U 2008 nr 215 poz 1366
212 11 (2)

więcej podobnych podstron