LL10 – Managing Users

Required reading

Gnu Linux Guide – reread chapter 1 (focusing on the users & groups) and read 2.2 Users & Groups

Note, this lab must be done in your personal Virtual Machines (one of: VMWare, Hyper-V, Virtual PC, VirtualBox, UTM, etc.) as you need administrator privileges (e.g. root/su) to add users/groups and modify their permissions.

Introduction

Ok so we have our virtual machine systems up and running and everyone is now a SysAdmin in charge of managing their multi-user multi-tasking environment.  In the future we will install Backtrack Linux or implement the LAMP stack where by default, the system begins with us working as root w/root or SU privileges.  This is very dangerous as we can muck up our system very easily.  Recall that the sudo command at least prompts us for our password so that we can recheck our command (I build/repair boats and the standard carpenter’s advice is to measure twice, cut once).  Using the sudo command essentially forces us to measure twice (the construction adage of measure twice and cut once).  We will begin to learn about adding users and working with the system in proper safer ways as we should almost never work as ‘root’.  Also as SysAdmins we will need to manage users and their access to the file system.

As SysAdmins we are now to prepared to research and extend our knowledge as necessary.  To this extent I will ask you to perform tasks but I will not always provide complete information as you should possess this knowledge and if you don’t you need to review previous labs and course work.  For this lab, please research sudo, apt-get, update and install (previously introduced) and the Linux commands below as they arise (i.e. man pages, online, reading, etc.).

Before starting the lab, please update your repositories and system with the following 2 commands on one line (and note the connector:

$ sudo apt-get update && sudo apt-get install

To begin, let’s verify who we are logged in as so please enter the following in your Guest OS’s Terminal.  Note you should have reread the text to know how to open a terminal in your VM.

$ whoami

Exercise Intro Screenshot: please take a screenshot and label it “Intro Screenshot” and paste into your submission document.

10.1 groupadd

Please research groupadd and then enter the following:

$ sudo groupadd –g 1125 ciss100   #note you will be prompted for your password).

Now at some point you will need to verify the existence of a group and to do this we need to check the group file which is located in the /etc directory.  Please navigate to the /etc directory and display the contents of the group file.  A description of the file format is here: http://www.cyberciti.biz/faq/understanding-etcgroup-file/

Now going to the /etc/group file is a lot of effort so let’s verify the existence of the group from our home directory.  Navigate back to your home directory and enter the following:

$ grep -i “ciss100” /etc/group # note I could also search/grep “1125”

Of course the far less elegant way to look at this file would be as follows and would work well for our simple VM instance but would not work well with 1000s of users/groups:

$ cat /etc/group

Exercise 10.1: Please take a screenshot and paste into your submission document.

10.2 useradd

Please research useradd and then enter the following:

$ sudo useradd –g 1125 –c “Name ciss 100 student”  lastnameCISS100

If the above does not work please try this variant:

$ sudo useradd –c “Name ciss 100 student”  lastnameCISS100 -g 1125

For me, I would replace “Name ciss 100 student” with “James Looby ciss 100 student” and you should include the quotes but of course you know this from researching useradd.  For ease, I will be using loobyCISS100 as my username however as before, you should replace my lastname with yours.  I will continue using my last name as an example but again, you will be using your last name.

Now Linux does not have a command to list all users but every user is listed in the /etc/passwd file and we of course know how to look at that with head, or less, or cat so please enter the following.

$ cat /etc/passwd

To understand the format of the passwd file please see here: http://www.cyberciti.biz/faq/understanding-etcpasswd-file-format/

But let’s now look specifically for our new user so please use grep to search for the new user similar to how we used it to search for a group.  Of course you will search for the user’s name in the /etc/passwd file.

Exercise 10.2: Please take a screenshot and paste into your submission document.

10.3 passwd

Now we have to assign a password for the new user  ‘lastnameCISS100’ as the user is locked until we add this entry to the etc/passwd file.  Please research passwd and then enter the command

$ sudo passwd loobyCISS100  #adjust for your environment

Note: you can also add a user to an existing group using the usermod command.  This is of course continuing Sys Admin maintenance.  The command to add an existing user with username “student” to the “ciss100” group is as follows but of course this is just an example and not necessary for this lab. $ sudo usermod -g ciss100 student

Exercise 10.3: Run the finger command on the new user (new user is the command’s argument) noting you may have to install it (In this case use a Google search to find the Ubuntu finger installation instructions.  This is a moving target and the 1st results may not work so please look at the subsequent Google search results as well).  Take a screenshot and paste it into your LastnameFirstnameLL10  file providing the appropriate heading.

Please clear your screen after taking your screenshot and before continuing.

Note: you may have to install finger using sudo aptget install -y finger (research as necessary).  If this still results in failure, the following set of commands have also worked again noting you are responsible for researching each component of the following commands:

sudo rm -rf /var/lib/apt/lists/*
sudo apt-get update
sudo apt-get clean
and then 
sudo apt-get install -y finger 

If the above doesn’t work (finger may be deprecated in your version), please take a screenshot showing your efforts and move on.

10.4 Continuing on:

Now let’s login to our new account so enter:

$ sudo login lastnameCISS100  #adjust your username as necessary and enter the password you set

Note – be very wary of the prompt as the system could be asking for your sudo password which would be your main password or it may have bypassed the sudo password and be asking for the loobyCISS100 password you just set.

Did you notice your prompt changed?  Perform a complete listing as this will reveal that while we added the user everything is not quite copesetic yet.  Where are we and what’s missing?  We don’t have a home directory similar to our original account nor do we have its contents (e.g. .bashrc, .profile, etc.).  Note rerunning the finger command will of course demonstrate different output but your research would have led you to this conclusion.

Exercise 10.4: Open another terminal (right click the terminal in the dashboard and choose ‘New Terminal’). Notice this terminal is for your original user.  Move the terminals side by side, perform a ls -a in each terminal screen, take a screenshot of your entire Ubuntu desktop and paste it into your file with the appropriate heading.

You should also take a close look at the difference between the 2 user’s environments. Where is this user’s home directory by default?  Where is your original user’s home directory?

Please clear your screen after taking your screenshot and before continuing.

Continuing on:

Ok, so observing the differences in the 2 user’s terminals (e.g. home directory, lack of startup .bashrc & .profile scripts, etc) there is obviously a lot of work to do.   We did not use the -d and -m options to create and set the home directory (please research this).  We could also manually create the home directory and set up the user’s environment by modifing the /etc/passwd file and login scripts but of course no one wants to do this repetitively.   We will try the adduser perl script but first, let’s start from scratch so please close your second terminal and exit out of the lastnameCISS100 user’s account.  (Also, please Google “What is Perl” if you do not know what it is).

10.5 userdel

So we have to remove the recently added user and we will need this skill in any event so research userdel and perform the following:

$ sudo userdel lastnameCISS100 # enter your sudo password as necessary

Now let’s set up the same user account using the perl script adduser

10.6 adduser

Please research adduser noting adduser is a Perl script that uses useradd. A very nice description is located here and note I found this with a simple Google search for “Linux adduser”: http://www.linfo.org/useradd.html

Now enter:

$ sudo adduser lastnameciss100 #for me this would be loobyciss100

Enter information appropriately when prompted by the script and when complete, finger the new user to see and verify all the additional information.

Exercise 10.6:  Open a new terminal window and place this window alongside your other terminal window.  In this new terminal window login to lastnameciss100 as you did above.  Perform a print working directory and a complete long listing, take a screenshot and paste this into your file.  You will note there is more to do from viewing the complete long listing but at least users have their own user/directory space and their environment is set up better as indicated by their tailored .bashrc and .profile.  Please submit your assignment file.

Note – there is also an addgroup Perl script that extends groupadd making it more user friendly as well.

Please clear your screen after taking your screenshot and before continuing.

10.7 Graphical System Administration (information only but please try)

There is equivalent functionality to some of the things we did in a CLI in the GUI.  Again note it is important that you attempt to master the CLI as you may not have a Desktop GUI in a server implementation or you may be working over a network.

First, please navigate to and choose the gear/cog in the upper right corner of your desktop but note the icons change over time.  There you will see System Settings, Displays, Startup Applications, Updates… etc.  There is a lot of functionality here especially in the System Settings which are highlighted below.  BTW – hopefully you have been shutting down your system correctly using the “Shut Down” menu item.

Adding Users 

Choose System Settings and then User Accounts.  Unlock your accounts (if necessary) by choosing the Unlock icon in the top right corner of the User Accounts window.  Note this will require that you enter your password.  Next choose the ‘+’ sign and add the user (Full name and Username) choosing whether it is a standard or admin account.  Note you can only have 1 Automatic Login.

Now open a terminal and go up 1 level and perform a listing.  Was a directory created for this new user?  Now you will need to setup a password for the new user per above.  Lastly you will need to add the user to a group so use the usermod command to add the user to an existing group.

skill command – recall what this does

Getting help: As in the past I will need the exercise number and screenshots to assist as I cannot assist without complete information (we don’t guess in Comp Sci.  Further, we are trying to learn and follow a process integral to both IT Support & Documentation as we must learn to document everything as we move through the System Development Life Cycle (SDLC). I have posted one know issue with Vbox below.

CommandDescription
useradd
groupadd
chown
passwd
login
userdel
adduser
sudo
apt-get
install
whoami
skill