User Tools

Site Tools


ls -a

The ls command as we have already seen lists files and or directories and specific information about them in a variety of formats. The -a option stands for all, as it displays all files anddirectorys including "hidden" files, i.e. the ones that have a dot, "." character, prepended to them. Usually a file is hidden so that a user will not accidentally edit an important configuration. In other words, the files are not hideen to any other than the most casual glace at the file system as anyone can normally use the -a option as easily as they can use ls with out it.

ls -a

will give output like


Note the . and .. characters at the top of the list. The dot is a type of index of the contents of the current directory, and the "..", double dot, is a listing of the files in the partent directory, i.e. the folder one level closer to the root of the filesystem. Use the -A, ( dash capital A), option to see the hidden files with out . and .. which all directories will have. The -a and -A options can be combined with a variety of other ls options to get the kind of data you need presented in the format most convenient for you, e.g.

ls -Ao

run in my home directory gives me a presentation that starts out like

total 692892
-rw-r--r--  1 burt         0 Apr  5 16:46 4wiki
drwx------  2 burt      4096 Sep 23  2015 .abook
drwx------  3 burt      4096 Feb 25  2015 .adobe
-rw-------  1 burt      5061 Mar 19 00:42 animals.docx
-rw-------  1 burt       762 Aug 15  2015 at-spi2-core-git.tar.gz
drwxr-xr-x  4 burt      4096 Jan 31 03:22 .audacity-data
drwxr-xr-x  8 burt      4096 Feb  1 10:28 Audio
drwxr-xr-x  2 burt      4096 Aug  9  2015 Audiobooks
-rw-r--r--  1 burt      5636 Sep 22  2015 avtrimmer-0.7.3.tar.bz2
-rwxr-xr-x  1 burt     11963 Mar 23 00:24 .bash_aliases
-rwxr-xr-x  1 burt     13618 Dec 22 14:35 bash_aliases
-rw-------  1 burt    124757 Apr  5 12:18 .bash_history

So with this command we combine the display of files and folders including the "hidden" ones we get with the -A option with the rather detailed information about each item we get from the -o option. The "total" number at the top of the list refers to the aproximate total size of all the files in the directory in kilobytes, but directories are only shown to have the size of their headers in the filesystem, 4096 bytes being the minimum. Actually my home folder on this machine is using about 26GB at this time.

*Tip: Now that you have been introduced to a couple of the most popular ls options type

man ls

in a console or terminal to learn about the many other ls options that you can use to fine tune output of the command to get the information you need. While many manpages are not clearly written, the ls manpage is mostly understandable even to someone quite new to computing and or technical documentation. There are options that let you control the order in which files and or directories are displayed in, colors used, and whether items are organized in columns, rows, or one entry to a line, as well as of course the actual data that will be shown for each file or folder.

*Tip: Some directories contain such sensitive data that either an administrator or an application itself give them restrictions that keep normal users from even reading filenames. Use

sudo ls

to see what secret files are there.

ls_-a.txt · Last modified: 2017/11/11 22:47 (external edit)