Visit Our UNIX and Linux User Community

Run script at first login user (only)

Thread Tools Search this Thread
Top Forums Shell Programming and Scripting Run script at first login user (only)
# 1  
Old 08-20-2009
Run script at first login user (only)

Hi all,

I would need a script to run only at the first login of a newly created user. And at the first time only. I did some googlework but unfortunatly... I made up it possibly had something to do with the bashrc file.
This script is some kind of info for the user ; with the possiblity to change things like name or passwd.
The environment is a debian server and bash scripting.

Thanks in advance!
# 2  
Old 08-20-2009
I'd suggest that you drop a .profile file in their home dir, do what you need to in it, then have the last line in it copy a more 'normal' default .profile from a template back over the top once you are finished.

Alternatively, you can add the following to the default profile:
if [ `last $USER | wc -l` -lt 2 ]
  <do first login stuff>

Or, you can use a flag file. Just touch /users/home/dir/newbie when you create them ( or put the file in the skeleton dir), then have this in the default .profile
if [ -f /users/home/dir/newbie ]
  <do first login stuff>
  rm -f /users/home/dir/newbie

Previous Thread | Next Thread
Test Your Knowledge in Computers #793
Difficulty: Easy
The base-2 numeral system is a positional notation with a radix of 3.
True or False?

9 More Discussions You Might Find Interesting

1. Solaris

Run commans as no login shell user

Hi All, I have problem running a command with another user who has no login shell the os is solaris 10 i am root and doing the following: su user -s /bin/bash "ls" no output .. no error messages if su - user i got No directory Please use CODE tags as required by forum... (2 Replies)
Discussion started by: BF_DEV
2 Replies

2. Solaris

Login/xterm and run script

Hi - I need to have a script run automatically when I login to my solaris 10 system (running CDE). I stuck this in my .cshrc file: xterm -e /bin/sh -c "/.script-name; exec /bin/sh" When I login, a window comes up and runs the iteractive script-name, and then when the script is done, my... (4 Replies)
Discussion started by: pyroman
4 Replies

3. Shell Programming and Scripting

Login into another user from user inside script

now i have logged in username : ramesh in unix Now i have to created script file to login into another user and have run a command inside that user and after executing the command i have to exit from that user. Inside script, i have to login into su - ram along with password : haihow and have to... (4 Replies)
Discussion started by: rammm
4 Replies

4. Shell Programming and Scripting

How to Login as another user through Shell script from current user[Not Root]

Hi Every body, I would need a shell script program to login as different user and perform some copy commands in the script. example: Supppose ora_toms is the active user ora_toms should be able to run a script where user: ftptomsp pass: XXX should login through and run the commands ... (9 Replies)
Discussion started by: ujjwal27
9 Replies

5. Shell Programming and Scripting

Run a script on login event

Hi, I need to run a script whenever a user logs in to HP-UX unix server. Please let me know how can i implement this. I need to run this script on login for all users starting with 'X' ( x110,x112,x13545, etc). Thanks a lot. (2 Replies)
Discussion started by: pradebban
2 Replies

6. Shell Programming and Scripting

Help to hide shell terminal and run prompt program after ssh login for specified user

Hey guys, I have some task from my office to lock user on the specified directory after the user logged on using ssh. And then run prompt program to fill the required information. Yeah, just like an ATM system. My question: How could I do those?? AFAIK I have to edit the ~./bashrc. But the... (1 Reply)
Discussion started by: franzramadhan
1 Replies

7. Linux

How to open a gnome-terminal in specific workspace and run script within it automatically upon login

OK this is a bit messy. I run Fedora with gnome on a compiz desktop, I have a script (userstart) that opens my 'standard' environment for all my machines when I login. userstart flips to a specific workspace and then opens the required applications in that workspace then flips to the next... (2 Replies)
Discussion started by: Bashingaway
2 Replies

8. AIX

How to: Run at login for only one user

Hi all, I Hope to find the answer. I am new to aix 5L, I have one oracle 10gR2 database server run on ain 5L so when I start my new Job I find that the operater login oracle user and run the, this menu is to make a backup of the database top disk and transfer it to tape,... (3 Replies)
Discussion started by: essamfayez
3 Replies

9. Shell Programming and Scripting

Running script from other user rather than login user

Hi, My requirement is that i am login from ROOT in a script but when any command is coming which is logging to sqlplus then i have to run it with normal user as only normal user have permission to connect to sqlplus . i tried making a script like this : #! /bin/ksh su -... (3 Replies)
Discussion started by: rawatds
3 Replies

Featured Tech Videos