How to see the command attached to a bash alias?












288















Suppose I have an alias in the bash shell. Is there a simple command to print out what command the alias will run?










share|improve this question





























    288















    Suppose I have an alias in the bash shell. Is there a simple command to print out what command the alias will run?










    share|improve this question



























      288












      288








      288


      64






      Suppose I have an alias in the bash shell. Is there a simple command to print out what command the alias will run?










      share|improve this question
















      Suppose I have an alias in the bash shell. Is there a simple command to print out what command the alias will run?







      command-line bash alias






      share|improve this question















      share|improve this question













      share|improve this question




      share|improve this question








      edited Feb 7 '12 at 23:59









      RolandiXor

      44.6k25140231




      44.6k25140231










      asked Feb 7 '12 at 3:24









      CasebashCasebash

      1,59931216




      1,59931216






















          5 Answers
          5






          active

          oldest

          votes


















          381














          The type builtin is useful for this. It will not only tell you about aliases, but also functions, builtins, keywords and external commands.



          $ type ls
          ls is aliased to `ls --color=auto'
          $ type rm
          rm is /bin/rm
          $ type cd
          cd is a shell builtin
          $ type psgrep
          psgrep is a function
          psgrep ()
          {
          ps -ef | {
          read -r;
          printf '%sn' "$REPLY";
          grep --color=auto "$@"
          }
          }


          type -a cmd will show all the commands by that name in order of precedence, which is useful for the ls alias above, where the alias itself calls ls.



          $ type -a ls
          ls is aliased to `ls --color=auto'
          ls is /bin/ls


          This tells you that when you run ls, /bin/ls will be used, and --color=auto will be included in its list of arguments, in addition to any other you add yourself.






          share|improve this answer


























          • what to do when an alias contains MORE aliases?

            – user251046
            Jul 26 '14 at 10:34






          • 1





            @user251046 keep using type until you hit something other than an alias ...

            – geirha
            Sep 3 '14 at 19:03











          • I like this answer because type will parse/interpret any quotes, so you can make sure the quotes are right.

            – wisbucky
            Mar 2 '18 at 4:21











          • I got ls is aliased to 'ls --color=auto', but how can I get one layer deeper, to see whether it uses /bin/ls or /usr/local/bin/ls or what?

            – krubo
            Jan 29 at 2:19






          • 1





            @krubo type -a ls will show all ls commands found in order of preference. Whichever is right below the alias is the one that will be executed by the alias.

            – geirha
            Jan 30 at 7:54



















          141














          Just type alias while at the Shell prompt. It should output a list of all currently-active aliases.



          Or, you can type alias [command] to see what a specific alias is aliased to, as an example, if you wanted to find out what the ls alias was aliased to, you could do alias ls.






          share|improve this answer





















          • 10





            Or type alias ls to find out what specifically ls is aliased to.

            – poolie
            Feb 7 '12 at 4:10






          • 2





            @poolie Indeed. I think the question was to see all the aliases, though, which is why i did not elaborate further on the alias command.

            – Thomas Ward
            Feb 7 '12 at 4:52











          • while this works for aliases, it doesn't work if you've defined a custom shell function. type however, works in both cases.

            – Sujay Phadke
            Sep 24 '16 at 6:38



















          52














          I really like Ctrl+Alt+E as I learned from this answer. It "expands" the currently typed command line, meaning it performs alias expansion (amongst other things).



          What does that mean? It turns any alias, that might be currently written on the command line, into what the alias stands for.



          For example, if I type:



          $ ls


          and then press Ctrl+Alt+E, it is turned into



          $ ls --time-style=locale --color=auto





          share|improve this answer


























          • have this an equivalent on other distros?

            – sepehr
            Jul 3 '14 at 13:40











          • @sepehr Works on Debian, I assume it's a bash feature and should work on any distribution.

            – Der Hochstapler
            Jul 3 '14 at 16:15






          • 3





            you're right, it works on bash but I have zsh and it doesn't work unfortunately.

            – sepehr
            Jul 4 '14 at 12:46













          • was really helpful. I had a different goal of expanding one of the previous bash commands logged in history with, i.e., !394, so that I could edit it first before executing

            – XXL
            Mar 23 '16 at 12:42













          • How to accomplish this on bash OSX?

            – Govind Rai
            Jan 9 '17 at 4:31



















          8














          Strictly speaking correct answer is using BASH_ALIASES array, e.g.:



          $ echo ${BASH_ALIASES[ls]}
          ls -F --color=auto --show-control-chars





          share|improve this answer



















          • 1





            I found this useful in a situation where I wanted programmatic access to the actual statement being aliased without the human-useful stuff around it.

            – M. Justin
            Mar 6 '17 at 20:16











          • this isn't working in zsh

            – ProGrammar
            Apr 18 '18 at 13:22











          • @ProGrammar the question was about bash - for zsh you should look questions about zsh

            – noonex
            Apr 18 '18 at 20:19



















          2














          You could use the which command.



          If you set an alias for ls as ls -al and then type which ls, you will see:



          ls: aliased to ls -al.






          share|improve this answer


























          • bash has no which command.

            – geirha
            Sep 11 '14 at 9:34











          • Not working for me..

            – Chiel ten Brinke
            Mar 15 '16 at 13:34






          • 2





            which is a bad way to lookup aliases as explained here: unix.stackexchange.com/questions/10525/… It doesn't even work for me for aliases in bash on Ubuntu.

            – Sujay Phadke
            Sep 24 '16 at 6:36













          Your Answer








          StackExchange.ready(function() {
          var channelOptions = {
          tags: "".split(" "),
          id: "89"
          };
          initTagRenderer("".split(" "), "".split(" "), channelOptions);

          StackExchange.using("externalEditor", function() {
          // Have to fire editor after snippets, if snippets enabled
          if (StackExchange.settings.snippets.snippetsEnabled) {
          StackExchange.using("snippets", function() {
          createEditor();
          });
          }
          else {
          createEditor();
          }
          });

          function createEditor() {
          StackExchange.prepareEditor({
          heartbeatType: 'answer',
          autoActivateHeartbeat: false,
          convertImagesToLinks: true,
          noModals: true,
          showLowRepImageUploadWarning: true,
          reputationToPostImages: 10,
          bindNavPrevention: true,
          postfix: "",
          imageUploader: {
          brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
          contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
          allowUrls: true
          },
          onDemand: true,
          discardSelector: ".discard-answer"
          ,immediatelyShowMarkdownHelp:true
          });


          }
          });














          draft saved

          draft discarded


















          StackExchange.ready(
          function () {
          StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2faskubuntu.com%2fquestions%2f102093%2fhow-to-see-the-command-attached-to-a-bash-alias%23new-answer', 'question_page');
          }
          );

          Post as a guest















          Required, but never shown

























          5 Answers
          5






          active

          oldest

          votes








          5 Answers
          5






          active

          oldest

          votes









          active

          oldest

          votes






          active

          oldest

          votes









          381














          The type builtin is useful for this. It will not only tell you about aliases, but also functions, builtins, keywords and external commands.



          $ type ls
          ls is aliased to `ls --color=auto'
          $ type rm
          rm is /bin/rm
          $ type cd
          cd is a shell builtin
          $ type psgrep
          psgrep is a function
          psgrep ()
          {
          ps -ef | {
          read -r;
          printf '%sn' "$REPLY";
          grep --color=auto "$@"
          }
          }


          type -a cmd will show all the commands by that name in order of precedence, which is useful for the ls alias above, where the alias itself calls ls.



          $ type -a ls
          ls is aliased to `ls --color=auto'
          ls is /bin/ls


          This tells you that when you run ls, /bin/ls will be used, and --color=auto will be included in its list of arguments, in addition to any other you add yourself.






          share|improve this answer


























          • what to do when an alias contains MORE aliases?

            – user251046
            Jul 26 '14 at 10:34






          • 1





            @user251046 keep using type until you hit something other than an alias ...

            – geirha
            Sep 3 '14 at 19:03











          • I like this answer because type will parse/interpret any quotes, so you can make sure the quotes are right.

            – wisbucky
            Mar 2 '18 at 4:21











          • I got ls is aliased to 'ls --color=auto', but how can I get one layer deeper, to see whether it uses /bin/ls or /usr/local/bin/ls or what?

            – krubo
            Jan 29 at 2:19






          • 1





            @krubo type -a ls will show all ls commands found in order of preference. Whichever is right below the alias is the one that will be executed by the alias.

            – geirha
            Jan 30 at 7:54
















          381














          The type builtin is useful for this. It will not only tell you about aliases, but also functions, builtins, keywords and external commands.



          $ type ls
          ls is aliased to `ls --color=auto'
          $ type rm
          rm is /bin/rm
          $ type cd
          cd is a shell builtin
          $ type psgrep
          psgrep is a function
          psgrep ()
          {
          ps -ef | {
          read -r;
          printf '%sn' "$REPLY";
          grep --color=auto "$@"
          }
          }


          type -a cmd will show all the commands by that name in order of precedence, which is useful for the ls alias above, where the alias itself calls ls.



          $ type -a ls
          ls is aliased to `ls --color=auto'
          ls is /bin/ls


          This tells you that when you run ls, /bin/ls will be used, and --color=auto will be included in its list of arguments, in addition to any other you add yourself.






          share|improve this answer


























          • what to do when an alias contains MORE aliases?

            – user251046
            Jul 26 '14 at 10:34






          • 1





            @user251046 keep using type until you hit something other than an alias ...

            – geirha
            Sep 3 '14 at 19:03











          • I like this answer because type will parse/interpret any quotes, so you can make sure the quotes are right.

            – wisbucky
            Mar 2 '18 at 4:21











          • I got ls is aliased to 'ls --color=auto', but how can I get one layer deeper, to see whether it uses /bin/ls or /usr/local/bin/ls or what?

            – krubo
            Jan 29 at 2:19






          • 1





            @krubo type -a ls will show all ls commands found in order of preference. Whichever is right below the alias is the one that will be executed by the alias.

            – geirha
            Jan 30 at 7:54














          381












          381








          381







          The type builtin is useful for this. It will not only tell you about aliases, but also functions, builtins, keywords and external commands.



          $ type ls
          ls is aliased to `ls --color=auto'
          $ type rm
          rm is /bin/rm
          $ type cd
          cd is a shell builtin
          $ type psgrep
          psgrep is a function
          psgrep ()
          {
          ps -ef | {
          read -r;
          printf '%sn' "$REPLY";
          grep --color=auto "$@"
          }
          }


          type -a cmd will show all the commands by that name in order of precedence, which is useful for the ls alias above, where the alias itself calls ls.



          $ type -a ls
          ls is aliased to `ls --color=auto'
          ls is /bin/ls


          This tells you that when you run ls, /bin/ls will be used, and --color=auto will be included in its list of arguments, in addition to any other you add yourself.






          share|improve this answer















          The type builtin is useful for this. It will not only tell you about aliases, but also functions, builtins, keywords and external commands.



          $ type ls
          ls is aliased to `ls --color=auto'
          $ type rm
          rm is /bin/rm
          $ type cd
          cd is a shell builtin
          $ type psgrep
          psgrep is a function
          psgrep ()
          {
          ps -ef | {
          read -r;
          printf '%sn' "$REPLY";
          grep --color=auto "$@"
          }
          }


          type -a cmd will show all the commands by that name in order of precedence, which is useful for the ls alias above, where the alias itself calls ls.



          $ type -a ls
          ls is aliased to `ls --color=auto'
          ls is /bin/ls


          This tells you that when you run ls, /bin/ls will be used, and --color=auto will be included in its list of arguments, in addition to any other you add yourself.







          share|improve this answer














          share|improve this answer



          share|improve this answer








          edited Jan 31 at 20:29

























          answered Feb 12 '12 at 9:52









          geirhageirha

          31.1k95760




          31.1k95760













          • what to do when an alias contains MORE aliases?

            – user251046
            Jul 26 '14 at 10:34






          • 1





            @user251046 keep using type until you hit something other than an alias ...

            – geirha
            Sep 3 '14 at 19:03











          • I like this answer because type will parse/interpret any quotes, so you can make sure the quotes are right.

            – wisbucky
            Mar 2 '18 at 4:21











          • I got ls is aliased to 'ls --color=auto', but how can I get one layer deeper, to see whether it uses /bin/ls or /usr/local/bin/ls or what?

            – krubo
            Jan 29 at 2:19






          • 1





            @krubo type -a ls will show all ls commands found in order of preference. Whichever is right below the alias is the one that will be executed by the alias.

            – geirha
            Jan 30 at 7:54



















          • what to do when an alias contains MORE aliases?

            – user251046
            Jul 26 '14 at 10:34






          • 1





            @user251046 keep using type until you hit something other than an alias ...

            – geirha
            Sep 3 '14 at 19:03











          • I like this answer because type will parse/interpret any quotes, so you can make sure the quotes are right.

            – wisbucky
            Mar 2 '18 at 4:21











          • I got ls is aliased to 'ls --color=auto', but how can I get one layer deeper, to see whether it uses /bin/ls or /usr/local/bin/ls or what?

            – krubo
            Jan 29 at 2:19






          • 1





            @krubo type -a ls will show all ls commands found in order of preference. Whichever is right below the alias is the one that will be executed by the alias.

            – geirha
            Jan 30 at 7:54

















          what to do when an alias contains MORE aliases?

          – user251046
          Jul 26 '14 at 10:34





          what to do when an alias contains MORE aliases?

          – user251046
          Jul 26 '14 at 10:34




          1




          1





          @user251046 keep using type until you hit something other than an alias ...

          – geirha
          Sep 3 '14 at 19:03





          @user251046 keep using type until you hit something other than an alias ...

          – geirha
          Sep 3 '14 at 19:03













          I like this answer because type will parse/interpret any quotes, so you can make sure the quotes are right.

          – wisbucky
          Mar 2 '18 at 4:21





          I like this answer because type will parse/interpret any quotes, so you can make sure the quotes are right.

          – wisbucky
          Mar 2 '18 at 4:21













          I got ls is aliased to 'ls --color=auto', but how can I get one layer deeper, to see whether it uses /bin/ls or /usr/local/bin/ls or what?

          – krubo
          Jan 29 at 2:19





          I got ls is aliased to 'ls --color=auto', but how can I get one layer deeper, to see whether it uses /bin/ls or /usr/local/bin/ls or what?

          – krubo
          Jan 29 at 2:19




          1




          1





          @krubo type -a ls will show all ls commands found in order of preference. Whichever is right below the alias is the one that will be executed by the alias.

          – geirha
          Jan 30 at 7:54





          @krubo type -a ls will show all ls commands found in order of preference. Whichever is right below the alias is the one that will be executed by the alias.

          – geirha
          Jan 30 at 7:54













          141














          Just type alias while at the Shell prompt. It should output a list of all currently-active aliases.



          Or, you can type alias [command] to see what a specific alias is aliased to, as an example, if you wanted to find out what the ls alias was aliased to, you could do alias ls.






          share|improve this answer





















          • 10





            Or type alias ls to find out what specifically ls is aliased to.

            – poolie
            Feb 7 '12 at 4:10






          • 2





            @poolie Indeed. I think the question was to see all the aliases, though, which is why i did not elaborate further on the alias command.

            – Thomas Ward
            Feb 7 '12 at 4:52











          • while this works for aliases, it doesn't work if you've defined a custom shell function. type however, works in both cases.

            – Sujay Phadke
            Sep 24 '16 at 6:38
















          141














          Just type alias while at the Shell prompt. It should output a list of all currently-active aliases.



          Or, you can type alias [command] to see what a specific alias is aliased to, as an example, if you wanted to find out what the ls alias was aliased to, you could do alias ls.






          share|improve this answer





















          • 10





            Or type alias ls to find out what specifically ls is aliased to.

            – poolie
            Feb 7 '12 at 4:10






          • 2





            @poolie Indeed. I think the question was to see all the aliases, though, which is why i did not elaborate further on the alias command.

            – Thomas Ward
            Feb 7 '12 at 4:52











          • while this works for aliases, it doesn't work if you've defined a custom shell function. type however, works in both cases.

            – Sujay Phadke
            Sep 24 '16 at 6:38














          141












          141








          141







          Just type alias while at the Shell prompt. It should output a list of all currently-active aliases.



          Or, you can type alias [command] to see what a specific alias is aliased to, as an example, if you wanted to find out what the ls alias was aliased to, you could do alias ls.






          share|improve this answer















          Just type alias while at the Shell prompt. It should output a list of all currently-active aliases.



          Or, you can type alias [command] to see what a specific alias is aliased to, as an example, if you wanted to find out what the ls alias was aliased to, you could do alias ls.







          share|improve this answer














          share|improve this answer



          share|improve this answer








          edited Dec 10 '13 at 16:16

























          answered Feb 7 '12 at 3:30









          Thomas WardThomas Ward

          44.5k23124177




          44.5k23124177








          • 10





            Or type alias ls to find out what specifically ls is aliased to.

            – poolie
            Feb 7 '12 at 4:10






          • 2





            @poolie Indeed. I think the question was to see all the aliases, though, which is why i did not elaborate further on the alias command.

            – Thomas Ward
            Feb 7 '12 at 4:52











          • while this works for aliases, it doesn't work if you've defined a custom shell function. type however, works in both cases.

            – Sujay Phadke
            Sep 24 '16 at 6:38














          • 10





            Or type alias ls to find out what specifically ls is aliased to.

            – poolie
            Feb 7 '12 at 4:10






          • 2





            @poolie Indeed. I think the question was to see all the aliases, though, which is why i did not elaborate further on the alias command.

            – Thomas Ward
            Feb 7 '12 at 4:52











          • while this works for aliases, it doesn't work if you've defined a custom shell function. type however, works in both cases.

            – Sujay Phadke
            Sep 24 '16 at 6:38








          10




          10





          Or type alias ls to find out what specifically ls is aliased to.

          – poolie
          Feb 7 '12 at 4:10





          Or type alias ls to find out what specifically ls is aliased to.

          – poolie
          Feb 7 '12 at 4:10




          2




          2





          @poolie Indeed. I think the question was to see all the aliases, though, which is why i did not elaborate further on the alias command.

          – Thomas Ward
          Feb 7 '12 at 4:52





          @poolie Indeed. I think the question was to see all the aliases, though, which is why i did not elaborate further on the alias command.

          – Thomas Ward
          Feb 7 '12 at 4:52













          while this works for aliases, it doesn't work if you've defined a custom shell function. type however, works in both cases.

          – Sujay Phadke
          Sep 24 '16 at 6:38





          while this works for aliases, it doesn't work if you've defined a custom shell function. type however, works in both cases.

          – Sujay Phadke
          Sep 24 '16 at 6:38











          52














          I really like Ctrl+Alt+E as I learned from this answer. It "expands" the currently typed command line, meaning it performs alias expansion (amongst other things).



          What does that mean? It turns any alias, that might be currently written on the command line, into what the alias stands for.



          For example, if I type:



          $ ls


          and then press Ctrl+Alt+E, it is turned into



          $ ls --time-style=locale --color=auto





          share|improve this answer


























          • have this an equivalent on other distros?

            – sepehr
            Jul 3 '14 at 13:40











          • @sepehr Works on Debian, I assume it's a bash feature and should work on any distribution.

            – Der Hochstapler
            Jul 3 '14 at 16:15






          • 3





            you're right, it works on bash but I have zsh and it doesn't work unfortunately.

            – sepehr
            Jul 4 '14 at 12:46













          • was really helpful. I had a different goal of expanding one of the previous bash commands logged in history with, i.e., !394, so that I could edit it first before executing

            – XXL
            Mar 23 '16 at 12:42













          • How to accomplish this on bash OSX?

            – Govind Rai
            Jan 9 '17 at 4:31
















          52














          I really like Ctrl+Alt+E as I learned from this answer. It "expands" the currently typed command line, meaning it performs alias expansion (amongst other things).



          What does that mean? It turns any alias, that might be currently written on the command line, into what the alias stands for.



          For example, if I type:



          $ ls


          and then press Ctrl+Alt+E, it is turned into



          $ ls --time-style=locale --color=auto





          share|improve this answer


























          • have this an equivalent on other distros?

            – sepehr
            Jul 3 '14 at 13:40











          • @sepehr Works on Debian, I assume it's a bash feature and should work on any distribution.

            – Der Hochstapler
            Jul 3 '14 at 16:15






          • 3





            you're right, it works on bash but I have zsh and it doesn't work unfortunately.

            – sepehr
            Jul 4 '14 at 12:46













          • was really helpful. I had a different goal of expanding one of the previous bash commands logged in history with, i.e., !394, so that I could edit it first before executing

            – XXL
            Mar 23 '16 at 12:42













          • How to accomplish this on bash OSX?

            – Govind Rai
            Jan 9 '17 at 4:31














          52












          52








          52







          I really like Ctrl+Alt+E as I learned from this answer. It "expands" the currently typed command line, meaning it performs alias expansion (amongst other things).



          What does that mean? It turns any alias, that might be currently written on the command line, into what the alias stands for.



          For example, if I type:



          $ ls


          and then press Ctrl+Alt+E, it is turned into



          $ ls --time-style=locale --color=auto





          share|improve this answer















          I really like Ctrl+Alt+E as I learned from this answer. It "expands" the currently typed command line, meaning it performs alias expansion (amongst other things).



          What does that mean? It turns any alias, that might be currently written on the command line, into what the alias stands for.



          For example, if I type:



          $ ls


          and then press Ctrl+Alt+E, it is turned into



          $ ls --time-style=locale --color=auto






          share|improve this answer














          share|improve this answer



          share|improve this answer








          edited May 23 '17 at 12:39









          Community

          1




          1










          answered Feb 13 '12 at 17:52









          Der HochstaplerDer Hochstapler

          2,81531629




          2,81531629













          • have this an equivalent on other distros?

            – sepehr
            Jul 3 '14 at 13:40











          • @sepehr Works on Debian, I assume it's a bash feature and should work on any distribution.

            – Der Hochstapler
            Jul 3 '14 at 16:15






          • 3





            you're right, it works on bash but I have zsh and it doesn't work unfortunately.

            – sepehr
            Jul 4 '14 at 12:46













          • was really helpful. I had a different goal of expanding one of the previous bash commands logged in history with, i.e., !394, so that I could edit it first before executing

            – XXL
            Mar 23 '16 at 12:42













          • How to accomplish this on bash OSX?

            – Govind Rai
            Jan 9 '17 at 4:31



















          • have this an equivalent on other distros?

            – sepehr
            Jul 3 '14 at 13:40











          • @sepehr Works on Debian, I assume it's a bash feature and should work on any distribution.

            – Der Hochstapler
            Jul 3 '14 at 16:15






          • 3





            you're right, it works on bash but I have zsh and it doesn't work unfortunately.

            – sepehr
            Jul 4 '14 at 12:46













          • was really helpful. I had a different goal of expanding one of the previous bash commands logged in history with, i.e., !394, so that I could edit it first before executing

            – XXL
            Mar 23 '16 at 12:42













          • How to accomplish this on bash OSX?

            – Govind Rai
            Jan 9 '17 at 4:31

















          have this an equivalent on other distros?

          – sepehr
          Jul 3 '14 at 13:40





          have this an equivalent on other distros?

          – sepehr
          Jul 3 '14 at 13:40













          @sepehr Works on Debian, I assume it's a bash feature and should work on any distribution.

          – Der Hochstapler
          Jul 3 '14 at 16:15





          @sepehr Works on Debian, I assume it's a bash feature and should work on any distribution.

          – Der Hochstapler
          Jul 3 '14 at 16:15




          3




          3





          you're right, it works on bash but I have zsh and it doesn't work unfortunately.

          – sepehr
          Jul 4 '14 at 12:46







          you're right, it works on bash but I have zsh and it doesn't work unfortunately.

          – sepehr
          Jul 4 '14 at 12:46















          was really helpful. I had a different goal of expanding one of the previous bash commands logged in history with, i.e., !394, so that I could edit it first before executing

          – XXL
          Mar 23 '16 at 12:42







          was really helpful. I had a different goal of expanding one of the previous bash commands logged in history with, i.e., !394, so that I could edit it first before executing

          – XXL
          Mar 23 '16 at 12:42















          How to accomplish this on bash OSX?

          – Govind Rai
          Jan 9 '17 at 4:31





          How to accomplish this on bash OSX?

          – Govind Rai
          Jan 9 '17 at 4:31











          8














          Strictly speaking correct answer is using BASH_ALIASES array, e.g.:



          $ echo ${BASH_ALIASES[ls]}
          ls -F --color=auto --show-control-chars





          share|improve this answer



















          • 1





            I found this useful in a situation where I wanted programmatic access to the actual statement being aliased without the human-useful stuff around it.

            – M. Justin
            Mar 6 '17 at 20:16











          • this isn't working in zsh

            – ProGrammar
            Apr 18 '18 at 13:22











          • @ProGrammar the question was about bash - for zsh you should look questions about zsh

            – noonex
            Apr 18 '18 at 20:19
















          8














          Strictly speaking correct answer is using BASH_ALIASES array, e.g.:



          $ echo ${BASH_ALIASES[ls]}
          ls -F --color=auto --show-control-chars





          share|improve this answer



















          • 1





            I found this useful in a situation where I wanted programmatic access to the actual statement being aliased without the human-useful stuff around it.

            – M. Justin
            Mar 6 '17 at 20:16











          • this isn't working in zsh

            – ProGrammar
            Apr 18 '18 at 13:22











          • @ProGrammar the question was about bash - for zsh you should look questions about zsh

            – noonex
            Apr 18 '18 at 20:19














          8












          8








          8







          Strictly speaking correct answer is using BASH_ALIASES array, e.g.:



          $ echo ${BASH_ALIASES[ls]}
          ls -F --color=auto --show-control-chars





          share|improve this answer













          Strictly speaking correct answer is using BASH_ALIASES array, e.g.:



          $ echo ${BASH_ALIASES[ls]}
          ls -F --color=auto --show-control-chars






          share|improve this answer












          share|improve this answer



          share|improve this answer










          answered Jan 13 '17 at 12:12









          noonexnoonex

          18013




          18013








          • 1





            I found this useful in a situation where I wanted programmatic access to the actual statement being aliased without the human-useful stuff around it.

            – M. Justin
            Mar 6 '17 at 20:16











          • this isn't working in zsh

            – ProGrammar
            Apr 18 '18 at 13:22











          • @ProGrammar the question was about bash - for zsh you should look questions about zsh

            – noonex
            Apr 18 '18 at 20:19














          • 1





            I found this useful in a situation where I wanted programmatic access to the actual statement being aliased without the human-useful stuff around it.

            – M. Justin
            Mar 6 '17 at 20:16











          • this isn't working in zsh

            – ProGrammar
            Apr 18 '18 at 13:22











          • @ProGrammar the question was about bash - for zsh you should look questions about zsh

            – noonex
            Apr 18 '18 at 20:19








          1




          1





          I found this useful in a situation where I wanted programmatic access to the actual statement being aliased without the human-useful stuff around it.

          – M. Justin
          Mar 6 '17 at 20:16





          I found this useful in a situation where I wanted programmatic access to the actual statement being aliased without the human-useful stuff around it.

          – M. Justin
          Mar 6 '17 at 20:16













          this isn't working in zsh

          – ProGrammar
          Apr 18 '18 at 13:22





          this isn't working in zsh

          – ProGrammar
          Apr 18 '18 at 13:22













          @ProGrammar the question was about bash - for zsh you should look questions about zsh

          – noonex
          Apr 18 '18 at 20:19





          @ProGrammar the question was about bash - for zsh you should look questions about zsh

          – noonex
          Apr 18 '18 at 20:19











          2














          You could use the which command.



          If you set an alias for ls as ls -al and then type which ls, you will see:



          ls: aliased to ls -al.






          share|improve this answer


























          • bash has no which command.

            – geirha
            Sep 11 '14 at 9:34











          • Not working for me..

            – Chiel ten Brinke
            Mar 15 '16 at 13:34






          • 2





            which is a bad way to lookup aliases as explained here: unix.stackexchange.com/questions/10525/… It doesn't even work for me for aliases in bash on Ubuntu.

            – Sujay Phadke
            Sep 24 '16 at 6:36


















          2














          You could use the which command.



          If you set an alias for ls as ls -al and then type which ls, you will see:



          ls: aliased to ls -al.






          share|improve this answer


























          • bash has no which command.

            – geirha
            Sep 11 '14 at 9:34











          • Not working for me..

            – Chiel ten Brinke
            Mar 15 '16 at 13:34






          • 2





            which is a bad way to lookup aliases as explained here: unix.stackexchange.com/questions/10525/… It doesn't even work for me for aliases in bash on Ubuntu.

            – Sujay Phadke
            Sep 24 '16 at 6:36
















          2












          2








          2







          You could use the which command.



          If you set an alias for ls as ls -al and then type which ls, you will see:



          ls: aliased to ls -al.






          share|improve this answer















          You could use the which command.



          If you set an alias for ls as ls -al and then type which ls, you will see:



          ls: aliased to ls -al.







          share|improve this answer














          share|improve this answer



          share|improve this answer








          edited Aug 5 '14 at 7:59









          Luís de Sousa

          9,1101752100




          9,1101752100










          answered Aug 5 '14 at 7:36









          user312471user312471

          391




          391













          • bash has no which command.

            – geirha
            Sep 11 '14 at 9:34











          • Not working for me..

            – Chiel ten Brinke
            Mar 15 '16 at 13:34






          • 2





            which is a bad way to lookup aliases as explained here: unix.stackexchange.com/questions/10525/… It doesn't even work for me for aliases in bash on Ubuntu.

            – Sujay Phadke
            Sep 24 '16 at 6:36





















          • bash has no which command.

            – geirha
            Sep 11 '14 at 9:34











          • Not working for me..

            – Chiel ten Brinke
            Mar 15 '16 at 13:34






          • 2





            which is a bad way to lookup aliases as explained here: unix.stackexchange.com/questions/10525/… It doesn't even work for me for aliases in bash on Ubuntu.

            – Sujay Phadke
            Sep 24 '16 at 6:36



















          bash has no which command.

          – geirha
          Sep 11 '14 at 9:34





          bash has no which command.

          – geirha
          Sep 11 '14 at 9:34













          Not working for me..

          – Chiel ten Brinke
          Mar 15 '16 at 13:34





          Not working for me..

          – Chiel ten Brinke
          Mar 15 '16 at 13:34




          2




          2





          which is a bad way to lookup aliases as explained here: unix.stackexchange.com/questions/10525/… It doesn't even work for me for aliases in bash on Ubuntu.

          – Sujay Phadke
          Sep 24 '16 at 6:36







          which is a bad way to lookup aliases as explained here: unix.stackexchange.com/questions/10525/… It doesn't even work for me for aliases in bash on Ubuntu.

          – Sujay Phadke
          Sep 24 '16 at 6:36




















          draft saved

          draft discarded




















































          Thanks for contributing an answer to Ask Ubuntu!


          • Please be sure to answer the question. Provide details and share your research!

          But avoid



          • Asking for help, clarification, or responding to other answers.

          • Making statements based on opinion; back them up with references or personal experience.


          To learn more, see our tips on writing great answers.




          draft saved


          draft discarded














          StackExchange.ready(
          function () {
          StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2faskubuntu.com%2fquestions%2f102093%2fhow-to-see-the-command-attached-to-a-bash-alias%23new-answer', 'question_page');
          }
          );

          Post as a guest















          Required, but never shown





















































          Required, but never shown














          Required, but never shown












          Required, but never shown







          Required, but never shown

































          Required, but never shown














          Required, but never shown












          Required, but never shown







          Required, but never shown







          Popular posts from this blog

          How to make a Squid Proxy server?

          Is this a new Fibonacci Identity?

          Touch on Surface Book