OS Lab Assignment 1
OS Lab Assignment 1
OS Lab Assignment 1
Class BCS-4A
When a user is created in Linux it maintains some file for each users, like the following:
1. /home: This directory stores the user’s home directory.
2. /etc/skel: This file stores default initialization file for the login shell.
3. /etc/shell: This file contains information of the login shells, like BASH.
4. /etc/passwd: This file contains information about the user passwords.
5. /etc/group: This file contains information about the user’s group.
6. /etc/shadow & /etc/gshadow: This file contains encrypted password file for user (shadow)
and group (gshadow).
7. /etc/login.defs: This file contains information about login defaults for the users.
These files are divided into 2 Parts one parts deal with passwords and the other part deal with User
Environment Management or are called profiling files.
e.g. abdullah:x:1000:1000:abdullah,,,,:/home/abdullah:/bin/bash
e.g PASS_MIN_LEN 5
CREATE_HOME yes
b. There is a file that goes by the name of login.access in the same /etc directory,
where the permissions of each users are defined. By using + and – symbols root can
alter the permissions given to the user, e.g.
+:chris:rabbit.mytrek.com
+:ALL EXCEPT larisa aleina:console
Option Details
This options make the respective account
-d / –delete
password less.
Immediately expires the user’s password and
-e / -expire forces him/her to change his password on next
login
-h / -help Displays help related to the passwd command
This option is followed by an integer value
INACTIVE_DAYS, which set the number of day the
-i / -inactive INACTIVE_DAYS
user can go inactive after the password expires
before the account is deactivated
This option is used when you have to change
password if it has expired. If max day for expire
-k / -keep-tokens
password is 9999 (never) it will change the
password.
It used to lock an account, thus making
-l / -lock
impossible to login to the account using normal
attempts. It appends ‘!’ symbol with the
password to lock it.
It sets the minimum number (MIN_DAYS) of days
-n / -mindays MIN_DAYS the user will wait to change his/her password
again.
This will not print the statement “Changing
-q / -quite
password for $username”.
This is used to change password for repository
-r / -repository REPO
name ‘REPO’
This option is used to change the root directory
-R / -root CHROOT_DIR
for passwd process for once.
This option shows password status for the user in
-S / -status
*7 fields
This options shows password status for all users
-S[, -status] –a[,-all]
(**-all cannot be used alone )
-u / -unlock This options unlocks the password for the user
This option is user to generate a warning
-w / -wrndays WARN_DAYS message for the user WANR_DAYS before the
password expires
This option will set max days a password is set to
-x / -maxdays MAX_DAYS
be valid after changing.
*7 Fields: Username, Account status (L (Locked), NP (No Password), P (Usable password), Date of last
password change, minimum days for password change, maximum days for password change, warning
period before password expires, inactivity period.
Note: while changing the password, make sure you remember it as it is not echoed on the terminal
Option Details
Minimum number of days [DAYS] to wait after
-m DAYS
setting a new password
Maximum numbers of days [DAYS] for which a
-M DAYS
password can remain unchanged
-d The last day password was changed
Specify the date [DATE] in mm/dd/yyyy format
-E DATE
for expiring the account
Allowable days [DAYS] of inactivity after which
-I DAYS (Capital i)
the password will expire.
Number of days before to warn for expiration of
-W DAYS
password
-l (small L) Display current password expiration controls
Linux provides certain commands for user account managements like useradd, etc and also provide
similar commands for user’s group management. Other than that if you have a GUI interface you also
use tools like KUser and GNOME User settings they both are tools to manuplate user accounts and
groups.
These commands search and make changes in /etc/passwd, /etc/shadow, /etc/login.defs and /etc/skel
directory.
Options Details
-d dir Used to set the directory of the user
-D Displays defaults for all settings. Can also be used
to reset default settings for the home directory (-
b), group (-g), shell (-s), expiration date (-e), and
password expirations (-f).
-e mm/dd/yyyy Sets an expiration date for the account (none, by
default). Specified as month/day/year.
-f days Sets the number of days an account remains
active after its password expires.
-g group Sets a group.
-m Creates user’s home directory, if it does not exist.
-m -k skl-dir Sets the skeleton directory that holds skeleton
files, such as .profile files, which are copied to the
user’s home directory automatically when it is
created; the default is /etc/skel.
Note: After adding a new user you will have to assign it a password using passwd command.
Option Details
-f / --force Forcefull removal of the user, enev if the user
is still logged in. or files not owned by user
-h / --help Get help on the userdel topic
-r / --remove Remove users home and mail spool directory
-R / --root CHROOT_DIR Directory to CHROOT into
-Z / --selinux-user Remove any selinux entry for the user
**Selinux is a distributions of linux with a set of kernel modification developed by red hat
software called Security Enhanced Linux.
These commands search and make changes/edits in /etc/group and /etc/gshadow directories.
e.g. abdullah:x:1000:
Private Groups: These are special groups that are specially set up of the user. When the user is created a
private group is assigned to him/her by default from OS by the same name of the user. This process is
also called User Private Grouping (UPG).
Group Directories: They are similar to the user files defined in home directory. To create them just
create a directory by the name of the group in /home and then change the group’s home to that
directory.
chmod g+rwx /home/engine: //this will allow the group members to perform the read, write and
execute on the group files/directories. By the same procedure you can add shared file and directories in
the group.
Linux provides group management commands like groupadd, groupmod and groupdel.
1. groupadd command: this command is used to add a new group to the system.
groupadd [-option] GROUP
Option Details
-f / --force Exit if group is already created. If used with
–g / --gid GID the it will do the same action
-g / --gid GID If you want to specify the group a specific
group id
-h / --help To view help
-K / --key KEY=value To override the defaults in /etc/login.defs
-o / --non-unique To create a duplicate group with non-unique
GID
-p / --password PASSWORD Use this password for the new group
-r / --system To create a system account
2. groupmod command: To change some attribute if the group. groupmod [-option] GROUP
Option Details
-g / --gid GID To change group id of group
-h / --help To get help
-n / --new-name NEW_GROUP_NAME Change the group name to
NEW_GROUP_NAME
-o / --non-unique Allow to use non-unique GID (duplicate)
-p / --password PASSWORD To set the group password to PASSWORD
3. groupdel command: to delete a group. groupdel –r group_name. This will remove the group
group_name.
File Permissions: As we have already studied chmod, chown, umask. Here we will user chgrp command.
You can also use a nested command for chown and chgrp. By using the following syntax:
The literal meaning of quota is the reserved part that a person or is group is entitled to receive.
In a computer system, we have a disk space that is a primary resource that all the users of the system
will share. There is a probability that one users will consume all the space while the other user won’t be
able to use any of it and even run any application. This happens as the user crate more and more files.
The terminology Disk Quota refers to the shares each user will get the primary storage resource. By
using this art the admin could restrict the disk usage for each registered user. Do perform this we use
Quota Tools.
Quota Tools:
Quota checks can be implemented on file system of a hard disk partition mounted on the system. To
unable quota quotacheck and quotaon commands. They are executed in /etc/rc.d/rc.sysinit script.
Each partition is to be mounted with quota options usrquota (User) and grpquota (Group). These
options usually mount entry in /etc/fstab.
This command will mount /dev/hda6 to disk partition to /home directory with support for groups and
users quota.
You also need to create quota.user and quota.group for each partition for quota. You can do this by
running the following statement:
quotacheck –a /dev/hda1: this will create hda1 disk partition on the hard disk partition.
1. edquota command: This command is used to access quota record for a particular user or group.
Option Details
-u Edits the user quota. This is by default
-g Edits group quota
-p Duplicates a quota for user or group
-t Edits soft time limits for each system file
Note: Hard limit deny the user to the ability to exceed the allotted limit while soft limit produces
a warning for the user so that he can edit the quota.
//this is the quota file for groups and users
2. quota command: this command helps user to view there memory and disk space usage.
Option Details
-u Prints user quota
-g Print user’s group quota details
-v Displays quotas on file system where no
storage is allocated
-q Prints info. on file systems where usage is
over quota
Note: To get a summary of quotas user can use repquota command. E.g. repqouta /dev/hda1. With –a
option we can check all file systems.