Click to See Complete Forum and Search --> : command to see where a symlink points?


coax
06-22-2001, 08:45 PM
I guess it's time I started asking some Questions.. Probably alot of simple stuff..

I figured out that in Konquerer I can highlight a symlink & see what it points to, but is there a command to use in the shell to do the same?

DMR
06-22-2001, 08:50 PM
Use the -l option with the ls command:ls -l <name of symlink>

Space Boy
06-22-2001, 08:52 PM
I believe ll or ls -l will do the trick. These commands are similar to ls, they list all the files in the directory, only they provide more information.

aarron

coax
06-22-2001, 09:57 PM
Thanks guys. I'm writing those in my notebook. :)

I am trying to figure out why my nvidia video drivers messed up (gonna post another thread). And it seems there might be another way to do it?

I just read where someone in another thread said to type in:

file /path/filename

I tried:

file /etc/X11/X

& it returned:

/etc/X11/X: symbolic link to ../../usr/X11R6/bin/XF86_SVGA

I also tried on a different symlink & it worked on that link too.

Kickass! This is fun. 8-)

Especially jammin' with XMMS while trying to figure it out.. Oh yea...

lsibn
06-23-2001, 11:18 AM
Originally posted by Space Boy:
<STRONG>I believe ll or ls -l will do the trick. These commands are similar to ls, they list all the files in the directory, only they provide more information.

aarron</STRONG>
ll is a common (though not actually standard) alias built into some distributions. When you run ll, it's really an alias for 'ls $LS_OPTIONS -l' (at least on my box).

Because it uses $LS_OPTIONS, you can enter `eval dircolors` (with the backticks) and use ll to get ls in color, if it isn't already. Your mileage may vary, because it depends on a few other things (for example, you might be using an xterm that doesn't support color).

Edit: My bad. It's not $LS_OPTIONS, it's --color=auto. :(

[ 23 June 2001: Message edited by: lsibn ]

coax
06-23-2001, 11:37 AM
What is the difference between an alias & a symlink?

lsibn: I like your sig. I'm gonna try to keep that in mind myself from now on. ;)

lsibn
06-23-2001, 11:53 AM
Originally posted by coax:
<STRONG>What is the difference between an alias & a symlink?

lsibn: I like your sig. I'm gonna try to keep that in mind myself from now on. ;)</STRONG>
An alias is another way of looking at a program, kind of. You only have one ls command, but you can alias it many ways. You can also change default behavior of a program with it. For example, if you copy one file over another, it will do it without asking. Unless you run 'cp -i file1 file2' where file 2 already exists. Chances are, you don't want to have to type a -i every time you do this, so a common alias for root is to set it to use -i automatically.

alias cp='cp -i'

then, whenever you type cp, it substitutes it for 'cp -i'. Another of my favorite aliases would be crontab='crontab -e' so I can edit my crontab just by running crontab.

A symlink is a file pointing to a file. An alias is a "temporary command" pointing to a file.

You can see what aliases you're using by running alias or alias -p.

You can create new ones by using:
alias aliasname='command to execute'

coax
06-23-2001, 11:59 AM
Got it!!! Now I've just learned a few more commands. Er, aliases I can use. :)

Thanks.

lsibn
06-23-2001, 12:04 PM
Originally posted by coax:
<STRONG>Got it!!! Now I've just learned a few more commands. Er, aliases I can use. :)

Thanks.</STRONG>
Oh, btw, if you put the alias in ~/.bashrc or ~/.profile, it will alias itself when you login. If you put it in .bashrc, it should work in the next terminal you open. If you put it in .profile, you'll have to logout and login again.

Be sure to put it in exactly like you'd type it on the command line, though.

Ah, and probably a better way to describe aliases is simply by calling programs by different names. If you've used DOS, cls clears the screen. In *nix, it's 'clear.' So you could run alias cls='clear' to make it clear the screen (in a terminal of some kind) whenever you run cls.

coax
06-23-2001, 12:13 PM
Originally posted by lsibn:
<STRONG>Oh, btw, if you put the alias in ~/.bashrc or ~/.profile, it will alias itself when you login. If you put it in .bashrc, it should work in the next terminal you open. If you put it in .profile, you'll have to logout and login again.

Be sure to put it in exactly like you'd type it on the command line, though.

</STRONG>

Ok. I typed in:

alias cls=clear

at the command prompt.

I looked in the file ~/.bashrc & didn't see it in there.

And I didn't find the file ~/.profile.

Where would the file .profile be?

I guess it would be better to edit the file .bashrc & put it in there anyway though?

Just want to make sure I'm on the right track.

coax
06-23-2001, 12:22 PM
Ok, I found it. It's called .bash_profile.

But it would still be better to put the alias in the .bashrc file anyway though right?

[Edit] Also, I was just looking at your syntax. I didn't notice/use the ' when I edited the .bashrc file & added the alias cls=clear.

Do I need those? It seems to work ok but I wanna make sure I'm doing it right.

[ 23 June 2001: Message edited by: coax ]

lsibn
06-23-2001, 12:42 PM
Originally posted by coax:
<STRONG>Ok, I found it. It's called .bash_profile.

But it would still be better to put the alias in the .bashrc file anyway though right?

[Edit] Also, I was just looking at your syntax. I didn't notice/use the ' when I edited the .bashrc file & added the alias cls=clear.

Do I need those? It seems to work ok but I wanna make sure I'm doing it right.

[ 23 June 2001: Message edited by: coax ]</STRONG>
It might be easier to put them in .bashrc, but .bashrc will be run EVERY time you open a new terminal. .bash_profile is run only when you first login. As a result, if you put it in .bash_login, logout and login again. It should work by itself from then on. If you put it in .bashrc, you won't have to logout and login again, BUT it'll slow you down (just a very small amount) with every new shell. Because the shell has to run it every time instead of just the once.

And it's a good idea to include the ' marks with an alias command='run me', because it helps to avoid problems. In the case of cls=clear, it probably wouldn't make a difference. But I'd do it just to be safe, anyway.

coax
06-23-2001, 12:46 PM
Excellent! I really appreciate your help & feel like I've learned alot this morning. :)

bdg1983
06-23-2001, 06:32 PM
You could also have a read of the BASH Command (http://www.linuxnewbie.org/nhf/intel/shells/bashconfig.html) NHF. It even has a secion on 'alias'.

Craig McPherson
06-25-2001, 06:25 AM
Aliases are handled entirely by the shell, and vary from shell to shell. Each running shell keeps its own list of aliases, and they have no existence outside of the shell. The "alias" command itself isn't actually a program, it's a builtin function of the bash shell.

As for the bash login scripts: ~/.profile, ~/.bashrc, and ~/.bash_profile all do the same thing. You really should pick one and just use it (I like .profile), because some won't run if some of the others exist, and you never can be sure what order they'll run in.