SSH Command in Linux with examples

Users and groups commands in Linux

Create and manage accounts, and see who is logged in.

#adduser

Create a user (friendly)

Syntaxsudo adduser name
  • sudo adduser alice

    Asks for a password and details, creates the home folder (Debian and Ubuntu)

#useradd

Create a user (low level)

Syntaxsudo useradd [options] name
  • sudo useradd -m -s /bin/bash bob

    Create bob with a home folder and the bash shell

  • sudo useradd -m -G sudo,www-data bob

    Also add him to groups (the groups must already exist)

#usermod

Change a user

Syntaxsudo usermod [options] name
  • sudo usermod -aG sudo alice

    Add alice to the sudo group (the -a keeps her other groups)

  • sudo usermod -s /bin/zsh alice

    Change the login shell

  • sudo usermod -L alice

    Lock the account

#userdel

Delete a user

Syntaxsudo userdel [-r] name
  • sudo userdel -r bob

    Delete bob and his home folder

#passwd

Set a password

Syntaxpasswd [user]
  • passwd

    Change your own password

  • sudo passwd alice

    Set another user's password

#groupadd

Create a group

Syntaxsudo groupadd name
  • sudo groupadd developers

    Create the group

#chage

Password ageing

Syntaxsudo chage [options] user
  • sudo chage -l alice

    Show when the password expires

  • sudo chage -M 90 alice

    Force a change every 90 days

#who / w

Who is logged in

Syntaxwho | w
  • who

    Users logged in now

  • w

    Users and what each one is running

#last

Login history

Syntaxlast [user]
  • last -n 10

    The last ten logins

  • sudo lastb

    Failed login attempts

Run these commands with SSH Command

SSH Command is a desktop app for Mac, Windows and Linux that puts a real terminal, SFTP file panes, a sudo switch and a searchable Linux command finder in one window. Type what you want to do, and send the command to your server with one click.

Download free Windows commands with examples SFTP & FTP client