Using chmod and chown

You can use the chown command to change the user:group associated with a file. For example: 

!# chown root:root testing.txt Will change the user:group permissions to root:root. Anyone other than the root user will have to be under the group "root" to access this file. 

You can also change the permissions for file access with the 'chmod' command. File permissions are Read, Write and Execute, and are broken up into 3 fields: Owner, Group, and World. 

So, for example: 

-rwxr--r-- 1 root root 81 Jan 1 12:00 testing.txt The owner (root) has read, write and execute permissions. The group (root) has only read permissions. World access (everyone else) has only read permissions. 

When changing permissions with "chmod" you will can use the numerical value for the permissions you want to set. These are: 

0 = no permissions whatsoever; this person cannot read, write, or execute the file 
1 = execute only 
2 = write only 
3 = write and execute (1+2) 
4 = read only 
5 = read and execute (4+1) 
6 = read and write (4+2) 
7 = read and write and execute (4+2+1) 
So the command: 

!# chmod 777 testing.txt would change the permissions of that file to: 

-rwxrwxrwx 1 root root 81 Jan 1 12:00 testing.txt And the file can now be edited or executed (if it were a script) by anyone, regardless if they are associated with the user or group. 

  • 2 Users Found This Useful
Was this answer helpful?

Related Articles

Connecting to your VPS via VNC

This knowledge base article will explain how you can connect to your VNC enabled Linux VPS....

How to set reverse DNS (rDNS)

At the moment you need to open a Helpdesk ticket and provide your IP and PTR record you want set,...

My SSH shows "-bash-*". How to change?

When a Xen VPS is delivered and you login for the first time you might see something similar to...

Installing OpenVPN on OpenVZ VPS (CentOS)

You must enable tun/tap and or PPP directly from inside VPS Manager under "settings" tab. then...

How to add website via webmin

This is a great tutorial how you can add new domain/website using webmin....