Friday, August 9, 2019

listing files and directories

Good article about the ls command in Linux: "16 Practical Examples of Linux LS command for Beginners"

It kinda bugs me that the author used capital letters in the title for the command. But I'm over it. The article contains some great tips. The ls command is one of the first commands most users learn about when they're new to Linux, and even after using Linux for many years, I'm still finding it to be a very useful tool.

Here's one I like to use that wasn't mentioned in the article:

$ ls -dl $PWD/*

I like to use it mainly because it outputs the full pathnames of all of the files and directories in the present working directory (except for hidden ones). Here's an example, from one of my Arch installations:


That listing shows only directories. Here's another example, from within another directory, and this one contains only files:


That's convenient sometimes when I want to copy and paste the full pathname of a file/directory. But most of the time, I'm keeping things simple and using one of these four commands:

$ ls
$ ls -a
$ ls -l
$ ls -al

For more info about the ls command, check out man ls.

No comments: