LinuxQuestions.org
Register a domain and help support LQ
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Distributions > Slackware
User Name
Password
Slackware This Forum is for the discussion of Slackware Linux.

Notices

Reply
 
Search this Thread
Old 01-03-2005, 12:56 PM   #1
ilnli
Member
 
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*
root@DARKSTAR:~#

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, 01:29 PM   #2
Linux~Powered
Member
 
Registered: Jan 2004
Location: /lost+found
Distribution: Slack`er-current
Posts: 845

Rep: Reputation: 31
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, 03:34 PM   #3
slakmagik
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, 12:40 AM   #4
ilnli
Member
 
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, 02:08 AM   #5
DaHammer
Member
 
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 02:10 AM.
 
Old 01-04-2005, 04:09 AM   #6
perfect_circle
Senior Member
 
Registered: Oct 2004
Location: Athens, Greece
Distribution: Slackware, arch
Posts: 1,783

Rep: Reputation: 52
Code:
[skalkoto@localhost src]$ cat samplecode
#! /bin/bash
                                                                                                                             
if [ ${0##*/} == "samplecode" ]
then    echo "Do this"
else    echo "Do that"
fi
                                                                                                                             
[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 04:31 AM.
 
Old 01-04-2005, 05:05 PM   #7
ringwraith
Senior Member
 
Registered: Sep 2003
Location: Indiana
Distribution: Slackware-current
Posts: 1,244

Rep: Reputation: 47
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.
 
  


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


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

Main Menu
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
identi.ca: @linuxquestions
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration