Files

Saturday, January 29, 2011

/etc/sysconfig/network-scripts/ifcfg-eth0

This file contains the configuration of your network card. The settings are different for dhcp connection and for a static connection.

For a dhcp connection the file looks like
# Advanced Micro Devices [AMD] 79c970 [PCnet32 LANCE]
DEVICE=eth0
BOOTPROTO=dhcp
HWADDR=00:0c:29:d6:04:92
ONBOOT=yes
TYPE=Ethernet
For static connection it looks like
# Advanced Micro Devices [AMD] 79c970 [PCnet32 LANCE]
DEVICE=eth0
BOOTPROTO=none
HWADDR=00:0c:29:d6:04:92
ONBOOT=yes
TYPE=Ethernet
NETMASK=255.255.255.0
IPADDR=192.168.1.3
GATEWAY=192.168.1.1

Friday, January 28, 2011

/etc/issue

This file contains the display message to be written in various virtual consoles. Kernel \r represents kernel version and \m represents machine architecture. Other option like \l (tty) and \s (kernel name) can be also used

Redhat Enterprise Linux release 5.4
Kernel \r on an \m

/etc/redhat-release

This file contains the release of the redhat version

.bash_profile, .bashrc, .bash_logout

.bash_profile is a bash script file which is run when the system starts up. Each user has their own .bash_profile, .bashrc and .bash_logout file. For the root user it is in /root/ and for other users it is in /home/username/ directory.
User specific environment and startup programs are written in .bash_profile file.

# .bash_profile

# Get the aliases and functions
# If file ~/.bashrc exists then run the file

if [ -f ~/.bashrc ]; then
. ~/.bashrc
fi

# User specific environment and startup programs
# Additional path can be added seperated by colon eg. PATH=$PATH:$HOME/bin:/usr/sbin:/sbin

PATH=$PATH:$HOME/bin

export PATH
unset USERNAME

User specific aliases and functions are declared in .bashrc



# .bashrc

# User specific aliases and functions

alias rm='rm -i'
alias cp='cp -i'
alias mv='mv -i'

# Source global definitions
# If file /etc/bashrc exists then run it
if [ -f /etc/bashrc ]; then
. /etc/bashrc
fi



The scripts which needs to be run when the user logs out can be written in .bash_logout.


# ~/.bash_logout

clear

Monday, January 24, 2011

/etc/X11/xorg.conf

The xorg.conf file is divided into a minimum of eight sections. The start of each section is marked by the word Section followed by the section's name, and its end by EndSection. Sections can be placed in any order, and you can have more than one section that cover a certain purpose -- for example, if you are using multiple monitors. As in most configuration files, you may also see lines that start with a number sign (#) that provide comments for human readers. These lines are ignored by the operating system, and you can add more for your own purposes.

Within each section, you can quickly observe the structure that additional entries should follow. For instance, most sections indent once for a field and again for its value, which is placed in double quotation marks. Similarly, hardware has an Identifier field, which can be anything so long as it is unique. The indentations are not needed by your computer, but they do ensure that the file is kept in human-readable form. Once you understand this basic structure, you are ready to edit xorg.conf.

Setting resources and improving font display

Resources for the X server are listed in the Files section. Some distributions include the path to the database used for the RGB color palettes used for the display (/usr/share/X11/rgb), as well as the path to the server modules (/usr/lib/xorg/modules or /usr/lib/modules), but these paths should be unnecessary unless your system has resources stored in unusual places. Recent versions of Debian, for instance, omit these entries entirely.

Most of the system resources are devoted to the paths used for fonts. Users must add all new fonts via a font server, the easiest one to use being the one built into the KDE Control Center, which stores fonts in /usr/local/share/fonts (nothing comparable exists for GNOME). Fonts that were added during system installation are usually stored in /usr/share/fonts/ or /usr/share/fonts/X11, which has subdirectories for TrueType, Type 1 or PostScript, and bitmapped fonts. You can add new font paths by following the format of existing entries:

FontPath ""

If an application needs to display a particular font, then the X server uses the first instance of the font located. For this reason, you can sometimes improve font display on the system by changing the order in which fontpaths are listed. The "XFree86 Font Deuglification Mini HOWTO," an old but still useful source, suggests that you place any directory for 100dpi bitmap fonts before those for 75dpi bitmap fonts, and add :unscaled to the end of all the paths for bitmapped fonts. These changes help to ensure that a higher quality font will be the one used by the X server.

Editing X server modules

xorg.conf's Modules and DRI sections refer to modules loaded by the X server for such purposes as 3-D acceleration (glx, dri) and font support (freetype, type1, speedo). For the most part, you should not edit these sections. They are dependent on resources compiled in the kernel and supplied by various libraries added during installation, so simply editing xorg.conf may not have any effect on your system. Unfortunately, too, they are by far the least documented sections of the file, so if you're not an expert, leave them alone.

However, if you are having display problems, as a last resort, you can try the hacker's solution of commenting out all of the modules and adding them back one by one with each reboot. In particular, if you're using the freetype module, other font modules may be redundant, such as type1, as well as the xtt module, which provides TrueType support conflicts with freetype according to some reports.

Defining the keyboard

The keyboard is defined in a separate Input Device section in xorg.conf that starts with an Identifier. The Identifier is followed by a Driver -- usually just kbd in a 2.6 kernel -- and, for the main keyboard in a configuration, the CoreKeyboard option.

Most users will also want to use the XkbRules options to define the general behavior of the keyboard, since the alternative is to define all aspects of the keyboard layout separately. This option should usually be defined as xorg, which indicates that the X server should use the standard settings for xorg.

However, even with the shortcut provided by XkbRules, you still need to define the XkbModel for the keyboard, using one of the options listed in /usr/share/X11/xkb/rules/base.lst, or else a generic one such as pc104 or pc102. You also need the XkbLayout option, which takes one of the standard two-digit locale codes that are also listed in base.lst in order to define the symbols associated with other keys.

If you want to use multiple layouts you can use XkbLayout to list multiple keyboard layouts in a comma-separated list, and use XkbOption to define a key or key combination that cycles through each layout. For example, to use Alt-Shift to move through the defined layouts, you would enter the line Option "XkbOptions" "grp:Alt_shift_toggle".

Similarly, if you want to define a Compose and an AltGraph key -- two keys that are used to enable the typing of international characters, such as accents or currency symbols -- you can use XkbOptions to define them. For instance, defining them as "compose:rwin, grp:lwin" would give those useless right and left Windows key a purpose at last.

Configuring the pointing device

A mouse or other pointing device is defined in a separate Input Device section. After the Identifier, the next three lines in the section will generally be:

Driver "mouse"

Option "CorePointer"

Option "Device" "/dev/input/mice"

As you can probably guess, the CorePointer option defines the primary input device, and the Device gives the path to the device.

After that, an entry for a pointer device will have an option defining the Protocol, which describes the manufacturer and model of the device. The Auto option for the protocol is reported as broken in recent versions of xorg, so you should specify the exact protocol, such as Microsoft or Logitech, or the general type of mouse, such as ImPS/2 or USB.

If you have a two-button mouse, you should add the "Emulate 2 buttons" option. For devices that have more than three buttons, you can use the "Buttons" option to specify the exact number if you have more than three. More esoterically, you can use the "XAxisMapping" and "YAxisMapping" options to give a space-separated list of buttons to use when a scroll wheel is emulated, or "ZAxisMapping" to map the scroll wheel motion to another axis or button, either because you are using a device that lacks a scroll wheel but has extra buttons, or for simple convenience.

Configuring the graphics card

xorg.conf's Device section controls the graphics card configuration. This name is obscure, but understandable when you consider that the graphics card drives the entire display. The basic configuration consists of the Identifier, followed by the Driver field. If you are having trouble with the display, you can try one of the drivers in the /usr/lib/xorg/modules/drivers directory, using the first element of the file name before the underscore as the entry for the driver in xorg.conf. For example, if the s3virge_drv.so file is in the directory, you would enter the driver name as "s3virge". If all else fails you can get basic video support by entering "vesa" or "vga" for the driver. Most of these drivers have a man page that you can consult for more information.

Increasingly, the BusID field, which defines the slot the video card is placed in, is also being used in this section. Usually, the first video card's bus ID will be PCI:1:0:0, but you can find it for sure by running the lspci command and looking for the video card in the results. Depending on the card in your system, you may also need to add the VendorName and BoardName fields, using information that came with your video card.

Defining the monitor

At a minimum, the modern Monitor section of xorg.conf consists of a unique Identifier and the option DPMS, which enables Display Power Management Signaling in order to conserve the power used by the monitor. However, you can also set the horizontal and vertical refresh rates in the HorizSync and VertRefresh fields, or the monitor's Gamma setting, using information supplied with the monitor.

Another option is DisplaySize, which is measured in millimeters and specifies the dots per inch to use at a particular resolution. To get the resolution in millimeters, multiply both the height and the width by 25.4, and divide each result by the desired DPI. For example, if your resolution is 1024 x768, the results rounded down would be 270 and 203, and the entire entry for the option would read:Option "DisplaySize" "270 203 # 96 DPI @ 1024x768".Alternatively, with some Nvidia cards, you may need to suppress the automatic setting of the DPI by including the option "USEdidDPI" set to "false" and following by the option "DPI" with a value for the desired DPI, such as "96 x 96".

Setting resolution and color depth

The Screen section begins with a unique identifier, followed by a summary of the display options, listing the video card ("Device") and monitor by the Identifiers they were given in early sections of the file, followed by the default color depth ("DefaultDepth").

The rest of the section is devoted to the Display subsection. For each color depth ("Depth"), the subsection lists each resolution ("Mode") that the system supports. When the X Window System starts, it will try to use the default color depth at the maximum resolution listed for it. However, if X is unable to do so for any reason, then it will try each resolution for the default color depth, then repeat the process for the next highest color depth until it manages to load.

You can use this behavior to force your display to use a particular color depth and resolution, either because your system refuses to use the settings you want -- possibly due to a flaw in the driver -- or because you want settings lower than the maximum. All you need to do is change the default color depth, then, under the listing of resolutions for that depth, place your preferred resolution first.

You may also choose to delete the resolution listings for other color depths, as well as other resolutions. As long as you have a backup of the original xorg.conf file, the worst this practice can do is force you to restore the backup and reboot.

Final steps and final words

If you have added hardware to your system, your last step in editing xorg.conf must be to make sure that the xorg.conf references it. That means adding the Identifier for a new monitor or video card to the Screen section, and the Identifier for a new pointing device or keyboard to the ServerLayout section. When you have done that, either reboot your system or restart X using Ctrl-Alt-Backspace to test the new configuration. Should X fail to start, you can still edit xorg.conf from the command line, or, when either all options or all patience is exhausted, restore your system using the backup copy you made of xorg.conf. You can find log files for Xorg in /var/log, although, since the problem is bound to be in your recent changes, you may not need the log to figure out what is wrong.

These are only the most basic options for editing xorg.conf. Depending on which manufacturer you buy your hardware from and whether you are using multiple pieces of the same type of hardware, you can significantly complicate the contents of the file. However, the information here is enough for a basic orientation. You may never have to edit xorg.conf manually, but if you do, knowing what to expect can only help.

Sample xorg.conf file

# Xorg configuration created by system-config-display

Section "ServerLayout"
Identifier "single head configuration"
Screen 0 "Screen0" 0 0
InputDevice "Keyboard0" "CoreKeyboard"
EndSection

Section "InputDevice"
Identifier "Keyboard0"
Driver "kbd"
Option "XkbModel" "pc105"
Option "XkbLayout" "us"
EndSection

Section "Monitor"

### Comment all HorizSync and VertSync values to use DDC:
Identifier "Monitor0"
ModelName "LCD Panel 1280x800"
### Comment all HorizSync and VertSync values to use DDC:
HorizSync 31.5 - 50.0
VertRefresh 56.0 - 65.0
Option "dpms"
EndSection

Section "Device"
Identifier "Videocard0"
Driver "vmware"
EndSection

Section "Screen"
Identifier "Screen0"
Device "Videocard0"
Monitor "Monitor0"
DefaultDepth 24
SubSection "Display"
Viewport 0 0
Depth 24
Modes "1280x720"
EndSubSection
EndSection

/etc/gshadow

The /etc/gshadow file is readable only by the root user and contains an encrypted password for each group, as well as group membership and administrator information. Just as in the /etc/group file, each group's information is on a separate line. Each of these lines is a colon delimited list including the following information:

project:!!:smith:sara,michael

  • Group name — The name of the group. Used by various utility programs as a human-readable identifier for the group.
  • Encrypted password — The encrypted password for the group. If set, non-members of the group can join the group by typing the password for that group using the newgrp command. If the value of this field is !, then no user is allowed to access the group using the newgrp command. A value of !! is treated the same as a value of ! — however, it also indicates that a password has never been set before. If the value is null, only group members can log into the group.
  • Group administrators — Group members listed here (in a comma delimited list) can add or remove group members using the gpasswd command.
  • Group members — Group members listed here (in a comma delimited list) are regular, non-administrative members of the group.

/etc/group

/etc/group is a text file which defines the groups to which users belong under Linux operating system. Under Linux multiple users can be categorized into groups. Linux file system permissions are organized into three classes, user, group, and others. The use of groups allows additional abilities to be delegated in an organized fashion, such as access to disks, printers, and other peripherals. This method, amongst others, also enables the Superuser to delegate some administrative tasks to normal users.

File format The /etc/group file is a text file with one group record per line, each one describing a group. This record consists of four fields separated by colons. The order of these fields within the file is important.

project:x:24:smith,sara,michael


  1. The first field (group_name) is the group name, i.e. a string entered in this file by the administrator or an application with sufficient privilege. The name of the group is like an identification or the record in the /etc/group file, it must be unique.
  2. The second field stores information used to validate a group's password if applicable. However in the actual modern systems this field is usually set to "x", this field is supposed to receive encrypted information of the encrypted password of the group to enhance the security.
  3. The third field, GID, is the group identifier, assigned by hand or automatically by the system, it’s a number that the operating system uses for internal purposes. It does not have to be unique in this file. This number can be checked in /etc/passwd file, where you conclude that each user should be assigned with a GID number.
  4. The fourth field, the last one, is list of the member of the group. The names in this list are separated by commas, and they have to be in /etc/passwd.

/etc/shadow

With a shadowed password scheme in use, the /etc/passwd file typically shows a character such as '*', or 'x' in the password field for each user instead of the hashed password, and /etc/shadow usually contains the following user information:

jsmith:$1$geoDOQv.$IFyZ/5iO6bCptW5xAp6E6/:3:2:5:7:10:23984:
  • User login name
  • salt and hashed password OR a status exception value e.g.:
    • "NP" or "!" or null - No password, the account has no password.
    • "LK" or "*" - the account is Locked, user will be unable to log-in
    • "!!" - the password has expired
  • Days since epoch of last password change
  • Days until change allowed
  • Days before change required
  • Days warning for expiration
  • Days before account inactive
  • Days since Epoch when account expires
  • Reserved

While the most important information in the shadow file consists of the salt and the hashed password, the file usually contains other fields as well, such as the last time the password was changed, when the password will expire, and whether the account is disabled. The format of the shadow file is simple, and basically identical to that of the password file, to wit, one line per user, ordered fields on each line, and fields separated by colons. Many systems require the order of user lines in the shadow file be identical to the order of the corresponding users in the password file.

/etc/passwd

The /etc/passwd file is a text file with one record per line, each describing a user account. Each record consists of seven fields separated by colons. The ordering of the records within the file is generally unimportant.

An example record may be:

jsmith:x:1001:1000:John Smith,Room 500,(456)111-20,(456)111-44,email:/home/jsmith:/bin/sh

The fields, in order from left to right, are:

  1. The first field is the user name, i.e. the string a user would type in when logging into the operating system: the logname. Each record in the file must have a unique user name field.
  2. The second field stores information used to validate a user's password; however in most modern uses this field is usually set to "x" (or some other indicator) with the actual password information being stored in a separate shadow password file. Setting this field to an asterisk "*" is the typical way to deactivate an account to prevent it being used.
  3. The third field is the user identifier (UID), the number that the operating system uses for internal purposes. It does not have to be unique.
  4. The fourth field is the group identifier(GID). This number identifies the primary group of the user; all files that are created by this user may initially be accessible to this group.
  5. The fifth field, called the Gecos field, is commentary that describes the person or account. Typically, this is a set of comma-separated values including the user's full name and contact details.
  6. The sixth field is the path to the user's home directory.
  7. The seventh field is the program that is started every time the user logs into the system. For a interactive user, this is usually one of the system's command line interpreters (shells).