content

 

file location collection

1. Directory collection

bin Commands used by ordinary users /bin/ls, /bin/date 
sbin Commands used by administrators /sbin/service
dev Device files /dev/sda, /dev/sda1
root The HOME
home of the root user stores the ordinary user's home directory
lost+ found when fsck is repaired, stores unlinked files or directories
proc virtual file system, which reflects the kernel, process information or real-time state
​usr
system files, equivalent to C:\Windows
/usr/local Software installation directory, quite System boot related files stored in C:\Program
​boot
, such as kernel, grub (boot loader)
etc. Configuration files (system related such as network /etc/sysconfig/network
​lib
library file Glibc
lib64 library file Glibc
​tmp
temporary Files (globally writable: temporary files generated by the process)
var stores some changed files, such as databases, logs, emails....
​==
Device (mainly refers to storage devices) mount directory ==
media Default for mobile devices Mount point
mnt Mount point for manually mounting the device

 

2. Other

/bin/date/etc/hosts/etc/sysconfig/network/etc/sysconfig/network-scripts/ifcfg-eth0//网卡文件

 

  • /etc/passwd//User basic information file


account:password:UID:GID:GECOS:directory:shell
(account:password:userid:groupid:general information:directory:shell)
  • /etc/shadow //User password information file


root:$1$MYG2NDG6$a1wtyr5GDM2esAPjug0YP0:15636:0:99999:7:: :
-------------------------
1) "login name" It is the user account that is consistent with the login name in the /etc/passwd file.
2) The "password" field stores the encrypted user password. If it is empty, the corresponding user does not have a password, and no password is required when logging in;  
asterisk Indicates that the account is locked;
double exclamation marks indicate that the password has expired.
$6$ indicates that it is encrypted with SHA-512,
$1$ indicates that it is encrypted with MD5,
$2$ is encrypted with Blowfish, and
$5$ is encrypted with SHA-256.
​3
) "Last modification time" indicates the number of days from a certain moment to when the user last modified the password. The starting point of time may be different for different systems. For example, in SCOLinux, this time starting point is January 1, 1970.
4) "Minimum time interval" refers to the minimum number of days required between two password changes. The password cannot be changed within 3 days.
5) "Maximum time interval" refers to the maximum number of days the password will remain valid. The lifecycle to time must be modified.
6) The "Warning Time" field indicates the number of days between when the system starts to warn the user until the user's password is officially expired. Reminder to change the password time.
7) "Inactivity time" means the maximum number of days that the user has no login activity but the account can still be valid. (Soft limit. How many days after expiration the account can not be used.)
8) The "expiration time" field gives an absolute number of days. If this field is used, the lifetime of the corresponding account is given. After the expiration, the account is no longer a legitimate account, and can no longer be used to log in. (Hard limit.)
9) Reserved
  • /etc/group//User group information file


PASSWD(5) File formats PASSWD(5)
​NAME
name
      passwd - password file ​Description
      Passwd is a text file, it contains a list of system accounts,       giving some useful information for each account, such as user ID, group ID, home directory, shell, etc.       Usually it also contains the encrypted password of each user.       It should usually be readable (many commands, utilities, like ls(1) use it for userid       -to-username mapping), But only superusers are allowed write access. ​In       the good old days, this general read permission was no big deal.       Everyone could read an encrypted password because the hardware was too slow to unlock one       Chosen ciphers, additionally, this is basically assumed to be used by friendly user groups.       Now, many people run versions of shadow cipher suites that       are * in the password field of /etc/passwd instead of encrypted Passwords, encrypted passwords are placed in /etc/shadow       , that file can only be read by superusers. ​Regardless of       whether shadow passwords are used, many system administrators use an asterisk in encrypted password fields















      to ensure that the user cannot authenticate his or her own password. (see note below)
​If
      you create a new login, first put an asterisk in the password field, then use
      passwd(1) to set it.
​(
      password file), one record per line, and each line has the following format:
​account
            :password:UID:GID:GECOS:directory:shell
            (account:password:user ID:group ID:general information:directory:shell
)
  • /etc/sudoers wheel提权


[root@tianyun ~]# vim /etc/sudoers
%wheel ALL=(ALL) NOPASSWD: ALL
allows users in the wheel group to use all commands without entering the user's password
  • The /etc/default/useradd file is a user rule file added for settings


[root@tianyun ~]# vim /etc/default/useradd//Can the default settings for user creation be changed? (For example, SHELL is forbidden to log in
SHELL=/sbin/nologin and
try to create a new user.
  • /etc/login.defs


The file man login.defs
​/etc/login.defs
defines the user restriction settings that go with /etc/password and /etc/shadow. This file is required, and its absence will not affect the use of the system, but may produce unexpected errors.
​If
there are the same options in the /etc/shadow file, the settings in /etc/shadow shall prevail, that is to say, the configuration priority of /etc/shadow is higher than that of /etc/login.defs.
​#
*REQUIRED* required
# Directory where mailboxes reside, _or_ name of file, relative to the
# home directory. If you _do_ define both, MAIL_DIR takes precedence.
# QMAIL_DIR is for Qmail
#
#QMAIL_DIR Maildir
MAIL_DIR /var/spool/mail #When
creating a user, create a user mail file in the directory /var/spool/mail #
MAIL_FILE .mail
​#
Password aging controls:
#
# PASS_MAX_DAYS Maximum number of days a password may be used.
# PASS_MIN_DAYS Minimum number of days allowed between password changes.
# PASS_MIN_LEN Minimum acceptable password length.
# PASS_WARN_AGE Number of days warning given before a password expires.
#
PASS_MAX_DAYS 99999 #Password
maximum validity period
PASS_MIN_DAYS 0 #Minimum
interval between two password changes
PASS_MIN_LEN 5 #Minimum
length of password, invalid for root
PASS_WARN_AGE 7 #How
many days before the password expires
#
# Min/max values ​​for automatic uid selection in useradd #The
range of automatic UID if no UID is specified when creating a user
UID_MIN 500 #Minimum
value of user ID
UID_MAX 60000 #Maximum
value of user ID
#
# Min/max values ​​for automatic gid selection in groupadd #The
range of automatic group ID
GID_MIN 500 #Minimum
value of group ID
GID_MAX 60000 #Maximum value
of group ID ​#
# If defined, this command is run when removing a user. # It should remove any at/cron/print jobs etc. owned by # the user to be removed (passed as the first argument). # #USERDEL_CMD /usr/sbin/userdel_local #Script to be executed when a user is deleted ​# # If useradd should create home directories for users by default # On RH systems, we do. This option is overridden with the -m flag on # useradd command line. # CREATE_HOME yes #When using useradd, it is enough to create a user directory ​# The permission mask is initialized to this value. If not specified,

















# the permission mask will be initialized to 022.
UMASK           077
# This enables userdel to remove user groups if no members exist.
#
USERGROUPS_ENAB yes
#用MD5加密密码
  • vim /etc/profile


Example 3: Modify the shell umask value (permanently not recommended)
[root@tianyun ~]# vim /etc/profile  
if [ $UID -gt 199 ] && [ "`id -gn`" = "`id -un`" ] ; then
  umask 002
else
  umask 022
fi
[root@tianyun ~]# source /etc/profile //It takes effect immediately in the current shell
  • vim /etc/login.defs


Example 4: Determine the permissions of the new user's HOME directory through umask
[root@tianyun ~]# vim /etc/login.defs
UMASK 077
[root@tianyun ~]# useradd gougou
[root@tianyun ~]# ll -d /home/ gougou/
drwx------. 4 gougou gougou 4096 March 11 19:50 /home/gougou/
​[
root@tianyun ~]# vim /etc/login.defs
UMASK 000
[root@tianyun ~]# useradd yangyang
[root@tianyun ~]# ll -d /home/yangyang/
drwxrwxrwx. 4 yangyang yangyang 4096 March 11 19:53 /home/yangyang/
  • /etc/vsftpd/vsftpd.conf


Example 5: For example, the vsftpd process /etc/vsftpd/vsftpd.conf [Know]
[root@tianyun ~]# yum -y install vsftpd
[root@tianyun ~]# man vsftpd.conf
anon_umask
local_umask
  • CPU


/proc/cpuinfo
[root@tianyun ~]# grep 'processor' /proc/cpuinfo //Number of logical CPUs
processor : 0
processor : 1
[root@tianyun ~]# grep 'physical id' /proc/cpuinfo // Number of physical CPUs
physical id : 0
physical id : 0
==flags
lm (64 bits) ----------------------------- ----
vmx supports virtualized Intel----------------------
svm supports virtualized AMD------------- ----------- ​​[ root@tianyun ~]# egrep 'lm|vmx|svm' /proc/cpuinfo flags : fpu vme de clflush dts acpi lm constant_tsc pni monitor ds_cpl vmx est tm2 ssse3 cx16 xtpr lahf_lm flags : fpu vme de clflush dts acpi lm constant_tsc pni monitor ds_cpl vmx est tm2 ssse3 cx16 xtpr lahf_lm ​[ root@tianyun ~]# lscpu







Architecture: x86_64
CPU op-mode(s): 32-bit, 64-bit
CPU(s): 4
On-line CPU(s) list: 0-3
Thread(s) per core: 2
Core(s) per socket: 2
Socket(s): 1
Virtualization: VT-x
L1d cache: 32K
L1i cache: 32K
L2 cache: 256K
L3 cache: 3072K
NUMA node0 CPU(s): 0-3
  • RAM


/proc/meminfo
[root@tianyun ~]# less /proc/meminfo
[root@tianyun ~]# free -m
total used free shared buff/cache available
Mem: 7950 704 6540 100 705 6908
Swap: 2047 0 2047
  • kernel


/proc/cmdline //Kernel boot parameters
[root@tianyun ~]# cat /proc/cmdline
BOOT_IMAGE=/vmlinuz-3.10.0-327.el7.x86_64 root=UUID=9b17ab4e-cd93-4f84-bd1e-7241a0baac9b ro rhgb quiet LANG=zh_CN.UTF-8
  • usage


uptime
[root@tianyun ~]# uptime
17:20:58 up 8:33, 3 users, load average: 0.43, 0.36, 0.36
  • The internet


[root@tianyun ~]# cat /proc/sys/net/ipv4/ip_forward
1
[root@tianyun ~]# echo 0 > /proc/sys/net/ipv4/ip_forward
[root@tianyun ~]# cat /proc/sys/net/ipv4/ip_forward
  • Automatically mount the disk (permanently valid)


Step 1: View the ID of the partition
# blkid
Step 2: Use UUID to automatically mount the partition
# vim /etc/fstab
UUID="9bf6b9f7-92ad-441b-848e-0257cbb883d1" /mnt/disk1 auto defaults 0 0
UUID= "4d26172c-7aff-4388-baa5-c6756c014d52" /mnt/disk2 ext4 defaults 0 0
Partition information Mount point (folder) File system type Properties (default) Compression detection
Step 3: Manual refresh
# mount -a
  • Automatically mount the file vim /etc/fstab


vim /etc/fstab
/dev/vg1/lv1 /mysql_data ext4 defaults 0 0
mount -a refresh the configuration file
  • redirect to empty device /dev/null


[root@tianyun ~]# ls /home/ /aaaaaaaaa >list.txt 2>/dev/null //Empty device, the output will be discarded

 

 

Case 7: Using redirects in scripts


[root@tianyun ~]# vim ping.sh
ping -c1 172.16.120.254 &>/dev/null
if [ $? -eq 0 ];then
echo "up.."
else
echo "down.."
fi
[root@tianyun ~]# bash ping.sh

Case 8: Redirection used in script
# vim ping2.sh
ping -c1 172.16.120.254 &>/dev/null
if [ $? -eq 0 ];then
echo "172.16.120.254 up.." >> /up.txt
else
echo "172.16.120.254 down.." >> /down.txt
fi
# bash ping2.sh
  • user bashrc file \ -bash-4.2#


cp /etc/skel/.bashrc /root/
cp /etc/skel/.bash_profile /root/
  • terminal /dev/pts/2 /dev/tty1

 

 

/etc/grub2.cfg /etc/resolv.conf /etc/profile //Set system environment variables /etc/bashrc //Affect bash shell environment /var/log/messages //System main log file /var/log/secure //Security-related logs such as ssh login, local login...

 

 

Guess you like

Origin http://43.154.161.224:23101/article/api/json?id=325374784&siteId=291194637