How do I change file permissions via SSH?

Using the CHMOD command:

The letters u (for user), g (for group), and o (for other) are used with the letters r (for read permission, w (for write permission, and x (for execute permission) along with + (plus),- (minus), and = (equals) to alter permissions for a file. Some examples:

chmod u=rwx file.htm
chmod g-rwx config.inc.php
chmod o+rwx weblog.txt
chmod u=rwx,g-rwx,o=r other.htm

In the first example, the "user" group (u) is given read (r), write (w), and execute (x) permissions to the file "file.html". In the second, the "group" group (g) has read, write, and execute permissions subtracted for the file secret.txt; effectively making it inaccessible to that group. In the third example, the "other" group is given all permissions to the file, allowing that group (which includes the web server) to access and modify it fully. 

To use CHMOD with numerical permissions, a three digit number is formed. The first indicates the permissions that "user" should receive, the second indicates what "group" should receive, and the last indicates what "other" would receive. Some examples:

chmod 700 private.txt
chmod 755 normal.txt
chmod 707 forwebserver.txt

The first example gives all permissions to user (7), and no permissions to group or other (the zeroes). The second again gives all permissions to user, and gives read and execute permissions (5) to group and other. The last gives all permissions to user and other, but gives no permissions to group.
  • 0 Users Found This Useful
Was this answer helpful?

Related Articles

How do I get SSH access enabled?

If SSH access is not enabled, please open a support ticket and we will activate it for you.

What are some basic Linux shell commands?

filename.txt Same as ls �alR, outputs the results to a filels *.html Lists all files ending with...

What is Telnet/SSH and do you allow it?

For security purposes, we do not enable Telnet at all and we only enable SSH access by request....

What is SCP / SFTP?

SCP and SFTP are both part of OpenSSH, the secure shell server we run. Do note that you cannot...

How can I check my disk space usage in SSH?

From the Unix prompt, type the following:du -s /home/youruserThis will give you a report back of...