The commands of chmod and chown are the most influential and renowned gears of a command line that would be utilized as a way to manage accessibility towards the files in Linux-based OS.
On top of everything, as a significant aspect of Info-Tech security, they look at several Info-Tech certificate examinations and practices such as CompTIA certification training. On the other side, it is not always easier to comprehend the ways where they are working.
The command of chmod is also termed Change Mode, and it enables the modification permissions of the folders and files, also recognized as the modes in U-N-I-X. However, the command of chown stands for the Change Owner, and it lets alter the owner of a particular folder or file, that would be either a group or a user. To sum up, this is the dissimilarity among them.
Table of Contents
Let’s Explore – chmod vs. chown
In the meanwhile, chmod and chown work together. However, chmod would manage those consents that are approachable to the owner, as well as the owner’s group for the particular directory or file. Whereas, chown rapidly modifies who on the network attains accessibility to the file. Change mode or chmod is dictating what the user or group that has a file would do with such kind of file. Particularly, the details of chmod are; reading, writing, and executing the permissions on the nix – command-line, and it is also a thing – which you would require to be aware of.
- If a person is interested in modifying what exactly users would be doing with the file, you might need chmod.
- In case a person is interested in altering the holder of the file – then you might need chown.
By keeping this in mind, here we would go into the detailed fundamentals of these command lines.
chmod Explained
On the side of the coin, chmod is fundamentally known as an acronym of Change Mode – that must inform you anything. It is not as same as shown is, in some of the usual scenarios, modifying the mode refers to the fact of altering permissions that we would illustrate below. When we work with chmod, it demands to put together 2 ideas which we acquainted earlier.
- read = 4, write = 2, and execute = 1 (it’s at times known as the octal appearance of the authorizations)
- The initial set of the 3-rwx fonts is for those users who own the file, another set of the 3-rwx fonts is for that particular group who have the file, while the file set of the 3-rwx fonts is for every other person.
In account to make the variation in the file permissions, we would just input the command in that layout:
- chmod command
- The octal appearance of the authorizations.
- The pathway towards file. Keep in mind to make use of complete pathways in case you did not “cd” in the newest directory.
For instance, chmod Examples: 600, 400, 664, to modify the “groupnotes.txt” file, just the actual owner has access to keep reading and writing while no other person has this accessibility, we would implement the command “chmod 600 groupnotes.txt”
:~$ chmod 600 groupnotes.txt
:~$ ls -l
-RW——- 1 coolusercooluser 0 Jun 7 19:47 groupnotes.txt
As predictable, just right after the command, permissions on a file alter to rw——-. It makes some sense. The initial “rw” shows that the owner of the file had access to reading and writing. Another 7 “-” font right after that shows that the owner is not having to implement authority and no other person has this authorization.
For example, we are interested in modifying it so only the owner would read, however not have access to writing, instead the file. In such a scenario, “chmod 400 groupnotes.txt” would be doing the trick.
If we’re planning to offer groups and users who have file reading and writing authority, and every other person would have only reading access, it can be done by making use of “chmod 664 groupnotes.txt.” The initial 6 offer reading and writing authority to the user who holds the file, and another 6 provide reading and writing authorization for the group who have the file. Whereas 4 offers only reading permissions to every other person.
Always keep in mind: In these abovementioned examples, we only utilized “groupnotes.txt” as we are working in a similar directory just like a file. To make use of chmod on the files in different directories, ensure to encompass the pathway towards files (for example /path/to/the/file.name).
Chown Explained
Since the full abbreviation of chown is Changing Owner – that is much self-explanatory. All the same, chmod is managing what exactly users would do with a file when they get access to it, and chown is assigning the ownership. If you notice, not any of the commands of chmod – which we discussed earlier modified who has files we work with. It is the reason why the arrival of chown happens. Comparing with chmod and chown owns some of the fundamentals to highlight before we make a start.
The fundamental chown command layout includes:
- sudo lets a person get access to the file once they enter the password.
- chown command
- The user name of the newest owner of the file – that is demonstrated as the user, user:, user: group, or: group.
- The pathway towards file.
It is essential to keep in mind that chown typically requires sudo or root authorization. Only having the file isn’t that sufficient as a way to become enough capable to modify the owner.
Wrap-up
Since you have been made aware of the dissimilarity between chmod and chown, you would combine them on account to accomplish your desired goals. This summary of chown and chown must assist you in achieving success in both actual-world projects, as well as nix-related certificate studies. Luckily, both of them would be understood easily along with slightly practicing and getting to understand the basics. In the meanwhile, still, there is much more to know about.