Monday, May 20, 2024
2
rated 0 times [  2] [ 0]  / answers: 1 / hits: 779  / 2 Years ago, thu, september 1, 2022, 12:01:02

I have some files inside a folder with various formats like .txt, .pem, .csv and .json.

I want only sudo/root to be able access them. I have done


chmod 700

and


chmod 600

on each of those files. But, I can still print the private key of my .pem files by doing cat on terminal without sudo privileges and open .json files from the file system in "gedit".


What has gone wrong? How do I not let anyone access the contents of those files?


More From » command-line

 Answers
5

Suppose your file is named example.txt. Then:


$ sudo chown root: example.txt
$ sudo chmod o-rwx example.txt

should do the job.


If you want an entire directory exampledir to be accessible only to root:


$ sudo chown -R root: exampledir
$ sudo chmod -R o-rwx exampledir

[#2370] Thursday, September 1, 2022, 2 Years  [reply] [flag answer]
Only authorized users can answer the question. Please sign in first, or register a free account.
ionodest

Total Points: 252
Total Questions: 122
Total Answers: 100

Location: Liechtenstein
Member since Tue, Apr 27, 2021
3 Years ago
;