~/.Trash, which corresponds to the desktop Trash icon, where they stay until the Empty Trash option is chosen. You can do the same thing from the command line:

$ mv badfile ~/.Trash 

4.3.1.11. Creating multiple names by linking files

Linux systems store files by number (the inode number ). You can view the inode number of a file by using the -i option to ls :

$ ls -i /etc/hosts

3410634 /etc/hosts

A filename is cross-referenced to the corresponding inode number by a link and there's no reason why several links can't point to the same inode number, resulting in a file with multiple names.

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 /etc/passwd named ~/passwords , type:

$ ln /etc/passwd ~/passwords

The second column in the output from ls -l displays the number of links on a file:

$ ls -l electric.mp3

-rw-rw-r-- 1 chris chris 23871 Oct 13 01:00 electric.mp3

$ rm zap.mp3

$ ln electric.mp3 zap.mp3

$ ls -l electric.mp3

-rw-rw-r-- 2 chris chris 23871 Oct 13 01:00 electric.mp3

Although these types of links, called hard links , are very useful, they suffer from three main limitations:

? 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 symbolic link , which links one filename to another filename instead of linking a filename to an inode number. This provides a work-around for all three of the limitations of hard links.

The ln command creates symbolic links when the -s argument is specified:

$ ls -l ants.avi

-rw-rw-r-- 1 chris chris 1539071 Oct 13 01:06 ants.avi

$ ln -s ants.avi ants_in_ant_farm.avi

$ ls -l *ants*

-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 command will read the first part of a file, analyze it, and display information about the type of data in the file. Supply one or more filenames as the argument:

$ 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 README

Dia is a program for drawing structured diagrams.

...(more)...

If you accidentally cat a non-text file, your terminal display can get really messed up. The reset command will clear up the situation:

,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 head or tail command instead of cat .

If the text file is too big to fit on the screen, the less command is used to scroll through it.

$ less README

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.

Вы читаете Fedora Linux
Добавить отзыв
ВСЕ ОТЗЫВЫ О КНИГЕ В ИЗБРАННОЕ

0

Вы можете отметить интересные вам фрагменты текста, которые будут доступны по уникальной ссылке в адресной строке браузера.

Отметить Добавить цитату