Handy Linux Files

There are a number of useful files as follows:

  • /etc/passwd - lists the users, their userid and home directory
  • /etc/group - list of groups and which users are members
  • /etc/os-release - details of the distribution
  • /etc/sysconfig/clock - contains the current time zone
  • /sys/devices/virtual/dmi/id - is a directory full of useful ids, such as product_serial and bios_version etc
  • /etc/shells - this file contains a list shells available for use
If you want to see all "release" file output then cat /etc/*ease works nicely.

passwd file

The /etc/passwd file is a : separated file that contains information about users. Originally it contained hashed password but this is usually in the /etc/shadow file now, or since about 1992. An example line looks like this:
geoff:x:501:1001:Geoff's user login:/home/geoff/:/bin/bash
As you an see, there are 7 fields, which are as follows:

  1. Username: the username, to login with
  2. Password: x means see /etc/shadow in Linux, AIX uses ! to mean password in /etc/security and * for invalid password
  3. User ID: unique ID for user
  4. Default Group ID: the ID of the users default or principle group, you'll need to lookup the ID in /etc/group
  5. Comment: this can be any piece of text, historically it was GCOS information; Full Name, Building, Phone, Other info
  6. Home Directory: absolute path to default login directory, where profile files are stored
  7. Shell: usually something like /usr/bin/sh or /bin/bash but also possibly /sbin/nologin or /bin/false
I found Linux & UNIX /etc/passwd file structure – Cook UoP to give a useful explanation.

CentOS - example output

# cat /etc/os-release
NAME="CentOS Linux"
VERSION="7 (Core)"
ID="centos"
ID_LIKE="rhel fedora"
VERSION_ID="7"
PRETTY_NAME="CentOS Linux 7 (Core)"
ANSI_COLOR="0;31"
CPE_NAME="cpe:/o:centos:centos:7"
HOME_URL="https://www.centos.org/"
BUG_REPORT_URL="https://bugs.centos.org/"

CENTOS_MANTISBT_PROJECT="CentOS-7"
CENTOS_MANTISBT_PROJECT_VERSION="7"
REDHAT_SUPPORT_PRODUCT="centos"
REDHAT_SUPPORT_PRODUCT_VERSION="7"

# cat /etc/centos-release
CentOS Linux release 7.1.1503 (Core)

Note: this file does not exist in CentOS 6.x or earlier

openSUSE - example output

> cat /etc/os-release
NAME=openSUSE
VERSION="13.2 (Harlequin)"
VERSION_ID="13.2"
PRETTY_NAME="openSUSE 13.2 (Harlequin) (x86_64)"
ID=opensuse
ANSI_COLOR="0;32"
CPE_NAME="cpe:/o:opensuse:opensuse:13.2"
BUG_REPORT_URL="https://bugs.opensuse.org"
HOME_URL="https://opensuse.org/"
ID_LIKE="suse"

Oracle Linux - example output

$ cat /etc/*ease
Oracle Linux Server release 7.2
NAME="Oracle Linux Server"
VERSION="7.2"
ID="ol"
VERSION_ID="7.2"
PRETTY_NAME="Oracle Linux Server 7.2"
ANSI_COLOR="0;31"
CPE_NAME="cpe:/o:oracle:linux:7:2:server"
HOME_URL="https://linux.oracle.com/"
BUG_REPORT_URL="https://bugzilla.oracle.com/"

ORACLE_BUGZILLA_PRODUCT="Oracle Linux 7"
ORACLE_BUGZILLA_PRODUCT_VERSION=7.2
ORACLE_SUPPORT_PRODUCT="Oracle Linux"
ORACLE_SUPPORT_PRODUCT_VERSION=7.2
Red Hat Enterprise Linux Server release 7.2 (Maipo)
Oracle Linux Server release 7.2

Ubuntu Linux - example output

$ cat /etc/*ease
DISTRIB_ID=Ubuntu
DISTRIB_RELEASE=14.04
DISTRIB_CODENAME=trusty
DISTRIB_DESCRIPTION="Ubuntu 14.04.5 LTS"
NAME="Ubuntu"
VERSION="14.04.5 LTS, Trusty Tahr"
ID=ubuntu
ID_LIKE=debian
PRETTY_NAME="Ubuntu 14.04.5 LTS"
VERSION_ID="14.04"
HOME_URL="http://www.ubuntu.com/"
SUPPORT_URL="http://help.ubuntu.com/"
BUG_REPORT_URL="http://bugs.launchpad.net/ubuntu/"