当前位置: 首页 > news >正文

Linux 基础(六)常用命令 - find locate which whereis gzip gunzip tar

find & locate & which & whereis & gzip & gunzip & tar

    • find
    • locate
    • which
    • whereis
    • gzip
    • gunzip
    • zip/unzip
    • tar

find

在指定目录下查找文件或目录

find --help
Usage: find [-H] [-L] [-P] [-Olevel] [-D help|tree|search|stat|rates|opt|exec] [path...] [expression]default path is the current directory; default expression is -print
expression may consist of: operators, options, tests, and actions:operators (decreasing precedence; -and is implicit where no others are given):( EXPR )   ! EXPR   -not EXPR   EXPR1 -a EXPR2   EXPR1 -and EXPR2EXPR1 -o EXPR2   EXPR1 -or EXPR2   EXPR1 , EXPR2positional options (always true): -daystart -follow -regextypenormal options (always true, specified before other expressions):-depth --help -maxdepth LEVELS -mindepth LEVELS -mount -noleaf--version -xautofs -xdev -ignore_readdir_race -noignore_readdir_racetests (N can be +N or -N or N): -amin N -anewer FILE -atime N -cmin N-cnewer FILE -ctime N -empty -false -fstype TYPE -gid N -group NAME-ilname PATTERN -iname PATTERN -inum N -iwholename PATTERN -iregex PATTERN-links N -lname PATTERN -mmin N -mtime N -name PATTERN -newer FILE-nouser -nogroup -path PATTERN -perm [-/]MODE -regex PATTERN-readable -writable -executable-wholename PATTERN -size N[bcwkMG] -true -type [bcdpflsD] -uid N-used N -user NAME -xtype [bcdpfls]-context CONTEXTactions: -delete -print0 -printf FORMAT -fprintf FILE FORMAT -print-fprint0 FILE -fprint FILE -ls -fls FILE -prune -quit-exec COMMAND ; -exec COMMAND {} + -ok COMMAND ;-execdir COMMAND ; -execdir COMMAND {} + -okdir COMMAND ;

find 目录(不指定目录,则以当前目录查找) 查找参数
最常用的查找参数是 tests 项下的

 -name-user-group
  • 如在当前目录下查找 abc.txt
find -name abc.txt
  • 通配符查询,在opt下模糊查找 tes*.txt
find /opt -name tes*.txt

locate

通过本地数据库并非实时搜索文件,定位文件,Linux系统会为每个文件建立路径对应的本地数据库。
只要完整路径中包含 关键字的都会找出来

基本语法

locate 文件(夹)

其相关文档

[root@test-centos ~]# locate --help
Usage: locate [OPTION]... [PATTERN]...
Search for entries in a mlocate database.-A, --all              only print entries that match all patterns-b, --basename         match only the base name of path names-c, --count            only print number of found entries-d, --database DBPATH  use DBPATH instead of default database (which is/var/lib/mlocate/mlocate.db)-e, --existing         only print entries for currently existing files-L, --follow           follow trailing symbolic links when checking fileexistence (default)-h, --help             print this help-i, --ignore-case      ignore case distinctions when matching patterns-l, --limit, -n LIMIT  limit output (or counting) to LIMIT entries-m, --mmap             ignored, for backward compatibility-P, --nofollow, -H     don't follow trailing symbolic links when checking fileexistence-0, --null             separate entries with NUL on output-S, --statistics       don't search for entries, print statistics about eachused database-q, --quiet            report no error messages about reading databases-r, --regexp REGEXP    search for basic regexp REGEXP instead of patterns--regex            patterns are extended regexps-s, --stdio            ignored, for backward compatibility-V, --version          print version information-w, --wholename        match whole path name (default)

但是这个数据库并不是实时更新的,可能最近添加的文件并未收录进去,也可能已经删除的文件没来得及移除;
默认是一周更新次,如果要修改这个频率,编辑 /etc/updatedb.conf,输入以下内容

DB_UPDATE_PERIOD="daily"

可选项为:

  • daily:每天更新一次
  • weekly:每周更新一次(默认值)
  • monthly:每月更新一次
  • never:禁止自动更新,需要手动运行updatedb命令来更新

若要立即同步,也可以手动执行命令 sudo updatedb

which

查找可执行文件。

基本语法

which 可执行文件名
which java

whereis

查找执行文件或命令相关的文件,其查询目录通常在系统标准目录
/usr
/etc
等等

基本语法

whereis 可执行文件名
whereis java

gzip

压缩或解压缩文件(默认,为压缩文件),不保留源文件,压缩多个文件时分别压缩成单个压缩文件

  • -d 参数 为解压

压缩

gzip filename

保留源文件压缩

gzip filname -c > 自定义压缩文件名

解压

gzip -d filename.gz

保留源文件解压

gzip -d filename.gz -c > 自定义文件名

gunzip

直接对gzip生成的压缩文件进行解压

解压

gunzip filename.gz

zip/unzip

同样是压缩,解压工具
但是zip可以压缩目录 -r,并且默认保留源文件,压缩多个文件默认生成到一个压缩文件

基本语法

  • 压缩文件 (-r 压缩文件夹)
zip [opts] 压缩文件名 源文件1 源文件2 ....
  • 解压 (-d 指定解压到哪个目录)
unzip [opts] 压缩文件名

tar

常用于打包,归档操作。同时可以通过 参数-z 结合 gzip 使用

基本语法

tar [opts] xx.tar.gz(如果不压缩,就tar) 要打包的文件/目录1 要打包的文件/目录2 ...

tar 命令是通过 参数来决定是打包还是解压的操作,常用参数如下

命令功能
-c打包成 tar文件
-f指定(压缩后/要解压)的文件名
-z进行 gzip 压缩或解压
-x解压 tar 文件,不包含解压 .gz
-C自定义解压到哪个目录,默认解压到当前目录下压缩文件名的目录
-v展示执行过程

还有很多参数,具体可以参考帮助文档;以下展示部分参数

tar --help[root@test-centos test]# tar --help
Usage: tar [OPTION...] [FILE]...
GNU `tar' saves many files together into a single tape or disk archive, and can
restore individual files from the archive.Examples:tar -cf archive.tar foo bar  # Create archive.tar from files foo and bar.tar -tvf archive.tar         # List all files in archive.tar verbosely.tar -xf archive.tar          # Extract all files from archive.tar.Main operation mode:-A, --catenate, --concatenate   append tar files to an archive-c, --create               create a new archive-d, --diff, --compare      find differences between archive and file system--delete               delete from the archive (not on mag tapes!)-r, --append               append files to the end of an archive-t, --list                 list the contents of an archive--test-label           test the archive volume label and exit-u, --update               only append files newer than copy in archive-x, --extract, --get       extract files from an archive

相关文章:

Linux 基础(六)常用命令 - find locate which whereis gzip gunzip tar

find & locate & which & whereis & gzip & gunzip & tar findlocatewhichwhereisgzipgunzipzip/unziptar find 在指定目录下查找文件或目录 find --help Usage: find [-H] [-L] [-P] [-Olevel] [-D help|tree|search|stat|rates|opt|exec] [path...…...

【Ajax】回调地狱解决方法

回调地狱(Callback Hell)是指在异步编程中,特别是在嵌套的回调函数中,代码变得深度嵌套、难以阅读和维护的现象。这通常发生在处理多个异步操作时,每个操作都依赖于前一个操作的结果。回调地狱使代码变得难以理解、扩展…...

解决Vue根组件设置transition失效的问题

解决Vue根组件设置transition失效的问题 1.代码 <div id"app"><!-- :name"$route.meta.transitionName" --><transition :name"animation" mode"out-in"><router-view /></transition></div>&…...

【剑指 Offer 40】最小的k个数

题目&#xff1a; 输入整数数组 arr &#xff0c;找出其中最小的 k 个数。例如&#xff0c;输入 4、5、1、6、2、7、3、8 这 8 个数字&#xff0c;则最小的 4 个数字是 1、2、3、4。 示例&#xff1a; 输入&#xff1a;arr [3,2,1], k 2 输出&#xff1a;[1,2] 或者 [2,1] …...

vue3+vite在main.ts文件中引入./App.vue报错(./App.vue不是模块)

问题 如下图&#xff1a; 方法一 下载TypeScript Vue Plugin (Volar)插件就不报红了&#xff0c;看它的描述应该就是ts文件可以识别vue文件。 方法二 在src文件夹下添加env.d.ts文件&#xff0c;添加以下代码&#xff1a; declare module *.vue {import type { DefineC…...

【LeetCode】102. 二叉树的层序遍历、107. 二叉树的层序遍历 II

作者&#xff1a;小卢 专栏&#xff1a;《Leetcode》 喜欢的话&#xff1a;世间因为少年的挺身而出&#xff0c;而更加瑰丽。 ——《人民日报》 102. 二叉树的层序遍历 102. 二叉树的层序遍历 给你二叉树的根节点 root &#xff0c;返回其节…...

HTML详解连载(2)

HTML详解连载&#xff08;2&#xff09; 专栏链接 [link](http://t.csdn.cn/xF0H3)下面进行专栏介绍 开始喽超链接作用代码示例解释经验分享 音频标签代码示例注意强调 视频标签代码示例注意强调 列表作用&#xff1a;布局内容排列整齐的区域。分类&#xff1a;无序列表&#x…...

qt事件系统源码-----定时器

qt定时器的使用一般有以下几种方式&#xff1a; 1、直接使用QTimer对象&#xff0c;绑定定时器的timeout信号&#xff1b; 2、使用QTimer的静态方法singleshot方法&#xff0c;产生一个一次性的定时事件 3、在QObject子类中&#xff0c;调用startTimer方法&#xff0c;产生定…...

【Android】ViewBinding+DataBinding+MVVM新手快速上手

为什么写这篇博客 网上大部分博客&#xff0c;代码量都比较大&#xff0c;把实际的业务都代入进去了 这篇博客的目的&#xff0c;就是为了讲解基本原理和使用思路&#xff0c;然后给出一个最简单的Demo 这里不讲解具体用法&#xff0c;那样篇幅会太长&#xff0c;直接看Demo…...

生成式人工智能模型:提升营销分析用户体验

使用生成式人工智能来改善分析体验&#xff0c;使业务用户能够询问有关我们数据平台中可用数据的任何信息。 在本文中&#xff0c;我们将解释如何使用新的生成式人工智能模型 ( LLM ) 来改善业务用户在我们的分析平台上的体验。假设我们为零售销售经理提供 Web 应用程序或移动应…...

【并发编程】无锁环形队列Disruptor并发框架使用

Disruptor 是苹国外厂本易公司LMAX开发的一个高件能列&#xff0c;研发的初夷是解决内存队列的延识问顾在性能测试中发现竟然与10操作处于同样的数量级)&#xff0c;基于Disruptor开发的系统单线程能支撑每秒600万订单&#xff0c;2010年在QCn演讲后&#xff0c;获得了业界关注…...

【C语言】初阶指针详解

大家好&#xff0c;我是苏貝&#xff0c;本篇博客带大家了解C语言中令人头疼的指针&#xff0c;如果大家觉得我写的不错的话&#xff0c;可以给我一个赞&#x1f44d;吗&#xff0c;感谢❤️ 使用的是VS2019编译器&#xff0c;默认为32位平台 文章目录 ①指针是什么②指针定义与…...

ElasticSearch:项目实战(1)

es环境搭建参考&#xff1a;ElasticSearch&#xff1a;环境搭建步骤_Success___的博客-CSDN博客 需求&#xff1a; 用户输入关键可搜索文章列表 关键词高亮显示 文章列表展示与home展示一样&#xff0c;当用户点击某一篇文章&#xff0c;可查看文章详情 思路&#xff1a; …...

React 实现文件分片上传和下载

React 实现文件分片上传和下载 在开发中&#xff0c;文件的上传和下载是常见的需求。然而&#xff0c;当面对大型文件时&#xff0c;直接的上传和下载方式可能会遇到一些问题&#xff0c;比如网络传输不稳定、文件过大导致传输时间过长等等。为了解决这些问题&#xff0c;我们…...

2023.8.13

atcoder_abc\AtCoder Beginner Contest 310\E_NAND_repeatedly //题意&#xff1a;给定一个n长度的01串&#xff0c;计算f(l,r)(l<r,l在1~n,r在1~n)的和,f的计算(ai,a(i1))运算,有0就为1,11为0 //若f(l,r)1,则f(l,r-1)为0或sr为0,即只取决于上一位的情况和当前位&#xff…...

kvm not all arguments converted during string

kylin virt-manager 远程镜像制作问题记录(not all arguments ) 项目场景&#xff1a; 服务器端安装的OS版本&#xff1a;Kylin-Server-10-SP1-Release-Build20-20210518-arm64-2021-05-18 客户端安装的OS版本&#xff1a;Kylin-Server-10-SP1-Release-Build20-20210518-x86_…...

JVM 基础

巩固基础&#xff0c;砥砺前行 。 只有不断重复&#xff0c;才能做到超越自己。 能坚持把简单的事情做到极致&#xff0c;也是不容易的。 JVM 类加载机制 JVM 类加载机制分为五个部分&#xff1a;加载&#xff0c;验证&#xff0c;准备&#xff0c;解析&#xff0c;初始化&am…...

智谷星图赵俊:让人才和区块链产业“双向奔赴”丨对话MVP

区块链产业需要什么样的人才&#xff1f;赵俊很有发言权。 赵俊是北京智谷星图科技有限公司的技术总监&#xff0c;也是FISCO BCOS官方认证讲师。他2017年接触区块链&#xff0c;随后选择人才培育领域深耕。“为区块链行业引进更多人才这件事很有价值&#xff0c;跟我的职业理…...

C# Equals()方法报错:NullReferenceException was unhandled

下面是一个C# Equals()方法的例子&#xff0c;执行时报错了 static void Main(string[] args) {string name "sandeep";string myName null;Console.WriteLine(" operator result is {0}", name myName);Console.WriteLine("Equals method result…...

Linux下C语言调用libcurl库获取天气预报信息

一、概述 当前文章介绍如何在Linux&#xff08;Ubuntu&#xff09;下使用C语言调用libcurl库获取天气预报的方法。通过HTTP GET请求访问百度天气API&#xff0c;并解析返回的JSON数据&#xff0c;可以获取指定城市未来7天的天气预报信息。 二、设计思路 【1】使用libcurl库进…...

深入剖析AI大模型:大模型时代的 Prompt 工程全解析

今天聊的内容&#xff0c;我认为是AI开发里面非常重要的内容。它在AI开发里无处不在&#xff0c;当你对 AI 助手说 "用李白的风格写一首关于人工智能的诗"&#xff0c;或者让翻译模型 "将这段合同翻译成商务日语" 时&#xff0c;输入的这句话就是 Prompt。…...

大话软工笔记—需求分析概述

需求分析&#xff0c;就是要对需求调研收集到的资料信息逐个地进行拆分、研究&#xff0c;从大量的不确定“需求”中确定出哪些需求最终要转换为确定的“功能需求”。 需求分析的作用非常重要&#xff0c;后续设计的依据主要来自于需求分析的成果&#xff0c;包括: 项目的目的…...

Docker 运行 Kafka 带 SASL 认证教程

Docker 运行 Kafka 带 SASL 认证教程 Docker 运行 Kafka 带 SASL 认证教程一、说明二、环境准备三、编写 Docker Compose 和 jaas文件docker-compose.yml代码说明&#xff1a;server_jaas.conf 四、启动服务五、验证服务六、连接kafka服务七、总结 Docker 运行 Kafka 带 SASL 认…...

前端导出带有合并单元格的列表

// 导出async function exportExcel(fileName "共识调整.xlsx") {// 所有数据const exportData await getAllMainData();// 表头内容let fitstTitleList [];const secondTitleList [];allColumns.value.forEach(column > {if (!column.children) {fitstTitleL…...

【算法训练营Day07】字符串part1

文章目录 反转字符串反转字符串II替换数字 反转字符串 题目链接&#xff1a;344. 反转字符串 双指针法&#xff0c;两个指针的元素直接调转即可 class Solution {public void reverseString(char[] s) {int head 0;int end s.length - 1;while(head < end) {char temp …...

【Java_EE】Spring MVC

目录 Spring Web MVC ​编辑注解 RestController RequestMapping RequestParam RequestParam RequestBody PathVariable RequestPart 参数传递 注意事项 ​编辑参数重命名 RequestParam ​编辑​编辑传递集合 RequestParam 传递JSON数据 ​编辑RequestBody ​…...

Linux --进程控制

本文从以下五个方面来初步认识进程控制&#xff1a; 目录 进程创建 进程终止 进程等待 进程替换 模拟实现一个微型shell 进程创建 在Linux系统中我们可以在一个进程使用系统调用fork()来创建子进程&#xff0c;创建出来的进程就是子进程&#xff0c;原来的进程为父进程。…...

Ubuntu Cursor升级成v1.0

0. 当前版本低 使用当前 Cursor v0.50时 GitHub Copilot Chat 打不开&#xff0c;快捷键也不好用&#xff0c;当看到 Cursor 升级后&#xff0c;还是蛮高兴的 1. 下载 Cursor 下载地址&#xff1a;https://www.cursor.com/cn/downloads 点击下载 Linux (x64) &#xff0c;…...

ubuntu系统文件误删(/lib/x86_64-linux-gnu/libc.so.6)修复方案 [成功解决]

报错信息&#xff1a;libc.so.6: cannot open shared object file: No such file or directory&#xff1a; #ls, ln, sudo...命令都不能用 error while loading shared libraries: libc.so.6: cannot open shared object file: No such file or directory重启后报错信息&…...

C++实现分布式网络通信框架RPC(2)——rpc发布端

有了上篇文章的项目的基本知识的了解&#xff0c;现在我们就开始构建项目。 目录 一、构建工程目录 二、本地服务发布成RPC服务 2.1理解RPC发布 2.2实现 三、Mprpc框架的基础类设计 3.1框架的初始化类 MprpcApplication 代码实现 3.2读取配置文件类 MprpcConfig 代码实现…...