Version 2

    element14's The Ben Heck Show

    Join the Ben Heck team every week for amazing hacks! Watch them build and mod community-inspired projects using electronics!

    Back to The Ben Heck Show homepage

    sudo Sergeant
    The Learning Circuit
    See All Episodes



    Linux is a multi-user operating system that allows more than one user to use Linux at the same time.  An important role of a system administrator is managing accounts.  Felix goes over some of the mechanisms used for account management.  He shows you how to create accounts, modify accounts, and remove accounts.



    From terminal, Felix takes a look at all the accounts on his machine:

    $ cat /etc/passwd

    This takes him to all the accounts that are on the system. To add an account you would use:

    $ sudo useradd  -m  -G  sudo -s /bin/bash username

    This creates a user account named username with sudo privileges.  To login to your new account you will need to first setup a password:

    $ sudo passwd username

    You’ll be asked to create a new password and the system will tell you when it has been updated. To login to your new account you would switch users using:

    $ su username

    To get out of the directory you were just in use:

    $ cd ~

    You’ve now created a new account, given it a password, given it sudo privileges, created a login shell, and home directory. You can now view the new user account by using:

    $ cat/etc/password

    To change the directory that the user account is located in use:

    $ sudo usermod  -d /home/newdirectory  -m user

    This will change the directory from username to user. To change the shell from /bin/bash to /bin/zsh you would use:

    $ sudo usermod   -s /bin/zsh

    To change the account name you would use following command:

    $ sudo usermod   -l newusername username

    This changes the account name from username to newusername.   You can confirm this by typing in:

    $ cat /etc/passwd

    To add a system account you would use the user add instruction again:

    $ sudo useradd  -r  -s  /usr/nologin  system-account

    This would be useful, for instance, if you had some kind of a background daemon running that needed a user.  You would assign a system account to the group.  To delete this account when you no longer need it, you would use the following command:

    $ sudo userdel  -r system-account