Using the terminal, it's easy to find file properties, using ls with any of its accepted flags or via stat. Notice that we are putting ''\n'' after each wanted property, so that each is printed in a new line. Which will in this case results in: marija You can filter out data such as the user name of the owner, group name of owner, or time of last status change, in even more human-readable form: $ stat - printf= '%U\n%G\n%z\n' Folder_one/ With stat, you can also format the printed info via -printf. Size: 4096 Blocks: 8 IO Block: 4096 directoryĭevice: 805h/2053d Inode: 688193 Links: 3Īccess: (0775/drwxrwxr-x) Uid: ( 1000/ marija) Gid: ( 1000/ marija)įor some, this is a much better solution than the ls command. It requires a filepath and isn't as customizable as ls: $ stat Folder_one The stat command is much more like the good old Right Click > Properties approach, because it formats all of the data and properties in a very readable format. Of course, you can chain it with other flags such as: $ ls -liĤ9323 3 david staff 96 Jun 16 20:39 Applicationsģ4615 drwx- 15 david staff 480 Jul 27 00:05 Desktop To use inode, we can add the -i flag: $ ls -i rw-r-r- 1 david staff 0 Jun 25 17:11 file.txtĭrwxr-xr-x 3 david staff 96 Jul 16 20:19 mpl ![]() Of course, you can chain the -l flag here as well, but the output might get a bit messy: $ ls -lR directory ls -lR directory Within axis-off, there's an app.py and get-pip.py. Within it, there's another directory - dvp-articles, and within it, yet another - axis-off. Here, we've recursively called ls on the directory. It will give you a tree representation of all of the files or directories that happen to be in a particular place: $ ls -R directory The -R option makes this a really simple endeavor. If you want to list subdirectories, you'll have to make a recursive ls call. It sorts the files by size, in descending order: $ ls -lS The -S flag, not to be confused with the lowercase -s from earlier, is a sorting flag. Sorting Files by Size with the -lS Option Note: Blocks are the smallest writable unit for your system and hardware. The -s option displays the file's size in blocks, rather than regular bytes: $ ls -s Combining the -l flag and -a flag, you can print the hidden files alongside regular files - with their information: $ ls -laĭrwxr-xr-x 3 marija marija 4096 Jul 18 20:03. On the other hand, if you'd specifically like to also include hidden files while listing the files of a directory - you can add the -a flag. These are typically files that you don't want to see, so this makes perfect sense. ) and aren't meant to be picked up by most GUI software, or the ls command. Though, that's mostly the benefit you get from this flag. instead of showing only in bytes, which can be very helpful. Now, we can see the size of files shown in KB, MB, GB, etc. ![]() rwxrwxrwx 1 marija marija 161K large.jpg If you want a more human-readable form, you can add the joined extension -lh or simply -h after the -l option: $ ls -lhĭrwxrwxr-x 3 marija marija 4,0K Jul 18 19:26 Folder_one Note: You can get far with the -l flag, and by combining other flags with it, the ls command will get you far for this task. ![]() If you'd like to read more about permissions and how to change them via the terminal, read our Guide to Understanding chmod. The number following the permissions is the number of links to the file or directory. We can also see their owner and group, marija, and their size in bytes, as well as their modification date/time. Here we can see that we have one directory ( d in drwxrwxr-x), named Folder_one, and 2 files. rwxrwxrwx 1 marija marija 164461 large.jpg The result of this command should look something like: total 15168ĭrwxrwxr-x 3 marija marija 4096 Jul 18 19:26 Folder_one The -l option will modify the ls command to give you much more detailed info, such as whether an entry is a file or directory, the size (usually in bytes), modified date and time, permissions, and more: $ ls -l You can use them alone, or by combining a few of them, depending on what exactly you are looking for. The ls command has several non-mandatory options which, when turned on, give us much more about these files when listing them. Though, these are just the names, and we can't infer much from them.
0 Comments
Leave a Reply. |