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
171 votes
6 answers
177k views

How do I read from /proc/$pid/mem under Linux?

The Linux proc(5) man page tells me that /proc/$pid/mem “can be used to access the pages of a process's memory”. But a straightforward attempt to use it only gives me $ cat /proc/$$/mem /proc/self/...
Gilles 'SO- stop being evil''s user avatar
109 votes
6 answers
411k views

How do I kill all a user's processes using their UID

I want to kill all running processes of a particular user from either a shell script or native code on a Linux system. Do I have to read the /proc directory and look for these? Any ideas? Is there a ...
user489152's user avatar
  • 1,193
89 votes
3 answers
42k views

What happens when I run the command cat /proc/cpuinfo?

What happens when I write cat /proc/cpuinfo. Is that a named pipe (or something else) to the OS which reads the CPU info on the fly and generate that text each time I call it?
slm's user avatar
  • 370k
87 votes
4 answers
52k views

What is the difference between procfs and sysfs?

What is the difference between procfs and sysfs? Why are they made as file systems? As I understand it, proc is just something to store the immediate info regarding the processes running in the ...
Navaneeth Sen's user avatar
78 votes
1 answer
94k views

How do I find out more about socket files in /proc/fd?

Looking in /proc/$mypid/fd/, I see these files lrwx------ 1 cm_user cm_user 64 Oct 14 03:21 0 -> /dev/pts/36 (deleted) lrwx------ 1 cm_user cm_user 64 Oct 14 03:21 3 -> socket:[1424055856] lrwx-...
benhsu's user avatar
  • 935
76 votes
7 answers
258k views

Tell fs to free space from deleted files NOW

Is there a way to tell the kernel to give back the free disk space now? Like a write to something in /proc/ ? Using Ubuntu 11.10 with ext4. This is probably an old and very repeated theme. After ...
Marcos's user avatar
  • 2,305
70 votes
6 answers
62k views

Which process is `/proc/self/` for?

https://www.centos.org/docs/5/html/5.2/Deployment_Guide/s3-proc-self.html says The /proc/self/ directory is a link to the currently running process. There are always multiple processes running ...
Tim's user avatar
  • 102k
49 votes
7 answers
134k views

"echo 3 > /proc/sys/vm/drop_caches" - Permission denied as root

I am currently having some issues with the cache. It is a little too much right now so I wanted to clear it. I googled and found this little command: sync && echo 3 > /proc/sys/vm/...
BrainStone's user avatar
  • 3,654
49 votes
5 answers
59k views

How to get the IPV4 address for an interface from /proc

Is there a clean, simple way to get an IP address for a network interface from /proc, similar to the way I can get the MAC address for a network interface? Ideally I would just type cat /proc/<foo&...
razeh's user avatar
  • 609
47 votes
3 answers
14k views

What is the difference between "all", "default" and "eth*" in /proc/sys/net/ipv[46]/conf/?

In sysctl, the /proc/sys/net/ipv[46]/conf/ keys have the following subkeys: all, default, and a key for each network interface. For example, on a machine with a single network interface eth0, it will ...
Martin von Wittich's user avatar
47 votes
3 answers
41k views

change environment of a running process

How might it be possible to alter some variable in the env of an already running process, for example through /proc/PID/environ? That "file" is read-only. Need to change or unset the DISPLAY variable ...
Marcos's user avatar
  • 2,305
42 votes
2 answers
48k views

/proc/PID/fd/X link number

In Linux, in /proc/PID/fd/X, the links for file descriptors that are pipes or sockets have a number, like: l-wx------ 1 user user 64 Mar 24 00:05 1 -> pipe:[6839] l-wx------ 1 user user 64 Mar 24 ...
Thanatos's user avatar
  • 917
37 votes
2 answers
11k views

How frequently is the proc file system updated on Linux?

How frequently is the proc file system updated on Linux? Is it 20 milliseconds (time quantum)?
samarasa's user avatar
  • 657
37 votes
2 answers
27k views

When was a process started

To know when was a process started, my first guess was to check the time when /proc/<pid>/cmdline was written/modified the last time. ps also shows a START field. I thought both of these ...
Swair's user avatar
  • 711
34 votes
2 answers
20k views

What does the "bugs" section of /proc/cpuinfo actually show?

On a Debian Stretch and testing/Buster system with a current kernel and installed microcode I still see meltdown and spectre listed as bugs in /proc/cpuinfo. However, running the spectre-meltdown-...
hurrbert's user avatar
  • 341
32 votes
3 answers
8k views

Is there any reason why /proc/*/cmdline is world-readable?

Maybe I haven't had enough coffee yet today, but I can't remember or think of any reason why /proc/PID/cmdline should be world-readable - after all, /proc/PID/environ isn't. Making it readable only by ...
cas's user avatar
  • 78.5k
32 votes
4 answers
45k views

Read "/proc" to know if a process has opened a port

I need to know if a process with a given PID has opened a port without using external commands. I must then use the /proc filesystem. I can read the /proc/$PID/net/tcp file for example and get ...
rmonjo's user avatar
  • 423
31 votes
10 answers
9k views

How do I source another process's environment variables?

If I examine /proc/1/environ I can see a null-byte-delimited string of process 1's environment variables. I'd like to bring these variables into my current environment. Is there an easy way to do this?...
Dane O'Connor's user avatar
31 votes
3 answers
19k views

How does the /proc/<pid>/exe symlink differ from ordinary symlinks?

If I start a process and then delete the binary of it, I can still recover it from /proc/<pid>/exe: $ cp `which sleep` . $ ./sleep 10m & [1] 13728 $ rm sleep $ readlink /proc/13728/exe ...
muru's user avatar
  • 72.6k
28 votes
4 answers
24k views

iotop but for particular disk?

Is there a tool like iotop but for monitoring IO on specific volumes? (Or perhaps I missed a way to filter iotop?) If not is there any way to get at this information via (say)/proc? (dstat etc. ...
xyzzyrz's user avatar
  • 391
26 votes
4 answers
28k views

Listen for exit of process given pid $$

Say I have a pid in hand, mypid=$$ is there some bash/system command I can use to listen for the exit of that process with the given pid? If no process with mypid exists, I guess the command should ...
Alexander Mills's user avatar
26 votes
6 answers
51k views

Find out what device /dev/root represents in Linux?

On linux, there is a /dev/root device node. This will be the same block device as another device node, like /dev/sdaX. How can I resolve /dev/root to the 'real' device node in this situation, so ...
kdt's user avatar
  • 443
24 votes
2 answers
6k views

Portability of file descriptor links

I've always wondered this but never took the time to find out, so I'll do so now - how portable is the usage shown here of either /proc/$$/fd/$N or /dev/fd/$N? I understand POSIX guarantees /dev/null, ...
mikeserv's user avatar
  • 58.3k
24 votes
10 answers
15k views

Make changes to `/proc/acpi/wakeup` permanent

I disabled most of my entries in /proc/acpi/wakeup/ to make sure only the power button and the laptop lid can resume my system, not the mouse or keyboard. The problem is: every time I reboot, the ...
piegames's user avatar
  • 907
24 votes
3 answers
22k views

How to find the pci slot of an usb controller in Linux?

I have a nearly common Linux machine here. So, it has a PCI (*-X, etc) bus, on that some USB controllers, and I have USB devices on these USB controllers. Similar to this: $ lspci|grep USB 00:12.0 ...
peterh's user avatar
  • 9,733
22 votes
3 answers
22k views

Current umask of a process with <pid>

Is it possible to get current umask of a process? From /proc/<pid>/... for example?
basin's user avatar
  • 2,051
22 votes
2 answers
8k views

kernel 5.10.119 caused the values of /proc/sys/kernel/random/entropy_avail and poolsize to be 256

After update to kernel 5.10.119, /proc/sys/kernel/random/entropy_avail became stuck to 256 and does not change when moving the mouse. It used to be greater than 3000. # cat /proc/sys/kernel/random/...
user528206'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
21 votes
4 answers
2k views

Why some shells `read` builtin fail to read the whole line from file in `/proc`?

In some Bourne-like shells, the read builtin can not read the whole line from file in /proc (the command below should be run in zsh, replace $=shell with $shell with other shells): $ for shell in ...
cuonglm's user avatar
  • 154k
20 votes
3 answers
4k views

Why is proc called a file system?

The proc file system allows the kernel to communicate information about each running process on a Linux system. Why is proc called a file system? It’s not a real file system like ext4. It’s just a ...
Lkaf Temravet's user avatar
20 votes
3 answers
38k views

Writing to stdin of a process

As far as I understand if i type the following... python -i ... the python-interpreter will now read from stdin, behaving (obviously) like this: >>> print "Hello" Hello I would expect ...
Sheppy's user avatar
  • 313
20 votes
1 answer
4k views

ps only prints up to 4096 characters of any process's command line

When I grep for a java process I get below output but it's limited to 4096 characters which results to actual process name(which is kafka.Kafka) not shown in grep output. Is this a limitation of grep?...
zer0Id0l's user avatar
  • 311
20 votes
1 answer
31k views

Is it possible to get process group ID from /proc?

In "https://stackoverflow.com/questions/13038143/how-to-get-pids-in-one-process-group-in-linux-os" I see all answers mentioning ps and none mentioning /proc. "ps" seems to be not very portable (...
Vi.'s user avatar
  • 5,688
19 votes
3 answers
38k views

Is there an easy way to log all commands executed, including command line arguments?

I am trying to find how to log a specific instantiation of rrdtool to see whether the path it is receiving is incorrect. I know I could wrap the executable in a shell script that would log the ...
Peter Grace's user avatar
19 votes
1 answer
15k views

Explain EV in /proc/bus/input/devices data

Can anybody explain to me what the EV value in /proc/bus/input/devices is? The keyboard always has value 120013. Why?
Gabriel's user avatar
  • 297
19 votes
2 answers
10k views

How is /proc/self implemented in Linux?

I was tinkering around with the /proc filesystem in Linux, and I came across /proc/self, which is a symbolic link to the process directory of the current process. I would like to know how it is ...
Vicky Chijwani's user avatar
19 votes
2 answers
17k views

Determine if a specific process is 32- or 64-Bit

Given a 2.6.x or newer Linux kernel and existing userland that is capable of running both ELF32 and ELF64 binaries (i.e. well past How do I know that my CPU supports 64bit operating systems under ...
Flexo's user avatar
  • 374
18 votes
3 answers
13k views

What happens when you run out of PIDs?

This is a purely academic question, because this will never happen. If a PID is stored as type pid_t, and not some arbitrary-precision type, then there is a limit to the number of PIDs that can exist ...
fpf3's user avatar
  • 344
18 votes
3 answers
2k views

Where are the contents of /proc of the Linux kernel documented?

Is there a site someplace that lists the contents of /proc and what each entry means?
HandyGandy's user avatar
  • 2,199
18 votes
1 answer
14k views

What's the purpose of the /proc/pid/mountinfo file?

What's the purpose of the /proc/pid/mountinfo file (with pid being numerical process id)? As far as I can see it reflects contents of the /proc/mounts file but with added information. Also the file ...
golem's user avatar
  • 2,288
18 votes
2 answers
18k views

What is anon_inode in the output of "ls -l /proc/[PID]/fd"?

While looking through /proc/[PID]/fd/ folder of various processes, I found curious entry for dbus lrwx------ 1 root root 64 Aug 20 05:46 4 -> anon_inode:[eventpoll] Hence the question, what are ...
Sergiy Kolodyazhnyy's user avatar
17 votes
2 answers
10k views

How should I check whether a given PID is running?

I'm writing a Perl script that parses logfiles to collect PIDs and then checks whether that PID is running. I am trying to think of the best way to make that check. Obviously, I could do something ...
terdon's user avatar
  • 242k
17 votes
4 answers
23k views

Arch linux : pacman does not work when chrooting

I have Ubuntu installed on my computer. I decided to install Arch linux, but I skipped the part about Grub installation as it is already installed. Seeing that Arch does not show up in Grub's menu ...
Gradient's user avatar
  • 3,659
17 votes
1 answer
4k views

Does /proc/[pid]/status always use kB?

Particularly, does proc always list the VmRSS value in kB? I can't find a solid answer on the documentation, although it appears that it sticks to one unit.
Jess Smith's user avatar
17 votes
5 answers
16k views

Notify of changes on a file under /proc

I have written a small 'daemon' in bash that will switch to the headphones if they are detected, and if not, switch to an external USB speaker with PulseAudio. What I'm looking for is some way to get ...
admirabilis's user avatar
  • 4,712
17 votes
5 answers
7k views

Read the stack of another process?

I'm trying to read a child process's stack but with no luck. I know it is possible using ptrace, but ptrace's interface allows you to read only one word at a time, and I'm trying to scan a larger ...
user4537's user avatar
  • 271
15 votes
2 answers
44k views

How can I wake a process from sleep status via signal or /proc?

Many years ago I had an issue with Linux where processes would randomly go to sleep. Back then, I knew a trick with the /proc filesystem to trigger a wakeup of the process. I vaguely remember being ...
Peter Grace's user avatar
15 votes
4 answers
1k views

How do I learn what I can do with /proc and /sys [closed]

I'd like to know more about the advanced uses of the /proc and /sys virtual filesystems, but I don't know where to begin. Can anyone suggest any good sources to learn from? Also, since I think sys has ...
xenoterracide's user avatar
15 votes
4 answers
20k views

Why can't I `tail -f /proc/$pid/fd/1`?

I wrote a simple script which echo-es its PID: #/bin/bash while true; do echo $$; sleep 0.5; done I'm running said script (it says 3844 over and over) in one terminal and trying to tail the ...
cprn's user avatar
  • 1,025
15 votes
1 answer
2k views

"ss" command in iproute package; why query slab table for timewait sockets?

Forgive me if this isn't the best forum for this question, but it seems more relevant to the kernel than to the programming itself. I'm writing a script that queries the system for open ports so that ...
Peter Grace's user avatar

1
2 3 4 5
12