Users and rights: Difference between revisions

From WickyWiki
Created page with "Category:201311 Category:Ubuntu Category:Ubuntu System * https://help.ubuntu.com/10.04/serverguide/user-management.html Enable the root account by specifying a p..."
 
mNo edit summary
Line 3: Line 3:
[[Category:Ubuntu System]]
[[Category:Ubuntu System]]


Files and directories on the Linux system belong to an ''owner'' and a ''group''. You can set ''read'', ''write'' and ''execute'' permissions on a file or directory for ''owner'', ''group'' and ''others''. Users belong to one or more groups and have its permissions. The command ''chmod'' is used to set the permissions, the command ''chown'' to change the owner and the command ''chgrp'' to change the group.
* https://wiki.archlinux.org/index.php/Users_and_Groups
* https://help.ubuntu.com/10.04/serverguide/user-management.html
* https://help.ubuntu.com/10.04/serverguide/user-management.html
* http://www.cyberciti.biz/tips/unix-or-linux-commands-for-changing-user-rights.html
* http://www.cyberciti.biz/faq/how-to-use-chmod-and-chown-command/
= Show ownership and permissions =
<syntaxhighlight lang=bash>
ls -l /path/to/files/*
</syntaxhighlight>
{| class="wikitable"
|-
! Directory/Link !! User !! Group !! Other !! Number of links !! Owner !! Group !! Size !! Modified date/time !! Object name
|-
| - || rwx || rw- || rw- || 1 || wilbert || users || 464843 || Apr  6 16:09 || file1.txt
|-
| - || rwx || rw- || rw- || 1 || wilbert || users || 1398792 || Apr  6 16:09 || file2.txt
|-
| d || rwx || rw- || rw- || 1 || wilbert || users || 4096 || Apr 17 23:16 || directory
|}
= Add, remove and modify users and groups =
Disable the root account:
<syntaxhighlight lang=bash>
sudo passwd -l root
</syntaxhighlight>


Enable the root account by specifying a password for it:
Enable the root account by specifying a password for it:
Line 38: Line 66:
</syntaxhighlight>
</syntaxhighlight>


* http://www.cyberciti.biz/tips/unix-or-linux-commands-for-changing-user-rights.html
= Change permissions on files and directories =
 
User/group:
* u user/owner
* g group
* o other
 
Permissions:
* r read
* w write
* x execute
 
Options:
* -R full recurive
* + add permission
* - remove permission
 
Examples:
<syntaxhighlight lang=bash>
sudo chmod -R u+rwx /path/to/files
sudo chmod -R go-x /path/to/files
</syntaxhighlight>
 
= Change ownership of files and directories =
 
Owner:
<syntaxhighlight lang=bash>
<syntaxhighlight lang=bash>
sudo chmod
sudo chown -R user /path/to/files
</syntaxhighlight>
</syntaxhighlight>


* http://www.cyberciti.biz/faq/how-to-use-chmod-and-chown-command/
Group:
<syntaxhighlight lang=bash>
<syntaxhighlight lang=bash>
sudo chown
sudo chgrp -R group /path/to/files
</syntaxhighlight>
</syntaxhighlight>

Revision as of 08:17, 18 April 2014


Files and directories on the Linux system belong to an owner and a group. You can set read, write and execute permissions on a file or directory for owner, group and others. Users belong to one or more groups and have its permissions. The command chmod is used to set the permissions, the command chown to change the owner and the command chgrp to change the group.

Show ownership and permissions

ls -l /path/to/files/*
Directory/Link User Group Other Number of links Owner Group Size Modified date/time Object name
- rwx rw- rw- 1 wilbert users 464843 Apr 6 16:09 file1.txt
- rwx rw- rw- 1 wilbert users 1398792 Apr 6 16:09 file2.txt
d rwx rw- rw- 1 wilbert users 4096 Apr 17 23:16 directory

Add, remove and modify users and groups

Disable the root account:

sudo passwd -l root

Enable the root account by specifying a password for it:

sudo passwd

Disable the root account:

sudo passwd -l root

Add a user account and home folder, delete user:

sudo adduser username
sudo deluser username

Lock (l) or unlock (u) a user account:

sudo passwd -l username
sudo passwd -u username

Add or delete a personalized group:

sudo addgroup groupname
sudo delgroup groupname

Add a user to a group:

sudo adduser username groupname

Change permissions on files and directories

User/group:

  • u user/owner
  • g group
  • o other

Permissions:

  • r read
  • w write
  • x execute

Options:

  • -R full recurive
  • + add permission
  • - remove permission

Examples:

sudo chmod -R u+rwx /path/to/files
sudo chmod -R go-x /path/to/files

Change ownership of files and directories

Owner:

sudo chown -R user /path/to/files

Group:

sudo chgrp -R group /path/to/files