LinuxQuestions.org
Review your favorite Linux distribution.
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Server
User Name
Password
Linux - Server This forum is for the discussion of Linux Software used in a server related context.

Notices


Reply
  Search this Thread
Old 11-16-2021, 05:58 AM   #1
kaza
Member
 
Registered: Apr 2010
Distribution: FC17
Posts: 343

Rep: Reputation: 2
Login to "tcsh" doesn't change to $HOME directory.


Hello!

After adding a new user (through NIS server), when running "su new_user"
the current directory doesn't chanes to $HOME.
The shell in use is "tcsh" (for historical reasons: too much to rewrite for "bash"),
after "su new_user" running "echo $HOME" displays the correct $HOME directory,
running "cd" without arguments changes correctly to the $HOME directory.
Other, previously existing users also running "tcsh" have no such problem.
And, for the new user, the same problem exists on two different servers.
There is no ".login" file in our home directories.

I looked at the files /etc/csh.login and /etc/login.defs but didn't see there
anything that hints to the initial directory after login.

Any ideas, what causes "tcsh" to "cd" (or, in this case, not to "cd") to $HOME?

TIA,
 
Old 11-16-2021, 07:32 AM   #2
Turbocapitalist
LQ Guru
 
Registered: Apr 2005
Distribution: Linux Mint, Devuan, OpenBSD
Posts: 7,386
Blog Entries: 3

Rep: Reputation: 3776Reputation: 3776Reputation: 3776Reputation: 3776Reputation: 3776Reputation: 3776Reputation: 3776Reputation: 3776Reputation: 3776Reputation: 3776Reputation: 3776
Wouldn't that be with the -l option to start a login shell and have an environment like a normal login?

Code:
su -l newuser
If you plan to migrate, despite Bash being the default, do take a look at Zsh, Fish, and Oil to see the current state of available shells. Myself, while I started out on tcsh, I quickly moved to Bash and have been there for ages. Lately I am even dabbling with Zsh.
 
Old 11-17-2021, 01:53 AM   #3
MadeInGermany
Senior Member
 
Registered: Dec 2011
Location: Simplicity
Posts: 2,849

Rep: Reputation: 1224Reputation: 1224Reputation: 1224Reputation: 1224Reputation: 1224Reputation: 1224Reputation: 1224Reputation: 1224Reputation: 1224
Or the classic Unix
Code:
su - new_user
See the man page
Code:
man su
 
Old 11-17-2021, 01:43 PM   #4
kaza
Member
 
Registered: Apr 2010
Distribution: FC17
Posts: 343

Original Poster
Rep: Reputation: 2
Yes, I've read that adding the "-l" switch forces "login shell".
But why the same "su username" command behaves differently for old users and the new user?
I can live with

alias su 'su -l'

but I have a feeling that it's like sweeping the problem under the carpet: I still don't
understand the reason for same command behaving differently for different users.
Other users have no alias for "su" but somehow using this command without
the "-l" (or any other) switch it behaves like login shell.

TIA,
kaza.
 
Old 11-17-2021, 06:22 PM   #5
MadeInGermany
Senior Member
 
Registered: Dec 2011
Location: Simplicity
Posts: 2,849

Rep: Reputation: 1224Reputation: 1224Reputation: 1224Reputation: 1224Reputation: 1224Reputation: 1224Reputation: 1224Reputation: 1224Reputation: 1224
Each tcsh runs the system /etc/csh.cshrc then the user's .tcshrc or .cshrc
A login tcsh additionally runs the system /etc/csh.login then the user's .login

If different users have different behavior with a plain su then look at their .tcshrc files if present otherwise their .cshrc files.
 
  


Reply



Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
Login Error- Could not chdir to home directory /home/UserID: No such file or directory abhi_jais Linux - Newbie 1 03-24-2018 12:01 PM
"Home directory already exists. Please enter another home directory path." Daravon Ubuntu 2 02-15-2009 10:26 PM
Help With Java Problem Please"""""""""""" suemcholan Linux - Newbie 1 04-02-2008 06:02 PM
root login shell tcsh does not allow "su" CooManChu Linux - Security 2 12-24-2004 02:23 PM
bash equivalence of tcsh "alias em "emacs \!:1 &""? rgiggs Slackware 3 07-29-2004 02:07 AM

LinuxQuestions.org > Forums > Linux Forums > Linux - Server

All times are GMT -5. The time now is 07:44 PM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration