Commands: $ logname  to check present working user. User2 $ clear


Using Octal Notations to change file permissions



Download 122.5 Kb.
Page12/17
Date25.10.2023
Size122.5 Kb.
#62396
1   ...   9   10   11   12   13   14   15   16   17
Unix Commands
Using Octal Notations to change file permissions
Below are the octal notations for giving permissions
Read  4
Write  2
Execute  1
---------------
All  7
---------------
For combination of permissions below octal notations are used
Read and Write  6
Read and execute  5
Write and Execute  3
Ex:
$ chmod 645 file1
In the above command
To the user  6 (read and write)
Group  4 (read)
Others  5 (read and execute)
These permissions are given to all. These are latest permissions.
The previous permissions of the file are removed and latest permissions will be added.
Ex 4:
$ ls –l file2
- r-x rw- -wx 3 user2 group2 5432 dec 09:00 file2
Requirement:
User  adding “w” and removing “x”
Group  removing “w” and adding “x”
Others  adding “r” and removing “x”
$ chmod 656 file2
$ ls –l file2
- rw- r-x rw- 3 user2 group2 5432 dec 10:00 file2

$ chmod 777 [filename]  all permissions to all


$ chmod –R 777 [dir name]  changing permissions of a directory including sub-directory contents.
$ chmod 65 file1  $ chmod 065 file1
$ chmod 5 file1  $ chmod 005 file1
$ chmod 0 file1  No permissions to all.
$ chmod file1  syntax error
Permissions:

: wq! The file will be forcefully overridden and saved and quit.

  • Executable permissions are only applicable for directories, executable files and shell scripts.

  • When there is an executable permission for a file, it is shown in green color.

$ ls –l x
Shows the contents of x directory and their permissions.
$ ls –l
Shows the permissions of directories.

Download 122.5 Kb.

Share with your friends:
1   ...   9   10   11   12   13   14   15   16   17




The database is protected by copyright ©ininet.org 2024
send message

    Main page