DEV Community

loading...
Cover image for Mini conceptual breakthrough re: ln

Mini conceptual breakthrough re: ln

alephalpha0 profile image alephalpha0 ・2 min read

mind. blown.

i do not use the typical laptop or desktop setup to muck around on the linux cli, to use text editors [micro, my babe], or futz around in image and video editors. i rely mainly on my android phones rocking termux and other various apps.

one of the pains in my keister lately, as far as getting the files to my site host's server goes, has been in the quite convoluted steps i take to do a quite simple task. these are mainly, mostly in fact, done as a direct result of a) i am scared of ssh/sftp via a cli still, and b) im self teaching on every aspect of my growth so far. the process is roughly:

  1. commit the updates via git
  2. rsync copy the files from the termux app storage into android storage proper /data/data/com.termux/... to the usual /storage/emulated/0
  3. use TotalCommander as visual ftp client and send those badboys up to the server.

Now the point of this post. ln and hard links. I was reading some articles and the die.net MAN pages on ln tonight and it finally sank in, what makes a hard link so incredibly valuable. especially in arenas like where i dwell.

a file name simply points the OS to the data bits and bytes that are written on the disk that make up what i conceptualize as a .html or .mp3 file. if the file name is erased (this happens when i delete the file) only the pointer to the specific bits is removed. the bits an bytes remain and are written over, etc etc. there is nothing that says that multiple file names cannot point to and access the same range of bytes from the OS. that multiple file pointers cant reference the same data.

😲😲😲😲😲😲

i can, through termux, access my /storage/emulated/0/ file system and create hard links, via ln, to the html, liquid, css, etc files i edit and manipulate in termux and be able to upload them from android os. takes out constant rsync and mkdir and cp and mv shenanigans. makes my workflow leaner, tighter, more tiger like.
πŸ“±πŸ”—πŸ”—β›“οΈπŸ”—βŒ¨οΈ

🐯

main article that brought on the ah hah moment

Alt Text

Discussion (1)

Collapse
moopet profile image
Ben Sinclair

I'm not sure I follow. You'll almost never want to use hard links where you could use soft links, because you lose canonicalisiosity (I just made that word up) and you end up never being 100% sure you've deleted a file or not. Things also break if you do an operation which effectively replaces a file.

Is there a benefit to using hard links here that I'm not seeing?

Forem Open with the Forem app