how does symbolic link execute command with option or parameter


 
Thread Tools Search this Thread
Top Forums UNIX for Dummies Questions & Answers how does symbolic link execute command with option or parameter
# 1  
Old 12-01-2008
how does symbolic link execute command with option or parameter

Hello World~Smilie

$ rbash
$ cd ..
rbash: cd: restricted
$ ls -l /bin/rbash
lrwxrwxrwx 1 root root 4 2008-11-02 15:56 /bin/rbash -> bash
rbash is a symbolic link to bash
but why does rbash execute 'bash -r' instead of 'bash'
i want to know how symbolic link executes command with option or parameter
i'm sorry i'm poor at writing english
but i'm good at reading english
thanks in advance
# 2  
Old 12-01-2008
The behavior of bash depends on the way it is invoked, and it will behave differently if it is invoked as rbash or sh by checking what the command used to run it was.

Code:
RESTRICTED SHELL

       If  bash  is  started with the name rbash, or the -r option is supplied at invocation, the shell becomes restricted.  
       A restricted shell is used to set up an environment more controlled than the standard shell.  It behaves identically
       to bash with the exception that the following are disallowed or not performed:

       ·      changing directories with cd

       ·      setting or unsetting the values of SHELL, PATH, ENV, or BASH_ENV

       ·      specifying command names containing /

       ·      specifying a file name containing a / as an argument to the .  builtin command

       ·      Specifying a filename containing a slash as an argument to the -p option to the hash builtin command

       ·      importing function definitions from the shell environment at startup

       ·      parsing the value of SHELLOPTS from the shell environment at startup

       ·      redirecting output using the >, >|, <>, >&, &>, and >> redirection operators

       ·      using the exec builtin command to replace the shell with another command

       ·      adding or deleting builtin commands with the -f and -d options to the enable builtin command

       ·      Using the enable builtin command to enable disabled shell builtins

       ·      specifying the -p option to the command builtin command

       ·      turning off restricted mode with set +r or set +o restricted.

       These restrictions are enforced after any startup files are read.

also the same idea applies if it is invoked as sh

Code:
       If  bash  is invoked with the name sh, it tries to mimic the startup behavior of historical versions of sh as closely as possible,
       while conforming to the POSIX standard as well.  When invoked as an interactive login shell, or a non-interactive shell  with  the
       --login  option,  it first attempts to read and execute commands from /etc/profile and ~/.profile, in that order.  The --noprofile
       option may be used to inhibit this behavior.  When invoked as an interactive shell with the name sh, bash looks for  the  variable
       ENV,  expands  its  value  if it is defined, and uses the expanded value as the name of a file to read and execute.  Since a shell
       invoked as sh does not attempt to read and execute commands from any other startup files, the --rcfile option has  no  effect.   A
       non-interactive  shell invoked with the name sh does not attempt to read any other startup files.  When invoked as sh, bash enters
       posix mode after the startup files are read.

# 3  
Old 12-01-2008
Awesome
Life Saver~
Thank you very much
I want to study the behavior of bash depends on the way it is invoked
I will check bash source code

Last edited by lifegeek; 12-01-2008 at 09:16 PM..
# 4  
Old 12-01-2008
That would be the easiest way, you can get the source on The GNU Operating System

If memory serves it does it by defining RESTRICTED_SHELL_NAME in one of the header files and then the code to check the method of invocation is in shell.c
# 5  
Old 12-01-2008
great~ thank you~
 
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. UNIX for Dummies Questions & Answers

Symbolic link

Hi, trying to understand more about symblic link, when I compiled a program called "match" in one folder ~/downloadsoftware/I want this program to be accessible like a system command by putting a symbolic link in /usr/bin/ Not by setting the $PATH method in .bashrc at this time. What I did is:... (4 Replies)
Discussion started by: yifangt
4 Replies

2. UNIX for Dummies Questions & Answers

[Solved] Symbolic link not allowed or link target not accessible

Hi everybody, I read about treads realted to this issue but they did not resovle issue given below. Please help me resolve issue given below I have html file under /srv/www/htdocs/actual_folder ls actual_folder/ test.html and following link works... (0 Replies)
Discussion started by: newbielgn
0 Replies

3. Shell Programming and Scripting

ls on a symbolic link

Hi all, Can anyone please confirm if the command below is the only way that I can get what the symbolic link is set to? mnlxd110(oracle)/db/posd2/dba$: ls -l | grep "^l" lrwxrwxrwx 1 oracle dba 28 Aug 9 2011 bdump -> diag/rdbms/posp1/posp1/trace mnlxd110(oracle)/db/posd2/dba$:... (7 Replies)
Discussion started by: newbie_01
7 Replies

4. Solaris

issue with Symbolic link

Hi All, I have to set a soft link to a directory, e.g. it’s done, however I want it make it permanent and in case if any program is pointing to /cms/cmsuat/server/cmu/contribution it should go to /cms/cmsUAT/server/cmu/Contribution. Need your help! Thanks in advance! (4 Replies)
Discussion started by: kumarmani
4 Replies

5. Shell Programming and Scripting

Symbolic Link Help

Hello All, This may be a silly question to some but I am really stuck. Is there a way to reverse the following; sudo rm /bin/sh sudo ln -s /bin/bash /bin/sh It was part of a driver compile/installation procedure by Digi for Ubuntu stating that dash isn't supported and a symbolic link... (2 Replies)
Discussion started by: LAVco
2 Replies

6. Shell Programming and Scripting

symbolic link

Hi, i am trying to create sym links on sles 11 , but it seems i am doing something wrong. oracle@tests:/u01/app/oracle/oradata/ACIS> pwd /u01/app/oracle/oradata/ACIS oracle@tests:/u01/app/oracle/oradata/ACIS> ln -s /db/ACIS/dbase/dbf/ /u01/app/oracle/oradata/ACIS/... (2 Replies)
Discussion started by: tonijel
2 Replies

7. UNIX for Dummies Questions & Answers

Shell Command for Symbolic Link Targets

**DUP post in Shell Programming and Scripting *** Hello, I'm still learning the ins and outs of how to combine multiple Unix commands together (specifically AIX), but I'm looking to do the following (only on local files): 1. Find all symbolic links that are not set up using absolute... (3 Replies)
Discussion started by: bdizenhouse
3 Replies

8. UNIX for Dummies Questions & Answers

need some info about symbolic link and hard link

hello folks how y'all doin well i have some questions about symbolic link and hard link hope some one answer me i open terminal and join as root and i wrote ln -s blah blah then i wrote ls i see red file called blah blah but didn't understand what is this can some one explain and... (2 Replies)
Discussion started by: detective linux
2 Replies

9. UNIX for Dummies Questions & Answers

symbolic Link

question abt symbolic link ... i'm doing the following ... ln -s x.sh ./scripts/y.sh and cat ./scripts/y.sh it is giving following error cat: cannot open y.sh Any reason u an think of ? But it is working fine when i goto scripts directory and cretae the symbolic link. ... (1 Reply)
Discussion started by: bhargav
1 Replies

10. UNIX for Advanced & Expert Users

1 symbolic link to 2 different places?

I was wondering is it possible todo something like following: A) Settings:- - 2 servers on the network - both can be reached via /net/SERVER1/datadir and /net/SERVER2/datadir - i'm running rsync to syncronize the data coming to server1 from whatever application B) Wanted: on other... (2 Replies)
Discussion started by: Bashar
2 Replies
Login or Register to Ask a Question