Linux - NewbieThis 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
Welcome to LinuxQuestions.org, a friendly and active Linux Community.
You are currently viewing LQ as a guest. By joining our community you will have the ability to post topics, receive our newsletter, use the advanced search, subscribe to threads and access many other special features. Registration is quick, simple and absolutely free. Join our community today!
Note that registered members see fewer ads, and ContentLink is completely disabled once you log in.
If you have any problems with the registration process or your account login, please contact us. If you need to reset your password, click here.
Having a problem logging in? Please visit this page to clear all LQ-related cookies.
Get a virtual cloud desktop with the Linux distro that you want in less than five minutes with Shells! With over 10 pre-installed distros to choose from, the worry-free installation life is here! Whether you are a digital nomad or just looking for flexibility, Shells can put your Linux machine on the device that you want to use.
Exclusive for LQ members, get up to 45% off per month. Click here for more info.
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, 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
#
# 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 ? :
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.
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
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
LinuxQuestions.org is looking for people interested in writing
Editorials, Articles, Reviews, and more. If you'd like to contribute
content, let us know.