2
Most read
8
Most read
17
Most read
Users, Groups and Permissions
Linux File Security Overview
• Linux file security is the most basic access (authentication)
and rights (authorization) management mechanism
• Standard Linux/UNIX security includes:
 User and Password authentication
 File & Directory access control
and has several more advanced features
Linux/UNIX Accounts
• Each user has a unique ID (UID)
• Each user is a part of at least one group.
• Each group has a unique group ID (GID)
• There are three types of users:
 Super User: also known as “root”, has full access to all the resources
in the system without any restrictions; its UID is 0.
 Regular Users: Normally have access to their own home-directory
only; their UID’s will always be greater than 100.
 Pseudo Users: Accounts that arrived built-into the system and do not
reflect “real” users.
Users & Groups in Linux
• The system supports multiple users that have distinct
properties and permissions.
• Linux defines groups to which a user can belong; groups add
another level of file access permissions.
• A user can belong up to 16 different groups but can only
belong to one primary group at any given time.
• The primary group of a user is applied as the “owning” group
on any files or directories that user creates.
/etc/passwd File
• The /etc/passwd is a semicolon delimited file which lists and
defines the system’s user accounts.
• Each entry in the file represents a user account:
 nir:x:500:500:Nir:/home/nir:/bin/bash
• Let’s break down a user entry, from left to right:
 1) This is the username.
 2) This field is a representation of the legacy password field; in
modern systems, the passwords are kept encrypted in /etc/shadow
instead of as plain text in /etc/passwd.
 3) The account’s UID.
 4) The account’s primary GID.
 5) The account’s comment section.
 6) The account’s home-directory location.
 7) A command to execute upon user log-in; normally, this section is
used to set the account’s default shell, as seen in this example.
/etc/shadow File
• The /etc/shadow file holds the account passwords and their
related settings:
 test:$1$oifwRIGr$SrDXfaxnvcoFUmR0IPW7a0:15172:0:99999:7:::
• The entry broken down, left to right:
 1) This is the username.
 2) The encrypted password.
 3) Last password change; the measure here is in days since January 1st
, 1970
which is the first day of the UNIX-time count.
 4) The minimum number of days required to pass before a user can change
their password again.
 5) The maximum number of days a password is valid for and before the
system forces the user to change it.
 6) The number of days before the password expires in which the system issues
a warning to the user about the upcoming expiry.
 7) The number of days after password expiry after which the account
becomes disabled.
 8) Days since June 1st
, 1970 after which the account may no longer be used.
/etc/group File
• The /etc/group file contains the groups of the system, defines
their GID’s and member user accounts for each group.
 test:x:503:
• Entry explained:
 1) The group’s name.
 2) Password, generally unused unless a privileged group is required.
 3) GID.
 4) Member usernames, separated by a comma ( , )
• There are two ways a user can be assigned to group(s):
 The group number that appears in the 4th
section of the /etc/passwd
file entries; this group is also known as the Primary group for the
account.
 Type the user name(s) in the 4th
section of the entry; the group will
then become an additional group that user is member of, in addition
to the fundamentally required primary group, listed in /etc/passwd.
User & Group Manipulation
• There are a few tools that allow us to manipulate users in
manners of creation, editing and/or removal:
 useradd: This command is used to created new users.
 usermod: This one is used to modify existing users.
 userdel: Deletes existing users.
• “useradd” has the ability to set every single property found in
the /etc/passwd file entries upon creation of a new user; if
no properties are explicitly specificied, it will use the defaults
which can be viewed by running: “useradd –D”.
• Very much like users, there are tools for group manipulation:
 groupadd
 groupmod
 groupdel
Initializaing Users
• When a new user is created, all the files from within /etc/skel
are copied into the new user’s home-directory.
• The sys-admin can edit, customize and create files like
.bash_profile and/or .bashrc, amongst others, that once a
new user is created – they would automatically have a pre-
defined, working environment which is not necessarily the
default basic one.
• Note, once a user has been created and the files were copied
from /etc/skel to his home directory, the only way to change
them would be to edit them directly in that specific user’s
home directory.
• Important environment variables such as PATH should be set
system-wide using /etc/profile
Changing User Passwords
• Aside from the users file, /etc/passwd, there is also a
command named “passwd”.
• “passwd” is used to change user passwords.
• In order to change the password of the currently logged-on
user, just type passwd and hit enter.
• We’ll be prompted for the current password then the new
password we wish to have and a new password re-type
verification.
• While logged on as the “root”, we are able to change
password for any user we wish by running: “passwd
[username]”.
File Ownership
• Each file and/or directory in Linux is owned by a single user
and belongs to a single group.
• The ownership details are assigned at the time the file or
directory are created.
• Note that user and group ownerships distinct; it is possible for
a user to own a file but not be a member of the owning
group.
 -rwxrwxr-- 1 user1 group1 35 Jul 19 13:42 file2
• The user ownership is colored in green and the group
ownership in light-blue in the above example.
Access Modes
• There are three access modes:
 Read, designated “r”
 Write, designated “w”
 Execute, designated “x”
• The meanings of the above access modes differ for files and
directories:
 Files:
 Read: Access to view the file’s contents.
 Write: Access to change the contents.
 Execute: Access to execute the file (binary or shell script).
 Directories:
 Read: Access to view the directory’s contents.
 Write: Access to change the directory’s contents (create or delete files)
 Execute: Access to enter the directory (with the “cd” command).
Access Modes
• Every file and directory are affected by 3 sets of the above
access modes:
 -rwxrwxrwx 1 nir test 35 Jul 19 13:42 file2
• The first set (green) refers to user access, in this example’s
case the owning user is “nir”.
• The second set (red) refers to group access, “test” in this
case; all members of the group “test” are currently allowed to
read, write and execute the file.
• The third set (blue) refers to “other” which affects any user or
group that are not explicitly set as one of the owners.
• In the above example, anyone and everyone can read, write
and execute the file.
Changing Ownerships
• By default, only the super-user (root) can change ownerships
for files and/or directories.
• In order to change Group ownership only, we’d use the
following command:
 chgrp [groupname] [filename(s)]
• If we wish to change both user and group ownerships, we’d
use:
 chown [username]:[groupname] [filename(s)]
Changing Access Modes
• The only ones allowed to change access modes on files and
directories are the owners and the super-user (root).
• The “chmod” command is used to change access modes;
there are two methods of usage:
 Symbolic Mode: uses a combination of letters and symbols to add or
remove access permissions.
 Octal Mode: Also known as Absolute or Numeric mode; this mode
uses octal numbers that represent the different permissions in order
to add or remove them.
Symbolic “chmod”
• The command’s syntax is:
 chmod [who][operation][permission(s)] [filename(s)]
• List of “who”:
 a: all; this includes user, group and other.
 u: user.
 g: group.
 o: other.
• List of operations:
 + : add permission, for example: chmod u+r /tmp/test/file
 - : remove permission, chmod g-x /tmp/test/file
 = : match permissions, chmod a=rw /tmp/test/*
Octal (Absolute) “chmod”
• The command’s syntax is:
 chmod [octal mode] [filename(s)]
• The octal modes are:
 Read: 4
 Write: 2
 Execute: 1
• Any combination of the above numbers would set the file’s
permissions:
 644 = rw-r--r--
 755 = rwxr-xr-x
 700 = rwx------
 777 = rwxrwxrwx
Setting access modes with umask
• The “umask” filter determines the default permissions for
newly created files and folders.
• Display the currently set umask by running: “umask”:
 # umask
0002
• The digits in the umask value represent permissions that are
to be “masked-out” from the maximum values of “777”; the
masked permissions will Not be used when a new file or
directory are created.
• This setting can be changed temporarily for the current
session by running: “umask [octal value]”
• In order to make the umask change permanent, it must be
added into the user’s initialization files.
Advanced Permissions - SUID
• SUID or SetUID is an additional permission bit that can be
added to files or directories.
• When running an application or a shell script in Linux, the
program will have the same permissions and access rights to
the system as the user who executed it does.
• Some applications require elevated permissions so that they
can access system files to achieve the desired results,
however we as administrators, do not want to grant special
permissions to regular users.
• This is when SUID comes in handy; it can be assigned to the
executable program or script and when those run, by any
user, the program would have elevated permissions, similar
to a super-user’s permissions.
Advanced Permissions - SUID
• Very important note: SUID is to be given ONLY to programs
you know exactly what they are and trust them completely.
• Keep in mind that super-user permissions give complete
control over the entire system and its contents to the user
and/or application holding them.
• To apply SUID on a file or directory, run “chmod” with an
additional number at the beginning of the octal permissions
value:
 # chmod 4422 file_list
# ls -l | grep file_list
-r-S-w--w- 1 nir test 336 Jul 20 10:47 file_list
• The upper case “S” is the SUID flag.
• To remove SUID, run the same chmod command with 0
instead of 4 as the first number in the octal value.
Introduction to Linux ACL
• “ACL” stands for “Access Control List”.
• ACL can be applied on files and directories in the system and
are an addition to the standard User/Group/Other “rwx”
permission model.
• ACL give another level of control over who can read, write
and execute files.
• Linux kernel v2.6 and higher supports ACL for numerous file-
system types:
 EXT3
 EXT2
 XFS
 JFS
 ReiserFS
Introduction to Linux ACL’s
• A pre-requisite for using ACL is that the files-ystem we wish to
apply ACLs on is mounted with the “acl” option enabled.
• The commands used when setting and displaying ACL
information are:
 getfacl: display ACL settings
getfacl filename
 setfacl: set acl settings
setfacl [options] [filename(s)]
Introduction to Linux ACL’s
• setfacl options
– -m type:name:rwx add permission of ‘rwx’ for user or
group ‘name’. ‘t’ should be ‘u’ for user, ‘g’ for group or ‘m’
in order to set the mask for this file
– -M file adds permission according to the information in
‘file’ (this file should in ‘getfacl’ format)
– -x type:name remove permissions to user or group
‘name’
– -b removes all of the permission records on ACL
Introduction to Linux ACL’s
# getfacl file1
file: file1
owner: root
group: root
user::rw-
group::r--
other::r--
# setfacl -m u:user1:rwx file1
# getfacl file1
file: file1
owner: root
group: root
user::rw-
user:user1:rwx
group::r--
mask::rwx
other::r--
# getfacl file1
file: file1
owner: root
group: root
user::rw-
group::r--
other::r--
# setfacl -m u:user1:rwx file1
# getfacl file1
file: file1
owner: root
group: root
user::rw-
user:user1:rwx
group::r--
mask::rwx
other::r--
# setfacl -m m::r-- file1
# getfacl file1
# file: file1
# owner: root
# group: root
user::rw-
user:user1:rwx #effective:r--
group::r--
mask::r--
other::r--
# setfacl -m m::r-- file1
# getfacl file1
# file: file1
# owner: root
# group: root
user::rw-
user:user1:rwx #effective:r--
group::r--
mask::r--
other::r--

More Related Content

PPTX
Users and groups
PPTX
Linux User Management
PPTX
File permission in linux
PDF
Users and groups in Linux
PDF
Course 102: Lecture 14: Users and Permissions
PPTX
Unix Linux Commands Presentation 2013
PPT
Unix/Linux Basic Commands and Shell Script
PPTX
Introduction 2 linux
Users and groups
Linux User Management
File permission in linux
Users and groups in Linux
Course 102: Lecture 14: Users and Permissions
Unix Linux Commands Presentation 2013
Unix/Linux Basic Commands and Shell Script
Introduction 2 linux

What's hot (20)

PPTX
Linux basics part 1
PPSX
User Administration in Linux
PDF
Presentation on linux
PPTX
User management
PDF
Linux systems - Linux Commands and Shell Scripting
PPTX
File permissions
PPTX
User and groups administrator
PPT
Shell Scripting in Linux
PPTX
Filepermissions in linux
PDF
Sa1 chapter-5-managing-local-linux-users-and-groups-v2 (4)
PDF
Linux directory structure by jitu mistry
PPT
Active directory and application
PPTX
Overview of Microsoft Exchange Server
PPT
Linux file system
PPT
Introduction to SSH
PDF
Course 102: Lecture 26: FileSystems in Linux (Part 1)
PPTX
Disk quota and sysd procd
PDF
Intro to Linux Shell Scripting
PPT
Linux files and file permission
PPTX
Windows Server 2019.pptx
Linux basics part 1
User Administration in Linux
Presentation on linux
User management
Linux systems - Linux Commands and Shell Scripting
File permissions
User and groups administrator
Shell Scripting in Linux
Filepermissions in linux
Sa1 chapter-5-managing-local-linux-users-and-groups-v2 (4)
Linux directory structure by jitu mistry
Active directory and application
Overview of Microsoft Exchange Server
Linux file system
Introduction to SSH
Course 102: Lecture 26: FileSystems in Linux (Part 1)
Disk quota and sysd procd
Intro to Linux Shell Scripting
Linux files and file permission
Windows Server 2019.pptx
Ad

Viewers also liked (15)

PDF
OLPC Presentation for Jamaica Linux Users Group
DOC
Introduction to Qt Designer
PDF
JMILUG Introduction - 2007
PDF
Shell Script Linux
PDF
100th Kernel code reading party
PPTX
Red hat linux essentials
PPTX
Different types of Editors in Linux
PPTX
Shell scripting
PPTX
Kernel (computing)
PPT
Kernel mode vs user mode in linux
PPT
Shell programming
PPTX
Unix Operating System
PPTX
Linux.ppt
OLPC Presentation for Jamaica Linux Users Group
Introduction to Qt Designer
JMILUG Introduction - 2007
Shell Script Linux
100th Kernel code reading party
Red hat linux essentials
Different types of Editors in Linux
Shell scripting
Kernel (computing)
Kernel mode vs user mode in linux
Shell programming
Unix Operating System
Linux.ppt
Ad

Similar to 06 users groups_and_permissions (20)

PPTX
Lecturehjiwiiiwiiiwiiiiwiiijjwjiwii.pptx
PPTX
Chapter 3 LectureChapter 3 LectureChapter 3 Lecture.pptx
PPT
Unix Administration 3
PPTX
Licão 04 permissions
PPT
UNIX -File attributes and permissions; The Security Implications
PPTX
Topic 3-1_More_Linux_Commands.pptx
PDF
File Access Permission
PDF
Linux Security
PPTX
Ai module
PPT
Learning Linux v2.1
PPT
101 4.5 manage file permissions and ownership v3
PPTX
Users and Groups in Linux for beginners.
PPT
4.5 manage file permissions and ownership v3
PPT
Host security
PPT
Host security
PPT
Basic Linux
PPT
Lession1 Linux Preview
PPT
OS Unit IV.ppt
DOCX
With respect to the security aspects of Linux- answer the following qu.docx
PPTX
Oerating system project
Lecturehjiwiiiwiiiwiiiiwiiijjwjiwii.pptx
Chapter 3 LectureChapter 3 LectureChapter 3 Lecture.pptx
Unix Administration 3
Licão 04 permissions
UNIX -File attributes and permissions; The Security Implications
Topic 3-1_More_Linux_Commands.pptx
File Access Permission
Linux Security
Ai module
Learning Linux v2.1
101 4.5 manage file permissions and ownership v3
Users and Groups in Linux for beginners.
4.5 manage file permissions and ownership v3
Host security
Host security
Basic Linux
Lession1 Linux Preview
OS Unit IV.ppt
With respect to the security aspects of Linux- answer the following qu.docx
Oerating system project

More from Shay Cohen (19)

PPT
Linux Performance Tunning Memory
PPT
Linux Performance Tunning Kernel
PPT
Linux Performance Tunning introduction
ODP
chroot and SELinux
ODP
Linux Internals - Kernel/Core
PPTX
Infra / Cont delivery - 3rd party automation
PPTX
14 network tools
PPTX
13 process management
PPTX
12 linux archiving tools
PPTX
11 linux filesystem copy
PPTX
10 finding files
PPT
08 text processing_tools
PPT
07 vi text_editor
PPT
05 standard io_and_pipes
PPT
04 using and_configuring_bash
PPT
03 browsing the filesystem
PPT
02 linux desktop usage
PPT
09 string processing_with_regex copy
PPT
01 linux history overview
Linux Performance Tunning Memory
Linux Performance Tunning Kernel
Linux Performance Tunning introduction
chroot and SELinux
Linux Internals - Kernel/Core
Infra / Cont delivery - 3rd party automation
14 network tools
13 process management
12 linux archiving tools
11 linux filesystem copy
10 finding files
08 text processing_tools
07 vi text_editor
05 standard io_and_pipes
04 using and_configuring_bash
03 browsing the filesystem
02 linux desktop usage
09 string processing_with_regex copy
01 linux history overview

Recently uploaded (20)

PDF
Auditboard EB SOX Playbook 2023 edition.
PDF
SaaS reusability assessment using machine learning techniques
PDF
Human Computer Interaction Miterm Lesson
PDF
Connector Corner: Transform Unstructured Documents with Agentic Automation
PDF
Rapid Prototyping: A lecture on prototyping techniques for interface design
PDF
zbrain.ai-Scope Key Metrics Configuration and Best Practices.pdf
PDF
Transform-Your-Factory-with-AI-Driven-Quality-Engineering.pdf
PDF
AI.gov: A Trojan Horse in the Age of Artificial Intelligence
PDF
ment.tech-Siri Delay Opens AI Startup Opportunity in 2025.pdf
PDF
Data Virtualization in Action: Scaling APIs and Apps with FME
PDF
A hybrid framework for wild animal classification using fine-tuned DenseNet12...
PDF
giants, standing on the shoulders of - by Daniel Stenberg
PDF
IT-ITes Industry bjjbnkmkhkhknbmhkhmjhjkhj
PDF
LMS bot: enhanced learning management systems for improved student learning e...
PPTX
SGT Report The Beast Plan and Cyberphysical Systems of Control
PPTX
Internet of Everything -Basic concepts details
PDF
The AI Revolution in Customer Service - 2025
PPTX
AI-driven Assurance Across Your End-to-end Network With ThousandEyes
PDF
5-Ways-AI-is-Revolutionizing-Telecom-Quality-Engineering.pdf
PDF
Advancing precision in air quality forecasting through machine learning integ...
Auditboard EB SOX Playbook 2023 edition.
SaaS reusability assessment using machine learning techniques
Human Computer Interaction Miterm Lesson
Connector Corner: Transform Unstructured Documents with Agentic Automation
Rapid Prototyping: A lecture on prototyping techniques for interface design
zbrain.ai-Scope Key Metrics Configuration and Best Practices.pdf
Transform-Your-Factory-with-AI-Driven-Quality-Engineering.pdf
AI.gov: A Trojan Horse in the Age of Artificial Intelligence
ment.tech-Siri Delay Opens AI Startup Opportunity in 2025.pdf
Data Virtualization in Action: Scaling APIs and Apps with FME
A hybrid framework for wild animal classification using fine-tuned DenseNet12...
giants, standing on the shoulders of - by Daniel Stenberg
IT-ITes Industry bjjbnkmkhkhknbmhkhmjhjkhj
LMS bot: enhanced learning management systems for improved student learning e...
SGT Report The Beast Plan and Cyberphysical Systems of Control
Internet of Everything -Basic concepts details
The AI Revolution in Customer Service - 2025
AI-driven Assurance Across Your End-to-end Network With ThousandEyes
5-Ways-AI-is-Revolutionizing-Telecom-Quality-Engineering.pdf
Advancing precision in air quality forecasting through machine learning integ...

06 users groups_and_permissions

  • 1. Users, Groups and Permissions
  • 2. Linux File Security Overview • Linux file security is the most basic access (authentication) and rights (authorization) management mechanism • Standard Linux/UNIX security includes:  User and Password authentication  File & Directory access control and has several more advanced features
  • 3. Linux/UNIX Accounts • Each user has a unique ID (UID) • Each user is a part of at least one group. • Each group has a unique group ID (GID) • There are three types of users:  Super User: also known as “root”, has full access to all the resources in the system without any restrictions; its UID is 0.  Regular Users: Normally have access to their own home-directory only; their UID’s will always be greater than 100.  Pseudo Users: Accounts that arrived built-into the system and do not reflect “real” users.
  • 4. Users & Groups in Linux • The system supports multiple users that have distinct properties and permissions. • Linux defines groups to which a user can belong; groups add another level of file access permissions. • A user can belong up to 16 different groups but can only belong to one primary group at any given time. • The primary group of a user is applied as the “owning” group on any files or directories that user creates.
  • 5. /etc/passwd File • The /etc/passwd is a semicolon delimited file which lists and defines the system’s user accounts. • Each entry in the file represents a user account:  nir:x:500:500:Nir:/home/nir:/bin/bash • Let’s break down a user entry, from left to right:  1) This is the username.  2) This field is a representation of the legacy password field; in modern systems, the passwords are kept encrypted in /etc/shadow instead of as plain text in /etc/passwd.  3) The account’s UID.  4) The account’s primary GID.  5) The account’s comment section.  6) The account’s home-directory location.  7) A command to execute upon user log-in; normally, this section is used to set the account’s default shell, as seen in this example.
  • 6. /etc/shadow File • The /etc/shadow file holds the account passwords and their related settings:  test:$1$oifwRIGr$SrDXfaxnvcoFUmR0IPW7a0:15172:0:99999:7::: • The entry broken down, left to right:  1) This is the username.  2) The encrypted password.  3) Last password change; the measure here is in days since January 1st , 1970 which is the first day of the UNIX-time count.  4) The minimum number of days required to pass before a user can change their password again.  5) The maximum number of days a password is valid for and before the system forces the user to change it.  6) The number of days before the password expires in which the system issues a warning to the user about the upcoming expiry.  7) The number of days after password expiry after which the account becomes disabled.  8) Days since June 1st , 1970 after which the account may no longer be used.
  • 7. /etc/group File • The /etc/group file contains the groups of the system, defines their GID’s and member user accounts for each group.  test:x:503: • Entry explained:  1) The group’s name.  2) Password, generally unused unless a privileged group is required.  3) GID.  4) Member usernames, separated by a comma ( , ) • There are two ways a user can be assigned to group(s):  The group number that appears in the 4th section of the /etc/passwd file entries; this group is also known as the Primary group for the account.  Type the user name(s) in the 4th section of the entry; the group will then become an additional group that user is member of, in addition to the fundamentally required primary group, listed in /etc/passwd.
  • 8. User & Group Manipulation • There are a few tools that allow us to manipulate users in manners of creation, editing and/or removal:  useradd: This command is used to created new users.  usermod: This one is used to modify existing users.  userdel: Deletes existing users. • “useradd” has the ability to set every single property found in the /etc/passwd file entries upon creation of a new user; if no properties are explicitly specificied, it will use the defaults which can be viewed by running: “useradd –D”. • Very much like users, there are tools for group manipulation:  groupadd  groupmod  groupdel
  • 9. Initializaing Users • When a new user is created, all the files from within /etc/skel are copied into the new user’s home-directory. • The sys-admin can edit, customize and create files like .bash_profile and/or .bashrc, amongst others, that once a new user is created – they would automatically have a pre- defined, working environment which is not necessarily the default basic one. • Note, once a user has been created and the files were copied from /etc/skel to his home directory, the only way to change them would be to edit them directly in that specific user’s home directory. • Important environment variables such as PATH should be set system-wide using /etc/profile
  • 10. Changing User Passwords • Aside from the users file, /etc/passwd, there is also a command named “passwd”. • “passwd” is used to change user passwords. • In order to change the password of the currently logged-on user, just type passwd and hit enter. • We’ll be prompted for the current password then the new password we wish to have and a new password re-type verification. • While logged on as the “root”, we are able to change password for any user we wish by running: “passwd [username]”.
  • 11. File Ownership • Each file and/or directory in Linux is owned by a single user and belongs to a single group. • The ownership details are assigned at the time the file or directory are created. • Note that user and group ownerships distinct; it is possible for a user to own a file but not be a member of the owning group.  -rwxrwxr-- 1 user1 group1 35 Jul 19 13:42 file2 • The user ownership is colored in green and the group ownership in light-blue in the above example.
  • 12. Access Modes • There are three access modes:  Read, designated “r”  Write, designated “w”  Execute, designated “x” • The meanings of the above access modes differ for files and directories:  Files:  Read: Access to view the file’s contents.  Write: Access to change the contents.  Execute: Access to execute the file (binary or shell script).  Directories:  Read: Access to view the directory’s contents.  Write: Access to change the directory’s contents (create or delete files)  Execute: Access to enter the directory (with the “cd” command).
  • 13. Access Modes • Every file and directory are affected by 3 sets of the above access modes:  -rwxrwxrwx 1 nir test 35 Jul 19 13:42 file2 • The first set (green) refers to user access, in this example’s case the owning user is “nir”. • The second set (red) refers to group access, “test” in this case; all members of the group “test” are currently allowed to read, write and execute the file. • The third set (blue) refers to “other” which affects any user or group that are not explicitly set as one of the owners. • In the above example, anyone and everyone can read, write and execute the file.
  • 14. Changing Ownerships • By default, only the super-user (root) can change ownerships for files and/or directories. • In order to change Group ownership only, we’d use the following command:  chgrp [groupname] [filename(s)] • If we wish to change both user and group ownerships, we’d use:  chown [username]:[groupname] [filename(s)]
  • 15. Changing Access Modes • The only ones allowed to change access modes on files and directories are the owners and the super-user (root). • The “chmod” command is used to change access modes; there are two methods of usage:  Symbolic Mode: uses a combination of letters and symbols to add or remove access permissions.  Octal Mode: Also known as Absolute or Numeric mode; this mode uses octal numbers that represent the different permissions in order to add or remove them.
  • 16. Symbolic “chmod” • The command’s syntax is:  chmod [who][operation][permission(s)] [filename(s)] • List of “who”:  a: all; this includes user, group and other.  u: user.  g: group.  o: other. • List of operations:  + : add permission, for example: chmod u+r /tmp/test/file  - : remove permission, chmod g-x /tmp/test/file  = : match permissions, chmod a=rw /tmp/test/*
  • 17. Octal (Absolute) “chmod” • The command’s syntax is:  chmod [octal mode] [filename(s)] • The octal modes are:  Read: 4  Write: 2  Execute: 1 • Any combination of the above numbers would set the file’s permissions:  644 = rw-r--r--  755 = rwxr-xr-x  700 = rwx------  777 = rwxrwxrwx
  • 18. Setting access modes with umask • The “umask” filter determines the default permissions for newly created files and folders. • Display the currently set umask by running: “umask”:  # umask 0002 • The digits in the umask value represent permissions that are to be “masked-out” from the maximum values of “777”; the masked permissions will Not be used when a new file or directory are created. • This setting can be changed temporarily for the current session by running: “umask [octal value]” • In order to make the umask change permanent, it must be added into the user’s initialization files.
  • 19. Advanced Permissions - SUID • SUID or SetUID is an additional permission bit that can be added to files or directories. • When running an application or a shell script in Linux, the program will have the same permissions and access rights to the system as the user who executed it does. • Some applications require elevated permissions so that they can access system files to achieve the desired results, however we as administrators, do not want to grant special permissions to regular users. • This is when SUID comes in handy; it can be assigned to the executable program or script and when those run, by any user, the program would have elevated permissions, similar to a super-user’s permissions.
  • 20. Advanced Permissions - SUID • Very important note: SUID is to be given ONLY to programs you know exactly what they are and trust them completely. • Keep in mind that super-user permissions give complete control over the entire system and its contents to the user and/or application holding them. • To apply SUID on a file or directory, run “chmod” with an additional number at the beginning of the octal permissions value:  # chmod 4422 file_list # ls -l | grep file_list -r-S-w--w- 1 nir test 336 Jul 20 10:47 file_list • The upper case “S” is the SUID flag. • To remove SUID, run the same chmod command with 0 instead of 4 as the first number in the octal value.
  • 21. Introduction to Linux ACL • “ACL” stands for “Access Control List”. • ACL can be applied on files and directories in the system and are an addition to the standard User/Group/Other “rwx” permission model. • ACL give another level of control over who can read, write and execute files. • Linux kernel v2.6 and higher supports ACL for numerous file- system types:  EXT3  EXT2  XFS  JFS  ReiserFS
  • 22. Introduction to Linux ACL’s • A pre-requisite for using ACL is that the files-ystem we wish to apply ACLs on is mounted with the “acl” option enabled. • The commands used when setting and displaying ACL information are:  getfacl: display ACL settings getfacl filename  setfacl: set acl settings setfacl [options] [filename(s)]
  • 23. Introduction to Linux ACL’s • setfacl options – -m type:name:rwx add permission of ‘rwx’ for user or group ‘name’. ‘t’ should be ‘u’ for user, ‘g’ for group or ‘m’ in order to set the mask for this file – -M file adds permission according to the information in ‘file’ (this file should in ‘getfacl’ format) – -x type:name remove permissions to user or group ‘name’ – -b removes all of the permission records on ACL
  • 24. Introduction to Linux ACL’s # getfacl file1 file: file1 owner: root group: root user::rw- group::r-- other::r-- # setfacl -m u:user1:rwx file1 # getfacl file1 file: file1 owner: root group: root user::rw- user:user1:rwx group::r-- mask::rwx other::r-- # getfacl file1 file: file1 owner: root group: root user::rw- group::r-- other::r-- # setfacl -m u:user1:rwx file1 # getfacl file1 file: file1 owner: root group: root user::rw- user:user1:rwx group::r-- mask::rwx other::r-- # setfacl -m m::r-- file1 # getfacl file1 # file: file1 # owner: root # group: root user::rw- user:user1:rwx #effective:r-- group::r-- mask::r-- other::r-- # setfacl -m m::r-- file1 # getfacl file1 # file: file1 # owner: root # group: root user::rw- user:user1:rwx #effective:r-- group::r-- mask::r-- other::r--

Editor's Notes

  • #3: Discuss: in Linux everything is a file and every action is done with at least two files (or two types of access types)
  • #4: Discussion: Identities in Linux
  • #11: Exercise: - create a new user - again, by editing the user files
  • #21: Exercise: man chmod to find about sticky bit Discussion about Sticky bit
  • #24: Explain about mask in unix again Remind of the format. Explain the greatness' of working this way, making the form of output and input the same. Remind the importance of command line interface
  • #25: Exercise: Add a simple permission to a file’s ACL. Can you find any indication that the file has an ACL except for getfacl output ?