![]() ![]() Router -> /home/alan/Documents/network/device/ASUSDF-3760/config 'Router' -> '/home/alan/Documents/network/device/ASUSDF-3760/config/' I could use the rm and ln commands to remove and create a new symbolic link, but there is a way to do this in one step using only the ln command with a few options: :~/Configuration/ $ ln -vfns ~/Documents/network/device/ASUSDF-3760/config/ Router Since my main router has changed, I want the router's symbolic link to point to its directory. This way, as the physical devices change over time, you do not have to continuously update any processes that might be managing them as they are addressing the links rather than the actual device directories. You can use symbolic links to represent each one logically with either a generic name, such as ap1, ap2, and so on, or you can use descriptive words such as ap_floor2, ap_floor3, etc. I create the directory and confirm its existence: $ mkdir -p ~/Documents/network/device/ASUSDF-3760/config :~/Documents/network/device/ $ lsĪnother example could be if you have several access points throughout your offices. Instead, I have a new directory that corresponds to the new router, perhaps an ASUS DF-3760. Therefore, its directory does not get deleted. I might re-task the old router to be an access point. The second advantage of using a symbolic link becomes evident if I decide to replace this router with a new model. The advantage is that when performing maintenance on this device, I simply browse to ~/Configuration/Router. NAS -> /home/alan/Documents/network/device/NFSBox/config Router -> /home/alan/Documents/network/device/NetgearRL5000/config Then, take a look and confirm with ls -l: :~/Configuration/ $ ls -l The command to create it is ln -s: $ ln -s /home/alan/Documents/network/device/NetgearRL5000/config Router The symbolic link Router points to the config directory of my Netgear RL5000. ![]() As shown above, the symbol indicates that these are links. I use symbolic links from this directory to point to the specific device directory: :~/Configuration/ $ ls The -F option of the ls command appends special characters to each file name to represent its type. To simplify the backup process, I have a directory in my home called Configuration. home/alan/Documents/network/device/NetgearRL5000/config. The configuration backups themselves might be deep within the directory tree, e.g. Devices can include routers, access points, NAS servers, and laptops, often of different brands and versions. I have a directory structure to hold everything related to documentation, updates, and other files for the computers and devices on my network. One way that I like to use symbolic links is to manage configuration backups of various IT equipment. In the shell, as you've discovered, while you can't replace a symbolic link atomically with the ln command ( ln -sf unlinks the previous file then creates the symbolic link), you can do it by first creating a symbolic link under a temporary name and then moving it into place.UNIX and Linux users find many uses for links, particularly symbolic links. This is annoying, but consistent with other system calls to create files such as open (which can create a new file or truncate an existing file, but not replace an existing file by a newly-created file) and mkdir. The symlink system call only creates a new symbolic link, it does not remove any existing file. Therefore the kernel does not offer any interface to edit a symbolic link, only an interface to create a new one, the symlink system call (plus the generic interface unlink to remove any file). The content of a symbolic link is pretty small (at most 4095 characters on Linux: the maximum length of a path to a file), so there would be little point in editing part of a symbolic link at the kernel level. If you're halfway through writing them, they won't work. Symbolic links need to be modified atomically. ![]()
0 Comments
Leave a Reply. |