Question
Write a Ruby or Bash script that will print usernames of all users on a Linux system together with their home directories. Here's some example
Write a Ruby or Bash script that will print usernames of all users on a Linux system together with their home directories. Here's some example output: gitlab:/home/gitlab nobody:/nonexistent . As you can see, each line is a concatenation of a username, the colon character (:), and the home directory path for that username. Your script should output such a line for each user on the system. Next, write a crontab entry that accomplishes the following: ● Runs once every hour. ● Takes the output of your above script and converts it to an MD5 hash. ● Stores the MD5 hash into the /var/log/current_users file. ● On subsequent runs, if the MD5 sum changes, it should log this change in the /var/log/user_changes file with the message, DATE TIME changes occurred, replacing DATE and TIME with appropriate values. Make sure to replace the old MD5 hash in /var/log/current_users file with the new MD5 hash.
Both the script and crontab entry should be provided for the answer to be complete.
Step by Step Solution
3.43 Rating (156 Votes )
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started