Share your knowledge at the LQ Wiki.
Go Back > Forums > Linux Forums > Linux - Distributions > Slackware
User Name
Slackware This Forum is for the discussion of Slackware Linux.


  Search this Thread
Old 01-03-2005, 01:56 PM   #1
Registered: Jul 2004
Location: Pakistan
Distribution: Slackware 10.0, SUSE 9.1, RH 7, 7.3, 8, 9, FC2
Posts: 413

Rep: Reputation: 32
symbolic link

root@DARKSTAR:~# ls -l /usr/bin/updatedb
lrwxrwxrwx 1 root root 7 2005-01-02 00:18 /usr/bin/updatedb -> slocate*

this is my updatedb file which is simply a symbolic to slocate
but when I directly execute slocate it show different behaviour but when I execute it with updatedb it show different, how is that possible???
if it is so then what type of link is this and how can i create such type of links?
Old 01-03-2005, 02:29 PM   #2
Registered: Jan 2004
Location: /lost+found
Distribution: Slackware 14.2
Posts: 845

Rep: Reputation: 33
slocate uses the updatedb database to for file searching. It indexes files on your box
ln -s to make a link. man ln
Old 01-03-2005, 04:34 PM   #3
Senior Member
Registered: Feb 2003
Distribution: Slackware
Posts: 4,113

Rep: Reputation: Disabled
Additionally, as I understand it, a program will check for its invocation. So if you invoke it as 'slocate' $0 is 'slocate' and it runs its default way. If you invoke it as updatedb, that points to slocate, so that's what is invoked but, at the same time, $0 is 'updatedb' - slocate can check for that and say, "Ah, I'm supposed to be running as 'slocate -u'" and does so.

But this is pretty much hardcoded. If you want it to run with a different set of default options, you need a shellscript wrapper or alias or the like instead of a symlink.
Old 01-04-2005, 01:40 AM   #4
Registered: Jul 2004
Location: Pakistan
Distribution: Slackware 10.0, SUSE 9.1, RH 7, 7.3, 8, 9, FC2
Posts: 413

Original Poster
Rep: Reputation: 32
anyone else with some more details
Old 01-04-2005, 03:08 AM   #5
Registered: Oct 2003
Location: Planet Earth
Distribution: Slackware, LFS
Posts: 561

Rep: Reputation: 30
As digiot stated, the slocate program reads the arguments it's called with (and the program name is always the first argument) and runs appropiately depending on how it's called. So if you run updatedb, you are essentially running "slocate -u". See "man updatedb". It's essentially a programming trick. Alot of linux utilities use it, gzip for example, calling gunzip is the same as calling "gzip -d" on alot of machines. Busybox is another example, in that it emulates alooooot of utils based on the name of the command it's called as.

Last edited by DaHammer; 01-04-2005 at 03:10 AM.
Old 01-04-2005, 05:09 AM   #6
Senior Member
Registered: Oct 2004
Location: Athens, Greece
Distribution: Slackware, arch
Posts: 1,783

Rep: Reputation: 52
[skalkoto@localhost src]$ cat samplecode
#! /bin/bash
if [ ${0##*/} == "samplecode" ]
then    echo "Do this"
else    echo "Do that"
[skalkoto@localhost src]$ ln -s samplecode link_to_samplecode
[skalkoto@localhost src]$ ls -l samplecode link_to_samplecode
lrwxrwxrwx  1 skalkoto skalkoto 10 Jan  4 12:08 link_to_samplecode -> samplecode
-rwxr-xr-x  1 skalkoto skalkoto 91 Jan  4 11:59 samplecode
[skalkoto@localhost src]$ ./samplecode
Do this
[skalkoto@localhost src]$ ./link_to_samplecode
Do that
[skalkoto@localhost src]$
This is a script but u may do the same in C or any other programming languages, since all languages offer a way to get input arguments and the first argument is the name of the file you execute. When you use a software link the name of the link is considered as the name of the file and not the name of the actual executable file.

I don't know if slackware use console-helper. It's an indirect way for a simple user to execute programs that need root privileges.
For example in fedora kppp.
there is an /sbin/kppp and there is a /bin/kppp.
the /sbin directory is not in the path of the simple user.
on the other hand /bin/kppp is a link to console-helper.
Every time a simple user executes kppp the consolehelper will pop-up a window were the user is asked to type the root password. If the password is correct then /sbin/kppp is executed.

Last edited by perfect_circle; 01-04-2005 at 05:31 AM.
Old 01-04-2005, 06:05 PM   #7
Senior Member
Registered: Sep 2003
Location: Indiana
Distribution: Slackware-current
Posts: 1,257

Rep: Reputation: 48
most of these questions could have been answered by reading "man slocate" and "man updatedb" part of developing slacktitude is learning to find answers to questions by reading a bit. Don't take this as a flame, just pointing out that you should always read the man pages and /usr/doc and then move on to searching these forums.


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 10:27 AM
help with a symbolic link mykrob Linux - Software 6 11-22-2004 11:01 AM
symbolic link jsetter Linux - Newbie 4 11-22-2004 08:18 AM
Symbolic link. bulzbb Linux - General 8 03-19-2004 05:57 AM
Symbolic link bwaynej2002 Linux - General 8 08-25-2003 11:06 PM > Forums > Linux Forums > Linux - Distributions > Slackware

All times are GMT -5. The time now is 09:29 AM.

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