2

I am unable to login via tty{1-6} as a normal user. I can only login as root.

When logged in with a normal user, the computer displays the greeting message from /etc/motd and logs me out immediately.

What could be the reason?

Which log files could be useful to check?

I can login fine with a normal user using Gnome on tty7.

Thomas Dickey
  • 76,765
akazlou
  • 133

2 Answers2

1

When you log in on a text mode console or over the network, your login shell is executed. It reads some system-wide and per-user configuration files; here are the most common ones (if your shell isn't listed here, refer to its documentation):

  • sh, ksh: /etc/profile; ~/.profile
  • bash: /etc/profile; ~/.bash_profile, if absent ~/.bash_login, if absent ~/.profile.
  • zsh: /etc/zshenv, /etc/zprofile, /etc/zlogin, /etc/zshrc (if interactive); ~/.zshenv, ~/.zprofile, ~/.zlogin, ~/.zshrc (if interactive)
  • csh, tcsh: ~/.login
  • fish: /usr/share/fish/config.fish, /etc/fish/config.fish; ~/.config/fish/config.fish`

These files may load other files; in particular many distributions set up /etc/profile to load files in /etc/profile.d.

If any of these files contains something that causes the shell to exit, you'll be logged out without having the opportunity to type a command.

You can add a line containing set -x to the top of the applicable file to see a trace of the commands that are executed. (That's for Bourne-style shells; use set echo in csh, and fish has no such thing)

When you log in via the GUI (on a display manager), your login shell isn't executed; however most systems arrange to run either sh or bash and load /etc/profile and ~/.profile.

If you're stuck because you can't log in:

  • Try pressing Ctrl+C during the login sequence. If you hit it at the right time, it'll interrupt the shell just as it's starting to load the profile file and you'll get a command line.
  • Run commands over the network. ssh mymachine.example.com 'mv .profile no.profile' moves a problematic ~/.profile out of the way; it doesn't load the profile files because the remote shell isn't a login shell. (But bash is weird: it loads .bashrc if its parent is rshd or sshd even though the shell isn't interactive.)
  • Access the account over FTP or SFTP.
0

Ok, found out, that there were some files left from my experiments with cdm, so /etc/profile.d/zzz-cdm-profile.sh was executed during tty login which triggered the log out immediately. Removing this one - fixed the problem.

akazlou
  • 133