- Community Home
- >
- Servers and Operating Systems
- >
- Operating Systems
- >
- Operating System - Linux
- >
- Re: how copy a symlink ?
Categories
Company
Local Language
Forums
Discussions
Forums
- Data Protection and Retention
- Entry Storage Systems
- Legacy
- Midrange and Enterprise Storage
- Storage Networking
- HPE Nimble Storage
Discussions
Discussions
Discussions
Discussions
Forums
Forums
Discussions
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
- BladeSystem Infrastructure and Application Solutions
- Appliance Servers
- Alpha Servers
- BackOffice Products
- Internet Products
- HPE 9000 and HPE e3000 Servers
- Networking
- Netservers
- Secure OS Software for Linux
- Server Management (Insight Manager 7)
- Windows Server 2003
- Operating System - Tru64 Unix
- ProLiant Deployment and Provisioning
- Linux-Based Community / Regional
- Microsoft System Center Integration
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Community
Resources
Forums
Blogs
- Subscribe to RSS Feed
- Mark Topic as New
- Mark Topic as Read
- Float this Topic for Current User
- Bookmark
- Subscribe
- Printer Friendly Page
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО06-23-2006 01:32 AM
тАО06-23-2006 01:32 AM
I want to copy the file /lib/ld-linux.so.2 but it's not easy because it's a symlink.
The real problem is to automatically copy the target of this symlink (it's for chrooting).
ls -l gives me:
/lib/ld-linux.so.2 -> ld-2.3.4.so
in fact, i want to copy the target (ld-2.3.4.so) with the symlink (ld-linux.so.2).
how can i do that ?
help needed.
--
Cheers,
Cedrick Gaillard
Solved! Go to Solution.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО06-23-2006 01:49 AM
тАО06-23-2006 01:49 AM
Re: how copy a symlink ?
You can try cp -R the directoy in which the symlink is in. That should work. If it does not, you may need to re-create the link with the ln -s commmand.
SEP
Owner of ISN Corporation
http://isnamerica.com
http://hpuxconsulting.com
Sponsor: http://hpux.ws
Twitter: http://twitter.com/hpuxlinux
Founder http://newdatacloud.com
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО06-23-2006 02:02 AM
тАО06-23-2006 02:02 AM
Re: how copy a symlink ?
An example for useradd who returns the needed librairies who are symlink whith the real target:
root@toto ~]# ldd -v /usr/sbin/useradd |grep "=>" |awk -F"=>" '{print $2}' |awk '{print $1}' |sort -u |xargs ls -l|grep " -> " |awk '{print $9" "$11}'
/lib/ld-linux.so.2 ld-2.3.4.so
/lib/libaudit.so.0 libaudit.so.0.0.0
/lib/libcrypt.so.1 libcrypt-2.3.4.so
/lib/tls/libc.so.6 libc-2.3.4.so
i don't know how to use this result for concatenate the basename and the last field for integrates it in a script, i'm definitively not a guru ;)
--
Cheers,
Cedrick Gaillard
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО06-23-2006 05:23 AM
тАО06-23-2006 05:23 AM
Solution$ cat libs.sh
#!/bin/bash
for program in "$@"
do
echo "$program"
ldd -v "$program" | (
while read f
do
if [[ "$f" =~ ' => [^ ]' ]]
then
f="${f#?* => }"
f="${f% ?*}"
echo "$f"
while [[ -h "$f" ]]
do
dir="$(dirname "$f")"
f="$(readlink "$f")"
if [[ ! "$f" =~ '^/' ]]
then
f="$dir/$f"
fi
echo " $f"
done
fi
done
)
done
You can do the copy itself with "cp -d" to make a new symbolic link that matches a current one.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО06-24-2006 06:58 AM
тАО06-24-2006 06:58 AM
Re: how copy a symlink ?
your script is too complicated for my knowledge but the -f flag for readlink seems to be enough for what i want to do, very interesting parameter.
thanks again.
--
Cedrick Gaillard
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО06-25-2006 08:28 PM
тАО06-25-2006 08:28 PM
Re: how copy a symlink ?
# export bin2chr="/usr/sbin/adduser" homechr="/home/newroot"
# mkdir -p `dirname ${homechr}${bin2chr}`
# cp -av $bin2chr ${homechr}${bin2chr}
# for i in `ldd -v ${bin2chr} |grep "=>" |awk -F"=>" '{print $2}' |\
# awk '{print $1}' |sort -u`; do dirdest="${homechr}`readlink -f $i`"; \
# mkdir -p `dirname $dirdest`; cp -av `readlink -f $i` $dirdest; done
# for i in `ldd -v ${bin2chr} |grep "=>" |awk -F"=>" '{print $2}' |\
# awk '{print $1}' |sort -u`; do cp -av $i ${homechr}${i}; done
thanks the help you have gived me :)
--
Cheers,
Cedrick Gaillard