nixCraft Linux Forum

nixCraft

Linux / UNIX Tech Support Forum

restrict a user to certain command

This is a discussion on restrict a user to certain command within the Solaris/OpenSolaris forums, part of the UNIX operating systems category; Hi all, I am using Sun OS 5.10. I am new to Unix. Is there some way to restrict a ...


Go Back   nixCraft Linux Forum > UNIX operating systems > Solaris/OpenSolaris

Linux answers from nixCraft.


Solaris/OpenSolaris Discuss all about the SUN Solairs/OpenSolaris. You are free to talk about any issues related to Solaris administration, networking, services and other stuff, share information or ask doubts.

Reply

 

LinkBack Thread Tools Display Modes
  #1 (permalink)  
Old 07-03-2008, 03:14 PM
Member
User
 
Join Date: Oct 2007
OS: Linux RHEL 5
Posts: 37
Thanks: 0
Thanked 0 Times in 0 Posts
Rep Power: 0
vikas027 is on a distinguished road
Unhappy restrict a user to certain command

Hi all,

I am using Sun OS 5.10. I am new to Unix.

Is there some way to restrict a specific user to certain command say "/usr/bin/more" ??
for example: I want that user1 can execute more command & user2 can't.


Can we somehow edit .profile file in the home directory of user to achieve this ??
OR
is there some other way ??

Pls help.

Thanks N Regards,
VIKAS
Reply With Quote
  #2 (permalink)  
Old 08-03-2008, 11:29 PM
rockdalinux's Avatar
Is that all you got?
User
 
Join Date: May 2005
Location: Planet Vegeta
OS: Redhat
Posts: 708
Thanks: 15
Thanked 19 Times in 18 Posts
Rep Power: 10
rockdalinux is a glorious beacon of light rockdalinux is a glorious beacon of light rockdalinux is a glorious beacon of light rockdalinux is a glorious beacon of light rockdalinux is a glorious beacon of light rockdalinux is a glorious beacon of light
Default

I don't think so it is possible; by default user are allowed to run program stored at /bin and /usr/bin; only root can run (almost) /sbin /usr/sbin
__________________
Rocky Jr.
What's wrong? I hope I am not making you uncomfortable...

Never send a boy to do a mans job.
Reply With Quote
  #3 (permalink)  
Old 11-03-2008, 08:14 AM
Junior Member
User
 
Join Date: Mar 2008
OS: Debian
Posts: 1
Thanks: 0
Thanked 0 Times in 0 Posts
Rep Power: 0
biwas is on a distinguished road
Default

How about SUDO
Reply With Quote
  #4 (permalink)  
Old 10-09-2009, 05:39 PM
Junior Member
User
 
Join Date: Sep 2009
OS: DragonFire
Posts: 1
Thanks: 0
Thanked 0 Times in 0 Posts
Rep Power: 0
Dragonfire is on a distinguished road
Lightbulb Its possible ...

This code code has been coded by me to allow users only through a specific ip (ip is configurable as an entry need to be made in a file). This code is for 'vi' ing a file .. This will vi the file if nobody else is 'vi' ing it .. we can do the same for 'more' ing a file :



STEP I :

ps -eaf | grep -w $USER | grep -v grep | grep -w vi | grep -w $1 >> /dev/null; #Just to check if someone is editing
if [ $? != 0 ];
then
echo "opening $1"
cp -p $1 $HOME/TEMP_BKP/$1;
vi $1;
else
echo "Please wait. following person is using this file : "
ps -eaf | grep -w $USER | grep -v grep | grep -w vi | grep -w $1 | awk '{ print $6 }' | while read line
do
who | grep -w $line | awk '{print $6}' | while read ipaddr
do
grep -w $ipaddr $HOME/Application/Exec/ShellScripts/ip_name_link.txt #add the ip address of all users
in this txt file
if test $? -ne 0; then
echo "Unknown $ipaddr"
fi;
done;
done;
fi;



STEP II :

Now add an alias in the .profile for more.

example :

assume, the above code is saved in a file open_file.sh.

then in .profile we can have :

alias vi="open_file.sh" # m assuming that the location of open_file.sh is set in the PATH variable.

__________________________________________________ ______

HOPE MY INPUT IS OF SOME HELP .. FEEL FREE TO COMMENT ...!!
__________________________________________________ ______

Regards
Prasanna Pradip Kulkarni.
Reply With Quote
  #5 (permalink)  
Old 05-10-2009, 02:17 PM
nixcraft's Avatar
Never say die
User
 
Join Date: Jan 2005
Location: BIOS
OS: RHEL
Scripting language: Bash and Python
Posts: 2,710
Thanks: 11
Thanked 246 Times in 184 Posts
Rep Power: 10
nixcraft has a reputation beyond repute nixcraft has a reputation beyond repute nixcraft has a reputation beyond repute nixcraft has a reputation beyond repute nixcraft has a reputation beyond repute nixcraft has a reputation beyond repute nixcraft has a reputation beyond repute nixcraft has a reputation beyond repute nixcraft has a reputation beyond repute nixcraft has a reputation beyond repute nixcraft has a reputation beyond repute
Default

Linux / UNIX: Restrict Access To A Given Command
__________________
Vivek Gite
Linux Evangelist
Be proud RHEL user, and let the world know about your enterprise choices! Join RedHat user group.
Always use CODE tags for posting system output and commands!
Do you run a Linux? Let's face it, you need help
Reply With Quote
Reply


Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)

 
Thread Tools
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


Similar Threads

Thread Thread Starter Forum Replies Last Post
Create new user account in Ubuntu Linux from command line sweta Getting started tutorials 3 07-02-2010 12:15 PM
restrict access of a user to two directories only vikas027 CentOS / RHEL / Fedora 0 15-04-2008 05:35 PM
UNIX command to find out whether particular process of a particular user is running Santosh Sharma Shell scripting 1 17-01-2008 03:26 PM
How to restrict devices usage for users in Solaris? kitty@sad Solaris/OpenSolaris 3 21-05-2007 02:05 PM
how to restrict lan users so that they cannot send bhagi123 Linux software 2 21-11-2006 11:38 AM


All times are GMT +5.5. The time now is 08:24 PM.


Powered by vBulletin® Version 3.8.5 - Copyright ©2000 - 2010, Jelsoft Enterprises Ltd.
Search Engine Optimization by vBSEO 3.3.2
©2005-2010 nixCraft. All rights reserved

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38