ls
ls –l
ls –a
ls –la
man ls
dir
permissions
number of hard links
owner
group
size (in bytes)
last-modified date
file name
directory, link or file?
r = read
w = write
x = execute
user triplet
group triplet
others triplet
What the heck is a hard link?
man link
info coreutils 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”).
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.)
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.
Normal users can’t. Root can. But it’s a terrible idea, and is very rarely done.
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.
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.
Absolutely. This is commonly done to simplify navigation:
ln -s /var/tmp /usr/tmp
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).
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.
Size is displayed in bytes, though there are options for showing it in blocks (often 4096 byte blocks).
Month, Day, Year (if not current year)
Time in “military” format
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.
Start with a dot
Contain system configuration
Usually text files
Can be directly modified