Posts

Showing posts with the label chmod

Understanding chmod and chown in Linux with a Real-World Analogy

In Linux, the commands chmod and chown are used to manage file permissions and ownership. To help understand how these work, let's use an analogy with a house . chmod (Change Mode) - Setting Permissions for the House Imagine you have a house (which represents a file) and you want to decide how different groups of people can interact with it. chmod is used to set those rules. R (Read) : Group 1 can look at the house, see its contents, and understand what's inside. This is equivalent to the read permission. W (Write) : Group 2 can buy and move items into the house, arrange the furniture , and decorate the house. They can also delete items. This corresponds to the write permission. X (Execute) : Group 3 can use the house itself, meaning they can enter and interact with the environment in the house (e.g., open doors, use utilities). This represents the execute permission. There are three main groups for setting permissions: User (u) : The owner of the house (file). Gr...

How to use chmod in linux

Image
user (u),  group (g),  other (o) all (a)  The permission r for read,  w for write and  x for execute For example: Change mode a file as below, that group has not write, execute permission, the other is too chmod go-wx filename Example 1: The file should have read, write and execute permissions to user, read and execute permissions to group and read, and execute permissions to others. read, write and execute permissions to user =7 read and execute permissions to group =5 read and execute permissions to others=5 So total permissions will be 755 chmod 755 filename Example 2: Providing write access to a user chmod u+w filename Example 3: Adding write permissions to a group chmod g+w filename Example 4: Adding executable permissions to others chmod o+x filename Example 5: Adding executable and write permissions to all chmod a+wx filename Example 6: Replicating user permissions to a group chmod u=g filename ...