Location via proxy:   [ UP ]  
[Report a bug]   [Manage cookies]                
0% found this document useful (0 votes)
7 views16 pages

Lecture 18.10.2017

Download as pdf or txt
Download as pdf or txt
Download as pdf or txt
You are on page 1/ 16

Linux System Administration

Permissions
Managing Users, Groups

By ENG. ALI AL-OBAL


2017
Review

Some of commands Boot Sequence


#touch
#ls
#cat
#tac
#pwd
#whoami
#history
#clear
#cd
Review

Grub

Windows 10
Users and Groups

Linux understands Users and Groups


A user can belong to several groups
A file can belong to only one user and one
group at a time
A particular user, the superuser “root” has extra
privileges (uid = “0” in /etc/passwd)
Only root can change the ownership of a file
In GUI: Applications  System Settings  Users and Groups
Users and Groups cont.

User information in /etc/passwd


Password info is in /etc/shadow
Group information is in /etc/group
/etc/passwd and /etc/group divide data
fields using “:”
/etc/passwd:
joeuser:x:1000:1000:Joe User,,,:/home/joeuser:/bin/bash

/etc/group:
joeuser:x:1000:
/etc/passwd File

/etc/passwd Holds user account info


Included fields are:
1. Login name (user name)
2. Password type
3. User Id (uid)
4. Group Id (gid)
5. General Comment about the user
6. Home Directory
7. Shell
/etc/passwd File
A program in detail

When we type:
ls -l /usr/bin/top
We'll see:
-rwxr-xr-x 1 root root 68524 2011-12-19 07:18 /usr/bin/top

What does all this mean?


-r-xr-xr-x 1 root root 68524 2011-12-19 07:18 /usr/bin/top

---------- --- ------- ------- -------- ------------ -------------


| | | | | | |
| | | | | | File Name
| | | | | |
| | | | | +--- Modification Time/Date
| | | | |
| | | | +------------- Size (in bytes
| | | |
| | | +----------------------- Group
| | |
| | +-------------------------------- Owner
| |
| +-------------------------------------- “link count”
|
+---------------------------------------------- File Permissions
Group
The name of the group that has permissions in addition to the file's owner.
Owner
The name of the user who owns the file.
File Permissions
The first character is the type of file. A "-" indicates a regular (ordinary) file. A "d”
indicate a directory. Second set of 3 characters represent the read, write, and execution
rights of the file's owner. Next 3 represent the rights of the file's group, and the final
3 represent the rights granted to everybody else.

(Example modified from http://www.linuxcommand.org/lts0030.php)


Some special cases

When looking at the output from “ls -l” in the


first column you might see:
d = directory
- = regular file
l = symbolic link
s = Unix domain socket
p = named pipe
c = character device file
b = block device file
File permissions

There are two ways to set permissions when


using the chmod command:
Symbolic mode:
testfile has permissions of -r--r--r--
U G O*
$ chmod g+x testfile ==> -r--r-xr--
$ chmod u+wx testfile ==> -rwxr-xr--
$ chmod ug-x testfile ==> -rw--r--r--
U=user, G=group, O=other (world)
File permissions cont.

Absolute mode:
We use octal (base eight) values represented like this:
Letter Permission Value
R read 4
W write 2
X execute 1
- none 0

For each column, User, Group or Other you can set


values from 0 to 7. Here is what each means:
0= --- 1= --x 2= -w- 3= -wx
4= r-- 5= r-x 6= rw- 7= rwx
File permissions cont.

Numeric mode cont:


Example index.html file with typical permission values:
$ chmod 755 index.html
$ ls -l index.html
-rwxr-xr-x 1 root wheel 0 May 24 06:20 index.html

$ chmod 644 index.html


$ ls -l index.html
-rw-r--r-- 1 root wheel 0 May 24 06:20 index.html

You might also like