How do I allow a login script for one user in fedora? ~/.initrc doesn't seem to work, and I tried adding an executable to /etc/init.d but that's for all users (and it didnt work either anyway).
Linux – Local User Login Script Fedora Linux
fedoralinuxlocalloginscript
Related Solutions
Short answer:
You command was incorrect:
useradd -d /path/to/home -s /path/to/shell -g admin username
Use
useradd -d /home/username -s /bin/sh -g admin username
to create normal user.
Tady posted some info in the chat:
tady:$:15750:0:99999:7:::
squarepeg:$:15751:0:99999:7::: that's the /etc/shadow
and the /etc/passwd
tady:x:5001:5001::/var/www:/bin/false
squarepeg:x:5003:109:square peg design:/var/www:/bin/false
The /bin/false home directory exists, I created it so users had somewhere to go even though they never use it (though looking at it, it's owner and group are root:root. would this matter?) The /var/www shell is where I want them to go when they login
"The format of the passwd file is pretty standard."
Yes, it is true. And format is informally described here: Wikipedia:Passwd (file); or, more normative, man 5 passwd
(from ubuntu)
Check an example:
jsmith:.......:/home/jsmith:/bin/sh
Wiki decodes it as:
The sixth field is the path to the user's home directory. The seventh field is the program that is started every time the user logs into the system. ... this is usually one of the system's command line interpreters (shells).
So, jmsith has home directory /home/jsmith
and shell program /bin/sh
which is legal shell (all legal shells are listed in the file /etc/shells
). Check man shells
, it says:
/etc/shells is a text file which contains the full pathnames of valid login shells...
Be aware that there are programs which consult this file to find out if a user is a normal user. E.g.: ftp daemons traditionally disallow access to users with shells not included in this file.
In my Linux /bin/false
is not listed here as valid shell.
According to citation of your passwd, tady and squarepeg have the home dir /var/www
and /bin/false
is their shell program. When they login in, shell is started; after shell termination, session is closed. /bin/false
is simple unix program which ... exits in short time (check Wikipedia:False (Unix) or just think about it as main(){return 1;}
).
Normal shell is the interactive program which reads user input and executes it in endless loop. Shell is started when you does ssh
to the computer. And you can't use ftp for users who has /bin/false
shell.
PS: If you want to prohibit somebody of using ssh, but allow them to use vsftpd, there are hacks
- hack of
/etc/pam.d/vsftpd
file: http://linux-tips.org/article/70/users-with-bin-false-shell-to-login-on-vsftpd - hask with adding
/bin/false
to list of valid shells: http://www.linuxexpert.ro/Linux-Tutorials/setup-vsftp-with-no-shell-access.html - or ask here.
Figured this out. Just had to put the desktop file in ~/.config/autostart
and then it worked like a charm. Thank you so much for the help though Hastur. If anyone is interested in the script, an installation one is available here Link
Best Answer
+1 for Dennis' answer; this should work for the shell logins (and if not, you'll want to check if the appropriate configuration file is being read/sourced at shell start up).
If you want to run something when a Fedora user logs into X (either Gnome or KDE), then you'll need to do something slightly different. If it's just for your user, you can (when you're running Gnome) use the System -> Preferences -> Sessions menu to set any items you want to run.
If you want to do this using a file, I think Gnome sources: ~/.config/autostart . The entries in here should be in FreeDesktop style. For example:
I'm not sure how to do this using KDE though...