0

I mistakenly asked this question on StackOverflow, and they suggested I ask it here instead.

I've read a lot of the other posts here, and they all seem to be answered successfully, but I just can't follow along. I'm still very new, and I don't want to try the trial and error approach, because I'm not sure if I'll be able to fix it. Here's where I am.

I have a file named "php.ini" that's in the root web folder of my host. I need this folder to also be in every single folder and subfolder on the server. The host suggested "creating a symbolic link in the subfolders" and that was the extent of their help. I asked how and they told me to google it. So I did.. and I'm lost. So far I have this:

ln -s /path/to/htdocs/php.ini LINK-NAME

But I'm not actually sure if this is right, and I'm not sure what the LINK-NAME is supposed to be, or what it does. Also, I don't know if this will create the link in every folder and subfolder? Since I'm supposed to use SSH to enter this command, I want to make sure I have it right before I try. I'm sorry if this is very basic knowledge (noob) question, all my searches just give an example and none of them explain what they do!

Thank you so much!

  • Can't you experiment a little? Just try the command in some test directory with subdirectories. You won't solve the problem completely but hopefully "what the LINK-NAME is supposed to be" and "if this will create the link in every folder and subfolder" will no longer be mysteries. Plus man ln is your friend. "Making sure you have it right before you try" won't get you far in Linux. :) Or maybe you lack knowledge on how to create a test directory and tidy the mess you may cause there? Are these commands familiar: mkdir, cd, cp, rm, rmdir`? I'm not judging; just asking. – Kamil Maciorowski Oct 4 '18 at 5:34
0

You could find every directory in some path

find path -type d 

and have find execute -exec (or -execdir is supposed to be more secure) ln (with -v for verbose) on it (assuming the full path you want to link to is /path/to/htdocs/php.ini)

find path -type d -execdir ln -v -s /path/to/htdocs/php.ini '{}' ';'

Or instead of using -exec or -execdir you could pipe find's output to xargs (null separated output might be helpful, -print0 / -0), or use in a bash/sh script, etc...


But first, you might want to check if there are already any php.ini files in there, with

find path -name php.ini

or if you've made a bunch of new php.ini links and want to check what they actually point to, use

find path -name php.ini -execdir readlink '{}' ';'

or if you make a mistake creating a ton of bad php.ini files, you can delete them with

find path -name php.ini -delete

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.