rhcsa 14-19
14.write script awesome.sh in the root directory on system1
a) if "me" is given as an argument, then th script shoutl "Yes, I'm awesome"
b) if "them is given as an argument " then he script soult output "okay, they are awesome"
c) If the argument is empty or anything else is given, the script should output "Usage./awesome.sh me|them"
solution:
#!/bin/bash
if [ "$1" == "me" ] ; then
echo "Yes, I'm awesome."
elif [ "$1" == "them" ] ; then
echo "Okay, they are awesome."
else
echo "Usage ./awesome.sh me|them"
fi
15. Create users phil, laura, stewart and kevin
a) all new user should have a file named "welcome" in thein home folder after account creation
b) all user password expire after 60 days and be at least 8 characters in length
c) phil and laura should be part of the "accounting" group. If the froup doesn't already exist, create it.
d) stewart and kevin should be part of the "marketing" group. If the group doesn't already exist, create it.
solution:
a)[root@localhost ~]# touch /etc/skel/Welcome
b) vi /etc/login.defs
- change PASS_MAX_DAYS
- change PASS_MIN_LEN
c) +d
[root@localhost ~]# useradd phil
[root@localhost ~]# useradd laura
[root@localhost ~]# useradd stewart
[root@localhost ~]# useradd kevin
chage -l phil
chage -l laura
chage -l stewart
chage -l kevin
groupadd accounting
gpasswd -a phil accounting
gpasswd -a laura accounting
groupadd marketing
gpasswd -a stewart marketing
gpasswd -a kevin marketing
16. only members of the accounting group should have access to the "/accounting" directory. Make laura the owner of this dicrectory. Make the accounting group the group owner of the "/accounting directory.
mkdir /accounting
chown laura:accounting /accounting
17. only members of the marketing group should have access to the "/marketing" directory. Make stewart the owner of this dicrectory. Make the marketing group the group owner of the "/marketing directory.
mkdir /marketing
chown stewart:marketing /marketing
18. New files should be owned by the group owner and only the file creater shoul have permission to delete their own files.
[root@localhost ~]# chmod 770 /accounting
[root@localhost ~]# chmod 770 /marketing/
[root@localhost ~]# chmod g+s /accounting/
[root@localhost ~]# chmod +t /accounting/
[root@localhost ~]# chmod g+s /marketing/
[root@localhost ~]# chmod +t /marketing/
19. Create a cron job that writes "this practice exam was easy and I'm ready to ace my RHCSA" to /var/log/messages at 12 pm only on weekdays
0 12 * * 1-5 echo "this practice exam was easy and I'm ready to ace my RHCSA" >> /var/log/messages
Žiadne komentáre:
Zverejnenie komentára