0
点赞
收藏
分享

微信扫一扫

了解Linux(1):Linux下/etc相关目录解析


这里写目录标题

  • ​​adduser.conf​​
  • ​​adjtime​​
  • ​​alternatives​​
  • ​​apparmor和apparmor.d​​
  • ​​bindrescport.black​​
  • ​​calendar​​
  • ​​chrony​​
  • ​​console-setup​​
  • ​​cron​​
  • ​​crontab​​
  • ​​deluser.conf​​
  • ​​dhcp​​
  • ​​dpkg​​
  • ​​emasc​​
  • ​​environment​​
  • ​​ethertypes​​
  • ​​fonts​​
  • ​​fstab​​
  • ​​gdb​​
  • ​​group​​
  • ​​grub.d​​
  • ​​hdparm.conf​​
  • ​​hosts​​

刚考完试,不想写代码…考虑到经常用Linux,总是懵懵懂懂的用有点鸡肋,所以来写一写关于它的解析.

先来看看第一个文件

adduser.conf

/etc cat adduser.conf
# /etc/adduser.conf: `adduser' configuration.
# See adduser(8) and adduser.conf(5) for full documentation.

# The DSHELL variable specifies the default login shell on your
# system.
DSHELL=/bin/bash

# The DHOME variable specifies the directory containing users' home
# directories.
DHOME=/home

# If GROUPHOMES is "yes", then the home directories will be created as
# /home/groupname/user.
GROUPHOMES=no

# If LETTERHOMES is "yes", then the created home directories will have
# an extra directory - the first letter of the user name. For example:
# /home/u/user.
LETTERHOMES=no

# The SKEL variable specifies the directory containing "skeletal" user
# files; in other words, files such as a sample .profile that will be
# copied to the new user's home directory when it is created.
SKEL=/etc/skel

# FIRST_SYSTEM_[GU]ID to LAST_SYSTEM_[GU]ID inclusive is the range for UIDs
# for dynamically allocated administrative and system accounts/groups.
# Please note that system software, such as the users allocated by the base-passwd
# package, may assume that UIDs less than 100 are unallocated.
FIRST_SYSTEM_UID=100
LAST_SYSTEM_UID=999

FIRST_SYSTEM_GID=100
LAST_SYSTEM_GID=999

# FIRST_[GU]ID to LAST_[GU]ID inclusive is the range of UIDs of dynamically
# allocated user accounts/groups.
FIRST_UID=1000
LAST_UID=59999

FIRST_GID=1000
LAST_GID=59999

# The USERGROUPS variable can be either "yes" or "no". If "yes" each
# created user will be given their own group to use as a default. If
# "no", each created user will be placed in the group whose gid is
# USERS_GID (see below).
USERGROUPS=yes

# If USERGROUPS is "no", then USERS_GID should be the GID of the group
# `users' (or the equivalent group) on your system.
USERS_GID=100

# If DIR_MODE is set, directories will be created with the specified
# mode. Otherwise the default mode 0755 will be used.
DIR_MODE=0755

# If SETGID_HOME is "yes" home directories for users with their own
# group the setgid bit will be set. This was the default for
# versions << 3.13 of adduser. Because it has some bad side effects we
# no longer do this per default. If you want it nevertheless you can
# still set it here.
SETGID_HOME=no

# If QUOTAUSER is set, a default quota will be set from that user with
# `edquota -p QUOTAUSER newuser'
QUOTAUSER=""

# If SKEL_IGNORE_REGEX is set, adduser will ignore files matching this
# regular expression when creating a new home directory
SKEL_IGNORE_REGEX="dpkg-(old|new|dist|save)"

# Set this if you want the --add_extra_groups option to adduser to add
# new users to other groups.
# This is the list of groups that new non-system users will be added to
# Default:
#EXTRA_GROUPS="dialout cdrom floppy audio video plugdev users"

# If ADD_EXTRA_GROUPS is set to something non-zero, the EXTRA_GROUPS
# option above will be default behavior for adding new, non-system users
#ADD_EXTRA_GROUPS=1


# check user and group names also against this regular expression.
#NAME_REGEX="^[a-z][-a-z0-9_]*\$"

# use extrausers by default
#USE_EXTRAUSERS=1

有点多,我们一个一个来

# 这个dshell变量指定默认登陆shell在您的系统
# The DSHELL variable specifies the default login shell on your
# system.
DSHELL=/bin/bash

翻译成中文shell就是外壳的意思,那他有什么用?我们知道管理整个计算机硬件的其实是操作系统的核心 (kernel),这个核心是需要被保护的,同时操作系统给会给出一个接口然你来控制这个操作系统的某些进程,而这个沟通的媒介就是Shell,在Linux系统中可能会内嵌很多种Shell,他们的目的都是和操作系统进行通信,常用的是Bash,这个Shell中的一种

所有的shells放在/etc/shells下

➜  /etc cat shells
# /etc/shells: valid login shells
/bin/sh
/bin/bash
/usr/bin/bash
/bin/rbash
/usr/bin/rbash
/bin/dash
/usr/bin/dash
/bin/zsh
/usr/bin/zsh

来看下一行

# DHOME变量指定目录为目录包含用户的目录(指的是是家目录)
# The DHOME variable specifies the directory containing users' home
# directories.
DHOME=/home

# 如果GROUPHOMES是yes,那么家目录默认被创建
# If GROUPHOMES is "yes", then the home directories will be created as
# /home/groupname/user.
GROUPHOMES=no

# 如果If LETTERHOMES为yes,那么会有一个额外的目录-用户名的第一个字母
# If LETTERHOMES is "yes", then the created home directories will have
# an extra directory - the first letter of the user name. For example:
# /home/u/user.
LETTERHOMES=no

来看下一个

# SKEL变量指明目录包含skeletal用户文件。
# 换句话来说,像sample.profile这样的文件将会在创建新用户的主目录时复制到新用户的主目录。
# etc目录下的profile文件是每一个用户登录时,操作系统首先执行的文件,然后再将控制权交给用户主目录下的.profile文件
# The SKEL variable specifies the directory containing "skeletal" user
# files; in other words, files such as a sample .profile that will be
# copied to the new user's home directory when it is created.
SKEL=/etc/skel

Linux是一个多用户的操作系统。每个用户登录系统后,都会有一个专用的运行环境。通常每个用户默认的环境都是相同的,这个默认环境实际上就是一组环境变量的定义。用户可以对自己的运行环境进行定制,其方法就是修改相应的系统环境变量。
常在/etc/profile文件中修改环境变量,在这里修改的内容是对所有用户起作用的。以下主要操作将在该文件中进行
如何添加环境变量。在profile文件的最后添加如下内容export NAME=zhangsan
使用env命令显示所有的环境变量 ,set命令显示所有本地定义的Shell变量
使用修改.bashrc文件(在用户的家目录下)进行环境变量的编辑,只对当前用户有用。使用修改 /etc/profile 文件进行环境变量的编辑,是对所有用户有用
Linux profile文件在系统启动时将被运行。大家可以在里面加入其他命令,但是一定要加正确,不然的话系统会启动不起来的

下一个

# 包含的是UID的范围
# 用于动态分配管理和系统帐户/组。
# 请注意系统软件,如base-passwd分配的用户
# 包,可能假设uid小于100是未分配的
# FIRST_SYSTEM_[GU]ID to LAST_SYSTEM_[GU]ID inclusive is the range for UIDs
# for dynamically allocated administrative and system accounts/groups.
# Please note that system software, such as the users allocated by the base-passwd
# package, may assume that UIDs less than 100 are unallocated.
FIRST_SYSTEM_UID=100
LAST_SYSTEM_UID=999

# 分配动态用户组(与上面的系统区分)
# FIRST_[GU]ID to LAST_[GU]ID inclusive is the range of UIDs of dynamically
# allocated user accounts/groups.
FIRST_UID=1000
LAST_UID=59999
FIRST_GID=1000
LAST_GID=59999

# USERGROUPS变量可以是“yes”或“no”。如果“是”
# 创建的用户将被授予他们自己的组作为默认使用。如果
# "no",每个创建的用户将被放置在gid为的组中
# USERS_GID(参见下面)。
# The USERGROUPS variable can be either "yes" or "no". If "yes" each
# created user will be given their own group to use as a default. If
# "no", each created user will be placed in the group whose gid is
# USERS_GID (see below).
USERGROUPS=yes

# 如果USERGROUPS是“no”,那么USERS_GID应该是组的GID
# ' users'(或等价的组)
# If USERGROUPS is "no", then USERS_GID should be the GID of the group
# `users' (or the equivalent group) on your system.
USERS_GID=100

# 如果设置了DIR_MODE,将使用指定的目录创建目录
# 模式。否则将使用默认模式0755。
# If DIR_MODE is set, directories will be created with the specified
# mode. Otherwise the default mode 0755 will be used.
DIR_MODE=0755

# 如果SETGID_HOME是“yes”,则用户可以使用自己的主目录
# group设置setgid位。这是默认值
# adduser的版本号<< 3.13。因为它有一些不好的副作用
# 默认不再这样做。如果你想要,你还是可以的
# 仍然设置在这里。
# If SETGID_HOME is "yes" home directories for users with their own
# group the setgid bit will be set. This was the default for
# versions << 3.13 of adduser. Because it has some bad side effects we
# no longer do this per default. If you want it nevertheless you can
# still set it here.
SETGID_HOME=no

如果设置了QUOTAUSER,将从该用户设置一个默认配额
# ' edquota -p QUOTAUSER newuser'
# If QUOTAUSER is set, a default quota will be set from that user with
# `edquota -p QUOTAUSER newuser'
QUOTAUSER=""

# 如果设置了SKEL_IGNORE_REGEX, adduser将忽略匹配的文件
#正则表达式创建一个新的主目录
# If SKEL_IGNORE_REGEX is set, adduser will ignore files matching this
# regular expression when creating a new home directory
SKEL_IGNORE_REGEX="dpkg-(old|new|dist|save)"

# Set this if you want the --add_extra_groups option to adduser to add
# new users to other groups.
# This is the list of groups that new non-system users will be added to
# Default:
#EXTRA_GROUPS="dialout cdrom floppy audio video plugdev users"

# 检查用户名和组名也针对这个正则表达式。
# check user and group names also against this regular expression.
#NAME_REGEX="^[a-z][-a-z0-9_]*\$"

# 默认使用extrausers
# use extrausers by default
#USE_EXTRAUSERS=1

adjtime

adjtime是用于调整Linux系统时间的

alternatives

这个文件里面都是软链接文件,当使用某些相似的文件,比如vi或者vim的时候,会进行自动选择配置

了解Linux(1):Linux下/etc相关目录解析_RPC

apparmor和apparmor.d

apparmor

了解Linux(1):Linux下/etc相关目录解析_bash_02

apparmor.d
Apparmor是ubuntu自带的安全工具,可以限制已知应用的能力,控制应用访问文件、目录和网络的能力。具有类似功能的工具还包括selinux、lids,目前selinux、lids和apparmor遵循LSM框架,并通过LSM框架整合到内核中。

/etc/init.d/apparmor start|stop|restart|status 用于启动、停止、重启apparmor和查看apparmor进程的状态。

apparmor_status可查看受apparmor控制的应用

了解Linux(1):Linux下/etc相关目录解析_bash_03


​​说明​

bindrescport.black

# 该文件包含一个端口号列表,范围在600到1024之间,
# 不应该被bindresvport使用。bindresvport主要是
# 由RPC服务调用。这基本上解决了这个问题,a
# RPC服务使用另一个服务的已知端口。
# This file contains a list of port numbers between 600 and 1024,
# which should not be used by bindresvport. bindresvport is mostly
# called by RPC services. This mostly solves the problem, that a
# RPC service uses a well known port of another service.

RPC采用客户机/服务器模式。请求程序就是一个客户机,而服务提供程序就是一个服务器。首先,调用进程发送一个有进程参数的调用信息到服务进程,然后等待应答信息。

在服务器端,进程保持睡眠状态直到调用信息的到达为止。当一个调用信息到达,服务器获得进程参数,计算结果,发送答复信息,然后等待下一个调用信息,最后,客户端调用过程接收答复信息,获得进程结果,然后调用执行继续进行。
​RPC​​

calendar

系统日历

chrony

Chrony是NTP(Network Time Protocol,网络时间协议,服务器时间同步的一种协议)的另一种实现,与ntpd不同,它可以更快且更准确地同步系统时钟,最大程度的减少时间和频率误差。

console-setup

更改Linux控制台的字体和大小,这对于那些不喜欢默认字体类型/大小或者喜欢不同字体的人来说非常有用

cron

当我们要增加全局性的计划任务时,一种方式是直接修改/etc/crontab。但是,一般不建议这样做,/etc/cron.d目录就是为了解决这种问题而创建的

cron进程执行时,就会自动扫描该目录下的所有文件,按照文件中的时间设定执行后面的命令。

cron执行时,也就是要读取三个地方的配置文件:一是/etc/crontab,二是/etc/cron.d目录下的所有文件,三是每个用户的配置文件
​cron​​

crontab

Linux crontab是用来定期执行程序的命令。

当安装完成操作系统之后,默认便会启动此任务调度命令。

crond 命令每分锺会定期检查是否有要执行的工作,如果有要执行的工作便会自动执行该工作。

​​crontab​​

deluser.conf

一些删除用户的设置

# /etc/deluser.conf: `deluser' configuration.

# Remove home directory and mail spool when user is removed
REMOVE_HOME = 0

# Remove all files on the system owned by the user to be removed
REMOVE_ALL_FILES = 0

# Backup files before removing them. This options has only an effect if
# REMOVE_HOME or REMOVE_ALL_FILES is set.
BACKUP = 0

# target directory for the backup file
BACKUP_TO = "."

# delete a group even there are still users in this group
ONLY_IF_EMPTY = 0

# exclude these filesystem types when searching for files of a user to backup
EXCLUDE_FSTYPES = "(proc|sysfs|usbfs|devpts|tmpfs|afs)"

dhcp

动态获取IP地址

dpkg

这个文件包含默认的dpkg的配置,所有的命令行都允许

➜  dpkg cat dpkg.cfg 
# dpkg configuration file
#
# This file can contain default options for dpkg. All command-line
# options are allowed. Values can be specified by putting them after
# the option, separated by whitespace and/or an `=' sign.
#

# Do not enable debsig-verify by default; since the distribution is not using
# embedded signatures, debsig-verify would reject all packages.
no-debsig

# Log status changes and actions to a file.
log /var/log/dpkg.log

emasc

类似vim

environment

/etc/environment这个文件可有可无,debian下就默认没有这个文件,自己创建一个系统也能认
系统会默认寻找一系列文件,从中提取需要的环境信息和变量,/etc/environment就是这类文件
没有这些文件,系统能运行,有了,系统能获得更多的配置信息
写入/etc/environment的那些信息完全可以写入/etc/profile,作用一样,没有影响

ethertypes

EtherType是一个2字节的以太网帧字段,用于表示
#在他们的有效载荷中包含哪个协议。

fonts

字体目录

fstab

#使用’blkid’打印一个唯一标识符
#装置;这可以与UUID=一起使用,作为一种更健壮的设备命名方式
#即使添加和删除磁盘也能工作

# /etc/fstab: static file system information.
#
# Use 'blkid' to print the universally unique identifier for a
# device; this may be used with UUID= as a more robust way to name devices
# that works even if disks are added and removed. See fstab(5).
# 文件系统 挂载点 类型 选择 转储 废弃
# <file system> <mount point> <type> <options> <dump> <pass>
# / was on /dev/vda1 during installation
UUID=12e5697d-887b-4790-a160-75cf814081a6 / ext4 errors=remount-ro 0 1
/dev/fd0 /media/floppy0 auto rw,user,noauto,exec,utf8 0 0

gdb

gdb调试

group

每个用户都有一个用户组,系统可以对一个用户组中的所有用户进行集中管理。不同Linux 系统对用户组的规定有所不同,如Linux下的用户属于与它同名的用户组,这个用户组在创建用户时同时创建。

用户组的管理涉及用户组的添加、删除和修改。组的增加、删除和修改实际上就是对/etc/group文件的更新。

grub.d

这个目录中的所有可执行文件都按照shell展开顺序进行处理。

  • 00_*:为00_header保留。
  • 10_*:本机引导项。
  • 20_*:第三方应用(如memtest86+)。
    中间的数字名称空间可由系统安装程序和/或配置
    管理员。

hdparm.conf

hdparm命令的配置文件
​​​hdparm命令​​

hosts

Linux系统在向DNS服务器发出域名解析请求之前会查询/etc/hosts文件,

如果里面有相应的记录,就会使用hosts里面的记录。

由此,/etc/hosts于设置 hostname是没直接关系的

解决的问题:

  • 远程登录linux主机过慢问题
  • 双机互连


举报

相关推荐

0 条评论