PC & IT SUPPORT MADE EASY FORUM
Would you like to react to this message? Create an account in a few clicks or log in to continue.

Create a symbolic link to another symbolic link on linux

Go down

Create a symbolic link to another symbolic link on linux Empty Create a symbolic link to another symbolic link on linux

Post by jamied_uk 4th September 2020, 16:53

Vid

This script is very powerful and very good for web servers, you can use a windows share to make a mount point (aka symbolic liink) and then use this script to make a symbolic link to that other symbolic link so that you dont have to have tonnes of space on the actual linux web server! also you can do this for any reason, this was just my reason!


Code:
#!/bin/bash
#
# (c) J~Net 2020
# jnet.sytes.net
#
# ./set.sh
#
# https://jnet.forumotion.com/t1708-create-a-symbolic-link-to-another-symbolic-link-on-linux#2645
#link a symbolyc link to another!
echo "Welcome To J~Net Symbolic Link Creator"
echo "Listing Current Mounts"
ls /mnt
echo "Enter first sym link that you wish to link to Example: /home/data/A"
read first
echo "Enter where you want the new sym link Example: /var/www/html/symtestfolder"
read second

ln -s "$first" "$second"
    #  ^--existing  ^----new link
          file $second
          echo "All Done."


Last edited by jamied_uk on 4th September 2020, 17:11; edited 2 times in total
jamied_uk
jamied_uk
Admin

Posts : 3053
Join date : 2010-05-09
Age : 41
Location : UK

https://jnet.sytes.net

Back to top Go down

Create a symbolic link to another symbolic link on linux Empty Re: Create a symbolic link to another symbolic link on linux

Post by jamied_uk 4th September 2020, 17:00

To Remove Symbolic links


Code:
#!/bin/bash
#
# (c) J~Net 2020
# jnet.sytes.net
#
# ./del.sh
#
# https://jnet.forumotion.com/t1708-create-a-symbolic-link-to-another-symbolic-link-on-linux#2645
#link a symbolyc link to another!
echo "Welcome To J~Net Symbolic Link Creator"
echo "Listing Current Mounts"
ls /mnt
echo "Enter SymLink To Remove Example: /var/www/html/symtestfolder"
read first
#
sudo rm $first
echo "All Done!"
jamied_uk
jamied_uk
Admin

Posts : 3053
Join date : 2010-05-09
Age : 41
Location : UK

https://jnet.sytes.net

Back to top Go down

Create a symbolic link to another symbolic link on linux Empty Re: Create a symbolic link to another symbolic link on linux

Post by jamied_uk 4th September 2020, 17:43

If you need the first mount point for a windows share via network on Linux (aka symbolic link).


Code:
#!/bin/bash
# (c) J~Net 2020
# jnet.sytes.net
#
# https://jnet.forumotion.com/t1708-create-a-symbolic-link-to-another-symbolic-link-on-linux#2645
#
# sudo chmod +x *.sh
# ./run.sh
#
echo "Welcome To Add Mount Point aka Symbolic Link By J~Net"
#
remotehost="192.168.1.30"
echo ""
echo "What name you want for the mountpoint?"
read first
remote_location=$first
if [ "$#" -eq  "0" ]
  then
    echo "Enter Remote IP"
    read ip
else
    ip=$1
fi
#
#cd smb://$ip/$remote_location/
#ls
sudo mkdir /mnt/$first
clear
# /etc/fstab
newstring="//$ip/$remote_location /mnt/$first        cifs    credentials=/root/.smbcredentials,uid=33,gid=33,rw,nounix,iocharset=utf8,file_mode=0777,dir_mode=0777 0 0"
sudo echo $newstring >> /etc/fstab
#
clear
echo "Put the following text at bottom of the file thats about to open (Then save and close)...."
echo ""
echo $newstring
sudo xed /etc/fstab
echo "Now checking for new lines..."
sudo mount -a
echo "Now listing files..."
ls /mnt/$first
echo "Now Ready ForSymbolic Linking using set.sh"
jamied_uk
jamied_uk
Admin

Posts : 3053
Join date : 2010-05-09
Age : 41
Location : UK

https://jnet.sytes.net

Back to top Go down

Create a symbolic link to another symbolic link on linux Empty Re: Create a symbolic link to another symbolic link on linux

Post by jamied_uk 4th September 2020, 17:54

Please note you will need index.php (blank file) if you want to protect from viewing list of files once it is linked!
jamied_uk
jamied_uk
Admin

Posts : 3053
Join date : 2010-05-09
Age : 41
Location : UK

https://jnet.sytes.net

Back to top Go down

Create a symbolic link to another symbolic link on linux Empty Re: Create a symbolic link to another symbolic link on linux

Post by Sponsored content


Sponsored content


Back to top Go down

Back to top

- Similar topics

 
Permissions in this forum:
You cannot reply to topics in this forum