linux

User Login

User Name
Password
   
Forgot Password                  Sign Up

What's up ?

We value your feedbacks,ideas and your articles.Please navigate to the following links.

  • Feedback
  • I have an Idea
  • Advertise
  • The Article

    Would you like to post an article on this web site, then please navigaet here to do that.

    Submit an article

    Newletter SignUp

    Please register to receive a Newsletter.

    Register Here

    Linux User Permissions

    Linux, like UNIX, is a multi-user system and file permissions are one way the protects the system. One way to gain entry when you are denied permission is to enter the command su -. This is because whoever knows the root password has complete access.

    All files and directories are "owned" by the person who created them. That means you can specify who is allowed to read the file, write to the file,who can execute the file(if it is an application file).

    Reading, writing, and executing are the three main settings in permissions. Since users are placed into a group when their accounts are created, you can also specify whether certain groups can read, write to, or execute a file. Those three sets are the owner of the file, the group in which the file belongs, and "others," meaning other users on the system.

    - (rw-) (rw-) (r--) 1 user user

    The first item, which specifies the file type, will probably be one of the following:

    d — a directory

    l — a symbolic link to another program or file elsewhere on the system

    Beyond the first item, in each of the following three sets, you may see one of the following:

    r — file can be read

    w — file can be written to

    x — file can be executed (if it is a program)


    The chmod Command

    Use the chmod command to change permissions. This example shows how to change the permissions on foo.txt with the chmod command.

    The original file looks like this, with its initial permissions settings:

    -rw-rw-r-- 1 user user 150 Mar 19 08:08 linux.txt

    If you are the owner of the file or are logged into the root account, you can change any permissions for the owner, group, and others . Right now, the owner and group can read and write to the file. Anyone outside of the group can only read the file (r--).

    chmod go-rw linux.txt By typing go-rw, you are telling the system to remove read and write permissions for the group and for others from the file linux.txt.

    The result looks like this:

    -rw------- 1 user user 150 Mar 19 08:08 linux.txt

    Identities

    u — the user who owns the file (that is, the owner)

    g — the group to which the user belongs

    o — others (not the owner or the owner's group)

    a — everyone or all (u, g, and o)

    Permissions

    r — read access

    w — write access

    x — execute access

    Actions

    + — adds the permission

    - — removes the permission

    = — makes it the only permission

    Each permission setting can be represented by a numerical value: r = 4

    w = 2

    x = 1

    - = 0

    When these values are added together, the total is used to set specific permissions. For example, if you want read and write permissions, you would have a value of 6; 4 (read) + 2 (write) = 6.

    For linux.txt, here are the numerical permissions settings:

    - (rw-) (rw-) (r--)

    The total for the user is six(4+2+0), the total for the group is six(4+2+0), and the total for others is four(4+0+0). The permissions setting is read as 664.

    If you want to change linux.txt so those in your group do not have write access, but can still read the file, remove the access by subtracting two (2) from that set of numbers.

    The numerical values then become six, four, and four (644).

    To implement these new settings, type:

    chmod 644 foo.txt