How can I use a command inside a minted one-liner?
This code
\newcommand{\HADOOPUSER}{hduser}
\mint{console}|sudo groupadd \HADOOPUSER|
currently produces
sudo groupadd \HADOOPUSER
whereas the output I want is
sudo groupadd hduser
How can I use a command inside a minted one-liner?
This code
\newcommand{\HADOOPUSER}{hduser}
\mint{console}|sudo groupadd \HADOOPUSER|
currently produces
sudo groupadd \HADOOPUSER
whereas the output I want is
sudo groupadd hduser
Although I really enjoy minted, I don't think it is the right tool for what you want to do. Invoking macros inside listings typeset by minted is currently very limited (as of v1.7). The package does provide an option called mathescape for allowing escape to LaTeX (i.e. interpret a sequence of token as LaTeX code instead of verbatim), but
Here is an example adapted from the minted manual:

\documentclass{article}
\usepackage{minted}
\begin{document}
\begin{minted}[mathescape]{python}
# Returns $\sum_{i=1}ˆ{n}i$
def sum_from_one_to(n):
r = range(1, n + 1)
return sum(r)
# An escape to LateX won't work outside comments
$\sum_{i=1}ˆ{n}i$
\end{minted}
\end{document}
Clearly, your shell script is not a comment, so there is no way of getting your macro to expand to its replacement text in your listing.
Actually, what I gather from the Python source of the lexer you use, console (a.k.a. BashSessionLexer), is that it doesn't define shell to-end-of-line comments (started by a #). Therefore, you can't even escape to LaTeX anywhere in your code (either inside or outside comments), if you use that lexer, as evidenced by the example below.

\documentclass{article}
\usepackage{minted}
\newcommand{\HADOOPUSER}{hduser}
\begin{document}
\begin{minted}[mathescape]{console}
sudo groupadd #$\HADOOPUSER$
\end{minted}
\end{document}
An alternative approach would be to use the listings package instead of minted. With some patch, escaping to LaTeX can be allowed inside listings inline code. If you think that would help, I can expand my answer to provide a solution based on listings.
However. I think it's silly to escape to LaTeX inside inline code. IMO, inline code should be reserved for typesetting a single identifier (keyword, variable, etc.); anything longer than that has the potential to mess up your paragraph. For longer pieces of code (even for a command with arguments such as sudo groupadd hduser), you should use a displayed listing instead:
\begin{minted}{console}
sudo groupadd hduser
\end{minted}
If you follow this rule, you shouldn't need to ever escape to LaTeX inside inline code.
minted. You might have better luck with lstlisting environments (from the listings package).
– jub0bs
May 15 '14 at 20:47
I am providing a ConTeXt solution, because I do not know about the state of LuaTeX packages in LaTeX.
One possibility is to use Lua (rather than TeX) to translate your input. For that, ConTeXt provides a m-translate module which can be used with the vim module. (The vim module uses vim to generate syntax highlighting; so, in principal, this should work with minted+LaTeX as well).
\usemodule[vim]
\usemodule[translate]
\translateinput[HADOOPUSER][hduser]
\definevimtyping[console][syntax=bash, before=\enableinputtranslation, after=\disableinputtranslation]
\starttext
Translated: \inlineconsole{sudo groupadd HADOOPUSER}
This only works inside console environment, not regular text. For example
HADOOPUSER.
\stoptext
which gives

This works as follows: The text sudo groupadd HADOOPUSER is written to an external file and translated to \SYNBOL{}sudo groupadd HADOOPUSER\SYNEOL{}. When the file is read by TeX, \enableinputtranslation is active, so the line is converted to \SYNBOL{}sudo groupadd hduser\SYNEOL{} and passed on to TeX, where the macros of t-vim add the necessary syntax highlighting.
mintedis via an escape to LaTeX, which is only possible inside comments in the language used.listingscan do it, though. – jub0bs May 15 '14 at 14:56mintedspecifically, though. – jub0bs May 15 '14 at 15:55m-translate(http://tex.stackexchange.com/a/36021/323) – Aditya May 15 '14 at 15:57:)– jub0bs May 15 '14 at 16:07