~/.bashrc  My ~/.bashrc contains the following (by default):  if [ -f ~/.bash_aliases ]; then     . ~/.bash_aliases fi     ~/.bash_aliases  My ~/.bash_aliases contains the following (my definition):  alias define="curl dict://dict.org/d:$1"     Expectation  The define in there is the alias so I could use something like the following directly in my shell (terminal):  define internet   While I expect it to look at dict.org and look up definition of internet and display it to me.  For some reason whenever I run it  (hosted on paste.debian.net, might disappear in time).    I tried sourcing the ~/.bash_aliases in the bash session.    Shell  I'm running bash version 5.0.11 on Debian Bullseye (currently testing, and planned major upcoming release).    What am I doing wrong with my own alias in ~/.bash_aliases?
1635
It's taken me almost 10 years of Linux usage to ask this question. It was all trial and error and random late-night internet surfing.  But people shouldn't need 10 years for this. If I were just starting out with Linux, I'd want to know: When to alias, when to script, and when to write a function?  Where aliases are concerned, I use aliases for very simple operations that don't take arguments.   alias houston='cd /home/username/.scripts/'   That seems obvious. But some people do this:  alias command="bash bashscriptname"   (and add it to the .bashrc file)   Is there a good reason to do that? I'm trying really hard, but I genuinely can't think of any circumstances in which I'd want to do that. So, if there is an edge case where that would make a difference, please answer below.  Because that's where I would just put something in my PATH and chmod +x it, which is another thing that came after years of Linux trial-and-error.  Which brings me to the next topic. For instance, I added a hidden folder (.scripts/) in the home directory to my PATH by just adding a line to my .bashrc (PATH=$PATH:/home/username/.scripts/), so anything executable in there automagically autocompletes.  If I needed to.  I don't really need that, though, do I? I would only use that for languages that are not the shell, like Python.  If it's the shell, I can just write a function inside the very same .bashrc:  funcname () {   somecommand -someARGS "$@" }   As I stated, I found a lot of this out through trial and error. And I only truly saw the beauty of functions when my computer died and I was forced to use the computers of the people around me when they weren't using them.   Instead of moving a whole directory of scripts from computer to computer, I ended up just replacing everyone else's .bashrc with my own, since they had never even made a single modification.  But did I miss anything?   So, what would you tell a beginning Linux user about when to alias, when to script, and when to write a function?   If it's not obvious, I'm assuming the people who answer this will make use of all three options. If you only use aliases, or only use scripts, or only use functions—or if you only use aliases and scripts or aliases and functions or scripts and functions—this question isn't really aimed at you.
50262
In the .bashrc file, one can add an alias for a command, say  alias geditm = 'gedit --display=D1'   Now I can run geditm in a terminal and have gedit open in display D1.  I am curious if there is a way to define an alias for running commands from the Alt-F2 menu, so that I could Alt+F2, type geditm and have the same result.   I am interested in doing this generally, not just for gedit.
36541
I just noticed that on one of my machines (running Debian Sid) whenever I type ls any file name with spaces has single quotes surrounding it. I immediately checked my aliases, only to find them intact. wyatt@debian630:~/testdir$ ls 'test 1.txt'  test1.txt wyatt@debian630:~/testdir$ alias alias ls='ls --color=auto' alias wget='wget --content-disposition' wyatt@debian630:~/testdir$   Another test, with files containing single quotes in their names (also answering a request by jimmij): wyatt@debian630:~/testdir$ ls 'test 1.txt'  test1.txt  'thishasasinglequotehere'\''.txt' wyatt@debian630:~/testdir$ touch &quot;'test 1.txt'&quot; wyatt@debian630:~/testdir$ ls ''\''test 1.txt'\'''  test1.txt 'test 1.txt'          'thishasasinglequotehere'\''.txt'   update with new coreutils-8.26 output (which is admittedly much less confusing, but still irritating to have by default). Thanks to Pádraig Brady for this printout: $ ls &quot;'test 1.txt'&quot;   test1.txt 'test 1.txt'    &quot;thishasasinglequotehere'.txt&quot;  $ ls -N 'test 1.txt'  test1.txt test 1.txt    thishasasinglequotehere'.txt  Why is this happening? How do I stop it properly? To be clear, I myself set ls to automatically color output. It just never put quotes around things before. I'm running bash and coreutils 8.25. Any way to fix this without a recompile? EDIT: Appears the coreutils developers  to break with the convention and make this the global default.  UPDATE - October 2017 - Debian Sid has re-enabled the shell escape quoting by default.  And at the bottom of the reply chain to the previous bug report, &quot;the change was intentional and will remain.&quot;  I thought this had already been settled, but apparently it was just reverted so that the &quot;stable&quot; Debian branch could keep its &quot;feature freeze&quot; while getting the other fixes, etc. from the newer version. So that's a shame (in my opinion). UPDATE: April 2019: Just found a  that was caused by this change to ls. When you're confusing developers and generating false bug reports, I think it might be time to re-evaluate your changes. Update: Android toybox ls is now doing something similar to this but with backslashes instead of quotes. Using the -q option makes spaces render as 'question mark characters' (I have not checked what they are, since they're obviously not spaces), so the only fix I have found so far without rooting the device in question is to add this to a script and source it when launching a shell. This function makes ls use columns if in a terminal and otherwise print one-per-line, while tricking ls into printing spaces verbatim because it's running through a pipe. ls() {     # only way I can stop ls from escaping with backslashes     if [ -t 1 ]; then         /system/bin/ls -C $@ |cat     else         /system/bin/ls $@ |cat     fi }
92716
Can anyone tell me about the -t option when invoking bash?   I found the following  handy command to use a    urxvt -geometry 80x3 -name 'bashrun' -e sh -c "/bin/bash -i -t"   Through a little investigation of its behavior, I see that the -t essentially makes bash exit after executing one command, but I am curious if there is any more to that specific -t option. I can't actually find any documentation about it, and I've looked through the following docs:   man bash     I find it odd that -t is not as clearly laid out as the rest of the options.
37969
How to create an alias that actually extends another alias of the same name in Bash?  Why:  I used to have GREP_OPTIONS set on .bashrc to something like this:  GREP_OPTIONS="-I --exclude=\*~"   I also had a script (let us say, setup-java.sh) which I would call before working on some Java projects. It would contain the line:  GREP_OPTIONS="$GREP_OPTIONS --exclude-dir=classes"   If I also use Sass, then I would call setup-sass.sh which contains the line:  GREP_OPTIONS="$GREP_OPTIONS --exclude-dir=\*/.sass-cache"   But  and apparently the standard solution is either create an alias or some script...
53485
[Reviewers: note that the question was completely rewritten after the close votes.]  I recently found how I can define aliases for bash in the ~/.bashrc.  But since I tried that, I see the followig messages eveery time I open a terminal.  I added some bash aliases to my I was trying to create shortcuts using alias but I unsuccessful and somehow managed to get the message below every time I open up a new terminal.  bash: alias: UIC: not found bash: alias: =: not found bash: alias: sudo openvpn --config ~/vpn/UIC-alopez78.ovpn: not found bash: alias: mat: not found bash: alias: =: not found bash: alias: cd /home/alexisblopez/MATLAB/R2014a/bin/: not found bash: alias: lab: not found bash: alias: =: not found bash: alias: ./matlab: not found ~$    Its's confusing; it does not say error, but because my aliases do not work, I think I did something wrong with them - I don't know what!
42698
That is literal, {fd} isn't a placeholder. I have a script that does this, and does not source in anything, nor does it reference {fd} anywhere else.  Is this valid bash?  exec {fd}&lt;/dev/watchdog
67150
When executing this bash script, it only shows my local path.  ssh ${REMOTE_HOST} 'bash -s' &lt;&lt;EOL     set -e     source ~/.profile     echo $PATH     # Commands here don't work because $PATH is not set properly.     # How can I see what $PATH is set to here? EOL   How can I view the remote value of $PATH to debug this?
9238
My .bashrc had some code that was repetitive so I used a function to simplify it  do_stuff() {   local version=$1   export FOO_${version}_X="17"   export FOO_${version}_Y="42" }  do_stuff '5.1' do_stuff '5.2'   However, now when I use my shell the "do_stuff" name is in scope so I can tab-complete and run that function (potentially messing up my environment variables). Is there a way to make "do_stuff" visible only inside the .bashrc?
14473
Suppose you have an alias go, but want it to do different things in different directories?  In one directory it should run cmd1, but in another directory it should run cmd2  By the way, I have an aliases for switching to the above directories already, so is it possible to append the go alias assignment to the foo alias?  alias "foo=cd /path/to/foo"   Working in bash(?) on OSX.
66342
When I create  alias wd='ps -ef | grep java | awk {'print $2 " " $9'} | egrep "(A|B|C|D)"'   or  function wd () {     ps -ef | grep java | awk '{print $2}' ... }   in my .bashrc file, I get errors.  Interestingly, if I source my .bashrc file with the function, it 'compiles', but when executing, gives me:   context is      &gt;&gt;&gt; \ &lt;&lt;&lt; {\print     missing }   Can someone help me with this, and also answer when its better to put something in a function versus in an alias?
61254
Suppose I have an alias in the bash shell. Is there a simple command to print out what command the alias will run?
64283
I have added alias ll='ls -la' in /etc/bash.bashrc but sudo ll is not working. Is there a way to "source" bash.bashrc? In a related post, another user suggesting creating an alias for sudo with a space after it. Eg. alias sudo='sudo ' but there wasn't any context to this answer. Should I add this to my bashrc? Seems hackish.  What is the correct method for adding an alias for my sudo one-off commands?
101526
An alias for ls command in ~/.bashrc file aliased with this one:  alias ls='ls --color=auto'   then, when I run ls command in terminal aliased ls(ls --color=auto) runs. but my question is how can I run original ls only and only ls alone without extra argument and without solving problem with deleting aliased entry? since when I delete this entry I can run it in simple ls.
43116
I want to remove ~/bin from my PATH.  I set it up months ago when Linux (Ubuntu) was very new to me, but I don't know how I added it...    Nothing shows up when I search all the files listed below. Where else could it be being set?  It is being pre-pended after $HOME/.profile prefixes PATH with $HOME/bin      If it makes any difference, I get the same PATH from both the command-prompt and a running script.    #!/bin/bash {   echo "first dir of PATH is: '${PATH%%:*}'"   shopt -s nullglob   cat \     /etc/profile \     /etc/bash.bashrc \     /etc/profile.d/*.sh \     $HOME/.bashrc \     $HOME/.bash_aliases \     /etc/bash_completion \     $HOME/.bash_completion* \     $HOME/.profile \     $HOME/.profile_zap \     $HOME/.bash_profile* \     $HOME/.bash_login* \   | sed -rne '/~\/bin/p' }   Output is:  first dir of PATH is: '~/bin'
34453
I recently installed the apache2 package using the Software Centre, I want to create an alias apacheres which will replace the more cumbersome command /etc/init.d/apache2 restart.  I opened the .bashrc file in my home directory, and it contains the following lines:  # 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   So I created a .bash_aliases file in my home directory, and added only this line:  alias apacheres ='/etc/init.d/apache2 restart'  When I started my terminal, I get this error message:  bash: alias: apacheres: not found bash: alias: =/etc/init.d/apache2 restart: not found   The shell has obviously read the file, otherwise it wouldn't know of its existence. I have checked the directory path and I can find the file apache2 there. What do I need to do to make this alias work?
52855
# ~/.profile: executed by the command interpreter for login shells. # This file is not read by bash(1), if ~/.bash_profile or ~/.bash_login # exists. # see /usr/share/doc/bash/examples/startup-files for examples. # the files are located in the bash-doc package.  # the default umask is set in /etc/profile; for setting the umask # for ssh logins, install and configure the libpam-umask package. #umask 022  # 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   Can anyone explain the contents of the ~/.profile file? So when you enter into the ~/.profile file what does all the writing mean?