Monday, April 29, 2024
14
rated 0 times [  14] [ 0]  / answers: 1 / hits: 723  / 1 Year ago, sat, february 4, 2023, 10:36:03

I have a guest computer for only internet usage. Some users download some files and leave them on the desktop but the computer does not have enough space for all guests and it is not allowed to put a file in there.



What I want to do is clean every file inside the home directory when the computer starts, but keep the directory structure like Music, Pictures, Documents & Downloads.



How can I accomplish this?


More From » software-recommendation

 Answers
6

You can safely remove all files in the home directory, because they are recreated, apart from files copied on user creation from /etc/skel, so



#!/bin/bash

shopt -s dotglob
rm -rf /home/username/*
sudo -u username cp -a /etc/skel/* /home/username/


where username should be substituted with something meaningful.



Per your request ("when computer starts") this can be executed from /etc/rc.local. More likely, you want to execute it between each to logins, so put it under /etc/gdm/PostSession or /etc/gdm/PreSession.


[#43685] Monday, February 6, 2023, 1 Year  [reply] [flag answer]
Only authorized users can answer the question. Please sign in first, or register a free account.
terose

Total Points: 185
Total Questions: 125
Total Answers: 131

Location: Venezuela
Member since Mon, Dec 13, 2021
2 Years ago
terose questions
;