ln -s Command Reference for CI Scripts
ln -s creates a symbolic link that points at another path.
Symlinks let CI pin a stable name to a versioned install (a "current" toolchain) or expose a binary on PATH. The relative-vs-absolute target choice trips people up.
Common flags/usage
- -s: make a symbolic (not hard) link
- -f: remove an existing destination first
- -n: treat an existing symlink destination as a normal file, not a dir
- -r: make the link target relative (GNU)
- ln -s TARGET LINKNAME: TARGET first, then the new link name
Example
shell
ln -sfn "/opt/node/${NODE_VERSION}" /opt/node/current
ln -sf "${PWD}/bin/tool" /usr/local/bin/toolIn CI
Use ln -sfn together when repointing a "current" symlink: -f replaces it and -n stops ln from descending into the old link and creating a nested link instead. A relative target (or -r) keeps the link valid if the tree is moved or mounted at a different prefix; an absolute target breaks then.
Key takeaways
- ln -s TARGET LINK takes the target first, then the new link name.
- ln -sfn safely repoints an existing "current" symlink in place.
- Relative targets survive a moved or remounted tree; absolute ones may not.
Related guides
chmod Command Reference for CI Scriptschmod changes file permissions in CI. Reference for +x, octal modes, -R, and symbolic modes, plus the 600-on-…
cp Command Reference for CI Scriptscp copies files and directories in CI for staging artifacts. Reference for -r, -p, -a, and trailing-slash beh…
readlink -f Command Reference for CI Scriptsreadlink -f resolves a path to its canonical absolute form in CI. Reference for -f, -e, and -m, plus the macO…
mkdir -p Command Reference for CI Scriptsmkdir -p creates directory trees idempotently in CI. Reference for -p, -m, and parent creation, plus why -p n…