Tag Info

Hot answers tagged

69

You can create a symbolic link with the command line utility mklink. MKLINK [[/D] | [/H] | [/J]] Link Target /D Creates a directory symbolic link. Default is a file symbolic link. /H Creates a hard link instead of a symbolic link. /J Creates a Directory Junction. Link specifies the new ...


28

That works for me, what is the output of strace ln -f -s /var/www/html/releases/build1390 app-current ? Oh, since it is a directory you need to add -n for no dereference and this should solve the issue. -f is really more of a convenience since adding the -f just causes it to unlink anyways. Although I guess it would probably happen a few hundred ms faster ...


19

Hell yes. If you execute the ln -s you create a symbolic link, which is an inode pointing to a certain filesystem object, which is why symlinks can traverse filesystems and hard links cannot: hard links do not have their own inode. If you mount a filesystem with --bind, you create a second mountpoint for a device or filesystem. If you envision a symlink as ...


13

There's only one kind of symbolic link. The issue you're seeing with FTP is probably that the FTP server is restricted to a subtree of the filesystem (this is called a chroot jail), and a symbolic link pointing outside that subtree won't work. That's by design: the chroot jail is for security, and you mustn't be able to escape the jail by following a ...


9

I know this has been answered a while ago, but I was wondering the same thing and found this answer. The accepted answer is actually not quite correct. There are symbolic links to files and directories. There are hard links to files. "Hard links" to directories are called junctions. The thing is, they are not quite hard links. Microsoft calls them Soft ...


8

Windows 2000 and later allows for symbolic linking but refers to symbolic links as junctions. I do not believe you can make them easily without an additional tool, but you can find free tools for creating them. Free tool: http://technet.microsoft.com/en-us/sysinternals/bb896768.aspx KB Article on Junctions: http://support.microsoft.com/?kbid=205524


8

Two options: 1) Use Hard symlinks. Rsync doesn't need special flags to traverse these, because they look like part of the filesystem. - Of course, this only works on the same filesystem, which doesn't apply. 2) A bind mount. sudo mount -o bind /source /dest.


7

If you type set -P in bash all commands such as cd, pwd will follow the physical path. Else you can use cd -P and pwd -P for temporary changes to the default behavior. From the manpage of bash: -P If set, the shell does not follow symbolic links when executing commands such as cd that change the cur- rent working ...


7

Use mklink or junction from Sysinternals (Microsoft). I believe mklink will work in Windows 2000 and above, but I cannot find any hard documentation on that. junction is for Windows 2000 and above.


7

GNU find's manpage says that all POSIX finds are supposed to detect filesystem loops and emit error messages in these cases, and I have tested find . -follow -printf "" on GNU find, which was able to find loops of the form ./a -> ./b and ./b -> ./a printing the error find: `./a': Too many levels of symbolic links find: `./b': Too many levels of ...


6

ls doesn't care about the permissions of a file because it's only listing its directory entry. However, when ls dereferences a symbolic link, it is accessing the contents of the link. So it does care about the permissions of the link. Here you don't have the permission to read what the target of libodm10.dylib is unless you're in the dba group. You need to ...


6

Are you talking about MS-DOS or Windows XP? Since it's likely that you're just talking about doing this from a command-prompt on Windows XP I'll answer for that case first... >smile< On an NTFS volume under Windows XP you can use the "fsutil" tool to create a hard link: fsutil hardlink create <destination filename> <source filename> ...


6

readlink is the command you want. You should look at the man page for the command. Because if you want to follow a chain of symbolic links to the actual file, then you need the -e or -f switch: [kbrandt@kb: ~/scrap] ln -s foooooo zipzip #fooooo doesn't actually exist [kbrandt@kb: ...


6

You can simply shut down Postgres, move the folder over and change the init scripts to point to the correct location for the data directory. Double-check the configuration files under data/ for references to the old path before restarting the server. You probably don't want to do this. Really. It's a BAD idea. NFS's other name is the Network Failure ...


5

I noticed you add git as a tag--it sounds like /home/ubuntu/etc-config is a git repository with all your configs in it. In which case, it sounds like you're trying to manage configuration files from a central location. If that's the case, I highly recommend looking for a real solution. Take a look at something like puppet, chef, cfengine, or any of the ...


5

man readlink It can do the following part with the -e option $ mkdir testlink $ cd testlink pjb@pjb-desktop:~/testlink$ ln -s c b pjb@pjb-desktop:~/testlink$ ln -s b a pjb@pjb-desktop:~/testlink$ ls -l total 0 lrwxrwxrwx 1 pjb pjb 1 2010-02-23 08:48 a -> b lrwxrwxrwx 1 pjb pjb 1 2010-02-23 08:48 b -> c pjb@pjb-desktop:~/testlink$ echo foo > c ...


4

If you mean "Does the link actually point to a file?", (which I think you do because lthen: if [[ -e "$file" ]]; then echo it is there; fi If just want to test if the file is a symbolic link, than: if [[ -h "$file" ]]; then echo it is a link; fi This is tailored toward Bash, and not the most portable way. And as a little bit of trivia you don't need ...


4

If you are only soft symlinking directories - rather than files - then they should for the most part behave entirely transparently. The only issue that you may stumble across is some applications which resolve and then continue to refer to the real path of the link. Which can cause issues if you choose to change the source of the link at a later stage.


4

Didn't see this in any of the answers, but linkd.exe (in the Windows 2003 Resource kit here) allows you to create junctions, which pretty much function as a soft/hard link does in Linux. Junctions are available from Windows 2000 and up, so just copy linkd.exe to the target system and it should work.


4

Are you sure this is really what you want to do? There's a very good article on why this is a bad bad bad idea over at Joel on Software (see point #3)... Conclusion: the next time someone tries to sell you a programming product that lets you access network resources the same was as you access local resources, run full speed in the opposite ...


4

Unless you know the environment, never run "find /", run e.g. "find / /var /home -xdev". Parse the mount or df output for the list of filesystems. Otherwise NFS mounts could make your find take a VERY long time. In a reasonable environment, days or weeks is very possible. I've seen more than one reasonable system on which a "find /" could not be expected ...


4

You probably see the effect of symlink security hardening introduced since UbuntuĀ 10.10. This feature can be turned off through /proc/sys/kernel/yama/protected_sticky_symlinks. On Debian, this feature can be turned off by adding the following to /etc/sysctl.conf: fs.protected_symlinks = 0 Yet another variation on this theme is ...


4

You can use the bind option of mount to remount the other folder so the FTP server sees the files as being within the root of the website. I posted an answer to the same question on UbuntuForums.org. ...You could mount /home/shared/files/ under /home/website/files/ like this. Create a mount point ( a directory ) in /home/website mkdir ...


4

As Bron as said, there is no official way of doing it (more strongly: there cannot be one due to the filesystem design, you can only roll your own). This would be how I would script it in bash (assuming the current structure, the fgrep is too lenient to be used generally): # Current list of symlinks (will return build.3 and build.4 in this case) symed=`ls ...


4

How about this: IFS= no=1 for file in `find /Volumes/library/Originals -type f -name '*.jpg'`; do prefix=`basename $file .jpg` ln -s $file /image-links/$prefix$no.jpg no=$(($no + 1)) done Quick note: you have to unset the IFS variable because MacOS X loves spaces within directory and file names. IFS set to nil prevents the "for" loop from ...


4

GNU du has the --dereference option, which dereferences symbolic links when computing disk usage. However, du refuses to count the same space twice, which may be a deal-breaker in your situation: % mkdir foo bar baz % dd if=/dev/zero of=foo/test bs=1024 count=10000 10000+0 records in 10000+0 records out 10240000 bytes (10 MB) copied, 0.0176239 s, 581 MB/s ...


4

Yeah, it's called mklink. http://technet.microsoft.com/en-us/library/cc753194(v=ws.10).aspx Edit - to clarify. You have a target folder - the one that already exists and contains your content, one of your examples was D:\programa\ . You want to create a link to it - that link doesn't currently exist, and would be C:\allprograms\programa\ . mklink /d ...


4

It's likely the SFTP is being chrooted, so that the directory /var/www is not available to the user in the chroot jail. Look in /etc/ssh/sshd_config and examine the sftp directives. Do you see something like: Match group sftp ChrootDirectory /home/%u AllowTcpForwarding no ForceCommand internal-sftp The sshd_config man page is here. Basically, ...


3

There's at least one circumstance where you can't replace a junction point with a symlink: if the content might need to be accessed remotely. If you access a file share on a Windows machine, junction points are interpreted by the server and work as expected. Symbolic links are interpreted by the client (i.e., a symlink to c:\foo\bar would be interpreted as ...


3

Not so much a "proper" way, but how often are you doing it? My usual approach would be to run up a small piece of Perl (choose your own poison) which read the directory contents, examined the symlinks, and built a list of directories to delete. There's no metadata on the destination of a symlink that will tell you it's being linked to. You'll want to take ...



Only top voted, non community-wiki answers of a minimum length are eligible