Questions tagged [proc]

procfs (or the proc filesystem) is a special filesystem in UNIX-like operating systems that presents information about processes and other system information in a hierarchical file-like structure

Filter by
Sorted by
Tagged with
0 votes
1 answer
456 views

tab completion of /proc/self/fd/ shows different completions compared with listed contents

Using zsh, if I try tab completion of the following command ls /proc/self/fd/ then I see the following: files 0@ 1@ 10@ 11@ 12@ 13 2@ 3 However, when I press enter (without completing) I ...
Ben's user avatar
  • 315
2 votes
0 answers
2k views

How to get unix socket inode given its path?

Let /var/run/mysqld/mysqld.sock/ be an open socket. I can stat it to get inode of the file (here 1200) # stat /var/run/mysqld/mysqld.sock File: /var/run/mysqld/mysqld.sock Size: 0 ...
matt's user avatar
  • 537
4 votes
1 answer
3k views

What's the meaning of [socket:number] in /proc/pid/fd

UNIX domain sockets opened by given $PID are listed in /proc/$PID/fd/X as symlinks to [socket:ID]. I understand that it's an identifier of that socket, but what exactly is it? Is it an inode in sockfs?...
matt's user avatar
  • 537
1 vote
1 answer
173 views

Will execute time of kernel thread will be included in /proc/[pid]/stat?

My process accesses a file in disk, which is mounted with iSCSI driver. I knew iSCSI has several kernel modules and some of them run as kernel threads. As my knowledge iSCSI needs a lot of CPU time, ...
5f3759df 0x's user avatar
0 votes
1 answer
430 views

Emulate /proc folder

I've a software that uses a few nasty algorithms to determine, wether it runs in a docker container or not. One example is, that it scans /proc/1/cgroup for non root paths (i.e. /docker/SOME-UUID ...
Georg Friedrich's user avatar
2 votes
1 answer
3k views

Documentation for the meaning of entries in /proc/meminfo and /proc/vmstat

Where can I find documentation explaining the meaning of entries in /proc/meminfo and /proc/vmstat files? I looked up on the web and the man page of proc but could not find much. Many entries are self ...
Ketan's user avatar
  • 9,226
0 votes
1 answer
574 views

What can a debugger do with /proc that cannot be done with ptrace?

The Wikipedia article on ptrace says: Communications between the controller and target take place using repeated calls of ptrace, passing a small fixed-size block of memory between the two (...
Ryan1729's user avatar
  • 601
1 vote
1 answer
4k views

kswapd0 in ubuntu slows down the system

We don't have any service running in the ubuntu but currently, we see the system becomes very slow from the morning, When I tried top command, I see there are two new services running like below, top ...
Harry's user avatar
  • 201
0 votes
1 answer
448 views

Is there any way to recover files from the informations in `/proc`? [duplicate]

I have just asked in an interview that if someone mistakenly deletes apache logfile from /var/log/apache/access.log while it's being written, can you recover it? After my answer interviewer said that ...
arif's user avatar
  • 1,459
1 vote
2 answers
255 views

Detailed information on a single process in a greppable format

Utilities such as ps and top are good for looking at many processes side-by-side. However, they are inconvenient for examining many fields of a single process and are not amenable to using grep. For ...
Nathaniel M. Beaver's user avatar
0 votes
1 answer
2k views

pidstat %CPU vs htop %CPU of a process

I'm using the pidstat to monitor the cpu usage of a process and it shows 100%. For the same process the htop or top shows 200% for the same process. The system has 16 cores, and the process i am ...
Madan's user avatar
  • 101
2 votes
1 answer
1k views

How do I restore files removed from /usr/bin?

TL;DR at the bottom. Background: The following occured on my CentOS 6.10 production server. I was using a browser based terminal program to run the program Midnight Commander which is a console-...
iskyfire's user avatar
  • 133
0 votes
1 answer
152 views

Does statting /proc/PID/stat make the kernel generate the contents so that a file size is returned?

I'm implementing an alternative to top, and thought that I should preallocate an appropriately sized buffer to hold the read contents of /proc/PID/stat. However, knowing that it's a pseudo filesystem ...
JoshuaRLi's user avatar
  • 253
0 votes
1 answer
587 views

How to determine active/passive end of TCP connection

If I inspect information about established TCP connections as returned by sock_diag(7) (or in /proc/net/tcp), how can I determine whether a given connection originated with the local side owning the ...
Drux's user avatar
  • 547
4 votes
1 answer
3k views

permission denied, even when I have permission

This may be a dumb question, but how does symbolic link preserve permission? $ls -ld /proc/1/exe ls: cannot read symbolic link '/proc/1/exe': Permission denied so I look up what the link point to ...
Herdsman's user avatar
  • 340
4 votes
0 answers
580 views

failure to stat /proc/self/map_files symlink - permission denied?

I am writing some code that checksums executable mappings. Through /proc/$PID/map_files, Linux provides symlinks to the files that back memory mappings. My code is calling "stat()" on one of these ...
rotaist's user avatar
  • 41
0 votes
1 answer
307 views

autofs --force unmounts /proc

Historically I've seen autofs get into situtations where systemctl restart autofs will hang indefinitely due to stale nfs handles. As a result I've employed the --force option to make autofs play a ...
azzid's user avatar
  • 998
1 vote
0 answers
252 views

Identify filesystem for each mtd

In /proc/mtd I can see all partition in my device dev: size erasesize name mtd0: 0xxxxx00 0xxxxx00 "yyyy" mtd1: 0xxxxx00 0xxxxx00 "yyyy" mtd2: 0xxxxx00 0xxxxx00 "yyyy" How can I know which ...
syste's user avatar
  • 11
0 votes
1 answer
564 views

How does OS kernel get known connected hardware configuration to save it in `/proc` files?

In my student assignment I'm asked to track how Linux kernel discovers configurations of any device connected. For instance, the system has a new printer plugged in. As far as I can see, all features ...
Flying circus's user avatar
22 votes
1 answer
828 views

I accidentally backed up /proc/* , and now I'm stuck with a 28Tb file called “cifs2695” that I can't remove!

Recently my boss asked me to backup a Ubuntu 16 workstation. I wanted to preserve all the libraries and system files, since we have C++ code that can only compile on that particular machine. Being ...
Dan Elton's user avatar
  • 347
-1 votes
1 answer
33 views

What do drivers have to do with modules?

I need to research and find out "which drivers are loaded on my system" using /proc. In /proc there is a dir called "driver" so I thought that was it, but reading about it online, I saw I should also ...
rubberband's user avatar
3 votes
1 answer
818 views

Why procfs mount option only working on remount?

I have written own init process (pid 1) for my system, to improve security I decided to add hidepid=2 while mounting procfs in /proc location (procfs not mounted by default). After mounting the ...
Karthik Nedunchezhiyan's user avatar
1 vote
1 answer
509 views

how to query information from the /proc filesystem?

how would I begin to do this? I want to write a shell script file that would allow me to pull information from the proc filesystem. Information like PID, state of processes, etc... a short code demo ...
Noob coder's user avatar
0 votes
1 answer
104 views

How to find out what function is runnng when reading /proc

I am trying to write a kernel module that hides some sockets from netstat. I checked how netstat is working and saw that it's reading from /proc/net/tcp. Now I am stuck. I am trying to figure out ...
Meir Tolpin's user avatar
1 vote
1 answer
663 views

What is the best way to restrict /proc fs from malicious users (linux)? [closed]

I am trying to make a restriction to procfs like only a certain groups of members can perform read and write actions. kernel document says we can do that by setting hidepid and gid in /etc/fstab. It ...
Karthik Nedunchezhiyan's user avatar
0 votes
1 answer
410 views

Is "/proc/<pid>/map_files" include mapped file of all tid or just include mapped file of tid=pid only?

There is /proc/pid/task/tid/maps file but no corresponding /proc/pid/task/tid/map_files.
illiterate's user avatar
1 vote
1 answer
371 views

What does the 4th column (root) in /proc/.../mountinfo mean?

From the proc manual it names the 4th column of mountinfo as "root", and describes it as "the pathname of the directory in the filesystem which forms the root of this mount". But how to understand it? ...
Tintervenor's user avatar
1 vote
1 answer
602 views

inotifywait not responding to change in /proc/mounts

I'm trying to get notification of the state of a problematic sshfs mount I have tried two bash scripts while inotifywait -e modify /proc/mounts; do echo "modified" done and inotifywait -m /...
Stephen Boston's user avatar
2 votes
1 answer
2k views

Why does `sudo cat /proc/self/attr/current` return "Invalid argument"?

I have read that the current AppArmor profile should be listed in the /proc/self/attr/current file, and that if it's empty the current profile is "unconfined". But why does cat return "Invalid ...
Shuzheng's user avatar
  • 4,371
2 votes
1 answer
757 views

How to check the device number of a device in `/proc/1/ns/{ns}`?

How to check the device number of a device in /proc/1/ns/{ns}? I've read the code for a Go library (see below), which states that it's possible to determine, if a container is in the host namespace ...
Shuzheng's user avatar
  • 4,371
7 votes
2 answers
4k views

Linux Kernel.org misleading about kernel panic /proc/sys/kernel/panic

I always have /proc/sys/kernel/panic set up to 0. Looking at description of this option in kernel.org we can see: panic: The value in this file represents the number of seconds the kernel ...
red0ct's user avatar
  • 645
3 votes
1 answer
2k views

What are BSDs' equivalents to /proc and /sys?

The amount of information that can be gathered in linux using the procfs and sysfs which are normally mounted at /proc and /sys is quite substantial. Being not on a FreeBSD install I am amazed to ...
fraleone's user avatar
  • 797
1 vote
1 answer
5k views

How to view Stack Trace of a process?

I have seen this answer and according to that Stack Trace can be seen like: $ cat /proc/<PID>/stack [<ffffffff81012b72>] save_stack_trace_tsk+0x22/0x40 [<ffffffff81213abe>] ...
Yash Jain's user avatar
  • 113
1 vote
1 answer
421 views

Why are the virtual memory regions for the same program different on every run?

I am studying virtual memory mappings of memory regions in Linux. The executable is a simple counting program. When two instances of the program are run, the following are the mappings shown by /proc/...
srinskit's user avatar
  • 115
9 votes
3 answers
7k views

Way to unambiguously parse /proc/<pid>/stat (given arbitrary contents of name field)

In linux procfs, /proc/<pid>/stat includes as its second argument the name of the process in parentheses. As far as I can tell (by experimentation) this is unescaped. For example, I have been ...
Dannie's user avatar
  • 193
2 votes
2 answers
3k views

The vmRSS value of /proc/$pid/status seems not accurate? Why?

I wrote a test program to help me understand the output field of different memory utilities such as free,ps,top,/proc/$pid/status,/proc/$pid/smaps,/proc/$pid/statm etc. One question finally rose up ...
user1434336's user avatar
0 votes
1 answer
337 views

Why we have so many 0's in intr field of /proc/stat

I am looking into intr field of /proc/stat. # cat stat cpu 10438 2056 25767 10098612 2490 0 1846 0 0 0 cpu0 1768 260 4750 1681597 119 0 608 0 0 0 cpu1 1735 67 5119 1683444 342 0 280 0 0 0 cpu2 1908 ...
md.jamal's user avatar
  • 291
0 votes
1 answer
31 views

use proc info to increase pc's speed

Just to filter the answers, I am a completely beginner trying to understand the basics about Linux Filesystem. According to many resources the proc directory in the filesystem shows information about ...
user avatar
0 votes
1 answer
40 views

watch to remember its last zero exit output

I run a process that takes lot of time. Time is not a problem actually but I would like to know how much RAM memory it requires. Process is already running so /usr/bin/time is not an option. I found ...
jangorecki's user avatar
0 votes
1 answer
62 views

Get data about system load in an easy-to-process format

Often I feel the need to run some computation on the data about my system load. For instance about the data that top shows. And possibly iotop and htop as well. Some of the things I'd like to do are ...
peoro's user avatar
  • 3,778
2 votes
1 answer
1k views

file /proc/cmdline is empty

I'm having a problem to boot my system, because the initramfs which should get its values from /proc/cmdline, such as the root device, isn't able to obtain any value, and that's because this file is ...
MayAccer's user avatar
1 vote
1 answer
2k views

Connections in /proc/[pid]/net/tcp which don't appear in /proc/net/tcp

I'm implementing code to fetch all network connections and associate them with the PIDs using them. Say, for tcp4, for each pid, I'm listing /proc/pid/fd, searching there for links to sockets, ...
Dave Reikher's user avatar
2 votes
6 answers
2k views

Redirect output on-the-fly - looks not possible in Linux, why?

I tried web search but have not found answer by searching for Linux redirect output on the fly. As far as I understand, output to say stdout works by using file descriptor 1: $ ls -l /proc/pid/fd/1 ...
Marisha's user avatar
  • 343
1 vote
0 answers
48 views

Arbitrary "files" in /proc/? [duplicate]

Is there a way to create files in /proc/ without actually writing a kernel module? This is for reverse engineering purposes, an app expects certain things in /proc/ and I do not want to write a ...
lukash's user avatar
  • 111
0 votes
1 answer
260 views

Difference between pid_max/ulimit. How to create fake processes?

I am trying to learn the nuances between pid_max and setting user limits through ulimit. My understanding is that, no matter how high you set the user limits (for example setting user max processes to ...
Alexander D's user avatar
4 votes
1 answer
1k views

What are the non-numeric IRQs in /proc/interrupts?

cat /proc/interrupts shows a bunch of IRQs such as NMI and LOC. The per-line comments in the output give clear explanation, but if they do not have a numeric IRQ number, how does the x86 CPU respond ...
QnA's user avatar
  • 545
2 votes
0 answers
238 views

Read per thread network statistics from C/C++

I have a Linux process with let's say 10 threads. Some of them make network traffic. From another thread or it can be even within another process I need to find out which threads have network activity....
mdaniel's user avatar
  • 141
3 votes
0 answers
2k views

Absolute path to current user's home directory without using bash expansions?

This is a problem that crops up from time to time and annoys me greatly. Sometimes I need to provide an absolute path, normally in a configuration file, that should refer to the current user's home ...
sircolinton's user avatar
2 votes
1 answer
1k views

How to use sysctl on UNIX variants, e.g. macOS, to read information normally found in /proc/self on Linux?

I've been using /proc/self for a long time to read process-related information like /proc/self/maps etc. However, on some UNIX variants, like macOS, the procfs filesystem is not implemented; but as ...
Shuzheng's user avatar
  • 4,371
2 votes
1 answer
416 views

How to find which mountpoint current working directory of a process correspond to?

I have a program a.out running from /tmp/test. If I list /proc/$(pgrep a.out)/cwd, it is a symbolic link to /tmp/test. Now, I bind /mnt/othertest onto /tmp/test with mount -o bind /mnt/othertest /tmp/...
rools's user avatar
  • 486

1 2
3
4 5
12