How To Install python-cmd2 on CentOS 7

In this tutorial we learn how to install python-cmd2 on CentOS 7. python-cmd2 is Extra features for standard library’s cmd module

Introduction

In this tutorial we learn how to install python-cmd2 on CentOS 7.

What is python-cmd2

Enhancements for standard library’s cmd module. Drop-in replacement adds several features for command-prompt tools * Searchable command history (commands * Load commands from file, save to file, edit commands in file * Multi-line commands * Case-insensitive commands * Special-character shortcut commands (beyond cmd’s “@” and “!”) * Settable environment parameters * Parsing commands with flags * > (filename), » (filename) redirect output to file * < (filename) gets input from file * bare >, », < redirect to/from paste buffer * accepts abbreviated commands when unambiguous * py enters interactive Python console * test apps against sample session transcript (see example/example.py) Usable without modification anywhere cmd is used; simply import cmd2.Cmd in place of cmd.Cmd. See docs at http

We can use yum or dnf to install python-cmd2 on CentOS 7. In this tutorial we discuss both methods but you only need to choose one of method to install python-cmd2.

Install python-cmd2 on CentOS 7 Using yum

Update yum database with yum using the following command.

sudo yum makecache

After updating yum database, We can install python-cmd2 using yum by running the following command:

sudo yum -y install python-cmd2

Install python-cmd2 on CentOS 7 Using dnf

If you don’t have dnf installed you can install DNF on CentOS 7 first. Update yum database with dnf using the following command.

sudo dnf makecache

After updating yum database, We can install python-cmd2 using dnf by running the following command:

sudo dnf -y install python-cmd2

How To Uninstall python-cmd2 on CentOS 7

To uninstall only the python-cmd2 package we can use the following command:

sudo dnf remove python-cmd2

References

Summary

In this tutorial we learn how to install python-cmd2 on CentOS 7 using yum and dnf.