Delete Set public Set private Add tags Delete tags
  Add tag   Cancel
  Delete tag   Cancel
  • • DevOps notes •
  •  
  • AI
  • Tags
  • Login

User management/shaare/zyCzng

  • linux
  • linux

  • Essential Commands:

    • useradd, groupadd, userdel, groupdel, usermod
    • Modify 3 files: /etc/passwd, /etc/group, /etc/shadow

Create User with Custom Options

useradd -G mygroup -s /bin/bash \
  -c "User Description" -m \
  -d "/home/myuser" myuser

Other Useful User Commands

  • useradd myuser → create user
  • id myuser → check if user exists
  • groupadd → create group
  • cat /etc/group → check group
  • userdel -r myuser → delete user and home directory
  • groupdel mygroup → delete group
  • usermod -G mygroup myuser → change user's group
  • chgrp -R mygroup myuser → change group ownership recursively
  • passwd myuser → set or update user's password

Password Aging with chage

  • chage → manage password aging

    • -m → minimum days
    • -M → maximum days
    • -d → last password change
    • -I → inactive days
    • -E → expiration date
    • -W → warning days
  • Example:

    • chage -M 5 -M 90 -W 10 -I 10 username

Edit Password Policies

  • File: /etc/login.defs

    • PASS_MAX_DAYS 9999
    • PASS_MIN_DAYS 0
    • PASS_MIN_LEN 5
    • PASS_WARN_AGE 7

Switch User Privileges

  • visudo → edit sudo permissions config (/etc/sudoers)

    • Add user to wheel group for sudo access
  • usermod -aG wheel myuser → grant sudo rights

User Info and Monitoring Commands

  • who → see logged in users
  • last → list last login records
  • w → who is logged in with more details
  • finger → show user details
  • id → show UID, GID and groups
  • id myuser → check user info

Send Messages to Users

  • wall → broadcast message to all users

    • Type message, then Ctrl + D to send
  • write myuser → send message to specific user

    • Type message, then Ctrl + D to send
4 months ago Permalink
cluster icon
  • Process monitoring : ps Command ps → Current shell process status ps -E → All running processes ps aux → All in BSD style with details ps -EF → Running process with detai...
  • Navigating File System / Linux filetypes : ls -l → List pwd → Print working directory dr-xr-xr-x | directories -rw-r--r-- | file Linux File Types Symbol Type - Regular file d Dire...
  • Special Permissions (SetUID, SetGID, Sticky Bit) : chmod u+s xyz.sh → add SetUID (user-level special permission) chmod g+s xyz.sh → add SetGID (group-level special permission) chmod u-s xyz.sh → remov...
  • Linux File Links and Permissions : Links Soft Link (Symbolic Link) ln -s Link will be removed if the original file is removed or renamed. Hard Link ln Deleting, renaming, or moving t...
  • Screen & Tmux : Screen (Terminal Multiplexer) Multi-terminal sessions in one window Alt+A | → split vertical Alt+A Shift+S → split horizontal Alt+A Tab → switch wind...


(19)
Filter untagged links
Fold Fold all Expand Expand all Are you sure you want to delete this link? Are you sure you want to delete this tag? The personal, minimalist, super-fast, database free, bookmarking service by the Shaarli community