Linux with Operating System Concepts



Download 5,65 Mb.
Pdf ko'rish
bet37/254
Sana22.07.2022
Hajmi5,65 Mb.
#840170
1   ...   33   34   35   36   37   38   39   40   ...   254
Bog'liq
Linux-with-Operating-System-Concepts-Fox-Richard-CRC-Press-2014

soft
, or 
symbolic
, link stores a pointer to the original link.
You might want to create a link to an existing file for convenience to provide a means of 
accessing the file from multiple locations. To create a link, you will use the 
ln
command. 
With the command, you specify whether the link should be a hard link (the default) or a 
soft link (by using the option -s).
The format of the instruction is 
ln [-s] 
existingfile newfile
where the exist-
ing file must permit links (there are permissions that can be established that forbid links to 
a file). In this example, 
newfile
is a pointer, not a new file or a copy of 
existingfile
.


Navigating the Linux File System

93
The symbolic link is very useful in that you can place the link in a directory where 
you expect that users might try to access a file. For instance, if users think a particular 
program is stored in /
bin
but in fact is in /
usr/local/bin
, a symbolic link from 
/bin/someprogram
to /
usr/local/bin/someprogram
would solve this prob-
lem. This would be better than adding /
usr/local/bin
to all users’ path variables. 
Additionally, if a system administrator (or user) were to move a file that other users 
reference, then a symbolic link can ensure that the users can still access the file in spite 
of it being moved.
Another application is for a user to place a symbolic link in his or her home directory, 
pointing to another location. In this way, the user can reference items outside of their 
directory without needing to specify a full path. As an example, imagine that the user has 
written a game which pulls words out of the Linux dictionary file, /usr/share/dict/words. 
Let us assume the user issues the following command:
ln -s /usr/share/dict/words ~/words
This creates a symbolic link in the user’s home directory called words that links to the 
dictionary. Now the user’s program can reference words without needing the path.
You should note that the symbolic link is merely a pointer and the pointer is not aware of 
the file it points to. If someone were to delete the file being linked to after the symbolic link 
had been created, the symbolic link would still exist. Using that symbolic link will yield an 
error because the file that it points to no longer exists. Alternatively, deleting the symbolic 
link does not impact the file itself.
You can see if an item is a file or a symbolic link by using 
ls -l
. The symbolic link 
is denoted in two ways. First, the first character in the list of permissions is a ‘l’ for link. 
Second, the name at the end of the line will have your symbolic link name, an arrow (
-
>
), 
and the file being pointed to. There are several symbolic links in the /etc directory. For 
instance, /
etc/grub.conf
is a symbolic link pointing to /
boot/grub/grub.conf

and the scripts located in /
etc/init.d
are actually symbolic links pointing to the files in 
/
etc/rc.d/init.d
.
You can also see if a file is pointed to by multiple hard links. The ls -l command displays 
in the second column an integer number. This is the number of hard links pointing at the 
file. Most files will contain only a single link, so the number should be 1. Directories often 
have multiple links pointing at them. If you were to delete a file, the hard link number is 
decremented by 1 so for instance if a file has 3 hard links and you delete one, it becomes 2. 
Only if you delete a file whose hard link number is 1 will the file actually be deleted from 
disk.
If you find the ln instruction confusing because of the -s option, you can also create 
links using 
link
to create a hard link and 
symlink
to create a symbolic link.
3.4 LOCATING FILES
In this section, we examine different mechanisms for searching through the Linux file 
system for particular files, directories, or items that match some criteria.


94

Linux with Operating System Concepts
3.4.1 The GUI Search Tool
The easiest mechanism is to use the GUI Search for Files tool. In the Gnome desktop, this 
is found under the Places menu. This tool is shown in Figure 3.5. Under “Name contains,” 
you enter a string. The tool will search starting at the directory indicated under “Look in 
folder.” Any file found whose name contains the string specified in that portion of the file 
system will be listed under Search results. By selecting “Select more options,” the user can 
also specify search criteria for files that contain certain strings, files that are of a specified 
size, modification date, ownership, and other details. The GUI program then calls upon 
find, locate (both of which are described below), and grep (which is covered in Chapter 6). 
While the Search for Files tool is easy to use, you might want to gain familiarity with both 
find and grep as you will often prefer to perform your searches from the command line.
3.4.2 The Find Command
The 
find
program is a very powerful tool. Unfortunately, to master its usage requires a 
good deal of practice as it is very complicated. The find command’s format is
find 

Download 5,65 Mb.

Do'stlaringiz bilan baham:
1   ...   33   34   35   36   37   38   39   40   ...   254




Ma'lumotlar bazasi mualliflik huquqi bilan himoyalangan ©hozir.org 2024
ma'muriyatiga murojaat qiling

kiriting | ro'yxatdan o'tish
    Bosh sahifa
юртда тантана
Боғда битган
Бугун юртда
Эшитганлар жилманглар
Эшитмадим деманглар
битган бодомлар
Yangiariq tumani
qitish marakazi
Raqamli texnologiyalar
ilishida muhokamadan
tasdiqqa tavsiya
tavsiya etilgan
iqtisodiyot kafedrasi
steiermarkischen landesregierung
asarlaringizni yuboring
o'zingizning asarlaringizni
Iltimos faqat
faqat o'zingizning
steierm rkischen
landesregierung fachabteilung
rkischen landesregierung
hamshira loyihasi
loyihasi mavsum
faolyatining oqibatlari
asosiy adabiyotlar
fakulteti ahborot
ahborot havfsizligi
havfsizligi kafedrasi
fanidan bo’yicha
fakulteti iqtisodiyot
boshqaruv fakulteti
chiqarishda boshqaruv
ishlab chiqarishda
iqtisodiyot fakultet
multiservis tarmoqlari
fanidan asosiy
Uzbek fanidan
mavzulari potok
asosidagi multiservis
'aliyyil a'ziym
billahil 'aliyyil
illaa billahil
quvvata illaa
falah' deganida
Kompyuter savodxonligi
bo’yicha mustaqil
'alal falah'
Hayya 'alal
'alas soloh
Hayya 'alas
mavsum boyicha


yuklab olish