Hello,
I've been trying to locate the bash files for placing command aliases, both for root and user accounts. Most of the help online says to place the alias lines (I know the syntax for these) in .bashrc and .bash_aliases, but I see neither in user or root home directories. Can anyone please give me a tip here?
Thanks
Where to place my command aliases?
Forum rules
LMDE 2 has reached end of support as of 1-1-2019
LMDE 2 has reached end of support as of 1-1-2019
Where to place my command aliases?
Last edited by LockBot on Wed Dec 28, 2022 7:16 am, edited 1 time in total.
Reason: Topic automatically closed 6 months after creation. New replies are no longer allowed.
Reason: Topic automatically closed 6 months after creation. New replies are no longer allowed.
Re: Where to place my command aliases?
Put them in .bashrc or put:
In .bashrc to use .bash_aliases.
Steve
Code: Select all
if [ -f ~/.bash_aliases ]; then
. ~/.bash_aliases
fi
Steve
Re: Where to place my command aliases?
Hmm...
I don't have either files in root or user directories. Here is what my default install has in my root directory:
olaris ~ # ls -la
total 40
drwx------ 8 root root 4096 Jul 14 09:28 .
drwxr-xr-x 23 root root 4096 Jul 14 09:17 ..
drwx------ 2 root root 4096 Jul 14 11:03 .aptitude
-rw------- 1 root root 333 Jul 14 11:16 .bash_history
drwx------ 3 root root 4096 Jul 14 11:18 .gconf
drwx------ 2 root root 4096 Apr 18 11:15 .mateconf
-rw-r--r-- 1 root root 140 Nov 19 2007 .profile
drwx------ 3 root root 4096 Jul 14 09:29 .synaptic
drwxr-xr-x 2 root root 4096 Nov 26 2010 .ure
drwxr-xr-x 2 root root 4096 Nov 26 2010 .wapi
If I create those 2 files, what exactly should be in them?
Thanks,
u0
I don't have either files in root or user directories. Here is what my default install has in my root directory:
olaris ~ # ls -la
total 40
drwx------ 8 root root 4096 Jul 14 09:28 .
drwxr-xr-x 23 root root 4096 Jul 14 09:17 ..
drwx------ 2 root root 4096 Jul 14 11:03 .aptitude
-rw------- 1 root root 333 Jul 14 11:16 .bash_history
drwx------ 3 root root 4096 Jul 14 11:18 .gconf
drwx------ 2 root root 4096 Apr 18 11:15 .mateconf
-rw-r--r-- 1 root root 140 Nov 19 2007 .profile
drwx------ 3 root root 4096 Jul 14 09:29 .synaptic
drwxr-xr-x 2 root root 4096 Nov 26 2010 .ure
drwxr-xr-x 2 root root 4096 Nov 26 2010 .wapi
If I create those 2 files, what exactly should be in them?
Thanks,
u0
Re: Where to place my command aliases?
In your users home - mine is /home/molly3/.bashrc
Then reload with:
from a terminal
Then reload with:
Code: Select all
source ~/.bashrc
Re: Where to place my command aliases?
You can simply create the files if they don't already exist. Then, do as xircon explained in his first response.
Re: Where to place my command aliases?
Okay... so I created a blank file called ".bashrc" in both root's home directory and my user's home directory. Both chmod to 755 with the aliases placed in the files for example: alias lsx='ls -la | more'veggen wrote:You can simply create the files if they don't already exist. Then, do as xircon explained in his first response.
I rebooted the computer and voila, none of the aliases work for any account. My knee-jerk reaction is that the .bashrc file needs something in it besides just command aliases and if this is true,
I wonder what those things are. There are plenty of sample .bashrc files on the Web but they differ slightly, leaving me confused as to what to do next.
-cj
Re: Where to place my command aliases?
Could you explain why you want to do stuff for the root account?userzero wrote:Hello,
I've been trying to locate the bash files for placing command aliases, both for root and user accounts. Most of the help online says to place the alias lines (I know the syntax for these) in .bashrc and .bash_aliases, but I see neither in user or root home directories. Can anyone please give me a tip here?
Thanks
Re: Where to place my command aliases?
I am having a major problem with the concept of not having a ~/.bashrc file in the first place.
This is mine from my Debian testing install that I use all the time. This is the default ~/.bashrc file.
Are you sure you have bash installed? Are you sure it is your default shell? You should have dash installed also, are you sure you have not been using it?
I would put the ~/.bashrc that you created somewhere else or rename it.
I would then try;
If this doesn't get you a ~/.bashrc file I would go to Sysnaptic, being nervous of doing this in a teerminal with this condition of yours, and mark bash for "complete removal" and remove it.
Reinstall the thing making sure that you have removed it from /var/cache/apt/archives. This will make sure that a new package is downloaded and installed instead of the package that is not correctly installed being reinstalled.
Reboot after doing that if you do not have the ~/.bashrc file and see if that gets it. If not you have a real problem with your shell.
This is mine from my Debian testing install that I use all the time. This is the default ~/.bashrc file.
Code: Select all
# ~/.bashrc: executed by bash(1) for non-login shells.
# see /usr/share/doc/bash/examples/startup-files (in the package bash-doc)
# for examples
# If not running interactively, don't do anything
[ -z "$PS1" ] && return
# don't put duplicate lines or lines starting with space in the history.
# See bash(1) for more options
HISTCONTROL=ignoreboth
# append to the history file, don't overwrite it
shopt -s histappend
# for setting history length see HISTSIZE and HISTFILESIZE in bash(1)
HISTSIZE=1000
HISTFILESIZE=2000
# check the window size after each command and, if necessary,
# update the values of LINES and COLUMNS.
shopt -s checkwinsize
# If set, the pattern "**" used in a pathname expansion context will
# match all files and zero or more directories and subdirectories.
#shopt -s globstar
# make less more friendly for non-text input files, see lesspipe(1)
#[ -x /usr/bin/lesspipe ] && eval "$(SHELL=/bin/sh lesspipe)"
# set variable identifying the chroot you work in (used in the prompt below)
if [ -z "$debian_chroot" ] && [ -r /etc/debian_chroot ]; then
debian_chroot=$(cat /etc/debian_chroot)
fi
# set a fancy prompt (non-color, unless we know we "want" color)
case "$TERM" in
xterm-color) color_prompt=yes;;
esac
# uncomment for a colored prompt, if the terminal has the capability; turned
# off by default to not distract the user: the focus in a terminal window
# should be on the output of commands, not on the prompt
#force_color_prompt=yes
if [ -n "$force_color_prompt" ]; then
if [ -x /usr/bin/tput ] && tput setaf 1 >&/dev/null; then
# We have color support; assume it's compliant with Ecma-48
# (ISO/IEC-6429). (Lack of such support is extremely rare, and such
# a case would tend to support setf rather than setaf.)
color_prompt=yes
else
color_prompt=
fi
fi
if [ "$color_prompt" = yes ]; then
PS1='${debian_chroot:+($debian_chroot)}\[\033[01;32m\]\u@\h\[\033[00m\]:\[\033[01;34m\]\w\[\033[00m\]\$ '
else
PS1='${debian_chroot:+($debian_chroot)}\u@\h:\w\$ '
fi
unset color_prompt force_color_prompt
# If this is an xterm set the title to user@host:dir
case "$TERM" in
xterm*|rxvt*)
PS1="\[\e]0;${debian_chroot:+($debian_chroot)}\u@\h: \w\a\]$PS1"
;;
*)
;;
esac
# enable color support of ls and also add handy aliases
if [ -x /usr/bin/dircolors ]; then
test -r ~/.dircolors && eval "$(dircolors -b ~/.dircolors)" || eval "$(dircolors -b)"
alias ls='ls --color=auto'
#alias dir='dir --color=auto'
#alias vdir='vdir --color=auto'
#alias grep='grep --color=auto'
#alias fgrep='fgrep --color=auto'
#alias egrep='egrep --color=auto'
fi
# some more ls aliases
#alias ll='ls -l'
#alias la='ls -A'
#alias l='ls -CF'
# Alias definitions.
# You may want to put all your additions into a separate file like
# ~/.bash_aliases, instead of adding them here directly.
# See /usr/share/doc/bash-doc/examples in the bash-doc package.
if [ -f ~/.bash_aliases ]; then
. ~/.bash_aliases
fi
# enable programmable completion features (you don't need to enable
# this, if it's already enabled in /etc/bash.bashrc and /etc/profile
# sources /etc/bash.bashrc).
if [ -f /etc/bash_completion ] && ! shopt -oq posix; then
. /etc/bash_completion
fi
I would put the ~/.bashrc that you created somewhere else or rename it.
I would then try;
Code: Select all
sudo dpkg-reconfigure bash
Reinstall the thing making sure that you have removed it from /var/cache/apt/archives. This will make sure that a new package is downloaded and installed instead of the package that is not correctly installed being reinstalled.
Reboot after doing that if you do not have the ~/.bashrc file and see if that gets it. If not you have a real problem with your shell.
Re: Where to place my command aliases?
Alright, found this bash tutorial and it pretty much explains the situation. Nothing wrong with the Bash install.
u0
http://www.hypexr.org/bash_tutorial.php#config
u0
http://www.hypexr.org/bash_tutorial.php#config