cancel
Showing results for 
Search instead for 
Did you mean: 
Chetan_Tiwary_
Community Manager
Community Manager
  • 107 Views

Red Hat Linux Interview Series 13

Q.) Write a cronjob to delete all .png files older than 7 days, everyday at midnight.

 

Q.) As a sysadmin, how will you send message to all logged in users for the system shutdown due to planned / unplanned maintenance ?

 

Q.) What happens when we use ctrl + c  and ctrl + z  to a process on the linux terminal ?

 

 

I'll be posting a series of Linux-related questions covering various skill levels. Feel free to share your insights and expertise. Your contributions will benefit learners at all stages, from those in current roles to those preparing for Linux interviews.

 

4 Replies
Ad_astra
Flight Engineer Flight Engineer
Flight Engineer
  • 57 Views

Q1) 

Write the cron job as follows:

0 0 * * * root find / -type f -name "*.png" -mtime +7 -exec rm -rf {} \;

Q2)
Message all users with the 'wall' command:

wall "System shutdown due to unplanned maintenance at 12:00. Please log out before that time"

Q3)

Ctrl + c - sends the SIGINT signal which effectively kills the currently running process.
Crtl + z - send the SIGTSTP which suspends the currently running process.

Chetan_Tiwary_
Community Manager
Community Manager
  • 40 Views

@Ad_astra you did great!  For Q1, when using -exec rm -rf {}  How will you handle race condition vulnerabilities if the directory is writable by others ?

Ad_astra
Flight Engineer Flight Engineer
Flight Engineer
  • 29 Views

I would substitute the -exec for -execdir as follows:

0 0 * * * root find / -type f -name "*.png" -mtime +7 -execdir rm -rf {} +

This would be useful if the directories being searched were writable by 'untrusted users'!

Reference the GNU docs for further explanation:

GNU Findutils 4.10.0

 

0 Kudos
Chetan_Tiwary_
Community Manager
Community Manager
  • 17 Views

Wonderful @Ad_astra !

Join the discussion
You must log in to join this conversation.