Skip to content

Instantly share code, notes, and snippets.

@amfischer
Last active May 20, 2022 15:27
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save amfischer/957debc3f873a32c081350868810e01d to your computer and use it in GitHub Desktop.
Save amfischer/957debc3f873a32c081350868810e01d to your computer and use it in GitHub Desktop.
Ubuntu commands cheat sheet
  • list all local users
    cut -d: -f1 /etc/passwd

  • list users and their permissions
    cat /etc/passwd

  • list groups
    cat /etc/groups

  • add new user
    sudo adduser new_username
    sudo useradd new_username

  • delete a user
    sudo userdel username
    To delete the home directory for the deleted user account:
    sudo rm -r /home/username

  • modify username
    usermod -l new_username old_username

  • change user password
    sudo passwd username

  • change user shell
    sudo chsh username

  • change user details
    sudo chfn username

  • add user to sudo group
    adduser username sudo
    usermod -aG sudo username

  • list user groups and gid
    id username

  • WireGuard start/stop cmds
    sudo wg-quick up reopen-garden sudo wg-quick down reopen-garden

  • WireGuard start on boot
    sudo systemctl enable wg-quick@reopen-garden.service

  • remove package
    sudo apt-get purge --auto-remove packagename

  • list all packages
    apt list --installed

  • list occupied ports sudo lsof -i -P -n | grep LISTEN

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment