CST8207: GNU/Linux Operating Systems I Lab Seven Linux User and Group Management. Linux User and Group Management

Similar documents
CST8207: GNU/Linux Operating Systems I Lab Seven Linux User and Group Management. Linux User and Group Management

CST8207: GNU/Linux Operating Systems I Lab Six Linux File System Permissions. Linux File System Permissions (modes) - Part 1

Lab 2A> ADDING USERS in Linux

NETW 110 Lab 5 Creating and Assigning Users and Groups Page 1

CSE 265: System and Network Administration

Commands are in black

Lab Authentication, Authorization, and Accounting

CST Lab 2 Review #1

User Accounts. The Passwd, Group, and Shadow Files

User & Group Administration

CST8207: GNU/Linux Operating Systems I Lab Nine Disks, Partitions, and File Systems Part 2. Disks, Partitions, and File Systems - Part 2 of 2

10 userdel: deleting a user account 9. 1 Context Tune the user environment and system environment variables [3]

CST8207: GNU/Linux Operating Systems I Lab Ten Boot Process and GRUB. Boot Process and GRUB

MANAGING THE NONUNIFORM BEHAVIOUR OF TERMINALS AND KEYBOARDS. : WHEN THINGS GO WRONG

The kernel is the low-level software that manages hardware, multitasks programs, etc.

Chapter 5: User Management. Chapter 5 User Management

User accounts and authorization

This is Worksheet and Assignment 12. Disks, Partitions, and File Systems

User Management. René Serral-Gracià Xavier Martorell-Bofill 1. May 26, Universitat Politècnica de Catalunya (UPC)

CS/CIS 249 SP18 - Intro to Information Security

CTEC1863/2018F Bonus Lab Page 1 of 5

Redhat Basic. Need. Your. What. Operation G U I D E. Technical Hand Note template version

Answers to Even- Numbered Exercises

Linux Kung-Fu. James Droste UBNetDef Fall 2016

Everything about Linux User- and Filemanagement

Working with Basic Linux. Daniel Balagué

Files (review) and Regular Expressions. Todd Kelley CST8207 Todd Kelley 1

Lab Working with Linux Command Line

Chapter 8: Security under Linux

Linux Essentials Objectives Topics:

5/8/2012. Creating and Changing Directories Chapter 7

Users, Groups and Permission in Linux

This is Lab Worksheet 13 - not an Assignment. Boot Process and GRUB

OPERATING SYSTEMS LINUX

Operating Systems Lab 1 (Users, Groups, and Security)

ADVANCED LINUX SYSTEM ADMINISTRATION

Introduction to Linux (Part I) BUPT/QMUL 2018/03/14

CENG 334 Computer Networks. Laboratory I Linux Tutorial

This lab exercise is to be submitted at the end of the lab session! passwd [That is the command to change your current password to a new one]

UNIT V. Dr.T.Logeswari. Unix Shell Programming - Forouzan

Course 144 Supplementary Materials. UNIX Fundamentals

Files and Directories

Some Ubuntu Practice...

Race Condition Vulnerability Lab

Users and Groups. his chapter is devoted to the Users and Groups module, which allows you to create and manage UNIX user accounts and UNIX groups.

System Administration

CSE 390a Lecture 3. Multi-user systems; remote login; editors; users/groups; permissions

1. Open VirtualBox and start your linux VM. Boot the machine and log in with the user account you created in Lab #1. Open the Terminal application.

Hands-on Keyboard: Cyber Experiments for Strategists and Policy Makers

Contents. Note: pay attention to where you are. Note: Plaintext version. Note: pay attention to where you are... 1 Note: Plaintext version...

02. At the command prompt, type usermod -l bozo bozo2 and press Enter to change the login name for the user bozo2 back to bozo. => steps 03.

TEL2821/IS2150: INTRODUCTION TO SECURITY Lab: Operating Systems and Access Control

CSE 303 Lecture 4. users/groups; permissions; intro to shell scripting. read Linux Pocket Guide pp , 25-27, 61-65, , 176

Practical Session 0 Introduction to Linux

Introduction to the UNIX command line

[ Terminal ] [ Users management ] Alt +F6 = Terminal switcher. useradd [option] JohnG

LPI Entry Level Linux Essentials Certificate of Achievement.

Linux Kung Fu. Stephen James UBNetDef, Spring 2017

Operating Systems. Copyleft 2005, Binnur Kurt

SANJAY GHODAWAT POLYTECHNIC

A Brief Introduction to the Linux Shell for Data Science

Operating Systems 3. Operating Systems. Content. What is an Operating System? What is an Operating System? Resource Abstraction and Sharing

Introduction. What is Linux? What is the difference between a client and a server?

Introduction to Unix May 24, 2008

National University of Computer and Emerging Sciences Operating System Lab - 02 Lab Manual

This is Lab Worksheet 3 - not an Assignment

Post Ubuntu Install Exercises

Processes are subjects.

Course Wiki. Today s Topics. Web Resources. Amazon EC2. Linux. Apache PHP. Workflow and Tools. Extensible Networking Platform 1

Due: February 26, 2014, 7.30 PM

CMSC 201 Spring 2017 Lab 01 Hello World

UNIT 9 Introduction to Linux and Ubuntu

Project #3: Implementing NIS

Linux & Shell Programming 2014

bash startup files Linux/Unix files stty Todd Kelley CST8207 Todd Kelley 1

CSE 390a Lecture 4. Persistent shell settings; users/groups; permissions

Dirty COW Attack Lab

CS246 Spring14 Programming Paradigm Notes on Linux

CSCI 2132 Software Development. Lecture 5: File Permissions

UNIX COMMANDS AND SHELLS. UNIX Programming 2015 Fall by Euiseong Seo

CSE 390a Lecture 4. Persistent shell settings; users/groups; permissions

Getting your department account

Permissions and Links

UNIX File Hierarchy: Structure and Commands

Introduction: What is Unix?

CSCE 212H, Spring 2008, Matthews Lab Assignment 1: Representation of Integers Assigned: January 17 Due: January 22

Introduction of Linux

UNIT 10 Ubuntu Security

UNIX. Basic UNIX Command

5/8/2012. Encryption-based Protection. Protection based on Access Permission (Contd) File Security, Setting and Using Permissions Chapter 9

PESIT Bangalore South Campus

Introduction to Linux

Capability and System Hardening

Files

Introduction to Computer Security

Computer Systems and Architecture

Assume that username is cse. The user s home directory will be /home/cse. You may remember what the relative pathname for users home directory is: ~

Welcome to getting started with Ubuntu Server. This System Administrator Manual. guide to be simple to follow, with step by step instructions

Exam Linux-Praxis - 1 ( From )

CSCM98 Lab Class #5 Getting familiar with the command line

Transcription:

Student Name: Lab Section: Linux User and Group Management 1 Due Date - Upload to Blackboard by 8:30am Monday April 2, 2012 Submit the completed lab to Blackboard following the Rules for submitting Online Labs and Assignments. You must upload two files for this submission. You must always upload both files when you submit. Both. 2 Commands, topics, and features covered Use the on-line help (man command) for the commands listed below for more information. /3 marks useradd add a new user account and home directory userdel delete an account (and possibly the home directory as well) usermod modify account information (and possibly home directory as well) groupadd add a new group to the /etc/group file groupdel remove a group from the /etc/group file groupmod modify group name, number, password account information in the /etc/group file newgrp start a new shell with the permissions of a different group (similar to su) gpasswd administer groups: set group administrator users, set group members, add and remove users from a group, change or remove the group password groups list the groups you (or another account) are in (from /etc/group) id display current account, current groups, and SELinux security context information 3 Correct user, command lines, and command output Parts of this lab are done as different ordinary, non-root users. Other parts are done as the root user. Pay attention to which part is done by which user. Your prompt will tell you if you are the root user. Some answer blanks require you to enter command lines. Do not include the shell prompt with your command lines. Give only the part of the command line that you would type yourself. Make sure you know the difference between a command line (which is what you type into the shell) and command output (which is what the command displays on your screen). 4 Backup and Recovery Take a snapshot of your virtual machine before you begin this lab so that you can recover if needed. Make a backup copy of the /etc/passwd file and its shadow and the /etc/group file and its shadow. 5 Creating an account useradd and passwd You will need root privileges to run these commands. The useradd utility creates a new account, storing information about the account in the /etc/passwd file and about the account groups in the /etc/group file. (On some versions of Linux - Debian, Ubuntu, etc. - a different command adduser is used. On Fedora, they are the same command with two different names.) The passwd utility sets a password for an account, storing the password in the shadow password file named /etc/shadow. An account cannot be used until a password has been set. Group passwords are stored in the shadow group file /etc/gshadow. [root@host ~]# useradd luke [root@host ~]# passwd luke [root@host ~]# su - luke [luke@host ~]$ pwd Page 1 of 6 (create a new luke user and home directory) (give the new account a password - remember it!) (become the luke user - dash ensures a full login) (verify your current directory - the home directory)

[luke@host ~]$ whoami (verify your current user) [luke@host ~]$ groups (verify your current groups) [luke@host ~]$ id (verify your current user, groups, and security context) [luke@host ~]$ exit (exit the luke shell and return to the previous user) [root@host ~]# grep 'luke' /etc/passwd /etc/shadow (display lines containing luke) [root@host ~]# grep 'luke' /etc/group /etc/gshadow (display lines containing luke) a) Record the one line of password file output from the grep command above: b) Use ls -lid on the new home directory of the new luke account and record the output here: c) Use a command to find all pathnames owned by the luke user, located under the /var directory and record the command line you used here (do not include the shell prompt with a command line): d) Use ls -li on the mail spool file output by the above command and record the output here: e) Who owns the mail spool file: What is its group: 6 Modifying a user account and group - usermod and groupmod This section depends on the existence of an account named luke, with an existing home directory, and a group named luke. Create this account and group (see Section 1, above) if it does not yet exist. Do not proceed until you have a luke account created. Verify that luke exists in all four account files: [root@host ~]# grep 'luke' /etc/{passwd,shadow,group,gshadow} This section uses the usermod and groupmod commands. Use only these commands to make the following section's account and group changes. Do not use any other commands to make these changes. The usermod command modifies account attributes, as recorded in the password file. Some are: o login name - modified with usermod -l o password - encrypted and stored in /etc/shadow file; - modified with usermod -p or passwd o UID, or user id number - modified with usermod -u o GID or group id number - modified with usermod -g o additional information, such as full name; modified with usermod -c o home directory - modified with usermod d... -m o login program - program (shell) run when a user logs in - modified with usermod -s or chsh Modifying account information does not automatically move or modify files owned by the account. If you change account information, you may have to walk the entire file system to find files owned by the account and change them. One exception is moving home directories using usermod: Using the d and -m options, the usermod command is able to move a home directory. The groupmod command modifies group name, number, and password, as recorded in the group file. a) Modify the login name of the luke account to be darth and record the command line you used here: b) Modify the group name of the luke group to be darth and record the command line you used here: c) The new darth account still uses a home directory of /home/luke. Modify and move (in one command line) this old home directory from its current luke name to the new name lord (use the absolute path!) and record the one command line you used here (RTFM and learn how to use -d and -m): Page 2 of 6

d) Check your work! Use a command to search in the password and group files and make sure the word luke does not appear anywhere in those files. Look in the /home directory and make sure that the old luke directory has been correctly moved to lord. Do not proceed until you check your work! When you have verified that the account has been moved, use su - darth to login as the new account and record the output of typing the two commands pwd and then id in the new darth account: e) Use the appropriate option to the chsh command to print the list of shells. Now change the shell for darth to be the one that prevents logins ("no logins"). Record the command line you used to change the shell for darth, followed by the output of su - darth showing the disabled account message: f) Repeat the above steps and completely move the new darth account and group to be the new name yoda with home directory under the usual place with subdirectory name jedi. Check your work carefully after you have followed all the steps! Login to the yoda account as before and again record the output of typing the two commands pwd and then id in the new yoda account (if you can't log in because the account is disabled, you should know why - reset the login shell to /bin/bash and try again): g) Check your work! Use a command to search in all four password and group files and make sure the word "darth" does not appear anywhere in those files. Record that command line you used here: h) Make sure the yoda home directory is in the correct location and has the correct owner and group. Copy the full output of the command that shows its inode, permissions, owner, group, modify date, etc. here: 7 Deleting an account - userdel [root@host ~]# useradd redshirt (create an expendable account redshirt and home dir) [root@host ~]# su redshirt (become [login as] the new redshirt user) [redshirt@host ~]$ su root (become root on top of the logged in redshirt user) [root@host ~]# userdel redshirt (try, and fail, to delete logged-in user - does not work) [root@host ~]# exit (exit the root shell and return to the redshirt shell) [redshirt@host ~]$ exit (exit the redshirt shell - redshirt no longer logged in) [root@host ~]# userdel redshirt (delete the redshirt account info, but not the home dir) [root@host ~]# grep 'redshirt' /etc/{passwd,shadow,group,gshadow} (no output) [root@host ~]# su redshirt (try, and fail, to become a nonexistent redshirt user) a) Use ls -lid on the existing home directory of the deleted redshirt account and record the output: b) Note the numeric owner and group numbers in the above output, due to the deleted redshirt account and group. The directory still exists and has its numeric owner and group IDs, but no accounts or groups exist for those IDs so they print as simple numbers. If you now create a new account, and the new account is assigned those IDs, the files formerly owned by redshirt will now be owned by the new account. This is almost never what you want. Create a new account named bogus and then repeat the above ls -lid on the former home directory of the deleted redshirt account and record the new output here, showing the new bogus owner and group: Page 3 of 6

c) You must make sure you fully delete an account and all its files no matter where the files are in the file system. The userdel command can remove home directories using an option. Use that option to fully remove the bogus account you just created and record the command line you used here: d) Removing the bogus account and its home directory did not remove the old redshirt files. Give a command that will find and display every file and directory owned by the numeric ID of the former redshirt account (command name hint: find using its option user). Pick the correct starting directory for the search, so that the command finds all the files, no matter where they are! Some error messages will also print with the output of the command - redirect just the error messages to /dev/null. Command used: e) Using ordinary commands (not account commands learned in this lab), completely and recursively remove all files and directories that still belong to the deleted redshirt account (listed in the previous question) and record the one or two command lines used (you can do it all in one command line with two pathnames): Re-run the command that searches for files owned by the former redshirt numeric ID. All gone, yes? 8 Group management: The Megadeth Project Take a VM snapshot before you begin this section, so you can return here if you make many mistakes. This section uses commands you have not used before. Every command you need to use is mentioned in the opening page(s) of this lab document. Every command has a man page. RTFM! Requirements for Group Management: The band Megadeth (note the unusual spelling of Megadeth make sure you use the correct spelling) uses the following work approach and has the following Requirements: 1. Song files are created by a single group administrator account. Only the one group administrator account can create, delete, modify and write song files. 2. Files are readable (not writable or removable) by all other (non-administrator) group (band) members. Ordinary band members can only read the files, not change or rename them. 3. Anybody who is not a band member is not allowed to view song files. No public access. Follow the directions below to create accounts and directories that implement the above permissions. Some of the work will need to be done as the root super-user. (Only the root user can create new accounts.) Some group maintenance work can be done as the group administrator. The four Megadeth band members are (get the name and account spellings correct! Case matters): Chris Broderick login name: broderc Dave Mustaine login name: mustaid Shawn Drover login name: drovers David Ellefson login name: ellefsd 8.1 Creating and configuring the Megadeth Working Group a) Use the --comment option to include the user's full name in each account you create (remember to quote names containing blanks) and record the four command lines used to create ordinary user accounts for all four band members (do not set any special groups yet - just create ordinary accounts): Page 4 of 6 Confirm that all four band members have accounts containing their full names by looking in a file.

b) Record the one command used to create a new group named megadeth (spelled all lower case): c) Set Chris Broderick as the group administrator of the new group and record the command line used: d) Become (su) the megadeth group administrator. Record the four command lines used by Chris to add each of the four band members to the megadeth group (exit the Chris shell when you are done): Confirm that the group file contains the new group with all four band members listed beside it. e) Create a new song directory named /home/songs and record the output of ls -lid on the new directory (it will be owned by root and in group root with default permissions): f) The band wants to store songs under the songs directory, matching the Requirements given above. Set ownership and permissions for the songs directory to implement the given Requirements: 1. Which account should become the owner of songs? 2. Which group should become the group of songs? 3. Which permissions (symbolic) should be set on songs? g) Record all the commands (minimum two) used to implement the above Requirements: 8.2 Test Plan for the Megadeth Group Project You need to verify that the requirements have been met using a Test Plan. Here it is: a) Become (su) the group administrator and redirect the current date into a file named test in the songs directory. Display the file on your screen to make sure it has content you can see. Record the output of command ls -li using the absolute pathname to the test file in the songs directory: a) Also record the same information for just the songs directory itself (use the absolute pathname): Exit the group administrator account when you are done. Refer again to the Requirements, listed at the start of this section. Complete the tests below for each type of user logged in (using su), making sure the test results match the Requirements (Hint: Neither of the test accounts below should be able to modify or delete the file.): Table #1 - test results when logged in as different users Logged in as a band member Loged in as any non-band Test to perform: Can you... (not the group administrator) user account (not root!) List the contents of the songs directory? Yes or No? Yes or No? Change into the songs directory? Yes or No? Yes or No? Read the file test? Yes or No? Yes or No? Modify the file test? Yes or No? Yes or No? Delete the file test? Yes or No? Yes or No? The Test Plan records the results of your testing. Do the test results meet the original Requirements? Page 5 of 6

Table #2 - excerpt from the /etc/passwd file Record the entries in the /etc/passwd file for each user created: User Name Password UID GID Home Directory Login Shell broderc X mustaid X drovers X ellefsd X Table #3 - excerpt from the /etc/group file Record the entries in the /etc/group file for these group entries: Group Name Password GID Group Members (if any) broderc X mustaid X drovers X ellefsd X megadeth X 8.3 Finishing touch - four symbolic links a) Log in as each band member (four times) and create a soft link (symbolic link) named tunes in the home directory that links up to /home/songs so that each member can then use the soft link to access the /home/songs directory instead typing the entire pathname. Record the command line used to create this symbolic link named tunes: Lab Check and Upload - lab07marks.txt This is the section that tests and marks the work you did above. The Lab Check program below will do the checking to make sure you got things right. (Did you correctly move luke to darth? Did you correctly move darth to yoda? Did you fully delete the redshirt account? Is the songs directory configured correctly?) Download (right-click and Save Link As) the lab07check program from the Class Notes into your home directory, make it executable, and run it as the root user with the HOME variable (all upper-case) set to the absolute path of your own HOME directory: [user@host ]$ cd [user@host ~]$ su root (do not use the dash that means a full login) [root@host user]# chmod u+x lab07check [root@host user]# HOME=/home/user (use your own HOME directory name here) [root@host user]#./lab07check This program will check your work for this lab, assign you a mark, and put the mark and status information into a new file lab07marks.txt so that you can upload it to Blackboard as part of this assignment. Do not print this file - it contains dozens of pages of status information! You may run the lab07check program as many times as you wish, to correct mistakes and get the best mark, before you upload the final marks file. You will upload two files for this assignment: this ODT document and the lab07marks.txt output file. Use the exact names given for uploading. Do not change the names. Do not print the lab07marks.txt file - it contains dozens of pages of status information! You will upload two files for this assignment. Two. Two files. You will use the correct names. Yes. Page 6 of 6