linux文件目录分析之/etc目录

在linux下修改系统配置时就会在/etc这个目录下修改配置文件,可见这个目录是系统的配置文件目录。

在终端输入ls看看里面的文件:

$ ls
acpi                    calendar             dpkg           host.conf             ldaptor         magic.mime      os-release               rc2.d          shells        udev
adduser.conf            chatscripts          drirc          hostname              ldapvi.conf     mailcap         overlayroot.conf         rc3.d          signond.conf  udisks2
alternatives            console-setup        emacs          hosts                 ld.so.cache     mailcap.order   pam.conf                 rc4.d          skel          ufw
apache2                 cpu                  environment    hosts.allow           ld.so.conf      manpath.config  pam.d                    rc5.d          sos.conf      updatedb.conf
apg.conf                cracklib             ffserver.conf  hosts.deny            ld.so.conf.d    mdadm           papersize                rc6.d          sound         update-manager
apm                     cron.d               fonts          ImageMagick-6         legal           memcached.conf  passwd                   rc.local       ssh           update-motd.d
apparmor                cron.daily           fstab          init                  libao.conf      mime.types      passwd-                  rcS.d          ssl           update-notifier
apparmor.d              cron.hourly          fuse.conf      init.d                libaudit.conf   mke2fs.conf     perl                     resolvconf     subgid        UPower
apport                  cron.monthly         gai.conf       initramfs-tools       libnl-3         modprobe.d      php                      resolv.conf    subgid-       upstart-xsessions
apt                     crontab              gconf          inputrc               libpaper.d      modules         pki                      rmt            subuid        usb_modeswitch.conf
at.deny                 cron.weekly          gdb            insserv               lightdm         modules-load.d  pm                       rpc            subuid-       vdpau_wrapper.cfg
at-spi2                 crypttab             ghostscript    insserv.conf          lighttpd        mongodb.conf    polkit-1                 rsyslog.conf   subversion    vim
auth-client-config      cupshelpers          gnome          insserv.conf.d        lintianrc       mtab            popularity-contest.conf  rsyslog.d      sudoers       vmware-tools
avahi                   dbus-1               gnome-vfs-2.0  iproute2              locale.alias    mysql           ppp                      samba          sudoers.d     vtrgb
bash.bashrc             dconf                GNUstep        iscsi                 locale.gen      nanorc          profile                  sane.d         supervisor    vulkan
bash_completion         debconf.conf         groff          issue                 localtime       network         profile.d                screenrc       sysctl.conf   wgetrc
bash_completion.d       debian_version       group          issue.net             logcheck        NetworkManager  protocols                securetty      sysctl.d      wpa_supplicant
bind                    default              group-         java-8-openjdk        login.defs      networks        pulse                    security       sysstat       X11
bindresvport.blacklist  deluser.conf         grub.d         kbd                   logrotate.conf  newt            python                   selinux        systemd       xdg
binfmt.d                depmod.d             gshadow        kernel                logrotate.d     nsswitch.conf   python2.7                sensors3.conf  terminfo      xml
bluetooth               dhcp                 gshadow-       kernel-img.conf       lsb-release     nvcc.profile    python3                  sensors.d      texmf         zsh_command_not_found
bonobo-activation       dictionaries-common  gss            ldap                  ltrace.conf     openal          python3.5                services       thermald
byobu                   dkms                 gtk-2.0        ldap-account-manager  lvm             OpenCL          rarfiles.lst             sgml           timezone
ca-certificates         dnsmasq.d            gtk-3.0        ldap.conf             machine-id      openmpi         rc0.d                    shadow         tmpfiles.d
ca-certificates.conf    docker               hdparm.conf    ldapscripts           magic           opt             rc1.d                    shadow-        ucf.conf

可以看到里面都是些系统配置文件,系统配置目录,应用程序配置文件,应用程序配置目录。

/etc/profile

系统全局环境变量设置,里面可以添加对所有用户有效的环境变量,系统配置等。

$ cat profile
# /etc/profile: system-wide .profile file for the Bourne shell (sh(1))
# and Bourne compatible shells (bash(1), ksh(1), ash(1), ...).

if [ "$PS1" ]; then
  if [ "$BASH" ] && [ "$BASH" != "/bin/sh" ]; then
    # The file bash.bashrc already sets the default PS1.
    # PS1='\h:\w\$ '
    if [ -f /etc/bash.bashrc ]; then
      . /etc/bash.bashrc
    fi
  else
    if [ "`id -u`" -eq 0 ]; then
      PS1='# '
    else
      PS1='$ '
    fi
  fi
fi

if [ -d /etc/profile.d ]; then
  for i in /etc/profile.d/*.sh; do
    if [ -r $i ]; then
      . $i
    fi
  done
  unset i
fi

/etc/bash.bashrc

bash的环境变量配置,里面添加启动bash时读取的环境。

$ cat bash.bashrc 
# System-wide .bashrc file for interactive bash(1) shells.

# To enable the settings / commands in this file for login shells as well,
# this file has to be sourced in /etc/profile.

# If not running interactively, don't do anything
[ -z "$PS1" ] && return

# check the window size after each command and, if necessary,
# update the values of LINES and COLUMNS.
shopt -s checkwinsize

# set variable identifying the chroot you work in (used in the prompt below)
if [ -z "${debian_chroot:-}" ] && [ -r /etc/debian_chroot ]; then
    debian_chroot=$(cat /etc/debian_chroot)
fi

# set a fancy prompt (non-color, overwrite the one in /etc/profile)
PS1='${debian_chroot:+($debian_chroot)}\u@\h:\w\$ '

# Commented out, don't overwrite xterm -T "title" -n "icontitle" by default.
# If this is an xterm set the title to user@host:dir
#case "$TERM" in
#xterm*|rxvt*)
#    PROMPT_COMMAND='echo -ne "\033]0;${USER}@${HOSTNAME}: ${PWD}\007"'
#    ;;
#*)
#    ;;
#esac

# enable bash completion in interactive shells
#if ! shopt -oq posix; then
#  if [ -f /usr/share/bash-completion/bash_completion ]; then
#    . /usr/share/bash-completion/bash_completion
#  elif [ -f /etc/bash_completion ]; then
#    . /etc/bash_completion
#  fi
#fi

# sudo hint
if [ ! -e "$HOME/.sudo_as_admin_successful" ] && [ ! -e "$HOME/.hushlogin" ] ; then
    case " $(groups) " in *\ admin\ *|*\ sudo\ *)
    if [ -x /usr/bin/sudo ]; then
        cat <<-EOF
        To run a command as administrator (user "root"), use "sudo ".
        See "man sudo_root" for details.

        EOF
    fi
    esac
fi

# if the command-not-found package is installed, use it
if [ -x /usr/lib/command-not-found -o -x /usr/share/command-not-found/command-not-found ]; then
        function command_not_found_handle {
                # check because c-n-f could've been removed in the meantime
                if [ -x /usr/lib/command-not-found ]; then
                   /usr/lib/command-not-found -- "$1"
                   return $?
                elif [ -x /usr/share/command-not-found/command-not-found ]; then
                   /usr/share/command-not-found/command-not-found -- "$1"
                   return $?
                else
                   printf "%s: command not found\n" "$1" >&2
                   return 127
                fi
        }
fi


/etc/hosts

主机域名的配置。

$ cat hosts
127.0.0.1       localhost
127.0.1.1       ubuntu

# The following lines are desirable for IPv6 capable hosts
::1     localhost ip6-localhost ip6-loopback
ff02::1 ip6-allnodes
ff02::2 ip6-allrouters

192.168.2.22  Master
192.168.2.23  Backup
192.168.2.61  vedio1
192.168.2.62  vedio2
/etc/ld.so.cof

ldconfig命令读取的系统库目录配置文件。

$ cat  ld.so.conf
include /etc/ld.so.conf.d/*.conf
/usr/local/cuda-8.0/lib64
/usr/local/samba/lib


/etc/ld.so.cache

ldconfig命令读取的系统库路径生成的缓存文件。

/etc/timezone

系统的时间时区设置。

/etc/adduser.conf

添加的用户信息。

/etc/deluser.conf

删除用户信息。

/etc/group

用户组信息。

/etc/crontab

系统定时任务信息。

/etc/passwd

用户密码信息。

/etc/sudoers

具有sodu执行权限的用户信息。

/etc/protocols

系统支持的ip协议簇。

/etc/sysctl.conf

系统内核的配置文件。

$ cat sysctl.conf
#
# /etc/sysctl.conf - Configuration file for setting system variables
# See /etc/sysctl.d/ for additional system variables.
# See sysctl.conf (5) for information.
#

#kernel.domainname = example.com

# Uncomment the following to stop low-level messages on console
#kernel.printk = 3 4 1 3

##############################################################3
# Functions previously found in netbase
#

# Uncomment the next two lines to enable Spoof protection (reverse-path filter)
# Turn on Source Address Verification in all interfaces to
# prevent some spoofing attacks
#net.ipv4.conf.default.rp_filter=1
#net.ipv4.conf.all.rp_filter=1

# Uncomment the next line to enable TCP/IP SYN cookies
# See http://lwn.net/Articles/277146/
# Note: This may impact IPv6 TCP sessions too
#net.ipv4.tcp_syncookies=1

# Uncomment the next line to enable packet forwarding for IPv4
#net.ipv4.ip_forward=1

# Uncomment the next line to enable packet forwarding for IPv6
#  Enabling this option disables Stateless Address Autoconfiguration
#  based on Router Advertisements for this host
#net.ipv6.conf.all.forwarding=1


###################################################################
# Additional settings - these settings can improve the network
# security of the host and prevent against some network attacks
# including spoofing attacks and man in the middle attacks through
# redirection. Some network environments, however, require that these
# settings are disabled so review and enable them as needed.
#
# Do not accept ICMP redirects (prevent MITM attacks)
#net.ipv4.conf.all.accept_redirects = 0
#net.ipv6.conf.all.accept_redirects = 0
# _or_
# Accept ICMP redirects only for gateways listed in our default
# gateway list (enabled by default)
# net.ipv4.conf.all.secure_redirects = 1
#
# Do not send ICMP redirects (we are not a router)
#net.ipv4.conf.all.send_redirects = 0
#
# Do not accept IP source route packets (we are not a router)
#net.ipv4.conf.all.accept_source_route = 0
#net.ipv6.conf.all.accept_source_route = 0
#
# Log Martian Packets
#net.ipv4.conf.all.log_martians = 1
#

参考链接: http://blog.csdn.net/rig622/article/details/7591419

你可能感兴趣的:(linux文件目录分析之/etc目录)