Two commands to find files and directories in Debian 12 easily / 文件、目录的查找 /搜索命令

LXQT / LXDE / MATE / XFACE :mate 也是轻量桌面,但有时太轻量了,导致有些功能缺失。造成在 GUI 界面下使用,不方便。

Debian属于源头发行版,由于有些软件包太旧,造成在 GUI图形界面下使用时,功能缺失。

如:官版 debian 11 xface (默认 thuner 16.x ),在图形界面下,没有文件和目录的查找/搜索功能。

而其衍生版,如 mxlinux 21 (debian 11, 默认 thuner 18.x,这个版本,功能增强了许多) 有文件和目录的查找/搜索功能。

--------

Xfce 4.18, GTK+3:才具备文件和目录的查找/搜索功能?

好像很早就有文件搜索这个功能了?  https://packages.debian.org/bullseye/catfish  。但是,只是作为单独的 GUI 工具使用,没有集成进文件管理器里。到  Xfce 4.18 之后,才集成进去了吗 ?

注:默认安装的 bullseye,sourcelist 只包含了安全更新网址,因此,还需要增加一般的 app 网址 ?

Xfce 4.18 Documentation  https://docs.xfce.org/

Catfish File Search  https://docs.xfce.org/apps/catfish/start

Introduction

Catfish is a handy file searching tool for Linux and Unix. The interface is intentionally lightweight and simple, using only GTK+3. You can configure it to your needs by using several command line options.

  https://archive.xfce.org/src/apps/catfish/

https://packages.debian.org/search?suite=default&section=all&arch=any&searchon=names&keywords=catfish

这样理解?:从 xface 1.4 开始,就有了文件搜索工具,但由于不成熟,只是被作为独立的工具使用;因此,直到 1.8 版本及之后,才被集成进文件管理器中 ?

而 debian 直到 12版本?才将 xface更新到 xface 18.x 版本。但是,Debian 的衍生版本,则很早、很快就更新到 xface 18.x 版本,这是衍生版本的价值和意义之一 ?

意味着:普通用户,还是使用 xface 1.8 及之后的版本,才方便吧?

如果使用 debian 12 (当前的最新版本),则文件管理器默认带有文件搜索功能;但使用最新版本的话,可能有些第三方的 app 无法运行在 debian 最新版上。使用 debian 11,需要运行 catfish 独立 GUI 工具来进行文件搜索,麻烦。

采用 debian 的有些衍生版本?则 衍生自 debian 11,却衍生版官方默认自带了 xface 4.18。

衍生版本,有好处,也有麻烦
许多 app 的开发,一般都是基于源头版本的。衍生版可能会对源头版做出了某些阉割,导致在安装、或运行某些 app时,会缺少某些库之类的。
然而,最大的麻烦是:在缺少某些库时,有些 app会给出提示缺少的库名称;而有些 app 根本就没有给出任何的错误提示

--------

桌面环境,一般与操作系统是深度捆绑的,并有可能被发行版制作者所修改、或调整。除非官方仓库中默认有,否则,不能随便自己去升级,这样有可能导致系统崩溃 ?

普通应用型的 app,只要是在 app 允许的平台,以及版本号上,一般用户都是可以自行升级的。

--------

Get:839 http://deb.debian.org/debian bookworm/main amd64 xfconf amd64 4.18.0-2 [126 kB]   https://cdimage.debian.org/debian-cd/current-live/amd64/iso-hybrid/debian-live-12.5.0-amd64-xfce.log

  Setting up xfce4-power-manager-plugins (4.18.1-1) ..

软件包:catfish(4.16.0-1)/ File searching tool which is configurable via the command line  https://packages.debian.org/bullseye/catfish

------

摘录:前瞻:Xfce 4.18 主要新功能  https://zhuanlan.zhihu.com/p/581530159

3、Thunar 文件管理器 

也许这个版本中最令人兴奋的变化是 Thunar 文件管理器的功能。首先,一个新的“搜索”图标取代了工具栏上的“重新加载”按钮。

  https://xfce.org/

--------

Two commands to find files and directories in Debian 12 easily

  https://vitux.com/debian-find-files/

October 26, 2023 by Vitux Staff

Basically, everything in Linux is a file. But before you are able to edit a file, you must be able to locate it in your system.

About Linux file search

In this article, I briefly describe two commands in detail with practical examples to search for files with the terminal. The two commands are the find command and the locate command. The difference between the two commands is that find performs a search in real-time and locate uses an indexed database for the search. This means that the locate command is usually faster, but it assumes that the file being searched for is in its index database, and that database is usually created at night, so newer files are not found by the locate command. I am using Debian 12 in my environment. But the commands should be the same on other Linux distributions.

If you want to search for files by their content instead of the file name, have a look at the grep command instead.

Searching for Files and Directories using the find Command

Search file in the current directory

If you want to find a file using the find command, execute one of the following on your terminal.

find <filname>

suppose,

find test.txt

This will search the file in the current directory you are working on.

Search file in another directory

Now, if you want to locate the file in a specific directory. The complete command should look like,

find <path of directory/filename>

Suppose you want to search a file named 'test.txt' in Documents, the complete command should be as follows.

find Documents/test.txt

Find files by file extension

Now if you want to find all text files in your current or specific directory, the respective commands should look as follows.

find *.txt
find <path of directory/*.txt>

Suppose you want to search all text files at the path of Documents/Karim, the complete command should look like.

find Documents/Karim/*.txt

Find files by name

Alternatively, you can use -name switch when you want to search a file by name.

find <path> -name <name of file you want to search>

Suppose, you want to search a file named test1.txt at Documents/Karim. The complete command should look like.

find Documents/Karim -name test1.txt

If you want to search a specific file in the current directory you are working on. Put . at the path as shown in the example.

find . -name test1.txt

Ignore case when searching for files

If you want to search a file and want to ignore the case, use -iname switch. The complete command should look as follows.

find . -iname test.txt

Find files by file type, e.g. symlinks

To search for a specific file type, use -type option. The complete command should look like the following.

find <path> -type <c>
  • c denotes the type of file and they are following.
  • b block (buffered) special
  • c character (unbuffered) special
  • d directory
  • p named pipe
  • f regular file
  • l symbolic link
  • D door (Solaris)

Suppose you want to search regular files at Documents/Karim, execute the following command.

find Documents/Karim -type f

If you want to search for regular files in your current directory. The complete command should look like the following.

find . -type f

If you want to search files with multiple extensions, use the c characters separated by commas.

Let's say you want to find all the regular empty files in your current directory.

find . -type f -empty

Suppose you want to find all the empty directories in your current directory, use the -d and -empty options in a find command as follows.

find . -type d -empty

Find files by size

If you want to find files with a specific size, you can use the -size parameter. You can use the following suffix with their exact size.

  • c: bytes
  • k: Kilobytes
  • M: Megabytes
  • G: Gigabytes
  • b: 512 bytes block

Suppose you want to find all files in your current directory that are exactly 50 bytes. You have to execute the following command.

find . -size 50c

Suppose you want to find all files in your current directory that are more than 50 bytes or less than 50 bytes respectively, you have to execute one of the following commands.

find . -size +50c
find . -size -50c

Find files by owner (user)

If you want to search for a file owned by a specific user, you can use the -user option. The syntax of the command should be as follows.

find <path> -user <username>

Suppose you want to search a file in your current directory owned by Vitux. The command should look as follows.

find . -user vitux

Finding Files Using a Locate Command

Second is the locate command you can use to search files and directories in your system.

First of all, you have to install the locate utility on your Debian 12 machine. Login with root and execute the following command on your terminal. Press Y from your keyboard when you are asked for confirmation.

apt-get install locate

Wait for an operation to complete.

Locate is a quicker command and it relies on the database of the file system. It is updated once a day but if you want to update it manually, run the following command on your terminal with root privileges.

updatedb

To search a file with the locate command in your current directory, execute the following on your terminal.

locate <filename>

Suppose my file name is test.txt. The complete command should look like the following.

locate test.txt

You can use the -i option to ignore the file name case.

locate -i <filename>

or

locate -i test.txt

Both locate and find commands help search the files. It's up to you which of the commands you primarily use. They can be extended with other commands by using pipe, wc, sort and grep, etc.

Categories Debian, Linux, Shell

How to block/allow ping using iptables in Ubuntu

5 Ways to Edit PDF files in Ubuntu

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值