I am a teacher and I use Linux which is great! But students are curious about this "new" operating system they do not know and in GUI they tweak program settings which affects hidden files inside /home/user:

[profesor@240-kateder ~]$ ls -a
.              .dbeaver4         .gtkrc-2.0        .sane
..             .dbeaver-drivers  .icons            .swt
.bash_history  .dropbox          .kde4             .themes
.bash_logout   .eclipse          .local            .thumbnails
.bash_profile  .esd_auth         .lyx              .ViberPC
.bashrc        .FlatCAM          .masterpdfeditor  .w3m
.cache         .FreeCAD          .mozilla          .Xauthority
.config        .gimp-2.8         .pki              .xinitrc
.convertall    .gnupg            .qucs             .xournal

This is unwanted because over time program interfaces will change so dramatically that programs will be missing toolbars, buttons, main menus, status menus... and students end up with completely different GUI, so they are calling me about the issue and we spend too much time.

Now to optimize this I have to make sure that program settings (hidden files inside /home/user) aren't changed, so I tried to change them like sudo chmod -R 555 ~/.* but this didn't work out well for all of the programs, because some of the programs want to manipulate their settings at boot and they therefore fail to start withouth sudo. And student's don't have sudo privileges.

But sudo chmod -R 555 ~/.* worked for .bash_profile, .bash_logout, .bashrc, .bash_history, .xinitrc so I was thinking if I would:

  1. prevent user from deleting .bash_profile, .bash_logout, .bashrc, .bash_history, .xinitrc
  2. copy all hidden setting files into a folder /opt/restore_settings
  3. program .bash_profile to clean up all settings in users home directory on login using rm -r ~/.* (I assume this wouldn't delete files from point 1., if I protect them) and then restore settings from the /opt/restore_settings.

I wan't to know your opinion about this idea, or if there is any better way to do it. And I need a way to prevent users from deleting files from point 1. Otherwise this can't work.

  • 3
    My personal opinion would be to instead provide hourly, daily and weekly backups of their home directories accessible through ~/.snapshots/ using something like rsnapshot. That way they can restore files if they need to. I'm not a big fan of locking people down... especially students.
    – Kusalananda
    Commented Sep 3, 2017 at 9:55
  • @Kusalananda I don't like locking them down too, but as I said if you want to work in a didactical way locking them down is needed. Otherwise after a month of usage, newly installed operating systems will be all messed up.
    – 71GA
    Commented Sep 3, 2017 at 10:01
  • 3
    I believe that making mistakes is part of the learning process. So allow your students to make them, but do guide them to overcome such mistakes. Commented Sep 3, 2017 at 10:06
  • Let them make mistakes at home. In school I have to keep 120 computers keep on running and I really don't have nerves to run from one computer to another to reset the program settings...
    – 71GA
    Commented Sep 3, 2017 at 10:28

2 Answers 2


Totally different approach: Create a group students, give each student his own account with group membership in students. Have a script that restores a given home directory from a template to a known good state, possibly deleting all extra dot files. Tell students about this script.

If you have a number of computers, centralize this approach (user management on a single central server), and use a central file server for student home directories, so each student gets the same home directory on any machine.

Together with proper (basic chmod) permissions everywhere, this will ensure that each student can only wreak havoc in his or her own home directoy, and can restore it when it breaks, possibly loosing their own customizations in this process, so they'll be more cautious next time.

BTW, that's a very standard setup for many users on a cluster of machines.

  • This is very similar to the approach I suggested. Well anyway I did it the way I suggested and it works nicely! Because you also gave idea about central server I will accept your answer as the best one.
    – 71GA
    Commented Sep 4, 2017 at 19:35

Setting Immutable and Undeletable attributes on the dotfiles via chattr should help. See man chattr or the wikipedia entry for chattr

Does not prevent changing or deleting totally since a user can run chattr, but it makes it definitely more obscure.

  • I think making it more obscure will do! =)
    – 71GA
    Commented Sep 3, 2017 at 10:03
  • 2
    This does not solve the problem that the applications want to legitimately change and save their settings at startup. Commented Sep 3, 2017 at 10:04
  • True for newly created files .. but not true for existing of pre-created files like .bashrc, .bash_profile or .anything, as stated.
    – martijn
    Commented Sep 3, 2017 at 10:08
  • This doesn't work well, because it locks some files and X cannot start on relogin. So it looks like locking files isn't even an option...
    – 71GA
    Commented Sep 3, 2017 at 10:26

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .