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? |
slocate uses the updatedb database to for file searching. It indexes files on your box
ln -s to make a link. man ln |
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. |
anyone else with some more details
|
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.
|
Code:
[skalkoto@localhost src]$ cat samplecode 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. |
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.
|
All times are GMT -5. The time now is 02:46 AM. |