OnWorks Linux and Windows Online WorkStations

Logo

Free Hosting Online for WorkStations

< Previous | Contents | Next >

Reading, Writing, And Executing

Access rights to files and directories are defined in terms of read access, write access, and execution access. If we look at the output of the ls command, we can get some clue as to how this is implemented:



[me@linuxbox ~]$ > foo.txt

[me@linuxbox ~]$ ls -l foo.txt

-rw-rw-r-- 1 me me 0 2016-03-06 14:52 foo.txt

[me@linuxbox ~]$ > foo.txt

[me@linuxbox ~]$ ls -l foo.txt

-rw-rw-r-- 1 me me 0 2016-03-06 14:52 foo.txt


The first ten characters of the listing are the file attributes. The first of these characters is the file type. Here are the file types you are most likely to see (there are other, less com - mon types too):


Table 9-1: File Types


Attribute File Type

Attribute File Type

- A regular file.


image

d A directory.


image

l A symbolic link. Notice that with symbolic links, the remaining file attributes are always “rwxrwxrwx” and are dummy values. The real file attributes are those of the file the symbolic link points to.


image


image

c A character special file. This file type refers to a device that handles data as a stream of bytes, such as a terminal or modem.


image

b A block special file. This file type refers to a device that handles data in blocks, such as a hard drive or CD-ROM drive.


image


The remaining nine characters of the file attributes, called the file mode, represent the read, write, and execute permissions for the file's owner, the file's group owner, and everybody else:


Owner

Group

World

rwx

rwx

rwx


When set, the r, w, and x mode attributes have the following effect on files and directo- ries:


Table 9-2: Permission Attributes


Attribute Files Directories

Attribute Files Directories

r Allows a file to be opened and read.


image

image

w Allows a file to be written to or truncated, however this attribute does not allow files to be renamed or deleted. The ability to delete or rename files is determined by directory attributes.

x Allows a file to be treated as a program and executed. Program files written in scripting languages must also be set as readable to be executed.

Allows a directory's contents to be listed if the execute attribute is also set.

Allows files within a directory to be created, deleted, and renamed if the execute attribute is also set.


Allows a directory to be entered, e.g., cd directory.


image


Here are some examples of file attribute settings:


Table 9-3: Permission Attribute Examples


File Attributes Meaning

File Attributes Meaning

-rwx------ A regular file that is readable, writable, and executable by the file's owner. No one else has any access.


image

-rw------- A regular file that is readable and writable by the file's owner.

No one else has any access.


image

-rw-r--r-- A regular file that is readable and writable by the file's owner. Members of the file's owner group may read the file. The file is world-readable.


image

-rwxr-xr-x A regular file that is readable, writable, and executable by the file's owner. The file may be read and executed by everybody else.


image

-rw-rw---- A regular file that is readable and writable by the file's owner and members of the file's group owner only.


image

lrwxrwxrwx A symbolic link. All symbolic links have “dummy”

permissions. The real permissions are kept with the actual file pointed to by the symbolic link.


image

drwxrwx--- A directory. The owner and the members of the owner group may enter the directory and, create, rename and remove files within the directory.


image

drwxr-x--- A directory. The owner may enter the directory and create, rename and delete files within the directory. Members of the owner group may enter the directory but cannot create, delete or rename files.


image


 

Top OS Cloud Computing at OnWorks: