I'm Vijay, and I've been working on this blog for the past 20+ years! I’ve been in the IT industry for more than 20 years now. I completed my graduation in B.E. Computer Science from a reputed Pune university and then started my career in…
In this tutorial, we will get to know how to change access permissions based on individual ownership and group ownership.
The commands covered here include chmod, chown, and chgrp.
Unix Video #7:
File Manipulation
#1) chmod: Change file access permissions.
Description: This command is used to change the file permissions. These permissions read, write and execute permission for the owner, group, and others.
The first optional parameter indicates who – this can be (u)ser, (g)roup, (o)there, or (a)ll.
The second optional parameter indicates opcode – this can be for adding (+), removing (-), or assigning (=) permission.
The third optional parameter indicates the mode – this can be (r)ead, (w)rite, or e(x)ecute.
Example: Add writes permission for user, group, and others for file1.
$ chmod ugo+w file1
Syntax (numeric mode): chmod [mode] file
The mode is a combination of three digits – the first digit indicates the permission of the user, the second digit for the group, and the third digit for others.
Each digit is computed by adding the associated permissions. Read permission is ‘4’, write permission is ‘2’ and execute permission is ‘1’.
Example: Give read/write/execute permission to the user, read/execute permission to the group, and execute permission to others.
$ chmod 751 file1
#2) chown: Change ownership of the file.
Description: Only the owner of the file has the right to change the file ownership.
Syntax: chown [owner] [file]
Example: Change the owner of file1 to user2 assuming it is currently owned by the current user
$ chown user2 file1
#3) chgrp: Change the group ownership of the file
Description: Only the owner of the file has the right to change the file ownership
Syntax: chgrp [group] [file]
Example: Change group of file1 to group2 assuming it is currently owned by the current user
$ chgrp group2 file1
Watch out for our upcoming tutorial to gain more knowledge on File Manipulation in Unix!!
Overview of Unix File System: In this tutorial, we will dive deep into Unix File System. The file system is central to how Unix organizes information, and all the information that needs to be stored and retrieved uses the file system. In this tutorial, we cover Unix file structure, types…
Unix Permissions: Learn what are the Different File Permissions in Unix Unix is a multi-user system where the same resources can be shared by different users. All permissions in Unix are based on restricting access to specific files and folders to specific users or user groups. => Click here for…
Overview of Unix Filename Wildcards or Special Characters or Metacharacters: In this tutorial, we will learn to use wildcards to specify and select multiple files for commands that manipulate files. Filename wildcards, which is also known as metacharacters, is a very helpful feature. Unix Video #9: Unix Filename Wildcards - Metacharacters…
Introduction to Find Command in Unix: Search files and directories with Unix Find File Command The Unix find command is a powerful utility to search for files or directories. The search can be based on different criteria, and the matching files can be run through defined actions. This command recursively…
A beginner's guide to Unix - A complete Unix tutorial series of 20+ in-depth text and video tutorials with hands-on examples. By the end of this series, you will be able to understand the basic and advanced concepts of Unix Architecture, Unix Commands, and applications including File Management, Text Processing,…
Overview of Unix File Comparison Commands : In this tutorial, we will cover the different ways involved for comparing two files. The file comparison command helps us to compare the files and find the similarities and differences between these files. The different file comparison commands used in Unix are cmp,…
Overview of Advanced Unix Shell Scripting: Unix shells provide a very powerful and extensible framework for scripting. A number of advanced mechanisms allow for more complex scripting using the inbuilt commands. Unix Video #24: Advanced Shell Scripting in Unix Unix includes commands for: Testing various conditions associated with specified files.…
Overview: In this tutorial, we will cover the basics of the Unix file system. We will also cover the commands that are used to work with the file system such as touch, cat, cp, mv, rm, mkdir, etc. => Click here for the Complete Unix Tutorial series Unix Video #3:…