Wednesday 28 March 2007

Linux login sequence

It's worth understanding at least those files in the login sequence that will affect things like whether you can login in the first place, where your initial environment comes from, and so on. At the risk of over-simplifying, here are the files you need to worry about that are invoked/consulted every time you log in (indented in an attempt to show who actually consults who):

/etc/passwd 1
/etc/shadow 2
/etc/group 3

/etc/profile 4
/etc/profile.d/*.sh 5

~/.bash_profile 6
~/.bashrc 7
/etc/bashrc 8

1

/etc/passwd defines, among other things, the username, numeric UID and GID of the user, the home directory and the login shell. For security reasons, the encrypted password is no longer stored in this file.

2

/etc/shadow represents a more secure place to store things like the encrypted password, password aging information and more. (This is the only file in this list of files that requires root privilege to display.)

3

/etc/group defines the working groups on the host, along with the users who are members of those groups.

45

/etc/profile represents the top-level startup/customization file that is invoked by each user. In addition, this file may, toward the bottom, invoke all of the customization files in the directory /etc/profile.d, which typically represent a small amount of customization on a per-application or per-command basis. If you're confused about where some login environment setting is coming from that seems to be affecting the behaviour of a particular command, this is a good place to look.

678

These two startup files in the user's home directory are for configuring the user's personal environment. In addition, on some Linux systems, the default .bashrc may invoke the global /etc/bashrc file, for one final dose of environment configuration and customization.

Also ~/.profile(ubuntu) or ~/.bash_profile (fedora) will run after ~/.bashrc to do more personal configuration.

As a final helpful hint, once you get logged in, there are two handy commands that can tell you everything there is to know about your identity and group affiliations:

$ id
$ groups

-------------------------------------------------------------------

/etc/rcX.d

X是runlevel,这里面的文件是对应于/etc/init.d/下的services, S开头代表自动启动,K则表示不启动的;S/K后的双位数是表示service的启动顺序;当rcX.d的service都启动后,会执行rc.local内的command,如果想加载什么命令,在这填写就ok啦.比如fedora下启动modprobe ndiswrapper.

No comments:

My photo
London, United Kingdom
twitter.com/zhengxin

Facebook & Twitter