LinuxQuestions.org
Welcome to the most active Linux Forum on the web.
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Newbie
User Name
Password
Linux - Newbie This Linux forum is for members that are new to Linux.
Just starting out and have a question? If it is not in the man pages or the how-to's this is the place!

Notices


Reply
  Search this Thread
Old 04-30-2013, 02:38 PM   #1
wolffjw
LQ Newbie
 
Registered: Apr 2013
Location: Central Florida
Posts: 6

Rep: Reputation: Disabled
how to unalias "vi" and "ls" globally in Linux


I'm perplexed. I am unable to figure out how to permanently unalias "vi" and "ls" (mainly to get rid of the color).

I've looked in /etc/bashrc, /etc/profile, /root/.bashrc, etc, but no where can I find where these aliases are set.

Obviously, I can add an "unalias <cmd>" into the above files and that will resolve the issue, but that seems like I am not addressing the real problem of where these aliases are set.
 
Old 04-30-2013, 02:45 PM   #2
Snark1994
Senior Member
 
Registered: Sep 2010
Location: Wales, UK
Distribution: Arch
Posts: 1,632
Blog Entries: 3

Rep: Reputation: 345Reputation: 345Reputation: 345Reputation: 345
Have you looked in ~/.bashrc ? You could, of course, run

Code:
grep "alias" ~/.* -i
and

Code:
grep "alias" /etc -ir
 
Old 04-30-2013, 03:06 PM   #3
wolffjw
LQ Newbie
 
Registered: Apr 2013
Location: Central Florida
Posts: 6

Original Poster
Rep: Reputation: Disabled
Hi Snark1994.

Yes, I tried first "grep "alias" ~/.* -i" and saw nothing relevant.
Then I tried "grep "alias" /etc -ir", and this pointed to some files in /etc/profile.d
It seems some files in this directory are setting the aliases that I'm annoyed with.
e.g.,

colorls.csh:alias ll 'ls -l'
colorls.csh:alias l. 'ls -d .*'
colorls.csh:alias ll 'ls -l --color=tty'
colorls.csh:alias l. 'ls -d .* --color=tty'
colorls.csh:alias ls 'ls --color=tty'
colorls.sh:alias ll='ls -l' 2>/dev/null
colorls.sh:alias l.='ls -d .*' 2>/dev/null
colorls.sh: alias ll='ls -l --color=tty' 2>/dev/null
colorls.sh: alias l.='ls -d .* --color=tty' 2>/dev/null
colorls.sh: alias ls='ls --color=tty' 2>/dev/null
vim.csh: alias vi vim
vim.sh: # for bash and zsh, only if no alias is already set
vim.sh: alias vi >/dev/null 2>&1 || alias vi=vim
which-2.sh:alias which='alias | /usr/bin/which --tty-only --read-alias --show-dot --show-tilde'

But, logging in directly as root, and the typing "alias", I do not see some of these aliases.
For example, the alias for vi to point to vim instead.

# alias
alias cp='cp -i'
alias l.='ls -d .* --color=tty'
alias ll='ls -l --color=tty'
alias ls='ls --color=tty'
alias mv='mv -i'
alias rm='rm -i'
alias which='alias | /usr/bin/which --tty-only --read-alias --show-dot --show-tilde'
 
Old 04-30-2013, 04:25 PM   #4
Habitual
LQ Addict
 
Registered: Jan 2011
Location: Youngstown, Ohio
Distribution: LM17.1/Xfce4.11.8
Posts: 7,166
Blog Entries: 10

Rep: Reputation: 1979Reputation: 1979Reputation: 1979Reputation: 1979Reputation: 1979Reputation: 1979Reputation: 1979Reputation: 1979Reputation: 1979Reputation: 1979Reputation: 1979
Code:
grep -i "source " ~/.bashrc
???
 
Old 04-30-2013, 05:21 PM   #5
ruario
Senior Member
 
Registered: Jan 2011
Location: Oslo, Norway
Distribution: Slackware
Posts: 2,175

Rep: Reputation: 1172Reputation: 1172Reputation: 1172Reputation: 1172Reputation: 1172Reputation: 1172Reputation: 1172Reputation: 1172Reputation: 1172
Quote:
Originally Posted by wolffjw View Post
Then I tried "grep "alias" /etc -ir", and this pointed to some files in /etc/profile.d
It seems some files in this directory are setting the aliases that I'm annoyed with.
Quote:
Originally Posted by wolffjw View Post
But, logging in directly as root, and the typing "alias", I do not see some of these aliases.
For example, the alias for vi to point to vim instead.
It may be that some or all of the the scripts in /etc/profile.d are only applied to regular users, e.g. your /etc/profile might check for your userid being something other than 0.

What distro are you using?
 
Old 04-30-2013, 05:30 PM   #6
ruario
Senior Member
 
Registered: Jan 2011
Location: Oslo, Norway
Distribution: Slackware
Posts: 2,175

Rep: Reputation: 1172Reputation: 1172Reputation: 1172Reputation: 1172Reputation: 1172Reputation: 1172Reputation: 1172Reputation: 1172Reputation: 1172
Quote:
Originally Posted by Habitual View Post
Code:
grep -i "source " ~/.bashrc
???
Probably not there because he has already realised that the alias's are being set in /etc/profile.d. In any case you can source stuff with a simple '.', e.g. from Slackware's default /etc/profile:

Code:
# Append any additional sh scripts found in /etc/profile.d/:
for profile_script in /etc/profile.d/*.sh ; do
  if [ -x $profile_script ]; then
    . $profile_script
  fi
done
So that grep may potentially miss things that are sourced in.
 
1 members found this post helpful.
Old 05-01-2013, 12:33 AM   #7
Diantre
Member
 
Registered: Jun 2011
Distribution: Slackware
Posts: 495

Rep: Reputation: 212Reputation: 212Reputation: 212
How about an alias in ~/.bashrc to avoid the color output?

Code:
alias ls='ls --color=never'
That way it's not necessary to change the system configuration. Well, unless changing the system configuration is actually needed/wanted...

Last edited by Diantre; 05-01-2013 at 04:26 AM. Reason: It's actually 'color=never', not 'color=none'...
 
Old 05-01-2013, 03:45 AM   #8
chrism01
LQ Guru
 
Registered: Aug 2004
Location: Sydney
Distribution: Centos 6.8, Centos 5.10
Posts: 17,240

Rep: Reputation: 2324Reputation: 2324Reputation: 2324Reputation: 2324Reputation: 2324Reputation: 2324Reputation: 2324Reputation: 2324Reputation: 2324Reputation: 2324Reputation: 2324
How about just re-aliasing it back to real ls
Code:
which ls
 /bin/ls

# therefore
alias ls=/bin/ls
 
Old 05-01-2013, 05:18 AM   #9
catkin
LQ 5k Club
 
Registered: Dec 2008
Location: Tamil Nadu, India
Distribution: Debian
Posts: 8,576
Blog Entries: 31

Rep: Reputation: 1195Reputation: 1195Reputation: 1195Reputation: 1195Reputation: 1195Reputation: 1195Reputation: 1195Reputation: 1195Reputation: 1195
Sometimes it helps to trace what happens (there can be a lot of output, especially when using bash --login instead of just bash to trace what happens when a login shell starts up):
Code:
set -xv
bash
Some scrippets in /etc/profile.d have comments to identify themselves when they are run. Helpful

/etc/profile.d/*.sh files can be disabled by changing their extensions, by emptying them or by removing read permission from them. The first method will not survive an upgrade, the second two probably will, depending on what the upgrade does when it finds package files have been modified.
 
2 members found this post helpful.
Old 05-01-2013, 07:46 AM   #10
wolffjw
LQ Newbie
 
Registered: Apr 2013
Location: Central Florida
Posts: 6

Original Poster
Rep: Reputation: Disabled
Quote:
Originally Posted by ruario View Post
It may be that some or all of the the scripts in /etc/profile.d are only applied to regular users, e.g. your /etc/profile might check for your userid being something other than 0.

What distro are you using?
It is the same regardless whether I log in as root, or another user.

Red Hat Enterprise Linux Server release 5.7 (Tikanga)
 
Old 05-01-2013, 07:52 AM   #11
ruario
Senior Member
 
Registered: Jan 2011
Location: Oslo, Norway
Distribution: Slackware
Posts: 2,175

Rep: Reputation: 1172Reputation: 1172Reputation: 1172Reputation: 1172Reputation: 1172Reputation: 1172Reputation: 1172Reputation: 1172Reputation: 1172
Quote:
Originally Posted by wolffjw View Post
It is the same regardless whether I log in as root, or another user.
Ok, then I misunderstood you. In that case I would go with catkin's advice and remove execute permissions on the files in /etc/profile.d/ that you do not want run.
 
1 members found this post helpful.
Old 05-01-2013, 08:13 AM   #12
wolffjw
LQ Newbie
 
Registered: Apr 2013
Location: Central Florida
Posts: 6

Original Poster
Rep: Reputation: Disabled
Quote:
Originally Posted by Diantre View Post
How about an alias in ~/.bashrc to avoid the color output?
Well, there are a few similar options that I can resolve the problem, but for now, I'm mainly trying to find the source that is creating the aliases, such as vi to use vim with color.
 
Old 05-01-2013, 08:32 AM   #13
Habitual
LQ Addict
 
Registered: Jan 2011
Location: Youngstown, Ohio
Distribution: LM17.1/Xfce4.11.8
Posts: 7,166
Blog Entries: 10

Rep: Reputation: 1979Reputation: 1979Reputation: 1979Reputation: 1979Reputation: 1979Reputation: 1979Reputation: 1979Reputation: 1979Reputation: 1979Reputation: 1979Reputation: 1979
uninstall vi and I'll bet you'll know exactly where they (aliases) are "at"....
 
Old 05-01-2013, 08:41 AM   #14
ruario
Senior Member
 
Registered: Jan 2011
Location: Oslo, Norway
Distribution: Slackware
Posts: 2,175

Rep: Reputation: 1172Reputation: 1172Reputation: 1172Reputation: 1172Reputation: 1172Reputation: 1172Reputation: 1172Reputation: 1172Reputation: 1172
deleted accidental double post, see below for my updated response

Last edited by ruario; 05-01-2013 at 08:56 AM.
 
Old 05-01-2013, 08:54 AM   #15
ruario
Senior Member
 
Registered: Jan 2011
Location: Oslo, Norway
Distribution: Slackware
Posts: 2,175

Rep: Reputation: 1172Reputation: 1172Reputation: 1172Reputation: 1172Reputation: 1172Reputation: 1172Reputation: 1172Reputation: 1172Reputation: 1172
Quote:
Originally Posted by wolffjw View Post
I'm mainly trying to find the source that is creating the aliases, such as vi to use vim with color.
You said above that you already found that vi was using vim because of /etc/profile.d/vim.sh, i.e.

Quote:
Originally Posted by wolffjw View Post
Code:
vim.sh: alias vi >/dev/null 2>&1 || alias vi=vim
You also found that /etc/profile.d/colorls.sh was the reason for coloured ls output, i.e.

Quote:
Originally Posted by wolffjw View Post
Code:
colorls.sh:alias ll='ls -l' 2>/dev/null
colorls.sh:alias l.='ls -d .*' 2>/dev/null
colorls.sh: alias ll='ls -l --color=tty' 2>/dev/null
colorls.sh: alias l.='ls -d .* --color=tty' 2>/dev/null
colorls.sh: alias ls='ls --color=tty' 2>/dev/null
As for the fact that vim uses colour, this is probably down to vim's own configuration file.

EDIT: Simplest fix is probably to install actual vi then remove read permissions on /etc/profile.d/vim.sh and /etc/profile.d/colorls.sh. You will then need to log out and back in again.

Last edited by ruario; 05-03-2013 at 03:43 PM. Reason: changed execute permissions to read permissions as likely to be more foolproof.
 
1 members found this post helpful.
  


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
What are the options "Nosuid" "mode" "size" in /etc/fstab? tuxfiles.org does not help pstein Linux - Newbie 1 11-16-2012 01:58 AM
unpredictable "delete" "move to trash" or "cut" file menu option dorianrenato Linux - General 3 11-28-2011 07:41 PM
net working eth0 eth1 wlan0 "no connection" "no LAN" "no wi-fi" Cayitano Linux - Newbie 5 12-09-2007 08:11 PM
Standard commands give "-bash: open: command not found" even in "su -" and "su root" mibo12 Linux - General 4 11-11-2007 11:18 PM
LXer: Displaying "MyComputer", "Trash", "Network Servers" Icons On A GNOME Desktop LXer Syndicated Linux News 0 04-02-2007 09:31 AM


All times are GMT -5. The time now is 06:20 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
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration