0% found this document useful (0 votes)
23 views6 pages

Groupadd User Useradd - G User - S /bin/bash - D /home/user - M User Passwd User Id User Ls - LD /home/user

1. This document discusses Linux user management and permissions. It covers creating a new user, viewing user information in /etc/passwd and /etc/group, and modifying file permissions with chmod. 2. Specific tasks include creating a user named "user", logging in as that user, viewing user data with grep and cut, and making a script executable with chmod +x. 3. It also discusses creating a directory as the "guest" user, prohibiting another user from accessing it, and restricting an owner's permissions to their own file.
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
23 views6 pages

Groupadd User Useradd - G User - S /bin/bash - D /home/user - M User Passwd User Id User Ls - LD /home/user

1. This document discusses Linux user management and permissions. It covers creating a new user, viewing user information in /etc/passwd and /etc/group, and modifying file permissions with chmod. 2. Specific tasks include creating a user named "user", logging in as that user, viewing user data with grep and cut, and making a script executable with chmod +x. 3. It also discusses creating a directory as the "guest" user, prohibiting another user from accessing it, and restricting an owner's permissions to their own file.
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 6

EPAM University Programs

DevOps external course


Module 4 Linux & Bash Essen@als
TASK 4.6

1. User management. Here we suppose there are at least two users, namely, root
and guest.
(i) Create a new user user
groupadd user
useradd -g user -s /bin/bash -d /home/user -m user
passwd user
id user
ls -ld /home/user
(ii) Log in to the system as “user” (hint use su).

(ii) Edit /etc/passwd to prevent user user from logging in to the system.
2. Content of /etc/passwd and /etc/group.

(i) Look through /etc/passwd and /etc/group (hint: use less or cat).
(ii) Get data from /etc/passwd and /etc/group about users: root, guest, user (hint:
filter by grep).

(iii)Parse /etc/passwd and /etc/group with cut.


cut -f1 -d: /etc/passwd cut -f1,2 -d: /etc/passwd
cut -f1,7 -d: /etc/passwd cut -f1 -d: /etc/group

cut -f1,2 -d: /etc/group

(iv) Try to call less on /etc/shadow and invoke


sudo less /etc/shadow
man -k shadow

man 5 shadow

Analyse content of /etc/shadow based on what you’ve found in man 5 shadow.


shadow — is a file which contains the password informa@on for the system's
accounts and op@onal aging informa@on.
/etc/shadow — Secure user account informa@on.
Each line of this file contains 9 fields, separated by colons (“:”), in the following
order: login name, encrypted password, date of last password change, minimum
password age, maximum password age, password warning period, password
inac@vity period, account expira@on date, reserved field.
For example user:!!$6$PO4lBQGk$9KoVSa.EsUtLXaDZya.hjwbGE/IOgtYl/vylH4T/
X802SCnlmNSr4Rd7MoNMd6dj5KU9bfpW5xjgkkTySb.z5/:18375:0:99999:7:::
3. Dealing with chmod.
(i) An executable script. Open your favourite editor and put these lines into a file
#!/bin/bash
echo “Drugs are bad MKAY?”
Give name “script.sh” to the script and call to
chmod +x script.sh
Then you are ready to execute the script:
./script.sh

(ii) Suppose, you have logged in to the system as guest. Create directory “testDir”
in the /tmp; put some file into testDir and prohibit user user from visi@ng this
directory (i.e. “testDir”).
(iii) Test, if it possible to forbid an owner of some file to read to or write from this
file.

You might also like