LL10 – Managing Users

Introduction – Users and the File System

In the very near future we/you will install Backtrack Linux or implement the LAMP stack where by default we will be working as root w/root 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 the following Linux commands in advance:

groupadd
useradd
chown
passwd
login
userdel
adduser

Let’s begin:

Enter the command

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

Enter the command

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

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 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.

Enter the command

$ sudo passwd loobyCISS100  #Enter and reenter the password when prompted

Note: you can add a user to an existing group using the usermod command.  This is of course is 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 10a

Take a screenshot and paste it into your LastnameFirstnameLL10.odt file providing an appropriate heading (e.g. Exercise 10a) and naming the file in accord with previous assignments.

Continuing on:

Research and run the finger command noting you may have to install it.

Recall you also have the who command at your disposal and you should try this as well.

Now let’s login to our new account

Enter the command

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

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 10b

1. Open a 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 and paste it into the .odt file.  (you should also take a close look at the difference between the 2 user’s environments).

2. Also, where is this user’s home directory by default?  Where is your original user’s home directory?  Please provide the path to both the new user’s (e.g. loobyciss100) and your original user’s home directories in the .odt file.  Note there is no “path” command so you will have to use something else if it is not obvious (i.e. it is likely that you do note even need to enter an additional command) and you will write this path into the .odt file using Office’s text writing ability (i.e. it is not a screenshot).  

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 could manually create the home directory and modify the login scripts etc. but of course no one wants to do this repetitively.  We also did not use the -d and -m options to create and set the home directory but scripts have been created to facilitate this.  We will try the adduser perl script but first, let’s start from scratch so we have to remove the recently added user and we will need this skill in any event so research 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 (and you should research this) so enter:

$ sudo adduser lastnameciss100 #for me this would be loobyciss100

Enter information appropriately when prompted by the script.

Exercise 10C

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 .odt 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 .odt file.

Ok, so what did we learn?  Continually research for functionality.

In parting,  for completeness, please see the “Graphical Sys Admin” component at the bottom of the Linux Labs submenu.

Leave a Reply