• Skip to primary navigation
  • Skip to main content
  • Skip to primary sidebar
sharadchhetri

sharadchhetri

AI, Linux, Cloud and DevOps

  • Home
  • Resources
    • Learn Linux
    • Articles
  • My Projects & Work
    • My Nagios Plugin
    • My Dockerhub Repo
    • My WordPress plugins
    • My Github Repos
  • Facebook Page
  • Contact
  • Privacy Policy
  • About Me
You are here: Home / Articles / know about GECOS in Linux

know about GECOS in Linux

March 22, 2014 by Sharad Chhetri Leave a Comment

Question: What is GECOS in Linux ? How to set GECOS for user on Linux ?

Answer: GECOS in linux is also known as comment field for User.The comment or GECOS field is used for informational purpose.
In comments field generally we write the information related to user for eg. employee id,phone number,department name,branch name etc.

GECOS/Comments field are saved in /etc/passwd file in Linux system (Also applicable to Other Unix like operating system)

GECOS stands for “General Electric Comprehensive Operating System” . GECOS was renamed to GCOS when GE’s large systems division was sold to Honeywell.

GECOS/Comment field are saved in /etc/passwd file

The GECOS or comment field are saved in /etc/passwd file in Linux/Unix.
The fifth field in /etc/passwd file is for GECOS. (See below given screenshot)
To get the GECOS comment,use below given command

Syntax:

grep User-name /etc/passwd

Example:
GECOS

Advantage Of Using Gecos

(1) The User’s important information can be saved by using GECOS field (or comment field)

(2) In case, in a company have 2 person with same name.Both require login in system.It is obvious thier employee id will be different.We can mention employee id along with name in GECOS/comment section. (or any information you can write which help to identify the user)

Methods to set GECOS/Comment field to user on linux

(1) Set GECOS/Comment field at the time of creating user (By using useradd/adduser command)

(2) Set GECOS/Comment field after creating the user (By using usermod and chfn command)

(i): Useradd command to set GECOS for user in Linux
With useradd command use -c or --comment option to set GECOS/Comment for user.

Syntax:

useradd -c "Write the information" User-name

Example:

useradd -c "System Administrator,IT Department" sharad

(ii) Usermod command to set/modify the GECOS/Comment field for user in Linux
By using usermod command,you can also set or modify the GECOS field. In case,while creating the user you forgot to set GECOS for user.Then you can use usermod command.
Even you can also modify the GECOS field of user by using usermod command.

Use -c or --comment option with usermod command

Syntax:

usermod -c "Write the information" User-Name

Example:

usermod -c "Linux System Engineer, Ops Team" sharad

(iii) chfn command to modify GECOS/Comment field for user in Linux
chfn command changes the user’s account information like full name,room number, working phone number,home phone number etc. The information feeded with chfn command can be printed by using finger.

In below given syntax,select the options you want to feed for user’s account.

Syntax:

chfn [-f full_name] [-r room_no] [-w work_ph] [-h home_ph] [-o other] [user]

Example :

chfn -f "sharad chhetri" -r "111" -w "91-000000" -h "91-0000001" sharad

The output from finger command

The finger command shows the information which is set in GECOS/Comment field by using chfn command

root@tuxworld:~# finger -m sharad
Login: sharad         			Name: sharad chhetri
Directory: /home/sharad             	Shell: /bin/bash
Office: 111, 91-000000			Home Phone: 91-0000001
Last login Fri Jan  3 21:38 (IST) on tty3
No mail.
No Plan.
root@tuxworld:~#

Share this:

  • Share on X (Opens in new window) X
  • Share on Facebook (Opens in new window) Facebook
  • More
  • Print (Opens in new window) Print
  • Email a link to a friend (Opens in new window) Email
  • Share on LinkedIn (Opens in new window) LinkedIn
  • Share on Reddit (Opens in new window) Reddit
  • Share on Tumblr (Opens in new window) Tumblr
  • Share on Pinterest (Opens in new window) Pinterest
  • Share on Telegram (Opens in new window) Telegram
  • Share on WhatsApp (Opens in new window) WhatsApp
  • Share on Mastodon (Opens in new window) Mastodon

Articles

How to rename and move the directory and files in linux
How to create own Git Server with Gitolite and Gitweb in Ubuntu
awk command to print columns from file
run command in remote linux / unix system by using ssh
How to install own git server with ssh and http access by using gitolite and gitweb in CentOS
How to configure vsftpd server with virtual user mysql authentication in CentOS 6
How to set -m option as default in useradd command in linux
Recover Linux Grub Password in linux rescue mode CentOS/Red Hat
Learn tar command and know about its precaution
create and delete user in Red Hat and CentOS
Install Jekyll on Ubuntu 14.04 LTS
Essential Linux Commands Every Beginner Should Know | With Examples
How to list users above or below particular user id
How to lock and unlock user account in linux
list files and directories by 4 commands in linux

Filed Under: Articles Tagged With: user management

Reader Interactions

Leave a Reply Cancel reply

Your email address will not be published. Required fields are marked *

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

Primary Sidebar

Articles

  • Install n8n docker in Ubuntu for practicing
  • Bash Script: MySQL Database backup to AWS S3
  • Automate no touch Jenkins setup wizard on docker (jcac)
  • How to run and configure Jenkins in Docker container
  • Complete Guide: How to install Nagios Monitoring on AlmaLinux / Rocky Linux
  • Install KVM on Ubuntu 24.04 LTS ( Bash Script )
  • How to install GIMP 2.10 on Ubuntu / Debian
  • 5 ways to check Ubuntu version of system (commands and GUI)
  • How To Solve Forgot MySQL / MariaDB Root Password
  • Create Self Hosted Build Agent Docker Image for Azure DevOps

Copyright © 2026 ยท
The material in this site cannot be republished either online or offline, without our permission.
Proudly Blogging From India.

  • Contact
  • About Me
  • My WordPress plugins
  • Privacy Policy