# comment in /etc/passwd and /etc/group

## chaonis

I am wondering if I can put comments in /etc/passwd and /etc/group files by starting the line with "#" character, like many other files do. 

Checked the man pages for both files and googled but don't see it mentioned anywhere. 

Can I do it? Will it cause any issue for the system to parse the line? Most importantly, will it hurt the secruity of the system?

--

C

----------

## timeBandit

Interesting question.   :Surprised: 

I don't have a definitive answer, but my routine daily travels have taken me through AIX, Solaris, HP-UX, five Linuxen and at least one other forgotten UNIX over the years, and I don't think I ever saw commented password or group files on any of them. I'd be leery of doing so since they're essentially delimited text databases. A comment would be an invalid "record" IMO, absent any information from a trusted source.

The shadow suite is a further complication. It might be upset by lines in /etc/passwd that had no counterparts in /etc/shadow.

----------

## dev-urandom

 *chaonis wrote:*   

> I am wondering if I can put comments in /etc/passwd and /etc/group files by starting the line with "#" character, like many other files do. 
> 
> Checked the man pages for both files and googled but don't see it mentioned anywhere. 
> 
> Can I do it? Will it cause any issue for the system to parse the line? Most importantly, will it hurt the secruity of the system?
> ...

 

Don't ever do this. There is no space for comments in /etc/passwd. Call it a design shortfall from 30 years ago if you want, but that it where we are. In fact, if you change 

```

foobar:x:1000:1000:Foo Bar:/home/foobar:/bin/bash

```

to

```

#foobar:x:1000:1000:Foo Bar:/home/foobar:/bin/bash

```

all you'll get is a user #foobar. Try it out if don't believe me  :Wink: 

----------

