LinuxQuestions.org
Review your favorite Linux distribution.
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Newbie
User Name
Password
Linux - Newbie This Linux forum is for members that are new to Linux.
Just starting out and have a question? If it is not in the man pages or the how-to's this is the place!

Notices


Reply
  Search this Thread
Old 06-18-2003, 04:08 PM   #1
jlaruffa
LQ Newbie
 
Registered: Jun 2003
Posts: 5

Rep: Reputation: 0
ls -laL command for Symbolic Link


I have a file in a directory, /home/map/.profile, and this file is a symbolic link to another file.

When i type ls -laL I get:
-rwxr-x--- 44 root sb 258 Jun 18 11:58 .profile

Under Unix, I would get information that tells me where the file really lives.

How do I find this out under Linux? I can tell by the 44 that it is a symbolic link but I don't know where it really is.

Thanks,
Jim

Red Hat Linux
 
Old 06-18-2003, 04:37 PM   #2
ranger_nemo
Senior Member
 
Registered: Feb 2003
Location: N'rn WI -- USA
Distribution: Kubuntu 8.04, ClarkConnect 4
Posts: 1,142

Rep: Reputation: 47
The L option shows info about the file the link points to, not about the link itself. Run it without the L, and you'll get what you want.

I have a ~/mnt with links to the mount points in /mnt...
Code:
[nemo@xxxxx mnt]$ ls
cdrom  floppy  usb

[nemo@xxxxx mnt]$ ls -laL
total 20
drwxrwxr-x    2 nemo     nemo         4096 May 14 16:51 .
drwx------   33 nemo     nemo         4096 Jun 18 16:25 ..
drwxr-xr-x    2 root     root         4096 Apr  5 15:23 cdrom
drwxr-xr-x    2 root     root         4096 Apr  5 15:23 floppy
drwxr-xr-x    2 root     root         4096 Apr  5 20:35 usb

[nemo@xxxxx mnt]$ ls -la
total 8
drwxrwxr-x    2 nemo     nemo         4096 May 14 16:51 .
drwx------   33 nemo     nemo         4096 Jun 18 16:25 ..
lrwxrwxrwx    1 nemo     nemo           10 May 14 16:51 cdrom -> /mnt/cdrom
lrwxrwxrwx    1 nemo     nemo           11 May 14 16:51 floppy -> /mnt/floppy
lrwxrwxrwx    1 nemo     nemo            8 May 14 16:51 usb -> /mnt/usb
 
Old 06-19-2003, 08:02 AM   #3
jlaruffa
LQ Newbie
 
Registered: Jun 2003
Posts: 5

Original Poster
Rep: Reputation: 0
Thanks for the reply.

Maybe its not a link. Here is the output:

root@acct01 two]# ls -la
total 32
drwx------ 2 two sb 4096 Nov 19 2002 .
drwxr-xr-x 53 root root 4096 Jun 18 11:58 ..
-rw-r--r-- 1 two sb 24 Nov 19 2002 .bash_logout
-rw-r--r-- 1 two sb 191 Nov 19 2002 .bash_profile
-rw-r--r-- 1 two sb 124 Nov 19 2002 .bashrc
-rw-r--r-- 1 two sb 820 Nov 19 2002 .emacs
-rwxr-x--- 44 root sb 258 Jun 18 11:58 .profile
-rw-r--r-- 1 two sb 3511 Nov 19 2002 .screenrc
[root@acct01 two]# pwd
/home/two


The file .profile does not really live in the directory /home/two. It's the same file under every /home/ subdirectory.

I was hoping to see .profile with the -> to tell me where it really is.

Thanks,
Jim
 
Old 06-19-2003, 11:07 AM   #4
moses
Senior Member
 
Registered: Sep 2002
Location: Arizona, US, Earth
Distribution: Slackware, (Non-Linux: Solaris 7,8,9; OSX; BeOS)
Posts: 1,152

Rep: Reputation: 50
If it's a hard link, it won't point to anywhere, since it actually shares the same inode and is, in fact, the same file as the one in /home/* (a file with multiple hard links will not be deleted until the last name is removed -- a file can have many names). The 44 tells you that this file actually has 44 names. . .
(man ln, man ls)
You could find all instances of the file by using find or locate. . .

Last edited by moses; 06-19-2003 at 11:10 AM.
 
Old 06-19-2003, 12:36 PM   #5
jlaruffa
LQ Newbie
 
Registered: Jun 2003
Posts: 5

Original Poster
Rep: Reputation: 0
Moses,
Thanks for the reply.

I tried locate .profile and it shows all of the paths, but some of the .profile files are local, and some are part of the linked 44.

/home/coe/.profile
/home/bas/.profile
/home/cyb/.profile
/home/kek/.profile
/home/ril/.profile
/home/dob/.profile
/home/anm/.profile
/home/ttt/.profile
/u1/uv/sample/.profile
/u1/uv/sample/?.profile
/u1/uv/.profile
/u1/sbplus/SB+/.profile
/u1/sbplus/SBDEMO/.profile

Is there any way to just display the ones that are linked?
 
Old 06-20-2003, 03:07 AM   #6
moses
Senior Member
 
Registered: Sep 2002
Location: Arizona, US, Earth
Distribution: Slackware, (Non-Linux: Solaris 7,8,9; OSX; BeOS)
Posts: 1,152

Rep: Reputation: 50
You might try the find command with the -links option (man find). You could probably do something like this:
Code:
find / -name .profile -links 44
If you KNOW all the files are under /home (there may be some in /etc), then you can limit the search to just /home (find /home -name . . .).
 
Old 06-20-2003, 08:26 AM   #7
jlaruffa
LQ Newbie
 
Registered: Jun 2003
Posts: 5

Original Poster
Rep: Reputation: 0
That did it! Thanks Moses..

Jim

 
Old 06-22-2003, 12:37 PM   #8
sriny_81
LQ Newbie
 
Registered: Jun 2003
Posts: 4

Rep: Reputation: 0
.profile is the scripts which is executed when u log in.. it will be in ur home directory itself(to chk home dir : at shell prompt type : echo $HOME or chk 6th field in '/etc/passwd' to know ur home dir"
 
  


Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
What is a Symbolic Link? little_penguin Linux - Software 2 05-14-2005 09:27 AM
Symbolic link? jasone Linux - Newbie 4 05-06-2005 07:55 AM
symbolic link jsetter Linux - Newbie 4 11-22-2004 07:18 AM
When referencing a command, how far in depth can the symbolic link be followed? davidas Debian 2 04-12-2004 06:09 AM
Linux tar command with symbolic link bug? LinuxQuest01 Linux - General 3 02-07-2003 05:46 PM

LinuxQuestions.org > Forums > Linux Forums > Linux - Newbie

All times are GMT -5. The time now is 03:13 AM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration