1

image link -chmod permission for user

I am trying to understand different permission for text file in linux , please refer the image i have attached. i want to ask two question.

1- when the text file only given read permission for user,i can move and rename file how it is possible if file has only read-only permission. ?

2- when file is only given write permission for user ,why can't i edit the file ?

1 Answers1

2
  1. Because it does not depend on the permissions of the file but on the permissions of the containing directory. As long as you have write-permission to the containing directory, you can move or rename the file.

  2. You can't edit the file with any text-editor because the text-editor would need to load the file first which is not possible if you don't have read-permission for the file. You could still use other commands fo example echo "some text" > file to alter it's content though.

mook765
  • 15,925
  • thank you , i want to extend a question little bit , i want a user can access files inside the directory and can view/ cat / ls files and directory but cannot create,delete,rename,move and edit(files) and directory structure , in a nutshell i want a user to have only read-only access to files and directories . what set of permission i need to give user for the directories and files inside of it . – user143252 Mar 06 '21 at 08:12
  • In this case, you give the user only read and execute permissions for the directory, so the user is able to access the files in the directory but can't move,rename,create or delete files in it. For the files in the directory you give only read permissions and, if a file is needed to be executed, also execute permissions, so the files can't be altered by the user. – mook765 Mar 06 '21 at 09:01
  • thank you for clearing my doubts – user143252 Mar 09 '21 at 07:53