Listing Files

Listing Files:


ls –l

ls –a

ls –la

man ls



Columns in the ls –la listing:


number of hard links



size (in bytes)

last-modified date

file name


The permissions column:

directory, link or file?

r = read

w = write

x = execute

user triplet

group triplet

others triplet



The hard links column:

What the heck is a hard link?

man link

info coreutils link


This is a hard link

You create one with a command like this:

ln /bin/bash ~/mybash

where the syntax is:

ln target_of_link link_file_name

So you choose a target file (like the bash binary above) and then a location for the hard link (in this case, my home directory, with the name “mybash”).


Now For (A Whole Lot) More About Files

At the very root of the file system is the superblock. The superblock is the physical location of the inode table. And the inode table in turn is a tabular list of inodes (information nodes), each of which is uniquely numbered, and holds the master information for a file: file size, data block location, last modification time and date; ownership; and permissions.

The inode more-or-less “is” the file; when a file is deleted (unlinked), what is actually deleted is its inode. The file’s data blocks are only overwritten when they are needed. And we do need them; in most systems there is a limit of 64K inodes. Yes, we can run out of “file space” even when there is still space on the hard disk.

(Want more explanation? Search for “inode” when you get to this page.)


Nothing Prevents A File From Being Listed In Two Different Directories
(or even twice in one directory)

With the above concepts clearly in mind, now think of a file that appears in two different directories. What the directory listing is really referring to is an inode. There are not two copies of the file; there is only one. It just shows up in two different places.

You can verify this by creating a link, then using the -i option to the ls command:

touch myfile

ln ./myfile ./myfile2

ln -li

In this listing, note the inode number on the left. Both myfile and myfile2 have the same inode.


Can You Hard Link Directories?

Normal users can’t. Root can. But it’s a terrible idea, and is very rarely done.



There are also “soft” links, or symlinks

Symlinks are somewhat similar to Windows shortcuts.

Most actions are passed through the link to the target, i.e. opening a program.

Only creation and deletion actually act on the link file itself.


How Do You Create One?

With a command like this:

ln -s /bin/bash ~/mybash

where the syntax is:

ls -s target_of_link link_file_name

Note the -s option, which makes ln create a soft link (symlink) rather than a hard link.


Can You Soft Link Directories?

Absolutely. This is commonly done to simplify navigation:

ln -s /var/tmp /usr/tmp


Further Discussion

See the System V Unix page that discusses links.


The Owner column:

The owner and the author are the same in most *nix, but not in all *nix.

The owner is referenced in the owner triad of the permissions.

Generally, files under your ownership are in your home directory, but not necessarily (see /var/mail/studenth).


The Group column:

When you are created as a user, a group with the same name is created, with you as its only member.

You may be assigned to other groups, for instance, the wheel group.

Your file permissions are set upon file creation.

These defaults can be changed.


The Size column:

Size is displayed in bytes, though there are options for showing it in blocks (often 4096 byte blocks).



The Last-Modified column:

Month, Day, Year (if not current year)

Time in “military” format



The File Name column:

Regular files can be named almost anything:

A-Z 0-9 _ – ~ .

You will run into certain special characters that you can’t use.

Unix does NOT use file extensions to identify file type; Gnome and KDE however DO.

Hidden files start with a dot: .

Backup files end with a tilde: ~

Some programs like emacs create backups automatically.


Hidden files:

Start with a dot

Contain system configuration

Usually text files

Can be directly modified