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 'sales' group |
usermod -aG sales anna |
Add anna to supplementary group 'sales' |
useradd -D |
Display default value of user |
/etc/default/useradd |
Configuration file for default value |
/etc/login.defs |
Additional configuration 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 Restrictions
yum groups install 'Directory Client' |
Install the Utility |
yum install authconfig-gtk |
Install graphic interface of auth |
/etc/security/limits.conf |
Limit configuration file:nproc, hard limit, soft limit |
Access Control List
setfacl -R -m d:g:sales:rx account |
Set ACL so 'sales' group can read, execute on account dir and all sub-dir on default |
getfacl |
Display all access control list permissions (+ symbol) |
System-Wide Environment 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 Environment
vim /etc/skel/.bashrc (file for setting)
/etc/skel (putting new file here will make it default for new user only)
|
|
|
Permissions
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 'account' group |
chown anna account |
Change anna to owner of 'account' dir |
chown linda.sales sales |
Change user and group owner of 'sales' dir to linda, sales |
chmod g+w account |
Make members of 'account' group have write permissions on account dir |
chmod 770 sales |
Make user, group have read, write, execute permission; others none |
Extended Attributes
chattr +i file1 |
Make file1 has "immutable" attribute |
Managing Quota on Ext4
yum install -y quota |
Install quota package |
vim /etc/fstab |
Config file for mounting file system automatically |
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=/dev/zero of=/quota/bigfile 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 |
Interactive change |
User,Group Configuration File
cat /etc/group |
Group config file |
sales:x:1004:anna |
GroupName:Password:GroupID:GroupMembers |
cat /etc/passwd |
User config file |
cat /etc/shadow |
User Config file |
vipw -s |
vi passwd consistently |
Advanced Permissions
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 permissions
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 |
|
Created By
Metadata
Favourited By
Comments
No comments yet. Add yours below!
Add a Comment
Related Cheat Sheets
More Cheat Sheets by nhatlong0605