LINUX TIPS AND TRICKS --- January 12, 2001

Published by ITworld.com -- changing the way you view IT
http://www.itworld.com/newsletters

________________________________________________________________________________

Alias Physical Files
By Danny Kalev

Linux allows you to associate more than one name to the same physical 
file. This feature is useful, for instance, when you need to refer to 
the same physical file from different directories. This week I will 
explain how to create file links using the ln command.

The ln command defines a new name - commonly called a link - for an 
existing file. In the following example, the user defines a new link 
called "january" for the file reports01_01:

    $ln reports01_01 january

The ln command takes two parameters, the first being the original 
filenames and the second the new associated name. If you list the 
current directory's files, you will see a new item added -- the link 
january:

   $ls
    reports01_01 january

Remember though, only one physical file resides in the directory. 
Adding a link doesn't create a new file, it merely creates an alias.

It's possible to associate more than one link per file. The 
following example issustrates associating a new link with the file 
reports01_01:

    $ln reports01_01 inventory

As expected, the ls command now shows three different files in the
current directory, two of which are the previously defined links:

    $ls
     reports01_01 january inventory

To find out the number of links associated with a file, type the ls 
command with the -l option. This option provides additional information 
about a file such as permissions, the number of associated links, the 
owner, the size, and modification date. However, this option still 
doesn't reveal the names linked to the same file. To see the 
associated links, use the -i option. This option displays the file's 
inode - a unique identification number Linux assigns to each physical 
file. If two filenames have the same inode number, then they are linked 
to the same physical file. For example:

    $ls -i january inventory
     4577 january 4577 inventory

To delete a file, you have to remove all of its associated links. So 
long as one associated link remains, the file isn't deleted; even if 
the original filename has been removed, the physical file remains 
intact. In the following example, the user employs the rm command to 
remove the file reports01_01. However, since this file has two other 
associated links, it still can be accessed through them:

    $rm reports01_01
    $cat january
     bulbs 12
     mice 56
     


About the author(s)
----------------
Danny Kalev is a system analyst and software engineer with more than 10 
years of experience, specializing in C++ and object-oriented analysis 
and design on various platforms including VMS, DOS, Windows, Unix, and 
Linux. His technical interests involve code optimization, networking, 
and distributed computing. He is also a member of the ANSI C++ 
standardization committee and the author of ANSI/ISO C++ Professional 
Programmer's Handbook (Que, 1999). Contact him at linuxnl@excite.com.

________________________________________________________________________________

ADDITIONAL RESOURCES

Fiddling around with files, part three

http://www.unixinsider.com/jsw/lintps_nl/swol-04-1998/
swol-04-insidesolaris.html

Linux file compression tool guide 
A review of free and useful tools

http://www.linuxworld.com/jlw/lintps_nl/lw-2000-11/
lw-11-compression.html

Getting the most from your shell 
A helpful guide to command-line editing, aliases and functions, and 
shell programming

http://www.unixinsider.com/jsw/lintps_nl/swol-10-2000/
swol-1027-unixshell.html

________________________________________________________________________________

COMMUNITY DISCUSSIONS

Hone your Linux development skills, share your expertise, and put out 
the occasional call for help in this discussion for programmers of all 
levels. Moderated by Danny Kalev.

http://www.itworld.com/jump/lintps_nl/forums.itworld.com/
webx?14@@.ee6b652/210!skip=140

Linux is making its presence felt on the desktop, but is it stable and 
polished enough for prime time? Talk distributions, window managers, 
themes, and desktop politics here.

http://www.itworld.com/jump/lintps_nl/forums.itworld.com/
webx?14@@.ee6b663/335!skip=277

Ask questions, offer solutions, and tell your tales in this lively 
discussion of the good, bad, and ugly sides of managing Unix systems.

http://www.itworld.com/jump/lintps_nl/forums.itworld.com/
webx?14@@.ee6b677/380!skip=331

________________________________________________________________________________

CONTACTS

* For editorial comments, write Andrew Santosusso, Associate Editor, 
  Newsletters at: andrew_santosusso@itworld.com

* For advertising information, write Dan Chupka, Account Executive at:
  dan_chupka@itworld.com

* For recruitment advertising information, write Jamie Swartz, Eastern
  Regional Sales Manager at: jamie_swartz@itworld.com or Paul Duthie,
  Western Regional Sales Manager at: paul_duthie@itworld.com

* For all other inquiries, write Jodie Naze, Product Manager, 
  Newsletters at: jodie_naze@itworld.com

________________________________________________________________________________

PRIVACY POLICY
http://www2.itworld.com/CDA/ITW_Privacy_Policy 

Copyright 2001 ITworld.com, Inc., All Rights Reserved.

http://www.itworld.com
