What does `init [2]` mean in the COMMAND column of ps?

n611x007 just a moment. 1 answers, 0 views
executable command ps init sysvinit

Reading What do the brackets around processes mean? I understand that the executable name is printed.

Linux ps man page:

Sometimes the process args will be unavailable; when this happens, ps will instead print the executable name in brackets.

However with ps -Awwo pid,comm,args I get:

  PID COMMAND         COMMAND
    1 init            init [2]

What does this mean? Does the "executable name" supposed to be init or [2]?

I suppose the executable is of course init - what is [2]? Why is it printed?

(Also, I don't really get why it can't show the full path if it knows the executable name.)

1 Answers


Gilles 08/06/2014.

Both the comm column and the first word of the args column in the ps output show the name of the executable program if everybody involved follows the default convention. However it is possible to have discrepancies for various reasons.

When a program starts, the command name as shown in the args column is chosen by the parent program that executes the program and passed as an argument (argv[0]). By convention, the parent chooses the base name of the executable (i.e. the path to the executable without the directory part), but this is not enforced. Once the program is running, it can overwrite that string.

Init (at least the traditional Linux SysVinit) overwrites its argv[0] to indicate the current runlevel.

On Linux, the comm column is initially filled in by the kernel to the first 16 characters of the base name of the executable. The process can change the content with the prctl system call.

If the executable is renamed or deleted, neither the comm column nor the args column will reflect this.

ps doesn't display the path to the executable, that's not in its job description. lsof can tell you with lsof -a -p 1 -d txt.

On Linux, you can see this information in files in /proc/PID/:

  • The process name (comm field) in in /proc/1/stat (second field in parentheses) and /proc/1/status (Name field).
  • The path to the executable via /proc/1/exe.
  • The arguments (starting with argv[0]) in /proc/1/cmdline (the arguments are separated by null bytes).

HighResolutionMusic.com - Download Hi-Res Songs

1 Alan Walker

Diamond Heart flac

Alan Walker. 2018. Writer: Alan Walker;Sophia Somajo;Mood Melodies;James Njie;Thomas Troelsen;Kristoffer Haugan;Edvard Normann;Anders Froen;Gunnar Greve;Yann Bargain;Victor Verpillat;Fredrik Borch Olsen.
2 Sia

I'm Still Here flac

Sia. 2018. Writer: Sia.
3 Cardi B

Taki Taki flac

Cardi B. 2018. Writer: Bava;Juan Vasquez;Vicente Saavedra;Jordan Thorpe;DJ Snake;Ozuna;Cardi B;Selena Gomez.
4 Little Mix

Woman Like Me flac

Little Mix. 2018. Writer: Nicki Minaj;Steve Mac;Ed Sheeran;Jess Glynne.
5 Halsey

Without Me flac

Halsey. 2018. Writer: Halsey;Delacey;Louis Bell;Amy Allen;Justin Timberlake;Timbaland;Scott Storch.
6 Lady Gaga

I'll Never Love Again flac

Lady Gaga. 2018. Writer: Benjamin Rice;Lady Gaga.
7 Bradley Cooper

Shallow flac

Bradley Cooper. 2018. Writer: Andrew Wyatt;Anthony Rossomando;Mark Ronson;Lady Gaga.
8 Bradley Cooper

Always Remember Us This Way flac

Bradley Cooper. 2018. Writer: Lady Gaga;Dave Cobb.
9 Kelsea Ballerini

This Feeling flac

Kelsea Ballerini. 2018. Writer: Andrew Taggart;Alex Pall;Emily Warren.
10 Mako

Rise flac

Mako. 2018. Writer: Riot Music Team;Mako;Justin Tranter.
11 Dewain Whitmore

Burn Out flac

Dewain Whitmore. 2018. Writer: Dewain Whitmore;Ilsey Juber;Emilio Behr;Martijn Garritsen.
12 Avril Lavigne

Head Above Water flac

Avril Lavigne. 2018. Writer: Stephan Moccio;Travis Clark;Avril Lavigne.
13 Khalid

Better flac

Khalid. 2018. Writer: Charlie Handsome;Jamil Chammas;Denis Kosiak;Tor Erik Hermansen;Mikkel Stoleer Eriksen;Khalid.
14 Lady Gaga

Look What I Found flac

Lady Gaga. 2018. Writer: DJ White Shadow;Nick Monson;Mark Nilan Jr;Lady Gaga.
15 Deep Chills

Run Free flac

Deep Chills. 2018.
16 Dynoro

In My Mind flac

Dynoro. 2018. Writer: Georgi Kay;Feenixpawl;Ivan Gough.
17 Charli XCX

1999 flac

Charli XCX. 2018. Writer: Charli XCX;Troye Sivan;Leland;Oscar Holter;Noonie Bao.
18 NCT 127

Regular (English Version) flac

NCT 127. 2018.
19 Lukas Graham

Love Someone flac

Lukas Graham. 2018. Writer: Don Stefano;Morten "Rissi" Ristorp;Morten "Pilo" Pilegaard;Jaramye Daniels;James Alan;David LaBrel;Lukas Forchhammer Graham.
20 Rita Ora

Let You Love Me flac

Rita Ora. 2018. Writer: Rita Ora.

Language

Popular Tags