0% found this document useful (0 votes)
2 views

Basic_User_Environment

The document outlines a lab exercise for familiarizing users with the basic user environment in a CentOS 7 system, requiring root or sudo access. It includes various commands and tasks to explore user profiles, environment variables, and the configuration of login scripts. Additionally, it provides tips for regenerating user dot files and creating custom login variables, along with resources for further research on user management and environment variables in CentOS.

Uploaded by

milukyone
Copyright
© © All Rights Reserved
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
2 views

Basic_User_Environment

The document outlines a lab exercise for familiarizing users with the basic user environment in a CentOS 7 system, requiring root or sudo access. It includes various commands and tasks to explore user profiles, environment variables, and the configuration of login scripts. Additionally, it provides tips for regenerating user dot files and creating custom login variables, along with resources for further research on user management and environment variables in CentOS.

Uploaded by

milukyone
Copyright
© © All Rights Reserved
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
You are on page 1/ 4

ProLug – Basic_User_Env Lab (Lab3)

Required Materials

CentOS 7 Machine

Root or sudo command access

EXERCISES (Warmup to quickly run through your system and familiarize yourself)

1. cd ~
2. ls
3. mkdir lab3
4. cd lab3
5. printenv | more #what is this showing you?
6. printenv | grep user
7. echo $PATH
8. printenv | wc –l #what does this do?
9. printenv | nl | more #does this verify the last?
10. su – student1
11. printenv | more
12. printenv | wc –l #is this more or less than root had?

LAB (as root unless otherwise stated)

1. Basic User environment


The /etc/skel directory has hidden files that are added into new user home directories. A list of
some of those files are:
.bashrc - basic bash configuration
.bash_logout - executed when you leave bash
.bash_profile - configures bash startup environment
And others can be there depending on software installed on the system
a. ls –a /etc/skel
b. ls –a /home/student1 #from previous labs
c. touch /etc/skel/.new_user_file
d. useradd studentlab3
e. ls –a /home/studentlab3
i. verify that the .new_user_file exists

*Tip from the professionals*


Users can change their “dot hidden files” in their profile and then have login issues with
different systems. This can especially be true if you’re using home directories shared out from a
network where all Linux/Unix systems are linked to a set of home directories. Since /etc/skel can
generate ~/. Files, when a user cannot log into a system this can sometimes fix the problem

f. cd /home/student1
g. mkdir old_dot_files
h. mv .* old_dot_files/
i. ls –a old_dot_files #verify files are all there
ii. ls –a #verify all dot files are not in /home/student1
i. su – student1
j. ls –la #verify that new files have been created

This can be a safe way to re-generate “dot files” for a user when they or their processes
have messed up their login files.

The /etc/bashrc file is used for aliases and functions. Take a minute to look around in your
system’s /etc/bashrc file
k. more /etc/bashrc

/etc/bashrc also does a very important function of setting the default umask

l. more /etc/bashrc #look specifically for how the umask is set


m. touch /root/umasktest1
n. vi /etc/bashrc
i. copy the umask line with “yy”
ii. type “pp” to copy the line below the original
iii. comment out the original umask with #
iv. change your new umask to something else
v. hit esc
vi. type wq:
o. touch /root/umasktest2
p. ls –l /root/
q. Set system back the way it was.
*note: Umask is different for users with ID’s under 100 and ID’s over 500 (regular users).
So ensure you’re changing it properly if the test does not work*

The /etc/profile script runs scripts within the /etc/profile.d directory. Take some time to
familiarize yourself with both

r. more /etc/profile
s. ls /etc/profile.d

Creating a custom set of login variables

t. su – student1
u. echo $starttime; echo $starthost #should not have anything in it
v. exit #go back to root
w. touch /etc/profile.d/startgather.sh
x. vi /etc/profile.d/startgather.sh
i. type “i”
ii. export starttime=`date +%T`
iii. export starthost=`hostname`
iv. type esc
v. hit :wq
y. su – student1
z. echo $starttime; echo $starthost #should now contain the values set in
profile.d/startgather.sh

Spend 5 minutes googling or otherwise researching online about these topics (these are for you, so take
some notes and learn some stuff here):

 https://www.centos.org/docs/5/html/5.1/Deployment_Guide/s2-users-add.html
Check this out and look at the variables that can be set with useradd. Do any of them surprise
you? How might these help you administer users?

 http://centoshowtos.org/environment-variables/
Look specifically here at how to add a path. Not all software installs automatically add their
paths. In the case of gpfs there is a directory /usr/lpp/mmfs/bin/ that holds all the commands
and is not automatically linked.
Think of how you might do this if something were installed under
/opt/myprogram/bin/my_startup.sh

How might you add this path?

Test by making the file and pretending to startup


o touch /opt/myprogram/bin/my_startup.sh
o vi and add the line echo “starting the program, boss”
o chmod 755
o add the path with that technique to include /opt/myprogram/bin/
o type my_startup.sh #does it work?

You might also like