Categories: Unix Tutorials

Unix File Permissions | What is Chmod command in unix?

Unix File Permissions :

In previous chapter we have discussed different file commands,directory commands. We had also discussed about process commands  with examples and grep command with example in previous articles. In this article i will try to explain the most important topic which is related to Unix File Permissions,directories,how to give the permissions using chmod command. File permissions are most important component of unix operating system because it secures the files by giving the specific permissions.There are following types of permissions :

Owner Permissions :

Owner Permissions are Unix File Permissions given to the specific owner to open,read,write or execute the file

Group Permissions :

Group permissions are Unix File Permissions  to specific group of users to open,read,write and execute the file.

World Permissions :

These are Unix File Permissions  to other user to perform open,read,write, execute file permission.

 

1) Default Permissions for Regular File:

Open File                                                         Read

Write or Modify                                               Write

Execute                                                            Read & Execute

Default:

rw – r – – r – –

User        Group   Others

2) Default Permissions for Directory File:

ls                                                                      à Read

Create or Delete Files                                     à Write

cd                                                                    à Read & Execute

Default:

rwx r – x r – x

User        Group   Others

$ ls –l                                                               à To check permissions on files

chmod:It is used to change file permissions

Syntax:

chmod who/[+,-,=]/Permission File_Name/Directory_Name

Who:                                                                                                                           Permissions:

User/Owner    u                              (+) Add Permission                                  Read                 r

Group              g                              (-) Deny Permission                                   Write               w

Other               o                              (=) Assign Permission                                Execute           x

Examples:

 

1) $ chmodu+xPermission_File      

It adds Execute Permission to User Members

$ ls –l Permission_File& see the O/P

2) chmod u-wx,g-x,o-x Permission_File  

It removes Permissions of Write, Execute for User and Execute for Group & Others from Permission_File

$ ls –l Permission_File& see the O/P

3) $ chmod u=w Permission_File  

It adds only Write Permission to User members and it deletes Read and Execute Permission from User members.

$ ls –l Permission_File& see the O/P

Octal Code (2nd Method)

Read                4

Write               2

Execute           1

0          No Permissions   4              r

1          x                              5              r, x

2          w                             6             r, w

3          w, x                         7             r, w, x

1) chmod 477 Permission_File    

It gives Read Permission to User, Read/Write/Execute  Permissions to Group & Others.

$ ls –l Permission_File& see the O/P

2) chmod700Permission_File  

It gives Read/Write/Execute Permission to User and No  Permissions to Group & Others

$ ls –l Permission_File& see the O/P

3) chmod777Permission_File      

It gives Read/Write/Execute Permission to User, Group & Others

$ ls –l Permission_File& see the O/P

4) chown:To change Owner of the File/Directory

Syntax:$ chownOwner_Name File/Directory

5) chgrp: To change Group of the File/Directory

Syntax:$ chgrpGroup_Name File/Directory

UMASK:

Default file creation permissions will be obtained from the umask value. Mask of umask will give the actual permissions. Mask is subtract value from 7

If umask is 021, then the default file permissions are 7-0,7-2,7-1

i.e. 756 are the permissions (rwxr-xrw-)

The current umask value can be had by:

$ umask

0227

first 0 indicate the value is octal; umask can be assigned new value by:

$ umask 042.

Click on Topic You want to learn:

  1. History of SQL
  2. SQL Create Table(DDL in SQL)
  3. SQL DML Statements(INSERT,UPDATE,DELETE)
  4. SQL Select Statement Execution
  5. Operators in SQL
  6. Views in SQL
  7. Materialized View in SQL
  8. Joins in SQL
  9. Inner Join / Outer Join
  10. Full Outer Join / Cartesian Join
  11. Union and Union ALL
  12. Intersect and Minus
  13. Indexing in SQL
  14. Rank and Dense Rank
  15. SubQueries and Correlated Subqueries
  16. Parser and Optimizer
  17. Oracle 11 G new Features
  18. SQL Functions List
  19. Constraints in SQL
  20. Database Normalization
  21. Table Partitioning
  22. Pivot in SQL
  23. Difference Between Truncate,Delete and drop
  24. Oracle System Tables

Unix Tutorials :

1.What is unix?

2.Basic unix commands

3.File Commands in unix

4.Create File in Unix using multiple ways

5.Cat Command

6.Touch Command

7.Mkdir command

8.rmdir Command

9.pwd command

10.Cd Command

11.cut Command

12.paste Command

13.tr Command

14.Cp Command

15.wc command

16.cmp command

17.Rm Command

18.Grep Command

19.Egrep Command

20.FGrep Command

Hope you like this article.If you like this article dont forget to comment in comment section.

Amit S

Oracle Consultant with vast experience in Oracle BI and PL/SQL Development. Amiet is the admin head of this website who contributes by preparing tutorials and articles related to database technologies. He is responsible to manage the content and front-end of the website.

Share
Published by
Amit S

Recent Posts

What is Root Cause Analysis (RCA) With real examples

In my previous article I have given details about application support engineer day to day…

1 day ago

Application Support Engineer Day to day responsibilities

In my previous articles I have given the roles and responsibilities of L1,L2 and L3…

3 days ago

What is mean by SLA ( Service Level Agreement) with Examples?

In my previous articles i have given the hierarchy of production support in real company…

6 days ago

What is Production support Hierarchy in organization?

In this article i would like to provide information about production support organization structure or…

6 days ago

What are roles and responsibilities for L3 Support Engineer?

In my previous article I have given roles for L1 and L2 support engineer with…

6 days ago

What are roles and responsibilities of L2 Engineer?

I have started this new series of how to become application support engineer. This article…

6 days ago