linux file system configuration file

File system

The kernel provides an interface to display some of its data structures, these data structures such as those used in determining the interrupt, initialize the system parameters of the device and memory statistics and the like may be useful. This interface is independent but as a virtual file system provides, called / proc file system. Many system utilities use this value to the file system to display system statistics. For example, / proc / modules include a file system modules currently loaded. lsmod command reads this information and display it in a format that people can understand. Specified in the following table in the same manner mtab file containing the current read mounted file system / proc / mount file.

/etc/mtab

This will change with / proc / mount file is constantly changing. In other words, when the file system is installed and uninstalled, change will be immediately reflected in this document.

1. File Format

/ Etc / mtab format and / etc / fstab is the same. But this file can not be regarded as a user profile, he is maintained by the system. And / etc / fstab difference is that, fstab is to be mounted at system startup files the system list, and mtab system is currently mounted file systems list, which is maintained by the system, the user performs the mount or umount command automatically updated. users should not have to make any changes to this file.

2. Security

/ Default permissions etc / mtab is still 644

3. Related command

mount

umount

smbmount

/etc/fstab

1. File Format

/ Etc / fstab documented automatically mounted at boot file system. A behavior record. Each record has six fields, separated by a space or tab key between fields. The six fields are: device name, mount point (except foreign exchange swap partition must be an existing directory name), file system type, mount options, whether to dump (1 expressed the need for, 0 indicates that no ), the fsck checking during reboot sequence (the active file system is set to 1, the rest of the file system is set to 2, if set to 0 indicates that the file system does not need to be checked).

In the coexistence of linux and windows, you may want to boot automatically mount windows partition, then you can add the corresponding record in this file.

Some time later made an adjustment to the hard disk partition, there also needs to do some appropriate changes. Otherwise, there will be some problems.

Available mount options:

async

All I / O operations on the file system are executed asynchronously

ro

The file system is read-only

rw

The file system is readable and writable

atime

Update the inode access time for each access

auto

You can use the -a option to mount

defaults

Use the default options: rw, suid, dev, exec, auto, nouser, async

dev

Interpret character or block devices on the file system

exec

Allow execution of binary files

noatime

Do not update access times on this file system

noauto

The file system can not use the -a option to mount

nodev

Do not interpret character or block devices on the file system

noexec

It is not allowed to perform any binaries on the mounted file system. This option is useful for file system server has its own structure contains non-binary of

nosuid

Setuid and setgid bit allowed to play a role. (This seems safe, but after installing suidperl, It is not safe).

nouser

Restrictions generally non-root user mount a file system

remount

Try to re-mount already mounted file system. This is typically used to change the sign mount a file system, especially to make read-only file system becomes rewritable

south

Setuid and setgid bit allowed to play a role

sync

All I / O file system synchronous execution

user

Generally allow non-root user mount the file system. This option applies noexec, nosuid, nodev three options (unless specified set these options on the command line coverage).

3. Security

/ Etc / fstab is the 644 default permissions, owner and root for each group.

2. Related command

mount

df

The computer list "can be installed" in the current file system. This is important, because the mount -a command will run when the computer boots, the command is responsible for the installation of the second-last column of fstab with the "1" tag for each file system.

/etc/mtools.conf

Configure all operations on DOS type of file system (creating directories, copying, formatting, etc.).

System Management

/etc/group

1. File Format

/etc/group存储了系统中所有用户的基本信息.它的格式和/etc/passwd的格式基本类似,这里就说简单一点,

/etc/group也是由一条条的记录组成.每条记录分4个字段.分别是组名,组口令,组ID和该组包含用户列表.其中组口令不再使用(现在只是保留为 x).最后一个域是一个用逗号分隔的用户名列表,这个组的成员就是在这里列出的所有用户.

2.安全性

/etc/group的默认权限是644,所有者和所有组均为root.注意经常检察.

3.相关命令

groupadd

groupdel

groupmod

groups

包含有效的组名称和指定组中包括的用户。单一用户如果执行多个任务,可以存在于多个组中。例如,如果一个“用户”是“project 1”工程组的成员,同时也是管理员,那么在 group 文件中他的条目看起来就会是这样的: user: * : group-id : project1

/etc/nologin

这是一个普通的文本文件.你可以在里面写上你喜欢的任何东西./etc/nologin的作用在于,如果它存在,那么系统将拒绝任何非root用户的登录请求,并对其它登录用户显示此文件的内容

此文件常由系统在停机前自动生成.有时系统管理员也会手工生成它,用以禁止其它用户登录,方便进行一些管理工作.

etc/passwd

1.文件格式

/etc/passwd存储了系统中所有用户的基本信息.可以说这是系统中最重要的一个配置文件.对它作任何修改一定要小心谨慎.同时要经常检察这个文件,包括它的内容和权限设置.

使用vi编辑程序打开此文件,可以看到这个文件由许多行记录组成.每一行记录对应着一个用户.我们以第一行为例.第一行一般是root用户的记录,尽管这不是必需的.实际上用户记录出现的顺序并没有任何的意义.

在我的系统中,/etc/passwd的第一行看起来是这样的:

root:x:0:0:root:/root:/bin/bash

每一条记录都由7个字段组成,每个字段之间用冒号隔开.第一个字段是用户名,示例中是root.第二个字段是用户口令,示例中是一个字符x,但这并不表示 root的口令是单个字符x,而是说用户口令被加密了,并且加密口令也没有放在本文件中,而是放到了/etc/shadow(参考 /etc/shadow).假如删除这个x,那么root的口令就清空了.第三个字段是用户的用户ID,即uid.第四个字段是用户的组ID,即gid. 这里要注意,系统分辨两个用户是看他们的uid是否相同而不是看他们的用户名是否相同.用户名不同但uid相同的两个用户实际上是同一个用户.对组来说也有类似的规则.所以这两个字段大家一定要注意.第五个字段是用户全称,没有什么实际用途,相当于注释,这里是root.第六个字段是用户的主目录 (home),即登录系统后默认所处目录,这里是/root.最后一个字段是用户的登录shell,可以是系统拥有的任何一个shell的完整路径,这里是/bin/bash.注意,这个字段可以有一个特殊的值,即/sbin/nologin.如果把一个用户的登录shell设置为 /sbin/nologin的话,系统将禁止此用户的本地登录.

请参阅“man passwd”。它包含一些用户帐号信息,包括密码(如果未被 shadow 程序加密过)。

2.安全性

/etc/passwd的默认权限为644,所有者和所有组均为root.切记,在任何情况下都不要更改它.

3.相关命令

passwd

useradd

userdel

adduser

usermod

users

/etc/rpmrc

rpm 命令配置。所有的 rpm 命令行选项都可以在这个文件中一起设置,这样,当任何 rpm 命令在该系统中运行时,所有的选项都会全局适用。

/etc/securetty

包含设备名称,由 tty 行组成(每行一个名称,不包括前面的 /dev/),root 用户在这里被允许登录。

1.文件格式

这是一个设备文件的列表.文件名取相对于/dev的相对路径.如,/dev/tty1记为tty1

root只有从这个列表中列出的设备上才可以登录系统.

例如:

代码:

$cat /etc/securretty

tty1

tty2

tty3

这里root被限定只能从/dev/tty1, /dev/tty2, /dev/tty3这三个设备上登录系统

如果/etc/securretty不存在的话,那么root将可以从任何设备登录系统.

2.安全性

/etc/securetty的默认权限是600,所有者和所有组都是root

/etc/shadow

包含加密后的用户帐号密码信息,还可以包括密码时效信息。包括的字段有:

  • 登录名
  • 加密后的密码
  • 从 1970 年 1 月 1 日到密码最后一次被更改的天数
  • 距密码可以更改之前的天数
  • 距密码必须更改之前的天数
  • 密码到期前用户被警告的天数
  • 密码到期后帐户被禁用的天数
  • 从 1970 年 1 月 1 日到帐号被禁用的天数

1.文件格式

/etc/shadow文件保存的是用户名,密码,用户账号设置相关信息。

例:

root:$1$6UviCNvh$WTR0zPMek41KmzD0Z1DdV1:12264:3:4:5:6:12267:

第一段: root----- 用户注册名

第二段: $1$6UviCNvh$WTR0zPMek41KmzD0Z1DdV1 ----加密口令

第三段: 12264-----上次更动密码的日期,以1970年1月1日为1,1天加1

第四段: 3---------密码将被允许修改之前的天数(0 表示“可在任何时间修改”)

第五段: 4---------系统将强制用户修改为新密码之前的天数(1 表示“永远都不能修改”)

第六段: 5---------密码过期之前,用户将被警告过期的天数(-1 表示“没有警告”)

第七段: 6---------密码过期之后,系统自动禁用帐户的天数(-1 表示“永远不会禁用”)

第八段: 12267-----该帐户被禁用的天数(-1 表示“该帐户被启用”).以1970年1月1日为1,1月2日为2

第九段 ------ 保留供将来使用

注:第2段中为*表示帐号不可登录,如密码前为 !! 或只有 !! 表示帐号被锁

2.安全性

/etc/shadow的默认所有者和所有组均为root.

建议运行# chattr +i /etc/shadow来保护文件使其不被意外地删除或重写

3.相关命令

passwd

useradd

userdel

usermod

/ect/gshadow

1.文件格式

/ect/gshadow文件保存的是用户和组群设置的信息

例:

root:!!::root,wa1

第一段:组名

第四段:该组包含用户列表

2.安全性

/etc/gshadow的默认所有者和所有组均为root.

建议运行# chattr +i /etc/shadow来保护文件使其不被意外地删除或重写

3.相关命令

groupadd

groupdel

groupmod

groups

/etc/sysctl.conf

1.文件格式

/etc/sysctl.conf是sysctl程序的配置文件.sysctl可以在系统运行时更改内核参数./etc/sysctl.conf中的配置将在系统起动时执行.

以 # 和 ; 开始的行是注释,将和空白行一起被忽略.

配置项的格式为:

token = value

token是一个键名,value是对应的键值.token和value前后的空格将被忽略

token不能是随意的字符串.他和/proc/sys下的文件有一一对应的关系:

假设foo是/proc/sys下的一个文件.删除foo的绝对路径前的 "/proc/sys" 这一部分,然后把剩下部分中的 "/" 替换成 ".",得到的字符串就是foo所对应的键名.例如:

/proc/sys/net/ipv4/ip_forward对应的键名为net.ipv4.ip_forward

应用举例:

Redhat Linux 9默认是禁止ip转发的,而我们在做ip伪装时需要起用ip转发.通常的做法是在iptables的规则之前加上一句:

echo 1>/proc/sys/net/ipv4/ip_forward

实际上我们也可以在/etc/sysctl.conf中写上:

net.ipv4.ip_forward = 1

这样系统就默认起用ip转发了.当然他不会立即生效.因为/etc/sysctl.conf是在系统起动时读入的.想要立即生效的话,请使用sysctl命令.

2.安全性

/etc/sysctl.conf的默认权限是644,所有者和所有组均为root

3.See also

sysctl(8)

sysctl.conf(5)

proc(5)

procinfo(8)

 

/etc/shells

包含系统可用的可能的“shell”的列表。

/etc/motd

每日消息;在管理员希望向 Linux 服务器的所有用户传达某个消息时使用。

Guess you like

Origin www.cnblogs.com/fanweisheng/p/11109358.html