tar command, grep command, find command

tar command

First, use the tar command to pack and compress the / etc directory in gzip format, and name the file etc.tar.gz:

[root@localhost ~]# tar -czvf etc.tar.gz /etc

Next, unzip the packed package file to the / root/etc directory (first use the mkdir command to create the / root/etc directory):

[root@localhost ~]# tar -xzvf etc.tar.gz -C /root/etc

grep command

-The n parameter is used to display the line number of the searched information; the - v parameter is used to deselect the information (that is, all information lines without keywords). These two parameters can almost complete 80% of your work needs in the future. As for the other hundreds of parameters, even if they are encountered in the future during the work, it is also convenient to use the man grep command to query.

In Linux system, the / etc/passwd file holds all the user information, and once the user's login terminal is
If it is set to / sbin/nologin, you are no longer allowed to log in to the system. Therefore, you can use the grep command to find out whether the current system is not allowed
All user information allowed to log in to the system:

[root@localhost ~]# grep /sbin/nologin /etc/passwd
bin:x:1:1:bin:/bin:/sbin/nologin
daemon:x:2:2:daemon:/sbin:/sbin/nologin
adm:x:3:4:adm:/var/adm:/sbin/nologin
lp:x:4:7:lp:/var/spool/lpd:/sbin/nologin
mail:x:8:12:mail:/var/spool/mail:/sbin/nologin
operator:x:11:0:operator:/root:/sbin/nologin
games:x:12:100:games:/usr/games:/sbin/nologin
ftp:x:14:50:FTP User:/var/ftp:/sbin/nologin
nobody:x:99:99:Nobody:/:/sbin/nologin
pegasus:x:66:65:tog-pegasus OpenPegasus WBEM/CIM services:/var/lib/Pegasus:/sbin/nologin
systemd-bus-proxy:x:999:997:systemd Bus Proxy:/:/sbin/nologin
systemd-network:x:192:192:systemd Network Management:/:/sbin/nologin
dbus:x:81:81:System message bus:/:/sbin/nologin
polkitd:x:998:996:User for polkitd:/:/sbin/nologin
apache:x:48:48:Apache:/usr/share/httpd:/sbin/nologin
tss:x:59:59:Account used by the trousers package to sandbox the tcsd daemon:/dev/null:/sbin/nologin
.........................Omit part of output process information........................

 

find command

Get the list of all files starting with host in the directory, and execute the following command:

[root@localhost ~]# find /etc -name "host*" -print
/etc/host.conf
/etc/hosts
/etc/hosts.allow
/etc/hosts.deny
/etc/selinux/targeted/active/modules/100/hostname
/etc/avahi/hosts
/etc/hostname

If you want to search the entire system for all files with the SUID permission included in the permission, just use - 4000:

[root@localhost ~]# find / -perm -4000 -print

Find all files belonging to jlinc users in the whole file system and copy them to the / root/findresults directory.

[root@localhost findresults]# find / -user jlinc -exec cp -a {} /root/findresults/ \;

"- exec {} \;" parameter, where {} represents each file searched by the find command, and the end of the command must be "\;". ".

Tags: ftp network Apache Linux

Posted on Sun, 05 Jan 2020 17:10:39 -0800 by jimiwa