$ mv
4.3.1.11. Creating multiple names by linking files
Linux systems store files by number (the
$ ls -i
3410634 /etc/hosts
A filename is cross-referenced to the corresponding inode number by a
This is useful in several situations. For example, the links can appear in different directories, giving convenient access to one file from two parts of the filesystem, or a file can be given a long and detailed name as well as a short name to reduce typing.
Links are created using the ln command. The first argument is an existing filename (source), and the last argument is the filename to be created (destination), just like the cp and mv commands. If multiple source filenames are given, the destination must be a directory.
For example, to create a link to
$ ln
The second column in the output from ls -l displays the number of links on a file:
$ ls -l
-rw-rw-r-- 1 chris chris 23871 Oct 13 01:00 electric.mp3
$ rm
$ ln
$ ls -l
-rw-rw-r-- 2 chris chris 23871 Oct 13 01:00 electric.mp3
Although these types of links, called
? The target (file being linked to) must exist before the link is created.
? The link must be on the same storage device as the target.
? You cannot link to directories.
The alternative to a hard link is a
The
$ ls -l
-rw-rw-r-- 1 chris chris 1539071 Oct 13 01:06 ants.avi
$ ln -s
$ ls -l
-rw-rw-r-- 1 chris chris 1539071 Oct 13 01:06 ants.avi
lrwxrwxrwx 1 chris chris 8 Oct 13 01:06 ants_in_ant_farm.avi -> ants.avi
Notice that the the link count on the the target does not increase when a symbolic link is created, and that the ls -l output clearly shows the target of the link.
4.3.1.12. Determining the contents of files
The
$ file *
fable: ASCII text
newicon.png: empty
passwd: ASCII text
README: ASCII English text
xpdf.png: PNG image data, 48 x 48, 8-bit/color RGBA, non-interlaced
4.3.1.13. Viewing the contents of text files
You can display the contents of a text file using the cat command:
$ cat
Dia is a program for drawing structured diagrams.
...(more)...
If you accidentally
,l*l<lLxe2 ,,<lFL<<<G\l<lGRL<lxe2 xf5 <L,l<lLlLLLl<*]US]$$][]UWVS[ j)Eue[^_1PuuuG;re[^_UUSR@t@CuX[USP[n X[xG hG6QGListxG!GN9Akregator11ApplicationE <LL 2hLlxe2 xf5 [&&*CS@&*_^-&@$#D]$ reset[chris@concord2 ~]$
To display only the top or bottom 10 lines of a text file, use the
If the text file is too big to fit on the screen, the
$ less
You can use the up and down arrow keys and the Page Up/Page Down keys to scroll, and the q key to quit. Press the h key for help on other options, such as searching.