0

I'm looking for a way to report all the command lines associated to all the processes in all Linux: CentOS: Ubuntu, Red Hat, Debian, Cent OS... And, in case of the best command for it has any limitation (I mean, truncating the command lines), I want to know at what point are they truncated

At this moment I'm using this command ps -eo pid,ppid,comm,args > ps.txt

I read in many places about getconf PAGE_SIZE, but it says 4096 and, in the txt file, I can see processes with command lines much longer than that.

Dave O.
  • 1
  • 4

1 Answers1

0

According to my investigations, there are 2 possible options:

  • truncation at the value of getconf PAGE_SIZE, usually 4096

  • unlimited characters

The only way to check in what case we are, is from the kernel

Here all the versions of Red Hat kernels https://access.redhat.com/documentation/en-us/red_hat_enterprise_linux/6/html/6.8_release_notes/new_features_kernel

  • In Ubuntu, Oracle Linux Server, Debian, SuSE and Fedora, since the kernel version 4.2. It can be checked in the source code, as other user said here How do I increase the /proc/pid/cmdline 4096 byte limit? In the release 4.2, they started to split the command line in blocks of PAGE_SIZE in order to be able to display the whole command line

The change in the method proc_pid_cmdline_read (to display the command lines) can be checked here, throughout the different versions.

Linux Kernel 4.0 https://kernel.googlesource.com/pub/scm/linux/kernel/git/ralf/linux/+/linux-4.0/fs/proc/base.c Linux Kernel 4.1 https://kernel.googlesource.com/pub/scm/linux/kernel/git/ralf/linux/+/linux-4.1/fs/proc/base.c Linux kernel 4.2 https://kernel.googlesource.com/pub/scm/linux/kernel/git/ralf/linux/+/linux-4.2/fs/proc/base.c

All the linux kernel vesions releases https://kernel.googlesource.com/pub/scm/linux/kernel/git/ralf/linux/+refs

All the Ubuntu versions with its kernels https://en.wikipedia.org/wiki/Ubuntu_version_history#Table_of_versions

Dave O.
  • 1
  • 4