SlideShare a Scribd company logo
1 of 24
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

What's hot

Linux User Management
Linux User ManagementLinux User Management
Linux User ManagementGaurav Mishra
 
The basic concept of Linux FIleSystem
The basic concept of Linux FIleSystemThe basic concept of Linux FIleSystem
The basic concept of Linux FIleSystemHungWei Chiu
 
Topic # 12 of outline Configuring Local Services.pptx
Topic # 12 of outline Configuring Local Services.pptxTopic # 12 of outline Configuring Local Services.pptx
Topic # 12 of outline Configuring Local Services.pptxAyeCS11
 
Users and groups in Linux
Users and groups in LinuxUsers and groups in Linux
Users and groups in LinuxKnoldus Inc.
 
Linux Directory Structure
Linux Directory StructureLinux Directory Structure
Linux Directory StructureKevin OBrien
 
Presentation on samba server
Presentation on samba serverPresentation on samba server
Presentation on samba serverVeeral Bhateja
 
User Administration in Linux
User Administration in LinuxUser Administration in Linux
User Administration in LinuxSAMUEL OJO
 
Linux command ppt
Linux command pptLinux command ppt
Linux command pptkalyanineve
 
Linux standard file system
Linux standard file systemLinux standard file system
Linux standard file systemTaaanu01
 
Linux basics part 1
Linux basics part 1Linux basics part 1
Linux basics part 1Lilesh Pathe
 
Complete Guide for Linux shell programming
Complete Guide for Linux shell programmingComplete Guide for Linux shell programming
Complete Guide for Linux shell programmingsudhir singh yadav
 
Introduction to Shell script
Introduction to Shell scriptIntroduction to Shell script
Introduction to Shell scriptBhavesh Padharia
 
Quick Guide with Linux Command Line
Quick Guide with Linux Command LineQuick Guide with Linux Command Line
Quick Guide with Linux Command LineAnuchit Chalothorn
 
Linux basic commands
Linux basic commandsLinux basic commands
Linux basic commandsSagar Kumar
 
Bash shell scripting
Bash shell scriptingBash shell scripting
Bash shell scriptingVIKAS TIWARI
 

What's hot (20)

Linux User Management
Linux User ManagementLinux User Management
Linux User Management
 
The basic concept of Linux FIleSystem
The basic concept of Linux FIleSystemThe basic concept of Linux FIleSystem
The basic concept of Linux FIleSystem
 
Topic # 12 of outline Configuring Local Services.pptx
Topic # 12 of outline Configuring Local Services.pptxTopic # 12 of outline Configuring Local Services.pptx
Topic # 12 of outline Configuring Local Services.pptx
 
Users and groups in Linux
Users and groups in LinuxUsers and groups in Linux
Users and groups in Linux
 
File permission of linux
File permission of linuxFile permission of linux
File permission of linux
 
Filepermissions in linux
Filepermissions in linuxFilepermissions in linux
Filepermissions in linux
 
Linux Directory Structure
Linux Directory StructureLinux Directory Structure
Linux Directory Structure
 
Presentation on samba server
Presentation on samba serverPresentation on samba server
Presentation on samba server
 
User Administration in Linux
User Administration in LinuxUser Administration in Linux
User Administration in Linux
 
Linux command ppt
Linux command pptLinux command ppt
Linux command ppt
 
UNIX/Linux training
UNIX/Linux trainingUNIX/Linux training
UNIX/Linux training
 
Linux standard file system
Linux standard file systemLinux standard file system
Linux standard file system
 
Linux basics part 1
Linux basics part 1Linux basics part 1
Linux basics part 1
 
Complete Guide for Linux shell programming
Complete Guide for Linux shell programmingComplete Guide for Linux shell programming
Complete Guide for Linux shell programming
 
Introduction to Shell script
Introduction to Shell scriptIntroduction to Shell script
Introduction to Shell script
 
Quick Guide with Linux Command Line
Quick Guide with Linux Command LineQuick Guide with Linux Command Line
Quick Guide with Linux Command Line
 
Shell scripting
Shell scriptingShell scripting
Shell scripting
 
Linux basic commands
Linux basic commandsLinux basic commands
Linux basic commands
 
Bash shell scripting
Bash shell scriptingBash shell scripting
Bash shell scripting
 
Linux commands
Linux commandsLinux commands
Linux commands
 

Viewers also liked

Intro to Linux Shell Scripting
Intro to Linux Shell ScriptingIntro to Linux Shell Scripting
Intro to Linux Shell Scriptingvceder
 
OLPC Presentation for Jamaica Linux Users Group
OLPC Presentation for Jamaica Linux Users GroupOLPC Presentation for Jamaica Linux Users Group
OLPC Presentation for Jamaica Linux Users Groupguest335892
 
Introduction to Qt Designer
Introduction to Qt DesignerIntroduction to Qt Designer
Introduction to Qt DesignerSaleem Ansari
 
JMILUG Introduction - 2007
JMILUG Introduction - 2007JMILUG Introduction - 2007
JMILUG Introduction - 2007Saleem Ansari
 
100th Kernel code reading party
100th Kernel code reading party100th Kernel code reading party
100th Kernel code reading partyHiro Yoshioka
 
Red hat linux essentials
Red hat linux essentialsRed hat linux essentials
Red hat linux essentialsHaitham Raik
 
Different types of Editors in Linux
Different types of Editors in LinuxDifferent types of Editors in Linux
Different types of Editors in LinuxBhavik Trivedi
 
Kernel mode vs user mode in linux
Kernel mode vs user mode in linuxKernel mode vs user mode in linux
Kernel mode vs user mode in linuxSiddique Ibrahim
 
Shell Scripting in Linux
Shell Scripting in LinuxShell Scripting in Linux
Shell Scripting in LinuxAnu Chaudhry
 
Unix/Linux Basic Commands and Shell Script
Unix/Linux Basic Commands and Shell ScriptUnix/Linux Basic Commands and Shell Script
Unix/Linux Basic Commands and Shell Scriptsbmguys
 
Unix Operating System
Unix Operating SystemUnix Operating System
Unix Operating Systemsubhsikha
 
Linux.ppt
Linux.ppt Linux.ppt
Linux.ppt onu9
 

Viewers also liked (18)

Intro to Linux Shell Scripting
Intro to Linux Shell ScriptingIntro to Linux Shell Scripting
Intro to Linux Shell Scripting
 
OLPC Presentation for Jamaica Linux Users Group
OLPC Presentation for Jamaica Linux Users GroupOLPC Presentation for Jamaica Linux Users Group
OLPC Presentation for Jamaica Linux Users Group
 
Introduction to Qt Designer
Introduction to Qt DesignerIntroduction to Qt Designer
Introduction to Qt Designer
 
JMILUG Introduction - 2007
JMILUG Introduction - 2007JMILUG Introduction - 2007
JMILUG Introduction - 2007
 
Linux
Linux Linux
Linux
 
Shell Script Linux
Shell Script LinuxShell Script Linux
Shell Script Linux
 
100th Kernel code reading party
100th Kernel code reading party100th Kernel code reading party
100th Kernel code reading party
 
Red hat linux essentials
Red hat linux essentialsRed hat linux essentials
Red hat linux essentials
 
Different types of Editors in Linux
Different types of Editors in LinuxDifferent types of Editors in Linux
Different types of Editors in Linux
 
Shell scripting
Shell scriptingShell scripting
Shell scripting
 
Kernel (computing)
Kernel (computing)Kernel (computing)
Kernel (computing)
 
Kernel mode vs user mode in linux
Kernel mode vs user mode in linuxKernel mode vs user mode in linux
Kernel mode vs user mode in linux
 
Shell Scripting in Linux
Shell Scripting in LinuxShell Scripting in Linux
Shell Scripting in Linux
 
Shell programming
Shell programmingShell programming
Shell programming
 
Unix/Linux Basic Commands and Shell Script
Unix/Linux Basic Commands and Shell ScriptUnix/Linux Basic Commands and Shell Script
Unix/Linux Basic Commands and Shell Script
 
Kernel (OS)
Kernel (OS)Kernel (OS)
Kernel (OS)
 
Unix Operating System
Unix Operating SystemUnix Operating System
Unix Operating System
 
Linux.ppt
Linux.ppt Linux.ppt
Linux.ppt
 

Similar to 06 users groups_and_permissions

Topic 3-1_More_Linux_Commands.pptx
Topic 3-1_More_Linux_Commands.pptxTopic 3-1_More_Linux_Commands.pptx
Topic 3-1_More_Linux_Commands.pptxdulala3
 
File Access Permission
File Access PermissionFile Access Permission
File Access PermissionBIT DURG
 
Learning Linux v2.1
Learning Linux v2.1Learning Linux v2.1
Learning Linux v2.1sdiviney
 
101 4.5 manage file permissions and ownership v3
101 4.5 manage file permissions and ownership v3101 4.5 manage file permissions and ownership v3
101 4.5 manage file permissions and ownership v3Acácio Oliveira
 
4.5 manage file permissions and ownership v3
4.5 manage file permissions and ownership v34.5 manage file permissions and ownership v3
4.5 manage file permissions and ownership v3Acácio Oliveira
 
Lession1 Linux Preview
Lession1 Linux PreviewLession1 Linux Preview
Lession1 Linux Previewleminhvuong
 
With respect to the security aspects of Linux- answer the following qu.docx
With respect to the security aspects of Linux- answer the following qu.docxWith respect to the security aspects of Linux- answer the following qu.docx
With respect to the security aspects of Linux- answer the following qu.docxSUKHI5
 
Oerating system project
Oerating system projectOerating system project
Oerating system projectHira Gul
 
ManagingLocalLinuxUsersandGroups(2)
ManagingLocalLinuxUsersandGroups(2)ManagingLocalLinuxUsersandGroups(2)
ManagingLocalLinuxUsersandGroups(2)Bipul Kumar
 
Linux training in chandigarh.pptx Join Now
Linux training in chandigarh.pptx Join NowLinux training in chandigarh.pptx Join Now
Linux training in chandigarh.pptx Join Nowasmeerana605
 
File permission in Linux
File permission in LinuxFile permission in Linux
File permission in LinuxKrutikMandre1
 

Similar to 06 users groups_and_permissions (20)

Unix Administration 3
Unix Administration 3Unix Administration 3
Unix Administration 3
 
Licão 04 permissions
Licão 04 permissionsLicão 04 permissions
Licão 04 permissions
 
Topic 3-1_More_Linux_Commands.pptx
Topic 3-1_More_Linux_Commands.pptxTopic 3-1_More_Linux_Commands.pptx
Topic 3-1_More_Linux_Commands.pptx
 
File Access Permission
File Access PermissionFile Access Permission
File Access Permission
 
Linux Security
Linux SecurityLinux Security
Linux Security
 
Ai module
Ai module Ai module
Ai module
 
Learning Linux v2.1
Learning Linux v2.1Learning Linux v2.1
Learning Linux v2.1
 
101 4.5 manage file permissions and ownership v3
101 4.5 manage file permissions and ownership v3101 4.5 manage file permissions and ownership v3
101 4.5 manage file permissions and ownership v3
 
4.5 manage file permissions and ownership v3
4.5 manage file permissions and ownership v34.5 manage file permissions and ownership v3
4.5 manage file permissions and ownership v3
 
Host security
Host securityHost security
Host security
 
Host security
Host securityHost security
Host security
 
Basic Linux
Basic LinuxBasic Linux
Basic Linux
 
Lession1 Linux Preview
Lession1 Linux PreviewLession1 Linux Preview
Lession1 Linux Preview
 
OS Unit IV.ppt
OS Unit IV.pptOS Unit IV.ppt
OS Unit IV.ppt
 
With respect to the security aspects of Linux- answer the following qu.docx
With respect to the security aspects of Linux- answer the following qu.docxWith respect to the security aspects of Linux- answer the following qu.docx
With respect to the security aspects of Linux- answer the following qu.docx
 
Oerating system project
Oerating system projectOerating system project
Oerating system project
 
ManagingLocalLinuxUsersandGroups(2)
ManagingLocalLinuxUsersandGroups(2)ManagingLocalLinuxUsersandGroups(2)
ManagingLocalLinuxUsersandGroups(2)
 
7 - User Administration in Red Hat
7 - User Administration in Red Hat7 - User Administration in Red Hat
7 - User Administration in Red Hat
 
Linux training in chandigarh.pptx Join Now
Linux training in chandigarh.pptx Join NowLinux training in chandigarh.pptx Join Now
Linux training in chandigarh.pptx Join Now
 
File permission in Linux
File permission in LinuxFile permission in Linux
File permission in Linux
 

More from Shay Cohen

Linux Performance Tunning Memory
Linux Performance Tunning MemoryLinux Performance Tunning Memory
Linux Performance Tunning MemoryShay Cohen
 
Linux Performance Tunning Kernel
Linux Performance Tunning KernelLinux Performance Tunning Kernel
Linux Performance Tunning KernelShay Cohen
 
Linux Performance Tunning introduction
Linux Performance Tunning introductionLinux Performance Tunning introduction
Linux Performance Tunning introductionShay Cohen
 
chroot and SELinux
chroot and SELinuxchroot and SELinux
chroot and SELinuxShay Cohen
 
Linux Internals - Kernel/Core
Linux Internals - Kernel/CoreLinux Internals - Kernel/Core
Linux Internals - Kernel/CoreShay Cohen
 
Infra / Cont delivery - 3rd party automation
Infra / Cont delivery - 3rd party automationInfra / Cont delivery - 3rd party automation
Infra / Cont delivery - 3rd party automationShay Cohen
 
14 network tools
14 network tools14 network tools
14 network toolsShay Cohen
 
13 process management
13 process management13 process management
13 process managementShay Cohen
 
12 linux archiving tools
12 linux archiving tools12 linux archiving tools
12 linux archiving toolsShay Cohen
 
11 linux filesystem copy
11 linux filesystem copy11 linux filesystem copy
11 linux filesystem copyShay Cohen
 
10 finding files
10 finding files10 finding files
10 finding filesShay Cohen
 
08 text processing_tools
08 text processing_tools08 text processing_tools
08 text processing_toolsShay Cohen
 
07 vi text_editor
07 vi text_editor07 vi text_editor
07 vi text_editorShay Cohen
 
05 standard io_and_pipes
05 standard io_and_pipes05 standard io_and_pipes
05 standard io_and_pipesShay Cohen
 
04 using and_configuring_bash
04 using and_configuring_bash04 using and_configuring_bash
04 using and_configuring_bashShay Cohen
 
03 browsing the filesystem
03 browsing the filesystem03 browsing the filesystem
03 browsing the filesystemShay Cohen
 
02 linux desktop usage
02 linux desktop usage02 linux desktop usage
02 linux desktop usageShay Cohen
 
09 string processing_with_regex copy
09 string processing_with_regex copy09 string processing_with_regex copy
09 string processing_with_regex copyShay Cohen
 
01 linux history overview
01 linux history overview01 linux history overview
01 linux history overviewShay Cohen
 

More from Shay Cohen (19)

Linux Performance Tunning Memory
Linux Performance Tunning MemoryLinux Performance Tunning Memory
Linux Performance Tunning Memory
 
Linux Performance Tunning Kernel
Linux Performance Tunning KernelLinux Performance Tunning Kernel
Linux Performance Tunning Kernel
 
Linux Performance Tunning introduction
Linux Performance Tunning introductionLinux Performance Tunning introduction
Linux Performance Tunning introduction
 
chroot and SELinux
chroot and SELinuxchroot and SELinux
chroot and SELinux
 
Linux Internals - Kernel/Core
Linux Internals - Kernel/CoreLinux Internals - Kernel/Core
Linux Internals - Kernel/Core
 
Infra / Cont delivery - 3rd party automation
Infra / Cont delivery - 3rd party automationInfra / Cont delivery - 3rd party automation
Infra / Cont delivery - 3rd party automation
 
14 network tools
14 network tools14 network tools
14 network tools
 
13 process management
13 process management13 process management
13 process management
 
12 linux archiving tools
12 linux archiving tools12 linux archiving tools
12 linux archiving tools
 
11 linux filesystem copy
11 linux filesystem copy11 linux filesystem copy
11 linux filesystem copy
 
10 finding files
10 finding files10 finding files
10 finding files
 
08 text processing_tools
08 text processing_tools08 text processing_tools
08 text processing_tools
 
07 vi text_editor
07 vi text_editor07 vi text_editor
07 vi text_editor
 
05 standard io_and_pipes
05 standard io_and_pipes05 standard io_and_pipes
05 standard io_and_pipes
 
04 using and_configuring_bash
04 using and_configuring_bash04 using and_configuring_bash
04 using and_configuring_bash
 
03 browsing the filesystem
03 browsing the filesystem03 browsing the filesystem
03 browsing the filesystem
 
02 linux desktop usage
02 linux desktop usage02 linux desktop usage
02 linux desktop usage
 
09 string processing_with_regex copy
09 string processing_with_regex copy09 string processing_with_regex copy
09 string processing_with_regex copy
 
01 linux history overview
01 linux history overview01 linux history overview
01 linux history overview
 

Recently uploaded

Advanced Test Driven-Development @ php[tek] 2024
Advanced Test Driven-Development @ php[tek] 2024Advanced Test Driven-Development @ php[tek] 2024
Advanced Test Driven-Development @ php[tek] 2024Scott Keck-Warren
 
08448380779 Call Girls In Greater Kailash - I Women Seeking Men
08448380779 Call Girls In Greater Kailash - I Women Seeking Men08448380779 Call Girls In Greater Kailash - I Women Seeking Men
08448380779 Call Girls In Greater Kailash - I Women Seeking MenDelhi Call girls
 
My Hashitalk Indonesia April 2024 Presentation
My Hashitalk Indonesia April 2024 PresentationMy Hashitalk Indonesia April 2024 Presentation
My Hashitalk Indonesia April 2024 PresentationRidwan Fadjar
 
Automating Business Process via MuleSoft Composer | Bangalore MuleSoft Meetup...
Automating Business Process via MuleSoft Composer | Bangalore MuleSoft Meetup...Automating Business Process via MuleSoft Composer | Bangalore MuleSoft Meetup...
Automating Business Process via MuleSoft Composer | Bangalore MuleSoft Meetup...shyamraj55
 
IAC 2024 - IA Fast Track to Search Focused AI Solutions
IAC 2024 - IA Fast Track to Search Focused AI SolutionsIAC 2024 - IA Fast Track to Search Focused AI Solutions
IAC 2024 - IA Fast Track to Search Focused AI SolutionsEnterprise Knowledge
 
Tech-Forward - Achieving Business Readiness For Copilot in Microsoft 365
Tech-Forward - Achieving Business Readiness For Copilot in Microsoft 365Tech-Forward - Achieving Business Readiness For Copilot in Microsoft 365
Tech-Forward - Achieving Business Readiness For Copilot in Microsoft 3652toLead Limited
 
CloudStudio User manual (basic edition):
CloudStudio User manual (basic edition):CloudStudio User manual (basic edition):
CloudStudio User manual (basic edition):comworks
 
Understanding the Laravel MVC Architecture
Understanding the Laravel MVC ArchitectureUnderstanding the Laravel MVC Architecture
Understanding the Laravel MVC ArchitecturePixlogix Infotech
 
Swan(sea) Song – personal research during my six years at Swansea ... and bey...
Swan(sea) Song – personal research during my six years at Swansea ... and bey...Swan(sea) Song – personal research during my six years at Swansea ... and bey...
Swan(sea) Song – personal research during my six years at Swansea ... and bey...Alan Dix
 
SIEMENS: RAPUNZEL – A Tale About Knowledge Graph
SIEMENS: RAPUNZEL – A Tale About Knowledge GraphSIEMENS: RAPUNZEL – A Tale About Knowledge Graph
SIEMENS: RAPUNZEL – A Tale About Knowledge GraphNeo4j
 
#StandardsGoals for 2024: What’s new for BISAC - Tech Forum 2024
#StandardsGoals for 2024: What’s new for BISAC - Tech Forum 2024#StandardsGoals for 2024: What’s new for BISAC - Tech Forum 2024
#StandardsGoals for 2024: What’s new for BISAC - Tech Forum 2024BookNet Canada
 
Pigging Solutions in Pet Food Manufacturing
Pigging Solutions in Pet Food ManufacturingPigging Solutions in Pet Food Manufacturing
Pigging Solutions in Pet Food ManufacturingPigging Solutions
 
Maximizing Board Effectiveness 2024 Webinar.pptx
Maximizing Board Effectiveness 2024 Webinar.pptxMaximizing Board Effectiveness 2024 Webinar.pptx
Maximizing Board Effectiveness 2024 Webinar.pptxOnBoard
 
WhatsApp 9892124323 ✓Call Girls In Kalyan ( Mumbai ) secure service
WhatsApp 9892124323 ✓Call Girls In Kalyan ( Mumbai ) secure serviceWhatsApp 9892124323 ✓Call Girls In Kalyan ( Mumbai ) secure service
WhatsApp 9892124323 ✓Call Girls In Kalyan ( Mumbai ) secure servicePooja Nehwal
 
08448380779 Call Girls In Civil Lines Women Seeking Men
08448380779 Call Girls In Civil Lines Women Seeking Men08448380779 Call Girls In Civil Lines Women Seeking Men
08448380779 Call Girls In Civil Lines Women Seeking MenDelhi Call girls
 
Transcript: #StandardsGoals for 2024: What’s new for BISAC - Tech Forum 2024
Transcript: #StandardsGoals for 2024: What’s new for BISAC - Tech Forum 2024Transcript: #StandardsGoals for 2024: What’s new for BISAC - Tech Forum 2024
Transcript: #StandardsGoals for 2024: What’s new for BISAC - Tech Forum 2024BookNet Canada
 
Slack Application Development 101 Slides
Slack Application Development 101 SlidesSlack Application Development 101 Slides
Slack Application Development 101 Slidespraypatel2
 
Making_way_through_DLL_hollowing_inspite_of_CFG_by_Debjeet Banerjee.pptx
Making_way_through_DLL_hollowing_inspite_of_CFG_by_Debjeet Banerjee.pptxMaking_way_through_DLL_hollowing_inspite_of_CFG_by_Debjeet Banerjee.pptx
Making_way_through_DLL_hollowing_inspite_of_CFG_by_Debjeet Banerjee.pptxnull - The Open Security Community
 

Recently uploaded (20)

Advanced Test Driven-Development @ php[tek] 2024
Advanced Test Driven-Development @ php[tek] 2024Advanced Test Driven-Development @ php[tek] 2024
Advanced Test Driven-Development @ php[tek] 2024
 
08448380779 Call Girls In Greater Kailash - I Women Seeking Men
08448380779 Call Girls In Greater Kailash - I Women Seeking Men08448380779 Call Girls In Greater Kailash - I Women Seeking Men
08448380779 Call Girls In Greater Kailash - I Women Seeking Men
 
My Hashitalk Indonesia April 2024 Presentation
My Hashitalk Indonesia April 2024 PresentationMy Hashitalk Indonesia April 2024 Presentation
My Hashitalk Indonesia April 2024 Presentation
 
E-Vehicle_Hacking_by_Parul Sharma_null_owasp.pptx
E-Vehicle_Hacking_by_Parul Sharma_null_owasp.pptxE-Vehicle_Hacking_by_Parul Sharma_null_owasp.pptx
E-Vehicle_Hacking_by_Parul Sharma_null_owasp.pptx
 
Automating Business Process via MuleSoft Composer | Bangalore MuleSoft Meetup...
Automating Business Process via MuleSoft Composer | Bangalore MuleSoft Meetup...Automating Business Process via MuleSoft Composer | Bangalore MuleSoft Meetup...
Automating Business Process via MuleSoft Composer | Bangalore MuleSoft Meetup...
 
IAC 2024 - IA Fast Track to Search Focused AI Solutions
IAC 2024 - IA Fast Track to Search Focused AI SolutionsIAC 2024 - IA Fast Track to Search Focused AI Solutions
IAC 2024 - IA Fast Track to Search Focused AI Solutions
 
The transition to renewables in India.pdf
The transition to renewables in India.pdfThe transition to renewables in India.pdf
The transition to renewables in India.pdf
 
Tech-Forward - Achieving Business Readiness For Copilot in Microsoft 365
Tech-Forward - Achieving Business Readiness For Copilot in Microsoft 365Tech-Forward - Achieving Business Readiness For Copilot in Microsoft 365
Tech-Forward - Achieving Business Readiness For Copilot in Microsoft 365
 
CloudStudio User manual (basic edition):
CloudStudio User manual (basic edition):CloudStudio User manual (basic edition):
CloudStudio User manual (basic edition):
 
Understanding the Laravel MVC Architecture
Understanding the Laravel MVC ArchitectureUnderstanding the Laravel MVC Architecture
Understanding the Laravel MVC Architecture
 
Swan(sea) Song – personal research during my six years at Swansea ... and bey...
Swan(sea) Song – personal research during my six years at Swansea ... and bey...Swan(sea) Song – personal research during my six years at Swansea ... and bey...
Swan(sea) Song – personal research during my six years at Swansea ... and bey...
 
SIEMENS: RAPUNZEL – A Tale About Knowledge Graph
SIEMENS: RAPUNZEL – A Tale About Knowledge GraphSIEMENS: RAPUNZEL – A Tale About Knowledge Graph
SIEMENS: RAPUNZEL – A Tale About Knowledge Graph
 
#StandardsGoals for 2024: What’s new for BISAC - Tech Forum 2024
#StandardsGoals for 2024: What’s new for BISAC - Tech Forum 2024#StandardsGoals for 2024: What’s new for BISAC - Tech Forum 2024
#StandardsGoals for 2024: What’s new for BISAC - Tech Forum 2024
 
Pigging Solutions in Pet Food Manufacturing
Pigging Solutions in Pet Food ManufacturingPigging Solutions in Pet Food Manufacturing
Pigging Solutions in Pet Food Manufacturing
 
Maximizing Board Effectiveness 2024 Webinar.pptx
Maximizing Board Effectiveness 2024 Webinar.pptxMaximizing Board Effectiveness 2024 Webinar.pptx
Maximizing Board Effectiveness 2024 Webinar.pptx
 
WhatsApp 9892124323 ✓Call Girls In Kalyan ( Mumbai ) secure service
WhatsApp 9892124323 ✓Call Girls In Kalyan ( Mumbai ) secure serviceWhatsApp 9892124323 ✓Call Girls In Kalyan ( Mumbai ) secure service
WhatsApp 9892124323 ✓Call Girls In Kalyan ( Mumbai ) secure service
 
08448380779 Call Girls In Civil Lines Women Seeking Men
08448380779 Call Girls In Civil Lines Women Seeking Men08448380779 Call Girls In Civil Lines Women Seeking Men
08448380779 Call Girls In Civil Lines Women Seeking Men
 
Transcript: #StandardsGoals for 2024: What’s new for BISAC - Tech Forum 2024
Transcript: #StandardsGoals for 2024: What’s new for BISAC - Tech Forum 2024Transcript: #StandardsGoals for 2024: What’s new for BISAC - Tech Forum 2024
Transcript: #StandardsGoals for 2024: What’s new for BISAC - Tech Forum 2024
 
Slack Application Development 101 Slides
Slack Application Development 101 SlidesSlack Application Development 101 Slides
Slack Application Development 101 Slides
 
Making_way_through_DLL_hollowing_inspite_of_CFG_by_Debjeet Banerjee.pptx
Making_way_through_DLL_hollowing_inspite_of_CFG_by_Debjeet Banerjee.pptxMaking_way_through_DLL_hollowing_inspite_of_CFG_by_Debjeet Banerjee.pptx
Making_way_through_DLL_hollowing_inspite_of_CFG_by_Debjeet Banerjee.pptx
 

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

  1. Discuss: in Linux everything is a file and every action is done with at least two files (or two types of access types)
  2. Discussion: Identities in Linux
  3. Exercise: - create a new user - again, by editing the user files
  4. Exercise: man chmod to find about sticky bit Discussion about Sticky bit
  5. 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
  6. 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 ?