LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Slackware (https://www.linuxquestions.org/questions/slackware-14/)
-   -   alias (https://www.linuxquestions.org/questions/slackware-14/alias-273774/)

ilnli 01-04-2005 12:57 PM

alias
 
In which file the aliases are defined for the shell?
cause where I run
alias
i can see that there are many alias by default defined but in which file they are defined I don't know that.
can any body tell me that in which file these aliases are defined in slackware 10.0 cause I have to remove an alias from that file.

busbarn 01-04-2005 01:37 PM

in your .bashrc

(home/usrname/.bashrc)

hussar 01-04-2005 01:38 PM

Do you mean aliases for email addresses that are used as short cuts for addressing emails? Or, do you mean aliases that are shorthand versions of longer commands?

The first type are often stored in an .alias or .aliases file in your home directory (could also be without the leading dot - alias or aliases). It depends somewhat on what you are using as an email client and how the client is configured.

Assuming you are using the bash shell, aliases that are command shortcuts are often found in the .bashrc, .bash_profile or .profile files in your home directory. Look for something like "alias name=command".

ilnli 01-04-2005 01:43 PM

no i don't mean alias for email address I mean alias for the bash shell.

"busbarn" i don't have any (home/usrname/.bashrc)
directory i am on slackware 10.0

acid_kewpie 01-04-2005 01:45 PM

"usrname" isn't literal. he means you need to put the username in place of "usrname". also the file is hidden. it is more than likely there already.

hussar 01-04-2005 01:56 PM

ilnli, in your home directory, do a `ls -a` and you will see one of .bashrc, .bash_profile or .profile. If you don't have any of these, then the alias you are looking for may be in /etc/profile. To change that file, you will probably have to be root.

ilnli 01-06-2005 12:54 PM

[CODE]

root@DARKSTAR:/etc# alias
alias d='dir'
alias dir='/usr/bin/ls $LS_OPTIONS --format=vertical'
alias ls='/usr/bin/ls $LS_OPTIONS'
alias mc='. /usr/share/mc/bin/mc-wrapper.sh'
alias v='vdir'
alias vdir='/usr/bin/ls $LS_OPTIONS --format=long'
root@DARKSTAR:/etc#
root@DARKSTAR:~# ls -a
./ .gstreamer-0.8/ .xine/ ls
../ .gtkrc-1.2-gnome2 .xinitrc ls.log
.DCOPserver_DARKSTAR_:0@ .kde/ .xinitrc-backup minicom.log
.DCOPserver_DARKSTAR__0 .kderc .xmms/ mouse.html
.ICEauthority .links/ CORE_IMPACT_3.3.rar network.html
.Xauthority .local/ Desktop/ out
.bash_history .mcop/ SuSE.Linux.9.1.professional.CD1of5.by.Kiffer.iso out.log
.config/ .mcoprc a.out* packages.html
.fonts.cache-1 .mozilla/ booting.html pakaims.edu
.fonts.conf .netwatch.1.0a drivers/ ppp.html
.fullcircle/ .qt/ gaim-1.1.1.tar.gz.part raptor_chown.c*
.gaim/ .recently-used hsfmodem-7.18.00full/ rootdir.html
.gconf/ .sane/ hsfmodem-7.18.00full-1.i386.rpm.zip slack\ startup.html
.gconfd/ .ssh/ hsfmodem-7.18.00full.tar.gz* stats/
.gkrellm2/ .thumbnails/ hsfmodem-doc-7.18.00full-1.noarch.rpm.zip telnet
.gnome/ .toprc init.html users.html
.gnome2/ .viminfo loadlin16c.txt x.html
.gnome2_private/ .vimrc loadlin16c.zip
root@DARKSTAR:~#

root@DARKSTAR:/etc# ls -a
./ genpowerd.conf isapnp.gone.sample my-medium.cnf scrollkeeper.conf
../ gimp/ issue my-small.cnf securetty
.pwd.lock gnome-vfs-2.0/ issue.net nail.rc security/
DIR_COLORS gnome-vfs-mime-magic joe/ named.

ilnli 01-06-2005 12:54 PM

Code:


root@DARKSTAR:/etc# alias
alias d='dir'
alias dir='/usr/bin/ls $LS_OPTIONS --format=vertical'
alias ls='/usr/bin/ls $LS_OPTIONS'
alias mc='. /usr/share/mc/bin/mc-wrapper.sh'
alias v='vdir'
alias vdir='/usr/bin/ls $LS_OPTIONS --format=long'
root@DARKSTAR:/etc#
root@DARKSTAR:~# ls -a
./                        .gstreamer-0.8/    .xine/                                            ls
../                      .gtkrc-1.2-gnome2  .xinitrc                                          ls.log
.DCOPserver_DARKSTAR_:0@  .kde/              .xinitrc-backup                                  minicom.log
.DCOPserver_DARKSTAR__0  .kderc            .xmms/                                            mouse.html
.ICEauthority            .links/            CORE_IMPACT_3.3.rar                              network.html
.Xauthority              .local/            Desktop/                                          out
.bash_history            .mcop/            SuSE.Linux.9.1.professional.CD1of5.by.Kiffer.iso  out.log
.config/                  .mcoprc            a.out*                                            packages.html
.fonts.cache-1            .mozilla/          booting.html                                      pakaims.edu
.fonts.conf              .netwatch.1.0a    drivers/                                          ppp.html
.fullcircle/              .qt/              gaim-1.1.1.tar.gz.part                            raptor_chown.c*
.gaim/                    .recently-used    hsfmodem-7.18.00full/                            rootdir.html
.gconf/                  .sane/            hsfmodem-7.18.00full-1.i386.rpm.zip              slack\ startup.html
.gconfd/                  .ssh/              hsfmodem-7.18.00full.tar.gz*                      stats/
.gkrellm2/                .thumbnails/      hsfmodem-doc-7.18.00full-1.noarch.rpm.zip        telnet
.gnome/                  .toprc            init.html                                        users.html
.gnome2/                  .viminfo          loadlin16c.txt                                    x.html
.gnome2_private/          .vimrc            loadlin16c.zip
root@DARKSTAR:~#

root@DARKSTAR:/etc# ls -a
./                  genpowerd.conf        isapnp.gone.sample      my-medium.cnf          scrollkeeper.conf
../                gimp/                issue                  my-small.cnf          securetty
.pwd.lock          gnome-vfs-2.0/        issue.net              nail.rc                security/
DIR_COLORS          gnome-vfs-mime-magic  joe/                    named.conf            serial.conf
HOSTNAME            gnopernicus-1.0/      ld.so.cache            networks              services
X11/                gpm-root.conf        ld.so.conf              nntpserver            sgml/
a2ps-site.cfg      gpm-syn.conf          lftp.conf              nscd.conf              shadow
a2ps.cfg            gpm-twiddler.conf    lilo.conf              nsswitch.conf          shadow-
acpi/              group                localtime              ntp/                  shells
adjtime            gshadow              localtime-copied-from@  ntp.conf              skel/
apache/            gtk/                  login.access            pango/                slackware-version
asound.state        gtk-2.0/              login.defs              passwd                smartd.conf
bonobo-activation/  hardwareclock        logrotate.conf          passwd-                sound/
cron.daily/        host.conf            logrotate.d/            pcmcia/                ssh/
cron.hourly/        hosts                lpd.conf                pear.conf              ssl/
cron.monthly/      hosts.allow          lpd.perms              pine.conf              stunnel/
cron.weekly/        hosts.deny            magic@                  ppp/                  syslog.conf
csh.login          hosts.equiv          magic.mime@            printcap              termcap
cups/              hotplug/              mail/                  printcap-lprng-sample  termcap-BSD
dev.d/              hotplug.d/            mdadm.conf              profile                termcap-Linux
dhclient.conf      hsfmodem/            mediaprm                profile.d/            timezone
dhcpc/              identd.conf          minicom.users          proftpd.conf          udev/
dhcpd.conf          im_palette-small.pal  minirc.dfl              protocols              updatedb.conf
dialogrc            im_palette-tiny.pal  modprobe.conf          radiusclient/          vga/
dnsmasq.conf        im_palette.pal        modules.conf            random-seed            warnquota.conf-sample
esd.conf            imrc                  modules.conf.old        rc.d/                  wgetrc
fb.modes            inetd.conf            modules.conf~          resolv.conf            xml/
fdprm              inittab              motd                    rmt@                  ytalkrc
file/              inputrc              mtab                    rndc.key              zprofile@
fonts/              ioctl.save            mtools.conf            rpc
fstab              iproute2/            mutt/                  samba/
ftpusers            irssi.conf            my-huge.cnf            sane.d/
gconf/              isapnp.conf.sample    my-large.cnf            screenrc
root@DARKSTAR:/etc#
root@DARKSTAR:/etc# cat profile
# /etc/profile: This file contains system-wide defaults used by
# all Bourne (and related) shells.

# Set the values for some environment variables:
export MINICOM="-c on"
export MANPATH=/usr/local/man:/usr/man:/usr/X11R6/man
export HOSTNAME="`cat /etc/HOSTNAME`"
export LESSOPEN="|lesspipe.sh %s"
export LESS="-M"

# If the user doesn't have a .inputrc, use the one in /etc.
if [ ! -r "$HOME/.inputrc" ]; then
  export INPUTRC=/etc/inputrc
fi

# Set the default system $PATH:
PATH="/usr/local/bin:/usr/bin:/bin:/usr/X11R6/bin:/usr/games"

# For root users, ensure that /usr/local/sbin, /usr/sbin, and /sbin are in
# the $PATH.  Some means of connection don't add these by default (sshd comes
# to mind).
if [ "`id -u`" = "0" ]; then
  echo $PATH | grep /usr/local/sbin 1> /dev/null 2> /dev/null
  if [ ! $? = 0 ]; then
    PATH=/usr/local/sbin:/usr/sbin:/sbin:$PATH
  fi
fi

# I had problems using 'eval tset' instead of 'TERM=', but you might want to
# try it anyway. I think with the right /etc/termcap it would work great.
# eval `tset -sQ "$TERM"`
if [ "$TERM" = "" -o "$TERM" = "unknown" ]; then
 TERM=linux
fi

# Set ksh93 visual editing mode:
if [ "$SHELL" = "/bin/ksh" ]; then
  VISUAL=emacs
#  VISUAL=gmacs
#  VISUAL=vi
fi

# Set a default shell prompt:
#PS1='`hostname`:`pwd`# '
if [ "$SHELL" = "/bin/pdksh" ]; then
 PS1='! $ '
elif [ "$SHELL" = "/bin/ksh" ]; then
 PS1='! ${PWD/#$HOME/~}$ '
elif [ "$SHELL" = "/bin/zsh" ]; then
 PS1='%n@%m:%~%# '
elif [ "$SHELL" = "/bin/ash" ]; then
 PS1='$ '
else
 PS1='\u@\h:\w\$ '
fi
PS2='> '
export PATH DISPLAY LESS TERM PS1 PS2

# Default umask.  A umask of 022 prevents new files from being created group
# and world writable.
umask 022

# Set up the LS_COLORS and LS_OPTIONS environment variables for color ls:
if [ "$SHELL" = "/bin/zsh" ]; then
 eval `dircolors -z`
elif [ "$SHELL" = "/bin/ash" ]; then
 eval `dircolors -s`
else
 eval `dircolors -b`
fi

# Notify user of incoming mail.  This can be overridden in the user's
# local startup file (~/.bash.login or whatever, depending on the shell)
if [ -x /usr/bin/biff ]; then
 biff y
fi

# 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
unset profile_script

# For non-root users, add the current directory to the search path:
if [ ! "`id -u`" = "0" ]; then
 PATH="$PATH:."
fi

root@DARKSTAR:/etc#

look there is no place where alias are defined but why do I have those aliases?

ilnli 01-06-2005 11:57 PM

any other?

hussar 01-07-2005 08:58 AM

You can try the bash built-in "unalias."

Quoting from the bash manpages published online at this URL http://www.die.net/doc/linux/man/man1/bash.1.html:

alias [-p] [name[=value] ...]
Alias with no arguments or with the -p option prints the list of aliases in the form alias name=value on standard output. When arguments are supplied, an alias is defined for each name whose value is given. A trailing space in value causes the next word to be checked for alias substitution when the alias is expanded. For each name in the argument list for which no value is supplied, the name and value of the alias is printed. Alias returns true unless a name is given for which no alias has been defined.

unalias [-a] [name ...]
Remove each name from the list of defined aliases. If -a is supplied, all alias definitions are removed. The return value is true unless a supplied name is not a defined alias.

hussar 01-07-2005 09:10 AM

One other question. Is the alias only active when you are root, or is it also active when you are logged in under your normal non-root account?

Gronau 01-07-2005 11:41 AM

aliase are only active if the user source a file with aliases (~/.bashrc, ~/.zshrc, /etc/profile...). If your user-account has such file you can use aliases as well.

AdaHacker 01-08-2005 08:27 AM

ilnli, the various 'ls' aliases you're seeing are set by the
Code:

eval `dircolors -b`
command run in /etc/profile. This command sets all the environment variables for coloring ls output in addition to setting afew aliases. The mc alias is set by by the /etc/profile.d/mc.sh script which is run by the
Code:

for profile_script in /etc/profile.d/*.sh ; do
  if [ -x $profile_script ]; then
    . $profile_script
  fi
done

section in /etc/profile. This one can be turned off by making /etc/profile.d/mc.sh non-executable.

vonst 01-08-2005 10:29 PM

Wow, I remember those aliases from a long time ago. I think I kept one of them... BUT, I forget where I erased them from. I inserted a "source ~/.alias" line into my /etc/profile line and it loads the whole profile list *I* built.

SOP loads your system from both the /etc/ directory and your /home/xxx directory. I suggest doing a "grep vdir *" and "grep vdir .*" in both directories. "vdir" is pretty unique and should pop up a file name that is keeping it.

--vonSt


All times are GMT -5. The time now is 03:14 AM.