Please respond to the ANSWER in regards to the QUESTION that has been answered.
ID: 669737 • Letter: P
Question
Please respond to the ANSWER in regards to the QUESTION that has been answered.
ANSWER(respond to this):
A command such as chmod ugo -rwx could be dangerous, especially if the file was then moved into a directory you didn't have permission to access. There are other possibilities I'm sure. Allowing other users that have malicious intentions is definitely a bad idea. I think everyone will eventually make a mistake like this, or a re -rf similar mistake, although I do not think we would ever make the mistake twice.
Question:
The Unix file permissions are very powerful, but at the same time you can do rather dangerous and silly things with permissions. Provide an example where you might set permissions in such a way (using chmod or chgrp) that prohibits others or even yourself from accessing a file.
Explanation / Answer
==============================================================
----------
chmod
----------
chmod command stands for change mode , It defines rules for which who can access the file in an Unix system.
----------------
Command syntax:
----------------
chmod options permissions filename
1.permissions defines the permissions for the owner of the file (the "user"), members of the group who owns the file (the "group"), and anyone else ("others").
2.There are two ways to represent these permissions: with symbols (alphanumeric characters), or with octal numbers (the digits 0 through 7).
---------------------------------------------------------------------------------------------
For example i created a file with name file1.txt and it has to be the following privilages.
---------------------------------------------------------------------------------------------
1. The user can read, write, and execute it;
2. Members of your group can read and execute it; and
3. others may only read it.
----------------------------------------------------
The command is : chmod u=rwx,g=rx,o=r file1.txt
or
chmod 754 file1.txt
or
chmod u+rwx,g+rx,o+r file1.txt
----------------------------------------------------
---------------------------------------------------------------------------------------------
As per your question if only the authorized user has the access to file no other has to access.
----------------------------------------------------
The command is : chmod u=rwx file1.txt
or
chmod 700 file1.txt
or
chmod u+rwx file1.txt
----------------------------------------------------
==============================================================
----------
chgrp
----------
change group associated to a file/folder from one group to other in Unix. It is sister command to chown which is used to change owner of the file
as well as group name associated with that file.
----------------
Command syntax:
----------------
chgrp options groupname file
----------------
Example:
----------------
chgrp grp1 file1.txt
It is useful if you want to give permissions to a command to some group you can use this command.
==============================================================
Related Questions
drjack9650@gmail.com
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.