Tag Info

New answers tagged

1

find . -lname filename will print symlink(s) pointing to a file. You can loop over the files, printing the links, those that do not have any links will be readily apparent for f in *; do echo $f has the following links $(find . -lname $f) done


1

I found solution: #!/bin/bash mkfifo /etc/z.conf ( while (true) do ssh x@y cat /etc/z.conf > /etc/z.conf done ) &


1

If you want to check whether $path is a symbolic link whose target is /some/where, you can use the readlink utility. It isn't POSIX, but it's available on many systems (GNU/Linux, BusyBox, *BSD, …). if [ "$(readlink -- "$path")" = /some/where ]; then … Note that this is an exact text comparison. If the target of the link is /some//where, or if it's ...


3

When links are put in /usr/bin or /usr/local/bin, this is often because the actual binary is living somewhere else. Why is it living somewhere else? Usually because it is a part of a group of files, often in its own subdirectory, which it depends on to run. Why can't all those files be dumped into /usr/bin or /usr/local/bin? Because those locations are only ...


4

The -i/--in-place flag edits a file in place. By default, sed does the (arguably) simplest possible thing and doesn't check if the file is a symlink, before reading from it, transforming, then truncating and writing. GNU sed has a --follow-symlinks flag, which makes it behave as you want with symlinks: $ echo "cat" > pet $ ln --symbolic pet pet_link $ ...


2

With GNU find (the implementation on non-embedded Linux and Cygwin): find /search/location -type l -xtype d With find implementations that lack the -xtype primary, you can use two invocations of find, one to filter symbolic links and one to filter the ones that point to directories: find /search/location -type l -exec sh -c 'find "$@" -L -type d -print' ...


1

Try: find /search/location -type l -exec test -e {} \; -print From man test: -e FILE FILE exists You might also benefit from this U&L answer to How can I find broken symlinks; be sure to read the comments too. Edit: test -d to check if "FILE exists and is a directory" find /search/location -type l -exec test -d {} \; -print


0

Here you go: for i in $(find /search/location -type l); do test -d $(readlink $i) && echo $i done


0

Assuming you want to create a: /home/kostas/test/dir/hello/link -> /home/kostas/file/to/link symlink (assuming /home/kostas is your current directory), but using a relative link, that is: /home/kostas/test/dir/hello/link -> ../../../file/to/link Then you could do (with GNU ln): $ current_path=test/dir/hello $ parent_file_to_lunk=file/to/link $ ...


1

Try parent_path=$(echo "$current_path"/ | sed -e "s|[^/]||g" -e "s|/|../|g") cd "${current_path}" ; ln -s "${parent_path}${parent_file_to_link}" This works simply by counting the slashes in "${current_path}".  The desired depth is one more than the number of slashes (e.g., the depth of test/dir/hello, which contains two slashes, is 3), so we simply add a ...


0

something like this should work file="/var/log/dmesg" ln -s $file $(dirname $file)/../


2

Shells keep track of symbolic links as a convenience for users. This has the nice effect that cd foo && cd .. always goes back to the original directory, even when foo is a symbolic link to a directory. It has two kinds of downsides: the main one is that other programs don't behave this way; additionally, symbolic directory tracking introduces ...


1

No, not really. You can test the by debug tracing your operation. Assuming you're on linux, that's strace. mkdir test1 ln -s test1 test2 strace -o strace1.log ls -l test1 strace -o strace2.log ls -l test2 Then diff your two logs. You'll see they're basically the same sequence of operations. They call lstat which is a version of stat that follows ...


2

It is because cp isn't playing the same link game your shell is. Your shell is tracking the links to the current working directory as an indirection to the current working directory, but the kernel doesn't want any of that nonsense when the shell goes to call up cp - rather the kernel will make the cp's current working directory a fully qualified absolute ...


0

The sys/types.h header belongs to glibc (or an alternative libc implementation if you are not using glibc). To get that header you should install the development package for glibc from your distribution. On debian 7, this package is libc6-dev. For ubuntu it is either libc6-dev-i386 (32bit) or libc6-dev-amd64 (64 bit). These names will likely work ...


0

Just symlink them (assuming you are doing it for your own development system). Ubuntu developers have gotten too clever for their own good. If you need to cross compile, obviously, you'll have another bridge to hack your way across. "Cleverly", my Mint 17.1 system has both /usr/include/c++ and /usr/include/x86_64-linux-gnu/c++. Even better, they are ...


0

From what I see -- You are trying to make some directory and then create a symbolic link to that directory ...... Just like how windows machines have the main program inside “Program Files” and an icon(aka...symbolic link in *nix world). To achive this you will need to simply do : =>> mkdir -p ~/home/folder/ "will make the directory for you ...


2

You can ask cp to create a so-called link tree for you: cp -al foo foo_0311 -a copies everything recursively, and -l creates hard links for files instead of copying them. If foo_0311 already exists then you should use cp -al foo/* foo_0311 instead. This creates hard links rather than symbolic links, so they don't appear with -> in the output of ls ...


0

Crude but effective: find / -warn -xdev -name "*" -type l -exec ls -l {} + | grep ' /tmp' (BTW, no matches at all on my system)


2

Assuming that FollowSymLinks is set correctly set, I suppose that the problem is that your home directory does not allow anyone else to traverse into it (Do the parent directory's permissions matter when accessing a subdirectory?). That's the default on Fedora; it looks like the default on Ubuntu is more permissive, which is why switching to that worked. ...


2

Verify symlinks are enabled inside apache itself. Apache doesn't necessarily allow for symlink redirection, even when permissions are fine. <Directory /var/www/myapp> Options +FollowSymLinks AllowOverride All ... </Directory>


0

Normally, a symbolic link is inert: it can store any sequence of bytes (except null bytes, and only up to a certain length). When creating a symbolic link, it is irrelevant whether the content happens to point to an existing file. It's only when accessing the symbolic link that the existence of the target matters. So what you're seeing on your VPS is ...


1

If I understand your question correctly you need to use realpath with -s: -s, --strip Only strip . and .., components, but do not resolve symbolic links. $ realpath -s a/b/c /tmp/a/b/c $ readlink a/b/c s


2

It is possible to copy relative symlinks using --links option: -l, --links When symlinks are encountered, recreate the symlink on the destination. Also: Note that --archive implies --links. Example: $ mkdir /tmp/tarsnap-test/ $ cd /tmp/tarsnap-test/ $ mkdir orig backup $ cd orig/ $ mkdir dir $ ln -s dir symlink $ ll total ...


1

I heard that symlinks can't be edited. So do I have to create new symlinks and then overwrite the existing ones? Symlinks can't be edited, that is correct. You can replace symlinks to files in a single operation with the -f option to ln, and if you add -T you can process symlinks to directories in the same way: ln -sfT /data/Tim/dir1 symlink1 will ...


0

Advantage 1 of sym-link (transparency): Only management software has to know of the existence of sym-links. They just work. Shortcuts only work if the software trying to open them knows that they are a short cut. Advantage 2 of sys-link (chainable): A sym-link will allow a link to a link to a link … 3: They are often stored in the inode (this may not ...



Top 50 recent answers are included