Shell – How to tell if a folder is actually a symlink and how to fix it if it’s broken

linuxshellsymlink

How do I tell if I have a symlink, a shortcut of some sort, or a folder in Linux? Please see following screenshot.

symbolic link in linux shell

As you can see, the ls command lists objects where some are colored in dark blue while others are colored light blue (cyan). What are these cyan colored objects? Are these actual symbolic links?

As you can see, I cannot cd to the one called hdd.

root@dm500hd:/# cd hdd
-sh: cd: can't cd to hdd

I think it has to redirect to /media/hdd and I have noticed that the hdd folder is missing.

Is there a way to fix this?

Update: Here are results of the ls -al command.

symbolic link in linux shell 2

As you can see it says hdd -> /media/hdd and it's colored in red. Does this mean that it's broken or that it is automounted, i.e. when a physical hdd is connected?

Update: Here is result of the grep media /etc/auto* command.

symbolic link in linux shell 3

What do these /etc/auto.master:/media/net and /etc/auto.network entries do?

Here are results of ls -Fal /media command.

symbolic link in linux shell 4

Is this of any help?…

Here are results of stat and file commands, as well as listings of /usr and /bin.

symbolic link in linux shell 5

Does this help me in any way?… does it help you help me?…

As a side not, what you should know is that this is a Linux based STB with BusyBox, it's an embedded system. So not all commands might be supported.

Update: Last screenshot, showing files and supported commands in /sbin and /usr/sbin.

symbolic link in linux shell 6

Update: New share added…

I have now removed that old share and recreated one with the same name as before and also added a second share now. So now I have two of them.

SHARES
remote share   local share
mydream        dream1
mydream2       dream2

LOCATIONS
remote        local
C:\mydream    /media/net/dream1
C:\mydream2   /media/net/dream2

The recordings are placed in /media/net/dream1/movie.

Also, for the share dream2 I have chosen not to mount it as a HDD replacement in the Mount Manager, as I suspect that it's not possible to have more than one act as a HDD. Where would it record? To both locations? With double the data rate?… I don't think it's possible.

So for this reason there is no subfolder named movie for the dream2 share. Only the ones that are specified as HDD replacement when created get the movie subfolder.

If I cd to hdd from root it goes to /media/net/dream1.
If I cd to .. (parent) it goes back to root (/).

At root
ls -al gives hdd -> media/hdd.
ls -al hdd gives hdd -> media/hdd.
ls -al media gives /media/net/dream1.

Also, if I cd to /media there is another hdd symlink. I have not noticed it before. I think this is created automatically when a share is mounted. And if I cd to this hdd it goes to /media/net/dream1.

A symlink hdd (/hdd) that points to another hdd symlink (/media/hdd), which in turn points to the share folder (/media/net/dream1)?….. I'm getting dizzy…

It was not like this before version 3.2.3 or at least 3.2.0 of the Enigma2 image.

Edit: By settings the second share to act as a HDD replacement it becomes the active share for recording. At the same time the share that was previously set to act as a HDD replacement is no longer active, even if it is still set to "yes" (act as HDD replacement).

If dream1 was first used as HDD replacement ("yes" to act as replacement) and then dream2 is set to act as HDD replacement, it becomes the new share for recording. I can still see and view video files stored in dream1 but I can no longer record to it. If I want to go back to use dream1 for recording I first have to set dream2 to "no" (stop acting as HDD replacement) and then reset dream1 to "yes".

So no, it cannot record to two shares at the same time. One of them has to go. So it's either dream1 or dream2, not both. Although I should mention that it's possible to record more than one service (tv channel) if they are both on the same transponder, if not you get the "no free tuner" message. This is a STB with only one tuner.

Best Answer

You can use file, stat or ls.

file:

The file command is used to classify files based on their type (symlink, directory, device) or content (text, gzip, image, tar, ..., regardless of their extension):

$ file /dev/stdout
/dev/stdout: symbolic link to `/proc/self/fd/1'
$ file /proc/self/fd/1
/proc/self/fd/1: symbolic link to `/dev/pts/0'
$ file /dev/pts/0
/dev/pts/0: character special (136/0)
$ file /etc/passwd
/etc/passwd: ASCII text

ls:

$ ls -al /dev/stdout
lrwxrwxrwx 1 root root 15 Jan 27 07:55 /dev/stdout -> /proc/self/fd/1

stat:

the stat command prints out file metadata like permissions, size, number of blocks and so on...

$ stat /dev/stdout
  File: ‘/dev/stdout’ -> ‘/proc/self/fd/1’
  Size: 15          Blocks: 0          IO Block: 4096   symbolic link
Device: 5h/5d   Inode: 1212        Links: 1
Access: (0777/lrwxrwxrwx)  Uid: (    0/    root)   Gid: (    0/    root)
Access: 2014-01-27 11:22:47.971187828 -0200
Modify: 2014-01-27 07:55:13.996981285 -0200
Change: 2014-01-27 07:55:13.996981285 -0200
 Birth: -
Related Question