Magento Expert Forum - Improve your Magento experience

Results 1 to 6 of 6

Linux Permission Using and Understanding

  1. #1
    Administrator david's Avatar
    Join Date
    Nov 2012
    Posts
    261
    Thanks
    22
    Thanked 42 Times in 34 Posts

    Thumbs up Linux Permission Using and Understanding

    Linux Permissions



    The Unix operating system (and likewise, Linux) differs from other computing environments in that it is not only amultitaskingsystem but it is also amulti-usersystem as well.

    What exactly does this mean? It means that more than one user can be operating the computer at the same time. While your computer will only have one keyboard and monitor, it can still be used by more than one user. For example, if your computer is attached to a network, or the Internet, remote users can log in viatelnetorssh(secure shell) and operate the computer. In fact, remote users can execute X applications and have the graphical output displayed on a remote computer. The X Windows system supports this.

    The multi-user capability of Unix is not a recent "innovation," but rather a feature that is deeply ingrained into the design of the operating system. If you remember the environment in which Unix was created, this makes perfect sense. Years ago before computers were "personal," they were large, expensive, and centralized. A typical university computer system consisted of a large mainframe computer located in some building on campus andterminalswere located throughout the campus, each connected to the large central computer. The computer would support many users at the same time.

    In order to make this practical, a method had to be devised to protect the users from each other. After all, you could not allow the actions of one user to crash the computer, nor could you allow one user to interfere with the files belonging to another user.

    This lesson will cover the following commands:

    • chmod- modify file access rights
    • su- temporarily become the superuser
    • chown- change file ownership
    • chgrp- change a file's group ownership



    File permissions



    Linux uses the same permissions scheme as Unix. Each file and directory on your system is assigned access rights for the owner of the file, the members of a group of related users, and everybody else. Rights can be assigned to read a file, to write a file, and to execute a file (i.e., run the file as a program).

    To see the permission settings for a file, we can use thelscommand as follows:

    Code:
    [[email protected] me]$ ls -l some_file
    
    -rw-rw-r-- 1 me   me   1097374 Sep 26 18:48 some_file
    We can determine a lot from examining the results of this command:

    • The file "some_file" is owned by user "me"
    • User "me" has the right to read and write this file
    • The file is owned by the group "me"
    • Members of the group "me" can also read and write this file
    • Everybody else can read this file



    Let's try another example. We will look at thebashprogram which is located in the/bindirectory:


    Code:
    [[email protected] me]$ls -l /bin/bash
    
    -rwxr-xr-x 1 root root 316848 Feb 27 2000 /bin/bash
    Here we can see:

    • The file "/bin/bash" is owned by user "root"
    • The superuser has the right to read, write, and execute this file
    • The file is owned by the group "root"
    • Members of the group "root" can also read and execute this file
    • Everybody else can read and execute this file



    In the diagram below, we see how the first portion of the listing is interpreted. It consists of a character indicating the file type, followed by three sets of three characters that convey the reading, writing and execution permission for the owner, group, and everybody else.




    chmod



    Thechmodcommand is used to change the permissions of a file or directory. To use it, you specify the desired permission settings and the file or files that you wish to modify. There are two ways to specify the permissions, but I am only going to teach one way.

    It is easy to think of the permission settings as a series of bits (which is how the computer thinks about them). Here's how it works:


    Code:
    rwx rwx rwx = 111 111 111
    rw- rw- rw- = 110 110 110
    rwx --- --- = 111 000 000
    and so on...

    Code:
    rwx = 111 in binary = 7
    rw- = 110 in binary = 6
    r-x = 101 in binary = 5
    r-- = 100 in binary = 4
    Now, if you represent each of the three sets of permissions (owner, group, and other) as a single digit, you have a pretty convenient way of expressing the possible permissions settings. For example, if we wanted to setsome_fileto have read and write permission for the owner, but wanted to keep the file private from others, we would:

    Code:
    [[email protected] me]$chmod 600 some_file
    Here is a table of numbers that covers all the common settings. The ones beginning with "7" are used with programs (since they enable execution) and the rest are for other kinds of files.

    • 777: (rwxrwxrwx)No restrictions on permissions. Anybody may do anything. Generally not a desirable setting.
    • 755 : (rwxr-xr-x)The file's owner may read, write, and execute the file. All others may read and execute the file. This setting is common for programs that are used by all users.
    • 700 : (rwx------)The file's owner may read, write, and execute the file. Nobody else has any rights. This setting is useful for programs that only the owner may use and must be kept private from others.
    • 666: (rw-rw-rw-)All users may read and write the file.
    • 644: (rw-r--r--)The owner may read and write a file, while all others may only read the file. A common setting for data files that everybody may read, but only the owner may change.
    • 600 : (rw-------)The owner may read and write a file. All others have no rights. A common setting for data files that the owner wants to keep private.


    Becoming the superuser for a short while



    It is often useful to become the superuser to perform important system administration tasks, but as you have been warned (and not just by me!), you should not stay logged on as the superuser. In most distributions, there is a program that can give you temporary access to the superuser's privileges. This program is calledsu(short for substitute user) and can be used in those cases when you need to be the superuser for a small number of tasks. To become the superuser, simply type thesucommand. You will be prompted for the superuser's password:

    Code:
    [[email protected] me]$su
    Password:
    [[email protected] me]#
    After executing thesucommand, you have a new shell session as the superuser. To exit the superuser session, typeexitand you will return to your previous session.

    In some distributions, most notably Ubuntu, an alternate method is used. Rather than usingsu, these systems employ thesudocommand instead. Withsudo, one or more users are granted superuser privileges on an as needed basis. To execute a command as the superuser, the desired command is simply preceeded with thesudocommand. After the command is entered, the user is prompted for the user's password rather than the superuser's:

    Code:
    [[email protected] me]$sudo some_command
    Password:
    [[email protected] me]$

    Changing file ownership



    You can change the owner of a file by using thechowncommand. Here's an example: Suppose I wanted to change the owner ofsome_filefrom "me" to "you". I could:

    Code:
    [[email protected] me]$su
    Password:
    [[email protected] me]#chown you some_file
    [[email protected] me]#exit
    [[email protected] me]$
    Notice that in order to change the owner of a file, you must be the superuser. To do this, our example employed thesucommand, then we executedchown, and finally we typedexitto return to our previous session.

    chownworks the same way on directories as it does on files.

    Changing group ownership



    The group ownership of a file or directory may be changed withchgrp. This command is used like this:

    Code:
    [[email protected] me]$chgrp new_group some_file
    In the example above, we changed the group ownership ofsome_filefrom its previous group to "new_group". You must be the owner of the file or directory to perform achgrp.

    Source: linuxcommand

    View more threads in the same category:


  2. #2
    Junior Member jacobwallace's Avatar
    Join Date
    Nov 2014
    Location
    Hyderabad
    Posts
    15
    Thanks
    1
    Thanked 1 Time in 1 Post

    Default

    very helpful topic,keep it on

    thanks

  3. #3
    New member
    Join Date
    Mar 2015
    Location
    india
    Posts
    5
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default

    very useful information, thanks for posting with us. I will bookmark this

  4. #4
    Junior Member
    Join Date
    Sep 2018
    Location
    Oman, Muscat
    Posts
    582
    Thanks
    0
    Thanked 2 Times in 2 Posts

    Default

    Comprehend Linux authorizations

    There are three sorts of consents – read, compose, and execute. Peruse authorization permits the client to see the substance of a record. Compose consent permits the client to overwrite or attach new information to the document or erase it. The execute consent permits the client to execute the code contained in the record.

  5. #5
    Junior Member
    Join Date
    Sep 2018
    Location
    United Kingdom
    Posts
    625
    Thanks
    0
    Thanked 4 Times in 4 Posts

    Default

    In the world of Linux, permissions are broken down into three categories: read, write and execute. “Read” access allows one to view a file's contents, “write” access allows one to modify a file's contents, and “execute” allows one to run a set of instructions, like a script or a program.

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •