linux search and compression

Linux storage management (part 2)

linux search and compression

File search

Command search
  • which
which 命令

Can find known commands

which ls
  • Custom command
alias ui='ls --color=auto -l'

At this time, pressing ui on the command line is equivalent to ls

ui
  • whereis
    find the absolute path of the command
whereis vim
Search for file name
find 路径 选项 描述 动作
  • Search by file name
find /etc -name '6789.txt'
find /etc -iname '6789.txt'
find /etc -iname hos*
  • Find according to file size
find /etc/ -size +5M

Find files larger than 5M under /etc/

find /etc/ -szie -5M

Find files smaller than 5M

  • Specify the depth of the searched directory
find / -maxdepth 3 -a -name 'idcfg-en*'
  • By file owner
find /home -user jack
  • Search by file group
find /home -group jack
  • Find by file type
    f means normal file
find /dev/ -type f

b stands for block device file

find /dev/ -type b

l stands for linked file

find /etc -type l
  • Search by file permissions
find . -perm 644
find . -perm 644 -ls

ls is the action of find.

find . -perm 644 -print

find comes with print action

  • Press to find the post-processing action
find . -perm 714 -delete

Delete after finding out

find /etc/ -name
find /etc/ -name ifcfg* -ok cp -rvf {
    
    } /tmp \;

ok represents a kind of connector, {} represents the content found by find, which represents a kind of reference.

Depend on database to find files
locate 命令
locate ls

This command can find a lot of data

File packaging and compression

Packaging and compression

File packaging and compression commands:

tar 选项 压缩包名称 源文件
tar -f 111.tar etc

Package file

tar -cf etc.tar  etc

Pack files and compress

tar -czf etc-gzip.tar.gz etc

The compressed file is found to be smaller.
The principle of compression is the deduplication method. The advantage is that the file size is reduced, but the disadvantage is that it cannot be used directly and needs to be decompressed.

tar -cjf etc.tar.bz /etc/
tar -cJf etc.tar.xz /etc/

The size of the compressed file will be smaller, but the time will be longer.

Unzip and unpack
tar -xf 1.tar

Such a compressed package is unzipped and unzipped to the current path

tar -tf etc.tar

Check which files and folders are in the compressed package.
linux software installation

Guess you like

Origin blog.csdn.net/qq_45671732/article/details/109755963