[chiptune music intro]
[paper tears]
Greetings and welcome to another exciting Lil' Linux Lesson!
[bells playing a little tune]
I'm Veronica, and today I'm going to quickly go through the `ls` command.
`ls` is the Linux and UNIX terminal command that lists out the contents of a directory.
This is **extremely** useful as a system administrator, where the terminal's totally triumphant in
the tableau of tried and true technology tendencies.
Learning how to efficiently use `ls` is vital on the way to becoming a sysadmin, so let's
get started.
First off, let's navigate to a folder that has a lot of files in it.
This is my "downloads" folder, and it has a bunch of random files I pulled from the Internet!
Lets try "ls" just by itself.
This drops a big list of files into the screen.
This is nice to see, and can be useful enough for some cases.
But usually, we want more information than this.
So, we're often using arguments to get more details.
The first argument I'll talk about is the `-a` argument.
This option means "all" and shows you every file in the directory, even the hidden files
that start with a period.
This is extremely useful when looking for configuration files, as those often are hidden
in a GUI.
The next argument is `-l`, which provides a more detailed list, called a "long listing".
This shows a ton of great info about the file, including file permissions, file size,
edit date, and more.
OK, that's all well and good, but look at these file sizes.
It's in bytes, which is great in the 1970s, but nowadays it's not particularly convenient.
Not to worry, because you can add the `-h` argument to make the file sizes human readable!
But what if we want to see the newest files first?
Well that's easy with the `-t` argument, which sorts by time, with the newest files first.
That's super neat, but what if you have to reverse the order?
Not to worry, because there's the `-r` argument for that.
OK, that was fun, and fast.
Of course, you can use just some, or all of these arguments together, depending on how you need to use the `ls` command.
And there's many, many more arguments to learn, and in this case, the man page is going to be your friend.
Just type `man ls` in the terminal to learn more.
One of my favorite things to do with the `ls` command is to route the output to a text file.
This is very useful in my life as a COBOL dev, when I'm writing up a checklist of files
that need to be updated.
To output to a text file, simply use the "greater than" symbol key, also known as an angle bracket,
like this.
Now, I have a text file with the listing of these files inside it.
Using two angle brackets instead of one appends it to an existing file,
which is great if I'm gathering a collection of files in multiple directories.
That's right: you can use `ls` for directories other than the one you're currently in.
This is extremely useful stuff as both a developer and a system administrator.
Now *you* know the basics of the `ls` command.
Of course, there's much, much more advanced usage out there, but that's a topic I'll save
for a future, longer video.
One last thing though, and I'd be remiss if I didn't mention it.
I know some folks, particularly on YouTube, will say things like "stop using `ls`, use this instead."
In fact, I'm sure some of you are writing a comment to that effect right now!
[punk kid voice] "1, 2, 3, 4!"
[music playing] The thing is, as a professional Linux and UNIX sysadmin, I'm frequently working with
systems that don't have access to fancy, newer tools like this.
If you work for an organization that has strict package security requirements, there's a decent
chance that you'll be denied access to alternatives that aren't part of the "traditional" UNIX experience.
It's like how having a power drill is nice, but a carpenter still needs to know how to
swing a hammer.
Plus, if you're scripting, or automating certain key tasks, the tried-and-true tools are going
to be much more consistent than some of these newer alternatives.
So in my experience, it's better to just learn the common tools in the first place.
Of course, you can use whatever you like. Just make sure you know how to swing a hammer.
Luckily, there are excellent resources out there for you to learn the common toolsets.
And why wouldn't there be, I mean Linux is Awesome!
And so are you!