Skip to content Skip to sidebar Skip to footer

Take Away From the Scripts Directory Read and Execute (Search) Permission for Yourself Only.

[Next Chapter] [Top page] [Previous Chapter]

Affiliate seven - FILE PERMISSIONS


What are file permissions?

The Unix file security system tin can foreclose unauthorised users from reading or altering files.

Every file and directory has specific permissions associated with it, giving dissimilar categories of user sure permissions to await at or change a file, and to run executable files.

Notation Executable files are files containing commands than can themselves be executed as if the file itself were a command.

The file permissions tin can exist displayed using the command:

% ls -l [filename]      

For instance, to brandish the permissions on the file lookup.icn, type the command:

% ls -l lookup.icn -rw-r--r-- 1  lnp5jb  777  Dec 18  lookup.icn      

The first prepare of characters in the output from the control (-rw-r--r--) gives the permissions. The username in the middle of the line (lnp5jb) is the owner of the file. This is user who created the file. The following fields tell yous the number of characters in the file, the date it was created and the proper noun of the file.

Note that the starting time grapheme specifies the file type. This is unremarkably ane of the post-obit:

- indicates a file

d indicates a directory

The following ix characters represent permissions for dissimilar classes of users. Users on a Unix arrangement are assigned to a group or groups, which might correspond to a item department, or research group in the real world. Members of a particular group tin can be immune access to files belonging to other members of the group.

The 2nd, 3rd and fourth characters in the permissions cord stand for permissions that employ to the owner of the file. The next three characters use to members of the owner's group. The terminal three utilize to all other users. The file in this instance therefore has rw- for the owner, r-- for the grouping and r-- for others.

The 3 characters corresponding to each form of user each represent a dissimilar type of permission. The first character represents 'read' permission. This means that a user has permission to open up a file and view the contents. If there is an r in this position then that class of users has read permission. In this example all users accept read permission. In this, and in every case, a horizontal bar character (-) means that permission is denied.

The second position represents 'write' permission (the right to make changes to a file). In the example, simply the owner has write permission. Commonly, you will not want others to be allowed to make changes to your files, so write permission is only allowed to the possessor.

The third position represents 'execute permission'. This means permission to 'execute', or run, a file that works like a control. In this example no-1 has execute permission for the file lookup.icn (information technology is an Icon program, and information technology would have to be compiled before it could be executed, so execute permission would be useless). To summarise the higher up, this is how the permissions string is divided upwardly:

        -			rw-		r--		r-- type of file	owner	group	others      

Here is another example, this time an executable file:

-rwxr-x--x ane    lnp5jb   562   January 10   hello      

This tells us that hello is a file; the owner is lnp5jb, the possessor has read, write and execute permission; the group has read and execute permission; others just have execute permission.


Do


What are the default permissions for your files and directories? Are they all the same?

When yous copy a file what file permissions does the new file take?

Irresolute file permissions

The control chmod is used to alter the permissions on a file. The format of this command is:

%  chmod        mode filename      

For case, to add read permission for the grouping to the file file1, give the command:

% chmod yard+r file1      

chmod modes

In the command:

% chmod        mode filename      

the mode consists of 3 elements:

who

operator

permissions

The following options are possible:

who:

u user (possessor)

g grouping

o other

a all

operators:

- remove permission

+ add permission

= assign permission

permissions:

r read

w write

x execute

For example:

chmod  o-rw  file1.f      

removes read and write permissions from others.

chmod  u+10  test      

adds execute permission to the owner.

Permissions for directories

Read, write and execute permissions are ready for directories as well as files. Read permission means that the user may meet the contents of a directory (e.thou. employ ls for this directory.) Write permission means that a user may create files in the directory. Execute permission means that the user may enter the directory (i.e. make information technology his electric current directory.)


Exercises

1. Endeavour to motion to the dwelling directory of someone else in your grouping. There are several ways to do this, and you may find that you are not permitted to enter certain directories. See what files they have, and what the file permissions are. (Think that you lot can protect your ain files from prying eyes, or from interference.)

two. Attempt to copy a file from some other user's directory to your own.

three. Set permissions on all of your files and directories to those that you desire. Yous may desire to give read permission on some of your files and directories to members of your group.


[Next Chapter] [Top page] [Previous Chapter]

gibsonshewit1957.blogspot.com

Source: https://users.ox.ac.uk/~martinw/unix/chap7.html

Post a Comment for "Take Away From the Scripts Directory Read and Execute (Search) Permission for Yourself Only."