Terminus by Warp
Chmod 755

Chmod 755

Razvan Ludosanu
Razvan Ludosanu
Founder, learnbackend.dev

[#the-short-answer]The Short Answer[#the-short-answer]

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

Executing the following command:

 $ chmod 755 file.txt

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 [.inline-code]755[.inline-code] permissions translate to [.inline-code]rwx r-x r-x[.inline-code].

[#chmod-755-on-directory][.inline-code]chmod 755[.inline-code] on a directory[#chmod-755-on-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.

[#sudo-with-chmod-755]Using [.inline-code]sudo[.inline-code] With [.inline-code]chmod 755[.inline-code][#sudo-with-chmod-755]

The [.inline-code]sudo[.inline-code] command is used to execute a command as the superuser (or root).

Executing the [.inline-code]chmod[.inline-code] command with [.inline-code]sudo[.inline-code] 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 [.inline-code]sudo chmod 755[.inline-code] command on a binary file to give permission to all users to execute it.

 $ sudo chmod 755 script.sh

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

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 [.inline-code]chmod[.inline-code] command, you can read about the chmod command more broadly.

[#chmod-755-vs-chown-755]The difference between [.inline-code]chmod 755[.inline-code] And [.inline-code]chown 755[.inline-code][#chmod-755-vs-chown-755]

Often mistaken for each other, [.inline-code]chmod[.inline-code] and [.inline-code]chown[.inline-code] are two different commands that serve a distinct purpose.

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

Since the [.inline-code]chown[.inline-code] 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 [.inline-code]chmod[.inline-code] command.

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

 $ chmod 755 file

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

Experience the power of Warp

  • Write with an IDE-style editor
  • Easily navigate through output
  • Save commands to reuse later
  • Ask Warp AI to explain or debug
  • Customize keybindings and launch configs
  • Pick from preloaded themes or design your own
Join the Linux waitlist:
Success! You will receive an email from Warp when the release is available to download.
Oops! Something went wrong while submitting the form.
brew install --cask warp
Copied!
Join the Windows waitlist:
Success! You will receive an email from Warp when the release is available to download.
Oops! Something went wrong while submitting the form.
Join the Linux waitlist:
Success! You will receive an email from Warp when the release is available to download.
Oops! Something went wrong while submitting the form.
Join the Linux waitlist or join the Windows waitlist
Join the Windows waitlist:
Success! You will receive an email from Warp when the release is available to download.
Oops! Something went wrong while submitting the form.