![]() There are so many options, how do you sift through them to find the useful ones? And having found them, how do you remember them? The ls command is one of those commands with a wealth of options. Beyond that, it gets little consideration. We list files in long format when we want to look at the permissions on a file. We list files with it to see what's in a directory. That might explain why there is more to this command than most users realize. Those of us who hang around the command line use it day in and day out without even thinking about it. The ls command is probably the first command most Linux users encounter. Pay it some attention, and you'll find many useful options - including some you should add to your command-line arsenal. ![]() Enjoy.We use the Linux ls command every day without thinking about it. I hope I made things clear to you and now you know what does ls -lrt command does and why is it used. You achieve this with ls -lrt as the addition of option r will reverse the sorting (by time): ls -lrt What you can do here is reverse the sorting and display the newest (created or modified) files at the bottom. Why? Because you'll have to scroll up to see the newest files. But if you have 20 or 50 or 100 files in the current directory and you want to see which files were accessed or modified recently, this will be a pain. Now, this is good enough if you have a few files. For older files, it shows the year (notice 2021?). ![]() Linux shows the time for the files created in the current year. The newest files are displayed at the top. I am going to sort ls command output by size in long listing with ls -lt: ls -ltĭo you notice the change? Now the entries are sorted by time. rwxr-xr-x 1 abhishek abhishek 57430439 Mar 17 07:52 pcloudĭrwxr-xr-x 2 abhishek abhishek 4096 PenguinSubtitlePlayer-Linux rwxr-xr-x 1 abhishek abhishek 89697412 balenaEtcher-1.5.116-圆4.AppImageĭrwxr-xr-x 6 abhishek abhishek 4096 cpufetch Now, if I use ls -l, it will display one entry per line, still sorted in alphabetical order. ![]() Obsidian-0.13.19.AppImage ScreenCloud-v1.5.3-x86_64.AppImageīy default, it just gives the name of the files and directories in alphabetical order. Let me show you the contents of my sample directory: ls Let's go a little further and understand it with practical examples. You'll get the same result for ls -lrt and ls -ltr. The order of the options doesn't matter here. The newest files are shown at the bottom. So when you combine them all, you display the contents in the present directory sorted in reverse chronological order. r: This one reverses the order of ls command output.t: This one sorts the long listing output based on time.It shows one file in each line with additional info such as permissions, ownership, size, timestamps etc. l: This is for the long listing of the contents.The lrt part is a combination of three different options: The ls command is used for listing the contents of a directory. I won't judge you because I have been there myself. If you are looking for an explanation, you are either a new Linux user or don't use Linux commands quite often. The -lrt provides additional options to the command. As a software developer or tester, you'll often use the "ls -lrt" command, specially while dealing with a large number of files.Īctually, it's just ls command.
0 Comments
Leave a Reply. |
Details
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |