How to Find Files in Linux | Learning Terminal

preview_player
Показать описание
In this video, I go over how to find files in Linux terminal. In this Linux Tutorial you will learn everything you ever wanted to know about the find commend and even some stuff you didn't know you wanted to know.

Basic syntax
-find options starting/path expression
$ find ~ -name media*
Note: -name is CASE SENSITIVE for results
$ find /var/html -name *.html
$ find ~ -type d -iname Downloads
Note: -iname makes it so results are not matched based on CASE.

Advanced syntax
Find Files based on modified in the past 1 day
$ find ~ -mtime -1
Note: cull this down by using | grep partial file name
Or Find Files based on modified in the past 10 minutes
$ find ~ -mmin -10
OR find Files based on modified in the past 10 minutes and greater than 10 megs
$ find ~ -mmin -10 -size +10M

You can also add the -delete command at the end to delete ALL FILES FOUND!!! Use with extreme caution!

Bonus easily find where a program is located with "whereis"
$ whereis gimp .

Рекомендации по теме
Комментарии
Автор

Another much needed and well made how-to video. Your channel is quickly becoming one of the best computer channels on YouTube. Thank you very much!

mitchelvalentino
Автор

Congrats on 10k followers! Another great video, I'm loving these

xXxMegacakedartxXx
Автор

Also find a command with:
$ which <command>

e.g.
$ which mv
/bin/mv

fourdotsYT
Автор

Hey Chris,

From a Terminal beginners perspective i feel like you went really really fast in this video, id like to know what every bit of the command does and have time to comprehend that personally, like really overexplaining things would be helpful for it to stick in. Overall though its a wellmade video with great info, thanks :)

amelio
Автор

You're killing it Chris!! I love these kinds of videos. However, I'd like them to be a bit more detailed for beginners like me. Also, longer tutorial from you is always awesome!
Cheers.

sim
Автор

I've always preferred to enable globbing and use "ls ** | grep -i [stuff]" to find things, just cause I never got used to find. However, filtering by time and size does sound pretty powerful, but I'm not sure that I have a use for that. Reassuring to know that this video exists if I ever find myself needing this command! Great vid!

Edit: I realize that my preferred method probably isn't as efficient as whatever algorithms/methods the find command uses, and can probably do a full search without me having to think too hard about narrowing my search. Methods like using information directly from the system, rather than expanding my grep query into a massively clustered regex command.... I'll come back to this video the next time I lose something in my system!

cuttlefishn.w.
Автор

Chris, you should have used 'media*' between quotes.
If you had a file in your current directory named fi. 'media.jpg' then bash would have replaced your medi* with media.jpg and you would be looking only for that filename.
If you had two filenames starting with media, bash would have replaced media* with those 2 names and the find command would have thrown an error.

So I guess it is time for you to make a video talking about wildcards and globbing ;-)

davidheremans
Автор

whereis DAMN! just brilliant. Never heard of that one before Very useful thanks

GUSL
Автор

This is going to be so useful, thanks! Awesome video, as always.

theodoros_
Автор

Thank you! Thank you! Thank you! Thank you! Always wanted to learn this. Thank you!

tpasiUG
Автор

“Till-day” as in I thought I would never find this .ttf inside my dusty old pocketchip until the day I found this channel! 🙃

smellymala
Автор

Thank you, even after using Linux for 10 years and trying to puzzle out man pages (which are complete, detailed, factual, and often utterly useless), I'd given up on finding via terminal (except for executables when I can use _whereis_ ) because I never got the command parameters right -- I'd either get no result, or the entire disk volume listed!

xheralt
Автор

That's an extremely helpful and concise video, thank you!

AlexanderWernerJr
Автор

May I ask what distro you are using for these examples? It has always been my experience that you must quote wildcarded file names to prevent the shell from expanding the wildcard (which produces unexpected results and/or errors) and allows find itself to operate on the wildcards. Are you using ~ as the starting directory because you are limiting the search to your home directory? Starting with ~ returns absolute path names relative to your home directory, starting the path name with / returns absolute path names relative to /, starting with dot (.) returns relative path names relative to current directory. This is how I learned to use find (-print is technically correct but redundant in later versions of find.)
- find all files in my home directory that start with the string 'media':
cd; find . -name 'media*' -print
find /home/user -name 'media*' -print
find ~ -name 'media*' -print
- find all files in my home directory that contain the string 'media' (use of grep is not necessary and also forks additional processes):
cd; find . -name '*media*' -print
- find all files in the file system that contain the string 'media' (you will be restricted from certain directories as an ordinary user):
cd /; find . -name '*media*' -print
find / -name '*media*' -print

If any part of my comment is incorrect or inappropriate, I apologize in advance.

Oops, to be clear ... the strings apply only to the actual file name and *not* to the content of the file.

williedells
Автор

Awesome video on Linux "find" command. learned so much.
If you can, If possible can you make one video on Linux file system or file system hierarchy? and how it works?
Thanks for the video!

trojan
Автор

For people who think the least amount of characters typed in terminal is best, enable globbing and use "ls **" with grep. Less optimized than find (probably, idk), but quick and useful if you're already somewhere deep in your filesystem (don't use it in root dir; it grabs every file from every subdirectory and will take hours to finish, or give up after 5 minutes).

cuttlefishn.w.
Автор

To search for the word where in txt files.
find . -iname '*.txt' | xargs grep -i 'where' {}

elfbier
Автор

Very very useful commands. Thanks a lot

omegamooon
Автор

Bro thanks so much for this info very helpful keep coming more videos

ricky
Автор

This is fantastic. Please, I'm a beginner in the use of Linux. In my reserach, my Advisor wants me use Linux for my work. The LInux has journals database for Literatures. how do I find the database using command?

adekunleadegbola