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

sharadchhetri

Tutorials On Linux, Unix & Open Source

  • Home
  • Linux Commands
  • Resources
    • Learn Linux
  • My WordPress plugins

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:

  • Twitter
  • Facebook
  • More
  • Print
  • Email
  • LinkedIn
  • Reddit
  • Tumblr
  • Pinterest
  • Pocket
  • Telegram
  • WhatsApp
  • Mastodon

Related posts:

  1. Recover Linux Grub Password in linux rescue mode CentOS/Red Hat
  2. How to upgrade Linux Mint 15 to Linux Mint 16
  3. How to delete password of user in Linux
  4. How to lock and unlock user account in linux
  5. How to zip the directory in linux with command line
  6. make command not found in linux CentOS Red Hat ubuntu Debian
  7. How to rename and move the directory and files in linux
  8. How to backup and restore iptables on Linux systems
  9. How to extract RPM package on Linux system
  10. How to set motd in linux

Filed Under: Linux 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

Our Social Media Presence

  • Facebook
  • GitHub
  • Twitter

Linux Command

What is Linux Internal And External Command

Linux Basic Commands With Examples For Every Beginner

tr command to convert lines to space , tab and vertical tab

smbpasswd command not found on CentOS 7 and RHEL 7

Solution : semanage command not found

Unix / Linux : How to print duplicate lines from file

More Posts from this Category

You Might Like These Articles!

simplecodesyntax wordpress plugin

SimpleCodeSyntax : My Another WordPress Plugin

Install Nginx

How To Install Nginx On Ubuntu 22.04 LTS

Install Latest Git package in Ubuntu Operating System

How To Always Install Latest Git Package In Ubuntu Operating System

Bash script for installing VirtualBox on Ubuntu 22.04 LTS Desktop

Install VirtualBox On Ubuntu 22.04 LTS Desktop (Bash Script)

libfuse

dlopen(): error loading libfuse.so.2 – Got Error On Ubuntu

Failed to open/create the internal network

VirtualBox Error: Failed to open/create the internal network

Always Useful Tips And Tricks

Replace keyword with its filename without extension : bash script

master admin password openerp 7.x

Set GRUB password after installation of CentOS/Red Hat

How to configure ethernet in CentOS 6 after installing in Virtual Box

Edit the crontab without using crontab -e

How to use grep command to get fixed pattern or exact keyword

Show visitor ip address php code

Explore 90+ Article On "Linux Tips And Tricks"

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

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