Posted: . At: 11:22 AM. This was 8 years ago. Post ID: 8755
Page permalink. WordPress uses cookies, or tiny pieces of information stored on your computer, to verify who you are. There are cookies for logged in users and for commenters.
These cookies expire two weeks after they are set.

Get the command line of a process without the ps command.

To get the command line of a process without the ps command, and the PID of the command is known, use this command. This example is using a process with a PID of 28633.

ubuntu ~ $ cat /proc/28633/cmdline ; echo
upstart-socket-bridge--daemon

This will show the command line of the process without using the ps command. So blocking the ps command on a Linux system will not stop users from gaining information about the command-line switches used by a certain process.

This is another example. Not all processes in the /proc directory have a cmdline entry, but it is very useful when you find one.

ubuntu ~ $ cat /proc/1771/cmdline ; echo
/sbin/getty-838400tty1

Of course, if the ps command is really required, then get the command line like this.

ubuntu ~ $ ps -ww 1771
  PID TTY      STAT   TIME COMMAND
 1771 tty1     Ss+    0:00 /sbin/getty -8 38400 tty1

This is a better example, this gets the command line of the Systemd process.

jason@jason-Lenovo-H50-55:~$ cat /proc/$(pidof systemd)/cmdline ; echo
/lib/systemd/systemd--user

Another example. This is quite easy to do.

Leave a Comment

This site uses Akismet to reduce spam. Learn how your comment data is processed.