Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

is there a way to see the actual contents of a symlink?

When you do

cat some-symlink-to-some-real-file 

it shows the contents of the real file, not what is within the symlink itself. Is there a way to see what's actually in it?

like image 273
fabio Avatar asked Jan 01 '11 00:01

fabio


People also ask

What is the content of a symlink?

A symbolic link is a special type of file whose contents are a string that is the pathname of another file, the file to which the link refers. (The contents of a symbolic link can be read using readlink(2).) In other words, a symbolic link is a pointer to another name, and not to an underlying object.

Can you edit a symlink?

No. The symlink system call will return EEXIST if newpath already exists. You can only link from a new node in the filesystem.

How do I check for broken symlinks?

3. Finding Broken Symlinks. The -H, -L and -P options control how symbolic links are treated, and when omitted, use -P as the default. When -P is used and find examines or prints information from a symbolic link, the details are taken from the properties of the symbolic link itself.


1 Answers

The ls -l command will show you that:

$ ls -l foo lrwxrwxrwx 1 user group 11 2010-12-31 19:49 foo -> /etc/passwd 

Or the readlink command:

$ readlink foo /etc/passwd 

So, the symbolic link foo points to the path /etc/passwd.

like image 130
PleaseStand Avatar answered Sep 21 '22 18:09

PleaseStand