Friday, May 3, 2024
 Popular · Latest · Hot · Upcoming
5
rated 0 times [  5] [ 0]  / answers: 1 / hits: 700  / 2 Years ago, wed, august 24, 2022, 8:41:00

I just learned about file security, user & group, etc.
And I appreciate a lot about the elegance of the filesystem of linux.



My username is lyg, and I found there are some files with owner lyg in /proc/, as shown below:



lyg@lyg-VirtualBox:~$ ll /proc/|grep lyg
dr-xr-xr-x 8 root lyg 0 Aug 7 09:11 1119/
dr-xr-xr-x 8 lyg lyg 0 Aug 7 09:47 1298/
dr-xr-xr-x 8 lyg lyg 0 Aug 7 22:05 7097/
dr-xr-xr-x 8 lyg lyg 0 Aug 7 22:05 7098/


Then I found that this could not happen normally, these files cannot be created by me manually, since I had no permissions requiered, see:



lyg@lyg-VirtualBox:~$ ls -ld /proc/
dr-xr-xr-x 108 root root 0 Aug 7 09:10 /proc/


and here was my processes information, from which I knew that /proc/1298/ was related to -bash process:



lyg@lyg-VirtualBox:~$ ps -ef|grep lyg
avahi 452 1 0 09:11 ? 00:00:00 avahi-daemon: running [lyg-VirtualBox.local]
lyg 1298 1119 0 09:11 tty1 00:00:22 -bash
lyg 7099 1298 0 22:05 tty1 00:00:00 ps -ef
lyg 7100 1298 0 22:05 tty1 00:00:00 grep --color=auto lyg


So, how are these files in /proc/ created?


More From » permissions

 Answers
5

Those files are related to the processes created by the OS on behalf of you. Those files store real-time information about the processes, such as memory-block used by the processes, opened files by the processes, names of files which are accessed by your processes.



Those files are created by the OS, that is Ubuntu for you. As Ubuntu, i.e the OS has full permission on the file system, so, it can create any file anywhere



Let's do an experiment:



For experiment, run these line of codes in your terminal




  1. First see the number of files in /proc on behalf of you



     ll /proc/ | grep lyg | wc -l

  2. Then create another process. Let the new process be another bash instance. So type bash and hit Enter.


  3. Again execute this command



    ll /proc/ | grep lyg | wc -l


    you can now see that, there is at least 1 more file. This file is created for the new process


  4. Then now exit the newly created bash, with exit command.


  5. Now again type this command:



    ll /proc/ | grep lyg | wc -l



You will see that, the output now is 1 less than the previous. Because, The OS deleted the file corresponding the just existed or terminated bash process.


[#36325] Thursday, August 25, 2022, 2 Years  [reply] [flag answer]
Only authorized users can answer the question. Please sign in first, or register a free account.
clegian

Total Points: 283
Total Questions: 115
Total Answers: 115

Location: Morocco
Member since Tue, Feb 2, 2021
3 Years ago
clegian questions
;