LinuxQuestions.org
LinuxAnswers - the LQ Linux tutorial section.
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Security
User Name
Password
Linux - Security This forum is for all security related questions.
Questions, tips, system compromises, firewalls, etc. are all included here.

Notices

Reply
 
Search this Thread
Old 08-14-2004, 06:21 AM   #1
Obie
Member
 
Registered: Apr 2004
Distribution: Red Hat
Posts: 290

Rep: Reputation: 30
Question bash commands


I'm not sure if this would involve security (I do though. Please let me know if it is otherwise). Everyone knows by now it is advisable not to log in as root to perform system maintenance or run various commands as it could do more harm than good. I was wondering is it possible to have bash prompt me say twice when I enter any command e.g. I run the command shutdown -h now. Is it possible to have bash prompt me "Are you sure that you want to run that command"?

Secondly, is it possible to log bash commands for a particular user 1) log only certain chosen commands 2) log every command

Last edited by Obie; 08-15-2004 at 02:43 PM.
 
Old 08-14-2004, 09:55 AM   #2
ranger_nemo
Senior Member
 
Registered: Feb 2003
Location: N'rn WI -- USA
Distribution: Kubuntu 8.04, ClarkConnect 4
Posts: 1,142

Rep: Reputation: 47
Not sure about the first, but as for the second, you could grep a user's .bash_history for any commands you want to keep track of.

<< EDIT >>

Just had a thought on the first... Create your own shell scripts and put them in your ~/bin directory. It would contain your "Do you really...?" query, and run the specific command if you answered yes.

It would even save you keystrokes if you named it something similar, but easily [TAB]-completed... "shutoff.sh" runs the query and "shutdown -h now".

Last edited by ranger_nemo; 08-14-2004 at 10:02 AM.
 
Old 08-15-2004, 02:47 AM   #3
ilnli
Member
 
Registered: Jul 2004
Location: Pakistan
Distribution: Slackware 10.0, SUSE 9.1, RH 7, 7.3, 8, 9, FC2
Posts: 413

Rep: Reputation: 32
Yes It is possible but for that you have to have a well written bach script which will get a command from you and then checks your decision and then run the command. An simple scripting idea I am giving you below

if [1 != ""] then
echo "Do You Really Want To Execute That Command [Y/N]: "
read $dec
if[ $dec = "Y" | $dec ="y"] then
/bin/sh $dec

then place this script in you "bin" of your home for every command you want to check. and then do
PATH=/yourhome/bin:$PATH
export PATH

there might be some errors in the script but I have just given you a rough idea
 
Old 08-15-2004, 11:35 AM   #4
btmiller
Senior Member
 
Registered: May 2004
Location: In the DC 'burbs
Distribution: Arch, Scientific Linux, Debian, Ubuntu
Posts: 4,078

Rep: Reputation: 297Reputation: 297Reputation: 297
To log user commands you should look into BSD style process accounting (just using .bash_history is not reliable, since a user can edit their .bash_history or disable it altogether). You'll need support for process accounting compiled into your kernel and the user space tools installed on your machine. Then read the man pages for accton and lastcomm and you should be set.
 
Old 08-15-2004, 02:42 PM   #5
Obie
Member
 
Registered: Apr 2004
Distribution: Red Hat
Posts: 290

Original Poster
Rep: Reputation: 30
Thank you all for your replies and suggestions.

quote:
----------------------------------------------------------------------
To log user commands you should look into BSD style process accounting (just using .bash_history is not reliable, since a user can edit their .bash_history or disable it altogether). You'll need support for process accounting compiled into your kernel and the user space tools installed on your machine. Then read the man pages for accton and lastcomm and you should be set.
----------------------------------------------------------------------

btmiller,

Could you further elaborate your answer as to how I could follow a BSD style of processing user commands? Thank you.
 
  


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
bash commands davatar Slackware 2 04-06-2005 03:05 AM
i need help with some newbie bash commands Alexander.s Programming 14 12-24-2004 02:33 PM
Help with BASH Commands rridler Linux - Newbie 3 04-16-2004 04:43 PM
Bash commands PhuckFonix Linux - Newbie 2 03-30-2004 07:13 PM
Bash commands wprescott Linux - Distributions 6 04-27-2002 02:56 PM


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

Main Menu
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
identi.ca: @linuxquestions
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration