symlink interview questions
Top symlink frequently asked interview questions
Can Powershell 1.0 create hard and soft links analogous to the unix variety? If this isn't built in, can someone point me to a site that has a ps1 script that mimics this? This is a nessary function of any good shell, IMHO. :)
Source: (StackOverflow)
Hallo all, I need to do this in linux:
- Given: file name 'foo.txt'
- Find: all files that are symbolic links to 'foo.txt'
How to do it? Thanks!
Source: (StackOverflow)
Is there a single way of detecting if a directory/file/symlink or.... entity (more generalized) exists?
I need a single function because I need to check an array of paths that could be directories, files or symlinks. I know File.exists?"file_path"
works for directories and files but not for symlinks (which is File.symlink?"symlink_path"
).
Source: (StackOverflow)
I have a symlink to an important directory. I want to get rid of that symlink, while keeping the directory behind it.
I tried rm
and get back rm: cannot remove 'foo'
.
I tried rmdir
and got back rmdir: failed to remove 'foo': Directory not empty
I then progressed through rm -f
, rm -rf
and sudo rm -rf
Then I went to find my back-ups.
Is there a way to get rid of the symlink with out throwing away the baby with the bathwater?
Source: (StackOverflow)
Below is my code for creating a symlink of a directory:
sudo ln -s /usr/local/nginx/conf/ /etc/nginx
I already created the directory /etc/nginx
. I just want the contents of the source directory (conf) to be in the contents of the target directory (nginx). But when I execute the code, /etc/nginx
contains a directory called "conf", instead of the contents of "conf". That directory contains the contents I want, but in the wrong location.
So, why did it put a directory in the target folder, instead of just putting the contents of the directory in the target folder?
Source: (StackOverflow)
I have been trying to set up some symbolic links in the Terminal, and haven't been able to get them to work.
In trying to find what I was doing wrong, I compared their function to the "create alias" button in the right click menu.
My question is this: what is the difference between alias(es) and symbolic links in Mac OS X?
Source: (StackOverflow)
If I have a file or directory that is a symbolic link and I commit it to a git repo what happens to it?
I would assume that it leaves it as a symbolic link until the file is deleted and then if you pull the file back from an old version it just creates a normal file.
What does it do when I delete the file it references? Does it just commit the dangling link?
Source: (StackOverflow)
I want to make a symbolic link in Linux. I have written this bash command where the first path is the folder I want link into and the second path is the compiled source.
ln -s '+basebuild+'/IpDome-kernel/kernel /home/build/sandbox/gen2/basebuild/IpDome-kernel/kernal
Is this correct?
Source: (StackOverflow)
So I created a symlink:
ln -s /location/to/link linkname
Now I want to change the location that the symlink links to. How do I do that? is there a way to do it without deleting it first?
Source: (StackOverflow)
I have a problem when installing npm modules. NodeJS is installed on Ubuntu 11.10 running on Virtual Box on Windows host. My project files are on NTFS partition (I have to share them with windows). When I try to install some npm module I get an error, and module is not installed. I've found out that problem occurs when npm tries to create symbolic links.
Probably you can not create symlinks on NTFS partition, when I'm installing module "inside" Linux file system, everything works fine.
How can I fix this? I don't want to resolve dependencies manually :/
Source: (StackOverflow)
I run find
and iterate through the results with [ \( -L $F \) ]
to collect certain symbolic links.
I am wondering if there is an easy way to determine if the link is broken in this scenario.
Here is my code:
FILES=`find /target/ | grep -v '\.disabled$' | sort`
for F in $FILES; do
if [ -L $F ]; then
DO THINGS
fi
done
Source: (StackOverflow)
I'm trying to check if a symlink exists in bash. Here's what I've tried.
mda=/usr/mda
if [ ! -L $mda ]; then
echo "=> File doesn't exist"
fi
mda='/usr/mda'
if [ ! -L $mda ]; then
echo "=> File doesn't exist"
fi
However, that doesn't work.
If '!' is left out, it never triggers. And if '!' is there, it triggers every time.
Source: (StackOverflow)
How can I take any given path in bash
and convert it to it's canonical form, dereferencing any symbolic links that may be contained within the path?
For example:
~$ mkdir /tmp/symtest
~$ cd /tmp/symtest/
/tmp/symtest$ mkdir -p foo/bar cat/dog
/tmp/symtest$ cd foo/bar/
/tmp/symtest/foo/bar$ ln -s ../../cat cat
/tmp/symtest/foo/bat$ cd ../../
/tmp/symtest$ tree
.
|-- cat
| `-- dog
`-- foo
`-- bar
`-- cat -> ../../cat
6 directories, 0 files
How can I get the full canonical path of /tmp/symtest/foo/bar/cat
(i.e: /tmp/symtest/cat
)?
Source: (StackOverflow)
Recently I was asked this during a job interview. I was honest and said I knew how a symbolic link behaves and how to create one, but do not understand the use of a hard link and how it differs from a symbolic one.
Source: (StackOverflow)
when i give
ls -l /etc/fonts/conf.d/70-yes-bitmaps.conf
lrwxrwxrwx <snip> /etc/fonts/conf.d/70-yes-bitmaps.conf -> ../conf.avail/70-yes-bitmaps.conf
so for a symbolic link or soft link, how to find the target file's full(absolute path) in python,
If i use
os.readlink('/etc/fonts/conf.d/70-yes-bitmaps.conf')
it outputs
../conf.avail/70-yes-bitmaps.conf
but i need the absolute path not the relative path, so my desired output must be,
/etc/fonts/conf.avail/70-yes-bitmaps.conf
how to replace the ..
with the actual full path of the parent directory of the symbolic link or soft link file.
Source: (StackOverflow)