LinuxQuestions.org
Latest LQ Deal: Linux Power User Bundle
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Newbie
User Name
Password
Linux - Newbie This Linux forum is for members that are new to Linux.
Just starting out and have a question? If it is not in the man pages or the how-to's this is the place!

Notices


Reply
  Search this Thread
Old 04-17-2014, 04:21 PM   #1
linuxmantra
Member
 
Registered: Dec 2013
Posts: 110

Rep: Reputation: Disabled
Disable 'cd' command for a user


I want to disable a 'cd' command for a user let say 'john'. John should not be able to run cd command or let say in future any command like rm, cp, mv etc. How can I do this in linux?
 
Old 04-17-2014, 05:14 PM   #2
smallpond
Senior Member
 
Registered: Feb 2011
Location: Massachusetts, USA
Distribution: CentOS 6 (pre-systemd)
Posts: 2,667

Rep: Reputation: 710Reputation: 710Reputation: 710Reputation: 710Reputation: 710Reputation: 710Reputation: 710
Do you also want to prevent the user from setting environment variables? For example:

Code:
export PWD=/usr/local/games
 
Old 04-17-2014, 05:21 PM   #3
Smokey_justme
Member
 
Registered: Oct 2009
Distribution: Slackware
Posts: 534

Rep: Reputation: 203Reputation: 203Reputation: 203
First off, 'cd' is an internal command in bash, so that would be out of the question..

For other commands maybe see extended ACLs if your system supports them and use them on the executable files.. But I wouldn't recommend you to do that for basic commands since a lot of stuff my fail afterwords.. Maybe tell us what are you trying to achive!?
 
Old 04-17-2014, 08:12 PM   #4
sgosnell
Senior Member
 
Registered: Jan 2008
Location: Baja Oklahoma
Distribution: Debian
Posts: 1,054

Rep: Reputation: 276Reputation: 276Reputation: 276
If you're trying to keep a user from using cd to get to root directories, you can use a chroot. But I don't think you can completely disable cd, nor do I think that's a good idea.
 
Old 04-18-2014, 10:19 AM   #5
jpollard
Senior Member
 
Registered: Dec 2012
Location: Washington DC area
Distribution: Fedora, CentOS, Slackware
Posts: 4,654

Rep: Reputation: 1255Reputation: 1255Reputation: 1255Reputation: 1255Reputation: 1255Reputation: 1255Reputation: 1255Reputation: 1255Reputation: 1255
You might check into the topic of "restricted shell".

These are shells that have a restriction on what they can do (rbash is one such) but you need to know what the limitations of restricted shells are.

It is entirely possible to create your own shell that has only options/commands you want included - and disables access to running any other processes (busybox partly works like that and is based on the ash shell).

As a side note, I once used the adventure game as a shell for a user account. When the user logged in the only thing that could be done was play the game. Any thing that terminated the shell logged the user out.

Last edited by jpollard; 04-18-2014 at 10:22 AM.
 
  


Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search

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 Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
Disable "ls" command for a user when he FTPs jonty_11 Linux - Software 3 04-06-2011 11:11 AM
[SOLVED] disable su command fernfrancis Linux - Newbie 8 04-29-2010 02:59 AM
Been hacked?, was: How to disable rm command for an user hansemmanuel Linux - Security 26 04-12-2010 04:17 AM
How to disable a user sasikumar123 Linux - Newbie 2 08-09-2009 02:59 AM
dbx command for corrosponding commands disable or disable on gdb bshankha AIX 0 09-26-2006 10:38 AM


All times are GMT -5. The time now is 02:20 PM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration