procenv - Man Page
display process environment details
Synopsis
procenv [OPTION]
Description
Display details of the process environment in a parseable format.
Options
Options shown with a bracketed asterisk '(*)' are non-display options and must precede any other (display) options.
- -a, --meta
Display meta details.
- -A, --arguments
Display program arguments.
- -b, --libs
Display details of linked libraries. See dl_iterate_phdr(3).
- -B, --libc
Display standard library details. See feature_test_macros(7) (Linux).
- -c, --cgroups
Display cgroup details (Linux only). See proc(5).
- -C, --cpu
Display CPU and scheduler details. See kvm_getprocs(3) (BSD), pthread_getaffinity_np(3), sched_getcpu(3) (Linux).
- --crumb-separator=str (*)
Specify string str as alternate delimiter for crumb format output (default=':').
- -d, --compiler
Display compiler details. See cpp(1), cc(1) and feature_test_macros(7) (Linux).
- -e, --environment
Display environment variables. See environ(7).
- -E, --semaphores
Display semaphore details (not queryable on BSD). See semctl(2).
- --exec (*)
Treat non-option arguments as program to execute after running procenv. See exec(3).
- -f, --fds
Display file descriptor details. Under FreeBSD, file descriptor capabilities will also be displayed assuming the kernel has Capsicum support. See cap_getmode(2) (BSD), cap_rights_get(2) (BSD), cap_rights_is_set(3) (BSD), fcntl(2), isatty(5).
- -F, --namespaces
Display namespace details (Linux only). See proc(5).
- --file=FILE (*)
Send output to file FILE (implies --output=file).
- --file-append (*)
If --file is specified, append to it rather than overwriting it.
- --format=FORMAT (*)
Specify output format. FORMAT may be one of:
- crumb ("breadcrumbs").
- json (JavaScript Object Notation).
- text (plain ASCII text) [default].
- xml (Extensible Markup Language).
- -g, --sizeof
Display sizes of data types.
- -h, --help
This help text.
- -i, --misc
Display miscellaneous details. See umask(P), getcwd(3), personality(2) (Linux), proc(5), prctl(2), aa_getcon(2) (Linux), getpidcon(3) (Linux), sysconf(3), kvm_getprocs(3) (BSD), getpriority(2).
- --indent (*)
Number of indent characters to use for each indent (default=2).
- --indent-char=c (*)
Use character c for indenting (default=' ' (space)).
- -j, --uname
Display uname details. See uname(2).
- -k, --clocks
Display clock details. See clock_getres(2).
- -l, --limits
Display limits. See getrlimit(2).
- -L, --locale
Display locale details. See setlocale(3) and locale(7).
- -m, --mounts
Display mount details. See getmntent(3) and statfs(2) (Linux), and getmntinfo(3) (BSD).
- -M, --message-queues
Display message queue details (not queryable on BSD). See msgctl(2).
- -n, --confstr
Display confstr details. See confstr(5).
- -N, --network
Display network details. See getifaddrs(3), getnameinfo(3), ip(7), netdevice(7), and ioctl(2) (Linux).
- -o, --oom
Display out-of-memory manager details (Linux only). See proc(5).
- --output=TYPE (*)
Send output to alternative location. TYPE can be one of:
- file (send output to a file).
- stderr (write to standard error).
- stdout (write to standard output (default)).
- syslog (write to the system log file).
- terminal (write to terminal).
- -p, --process
Display process details. See getpid(2), getppid(2), getresuid(2), getresgid(2), getuid(2), geteuid(2), getgid(2), getegid(2), getsid(2), getlogin(3), getpgrp(2), ctermid(3), tcgetpgrp(3), tcgetsid(3), getpwuid(3) and getgroups(2).
- -P, --platform
Display platform details.
- -q, --time
Display time details. See clock_gettime(2), localtime(3) and asctime(3).
- -r, --ranges
Display range of data types. See limits.h(P).
- -s, --signals
Display signal details. See sigaction(2).
- -S, --shared-memory
Display shared memory details (not queryable on BSD). See shmctl(2).
- --separator=str (*)
Specify string str as alternate delimiter for text format output (default=': ').
- -t, --tty
Display terminal details. On Linux, will also show if any attributes are locked when running as root. See tcgetattr(3) and tty_ioctl(4) (Linux).
- -T, --threads
Display thread details. See pthread_attr_getstacksize(3), pthread_attr_getstacksize(3) and pthread_attr_getguardsize(3).
- -u, --stat
Display stat details. See stat(2).
- -U, --rusage
Display rusage details. See getrusage(2).
- -v, --version
Display version details.
- -w, --capabilities
Display Linux capability details. For FreeBSD file descriptor capabilities, see --fds. See prctl(2) (Linux), libcap(3) (Linux).
- -x, --pathconf
Display pathconf details. See pathconf(3).
- -y, --sysconf
Display sysconf details. See sysconf(3) and posixoptions(7) (Linux).
- -Y, --memory
Display memory details. See getpagesize(2), numa(3) (Linux) and numa(7) (Linux), sysinfo(3).
- -z, --timezone
Display timezone details. See tzset(3).
Environment Variables
The following environment variables may be used as aliases to their command-line counterparts:
- PROCENV_CRUMB_SEPARATOR
Alternative to --crumb-separator.
- PROCENV_EXEC
Alternative to --exec.
- PROCENV_FILE
Alternative to --file.
- PROCENV_FILE_APPEND
Alternative to --file-append.
- PROCENV_FORMAT
Alternative to --format.
- PROCENV_INDENT
Alternative to --indent.
- PROCENV_INDENT_CHAR
Alternative to --indent-char.
- PROCENV_SEPARATOR
Alternative to --separator.
- PROCENV_OUTPUT
Alternative to --output.
Notes
- Options are considered in order, so --output should precede any other option.
- If no display option is specified, all details are displayed.
- Only one display option may be specified.
- Command-line options take priority over environment variables.
- All values for --indent-char are literal except '\t' which can be used to specify a tab character. The same is true for --separator-char and --crumb-separator but only if it is the first character specified.
- Specifying a visible indent-char is only (vaguely) meaningful for text output.
- If --exec is specified, at least one non-option argument must also be specified.
- Any long option name may be shortened as long as it remains unique.
- The crumb output format is designed for easy parsing: it displays the data in a flattened format with each value on a separate line preceded by all appropriate headings which are separated by the current separator.
- The --message-queues, --semaphores and --shared-memory options are not available on BSD since although the values are queryable, there is no documented method to do so.
Examples
# Show limits procenv -l # Send compiler information to syslog (note the order of the options). procenv --output=syslog --compiler # Write compiler details direct to the terminal procenv --output=terminal --compiler # Run a command ('mycmd --arg1 --foo=bar') without creating a new # process, but have procenv run first and log its output to a # regular file. exec procenv --file=/tmp/procenv.log --exec -- mycmd --arg1 --foo=bar # The following kernel command-line snippet will cause procenv to # run as PID 1 and write output to the first serial tty device. It will then # execute the init daemon (specifying some arguments to show how this is possible). # Note that since procenv re-executes, the init daemon will (also) be run as PID 1. init=/usr/bin/procenv PROCENV_FILE=/dev/ttyS0 PROCENV_EXEC="/sbin/init --foo-bar --baz" # Display all data in JSON format using an indent of 4 spaces procenv --format=json --indent=4 # Display all data in XML format using tabs for indents procenv --format=xml --indent-char="\t" # Display signal details in XML format procenv --format=xml --signals # Display resource limits in easily-parseable format procenv --format=crumb --limits # Produce output suitable for importing into a spreadsheet procenv --format=crumb --crumb-separator=',' --separator=',' --limits # Produce stylised output procenv --format=crumb --crumb-separator=' → ' --separator='='
Limitations
- Spaces within the value of PROCENV_EXEC are treated as delimiters meaning that any spaces within a string argument for example will result in incorrect behaviour.
- The separator character must be chosen carefully since no check is performed on the data to see if it itself contains instances of the separator character.
Authors
Written by James Hunt <jamesodhunt@gmail.com> and Kees Cook <kees@ubuntu.com>.
Copyright
Copyright © 2012-2021 James Hunt <jamesodhunt@gmail.com> and Kees Cook <kees@ubuntu.com>.
This is free software; see the source for copying conditions. There is NO warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
License
GNU GPL version 3 or later <http://gnu.org/licenses/gpl.html>.
This is free software: you are free to change and redistribute it. There is NO WARRANTY, to the extent permitted by law.
See Also
capabilities(7) (Linux), capsicum(4) (BSD), cc(1), clock_gettime(2) (Linux), credentials(7), date(1), env(1), exec(P), getconf(1), groups(1), ifconfig(8), ip(9), ipcs(1), kill(1), ldd(1), locale(1), ls(1), mount(1), proc(5), ps(1), rights(4)(BSD), sh(1), stat(1), stty(1), umask(P), uname(1)