Chmod explained

  • Hi folks


    Many guys here are well vexed with file permissions and how to chmod files, but I had always wondered what it was until I did a little read up on Google, and this is what I got
    For those who don’t understand why it’s always been said chmod 777/755/644….etc.
    May be you will appreciate them after reading this tutorial


    Let’s start


    In Unix/Linux whenever you check the property of any file, under the permissions tab, there are 3 categories of users of the file





    PERMISSIONS EXPLAINED



    All the file permissions read, write, execute have certain numeric values associated with them



    Quote

    Which means that at best a file can have a numeric value of 7, which is 4+2+1=7


    So a file created in Unix/Linux by default has



    Quote

    So by default any file created in Linux has 644 permission


    UMASK


    Umask is a system variable in Linux, when you type umask in the terminal you get a value 0022
    But we consider the value 022.Now when a file is created what Linux does is that it subtracts the value of umask from 666 for a file and 777 for a directory, so by default a file has 644 permissions and a directory has 755 permissions.


    HOW TO CHMOD IN TERMINAL


    Change directory or cd to the directory where the file is located
    e.g.

    Quote

    cd /usr/bin/


    Now let’s assume you file is called kingjj
    So we can change permissions to 644 by typing

    Quote

    chmod 644 kingjj


    Or simply type

    Quote

    chmod 644 /usr/bin/kingjj

Chat about everything else!

A friendly forum for off-topic discussions, random questions, and community bonding. Your space for conversations outside our main categories. Discuss hobbies, news, games, or anything else with the wider community.

Participate now!

Don’t have an account yet? Register yourself now and be a part of our community!