Go Back   The UNIX and Linux Forums > Top Forums > UNIX for Dummies Questions & Answers
google site



UNIX for Dummies Questions & Answers If you're not sure where to post a UNIX or Linux question, post it here. All UNIX and Linux newbies welcome !!

Closed Thread
English Japanese Spanish French German Portuguese Italian Powered by Powered by Google
 
Thread Tools Search this Thread Display Modes
  #1  
Old 12-30-2009
Registered User
 

Join Date: Dec 2009
Posts: 11
Thanks: 0
Thanked 0 Times in 0 Posts
Restrict command for an user ?

Hi everyone !

I got "viewer" and "root" user on a *nix computer. When i log in using "viewer" I only can use "df" command. When I try another command like "ls" it say :

-bash: ls: command not found

I checked permission of "/bin/ls" file, it has excute permission for everyone. Inside home directory of "viewer" there's only a directory "bin" and within it only the "df" file.

Can anyone tell me how to restrict command for an user like that ?

Last edited by camus; 12-30-2009 at 02:18 AM..
Sponsored Links
  #2  
Old 12-30-2009
zaxxon's Avatar
zaxxon zaxxon is offline Forum Staff  
code tag tagger
 

Join Date: Sep 2007
Location: Germany
Posts: 3,238
Thanks: 7
Thanked 47 Times in 45 Posts
You might want to check if this is a chroot environment (it looks like one) or if that user has a restricted shell, which can be checked in /etc/passwd (look for the shell entry).
To make sure, try to cd into another directory or try to call ls by it's full path /bin/ls and check what error you might get.

If this viewer user should be enhanced by additional commands, you might want to copy those binaries he should be able to use into that ./bin directory inside his home directory. Some tools require libraries to work correctly, which you can check with the tool ldd. You might need to copy it there too to an adequate path so it can be found by the binary.
  #3  
Old 12-30-2009
Registered User
 

Join Date: Dec 2009
Posts: 660
Thanks: 6
Thanked 49 Times in 47 Posts
This could be due to a change in the value of $PATH.


Code:
$ which ls
/bin/ls
$ PATH=/sbin
$ ls /bin/ls
-bash: ls: command not found
$ /bin/ls /bin/ls
/bin/ls

If it's a PATH issue, you should still be able to run the command if you invoke it by specifying the path to the command with either an absolute or relative pathname (must contain a forward slash).

Last edited by alister; 12-30-2009 at 01:39 PM..
  #4  
Old 12-30-2009
Registered User
 

Join Date: Dec 2009
Posts: 11
Thanks: 0
Thanked 0 Times in 0 Posts
Quote:
Originally Posted by zaxxon View Post
You might want to check if this is a chroot environment (it looks like one) or if that user has a restricted shell
Can you please explain about chroot and what is restricted shell ? In /etc/passwd the shell of viewer is /bin/bash

@alister : I checked the $PATH and yes it is /home/viewer/bin. And using the full path of other command has no problem. But I still have one question why I can use cd and echo command ( not full path ) while they're not in /home/viewer/bin . Because they're Built-in command ?

Thanks for help !!
Camus
  #5  
Old 12-30-2009
Registered User
 

Join Date: Mar 2009
Posts: 11
Thanks: 0
Thanked 0 Times in 0 Posts
Quote:
Originally Posted by camus View Post
Can you please explain about chroot and what is restricted shell ? In /etc/passwd the shell of viewer is /bin/bash

@alister : I checked the $PATH and yes it is /home/viewer/bin. And using the full path of other command has no problem. But I still have one question why I can use cd and echo command ( not full path ) while they're not in /home/viewer/bin . Because they're Built-in command ?

Thanks for help !!
Camus
yes, you get it. cd and echo commands are implemented as part of shell itself, that is so called shell built-in. And thus these builtin command are always available in a running shell and have nothing to do with PATH envroment variable
Sponsored Links
Closed Thread

Bookmarks

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

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 On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


More UNIX and Linux Forum Topics You Might Find Helpful
Thread Thread Starter Forum Replies Last Post
New user and restrict path lo-lp-kl AIX 1 01-18-2009 05:54 AM
How to restrict the perticular command to user murthy76 Solaris 3 11-26-2008 06:27 PM
restrict the user not to key in more than 50 chars injeti Shell Programming and Scripting 18 08-16-2008 11:06 AM
restrict a user to certain command vikas027 Solaris 1 03-07-2008 08:52 AM
need to restrict user to his home dir lidram Solaris 5 02-06-2008 10:03 AM



All times are GMT -4. The time now is 07:49 AM.