Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 366287
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 12, 20262026-05-12T13:37:06+00:00 2026-05-12T13:37:06+00:00

Does any operating system provide a mechanism (system call — not command line program)

  • 0

Does any operating system provide a mechanism (system call — not command line program) to change the pathname referenced by a symbolic link (symlink) — other than by unlinking the old one and creating a new one?

The POSIX standard does not. Solaris 10 does not. Mac OS X 10.5 (Leopard) does not. (I’m tolerably certain neither AIX nor HP-UX does either. Judging from this list of Linux system calls, Linux does not have such a system call either.)

Is there anything that does?

(I’m expecting that the answer is "No".)


Since proving a negative is hard, let’s reorganize the question.

If you know that some (Unix-like) operating system not already listed has no system call for rewriting the value of a symlink (the string returned by readlink()) without removing the old symlink and creating a new one, please add it — or them — in an answer.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-12T13:37:06+00:00Added an answer on May 12, 2026 at 1:37 pm

    Actually, you can overwrite a symlink and thus update the pathname referenced by it:

    $ ln -s .bashrc test
    $ ls -al test
    lrwxrwxrwx 1 pascal pascal 7 2009-09-23 17:12 test -> .bashrc
    $ ln -s .profile test
    ln: creating symbolic link `test': File exists
    $ ln -s -f .profile test
    $ ls -al test
    lrwxrwxrwx 1 pascal pascal 8 2009-09-23 17:12 test -> .profile
    

    As the OP pointed out in a comment, using the --force option will make ln perform a system call to unlink() before symlink(). Below, the output of strace on my linux box proving it:

    $ strace -o /tmp/output.txt ln -s -f .bash_aliases test
    $ grep -C3 ^unlink /tmp/output.txt
    lstat64("test", {st_mode=S_IFLNK|0777, st_size=7, ...}) = 0
    stat64(".bash_aliases", {st_mode=S_IFREG|0644, st_size=2043, ...}) = 0
    symlink(".bash_aliases", "test")        = -1 EEXIST (File exists)
    unlink("test")                          = 0
    symlink(".bash_aliases", "test")        = 0
    close(0)                                = 0
    close(1)                                = 0
    

    The following is copied from Arto Bendiken’s answer over on unix.stackexchange.com, circa 2016.

    This can indeed be done atomically with rename(2), by first creating the new symlink under a temporary name and then cleanly overwriting the old symlink in one go. As the man page states:

    If newpath refers to a symbolic link the link will be overwritten.

    In the shell, you would do this with mv -T as follows:

    $ mkdir a b
    $ ln -s a z
    $ ln -s b z.new
    $ mv -T z.new z
    

    You can strace that last command to make sure it is indeed using rename(2) under the hood:

    $ strace mv -T z.new z
    lstat64("z.new", {st_mode=S_IFLNK|0777, st_size=1, ...}) = 0
    lstat64("z", {st_mode=S_IFLNK|0777, st_size=1, ...}) = 0
    rename("z.new", "z")                    = 0
    

    Note that in the above, both mv -T and strace are Linux-specific.

    On FreeBSD, use mv -h alternately.

    This is how Capistrano has done it for years now, ever since ~2.15. See this pull request.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Ask A Question

Stats

  • Questions 215k
  • Answers 215k
  • Best Answers 0
  • User 1
  • Popular
  • Answers
  • Editorial Team

    How to approach applying for a job at a company ...

    • 7 Answers
  • Editorial Team

    What is a programmer’s life like?

    • 5 Answers
  • Editorial Team

    How to handle personal stress caused by utterly incompetent and ...

    • 5 Answers
  • Editorial Team
    Editorial Team added an answer Dereference (the '*') has a lower precedence than the '.'… May 12, 2026 at 10:59 pm
  • Editorial Team
    Editorial Team added an answer Answering my own question. When you return an IStream from… May 12, 2026 at 10:59 pm
  • Editorial Team
    Editorial Team added an answer If you're using Zend Framework 1.8+, and created your project… May 12, 2026 at 10:59 pm

Related Questions

Forgive me if this has been asked before; I did a search but couldn't
I have decided it is impossible to do the following (equivalent) enum operations via
The Situation: I'm optimizing a pure-java implementation of the LZF compression algorithm, which involves
We have a large number of programmers on different platforms all using CVS. We

Trending Tags

analytics british company computer developers django employee employer english facebook french google interview javascript language life php programmer programs salary

Top Members

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.