Learning Mysql


bgto send the suspended job to the background.Restricting access to files and directories



Download 4.24 Mb.
View original pdf
Page23/366
Date04.08.2023
Size4.24 Mb.
#61806
1   ...   19   20   21   22   23   24   25   26   ...   366
Learning MySQL
bg
to send the suspended job to the background.
Restricting access to files and directories
Before we end our discussion of the Linux and Mac OS X shell, let’s look at how access to files and directories is controlled under such Unix-like operating systems. Each file or directory can have read, write, and execute permissions set for the user who owns it, the group associated with it, and every other user.
Using the Command-Line Interface | 15

When the operating system is asked to allow access to a file or directory, it looks to see who the user is and what groups this user belongs to. It then checks the user and the group associated with that file or directory, and allows access only if the permission settings are appropriate.
Your group on a Linux or Mac OS X system is typically the same as your username, so,
for example, the username and group for the user adam would both be adam
. The user and group associated with a file or directory can be changed by using the chown command and specifying the username and group as
username:group
. For example, you can set the owner of myfile.txt to be adam
, and the associated group to be managers, by typing chown adam:managers myfile.txt
Only the superuser is allowed to change the owner of a file or directory.
You can allocate permissions to a file or directory by using the chmod command. To allow the user who owns the file myfile.txt to read and write (modify) it but allow other users to only read it, you would write chmod u=rw,g=r,o=r myfile.txt
You can also ensure that only the user who owns the file can read and write to the file as follows chmod u=rw,g=,o= myfile.txt
Here, the group and other users have been assigned no permissions. Similarly, you can give everyone read, write, and execute permissions to the directory mydir by typing the command chmod u=rwx,g=rwx,o=rwx mydir
When reading other documentation, you’ll probably also come across cases where an octal value (or mask) is used with the chmod command. In this notation, read access has the value 4, write access has the value 2, and execute access has the value 1. So, read- only access has the value 4, but read-and-write access has the value 4+2=6. Our previous two examples would be written as chmod 644 myfile.txt
and:
$ chmod 777 mydir
The chown or chmod operation can be applied to all files and directories under a specified directory by using the recursive option (under Linux) or the
-R
option (under Mac
OS X as well as Linux. We’ll see examples of this later in this chapter.

Download 4.24 Mb.

Share with your friends:
1   ...   19   20   21   22   23   24   25   26   ...   366




The database is protected by copyright ©ininet.org 2024
send message

    Main page