you are viewing a single comment's thread
view the rest of the comments
[–] 3 points 1 year ago* (last edited 1 year ago) (2 children)

My dumbass can only come up with three:

  1. You are already root (ok, fine)
  2. You have made /dev/ writable by non-privileged users
  3. Your non-privileged user already owns the symlink /dev/nul. Which "ok, fine", but also the point of command would have to be to functionally do nothing other than print out the error ln: failed to create symbolic link '/dev/nul': File exists

I would love to understand the use case behind #2. I am also curious to see even 7 more cases, let alone your figurative million.

In regards to #3 even if the behaviour of ln was to replace a symlink if it already existed, it'll probably have to unlink() the existing symlink, which I'm pretty sure is gonna get you a permission denied error on any /dev filesystem with sane permissions.

  • source
  • parent
  • hideshow 2 child comments
  • [–] 1 point 1 year ago*

    Follow up, tested and confirmed #3:

    [korthrun@host]$ ls -l /dev/korth
    .rw-r--r-- korthrun wheel 0 B Wed Jun 11 17:11:03 2025 /dev/korth
    [korthrun@host]$ rm /dev/korth
    rm: cannot remove '/dev/korth': Permission denied
    
  • source
  • parent