LinuxQuestions.org
Register a domain and help support LQ
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Software
User Name
Password
Linux - Software This forum is for Software issues.
Having a problem installing a new program? Want to know which application is best for the job? Post your question in this forum.

Notices

Reply
 
Search this Thread
Old 03-22-2010, 03:11 AM   #1
Himilhil
Member
 
Registered: Jun 2009
Posts: 52

Rep: Reputation: 15
GNU Screen doesn't start shells as a login shell


I want to have an ls' output colorization in gnu screen. Colorization in my system (Slackware 13) is realized by aliasing of ls in /etc/profile.d/coreutils-dircolors.sh:
Code:
$ alias ls
alias ls='/bin/ls $LS_OPTIONS'
where $LS_OPTIONS is
Code:
$ echo $LS_OPTIONS
-F -T 0 --color=auto
But in screen this alias isn't defined. It seems like /etc/profile script isn't executed at shell starting in screen. I think it happens because screen starts a shell not as a login shell. I tried to correct it by adding
Code:
shell -$SHELL
to ~/.screenrc or to /etc/screenrc. The problem is the same. By the way when I start screen as a root I haven't this problem. What's wrong?
 
Old 03-22-2010, 03:37 AM   #2
grail
Guru
 
Registered: Sep 2009
Location: Perth
Distribution: Manjaro
Posts: 7,686

Rep: Reputation: 1987Reputation: 1987Reputation: 1987Reputation: 1987Reputation: 1987Reputation: 1987Reputation: 1987Reputation: 1987Reputation: 1987Reputation: 1987Reputation: 1987
Assuming main shell is bash, I would look at what the setting are for .bashrc and .bash_profile for root.
I believe this should shed some light on the subject. You might also want to google for bashrc bash_profile
differences
 
Old 03-22-2010, 04:13 AM   #3
catkin
LQ 5k Club
 
Registered: Dec 2008
Location: Tamil Nadu, India
Distribution: Servers: Debian Squeeze and Wheezy. Desktop: Slackware64 14.0. Netbook: Slackware 13.37
Posts: 8,563
Blog Entries: 29

Rep: Reputation: 1179Reputation: 1179Reputation: 1179Reputation: 1179Reputation: 1179Reputation: 1179Reputation: 1179Reputation: 1179Reputation: 1179
Quote:
Originally Posted by Himilhil View Post
I want to have an ls' output colorization in gnu screen. Colorization in my system (Slackware 13) is realized by aliasing of ls in /etc/profile.d/coreutils-dircolors.sh:
Code:
$ alias ls
alias ls='/bin/ls $LS_OPTIONS'
where $LS_OPTIONS is
Code:
$ echo $LS_OPTIONS
-F -T 0 --color=auto
But in screen this alias isn't defined. It seems like /etc/profile script isn't executed at shell starting in screen. I think it happens because screen starts a shell not as a login shell. I tried to correct it by adding
Code:
shell -$SHELL
to ~/.screenrc or to /etc/screenrc. The problem is the same. By the way when I start screen as a root I haven't this problem. What's wrong?
Non-login shells are necessarily descendant processes of a login ancestor shell in the normal interactive working environment. Thus they inherit anything exported when the login shell ran /etc/profile (and not unset after then). AFAIK this does not include aliases and is one of the reasons for preferring functions over aliases, because functions can be exported.

The conventional solution to this issue is to define aliases in ~/.bashrc and source ~/.bashrc from within /etc/profile
Code:
if [ -f ~/.bashrc ]; then . ~/.bashrc; fi
Another solution in this particular case would be to source /etc/profile.d/coreutils-dircolors.sh from within ~/.bashrc.

As grail suggested, the root discrepancy may lie in specifics of root's bash startup files or you may be running a login shell when starting a terminal session for root (a very Good Thing for security).

Documentation on bash startup files here.

Last edited by catkin; 03-22-2010 at 04:15 AM. Reason: Sub-editing: clarity
 
Old 03-22-2010, 04:52 AM   #4
Himilhil
Member
 
Registered: Jun 2009
Posts: 52

Original Poster
Rep: Reputation: 15
.bashrc file with ls alias definition is placed in root's home directory indeed. Hmmm... I can't even remember when I placed it there. But if alias definition is commented in this file colorization don't work in root's screen too. I've copied root's .bashrc to my home directory. First it didn't resolve my problem. It was needed to define shell as /bin/bash for my user obviously. Before that default shell (/bin/sh) was used for my user. I have no idea why .bashrc wasn't used in this case because /bin/sh is symlink linked to /bin/bash. Nevertheless after I had defined shell for my user in /etc/passwd colorization came to be worked in screen.
 
  


Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search

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
[SOLVED] GNU screen---uses my login password on other distros, but not on Slackware. koenigdavidmj Slackware 2 01-26-2010 01:37 AM
Start VM from login screen on Ubuntu 9.10 tophee Linux - Virtualization and Cloud 9 11-03-2009 08:45 AM
Trying to start a GNU screen session at startup th_alton Linux - Newbie 2 09-10-2009 04:31 PM
LXer: Multiple shell management with GNU Screen LXer Syndicated Linux News 0 02-12-2009 12:40 AM
Text Shell Login Welcome Screen Help tag Linux - Desktop 2 01-07-2007 08:26 PM


All times are GMT -5. The time now is 05:08 PM.

Main Menu
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
identi.ca: @linuxquestions
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration