Tag Info

New answers tagged

0

Quoting an answer by esmail at askubuntu, this should work the same on elementary OS too: I'm currently storing the sub-folders of my home (e.g. ~/Documents, ~/Music) on an NTFS filesystem and it appears to be working fine a few months in. As an example, here's how to host your ~/Documents in your Windows profile folders on an NTFS partition: ...


0

In addition to solutions using Perl I decided to try to implement my own mini version readlink using readlink syscall. The source code of the utility using is very simple and looks like this: ret_length = readlink( argv[1], buffer, buffer_size ); if( ret_length >= 0 ) { buffer[ ret_length ] = '\0'; printf( "%s\n", buffer ); return 0; } ...


4

I can provide you with a perl snippet to do this for you: #!/usr/bin/perl # foreach my $i (@ARGV) { # If it is a symlink then... -l $i and do { # First indirection; ensure that it exists and is not a link my $j = readlink($i); print "$i\n" if -e $j and ! -l $j } } If you save that as /usr/local/bin/if-link and make it ...


4

/proc/<pid>/exe does not follow the normal semantics for symbolic links. Technically this might count as a violation of POSIX, but /proc is a special filesystem after all. /proc/<pid>/exe appears to be a symlink when you stat it. This is a convenient way for the kernel to export the pathname it knows for the process' executable. But when you ...


1

According to the man page of /proc, under Linux 2.2 and later, the file is a symbolic link containing the actual pathname of the executed command. Apparently, the binary is loaded into memory, and /proc/[pid]/exe points to the content of the binary in memory. On the other hand, under Linux 2.0 and earlier, /proc/[pid]/exe is apparently a pointer to the file ...


0

So /var/www/public_html is actually as Windows folder, but /var/www/data is not?  You're trying to create a symbolic link from a Windows directory into a Ubuntu directory in a virtual machine.  There's no way that Windows can support an object like that.


6

Other answers have covered /bin/pwd vs the shell's builtin pwd. If you want to follow symlinks in the Windows style you mentioned, use cd -P: it will change the PWD variable accordingly. If you want to use -P by default, you can add this line to your .bashrc or .zshrc: set -P Other shells may vary.


1

You can try a couple of find commands like this: mkdir FULL-PATH-TO-COPY cd SOURCE find . \( ! -regex '\.' \) -type d -exec mkdir FULL-PATH-TO-COPY/{} \; find * -type f -exec ln -s `pwd`/{} FULL-PATH-TO-COPY/{} \;


6

Contrast pwd and /bin/pwd. pwd, which is a built-in command in many shells, tells you where your shell thinks you are (and hence treats symlinks "soft links" as if they were real directories. /bin/pwd is an external program that tells you where you really are, if necessary by traversing the filesystem tree up to /. It takes no account of symlinks because ...


13

That is a feature of the shell that remembers how you got to where you are. If you have realpath installed you can do: $ realpath /home/dazz/test/1 And lacking that if you have python: $ python -c "import os; print(os.path.realpath('.'))" /home/dazz/test/1 or readlink (from coreutils): $ readlink -f . /home/dazz/test/1 or /bin/pwd (not the shell ...


3

Here's the solution on non-embedded Linux and Cygwin: cp -as SOURCE COPY


0

Something like this will do what you need. #!/bin/bash # SOURCE="$1" COPY="$2" cd "$SOURCE" find . | sed 's!^\./!!' | while IFS= read ITEM do test -d "$ITEM" && { mkdir -p "$COPY/$ITEM"; continue } BASE="${FILE%\/*}" ( cd "$COPY/$BASE" && ln -s "$SOURCE/$ITEM" ) done Directories are created in the ...


0

I would start by breaking out the perl: #!/usr/bin/perl use strict; use warnings; use File::Find; my $src_dir = "/full_path/to/dir"; my $tgt_dir = "/path/to/new/location"; sub link_or_mkdir { #current file is directory if (-d) { #extract the path my $newpath = $File::Find::dir; #change the path so 'old' and 'new' are ...


0

If there are not empty dirs in SOURCE which need to be copied find /full/path/to/SOURCE -type f -exec cp -t COPY --parents -s {} + mv COPY/full/path/to/SOURCE COPY rm -r COPY/full


0

It seems you are looking for something like the tool rsnapshot; it creates copies of arbitrary directories and uses hardlinks where possible. (Have a look at the man page to see whether that fits.)


9

You can do this with systemd, so you don't have to install extra software and just have a small amount of extra configuration. Simply add noauto,x-systemd.automount to the options in fstab. noauto to not mount automatically on boot and x-systemd.automount to let systemd mount it on access. Source: ArchWiki - fstab


17

autofs can do this for you. You can configure any number of mountpoints with various options, and the corresponding filesystems are mounted whenever the mountpoint is accessed. After a given amount of inactivity the filesystems are unmounted again. There are no doubt various ways of using autofs, but here's one way of doing what you're trying to do, based ...


4

The first problem is that your find command will only find links that used full paths, not relative ones. To illustrate: $ ln -s /home/terdon/foo/NonExistantFile foo $ ln -s NonExistantFile bar $ tree . |-- bar -> NonExistantFile `-- foo -> /home/terdon/foo/NonExistantFile In the example above, I created two broken links. The first used an absolute ...


1

As pointed out by Stéphane Chazelas, file modes cover two different notions, file types and file permissions. A file's mode is represented by the value of st_mode in the result of stat(2) calls, and ls -l presents them all together; see Understanding UNIX permissions and their attributes for details. Once a file is created its type can't be changed. In ...


0

A symlink (though some filesystems handle symlinks differently) is an inode table entry that points to the same place as another file (or directory). For example if foo is inode 1234 then bar (a symlink to foo) is inode 1234. bar doesn't really exist it's just a pointer to a "real" file. Symlinks generally don't have permissions outside the permissions ...


1

I think your confusing mount points and filesystem semantics. The answer is yes though. Symbolism has nothing to do with file systems or mount points. See http://en.m.wikipedia.org/wiki/Symbolic_link


1

Sure can, unless target/source filesystem do support soft links.



Top 50 recent answers are included