Skip to content

Getting started

Ruben Christoffer Hegland-Antonsen edited this page May 29, 2020 · 7 revisions

This guide is about using Mklinker after you have installed it. If you are looking for an installation guide, refer to the README.

Table of contents

  1. Basics of how Mklinker works
    1. Default links
  2. Basic commands
  3. What are variables?
    1. Using variables in commands

Basics of how Mklinker works

Most Mklinker commands interacts with the config file in some way. The (symbolic) links that you want to create are stored in the config file along with optional variables. The config file stores source path, target path and link type for all links. The link type is by default set to default, but it is possible to explicitly store link type.

Then, after adding the links you want to create to the config file, you have to run the linkall command to actually create the links on disk.

Default links

The link type is by default set to default, which means that the linker you are using will determine if a junction, symbolic or hard link should be created. Below is a table of how the various linkers resolve default links.

Default Windows Unix (Linux / Mac)
File Symbolic Symbolic
Directory Junction Symbolic

Basic commands

  1. Run mklinker config --create to create a new config if one does not already exist
  2. Run mklinker config --delete to delete a config if one already exists
  3. Run mklinker addlink [SOURCE] [TARGET] to add a new default link to config file (e.g. mkinker add /home/user ./LinkToUser)
  4. Run mklinker linkall to create all the links on the filesystem (reads data from config)
  5. Run mklinker help to display help screen
  6. Run mklinker help [VERB] to display help screen for verb (e.g. mklinker help addlink)

You can find all commands and their description by running "mklinker help", but they are also available on this wiki here.

What are variables?

Variables can be used to avoid copy-pasting the same base path for multiple links. With a variable, you only have to define the base path once and then if you want to change it later you only have to change it in one place instead of multiple places. Take the following example:

Example: You want to create two symbolic links: ["/home/user/documents" => "./documents"] and ["/home/user/media" => "./media"]. Now, you could just add the full paths manually for each link to the config file or you can take advantage of variables.

You can create a variable called "user" with the value "/home/user". Then, instead of using "/home/user/documents" as source path, you use "?user?/documents" (note the ? at start and end of user to indicate that it's a variable).

This way, if you later want to use the source path of another user, let's say "/home/anotheruser/documents", all you have to do is change the "user" variable to "/home/anotheruser" and the rest of the config can be left untouched. This is especially important if you want to share your config file with other people without the possibility to use relative paths, as their paths will most likely differ from yours.

TIP: It is also possible to use multiple variables and nested variables. E.g. "?drive?/?user?/staticfoldername/?foldername?" would be considered a valid source / target path

Using variables in commands

  1. Run mklinker addvar [NAME] [VALUE] to add a new variable (e.g. mklinker addvar user /home/user)
  2. To replace variable value you can run mklinker addvar [NAME] [VALUE] --force
  3. After adding variable, you can include it in links like this: mklinker addlink ?user?/userfile ./LinkToUserFile, which will be resolved to mklinker addlink /home/user/userfile ./LinkToUserFile when running the linkall command (it is stored as ?user?/userfile in the actual config file)