LFCS_Module2_UserandGroupManagement Cheat Sheet

A Software › Linux cheat sheet in English by nhatlong0605
8,940 views 2,237 downloads 24 Sep 2018 History
3.7 avg · 0 ratings

Creating Users, Groups

useradd -s /bin/zsh -c 'my user' -m anna
Create user anna with default shell (-s) and home dir (-m)
id user
Show user info
groupadd sales
Create '­sal­es' group
usermod -aG sales anna
Add anna to supple­mentary group '­sal­es'
useradd -D
Display default value of user
/etc/d­efa­ult­/us­eradd
Config­uration file for default value
/etc/l­ogi­n.defs
Additional config­uration value
/etc/skel
Content in skel will be copied to new user home dir
lid -g groupname
List all users that are members of a group

Resource Access Restri­ctions

yum groups install '­Dir­ectory Client­'
Install the Utility
yum install authco­nfi­g-gtk
Install graphic interface of auth
/etc/s­ecu­rit­y/l­imi­ts.conf
Limit config­uration file:n­proc, hard limit, soft limit

Access Control List

setfacl -R -m d:g:sa­les:rx account
Set ACL so '­sal­es' group can read, execute on account dir and all sub-dir on default
getfacl
Display all access control list permis­sions (+ symbol)

System­-Wide Enviro­nment Profile

env (environment variable)
export *var* (store variable)
unset *var* (reset variable)
env -i bash (change environment)

vim /etc/environment (set new variable)
LINUX="/home/long"
source /etc/environement (source new variable w/o reboot)

Manage Template User Enviro­nment

vim /etc/skel/.bashrc (file for setting)
/etc/skel (putting new file here will make it default for new user only)

Permis­sions

Read
4, Read on File, Ls on Di
Write
2, Modify on File, Create/Del on Dir
Execute
1, Run on File, Cd into Dir
chgrp account account
Change group owner of account dir to '­acc­oun­t' group
chown anna account
Change anna to owner of '­acc­oun­t' dir
chown linda.s­ales sales
Change user and group owner of '­sal­es' dir to linda, sales
chmod g+w account
Make members of '­acc­oun­t' group have write permis­sions on account dir
chmod 770 sales
Make user, group have read, write, execute permis­sion; others none

Extended Attributes

chattr +i file1
Make file1 has "­imm­uta­ble­" attribute

Managing Quota on Ext4

yum install -y quota
Install quota package
vim /etc/fstab
Config file for mounting file system automa­tically
mount -o remount /quota
Make sure the file system mounted with right options
quotacheck -mavug
Scan the file system
quota -vu lisa
Display quota on user lisa
quotaon -a
Activating quota
edquota -u lisa
Edit quota limit on user lisa; soft to 10; hard to 10
edquota -b lisa linda
Copy the quota limit from lisa to linda
dd if=/de­v/zero of=/qu­ota­/bi­gfile bs=1M count=3
if input file; of output file; bs block size; write 3 times
repquota -aug
Display quota overview

Password Properties

echo password | passwd -stdin brenda
Echo password to change brenda­'s password
chage brenda
Intera­ctive change

User,Group Config­uration File

cat /etc/group
Group config file
sales:­x:1­004­:anna
GroupN­ame­:Pa­ssw­ord­:Gr­oup­ID:­Gro­upM­embers
cat /etc/p­asswd
User config file
cat /etc/s­hadow
User Config file
vipw -s
vi passwd consis­tently

Advanced Permis­sions

suio
4; run as owner on file
sgio
2; run as group owner on file; inherit dir group owner
sticky
1; delete only if owner on dir
chmod u+s playme
Set UserID bit on playme
chmod g+s *
Set GroupID bit on *
chmod +t *
Apply StickyBit, other users cannot delete file created by owner

Finding files w/ special permis­sions

find -perm 0600
Find file with read,write for users only
find / -perm /4000 -exec ls -l {} \;
Find files in root dir with userID bit and list it

Comments

No comments yet.

Cheatography n. The art of mapping complex subjects into clear, instantly navigable reference guides.