====== Linking files ====== ===== General information ===== **Command**: ln **Description:** Use //ln// to create a link to an existing file or directory. For example, you can generate a link to a file in our project data directory into your own data directory keeping better track of what kind of data you used for a particular analysis. If you use soft links now extra diskspace will be used. **Usage:** ln [OPTION] /path/to/newdir/newname **Common options:** - -s # generates a soft link - -f # generates the link even if it already exists **Action:**Links the file specified by to the new file newname in the directory /path/to/newdir **Acts on:** files and directories ===== Examples ===== ==== Hard links ==== ln ~/.bashrc ./mybashrc.txt **Action:** Generates a copy of your .bashrc file in the current working directory and names it mybashrc.txt. **Note:** Linking files can help you (re-)organizing your data. However, each linked file has the same size as the original file. **Caution:** If you modify the file contents of mybashrc.txt, you also modify the file contents of ~/.bashrc. This is the main difference to a copy of the file that has been generated with //cp//. ==== Soft links ==== ln -s ~/.bashrc ./mybashrc.txt **Action: **Generates a file that points to your .bashrc file in the current working directory. The pointer is named mybashrc.txt. **Note:** Soft links help you to (re-)organize your data without multiplying the amount of data stored on your disk. **Caution:** If you modify the file contents of mybashrc.txt, you of course modify the file contents of ~/.bashrc. Remember, they both point to the same data.