• Modern UX

    Edit and navigate faster in the terminal with Warp's IDE-like input editor.

  • Warp AI

    AI suggests what commands to run and learns from your documentation.

  • Agent Mode

    Delegate tasks to AI and use natural language on the command line.

  • Warp Drive

    Save and share interactive notebooks, workflows, and environment variables.

  • All Features

Chmod 755

Thumbnail for Razvan LudosanuRazvan Ludosanu

Razvan Ludosanu

Founder, learnbackend.dev

Published: 8/3/2023

About Terminus

The Short Answer

On Linux and Unix-like operating systems (including macOS), the chmod command is used to change the read, write, and execute permissions of a file or directory.

Executing the following command:

 $ chmod 755 file.txt

Run in Warp

Will give:

  • Read, write, and execute permissions to the owner of the file; which is the user account that created the file or has been assigned ownership of the file.
  • Read and execute permissions to the group associated with a file; which is a collection of user accounts, such as members of the same team, that have been granted certain permissions on the file.
  • Read and execute permissions to the others; which are all other users who are not the owner or members of the group associated with the file.

When using the symbolic notation, the 755 permissions translate to rwx r-x r-x.

chmod 755 on a directory

When applied to a directory as opposed to a single file, these permissions have a slightly different meaning:

  • The read permission allows users to list the content of the directory (but only if the execute permission is also set).
  • The write permission allows users to create, rename, and delete the entries of the directory.
  • The execute permission allows users to enter (or traverse) the directory.

If you want to learn more about file permissions, you can read all about linux/unix permissions.

Using sudo With chmod 755

The sudo command is used to execute a command as the superuser (or root).

Executing the chmod command with sudo allows you to modify the permissions of a file or directory that you do not have access to as the current user.

For example, you can use the sudo chmod 755 command on a binary file to give permission to all users to execute it.

 $ sudo chmod 755 script.sh

Run in Warp

As another example, you can use the same command on a directory, such as one containing server logs, to give permission to other users to read the logs file.

 $ sudo chmod 755 /var/log/nginx

Run in Warp

It is important to note that giving the read and execute permission to all users to a file or directory may lead to security vulnerabilities, especially if it contains sensitive information or has the ability to execute arbitrary code.

If you want to learn more about the chmod command, you can read about the chmod command more broadly.

The difference between chmod 755 And chown 755

Often mistaken for each other, chmod and chown are two different commands that serve a distinct purpose.

The chmod command is used to change the permissions of a file or directory, while the chown command is used to transfer the ownership of a file or directory to another user or group.

Since the chown command allows you to either use symbolic names (e.g. foobar) or identifiers (e.g. 1001) to specify the user or group you want to transfer the ownership of a file to, you have to make sure not to mistake them with numeric permissions, such as the ones used with the chmod command.

For example, this command will change the permissions of the target file:

 $ chmod 755 file

Run in Warp

While this command will transfer the ownership of the target file to the user identified on the system by the UID 755:

 $ sudo chown 755 file

Run in Warp

Written by

Thumbnail for Razvan LudosanuRazvan Ludosanu

Razvan Ludosanu

Founder, learnbackend.dev

Filed Under

Related Articles

List Open Ports in Linux

Learn how to output the list of open TCP and UDP ports in Linux, as well as their IP addresses and ports using the netstat command.

UnixLinux
Thumbnail for Razvan LudosanuRazvan Ludosanu

Count Files in Linux

Learn how to count files and folders contained in directories and subdirectories in Linux using the ls, find, and wc commands.

LinuxUnix
Thumbnail for Razvan LudosanuRazvan Ludosanu

How to Check the Size of Folders in Linux

Learn how to output the size of directories and subdirectories in a human-readable format in Linux and macOS using the du command.

LinuxUnix
Thumbnail for Razvan LudosanuRazvan Ludosanu

Linux Chmod Command

Understand how to use chmod to change the permissions of files and directories. See examples with various chmod options.

Linux
Thumbnail for Razvan LudosanuRazvan Ludosanu

POST JSON Data With Curl

How to send valid HTTP POST requests with JSON data payloads using the curl command and how to avoid common syntax pitfalls. Also, how to solve the HTTP 405 error code.

BashUnixLinux
Thumbnail for Neeran GulNeeran Gul

Format Command Output In Linux

Learn how to filter and format the content of files and the output of commands in Linux using the awk command.

Linux

Create Groups In Linux

Learn how to manually and automatically create and list groups in Linux.

Linux

Switch Users In Linux

Learn how to switch between users, log in as another user, and execute commands as another user in Linux.

Linux

Remover Users in Linux

Learn how to remove local and remote user accounts and associated groups and files in Linux using the userdel and deluser commands.

Linux

Delete Files In Linux

Learn how to selectively delete files in Linux based on patterns and properties using the rm command.

Linux

Find Files In Linux

Learn how to find and filter files in Linux by owner, size, date, type and content using the find command.

Linux

Copy Files In Linux

Learn how to safely and recursively copy one or more files locally and remotely in Linux using the cp and scp command.

Linux

Trusted by hundreds of thousands of professional developers

Download Warp to get started

Download for Mac
Request demo
Thumbnail for null