...making Linux just a little more fun!

<-- 2c Tips | TAG Index | 1 | 2 | 3 | 4 | Knowledge Base -->

The Answer Gang

By Jim Dennis, Jason Creighton, Chris G, Karl-Heinz, and... (meet the Gang) ... the Editors of Linux Gazette... and You!



(?) LN -- have I gone brain dead?

From Bob van der Poel

Answered By: Breen Mullins, Thomas Adam, Ben Okopnik

I'm trying to do something pretty simple, I thought, and am near the "tear out my hair" stage ... All I want to do is to create a symbolic link to an existing directory:

bob$ ln -s tmp foo
bob$ ls -l foo
lrwxrwxrwx  1 bob bob 3 Dec  1 15:21 foo -> tmp/

No, foo is not a link to tmp. Well, it sort of is:

bob$ file foo
foo: symbolic link to `tmp'

But,

bob$ ls foo
foo@
(!) [Breen] It looks like you're somehow passing -F -d to the ls command. What does 'alias ls' tell you?

(?) Oh, that was easy! Here I've been struggling trying to get the *&*(^ ln command to work and it was working all along! Yup, ls was aliased:

alias ls
alias ls='ls -F --color=auto'

Guess how quickly I'm going to fix that! Dumb, dumb, dumb. Don't know who .. the packager who snuck in the -F or me :)

(!) [Breen] Moral: always check for aliases.
(!) [Ben] For some of us - those who have their "mv", "cp", and "rm" aliased to automatically use "-i", for example - it's the automatic response (sticking, say, 'rm' into a 'for' loop doesn't work too well if you're going to get asked "Are you sure?" for a couple hundred files.) However, there's other stuff of this ilk in shells that can really drive you nuts. In the past, I've been tripped up by looking for programs that didn't exist (they turned out to be functions that the sysadmin put in /etc/profile), have been driven almost insane by CDPATH ('cd foo' would go to '/usr/local/foo/bar/zotz/qux/argle/bargle/will/this/never/end/foo' instead of ./foo), and have become Quite Annoyed by per-directory source files - although '.exrc' isn't really a shell-related gadget. But still. :)
The Daemons of Unix are wily, subtle, and enjoy sucking out your brains through your ears if you let them. They're also a very strange shade of mauve with green dots, so avoid the psychedelic drugs and all will be well. Intoxicants and computing do NOT mix well... remember, never drink and derive.
(!) [Breen] Fedora Core 3 (in a fit of complete brain-death) shipped with vi unconditionally aliased to /usr/bin/vim.
(!) [Ben] Gaah! I've run into similar idiot's handiwork on a Solaris system - although, to be fair, it was the local sysadmin who perpetrated this one. He had set root's $SHELL to "/usr/bin/bash" - 'cause, y'know, "sh" is just so annoying (and .profile is just some stupid thing that nobody ever uses anyway, right?) The, one fine morning, the "/usr" slice failed to mount...
(!) [Breen] I've just taken another look at this -- at some point Fedora fixed the bug. /etc/profile.d/vim.sh now looks like this:
if [ -n "$BASH_VERSION" -o -n "$KSH_VERSION" -o -n "$ZSH_VERSION" ];
then
 [ -x /usr/bin/id ] || return
 [ `/usr/bin/id -u` -le 100 ] && return
 # for bash and zsh, only if no alias is already set
 alias vi >/dev/null 2>&1 || alias vi=vim
fi
which is much more reasonable behavior. As originally shipped the two tests after then were missing.
(!) [Breen] Which doesn't matter much until you're trying to repair a system which doesn't have /usr/ mounted (because you borked /etc/fstab when tweaking your partitioning scheme).
Remembering to type /bin/vi is easier when you're not sweating bullets.

(?) doesn't give me a listing of the contents of tmp. Ummm, what am I doing wrong here?????

(!) [Thomas] Nothing. Although you should qualify which directory you created the link in. Indeed, what does:
ls -l ./foo
produce as output? Indeed, did you do that the right way around?
% ln -s /tmp foo && ls ./foo

This page edited and maintained by the Editors of Linux Gazette
HTML script maintained by Heather Stern of Starshine Technical Services, http://www.starshine.org/


Each TAG thread Copyright © its authors, 2006

Published in issue 122 of Linux Gazette January 2006

<-- 2c Tips | TAG Index | 1 | 2 | 3 | 4 | Knowledge Base -->
Tux