Balloon Collaboration
February 26, 2020, 11:52:24 PM *
Welcome, Guest. Please login or register.

Login with username, password and session length
News: Hosting for has been extended for another 3 years
   Home   Help Search gallery Calendar Login Register  
Pages: [1]
Author Topic: Changing file permissions and owners.  (Read 1447 times)
Hero Member
Posts: 1167

View Profile
« on: August 04, 2013, 09:35:36 PM »

< How to set file permissions - symbolic mode >

You can set file permissions with the chmod command. Both the root user and the file's owner can set file permissions. chmod has two modes, symbolic and numeric.

The symbolic mode is pretty easy to remember. First, you decide if you set permissions for the user (u), the group (g), others (o), or all of the three (a). Then, you either add a permission (+), remove it (-), or wipe out the previous permissions and add a new one (=). Next, you decide if you set the read permission (r), write permission (w), or execute permission (x). Last, you'll tell chmod which file's permissions you want to change.

Let's have a couple of examples. Suppose we have a regular file called testfile, and the file has full access permissions for all the groups (long directory listing would show -rwxrwxrwx as the file's permissions).

Wipe out all the permissions but add read permission for everybody:
$ chmod a=r testfile After the command, the file's permissions would be -r--r--r--

Add execute permissions for group:
$ chmod g+x testfile
 Now, the file's permissions would be -r--r-xr--

Add both write and execute permissions for the file's owner. Note how you can set more than one permission at the same time:
$ chmod u+wx testfile
 After this, the file permissions will be -rwxr-xr--

Remove the execute permission from both the file's owner and group. Note, again, how you can set them both at once:
$ chmod ug-x testfile
 Now, the permissions are -rw-r--r--

As a summary, have a look at this quick reference for setting file permissions in symbolic mode:

Which user?
u user/owner
g group
o other
a all

What to do?
+ add this permission
- remove this permission
= set exactly this permission

Which permissions?
r read
w write
x execute

Changing owners is as follows:
chown newowner[:newgroup] filename(or foldername)

If you ls -l, it will show you how the owners are.
ki4ims@RPi3 ~ $ ls -l
total 76
drwxr-xr-x 2 ki4ims ki4ims  4096 Mar 29 18:05 Desktop
drwxr-xr-x 2 ki4ims ki4ims  4096 Mar 29 17:55 Images
-rwxrwxrwx 1 root   root   24028 Aug  4 13:57 motion.txt
drwxr-xr-x 2 root   root    4096 Aug  3 21:13 PiFM
drwxr-xr-x 2 root   root   36864 Aug  4 13:34 time_lapse

To changer owner of motion.txt:
chown ki4ims:ki4ims motion.txt
That will change the username and user group to ki4ims.
« Last Edit: August 04, 2013, 11:39:57 PM by Larry » Logged
Pages: [1]
Jump to:  

Powered by MySQL Powered by PHP Powered by SMF 1.1.11 | SMF © 2006-2009, Simple Machines LLC Valid XHTML 1.0! Valid CSS!