Under /etc: A Simple Guide
October 7th, 2005 by AmirAli Lalji in
Newcomers to Linux, especially those coming from a Windows background, often find files in the /etc directory to be difficult to understand. In this article, I provide a brief explanation of some of these files and their uses. Before we dive into the /etc directory however, I would like to point out that changes to some of these files can render your system unstable or in some circumstances unbootable. I cannot emphasize enough that you should make a backup of these files before making any changes.
Let's dive in:
/etc/exports: this file contains the partition configuration to load NFS (network filesystem). It states how partitions are mounted and shared with other Linux/UNIX systems.
/etc/ftpusers: this file contains the login names of users who are not allowed to log in by way of FTP. For security reasons, it is recommended to add the root user to this file.
/etc/fstab: this file automatically mounts filesystems that are spread across multiple drives or separate partitions. This file is checked when the system boots and filesystems are mounted.
/etc/hosts.[allow, deny]: you can control access to your network by using these files. Adds hosts that you want to grant access to your network to the hosts.allow file; add hosts that you want to deny access to hosts.deny.
/etc/inetd.conf or /etc/xinetd.conf: the inetd file can be called the father of networking services. This file is responsible for starting services such as FTP, telnet and the like. Some Linux distributions come with xinetd.conf, which stands for extended Internet services daemon. This file provides all the functionalities and capabilities of inetd but extends them further.
It is advisable to comment out services you do not use.
/etc/inittab: this file describes what takes place or which processes are started at bootup or at different runlevels. A runlevel is defined as the state in which the Linux box currently is in. Linux has seven runlevels, from 0-6.
/etc/motd: motd stands for message of the day. This file is executed and its contents displayed after a successful login.
/etc/passwd: this file contains user information. Whenever a new user is added, an entry is added to this file containing the user's login name, password and so on. This file is readable by everyone on the system. If the password field contains "x", then encrypted passwords are stored in /etc/shadow, a file that is accessible only by the root user.
/etc/profile: when a user logs in, a number of configuration files are executed, including /etc/profile. This file contains settings and global startup information for the bash shell.
/etc/services: this file works in conjunction with /etc/inetd.conf or /etc/xinetd.conf files (see above). This file determines which port a service mentioned in inetd.conf is to use, for example, FTP/21, TELNET/23 and so on.
/etc/securetty: this file lists TTYs from which root is allowed to log in. For security reasons it is recommended to keep only tty1 for root login.
/etc/shells: this file contains the names of all the shells installed on the system, along with their full path names.
I hope you enjoyed this article and hope it helped in your understanding the /etc directory. You might find other subdirectories beneath the /etc directory that are application specific. /etc/httpd and /etc/sendmail, for example, are for Apache and sendmail, respectively.
Copyright (c) 2003, AmirAli Lalji. Originally published in Linux Gazette issue 94. Copyright (c) 2003, Specialized Systems Consultants, Inc.
Special Magazine Offer -- 2 Free Trial Issues!
Receive 2 free trial issues of Linux Journal as well as instant online access to current and past issues. There's NO RISK and NO OBLIGATION to buy. CLICK HERE for offer
Linux Journal: delivering readers the advice and inspiration they need to get the most out of their Linux systems since 1994.
Sorry, offer available in the US only. International orders, click here.
Subscribe now!
The Latest
Featured Videos
The X Window System is a magnificent platform for many uses, but using it to run an application over a slow network is nearly impossible. This is an introduction to NX, a technology that makes remote applications fly even over commodity internet.
Linux Journal Gadget Guy, Shawn Powers, reviews the Flip Video Ultra, a small portable video camera, and shows us how easy it is to edit the video with Kino.
Thanks to our sponsor: Silicon Mechanics
Recently Popular
From the Magazine
September 2008, #173
Feeling a bit like a Thermian? Never give up, never surrender! Someday, you could go from underdog to top dog. Just take a look at a few of the underdogs we highlight in this issue: Mutt, djbdns, Nginix, Gentoo, Xara and the program voted mostly likely to fail just a few years back—Firefox. If Firefox not radical enough for you, check out Chef Marcel's column for some more alternatives. Having trouble mapping your program data to your relational database? If so, Rueven Lerner shows you some tricks in his At The Forge column.
Need to run GUI applications on your server in the next state? In his Paranoid Penguin column, Mick Bauer shows you how to do it securely. Kyle Rankin keeps hacking and slashing and shows you a few split screen secrets you may not be familiar with. Finally, we all know what happens next February, but only Doc knows what happens afterward.
Delicious
Digg
Reddit
Newsvine
Technorati







the /etc directory
On June 4th, 2006 Anonymous (not verified) says:
Thank you for writing this page. The information on the /etc directory and files has been very useful. I've learned a great deal about my system..
What does "etc" stand for?
On October 19th, 2005 Anonymous (not verified) says:
Thanks for the good summary of the use of the /etc directory. But I've always wondered, what does "etc" stand for anyway? And where did it come from? I like to think of it as "Everything That's Configurable", but that's just my own idea. Anyone know?
I want to know too!
On November 3rd, 2005 Anonymous (not verified) says:
Anyone? We're having a tough debate here at work on the subject :)
/etc seems to be comming
On February 17th, 2006 Anonymous (not verified) says:
/etc seems to be comming from "et cetera" (or "etcetera").
http://en.wikipedia.org/wiki/Filesystem_Hierarchy_Standard
/usr means Unix System Resources encording to wikipedia, though, I've learnt it's Shared not System - but I guess both are valid.
ETC - what it stands for
On March 5th, 2007 Tim (not verified) says:
Read in an old Unix book - "Extended Tool Chest" is what /etc/ stands for, not et cetera. In other words, it's the configuration directory for system config files. There is a system /etc/ directory but is also a concept for directories that hold config files.
Good primer for a newbie like me
On October 15th, 2005 Peter B (not verified) says:
Thanks. :-)
A good primer for a newbie like me. I did some googling and found this page with some info on the etc/ directory as well:
http://www.faqs.org/docs/linux_admin/x399.html
Nice and Useful article
On October 13th, 2005 Viveka Nathan K (not verified) says:
Its a very good article to know /etc, for all.
hmmm
On October 12th, 2005 Anonymous (not verified) says:
This article only listed about 1/20 of what is in the /etc directory. Also, check out the FSH, Filesystem Hierarchy. Its for all of linux's directories with much detail.
Excellent tutorial on /etc
On October 11th, 2005 Anthony Ettinger (not verified) says:
One question, do you pronouce it "ET-SEE" or "Etcetera" or "E-T-C"?
I personally call it "Etcetera" :-)
It's pronounced "ET-SEE".
On October 11th, 2005 Anonymous (not verified) says:
It's pronounced "ET-SEE".
Only if you are american
On October 17th, 2005 Anonymous (not verified) says:
"E-T-C"++
I have only ever heard Americans calling it "et-see"
We call it ET-SEE because we
On March 5th, 2007 Anonymous (not verified) says:
We call it ET-SEE because we invented it and get to call it what we want.
No, you get to call it what
On July 18th, 2007 Anonymous (not verified) says:
No, you get to call it what the actual developers call it, and they DO NOT call it ETSEE! Do some research and don't claim the work of others as your own.
-anonymous kernel dev.
/etc -- it's not a word, it's a directory
On April 20th, 2008 Anonymous (not verified) says:
ETSEE ETSEE ETSEE -- I'll call it that if I want to, and I often do. When I'm not saying "E - T - C", that is. It's not all that important. Perhaps you need a rest?
Some more detailed info....
On October 11th, 2005 Anonymous (not verified) says:
Hi,
I applaud your intentions, but you could be a bit more clear about what each file actually *is* and what it is for.
/etc/exports - This TEXT FILE Is read by the NFS servers on the local machine to make local disk areas usable by remote NFS clients.
/etc/fstab - This TEXT FILE is read by the mount program when it is used to automatically or manually mount file systems. The mount command is run from startup scripts at boot time. mount can mount local as well as remote disks using information from this file.
/etc/hosts.[allow, deny] - These TEXT FILEs are read by services which were compiled with tcp wrappers (tcpd) support to provide access control. You can allow or deny access to services based on host or network.
/etc/inetd.conf or /etc/xinetd.conf - This TEXT FILE is read by the inetd or xinetd program which is started by startup scripts at boot time. This is a "super-server", which binds to many ports and starts specific servers on an as-needed basis.
...and so on...
The basic point is that most of the files in /etc are not PROGRAMS, but rather configuration files which programs read when they are started. There are also SCRIPTS, usually in rc-subdirectories, but
that is not the subject of this article.
On booting, the kernel starts the init PROGRAM, indicating to it the desired run level. init is a program, which reads the inittab file and based on the desired runlevel starts other programs, including startup scripts and tty managers. The scripts mount filesystems, start inetd, nfs services, and the like.
The tty managers start the login PROGRAM, which reads the /etc/password and /etc/shadow files to authenticate users. If network authentication is used, /etc/password and /etc/shadow might only contain information for daemon ids. Login will start a shell PROGRAM, which will read default configs in /etc and in the user's home directory.
Some daemons are started directly by startup scripts, while others are started from (x)inetd. In some cases, a daemon is written so it can be started either way, requiring an argument to indicate the mode.
Lastly, many daemons will typically read their configuration only on startup. Changes to their config files are ignored unless the daemon is restarted, or unless it was written with a method to allow it to be notified to re-read it's config file. Typically a 'kill -HUP ' tells a daemon to re-read it's config file. Most simple daemons follow this tradition. However, complex multi-daemon services like NFS sometimes require a special tool. 'exportfs -ra' on many systems tells the NFS service to re-read it's configs.
Hope this helps to clear any confusion. Damn, I can't believe I wrote all that....
- Pete
Excellent, more please!
On October 11th, 2005 John (not verified) says:
I was so excited to see this article. I think having an example of a config file with a description of the various entries would be a great second step. Of course, explaining the steps to make a back up first would be a great pre-step. So, right after the "I can not emphasize enough that you should make a back up .." insert:
su This is to switch to the super user or "root" acount then type in the root password.
cp /etc/exports /etc/exports.backup
This creates a copy of the exports file in the same directory. You can repeat this with each file you wish to play with.
Some distro's (like Ubuntu) use sudo, which gives you root access for one command only. In that case the command will be
sudo cp /etc/file /etc/file.backup then you will be asked for the root password.
Two corrections: sudo su
On October 13th, 2005 Anonymous (not verified) says:
Two corrections:
sudo su -gives you root access so you can execute as many commands as desiredCheers,
-Adam
"sudo cp /etc/file /etc/file.
On October 11th, 2005 Anonymous (not verified) says:
"sudo cp /etc/file /etc/file.backup then you will be asked for the root password."
Aren't you asked for your own password, and not root's?
whose password for sudo?
On October 11th, 2005 Chris B (not verified) says:
Well, it depends on your distro. Some distros setup sudo to use the user's password, others, look for the root user's password.
Sudo would be a bit pointless
On October 13th, 2005 Anonymous (not verified) says:
Sudo would be a bit pointless and more difficult to enforce if everbody already knows the root password.
What distro sets up sudo to use the root password?
Some more detailed info....
On October 11th, 2005 Anonymous (not verified) says:
Hi,
I applaud your intentions, but you could be a bit more clear about what each file actually *is* and what it is for.
/etc/exports - This TEXT FILE Is read by the NFS servers on the local machine to make local disk areas usable by remote NFS clients.
/etc/fstab - This TEXT FILE is read by the mount program when it is used to automatically or manually mount file systems. The mount command is run from startup scripts at boot time. mount can mount local as well as remote disks using information from this file.
/etc/hosts.[allow, deny] - These TEXT FILEs are read by services which were compiled with tcp wrappers (tcpd) support to provide access control. You can allow or deny access to services based on host or network.
/etc/inetd.conf or /etc/xinetd.conf - This TEXT FILE is read by the inetd or xinetd program which is started by startup scripts at boot time. This is a "super-server", which binds to many ports and starts specific servers on an as-needed basis.
...and so on...
The basic point is that most of the files in /etc are not PROGRAMS, but rather configuration files which programs read when they are started. There are also SCRIPTS, usually in rc-subdirectories, but
that is not the subject of this article.
On booting, the kernel starts the init PROGRAM, indicating to it the desired run level. init is a program, which reads the inittab file and based on the desired runlevel starts other programs, including startup scripts and tty managers. The scripts mount filesystems, start inetd, nfs services, and the like.
The tty managers start the login PROGRAM, which reads the /etc/password and /etc/shadow files to authenticate users. If network authentication is used, /etc/password and /etc/shadow might only contain information for daemon ids. Login will start a shell PROGRAM, which will read default configs in /etc and in the user's home directory.
Some daemons are started directly by startup scripts, while others are started from (x)inetd. In some cases, a daemon is written so it can be started either way, requiring an argument to indicate the mode.
Lastly, many daemons will typically read their configuration only on startup. Changes to their config files are ignored unless the daemon is restarted, or unless it was written with a method to allow it to be notified to re-read it's config file. Typically a 'kill -HUP ' tells a daemon to re-read it's config file. Most simple daemons follow this tradition. However, complex multi-daemon services like NFS sometimes require a special tool. 'exportfs -ra' on many systems tells the NFS service to re-read it's configs.
Hope this helps to clear any confusion. Damn, I can't believe I wrote all that....
- Pete
Awesome, More Please!
On October 10th, 2005 Anonymous (not verified) says:
This is what is needed to push us to wider acceptance!
Thank You, Thank you, thank you !
More, More More !
This page seems to be really
On October 10th, 2005 Parth (not verified) says:
This page seems to be really good at giving an intro to /etc for the newbies... the author can try explaining in detail certain parts like etc/passwd which the user can alter to add/del users. Such things would be helpfull to newbiew :)
Nice article :) Note: the
On October 8th, 2005 Trancelis (verified) or (not verified) says:
Nice article :)
Note: the /etc/motd file is not _executed_, it's just printed.
Thanks for the /etc primer -
On October 8th, 2005 Mathew Drury (not verified) says:
Thanks for the /etc primer - clear, concise. Great article.
I hope you have plans on covering the rest of the filesystem - it's a fantastic starting point for newbies everywhere.
LJ online readers are newbies?
On October 13th, 2005 Admir Trakic (not verified) says:
I'm supprised that the Lj users find this article THAT nifty!?
The contents of this article are trully basic - and can be easily figured out by exploring the *nix machines file tree, instead using the fancy desktop distros.
What is a next article? - man newbie ?
/admir trakic, Cph. DK
I completely agree with
On October 15th, 2005 twocents (not verified) says:
I completely agree with you...... Some people are so dense they fail to see the value of a quick start guide. That fact that search engines exist to drive non-LJ users to these type of sites.
Please feel free to continue to share your brilliant thoughts, always taking into account the big picture - the sharing of information for all skill levels.
mv /admir trakic, Cph. DK > NULL
/etc stands for
On May 14th, 2006 kan (not verified) says:
does /etc stand for: EssenTial Configure files
/etc
On April 11th, 2007 D3vi8nt (not verified) says:
It stands for exntendable tool chest :)
:P
On October 31st, 2007 campuscodi (not verified) says:
10x