1

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?

1

3 Answers 3

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.

0
1

Those files in /proc/nnnnn are created by the kernel for every process (PID) running on your system and contain low-level process-related information and data.

As you may know, the superuser (or root) can create files with any ownership and any permissions...and the kernel effectively runs with full privileges (as "root"), so it can create those files in your name.

0

A process started by you can create other processes under your account control. May be you have started some application which has created other forks.

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

and these three are currently executing process for displaying the output; created by you.

You must log in to answer this question.

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