Read the video transcript
Sooner or later, you have to find a file on a Linux server. In this video, you'll learn the commands that do it fast: find, locate, which, and grep. All live, on a real Ubuntu server, with SSH Command. We're connected, with the Shell view open. I've made a practice folder called find-demo, with a mix of files to search. find lists everything inside a folder, all the way down. The dot means the current folder. Add -name to search by file name. Put the pattern in quotes, so the shell doesn't expand it. Here are all the .txt files. -type d finds only folders, and -type f finds only files. -iname ignores capital letters. This finds every file with report in its name, however it's written. -size finds files by size. +100M means bigger than one hundred megabytes. This is how you track down what is filling a disk. -mtime filters by age. -mtime +7 means changed more than seven days ago. -mtime -1 means changed within the last day. Once you've found files, you can act on them. -exec runs a command on each result. Here, ls -lh shows their sizes. Always test without -delete first, because deleting has no undo. locate is much faster, because it searches a database of file names instead of walking the disk. Try it on sshd_config. -n 5 limits the output to five results. The catch: the database is refreshed only once a day, so a brand new file won't be there. sudo updatedb refreshes it, and now the file turns up. which tells you where a command lives. whereis also finds its manual page. To find a file by what is inside it, use grep with -r, which searches every file in a folder. -n adds line numbers. Let's find every TODO. And in SSH Command, the search bar lists these commands with their options. Type find, and pick one to copy. That's how to find files on Linux: find for the details, locate for speed, which for commands, and grep for contents. The full guide is at sshcommand.com, under search commands. SSH Command is free for personal use. The link is in the description. Thanks for watching.