OS: Linux(Debian) User: root
UNIX/Linux has no per-user permissions/rights/policies. Everything is done on files, making sure who can read/write/exectute the right files. To check the current permissions of files, run "ls -l". If you run "ls -l /", to list all files in the root directory, you will get output that looks something like this:
drwxr-xr-x 2 root root 4096 2003-07-15 22:41 bin
drwxr-xr-x 4 root root 1024 2003-07-16 03:26 boot
drwxr-xr-x 20 root root 118784 2003-07-16 03:32 dev
The first column (that looks like drwxr-xr-x) is the mode of the file. The first character indicates what kind of file it is. d, as in this case, means directory. - means regular file, and then there are some other file types of which you need not know more now, like named FIFOs, sockets, devices, etc. The rwxr-xr-x is the permissions of file. The first rwx means that the owner of the file can read, write and execute the file. For directories, the right to execute it means the right to use it. Just being able to read a directory means that you can read what files are in the directory, but you won't be able to use them without the execute permission on the directory. The first r-x means that those that are in the same group as the file have read and execute permissions to the file.
The second r-x means that all those that are neither the owner of the file nor are in the same group as the file have read and execute permissions on it. So r=read, w=write and x=execute, and the first group of three applies to the owner of the file, the second group applies to those in the same group of the file, and the third group applies to all other users. The second column (2, 4 and 20 in this case) is the number of links that the file has. Don't care about that for now. The third column is the owner of the file, in this case root. The fourth column is the group of the file, in this case the root group.
The fifth column is the size of the file. The sixth is the time the file was last modified The seventh is naturally the name of the file.
Picture Summary:
chmod /change the permissions of a file/
chown /change the owner of the file/
chgrp /change the group that the file belongs to/
example:
chmod 777 somefile.file /*
This gives exe write and read to all */ not recommended for any file.
for chmod here is a list of the numbers and what they meen
the 100's are for the owner of the file 400 read 200 write 100 execute
10's are for the group of the file 40 read 20 write 10 execute
1's are for everyone else 4 read 2 write 1 execute
you add the number together to get different permmisions
Example: How to change owner and owner group of a file
chown -R sabnzbd:sabnzbd sabnzbd/
- -R: Recursive, own directory and all contents
How to add a user to a group:
usermod -a -G <groupname> username
Change user's primary group:
usermod -g <groupname> username
What group user is assigned to:
id <username>
View all groups:
groups or users
Add new user and assign group:
useradd -g <groupname> username
Add single user to multiple groups:
usermod -a -G ftp,admins,othergroup <username>
Assign user a password:
passwd jsmith
Add a group:
groupadd <groupname>