LinuxQuestions.org
Share your knowledge at the LQ Wiki.
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, 01: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, 01:45 PM   #2
Snark1994
Senior Member
 
Registered: Sep 2010
Distribution: Debian
Posts: 1,632
Blog Entries: 3

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

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

Code:
grep "alias" /etc -ir
 
Old 04-30-2013, 02: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, 03:25 PM   #4
Habitual
LQ Veteran
 
Registered: Jan 2011
Location: Abingdon, VA
Distribution: Catalina
Posts: 9,374
Blog Entries: 37

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

Rep: Reputation: 1761Reputation: 1761Reputation: 1761Reputation: 1761Reputation: 1761Reputation: 1761Reputation: 1761Reputation: 1761Reputation: 1761Reputation: 1761Reputation: 1761
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, 04:30 PM   #6
ruario
Senior Member
 
Registered: Jan 2011
Location: Oslo, Norway
Distribution: Slackware
Posts: 2,557

Rep: Reputation: 1761Reputation: 1761Reputation: 1761Reputation: 1761Reputation: 1761Reputation: 1761Reputation: 1761Reputation: 1761Reputation: 1761Reputation: 1761Reputation: 1761
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 04-30-2013, 11:33 PM   #7
Diantre
Member
 
Registered: Jun 2011
Distribution: Slackware
Posts: 515

Rep: Reputation: 234Reputation: 234Reputation: 234
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 03:26 AM. Reason: It's actually 'color=never', not 'color=none'...
 
Old 05-01-2013, 02:45 AM   #8
chrism01
LQ Guru
 
Registered: Aug 2004
Location: Sydney
Distribution: Rocky 9.2
Posts: 18,348

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

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

Rep: Reputation: 1208Reputation: 1208Reputation: 1208Reputation: 1208Reputation: 1208Reputation: 1208Reputation: 1208Reputation: 1208Reputation: 1208
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, 06: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, 06:52 AM   #11
ruario
Senior Member
 
Registered: Jan 2011
Location: Oslo, Norway
Distribution: Slackware
Posts: 2,557

Rep: Reputation: 1761Reputation: 1761Reputation: 1761Reputation: 1761Reputation: 1761Reputation: 1761Reputation: 1761Reputation: 1761Reputation: 1761Reputation: 1761Reputation: 1761
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, 07: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, 07:32 AM   #13
Habitual
LQ Veteran
 
Registered: Jan 2011
Location: Abingdon, VA
Distribution: Catalina
Posts: 9,374
Blog Entries: 37

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

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

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

Rep: Reputation: 1761Reputation: 1761Reputation: 1761Reputation: 1761Reputation: 1761Reputation: 1761Reputation: 1761Reputation: 1761Reputation: 1761Reputation: 1761Reputation: 1761
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 02: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 12:58 AM
unpredictable "delete" "move to trash" or "cut" file menu option dorianrenato Linux - General 3 11-28-2011 06:41 PM
net working eth0 eth1 wlan0 "no connection" "no LAN" "no wi-fi" Cayitano Linux - Newbie 5 12-09-2007 07:11 PM
Standard commands give "-bash: open: command not found" even in "su -" and "su root" mibo12 Linux - General 4 11-11-2007 10:18 PM
LXer: Displaying "MyComputer", "Trash", "Network Servers" Icons On A GNOME Desktop LXer Syndicated Linux News 0 04-02-2007 08:31 AM

LinuxQuestions.org > Forums > Linux Forums > Linux - Newbie

All times are GMT -5. The time now is 03:28 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