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. |
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.
|
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
|
/etc/profile contains a small bash script usually. Here's a completely fake example:
Code:
# /etc/profile: Don't forget to disclose to users that actions are being logged. |
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 ? : |
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. |
Ok and....
do I heave to resart some file/ demon/ or somthing ? after I made the chage to profile ?
|
ok ok
It works :-D , now lets chalenge it :D thank you for help
I'm going to try it out |
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.
|
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 :D :confused: |
Does script work properly if just executed from the command line?
|
yes
but thera are more small problems , for example if the user logs in 2 times the 1 time things are erased :D so I'm going to se which extra atributes to put with it and come back with more info :D
|
Have you tried script -a to make it append to the previous session?
|
All times are GMT -5. The time now is 01:38 AM. |