Alias problem

Forum rules
Before you post please read how to get help
sehoonha
Level 1
Level 1
Posts: 6
Joined: Sun Jun 22, 2014 1:40 am

Alias problem

Postby sehoonha » Sun Jun 22, 2014 1:46 am

Hi,

I using Linux Mint 17 that is upgraded from Linux Mint 16.
I tried to set aliases as usual, but it goes very wrong :(

This is ".bash_profile" in my home directory
=======
alias install='sudo apt-get install'
=======
It is just a single line, very simple.
But if I typed "alias" to check aliases, it goes totally wrong.

=======
sehoonha@constantinople ~ $ alias
alias grep='grep --colour=auto'
'lias install='sudo apt-get install
alias ll='ls -al'
alias ls='ls --color=auto'
=======

See? How can possibly an entry starts with 'lias?
Of course, if I type install....

=======
sehoonha@constantinople ~ $ install
[sudo] password for sehoonha:
E: Invalid operation install
=======

If someone could help me to resolve this problem, I will really appreciate...

User avatar
Habitual
Level 12
Level 12
Posts: 4207
Joined: Sun Nov 21, 2010 8:31 pm
Location: Youngstown, Ohio

Re: Alias problem

Postby Habitual » Sun Jun 22, 2014 8:58 am

Code: Select all

alias install='sudo apt-get install'
then exit the editor and type in shell:

Code: Select all

source .bash_profile


then type install <package>
enter sudo password and ta da!

you can always check your aliases with

Code: Select all

alias <alias_name>

or

Code: Select all

type <alias_name>
Windows assumes you're an idiot.
Linux demands proof of it.

sehoonha
Level 1
Level 1
Posts: 6
Joined: Sun Jun 22, 2014 1:40 am

Re: Alias problem

Postby sehoonha » Sun Jun 22, 2014 2:05 pm

Thanks for your kind response.

But the problem is that aliases are messed up only when it is *automatically* loaded from .bashrc.

User avatar
Habitual
Level 12
Level 12
Posts: 4207
Joined: Sun Nov 21, 2010 8:31 pm
Location: Youngstown, Ohio

Re: Alias problem

Postby Habitual » Sun Jun 22, 2014 4:57 pm

sehoonha wrote:Thanks for your kind response.

But the problem is that aliases are messed up only when it is *automatically* loaded from .bashrc.

Show us your .bashrc then.

I usually create aliases directly in .bashrc or use

Code: Select all

source /path/to/another/alias/file
in .bashrc

Remove any alias causing issue from .bash_profile
and move it somewhere else, either in .bashrc or a new file and source it in .bashrc
I use .aliases (one of many such files) like so:

Code: Select all

grep aliases .bashrc | grep source
source /home/jj/.aliases

and in it are such things as:

Code: Select all

alias stampl="date '+%a %b %d, %Y - %l:%M:%S %p %Z'" # original date/time stamp
alias stamp="date '+%a %b %d, %Y'"

alias ipcalc='ipcalc -b'
alias cal='cal -3'
alias ip="curl icanhazip.com"
alias heat="sensors -f"


Your alias is probably being 'stepped on' by another alias of similar definition.
in your ~ (home) directory type this:

Code: Select all

grep -w apt-get" .*  | grep -v .bash_history

or

Code: Select all

alias | grep install


What shows up?

You can test aliases with putting them anywhere by using a "--norc option in bash with

Code: Select all

bash --norc

then type

Code: Select all

alias install="sudo apt-get install"
right in the shell.

Verify by typing

Code: Select all

alias install

you should see

Code: Select all

alias install='sudo apt-get install'


test it directly with
install <some_program>

Let us know...

Once it behaves as expected in the "bash --norc" environment, then move it to either .basrhrc
or another sourced file from .bashrc

NOTE: I declared this same alias like

Code: Select all

alias install="sudo apt-get install"

but when I check it, it shows up as

Code: Select all

alias install='sudo apt-get install'
Windows assumes you're an idiot.
Linux demands proof of it.

sehoonha
Level 1
Level 1
Posts: 6
Joined: Sun Jun 22, 2014 1:40 am

Re: Alias problem

Postby sehoonha » Mon Jun 23, 2014 8:44 pm

In fact, as I stated, a single line of "alias install='sudo apt-get install'" is all of my .bashrc.
And the following is the result that I checked by typing "alias"

====
'lias install='sudo apt-get install
====

Of course, if I directly type " alias install='sudo apt-get install' ", it worked very well as usual.

User avatar
Habitual
Level 12
Level 12
Posts: 4207
Joined: Sun Nov 21, 2010 8:31 pm
Location: Youngstown, Ohio

Re: Alias problem

Postby Habitual » Tue Jun 24, 2014 3:44 pm

show us your ~/.bash_profile please.
Windows assumes you're an idiot.
Linux demands proof of it.

sehoonha
Level 1
Level 1
Posts: 6
Joined: Sun Jun 22, 2014 1:40 am

Re: Alias problem

Postby sehoonha » Tue Jun 24, 2014 10:38 pm

I have ~/.profile, which is following

Code: Select all

# if running bash
if [ -n "$BASH_VERSION" ]; then
    # include .bashrc if it exists
    if [ -f "$HOME/.bashrc" ]; then
   . "$HOME/.bashrc"
    fi
fi

# set PATH so it includes user's private bin if it exists
if [ -d "$HOME/bin" ] ; then
    PATH="$HOME/bin:$PATH"
fi

User avatar
WharfRat
Level 16
Level 16
Posts: 6962
Joined: Thu Apr 07, 2011 8:15 pm

Re: Alias problem

Postby WharfRat » Tue Jun 24, 2014 11:01 pm

Does this return anything :?:

Code: Select all

grep -w lias  ./.*
Image

sehoonha
Level 1
Level 1
Posts: 6
Joined: Sun Jun 22, 2014 1:40 am

Re: Alias problem

Postby sehoonha » Tue Jun 24, 2014 11:03 pm

Code: Select all

sehoonha@constantinople ~ $ grep -w lias  ./.*
grep: ./.: Is a directory
grep: ./..: Is a directory
./.bash_history:grep -w lias  ./.*
./.bash_history:grep -w lias  ./.*
grep: ./.cache: Is a directory
grep: ./.cinnamon: Is a directory
grep: ./.config: Is a directory
grep: ./.dbus: Is a directory
grep: ./.dotfiles: Is a directory
grep: ./.dropbox: Is a directory
grep: ./.dropbox-dist: Is a directory
grep: ./.dropbox-master: Is a directory
grep: ./.emacs.d: Is a directory
grep: ./.gconf: Is a directory
grep: ./.gimp-2.8: Is a directory
grep: ./.gnome: Is a directory
grep: ./.gnome2: Is a directory
grep: ./.gnome2_private: Is a directory
grep: ./.linuxmint: Is a directory
grep: ./.local: Is a directory
grep: ./.mozilla: Is a directory
grep: ./.pki: Is a directory
grep: ./.semanticdb: Is a directory
grep: ./.smartgit: Is a directory
grep: ./.speech-dispatcher: Is a directory
grep: ./.subversion: Is a directory
grep: ./.thumbnails: Is a directory
grep: ./.Trash: Is a directory
sehoonha@constantinople ~ $

User avatar
WharfRat
Level 16
Level 16
Posts: 6962
Joined: Thu Apr 07, 2011 8:15 pm

Re: Alias problem

Postby WharfRat » Tue Jun 24, 2014 11:12 pm

What about

Code: Select all

grep -w alias  ./.*
Image

sehoonha
Level 1
Level 1
Posts: 6
Joined: Sun Jun 22, 2014 1:40 am

Re: Alias problem

Postby sehoonha » Tue Jun 24, 2014 11:13 pm

Code: Select all

sehoonha@constantinople ~ $ grep -w alias  ./.*
grep: ./.: Is a directory
grep: ./..: Is a directory
./.bash_history:alias
./.bash_history:alias
./.bash_history:alias
./.bash_history:alias
./.bash_history:alias
./.bash_history:alias
./.bash_history:alias
./.bash_history:alias
./.bash_history:alias make=
./.bash_history:alias
./.bash_history:alias make=make -j4
./.bash_history:alias
./.bash_history:alias make='make -j4'
./.bash_history:alias
./.bash_history:alias
./.bash_history:alias --help
./.bash_history:alias p
./.bash_history:alias -p
./.bash_history:alias
./.bash_history:alias
./.bash_history:alias
./.bash_history:alias
./.bash_history:alias
./.bash_history:alias
./.bash_history:alias
./.bash_history:alias
./.bash_history:alias
./.bash_history:alias
./.bash_history:alias
./.bash_history:alias
./.bash_history:alias
./.bash_history:alias
./.bash_history:locate alias
./.bash_history:alias
./.bash_history:alias
./.bash_history:alias
./.bash_history:alias
./.bash_history:alias
./.bash_history:alias
./.bash_history:alias
./.bash_history:alias
./.bash_history:alias
./.bashrc:alias install='sudo apt-get install'
grep: ./.cache: Is a directory
grep: ./.cinnamon: Is a directory
grep: ./.config: Is a directory
grep: ./.dbus: Is a directory
grep: ./.dotfiles: Is a directory
grep: ./.dropbox: Is a directory
grep: ./.dropbox-dist: Is a directory
grep: ./.dropbox-master: Is a directory
grep: ./.emacs.d: Is a directory
grep: ./.gconf: Is a directory
grep: ./.gimp-2.8: Is a directory
grep: ./.gnome: Is a directory
grep: ./.gnome2: Is a directory
grep: ./.gnome2_private: Is a directory
grep: ./.linuxmint: Is a directory
grep: ./.local: Is a directory
grep: ./.mozilla: Is a directory
grep: ./.pki: Is a directory
grep: ./.semanticdb: Is a directory
grep: ./.smartgit: Is a directory
grep: ./.speech-dispatcher: Is a directory
grep: ./.subversion: Is a directory
grep: ./.thumbnails: Is a directory
grep: ./.Trash: Is a directory
sehoonha@constantinople ~ $

User avatar
WharfRat
Level 16
Level 16
Posts: 6962
Joined: Thu Apr 07, 2011 8:15 pm

Re: Alias problem

Postby WharfRat » Tue Jun 24, 2014 11:17 pm

Call the alias something else, it might be due to the /usr/bin/install file
Image

User avatar
WharfRat
Level 16
Level 16
Posts: 6962
Joined: Thu Apr 07, 2011 8:15 pm

Re: Alias problem

Postby WharfRat » Wed Jun 25, 2014 2:36 pm

WharfRat wrote:Call the alias something else, it might be due to the /usr/bin/install file


@ sehoonha,

I tried the same alias as you and it worked. Are you sourcing anything in /etc/profile, /etc/profile.d/, /etc/bash.bashrc, ~/.bash_profile, ~/.bash_login, ~/.bashrc or ~/.profile :?:

This is certainly odd :?
Image

User avatar
Habitual
Level 12
Level 12
Posts: 4207
Joined: Sun Nov 21, 2010 8:31 pm
Location: Youngstown, Ohio

Re: Alias problem

Postby Habitual » Wed Jun 25, 2014 3:39 pm

Code: Select all

locale
maybe?
Windows assumes you're an idiot.
Linux demands proof of it.


Return to “Scripts & Bash”

Who is online

Users browsing this forum: No registered users and 2 guests