Ubuntu Unleashed 2019 Edition: Covering 18.04, 18.10, 19.04

(singke) #1

Click here to view code image
matthew@seymour:~$ ls -sh *.txt


This outputs the size of each matching file in a human-readable format, such
as 108KB or 4.5MB.


Using the -l parameter enables you to get much more information about
your files. Instead of just getting the names of the files, you get output like
this:


Click here to view code image
drwxrwxr-x 24 matthew matthew 4096 Dec 24 21:33 arch
-rw-r--r-- 1 matthew matthew 18691 Dec 24 21:34 COPYING
-rw-r--r-- 1 matthew matthew 88167 Dec 24 21:35 CREDITS
drwxrwxr-x 2 matthew matthew 4096 Dec 24 21:35 crypto


This output shows four matches and prints a lot of information about each of
them. The first row shows the arch directory; you can tell it is a directory
because its file attributes starts with a d. The rwxrwxr-x following that
shows the access permissions, and this has special meanings because it is a
directory. Read access for a directory enables users to see the directory
contents, write access enables you to create files and subdirectories, and
execute access enables you to cd into the directory. If a user has execute
access but not read access, the user can cd into the directory but cannot list
files.


Moving on, the next number on the line is 24 , which also has a special
meaning for directories: It is the number of subdirectories (including . and
..). After that is matthew matthew, which is the name of the user owner
and the group owner for the directory. Next are the size and modification
time, and finally the directory name itself.


The next line shows the file COPYING, and most of the numbers have the
same meaning, with the exception of the 1 immediately after the access
permissions. For directories, this is the number of subdirectories, but for files
it is the number of hard links to this file. A 1 in this column means this is the
only filename pointing to this inode, so if you delete it, it is gone.


Ubuntu comes configured with a shortcut command for ls -l: ll.


The —sort parameter enables you to reorder the output from the default
alphabetic sorting. You can sort by various things, although the most popular
are extension (alphabetically), size (largest first), and time (newest first). To
flip the sorting (making size sort by smallest first), use the -r parameter also.
So, the following command lists all .ogg files, sorted smallest to largest:

Free download pdf