In Ubuntu, permissions restrict access to files and directories. There are three categories of users for whom permissions can be set: the file’s owner, the members of the group that owns the file, and all others. Changing the file permissions to 777 will allow all users of the file to read, write and execute the file. In this tutorial, I will discuss how to change file permissions to 777 in Ubuntu.
Key Takeaways
- Learning about read, write & execute permission in Linux.
- Learning to change file permissions to 777 using the chmod.
- Knowing about frequently asked questions and their answers regarding file permission.
Requirements
- You must be a root user or have root/sudo access to Ubuntu.
Process Flow Chart
Distro Used Throughout the Tutorial: Ubuntu 22.04.1 LTS
Read, Write & Execute Permissions in Linux
File and directory permissions are used in Linux to control resource access. Read, write, and execute permissions, which are denoted by the letters “r,” “w,” and “x,” respectively, are three basic forms of permissions. These permissions can be assigned to 3 types of users: the file or directory’s owner, the group that owns the file or directory, and others.
- Read permission (r): Allows a user to view the contents of a file or lists of a directory, but cannot modify them.
- Write permission (w): Allows a user to modify the contents of a file or to create, delete, or rename files in a directory. For example, a user with only written permission on a file can modify its contents but can’t view or execute it.
- Execute permission (x): Allows a user to run an executable file or change into a directory, but can not view or write onto it.
Read, write, and execute permissions can be represented using either octal or binary numbers. Here is a table below showing octal representation, binary representation, file permission set, and corresponding permissions of any file/directory.
Octal Representation | Binary Representation | File Permission Set |
Permission |
||
---|---|---|---|---|---|
0 | 000 | — | No permission | ||
1 | 001 | –x | Execute | ||
2 | 010 | -w- | Write | ||
3 | 011 | -wx | Write | Execute | |
4 | 100 | r– | Read | ||
5 | 101 | r-x | Read | Execute | |
6 | 110 | rw- | Read | Write | |
7 | 111 | rwx | Read | Write | Execute |
Watch Change File Permissions to 777 in Ubuntu
Steps to Change File Permissions to 777 in Ubuntu
You can change file permissions to 777 in Ubuntu. This will assign read, write, and execute permission to the three types of users. Here, I am using the file Summer to change its permissions to 777. Follow the instructions below for a better understanding.
Steps to Follow >
➊ Start by pressing CTRL+ALT+T to open the Ubuntu Terminal.
➋ To view the current permissions of the Summer file, run the following command in the command prompt:
ls -l
- ls: Shows all the files in a specific folder.
- option -l: Long listing format.
➌ To change the permissions to 777, execute the following command in the command prompt:
chmod 777 Summer
- chmod: Changes file permissions.
- 777: Read, Write & Execute Permission.
- Summer: The file to change permission.
ls -l
- ls: Shows all the files in a specific folder.
- option -l: Long listing format.
Complementary Information
You will find the following information useful along with learning how to change file permissions to 777 in Ubuntu.
Change Permission of Directory and Subdirectory Using the chmod Command Recursively
You can change a directory and subdirectory’s permission at once using the chmod command in recursive mode. For this, you need to add the -R option to the chmod command. You can do this by following the procedure below.
Steps to Follow >
➊ Open the Terminal in Ubuntu.
➋ To view the current permissions of the Summer directory and its subdirectory Fruits, run the following commands in the command prompt:
ls -l
ls -l Summer
- ls: Shows all the files in a specific folder.
- option -l: Long listing format.
- Summer: The folder to change permission.
➌ To change the permission of the directory and subdirectory concurrently, execute the following command in the command prompt:
chmod -R 764 Summer
- chmod: Changes file permissions.
- -R option: Enables recursive mode.
- 764: Read, Write & Execute Permission.
- Summer: The folder to change permission.
❹ Finally, run the following commands to check if the permissions of the Summer directory and Fruits subdirectory are changed:
ls -l
ls -l Summer
- ls: Shows all the files in a specific folder.
- option -l: Long listing format.
- Summer: The folder to change permission.
Change Ownership of File in Linux
You can change a file’s ownership using the chown command in Ubuntu. You can change the ownership to a specific user, specific group, or both the user and the group. I have shown you how you can change the ownership of a file to these user types below.
Change the Ownership of a File to a Specific User in Linux
You can change the ownership of a file to a specific user in Ubuntu. Here I am changing ownership of myfile.txt from user sylvie to user rynvie. Follow the process below to do that.
Steps to Follow >
➊ Open the Ubuntu Terminal.
➋ To view the current owner/user of the file myfile.txt, run the following command in the command prompt:
ls -l
- ls: Shows all the files in a specific folder.
- option -l: Long listing format.
➌ To change the ownership of the file to a specific user, execute the following command in the command prompt:
sudo chown rynvie myfile.txt
❹ Then, type the password and press the ENTER button.❺ Finally, execute the following command to check if the ownership of the myfile.txt file is changed:
ls -l
- ls: Shows all the files in a specific folder.
- option -l: Long listing format.
- How to Give Permission to User in Linux? [4 Methods]
- 2 Ways to Change Folder Permissions from Root to User in Linux
- How to Change Folder Permissions in Linux? [2 Methods]
- 2 Ways to Change Folder Permissions Recursively in Linux
Change the Ownership of a File to a Specific Group in Linux
You can change the ownership of a file to a specific group in Ubuntu. Here I am changing ownership of myfile.txt from group sylvie to group rynvie. Follow the procedure below to do that.
Steps to Follow >
➊ Open the Terminal in Ubuntu.
➋ To view the current group of the file myfile.txt, run the following command in the command prompt:
ls -l
- ls: Shows all the files in a specific folder.
- option -l: Long listing format.
➌ To change the ownership of the file to a specific group, execute the following command in the command prompt:
sudo chown :rynvie myfile.txt
- sudo: Grants administrative privileges.
- chown: Changes the file’s ownership.
- rynvie: name of the group.
- myfile.txt: The file to change ownership.
❹ Then, type the password and press the ENTER button.❺ Finally, execute the following command to check if the group of the myfile.txt file is changed:
ls -l
- ls: Shows all the files in a specific folder.
- option -l: Long listing format.
Change Both the User and Group Ownership of a File in Ubuntu
You can change both the user and group ownership of a file in Ubuntu. Here I am changing both the user and group ownership of myfile.txt from sylvie to rynvie. Follow the instructions below to do that.
Steps to Follow >
➊ Initially open the Ubuntu Terminal.
➋ To view the current owner/user and group of the file myfile.txt, run the following command in the command prompt:
ls -l
- ls: Shows all the files in a specific folder.
- option -l: Long listing format.
➌ To change both the user and group ownership of a file, execute the following command in the command prompt:
sudo chown rynvie:rynvie myfile.txt
- sudo: Grants administrative privileges.
- chown: Changes the file’s ownership.
- rynvie: name of the user and group.
- myfile.txt: The file to change ownership.
❹ Then, type the password and press the ENTER button.❺ Finally, execute the following command to check if the ownership of both the user and group of the myfile.txt file are changed:
ls -l
- ls: Shows all the files in a specific folder.
- option -l: Long listing format.
Conclusion
The chmod command can be used in Ubuntu to change file permissions to 777. Setting file permissions to 777 can be a security issue because it allows anyone to change or execute the file. It is best recommended to set the file permissions to the bare minimum needed to finish the task.
People Also Ask
Related Articles
- How to Change Permissions of All Files in a Folder in Linux?
- Manage File Permissions in Ubuntu Using Command?
- How to Change File Permissions in Linux with 6 Examples
- 2 Cases to Give User Permission to Folder and Subfolders in Ubuntu
- How to Change Directories and Files Recursively with “chmod”
- Change Permissions on Mounted Drive in Linux