Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

Linux 1. Create a new user on the system. Check that the user is added to the ho

ID: 3706004 • Letter: L

Question

Linux

1. Create a new user on the system. Check that the user is added to the home directory and can login. Now as a root disable user's login by various methods we discussed in the class. Check that the user cannot login. a. What entries in what files are modified so user cannot login? b. Enable user again, and check that the user can login. Which files were changed? c. Add that user to the sudo list and check that user can do some commands as a root. Remove user from the sudo list. As that user try to run some sudo commands. Switch to the root and check your email. What alert do you receive? d. Log as a user you created, open a text editor (vi) and start writing some file. Login as a root to another terminal and remove that user's account with the force flag What happens to the user working on the file?

Explanation / Answer

1. How to create a new user in Linux: We have 'useradd' or 'adduser' commands to add or create a new user in Linux with 'username'. 'Username' is user login name, that is used to login into the system.

Only one user can be added and that username must be unique (different from other username already exists on the system).

If you are logged in as root then write the following:

useradd jhon

If you are logged in as a user with “sudoers” privileges:

sudo useradd jhon

With this method: the user is created without home directory.

Create a new user with home directory in Linux

If you are logged in as root then write the following:

useradd -m -d /home/dirjhon jhon

If you are logged in as a user with “sudoers” privileges:

sudo useradd -m -d /home/dirjhon jhon

It will create a new user “joe” with his home directory in the following path: “/home/dirjoe”.

When we add a new user in Linux with ‘useradd‘ command it gets created in locked state and to unlock that user account, we need to set a password for that account with ‘passwd‘ command.

a. Ensuring it is a Directory, and that the User Has Access

If (or once) the names are both /home/penner, you should also make sure that the user has access to their own home directory. Run:

You should see something that looks like this (though the date and time will be different):

b. user can not log in as user because it is a system account, which is specified by the --systemoption. System accounts are for daemons or services, not for human users, and are therefore given /bin/false for login shell. If you enter grep '^user' /etc/passwd, you will get something like this:

user:x:117:123::/opt/user:/bin/false

To allow user to log in, you can use usermod to change its login shell to bash:

usermod -s /bin/bash user

Alternatively, you can also edit /etc/passwd by hand. You may also want to make some other changes to user's UID, GID, and home directory location.

c.

Steps to Create a New Sudo User

Log in to your server as the root user.

Use the adduser command to add a new user to your system.

Be sure to replace username with the user that you want to create.

Set password prompts:

Hire Me For All Your Tutoring Needs
Integrity-first tutoring: clear explanations, guidance, and feedback.
Drop an Email at
drjack9650@gmail.com
Chat Now And Get Quote