Notes
1.0.0
1.0.0
  • Introduction
  • Commands
    • cd
    • df
    • du
    • fc-cahe
    • ifconfig
    • ip
    • ls
    • lsb_release
    • mkdir
    • mksquashfs
    • mount
    • ping
    • pwd
    • rm
    • sar
    • sudo
  • Linux C
    • Preprocessor
    • Keywords
    • Kernel
      • Ftrace
      • Watchdog
  • Python
    • general
      • Decorator
      • Generator
      • Iterator
      • Lambda
    • Download
    • NIC
  • Network
    • Protocol
      • Link layer
      • IP
      • ARP
      • ICMP
    • Proxy
      • Cntlm
      • Proxychains4
      • ShadowSocks
    • Tools
      • iperf
      • tc
      • Wireshark
    • Apps
      • samba
      • tftp
  • Software
    • Atom
    • Chrome
    • Docker
    • Git
    • Gitbook
    • Hexo
    • Nodejs
    • Teraterm
    • Tex
    • Tmux
    • VIM
    • VSCode
  • Database
    • MongoDB
  • Web
    • CSS
    • LNMP
  • Tools
    • common
    • programming
  • Ubuntu
    • Add user
    • AWS EC2
    • FAQ
    • Installer
    • Shell
    • Shell scripts
    • Themes
    • VPS
  • Windows
    • PowerShell
    • CMD
    • FAQ
  • Aphorisms
  • Book List
  • Favorites
  • Appendix
    • ASCII
    • GSM
Powered by GitBook
On this page
  • useradd
  • chown
  • chgrp
  • userdel
  • Add user to sudo group

Was this helpful?

  1. Ubuntu

Add user

useradd

# add user with root user
$ useradd USERNAME
# or add like that
$ useradd -m USERNAME -s /bin/zsh

# add password for new user
$ passwd USERNAME

# add user to sudoers
$ chmod u+w /etc/sudoers
$ vim /etc/sudoers
root    ALL=(ALL)  ALL
USERNAME ALL=(ALL)  ALL  # new line
# login with new username and password
$ ssh USERNAME@HOSTIP

# change default shell of new user
$ chsh -s /bin/zsh

chown

# change the owner of directory or files
$ sudo chmod USERNAME DIRECTORY_OR_FILENAME

chgrp

# change the group of directory or files
$ sudo chgrp USERNAME DIRECTORY_OR_FILENAME

userdel

# with user in root
$ userdel USERNAME
# please make sure the files of USER already backup, then do the follow things
$ rm -rf /home/USERNAME
# remove USER from /etc/sudoers

Add user to sudo group

usermod -aG newuser
# may need relogin newuser to make is access
PreviousUbuntuNextAWS EC2

Last updated 5 years ago

Was this helpful?