<?xml version="1.0" encoding="UTF-8"?> <rss
version="2.0"
xmlns:content="http://purl.org/rss/1.0/modules/content/"
xmlns:wfw="http://wellformedweb.org/CommentAPI/"
xmlns:dc="http://purl.org/dc/elements/1.1/"
xmlns:atom="http://www.w3.org/2005/Atom"
xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
xmlns:slash="http://purl.org/rss/1.0/modules/slash/"
> <channel><title>gHacks Technology News &#124; Latest Tech News, Software And Tutorials &#187; ln</title> <atom:link href="http://www.ghacks.net/tag/ln/feed/" rel="self" type="application/rss+xml" /><link>http://www.ghacks.net</link> <description>A technology news blog covering software, mobile phones, gadgets, security, the Internet and other relevant areas.</description> <lastBuildDate>Sat, 11 Feb 2012 09:52:46 +0000</lastBuildDate> <language>en</language> <sy:updatePeriod>hourly</sy:updatePeriod> <sy:updateFrequency>1</sy:updateFrequency> <generator>http://wordpress.org/?v=3.3.1</generator> <atom:link rel="hub" href="http://pubsubhubbub.appspot.com"/><atom:link rel="hub" href="http://superfeedr.com/hubbub"/> <item><title>Get to know Linux: Links</title><link>http://www.ghacks.net/2009/06/18/get-to-know-linux-links/</link> <comments>http://www.ghacks.net/2009/06/18/get-to-know-linux-links/#comments</comments> <pubDate>Thu, 18 Jun 2009 00:18:13 +0000</pubDate> <dc:creator>Jack Wallen</dc:creator> <category><![CDATA[Advice]]></category> <category><![CDATA[Linux]]></category> <category><![CDATA[Open Source]]></category> <category><![CDATA[Tutorials Basic]]></category> <category><![CDATA[hard links]]></category> <category><![CDATA[ln]]></category> <category><![CDATA[ln-s]]></category> <category><![CDATA[soft links]]></category> <category><![CDATA[symbolic links]]></category> <guid
isPermaLink="false">http://www.ghacks.net/?p=13653</guid> <description><![CDATA[During your time using Linux you are going to run into what is called a link. Links are used quite a bit in the world of Linux. Most of the time they go completely unnoticed. There are times, however, when the user will have to create a link. One common link a user will create [...]]]></description> <content:encoded><![CDATA[<p>During your time using Linux you are going to run into what is called a link. Links are used quite a bit in the world of Linux. Most of the time they go completely unnoticed. There are times, however, when the user will have to create a link. One common link a user will create is a link pointing to the global Firefox java plugin. Because the user can&#8217;t directly access that file in <strong>/usr/lib/mozilla/plugins</strong> a link must be created.</p><p>Links are very useful tools for a number of reasons. One very good use of Links is linking to a directory on another drive so you can easily access its contents. Say, for example, you have a hard drive containing mp3 files that is mounted to the directory /data. You want to be able to easily access those mp3 files but you don&#8217;t always want to have to navigate through the directory structure to get to them. Make this easy with a link in your <strong>~/ </strong>(home) directory.</p><p><span
id="more-13653"></span><strong>Types of links</strong></p><p>There are two types of links: Hard and Soft (Symbolic) links. The primary difference between hard and soft links is that hard links can only link to a file and can not span drives or volumes. Soft links, however, can link to directories and can span drives/volumes. At first you may think &#8220;Why even use hard links?&#8221; One major advantage to hard links is that a link will remain even if the original file is moved.</p><p>Another difference between hard and soft links, that isn&#8217;t really examined by the end user is that hard links reference an exact inode whereas soft links reference abstract files/directories and are given their own, unique inode.</p><p><strong>How to create links</strong></p><p>Links are created by using the <em>ln</em> command. Hard links are created by using the <em>ln</em> command alone where soft links are created with the <em>ln</em> command using the <em>-s</em> switch.</p><p>Let&#8217;s start out by creating a hard link. We&#8217;ll use a very simple example. Using the Enlightenment E16 window manager requires you to edit the ~/.e16/menus/user_apps file to add to your menu. Let&#8217;s say you want a link in your ~/ directory to that file so you&#8217;re not always having to type so much to get to that file. You can do this with a hard link by entering the following command (as your standard user:</p><p><em>ln ~/.e16/menus/user_apps ~/user_apps</em></p><p>This will create a link in your home directory called <em>user_apps</em>. The nice thing about this is any time you edit either file, both will change. So you can simply edit the file in your home directory and the changes will reflect in your ~/.e16/menus/user_apps file.</p><p>One of the more common uses (as stated earlier) is linking a file from the <strong>/usr/lib/mozilla/plugins </strong>directory to your <strong>~/.mozilla/firefox/XXX/plugins/ </strong>directory. Instead of linking file by file you can just link to the entire directory. NOTE: This is not often the case. Some distributions/installations handle the browser plugin system differently. I am using this as an obvious example of how soft links come in handy.</p><p>Where XXX is a random string of characters created upon installation of Firefox.</p><p>So to make a soft link from your <strong>/usr/lib/mozilla/plugins</strong> directory to your <strong>~/.mozilla/firefox/XXX/ </strong>directory you would issue the command:</p><p><em>ln -s /usr/lib/mozilla/plugins ~/.mozilla/firefox/XXX/</em></p><p>Now your user installation of Firefox can see the plugins for the global installation. Of course this doesn&#8217;t always work in the case of plugins. Again, I state it was used as an obvious example to explains links.</p><p>One of the nice aspects of soft links is that a standard user can link to files in any directory. But just because they can link to them doesn&#8217;t mean they can edit them. You can create a link from the /etc/hosts.deny file to your home directory but, as the standard user, you can not edit the file. The standard user will, however, see all edits made to this file when edits are made by a user with write permissions.</p><p>Confused?</p><p>Let me try to explain that in another way. Say, for example, you want your users on your Linux machine to be able to see the contents of file<strong> /data/SAMPLE_DATA</strong>. You don&#8217;t however want them to see the contents of the <strong>/data</strong> directory. Remove the read permissions from the directory <strong>/data</strong> with the command:</p><p><em>chmod -R o-w /data</em></p><p>and then give the file SAMPLE_DATA back read permission with:</p><p><em>chmod o+w /data/SAMPLE_DATA</em></p><p>command.</p><p>Now link to the SAMPLE_DATA file with the command:</p><p><em>ln /data/SAMPLE_DATA ~/</em></p><p>and the user will have a hard link to the file that they can read but not edit.</p><p><strong>Final thoughts</strong></p><p>Although links can be a bit confusing, they are a very helpful tool to use with the Linux operating system. They can make your administration job easier and save hard drive space. Get to know links, they are your friends.</p> ]]></content:encoded> <wfw:commentRss>http://www.ghacks.net/2009/06/18/get-to-know-linux-links/feed/</wfw:commentRss> <slash:comments>5</slash:comments> </item> </channel> </rss>
