Create user with access only to one command


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting Create user with access only to one command
# 1  
Old 08-06-2014
Create user with access only to one command

Hi all,

Is there any way to create linux user with access only one defined command? For example, I want new user has access only to ls command.
# 2  
Old 08-06-2014
You could edit the user's personal profile (which on depends on the shell you assign) and trap them in a script. You could then prompt them for what they want to list and do just that, returning to your prompt. The only other option would be a quit where you would code a logout.

Does that theory meet your needs?



Robin
# 3  
Old 08-06-2014
Did you consider a "restricted shell" (c.f. man bash: -r option)?

Not sure if you could place that command in field 7 (optional user command interpreter) of the /etc/passwd file in lieu of the usual shell?
# 4  
Old 08-06-2014
You can put rbash in /etc/passwd instead of bash -r for this reason.

I agree that more explanation of the purpose behind this would be good.
# 5  
Old 08-06-2014
chroot and FreeBDD jail(8) comes to mind here, although they will then have little to list in the jail unless you mount the folders of interest.

Perhaps you could write a script that prompts for the directory and does ls for them then set this as their .profile:

Code:
#!/bin/sh
trap "" 1 2 3 15
while true
do
   printf "\nEnter directory to list (\"exit\" when done): "
   read dir
   [ "$dir" = "exit" ] && exit
   ls -l "${dir}" | more
done

# 6  
Old 08-06-2014
Or you could make a user whose shell is /bin/ls... and their home directory is the directory they're allowed to ls.
# 7  
Old 08-12-2014
Thanks to all for the replies.
Was out for a week, thats why didn't respond in time.
Sorry for that.
Actually, what I need is to create user with access only to one special command :
Code:
ldapsearch (with parameters)

....and to the scripts which in user's home directory. That's all. No other commands should be available.

Which is most "normal" way to achieve it?

Last edited by rbatte1; 08-14-2014 at 06:11 AM..
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

Need one line command to create and set password for new user...

Using useradd abc --password password (5 Replies)
Discussion started by: Jagruti Rml
5 Replies

2. Homework & Coursework Questions

Create script to add user and create directory

first off let me introduce myself. My name is Eric and I am new to linux, I am taking an advanced linux administration class and we are tasked with creating a script to add new users that anyone can run, has to check for the existence of a directory. if the directory does not exist then it has... (12 Replies)
Discussion started by: pbhound
12 Replies

3. UNIX for Advanced & Expert Users

How to create user with access only to one folder through ftp?

Hi all, Can someone help me with creating user with special privilegies? I need to create user who will have access ONLY to one folder (like /etc/log/) through ftp (read only access) and which will not have any other ways to log in like telnet, ssh etc.? (5 Replies)
Discussion started by: nypreH
5 Replies

4. Shell Programming and Scripting

To create user name with read only access

hi, how to create user name with read only access. i think first need to create group with read only access after that i need to create the user and assign it to that group. If it is correct, how to create user with read only access? (4 Replies)
Discussion started by: rsivasan
4 Replies

5. Solaris

create user with RWX access to a specific directory in Solaris 10

I need to create a user account for a developer that will allow him rwx access to all resources in a directory. How can I do that? Thanks (5 Replies)
Discussion started by: gsander
5 Replies

6. Solaris

create command aliases for a user

Hi all, I am using Solaris 10 OS on X86. When I add a new user from command useradd -d /export/home/vikas -m -s /bin/bash vikas files local.cshrc, local.login, local.profile and .profile get copied to my home directory (i.e. /export/home/vikas) from /etc/skel/ Which file I have to change... (4 Replies)
Discussion started by: vikas027
4 Replies

7. Solaris

How to create a new ftp user account with limited access..?

Hi All, I'm using solaris 2.8, and I want create a new ftp user account with the following restrictions: - Have only ftp access, no telnet or rlogin - Have restricted access to its home directory example /export/home/newuser - Deny access to any other directory. Thanks for your help, ... (6 Replies)
Discussion started by: Jeremy3
6 Replies

8. UNIX for Advanced & Expert Users

Other than root user .Normal user is unable to create files

Hi all, I am using Sun Solaris 9 .In this system normal users unable to create files from the command line.I added these users in bin,adm and even root group i found them unable to create a file. (1 Reply)
Discussion started by: mallesh
1 Replies

9. UNIX for Dummies Questions & Answers

create or modify user account to have same access as root

Is there a way to create or better yet modify a user account so it has the same privs as root? (6 Replies)
Discussion started by: xadamz23
6 Replies

10. UNIX for Dummies Questions & Answers

Want to create new users without using "useradd" command and user Interaction.

Don't want to use useradd command to create a new user I am doing manual addition of accounts. Actually I am writing a script and I am working on RedHat7.1 system. What I am trying to do is run the script and pass all the values of the username password and group as command line parameters. Now... (2 Replies)
Discussion started by: syedifti
2 Replies
Login or Register to Ask a Question