Hi Linux power users, I was wandering how you do search for files

Hi guys, I am kind of a Linux novice and a student of sw engineering. I have always been fascinated by efficiency with no compromises (I don’t care about aesthetics, I want to be fast and comfortable).

I always found graphical file managers, like for example windows file explorer, clunky to navigate. I often lose my orientation and thus my focus, navigating through folders feels like a cumbersome experience instead of feeling like the natural way of “being inside” a pc.

When I first approached the development world I started to use more the tree-like file explorers that you’ll commonly find in IDEs. But I didn’t like those either, being graphical oriented they require me a lot of activity to achieve a file I want (either by keyboard or mouse) and when I need more folders open at the same time the space they take up on the screen becomes impractical.

Finally, I like to navigate the system through command line but I miss some kind of visualization, this makes me feel disoriented more often than not. As I said I’m just a novice in the command line world though, what do you guys do to navigate the files and folders on your systems? What do you suggest me?

Thanks in advance for your time!

1 Like

Me too. It clutters the screen

There is the basic find command, which will search for a file if you know the filename
There is tree which will display directory structure in a command line terminal
There is file which will tell you the file type

I mostly just use cd and ls , and then look at files with view or more.

Regards
Neville

3 Likes

I just use the file manager, dolphin or thunar or whatever, in the distro I’m using at the moment. Seems entirely adequate for me.

2 Likes

I think maybe what you might be looking for is Midnight Commander? I think the command to run it is “mc” - it’s supposedly a clone of the old Norton Commander for MS-DOS (but for UNIX / Linux) systems. I can install it on Ubuntu with “sudo apt install mc”. It’s a console tool you can run in a terminal window, but you can still even use a mouse if you want (e.g. open the menus at the top).

At the very bottom of the MC screen, i.e. in the “black space” under the “Hint:” you can still use shell commands - e.g. cd /home/x

I issued the “mc” command from ~/MPZ folder - and it presents that as the default view (note: ~/MPZ is a shortcut to /mnt/BARGEARSE/MPZ - my music collection on my NAS [over NFS]):


I typed “cd /home/x” to go to my home folder.

And now the left pane is in my $HOME (/home/x)

Note also - as you navigate the tree - the very bottom “pane” of the blue part, of that pane, will show stuff - e.g. if the cursor (where you’ve stopped navigating) is over ~Music, it will show that this is a symlink to /home/x/ResilioSync/Music :

As for searching / finding :
Top menu : Command → Find file :
Screenshot from 2022-12-18 11-06-41

I chose “shit” as the search item - because I use that string in a lot of file and folder names :smiley: so it’s bound to yield some hits :


You can see at the bottom of the results, there’s options there to e.g. “Chdir” to that folder that has a result… Neat…

Me - I personally don’t use it… I mostly use all the GNU commands at my disposal :

  • cd
  • ls
  • pwd
  • tree (not very often mind you)
  • find
  • chmod, chown, chgrp
  • du
  • df
  • file
  • cp, mv, mkdir, rmdir
  • on debian and ubuntu systems, I often use the “rename” command, it uses Perl/Sed style regex to rename files (e.g. remove space chars from filenames) - but - on Fedora / RedHat systems, “rename” is an entirely different command, and the only way to get it on RPM based distros is to enable CPAN and install it from the Perl repos, e.g. as the command “prename” (mnemonic for Perl Rename)

I’ll often use find with exec - e.g. one thing that bugs me on my NAS is some stuff is stored in folders with 777 - now I don’t remember doing that - in fact, I NEVER do that (I think sometimes it might be stuff I downloaded as a ZIP file and they get unzipped with 777 :rage: ) … I prefer 775 or 755 (drwxr-x-r-x) - and 777 shows up in an ugly colour in the terminal (and probably due to my colourblindness - I mostly cannot even read it sometimes as it’s BLOCKED out in green or orange or some other colour) - so I’ll often do something like this :

find . -maxdepth 1 -type d -exec chmod 755 {} \;

And I guess if I can be arsed, doing it all in one big hit :

find . -type d -perm 777 -exec chmod 755 {} \;

(Note : I’d use EXTREME CAUTION doing the above - i.e. even I sometimes make mistakes after 30 years of using UNIX - this is the MAIN reason I only do it on a case by case basis, and only
with -maxdepth 1 - it could potentially take hours on my 900 GB of music files and too much potentiall for human error) **

And I used to use this to find BIG folders :

find . -maxdepth 1 -type -exec du -sh {} \; | sort -h

But then I realised “du” itself had a maxdepth argument so

du -d 1 -h |sort -h

Except for the SHITTY fact that Solaris can do NEITHER of those neat tricks, doh (and I do get filesystem at 80, 90, 100% calls at 3:00 am for Solaris servers!)! A lot of times ~15-20 years ago, you could get the GNU versions of tar and find and grep and ALL those goodies as Solaris Sparc binaries from SunFreeware, but around 2012 - Oracle sent the Sunfreeware Org people a nasty cease and desist letter - but DID NOT OFFER THEIR OWN ALTERNATIVE!

Oracle are doing their damnedest to kill off Solaris.

** I’ve had cases before where some “web developer” (i.e. using Dreamweaver on a Mac) did a chmod 777 and there was NO way to recover from this moronic act. The only way I can think of, is to either BEFORE you do something so utterly STUPID, run “getfacl > file” (or similar) and record the perms BEFORE you change them (you can always replay that “file” later on to set them back to what they were before when the Dreamweaver user used their “passion fingers”…

4 Likes

I find Catfish works well to search for files. Fast and usually finds what I’m looking for.

1 Like

Hi @allo_gallo, :wave:

if I want to look for a particular file and know at least some part of the file name I use a dedicated (simple) script I once wrote for such purposes.

This way I cannot get distracted by something else and am presented with the search results that fit the pattern.

I employ the find command for that matter - as already suggested by @nevj. :+1:

As an example - here´s the script for finding anything on 3 different USB-sticks:
The script is called 2_script_für_find_auf_USB-Sticks.sh:

bat 2_script_für_find_auf_USB-Sticks.sh
File: 2_script_für_find_auf_USB-Sticks.sh
───────┼───────────────────────────────────────────────────────────────────────────────────────
   1   │ #!/bin/bash
   2   │ 
   3   │ echo "What are you looking for?"
   4   │ read suche
   5   │ echo "You entered $suche ."
   6   │ sleep 1.0
   7   │ find /media/rosika/A492-CD29 -iname "*$suche*" > /home/rosika/Desktop/Suchergebnisse
   8   │ echo "----------------------------------------------------------"
   9   │ sleep 1.0
  10   │ find /media/rosika/74C1-30C7 -iname "*$suche*" >> /home/rosika/Desktop/Suchergebnisse
  11   │ echo "----------------------------------------------------------"
  12   │ sleep 1.0
  13   │ find /media/rosika/28BC-DAFC -iname "*$suche*" >> /home/rosika/Desktop/Suchergebnisse
  14   │ echo "----------------------------------------------------------"
  15   │ sleep 1.0
  16   │ find /media/rosika/f14a27c2-0b49-4607-94ea-2e56bbf76fe1/pers_Dateien_von_C -iname "*$s
       │ uche*" >> /home/rosika/Desktop/Suchergebnisse
  17   │ sleep 1.0
  18   │ firejail --net=none gedit /home/rosika/Desktop/Suchergebnisse

The results are presented in the text editor gedit and the paths of the discovered files are given.
It´s easy to copy and paste them for use in a file manager (like thunar).

I also created a .desktop file for the script and put it on my dsktop. It´s convenient for quick access by e.g. double-clicking it :wink: :

bat find_USB-Sticks.desktop
───────┬───────────────────────────────────────────────────────────────────────────────────────
       │ File: find_USB-Sticks.desktop
───────┼───────────────────────────────────────────────────────────────────────────────────────
   1   │ [Desktop Entry]
   2   │ Version=1.0
   3   │ Name=find_USB-Sticks      
   4   │ Comment=Suchen
   5   │ Exec=/media/rosika/f14a27c2-0b49-4607-94ea-2e56bbf76fe1/LINK-FARM/Skripte_für_bionic/2
       │ _script_für_find_auf_USB-Sticks.sh
   6   │ Icon=utilities-terminal
   7   │ Terminal=true
   8   │ Type=Application
   9   │ Categories=Application;
  10   │ Name[de_DE]=find_USB-Sticks      
  11   │ Comment[de_DE]=Suchen

I also wrote a script for finding files on my 3rd (data-)partition of the HDD.

Many greetings from Rosika :slightly_smiling_face:

3 Likes

What is does the “M” stand for in the keyboard shortcut for the Find file option?
F2 I get.
C-u I get.
I assume the “A” key would be Alt and choose options in the menu.
Is it the Windows or Super key?

Oh and I used Norton Commander back in the days of DOS 3.3. :slight_smile:

I prefer to use the ‘locate’ command as it is much faster than ‘find’.

 locate -i 'filename'

         where -i makes it case insensitive.  
         In Ubuntu the quotation marks are optional.
         The 'filename' can be incomplete.
         I usually first run 'sudo updatedb' to bring the file database up-to-date.
1 Like

Sorry mate - no f–king idea… not my product… just my suggestion… if you’re curious maybe contact the developer? As mentioned previously I don’t use it myself…

I remember “seeing it” - I used Norton Utilities and it came with them… But I preferred to use Xtree/XtreeGold over Norton Commander…

This is an antique keyboard key name, which was retained for so many decades due to the elitist mindset of many UNIX & Linux dinosaurs, because “we have always done it like this”.

“M” stands for Meta and nowadays basically just refers to the Windows key, which is pretty much found on every keyboard, that is not specifically crafted for Linux or macOS.

Nobody knows this, when seeing it for the first time, because it is antiquated & technically does not exist anymore, when considering the original meaning.

Calling that type of key “Meta” is basically like saying “I’m going to ride my horse today” and then entering the car.


I am extremely baffled, how everyone in this thread forgot to mention, that the classical UNIX’ find utility is pretty much the slowest CLI searching utility, one could possibly imagine. It is antique & works like one in every way. It even uses single dashes for long options, because “we have always done it like this”.

Nobody should use find anymore, because it is the slowest, worst & most antiquated searching utility, today. Using it is like using a horse on an autobahn.

Some alternatives I could quickly find.

However, it does not really matter, which alternative you choose. ANYTHING is better than the traditional find. Stop using find. It’s a waste of time. Literally.


This post had inspired me to look for a solution to optimise my browsing behaviour in the CLI. I have always just done it the old school way, before, but now I realised I just did it, because I got used to it, i.e. because “I have always done it like this”.

When searching for a fine alternative, I came across this solution.

When I tried it out for the first time, I encountered two issues with it.
Luckily, this project’s maintainer was very helpful & responsive.
He fixed the issues very quickly.
This is already a very good sign. A project has to be maintained by sane persons.

Once you get used to the shortcuts (takes only about 10 minutes of playing around), you will be able to have an efficient file browsing experience in your terminal.

2 Likes

Alternatives are fine if you only have one or two nix boxes to administer…

I’ve got between 1500 and 2000 - different distributions and a whole waft (“waft” as in the sulphurous stench of flatus) of different release versions - not to mention Solaris (I used to love it - now I just wish it would hurry up and die SOON! I can’t believe there are “enterprises” still using it - THEY’RE WRONG!
anyone still using should be strongly urged [at gunpoint] to reconsider)…

So - I need to keep using find because I can almost guarantee that’s one thing that will be on nearly EVERY single UNIX box… even if half the shit I like to use in find isn’t there in some of these ancient last millenium legacy piles of crap… e.g. in Solaris you can’t even case insenstive search! True! There’s no “-iname” argument… and I a whole bunch of RPM based distros that IGNORE BOTH “-xdev” and “-mount” arguments (i.e. I NEED to exclude mountpoints - but cannot).

And that very specific use-case is fine. Of course, it’s a different story with enterprises & similar use-cases.

However, it’s too often the case, that, for example, people familiar with enterprise environments do not question what is going on there, then copy the behaviour onto private platforms, if enough people do it like this, it is considered “normal”, “standard” or the “default” & suddenly you are stuck with a disaster utility like find, just because there is a “normal” “standard” “default” made up, just because most did not bother to question, whether that makes sense in the first place.

So, if compatibility is crucial, I can understand the usage of antiquated tools, to a certain degree (even this use-case has limits), but most readers here are home users, so I just addressed the average home user.
The average home user should know, that find should not be used anymore, due to the reasons I depicted earlier.

point taken :slight_smile: (and duly noted [to add more chars upto and beyond 20 char minimum :slight_smile: ])

1 Like

This does not quite line up with the traditional use of Meta key in emacs. In emacs meta is usually Escape, but it can be changed (eg to Alt)

Does anyone use emacs today? Can you give us an update on Meta?

Yes. It is actually even more complicated, than that. Xah Lee explained this at some point.

http://xahlee.info/emacs/emacs/emacs_meta_key.html

http://xahlee.info/kbd/meta_key.html

And of course he also has an article about that, which is self-explanatory. :smiley:

Therefore, the only reason for saying “Meta” key nowadays is to show off, how elitistic & antique one’s UNIX terminology is.

A keyboard with an actual “Meta” key.

People using the term “Meta” key voluntarily today just want to be elitists.

1 Like

And of course, Discourse cannot view images via embedded http links by default… :roll_eyes:

Wow. It’d take a bit of getting used to that keyboard.
Looks like it has the world’s largest zero key. :slight_smile:

2 Likes

“Break”! Wow! I’ve seen that before - was it on mainframe keyboards? Tandy TRS-80…

Anyway - spotted this article today - “nnn” looks pretty interesting :

and “modern” I guess… and I can install it no dramas on Ubuntu 22.04 and MacOS with homebrew! Sweet…

IT’s actually quite nice to use - and a tad more intuitive than midgnight commander too - it, it might look more “terse” and economical than “mc”, but it seems pretty straightforwad to me…

Dunno if it can find shit but :slight_smile:

1 Like

From my two minutes research, I could not find anything, that this tool can do & felix cannot do.

Is there something, I’m missing?

Okay, just noticed, it seems to have more generic keyboard shortcuts by default.

However, it is written in C. Who knows how & when it will break. :smiley: