Topics and Analysis of Linux Operating System (2)

1. View the file content

1. View line 6 of the /etc/passwd file

insert image description here

2. View the line starting with SELINUX in /etc/selinux/config (use group to operate)

insert image description here

3. Find the line ending with no in /etc/ssh/sshd_config

insert image description here

4. Filter /etc/ssh/sshd_config lines containing numbers (use "group [0,9]" to find numbers from 0 to 9)

insert image description here

2. Text processing commands

1. View the contents of the first column of the /etc/passwd file with: as the separator, and sort them in reverse alphabetical order

"cut" delimiter, "-d:" defines delimiter, here is ":", "-f1" which field needs to be taken, here is "first line". "sort -r" sorts in reverse.
insert image description here

2. Use the cut command to cut and display the ip address of the current host

insert image description here

3. Copy and move

(1) Create a subdirectory dir in the /test directory, copy /etc/passwd to this directory
(2) Copy the /etc/ssh/sshd_config file to the /test directory
(3) Copy /etc/yum.repos. Copy the d/ directory to the /test directory
(4) Copy the /etc/hosts file to the /test directory
(5) Copy the /etc/hostname file to the /test directory
(6) Move the /test/sshd_config file to /test/ dir directory and renamed to sshd.conf
insert image description here

4. File search

1. In the $HOME directory and its subdirectories, find the files that were changed 2 days ago

Through the "find" method, "-mtime" indicates the time when the content was modified, and "-2" indicates the file name within 2 days.
insert image description here

2. Look for files starting with host in the /etc/ directory

insert image description here

3. Find the directory file under /test/

insert image description here

4. In the /test directory and subdirectories, look for files over 2KB

insert image description here

Five, package compression

1. Compress all files and folders in the /test directory into a myfile.zip file

insert image description here
insert image description here

2. Unzip the myfile.zip file to /opt

insert image description here

3. Pack all the files in the /opt directory and compress them into /test/newfile.tar.gz with gzip

insert image description here

4. Check which files are in the /test/newfile.tar.gz file?

insert image description here

5. In the /test directory, back up all files under /etc and retain their permissions

insert image description here

Guess you like

Origin blog.csdn.net/Zombie_QP/article/details/127490436