J Weezy
J Weezy

Reputation: 3957

What are some common HDFS commands that can be mapped in the bash files?

I am relatively new to Hadoop and I have been using HDFS CLI a lot. Commands like hdfs dfs -ls are becoming redundant to type. Is it possible to create an alias to this command (i.e., h -ls) in either the .bashrc or .bash_profile files? Are there any other useful commands that I can map here?

Upvotes: 1

Views: 535

Answers (1)

Alice
Alice

Reputation: 1432

The good practice is to put aliases in .bash_aliases.

For your problem, I'd put alias h="hdfs dfs" in my .bash_aliases file (create it if it doesn't exist)

Most distribs will already have this in their .bashrc file but if it's not there, add

if [ -f ~/.bash_aliases ]; then
    . ~/.bash_aliases
fi

in your .bashrc

Now you can either type source .bashrc or restart you terminal and h -ls wille be interpreted as hdfs dfs -ls

Note that cou can also very well put all of your aliases directly in the .bashrc, but I find it more convenient to have all the aliases set appart.

Are there any other useful commands that I can map here?

Look at this, it might give you some ideas : https://www.cyberciti.biz/tips/bash-aliases-mac-centos-linux-unix.html

And you can add what you want so if you run a command really often you can consider adding it in your aliases.

Hope this helps!

Upvotes: 1

Related Questions