RHCSA Practice Questions

Download as doc, pdf, or txt
Download as doc, pdf, or txt
You are on page 1of 18

RHCSA Practice Questions

1. User Administration

2. Permissions

a. Standard permissions

b. Access Control List

3. I/O redirections & Regular Expressions

4. Kernel

a. Kernel boot Parameters

b. Kernel Upgrade

5. Boot process

6. Cron Scheduling

7. Servers

a. FTP Server

b. HTTP Server

8. Storage Administration

a. Partitioning

b. LVM

c. Swap

9. LDAP

10. NFS

11. Software management

a. YUM

b. RPM

12. Network Setup


User Administration

Q. What command would lock satish’s account?

A. usermod –L satish

When an account is locked, user cannot log into his/her


account even if the password is known. The first exclamation
mark (!) in the /etc/shadow file will confirm that the
account is locked.

Q. What command would unlock satish’s account?

A. usermod –U satish

The exclamation mark (!) from the /etc/shadow file will be


removed indicating that the user satish is not locked
anymore.

Q. What command would cause satish’s account to expire on march


15th 2012?

A. chage –E 2012-03-15 satish

Keep in mind that the date is expressed in the YYYY-MM-DD


format.

Q. What command would show the groups satish is a member of

A.
 id satish

 groups satish

Both of the above commands will show the groups that user
satish belongs to. The primary group is mentioned at the
beginning of the list.

Q. How do you assign a password of Qi5#1k to user satish

A. echo ‘Qi5#1k’ | passwd –-stdin satish

The above command will not ask the password to be entered


twice. It is also easier as we can see the password that we
are setting.

Q. How do you create a user named satish with a primary group


of cprog and the secondary group of jprog.

A.

 groupadd cprog  Only if the group is not present

 groupadd jprog  Only if the group is not present

 useradd –g cprog –G jprog satish

Please note that the –g is used for assigning a primary


group and –G is used for assigning a secondary group to a
user.
If the user satish already existed then you can use the
usermod command instead of useradd as follows.

 usermod –g cprog –G jprog satish

List of groups is stored in the /etc/group file.

Q. How do you force a user satish to change his password on his


next logon.

A. chage –d 0

Q. How do you force user satish to have his password validity


to 30 days. In other words satish’s password is valid only
for 30 days since his last password change.

A. chage –M 30

Note:

Information regarding the users’ password policy is stored


in the /etc/shadow file.

Q. How do you create a user named satish whose UID is 2013

A. useradd –u 2012 satish


Note: UID is a unique number assigned to each user. This
number is stored as a third field in the /etc/passwd file.

Q. How do you create a user named satish who has access to an


interactive shell.

A. useradd –s /bin/bash satish

Note: There are multiple interactive shells like


/bin/ksh, /bin/csh, /bin/bash etc. In the above example we
have assigned /bin/bash to user satish.

If you want user satish to have a non-interactive shell - in


other words you don’t want user satish to log in, you must
assign a shell named /sbin/nologin as follows

useradd –s /sbin/nologin satish


Cron Scheduling

Q. When will the following jobs run?

 00 07 25 12 * /root/backup.sh

 */5 * * * * /root/take_stats.sh

 07 03 * * * /root/email_check.sh

 30 16 * * 5 /root/check_server.sh

 00 00 * * 1-5 /root/check_server.sh

A.

 /root/backup.sh will run at 7 AM on Christmas Day(25th of


December)

 /root/take_stats.sh will run every 5 minutes

 /root/email_check.sh will run every day at 3:07 AM

 /root/check_server.sh will run every Friday at 4:30 PM

 /root/check_server.sh will run at midnight on all


weekdays(M,Tu,W,Th,F)

Note:

field allowed values


----- --------------
minute 0-59
hour 0-23
day of month 1-31
month 1-12 (or names, see below)
day of week 0-7 (0 or 7 is Sun, or use names)

Q. What command shows all of your scheduled jobs

A. crontab –l

Q. What command shows all of satish’s scheduled jobs

A. crontab –u satish -l

Q. What command will allow root to setup a cron schedule for


user satish to run the /bin/ls command every minute.

A. crontab –u satish -e

 Once you type the above command, a temporary file will be


opened in vi. You will need to type the following line and
just save the file.

* * * * * /bin/ls

Once the file is saved you can confirm the cron schedule by
typing the crontab –u satish –l command
 Another way to perform the same task is to edit the
/etc/crontab file and add the following line at the
bottom of this file.

* * * * * /bin/ls -u satish
Regular Expressions & I/O redirection

Q. Print all usernames that begin with the letter r.

A. grep '^r' /etc/passwd

Note:

^ means the beginning of the line. Similarly $ means the end


of the line.

Q. Search usernames that begin with the letter k and store them
in a file named /tmp/k_user_list.txt

A. grep '^k' /etc/passwd > /tmp/k_user_list.txt

Note:

The > I/O redirection will capture the standard of the grep
command and store in the file named /tmp/k_user_list.txt. If
this file is already present, the contents of this file will
be overwritten.

Q. Print all accounts whose shells (last column) are


/sbin/nologin

A. grep '/sbin/nologin$' /etc/passwd


Note: /sbin/nologin is a non-interactive shell

Q. List all files in /usr/share/doc that end with the number


four.

A. ls /usr/share/doc | grep '4$'

Q. Search all lines with the word Bombay from file


/tmp/cities.txt and order them in a-z. These ordered lines
should be stored in a new file named /tmp/Bombay.txt

A. grep 'bombay' /tmp/cities.txt | sort > /tmp/bombay.txt

Q. Find all files named a.txt on satish’s home directory.

A. find /home/satish –name 'a.txt' –print


Q. Find all files on your system whose permission is 777.

A. find / –perm 777 –print

Q. Find all files on your system whose owner is satish and


redirect them to another file named
/tmp/satish_file_list.txt.

A. find / –user satish –print > /tmp/satish_file_list.txt

Q. Find all files on your system whose permission is 777 and


change this permission to 700.

A. find / –perm 777 –exec chmod 700 {} \;

Note:

 For the chmod command, {} acts like a filename

 \; acts as a termination symbol for the chmod command.


Q. Find all files on your system that are owned by user satish
and copy these files in a directory named /tmp/satish_files.

A.

 mkdir /tmp/satish_files

 find / –user satish –exec cp {} /tmp/satish_files \;


RHCSA Practicals

Scenario #1

You are an SA who has been given a responsibility to manage the


security of a new project named SALESPD on a new production server.
Create the following users and groups with appropriate password
assignments. Make sure that you force the users to change their
password on the first logon

Groups Users Password

salesrep ajit, peter, mark, kiran A#!8903P

salesmgr jason, anup Q87$81j

Scenario #2

As a System Administrator you are responsible to take a backup of your


/etc directory every night. Build a shell script to take a backup of
the /etc/directory using the tar command. The backup script should be
named as /root/backup.sh. Schedule this script to run at 11:00 PM
every night – except Sundays.

Scenario #3

Find out the list of all users in the /etc/passwd file who have not
been assigned a “/bin/bash” shell. Save this list in a file named
/tmp/non_bash_user_list.txt. This list should be alphabetically
arranged from z-a.

Scenario # 4

No users should be able to read this file other than the users from
the “salesrep” group. It is assumed that root can read any files.

Scenario # 5

Create a user named jackie with UID of 3002 and default login shell as
“/bin/ksh” This user’s password should e set to Qip587#
Scenario # 6

Setup a cron job for user jackie to execute a command /bin/echo “Hi
How are you” at 1:20 PM on January 18, 2012.

Scenario # 7

Download a file named a.txt from the ftp server 172.24.8.111. The ftp
server is configured as an anonymous FTP server. The file has been
kept inside /pub directory of the ftp server. When you download the
file, keep it in the /tmp directory with a name of b.txt. Set up the
permissions and ownership on this file as follows.

1. Owner of file : anup

2. All users from the “salesmgr” group should be able to read and
write to this file.

3. But user named “jason” should not be able to modify any contents
of this file even if he is a member of “salesmgr” group.

Scenario # 8

Create a directory named /SAPESPD. This directory should be owned by


root. Set up this directory in such a way that:

1. Any member of group “salesrep” should be able to create files in


this directory.

2. Any member of the “salesrep” group should not be able to delete


any file other that the files created by him/her in this
directory.
Storage Management

Scenario #1

You have been given a task by your manager to plan for the future disk
space requirement of your server. As a first step towards this task,
you are required to find out the following information about your
server. Please run appropriate commands to gather the information.

 Names of the disks attached to your server.

 What are their sizes?

 How much of free space is left on each disk?

Scenario #2

As a continuation of the above exercise, you are also required to find


out the following.

 Names of the partitions, their sizes and their mount points?

 How much of free space is left in each partition?

 Which of these partitions can be resized, if necessary?

Scenario #3

Is LVM implemented for any of the partitions. If yes, find out the
following information.

 Physical Volumes

o Names of all Physical volumes


o Sizes of all Physical volumes

 Volume Groups

o Names of all Volume groups

o Sizes of all Volume groups

o Size of the physical extent of each volume group.

o How many physical extents are present in each volume group.

o How much of free space is left in each Volume Group

o How many extents are free in each volume group

 Logical Volume

o Names of all LVs and the VG that they belong to

o Sizes of all Logical volumes

o Mount points for each Logical volume, if mounted

Scenario #4

You have recently deployed a new web application on your Red Hat
server. You have realized that the memory requirement of this web
application is high. You, therefore, have decided to increase the swap
space to take care of this issue. In such a situation, configure your
server to have additional swap space of 500 MB. This additional swap
should be made available to the system when the server reboots.

Scenario #5

A new project has been started in your organization. The developers of


this project need additional disk space for the source code programs
related to this project to be stored in their respective home
directories. Increase the size of /home to 650MB. If for some reason
your are unable to resize it to 650MB, any size between 630MB and 660
MB will suffice.

Note: While performing the above operation there should not be any
data loss of existing data in the /home directory.
Scenario #6

For the above mentioned new project, there is a need to keep large
data files on the server. You need to cerate a separate mount point
named /sales_data for this purpose. Create a new volume group and a
logical volume for this purpose from the remaining free space on your
disk/s. The size of Physical extent of the volume group should be 8MB.
The logical volume should have 50 extents. This mount point should get
automatically mounted at the boot time.

Scenario # 7

Resize the file system /opt from its current size of 500 MB to 400 MB.
Do not lose any data while performing the resizing.

Scenario #1

You need to deploy an http server. Configure this server in such a way
that it can render html pages from his Document Root directory.
Download an already developed HTML page from an ftp server
172.24.0.254. The name of this HTML page file is abc.html. Configure
your web server so that this web page will be displayed when a user
hits your web site. You may rename this HTML file if necessary.

Open the appropriate port of your firewall for this web site to be
accessible from other machines.

Kernel Upgrade

Scenario #1

You need to create YUM repository on your YUM server. For this reason,
a RPM package named “createrepo” has to be installed on your YUM
server. The “createrepo” RPM and its dependent RPMs are kept in
/tmp/rpm directory.
Scenario #2

You are required to change Boot Loader’s Splash Screen to display the
name of your Organization ‘ABC Corporation’ instead of the default
‘Red Hat Enterprise Linux’ at the boot time.

Scenario #3

A new version of Linux Kernel is available. As a System Administrator


you have been given a task to upgrade your existing kernel to the new
one. You must keep the old kernel on the system as a backup. Make your
system to boot with the newer kernel.

The newer kernel is available at ftp://server1.example.com/pub/updates

Scenario #4

There is a need for a cluster setup in your company for providing High
Availability of production servers. For this reason, all servers in
the cluster must have the exact system time. You are required to setup
your current server’s system time to sync with the TIME server in your
organization as your current is part of a cluster. The IP address of
the Time Server is 172.24.0.254.

VM – (no servers to be installed)

1. /boot – partition – 100MB

2. / - partition – 3GB

3. Swap – vg1 – lv1 (pe size = 4M for vg1) – 500MB

4. /home – vg1 – lv2 (400MB)

5. /opt –vg1 –lv3 (500MB)

You might also like