Linux learning notes - supplemental

1.find command

Command format:

find directory condition value

1.find -name

find /etc/ -name passwd   ##Find the file named passwd under / etc

2.find -user -group -a -o -not

find /mnt -group root
find /mnt -user westos
find /mnt -group root -user student  ##and
find /mnt -group root -a -user student   ##Both conditions are satisfied
find /mnt -group root -o -user student   ##Two conditions meet at least one

3.find -perm

find /mnt -perm 444    ##u=4 g=4 o=4
find /mnt -perm -444   ##u contains 4 and g contains 4 and o contains 4
find /mnt -perm -644   ##u contains 4 + 2 and g contains 4 and o contains 4
find /mnt -perm /444   ##u contains 4 or g contains 4 or o contains 4
find /mnt -perm -002   ##o contains 2 only others can write

4.find -size

find /mnt -size 20k       ##File size equals 20k
find /mnt -size -20k      ##File size less than 20k
find /mnt -size +20k      ##File size greater than 20k

5.find -type -maxdepth -mindepth

find /var -type s         ##socket 
find /dev -type d         ##Catalog
find /dev -type f         ##file
find /dev -type c         ##Character device
find /dev -type b         ##Block device
find /dev -type p         ##Piping equipment
find /etc -maxdepth 2 -mindepth 2 -type f   ##Find/etc2-level file
find /etc -maxdepth 2 -type l               ##Find/etcLinks with a maximum down depth of 2 (depth ≤ 2)
find /etc -mindepth 1 -type l               ##Find/etcLinks with a depth of at least 1 (depth greater than or equal to 1)

6.find -exec \

find /etc -type f -exec cp {} /mnt \;       ##Find the file under / etc to fully backup to / mnt

Thinking question: find all files belonging to mail group in the system and back them up to / mnt

find / -group mail -exec cp {} -rp /mnt \; &> /dev/null      ##

2. Soft link / hard link

Soft link
You can copy node numbers across partitions. Multiple node numbers correspond to one file to save disk space. Example: Shortcut
Hard link
You cannot copy data across partitions. One node number corresponds to multiple files. For example, backup

[root@localhost mnt]# ll
total 0
-rw-r--r--. 1 root root 0 Jan 28 22:52 file1
-rw-r--r--. 1 root root 0 Jan 28 22:50 file2
[root@localhost mnt]# ls -li *                       ##i-inode node number
8846759 -rw-r--r--. 1 root root 0 Jan 28 22:52 file1
8846760 -rw-r--r--. 1 root root 0 Jan 28 22:50 file2
[root@localhost mnt]# ln -s /mnt/file1 /mnt/westos   ##Number of soft link-s files is 1
[root@localhost mnt]# ls -li *
8846759 -rw-r--r--. 1 root root  0 Jan 28 22:52 file1
8846760 -rw-r--r--. 1 root root  0 Jan 28 22:50 file2
8846761 lrwxrwxrwx. 1 root root 10 Jan 28 22:52 westos -> /mnt/file1
[root@localhost mnt]# rm -fr file1                   ##Delete file1
[root@localhost mnt]# ls -li *
8846760 -rw-r--r--. 1 root root  0 Jan 28 22:50 file2
8846761 lrwxrwxrwx. 1 root root 10 Jan 28 22:52 westos -> /mnt/file1    ##westos exists, but there is no content
[root@localhost mnt]# rm -fr westos
[root@localhost mnt]# ls -li *
8846760 -rw-r--r--. 1 root root 0 Jan 28 22:50 file2
[root@localhost mnt]# ln /mnt/file2 /mnt/westos      ##Hard link does not have the same - s node number
[root@localhost mnt]# ls -li *
8846760 -rw-r--r--. 2 root root 0 Jan 28 22:50 file2    ##Number of files is 2
8846760 -rw-r--r--. 2 root root 0 Jan 28 22:50 westos

3.dhcp service

Client (Server):

[root@localhost ~]# yum install dhcp -y                      ##Install dhcp service
[root@localhost ~]# vim /etc/dhcp/dhcpd.conf                 ##configuration file
[root@localhost ~]# cp /usr/share/doc/dhcp*/dhcpd.conf.example /etc/dhcp/dhcpd.conf       ##Copy the given example to the profile according to the profile prompt
cp: overwrite '/etc/dhcp/dhcpd.conf'? y
[root@localhost ~]# vim /etc/dhcp/dhcpd.conf                 ##Edit profile

 7 option domain-name "westos.org";                          ##domain name
 8 option domain-name-servers 172.25.254.250;                ##Server ip
 27.28Line delete
 30 subnet 172.25.254.0 netmask 255.255.255.0 {
 31   range 172.25.254.205 172.25.254.210;                    ##dhcp distribution network segment range
 32   option routers 172.25.254.250;                          ##Server ip
 33 }
 35Delete after line

[root@localhost ~]# systemctl restart dhcpd                  ##Restart service

testing:
Desktop virtual machine:

systemctl restart network                     ##service network restart 
ifconfig                                      ##Check whether ip is in the range of server and MAC address

Server virtual machine:

less /var/lib/dhcpd/dhcpd.leases   ##Check whether MAC address allocation is consistent with desktop

MAC address assignment:

Keywords: network Mac less vim

Added by GaryC on Fri, 01 May 2020 11:04:56 +0300