How to install minicom in Debian or Ubuntu to configure Cisco switches and routers through the console port

I will assume that you are using Debian or Ubuntu Linux to configure your CISCO router using CLI.
Open your terminal and install minicom and setserial by typing this command in the terminal.

apt-get install minicom setserial

Check your serial port

dmesg | grep tty

The output should be like this:

[   18.439952] console [tty0] enabled
[   20.172975] serial8250: ttyS0 at I/O 0x3f8 (irq = 4) is a 16550A
[   20.173725] 00:08: ttyS0 at I/O 0x3f8 (irq = 4) is a 16550A

or you can use the setserial command

setserial -g /dev/ttyS0
/dev/ttyS0, UART: 16550A, Port: 0x03f8, IRQ: 4

Start minicom and configure it using the below command:

minicom -s

Select "Serial port setup"

            +-----[configuration]------+
            | Filenames and paths      |
            | File transfer protocols  |
            | Serial port setup        |
            | Modem and dialing        |
            | Screen and keyboard      |
            | Save setup as dfl        |
            | Save setup as..          |
            | Exit                     |
            | Exit from Minicom        |
            +--------------------------+

then use the following configuration

    +-----------------------------------------------------------------------+
    | A -    Serial Device      : /dev/ttyS0                                |
    | B - Lockfile Location     : /var/lock                                 |
    | C -   Callin Program      :                                           |
    | D -  Callout Program      :                                           |
    | E -    Bps/Par/Bits       : 9600 8N1                                  |
    | F - Hardware Flow Control : No                                       |
    | G - Software Flow Control : No                                        |
    |                                                                       |
    |    Change which setting?                                              |
    +-----------------------------------------------------------------------+

and save.

            +-----[configuration]------+                                     
            | Filenames and paths      | +-----------------------------------------+
            | File transfer protocols  | |Give name to save this configuration?    |
            | Serial port setup        | |> cisco                                  |
            | Modem and dialing        | +-----------------------------------------+
            | Screen and keyboard      |                    
            | Save setup as dfl        |                    
            | Save setup as..          |                    
            | Exit                     |                    
            | Exit from Minicom        |                    
            +--------------------------+                    

You can configure your CISCO router now, to exit minicom press CTRL+A then release and press Q or X.
Next time if you want to configure your CISCO router using console, you can just type this command.

minicom cisco

Have fun!