Is there any way for me to symlink a particular file so that it appears in every directory on the system?

So if I symlink /tmp/scratch

No matter where I am I can type vi scratch?

  • 1
    You could create a command for Vi that if you type in vi +scratch it will automatically open /tmp/scratch. Its much more maintainable.
    – sparticvs
    Commented Dec 13, 2013 at 16:20
  • @sparticvs If you could expand this comment into an answer with actual vimscript code, I think it would be really useful.
    – Joseph R.
    Commented Dec 13, 2013 at 16:22
  • find / -type d will find every directory on your system. However if adding this symlink everywhere does not break something, you will still regret it. (with great power comes great responsibility. Commented Dec 13, 2013 at 16:34
  • 2
    why not just do alias scratch='vi /my/path/scratch.txt' then when you run scratch anywhere on the system, it will open /my/path/scratch.txt?
    – amphibient
    Commented Dec 13, 2013 at 16:54

4 Answers 4


Since Joseph R wanted me to expand, I will. If you use VIM (because that's what I know more than Vi) you can add this to your ~/.vimrc file.

if @% == "scratch"
    silent edit /tmp/scratch

Tada, now you have scratch everywhere!

  • 1
    @JosephR. thanks for making me do this, because now I have this in my vimrc and I have found it to be REALLY useful.
    – sparticvs
    Commented Dec 16, 2013 at 14:10

A more robust solution would be to use an alias in your .bashrc:

alias viscrtch='vi /tmp/scratch'

This way viscrtch can be used to edit /tmp/scratch from anywhere within the filesystem.

If you want the ability to add command line arguments, use a shell function instead:

viscrtch(){ vi "$@" /tmp/scratch; }

Call it as

viscrtch your_options_here

Even if you find a way to symlink one file to every directory in the system, I discourage you from doing it: it's neither maintainable nor practical.

  • 2
    Alternatively you could do alias scratchpad='vi /tmp/scratch' and then you have a new command. Same as above just renamed something that you will probably remember.
    – sparticvs
    Commented Dec 13, 2013 at 16:22

As others noted, it is probably not the best solution, but here is a way to link in all directories beneath the current.


for Dir in $(find ./* -type d);
    ln -s $lnfile $Dir

find / -type d -exec ln -s -T /tmp/scratch scratch {} \;

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .