Friday, April 26, 2024
 Popular · Latest · Hot · Upcoming
6
rated 0 times [  6] [ 0]  / answers: 1 / hits: 12665  / 2 Years ago, fri, november 4, 2022, 1:52:05

To combat procrastination, I edit my /etc/hosts file by adding time-wasting websites and pointing them to localhost. However, the flesh is weak and I often find myself reverting my changes.



I was thinking of the following solution, but I don't know if it is technically possible.



I would ask a trusted friend to come over, create a new account with a strong password that I don't know, change the owner and permissions of the /etc/hosts file so that only that new user can change that file and that I nor root no longer have access to it.



The use case would be that I ask my friend to come over before the exam period, he changes the file and puts the procrastination blocking measures in place, and that during the time I need to study I have no way of editing the file myself. After the exam period is over, I ask him to 'unlock' the file and I can browse freely again.


More From » permissions

 Answers
7

You can lock a file so not even root user can edit it.



sudo chattr +i /etc/hosts


Stop reading this answer until after you exams :)



Then you unlock the file again using



sudo chattr -i /etc/hosts

[#43906] Saturday, November 5, 2022, 2 Years  [reply] [flag answer]
Only authorized users can answer the question. Please sign in first, or register a free account.
pheter

Total Points: 223
Total Questions: 111
Total Answers: 119

Location: Guadeloupe
Member since Sat, Aug 22, 2020
4 Years ago
pheter questions
Mon, Jun 21, 21, 07:35, 3 Years ago
Tue, Jul 5, 22, 22:50, 2 Years ago
Sat, Nov 27, 21, 17:50, 2 Years ago
;