Full Stack for Front-End Engineers, v2 Finding Files & Directories
Transcript from the "Finding Files & Directories" Lesson
>> Jem Young: Let's talk about finding things, this is important. How do you find things today on your computer?
>> Jem Young: It's not a trick question, I promise you.
>> Speaker 2: Cmd+F.
>> Jem Young: Yeah, Cmd+F, Finder, you can do Cmd+Space on Mac, which I love, I wish Windows would pick that up. But on a Unix system, or on a Linux system, you can't just Cmd+F, necessarily.
[00:00:23] You need something a bit more robust. So there's two ways generally we're gonna try to find anything. We're gonna use the find command, and we're gonna use grep. And we use grep often because we're piping output and we're searching for specific lines in the output. Find, I haven't used yet, but we'll run through a few examples.
[00:00:42] So find has the syntax of find, the place you're trying to look, the options you're trying to look for, such as name or directory, something like that. And then the specific file that you're looking for, so that's the find syntax. And reference back to this, because find is one of those things that you'll forget how to use really quickly, because it's kind of long and it's not necessarily intuitive.
[00:01:05] You're like, I just wanna find all my log files, and you'll be thinking of the syntax. So feel free to reference back to this. I'll tell you a secret, I reference my own slides sometimes [LAUGH] because I don't remember all of this stuff. If you don't use it on the day to day, that's okay, don't feel bad.
[00:01:21] And don't let anybody make you feel bad for not remembering this. [LAUGH] Unless you're a DevOps person, these are things you should probably know. Some useful options are the type of the thing you're looking for, the name, is the file empty, is the file executable, is it writable?
[00:01:37] And we'll cover executable and writable in permissions a little bit later. But this is pretty useful if you're trying to lock down your system and you're saying, hey, I'm in this directory, did I set all my permissions correctly? So you can just do a search for everything that is writable or not writable, things like that, in a directory.
[00:01:52] So let's run through an exercise. It's a bit early, [SOUND] so let's do some exercises, get those fingers working. So find all the log files in var/log.
>> Speaker 3: I had to quote *.log.
>> Jem Young: Good point.
>> Jem Young: Thank you.
>> Jem Young: Again, I'm not perfect, [LAUGH] I remember these things as I go along.
[00:02:26] So did that work for everybody, hopefully, yes. And if we wanted to, we can grep that output. We can pipe that output through grep, and we can say, I wanna find all of the error logs, or all of the access logs, things like that.
>> Jem Young: All right, now let's find all the directories with the name log.
[00:02:45] You're saying, why am I always looking for log? It's something you do most of the time, because that's one thing you're trying to search over, you're trying to find one of your log files. So find the directory, the type, and then the name.
>> Jem Young: So we're gonna do,
>> Jem Young: find, the directory, the type, actually, d, the name is log. And we're getting a lot of permission denied, because without running sudo, you can't dive into those logs, cuz those are private logs.