LinuxQuestions.org
Latest LQ Deal: Latest LQ Deals
Home Forums Tutorials Articles Register
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 09-15-2005, 08:56 AM   #1
turalo
Member
 
Registered: Sep 2005
Location: NL
Distribution: linux, windows,
Posts: 115

Rep: Reputation: 19
need help with command


Can sombody help me to understand or to lern how to start a command when any or priticular user logs on de system? for example there is a command "script" it logs all activity of the user , to start it you just type it in the commandline : script and it starts logging , by default the log is writen in users home directory.
what I wanna do is that if sombody logs in to the system , then this command automaticly starts for that user and logs hes activity, this way I can later on see what is going on in case somthing is damaged.
in my case we use the ssh many times so I want to know what does the user doe whe he logs in.
 
Old 09-15-2005, 12:41 PM   #2
Matir
LQ Guru
 
Registered: Nov 2004
Location: San Jose, CA
Distribution: Debian, Arch
Posts: 8,507

Rep: Reputation: 128Reputation: 128
First off, keep in mind that if the file is in the user's home directory, he can edit/delete/etc. the file. In fact, it's almost trivial to do 'ln -s /dev/null typescript' to keep the file from ever being created. Anyway. The /etc/profile or ~/.bash_profile files can be used to run commands on login for a user. Good luck with this.
 
Old 09-15-2005, 12:46 PM   #3
turalo
Member
 
Registered: Sep 2005
Location: NL
Distribution: linux, windows,
Posts: 115

Original Poster
Rep: Reputation: 19
Can you be more specific

Can you be more specific, couse I tryd alredy this files but I'cant even find all of them and when I find them there inside in the file is not the info and text wat has to be, and even if it is I'm not realy good at programing , so if you can show me small example , I'll be very thankfull
 
Old 09-15-2005, 12:49 PM   #4
Matir
LQ Guru
 
Registered: Nov 2004
Location: San Jose, CA
Distribution: Debian, Arch
Posts: 8,507

Rep: Reputation: 128Reputation: 128
/etc/profile contains a small bash script usually. Here's a completely fake example:
Code:
# /etc/profile:
PATH=/bin:/usr/bin:/usr/local/bin
# more code
script
Where the bold section is what you want run. Also, have you looked at ~/.bash_history?

Don't forget to disclose to users that actions are being logged.
 
Old 09-15-2005, 01:01 PM   #5
turalo
Member
 
Registered: Sep 2005
Location: NL
Distribution: linux, windows,
Posts: 115

Original Poster
Rep: Reputation: 19
Here is some example of ...

ok this is the end of my profile file

#
# System BASH specials, maybe also good for other shells
#
test -r /etc/bash.bashrc && . /etc/bash.bashrc
if test "$is" = "bash" -a -z "$_HOMEBASHRC" ; then
# loop detection
readonly _HOMEBASHRC=true
test -r $HOME/.bashrc && . $HOME/.bashrc
fi

#
# KSH specials
#
if test "$is" = "ksh" ; then
test -r /etc/ksh.kshrc && . /etc/ksh.kshrc
fi
if test "$is" = "ksh" -a -z "$_HOMEKSHRC" ; then
# loop detection
readonly _HOMEKSHRC=true
test -r $HOME/.kshrc && . $HOME/.kshrc
fi

#
# End of /etc/profile
#
Vigor50:/etc #




Do I make it like this ? :

#
# System BASH specials, maybe also good for other shells
#
test -r /etc/bash.bashrc && . /etc/bash.bashrc
if test "$is" = "bash" -a -z "$_HOMEBASHRC" ; then
# loop detection
readonly _HOMEBASHRC=true
test -r $HOME/.bashrc && . $HOME/.bashrc
fi

#
# KSH specials
#
if test "$is" = "ksh" ; then
test -r /etc/ksh.kshrc && . /etc/ksh.kshrc
fi
if test "$is" = "ksh" -a -z "$_HOMEKSHRC" ; then
# loop detection
readonly _HOMEKSHRC=true
test -r $HOME/.kshrc && . $HOME/.kshrc
fi

# This is the added code for loging
PATH=/bin:/usr/bin:/usr/local/bin
# more code
script

#
# End of /etc/profile
#
Vigor50:/etc #


or my dombo brains are green yet ? sorry if its to stupid, I'm realy trying .Do I make it like this ? :

Last edited by turalo; 09-15-2005 at 01:04 PM.
 
Old 09-15-2005, 01:04 PM   #6
Matir
LQ Guru
 
Registered: Nov 2004
Location: San Jose, CA
Distribution: Debian, Arch
Posts: 8,507

Rep: Reputation: 128Reputation: 128
It's okay, everyone was new to this at one point. I'm always glad to help.

No, you do not need the PATH line, that was just for an example. Just leave the 'script' line in.
 
Old 09-15-2005, 01:22 PM   #7
turalo
Member
 
Registered: Sep 2005
Location: NL
Distribution: linux, windows,
Posts: 115

Original Poster
Rep: Reputation: 19
Ok and....

do I heave to resart some file/ demon/ or somthing ? after I made the chage to profile ?
 
Old 09-15-2005, 01:25 PM   #8
turalo
Member
 
Registered: Sep 2005
Location: NL
Distribution: linux, windows,
Posts: 115

Original Poster
Rep: Reputation: 19
ok ok

It works :-D , now lets chalenge it thank you for help


I'm going to try it out
 
Old 09-15-2005, 01:33 PM   #9
Matir
LQ Guru
 
Registered: Nov 2004
Location: San Jose, CA
Distribution: Debian, Arch
Posts: 8,507

Rep: Reputation: 128Reputation: 128
No problem. In answer to your question, even though you found out yourself: /etc/profile is automatically re-read everytime someone logs in to a shell. It must be a login shell to be read.
 
Old 09-15-2005, 01:38 PM   #10
turalo
Member
 
Registered: Sep 2005
Location: NL
Distribution: linux, windows,
Posts: 115

Original Poster
Rep: Reputation: 19
mmmmm

There is some problem with this thing,

now its starts everytiyng ok , but for example I loged in , I made soma commands like ls and so on , just to test, after I typed exit then its also normaly says script stoped and file is typescript

then I do : cat typescript and it flys in my screen without stoping it just keeps repeating my comands for examle I just jused 3 commands : ls, cal, ls it has to show

example

cat typescript

then

ls + screen

cal + screen

ls + screen

thats it it has to stop, but it just keeps repeating its like a big file that keeps scroling in the sreen .

so now I'm trying to finde what did I do wrong or what is wrong
 
Old 09-15-2005, 01:45 PM   #11
Matir
LQ Guru
 
Registered: Nov 2004
Location: San Jose, CA
Distribution: Debian, Arch
Posts: 8,507

Rep: Reputation: 128Reputation: 128
Does script work properly if just executed from the command line?
 
Old 09-15-2005, 01:47 PM   #12
turalo
Member
 
Registered: Sep 2005
Location: NL
Distribution: linux, windows,
Posts: 115

Original Poster
Rep: Reputation: 19
yes

but thera are more small problems , for example if the user logs in 2 times the 1 time things are erased so I'm going to se which extra atributes to put with it and come back with more info
 
Old 09-15-2005, 01:57 PM   #13
Matir
LQ Guru
 
Registered: Nov 2004
Location: San Jose, CA
Distribution: Debian, Arch
Posts: 8,507

Rep: Reputation: 128Reputation: 128
Have you tried script -a to make it append to the previous session?
 
  


Reply



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
Is there a single command to list all hardware installed (command line)? davee Linux - Hardware 6 02-28-2009 07:19 PM
Require Linux/Perl equivalent command for windows Command alix123 Programming 7 08-19-2005 02:23 AM
Why after start of a command the invitation for input next command has not appeared. ukrainet Linux - General 3 06-24-2005 08:16 AM
Key stroke/command to shut down x and go into the command prompt screen? Fear58 Linux - General 1 07-14-2004 07:14 PM
Where is Command line utility for Cups and command tutorial mossy Linux - Software 8 01-16-2004 12:24 AM

LinuxQuestions.org > Forums > Linux Forums > Linux - Newbie

All times are GMT -5. The time now is 05:49 AM.

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
Open Source Consulting | Domain Registration