LinuxQuestions.org
Help answer threads with 0 replies.
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - General
User Name
Password
Linux - General This Linux forum is for general Linux questions and discussion.
If it is Linux Related and doesn't seem to fit in any other forum then this is the place.

Notices


Reply
  Search this Thread
Old 07-30-2001, 11:36 AM   #1
cinnix
Member
 
Registered: Jun 2001
Location: Northern Ohio
Distribution: RedHat, Engarde and LFS
Posts: 237

Rep: Reputation: 30
control aliases by tty


Is there a way to control a users alias by the tty that they are logged in as.

I have a green-screen terminal that I need to have root access on, but my root acount has some aliases that are not compatible on the green-screen terminal.

example

alias ls='ls -a --color'

The --color is causing jumbled characters on the terminal. I really like this option on the main console so I don't really want to get rid of it. I would like to void the alias when I log in on ttyS0 as the root account. I know I can do a \ls to escape the alias but I am hoping for a more convenient method.

Any suggestions or alternate methods would be a great help.
 
Old 07-31-2001, 05:58 AM   #2
unSpawn
Moderator
 
Registered: May 2001
Posts: 29,415
Blog Entries: 55

Rep: Reputation: 3600Reputation: 3600Reputation: 3600Reputation: 3600Reputation: 3600Reputation: 3600Reputation: 3600Reputation: 3600Reputation: 3600Reputation: 3600Reputation: 3600
std app called "env" shows all variables when logged in, look for value exact/aproximating the dev TTY device (Im using SSH_TTY for now), when using bash, on login first .bash_profile is executed, then .bash_login (if necessary), then .bashrc. user-specific aliases are in .bashrc, we can have either .bash_profile or .bashrc check for a few values, and assign the alias like:

TTY=$(echo $SSH_TTY | cut -d "/" -f 3 | cut -c 1-4)
if [ $TTY = ttyp ]; then
alias ls='ls -a --color'
else
alias ls='ls -a'
fi

1. insert for "$SSH_TTY" the /dev/tty value u want (get from env), the "TTY=" line will return the 1st 4 chars like "ttyS"
2. same for "ttyp"

HTH
 
Old 07-31-2001, 10:43 AM   #3
cinnix
Member
 
Registered: Jun 2001
Location: Northern Ohio
Distribution: RedHat, Engarde and LFS
Posts: 237

Original Poster
Rep: Reputation: 30
Thanks a lot, I should have thought of this myself.
 
  


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 On
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
sh: can't access tty; job control turned off. shadowsa SUSE / openSUSE 2 11-21-2005 11:13 AM
change tty => system crashes (ati driver/tty resolution) mosca Debian 6 08-05-2004 07:37 AM
can't access tty; job control turned off johnnybezak Linux - General 4 02-21-2004 10:49 PM
sh: can't access tty, job control turned off tgardner Linux - Software 1 06-07-2003 12:39 AM
Pseudo-TTY Control Under Linux nitr0gen Programming 0 03-21-2002 12:49 PM

LinuxQuestions.org > Forums > Linux Forums > Linux - General

All times are GMT -5. The time now is 01:56 AM.

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