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!
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.
Introduction to Linux - A Hands on Guide
This guide was created as an overview of the Linux Operating System, geared toward new users as an exploration tour and getting started guide, with exercises at the end of each chapter.
For more advanced trainees it can be a desktop reference, and a collection of the base knowledge needed to proceed with system and network administration. This book contains many real life examples derived from the author's experience as a Linux system and network administrator, trainer and consultant. They hope these examples will help you to get a better understanding of the Linux system and that you feel encouraged to try out things on your own.
Click Here to receive this Complete Guide absolutely free.
create a script that runs after a certain user has logged in
Since this question isn't that clear to me, one word of caution. It depends if you vant to run ze script that is under ze control of a user or if it's for system-wide purposes. In ze first case (say you vant to start say ssh-agent) ~/.bash_login will do. In ze second case you will vant to resort to something outside of the users control for which you can use PAM modules like PAM_script.
Script that is that is under the control of a user will do, like the one you get by editing .bashrc. However, how do you write a script that is run only if x-server is not running on the display that has logged in?
ok if that's the route you wish to go down, you just need to do something like checking the output of the "tty" command with your bash script. if it starts "/dev/tty" then your in a real console, if not, and it's /dev/pts/1 or something then you're in a terminal within an x session:
(tty | grep tty > /dev/null) && command to run when in real terminal || command to run when in emulated terminal
Hmm. still didn't quite work. I'm trying to write a script that is run only if login is not going to start the x-server. (tty | grep tty > /dev/null) shows tty in both cases, so the script is run always. (Because, if the x is goint to be started it is not already on.) I think, that the only time (tty | grep tty > /dev/null) doesn't result tty is, when you are in an emulated console.
When you are running the x-server, it usually runs on emulated console #7, I want to create script, that is not run, if you log in trough emulated console #7 while in runlevel 5. (And, in another words, this means that script is always run, if you don't use an x serve. Because that means, that you are not loggin in trough console #7 at rl 5).
For some reason, the "(tty | grep tty > /dev/null) && command" is run, when I log in at #7 in rl 5, even though the x is supposed to be running (So maybe it is reset at some point in login process? I don't know.)