Skip to content

Instantly share code, notes, and snippets.

@cobaohieu
Forked from patrickmmartin/PYTHON_DEFAULT.md
Last active January 4, 2026 22:27
Show Gist options
  • Select an option

  • Save cobaohieu/ded429cb892b46ae9bfd9919a11e593a to your computer and use it in GitHub Desktop.

Select an option

Save cobaohieu/ded429cb892b46ae9bfd9919a11e593a to your computer and use it in GitHub Desktop.

Revisions

  1. cobaohieu revised this gist Jun 21, 2021. No changes.
  2. cobaohieu revised this gist Jun 21, 2021. 1 changed file with 1 addition and 1 deletion.
    2 changes: 1 addition & 1 deletion update-gcc.md
    Original file line number Diff line number Diff line change
    @@ -56,7 +56,7 @@ $ sudo update-alternatives --install /usr/bin/gcc gcc /usr/bin/gcc-10 10 --slave
    $ sudo update-alternatives --install /usr/bin/gcc gcc /usr/bin/gcc-11 11 --slave /usr/bin/g++ g++ /usr/bin/g++-11 --slave /usr/bin/gcov gcov /usr/bin/gcov-11
    $ sudo update-alternatives --config gcc
    There are 2 choices for the alternative python (providing /usr/bin/python).
    There are 2 choices for the alternative gcc (providing /usr/bin/gcc).
    Selection Path Priority Status
    ------------------------------------------------------------
  3. cobaohieu renamed this gist Jun 21, 2021. 1 changed file with 0 additions and 0 deletions.
    File renamed without changes.
  4. cobaohieu revised this gist Jun 3, 2021. 1 changed file with 6 additions and 6 deletions.
    12 changes: 6 additions & 6 deletions update_gcc.md
    Original file line number Diff line number Diff line change
    @@ -60,12 +60,12 @@ There are 2 choices for the alternative python (providing /usr/bin/python).
    Selection Path Priority Status
    ------------------------------------------------------------
    0 /usr/bin/gcc-11 110 auto mode
    1 /usr/bin/gcc-10 100 manual mode
    2 /usr/bin/gcc-11 110 manual mode
    3 /usr/bin/gcc-7 70 manual mode
    * 4 /usr/bin/gcc-8 80 manual mode
    5 /usr/bin/gcc-9 90 manual mode
    0 /usr/bin/gcc-11 11 auto mode
    1 /usr/bin/gcc-10 10 manual mode
    2 /usr/bin/gcc-11 11 manual mode
    3 /usr/bin/gcc-7 7 manual mode
    * 4 /usr/bin/gcc-8 8 manual mode
    5 /usr/bin/gcc-9 9 manual mode
    Press <enter> to keep the current choice[*], or type selection number:
  5. cobaohieu revised this gist Jun 3, 2021. 1 changed file with 4 additions and 4 deletions.
    8 changes: 4 additions & 4 deletions update_gcc.md
    Original file line number Diff line number Diff line change
    @@ -2,10 +2,10 @@ Run the following commands as root or user with sudo access to update the packag
    To install the Development Tools packages, run the following command as root or user with sudo privileges :
    ```
    $ sudo apt update
    $ sudo apt-get upgrade -y && \
    $ sudo apt-get dist-upgrade -y && \
    $ sudo apt-get install build-essential software-properties-common manpages-dev -y && \
    $ sudo add-apt-repository ppa:ubuntu-toolchain-r/test -y && \
    $ sudo apt-get upgrade -y
    $ sudo apt-get dist-upgrade -y
    $ sudo apt-get install build-essential software-properties-common manpages-dev -y
    $ sudo add-apt-repository ppa:ubuntu-toolchain-r/test -y
    $ sudo apt-get update -y
    ```

  6. cobaohieu revised this gist Jun 3, 2021. 1 changed file with 1 addition and 1 deletion.
    2 changes: 1 addition & 1 deletion update_gcc.md
    Original file line number Diff line number Diff line change
    @@ -22,7 +22,7 @@ warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
    Installing Multiple GCC Versions

    ```
    $ sudo apt install gcc-8 g++-8 gcc-9 g++-9 gcc-10 g++-10 gcc-11 g++-11
    $ sudo apt install gcc-8 g++-8 gcc-9 g++-9 gcc-10 g++-10 gcc-11 g++-11 -y
    ```
    change the default version

  7. cobaohieu revised this gist Jun 3, 2021. 1 changed file with 5 additions and 2 deletions.
    7 changes: 5 additions & 2 deletions update_gcc.md
    Original file line number Diff line number Diff line change
    @@ -2,8 +2,11 @@ Run the following commands as root or user with sudo access to update the packag
    To install the Development Tools packages, run the following command as root or user with sudo privileges :
    ```
    $ sudo apt update
    $ sudo apt install build-essential
    $ sudo apt-get install manpages-dev
    $ sudo apt-get upgrade -y && \
    $ sudo apt-get dist-upgrade -y && \
    $ sudo apt-get install build-essential software-properties-common manpages-dev -y && \
    $ sudo add-apt-repository ppa:ubuntu-toolchain-r/test -y && \
    $ sudo apt-get update -y
    ```

    Verify that the GCC compiler is successfully installed by running the following command that prints the GCC version:
  8. cobaohieu revised this gist Jun 3, 2021. 1 changed file with 5 additions and 5 deletions.
    10 changes: 5 additions & 5 deletions update_gcc.md
    Original file line number Diff line number Diff line change
    @@ -46,11 +46,11 @@ lrwxrwxrwx 1 root root 21 Thg 5 27 09:22 /usr/bin/g++ -> /etc/alternatives/g++
    So we have 5 - use these in update-alernatives

    ```
    $ sudo update-alternatives --install /usr/bin/gcc gcc /usr/bin/gcc-7 70 --slave /usr/bin/g++ g++ /usr/bin/g++-7 --slave /usr/bin/gcov gcov /usr/bin/gcov-7
    $ sudo update-alternatives --install /usr/bin/gcc gcc /usr/bin/gcc-8 80 --slave /usr/bin/g++ g++ /usr/bin/g++-8 --slave /usr/bin/gcov gcov /usr/bin/gcov-8
    $ sudo update-alternatives --install /usr/bin/gcc gcc /usr/bin/gcc-9 90 --slave /usr/bin/g++ g++ /usr/bin/g++-9 --slave /usr/bin/gcov gcov /usr/bin/gcov-9
    $ sudo update-alternatives --install /usr/bin/gcc gcc /usr/bin/gcc-10 100 --slave /usr/bin/g++ g++ /usr/bin/g++-10 --slave /usr/bin/gcov gcov /usr/bin/gcov-10
    $ sudo update-alternatives --install /usr/bin/gcc gcc /usr/bin/gcc-11 110 --slave /usr/bin/g++ g++ /usr/bin/g++-11 --slave /usr/bin/gcov gcov /usr/bin/gcov-11
    $ sudo update-alternatives --install /usr/bin/gcc gcc /usr/bin/gcc-7 7 --slave /usr/bin/g++ g++ /usr/bin/g++-7 --slave /usr/bin/gcov gcov /usr/bin/gcov-7
    $ sudo update-alternatives --install /usr/bin/gcc gcc /usr/bin/gcc-8 8 --slave /usr/bin/g++ g++ /usr/bin/g++-8 --slave /usr/bin/gcov gcov /usr/bin/gcov-8
    $ sudo update-alternatives --install /usr/bin/gcc gcc /usr/bin/gcc-9 9 --slave /usr/bin/g++ g++ /usr/bin/g++-9 --slave /usr/bin/gcov gcov /usr/bin/gcov-9
    $ sudo update-alternatives --install /usr/bin/gcc gcc /usr/bin/gcc-10 10 --slave /usr/bin/g++ g++ /usr/bin/g++-10 --slave /usr/bin/gcov gcov /usr/bin/gcov-10
    $ sudo update-alternatives --install /usr/bin/gcc gcc /usr/bin/gcc-11 11 --slave /usr/bin/g++ g++ /usr/bin/g++-11 --slave /usr/bin/gcov gcov /usr/bin/gcov-11
    $ sudo update-alternatives --config gcc
    There are 2 choices for the alternative python (providing /usr/bin/python).
  9. cobaohieu revised this gist May 31, 2021. 1 changed file with 2 additions and 2 deletions.
    4 changes: 2 additions & 2 deletions update_gcc.md
    Original file line number Diff line number Diff line change
    @@ -57,11 +57,11 @@ There are 2 choices for the alternative python (providing /usr/bin/python).
    Selection Path Priority Status
    ------------------------------------------------------------
    * 0 /usr/bin/gcc-11 110 auto mode
    0 /usr/bin/gcc-11 110 auto mode
    1 /usr/bin/gcc-10 100 manual mode
    2 /usr/bin/gcc-11 110 manual mode
    3 /usr/bin/gcc-7 70 manual mode
    4 /usr/bin/gcc-8 80 manual mode
    * 4 /usr/bin/gcc-8 80 manual mode
    5 /usr/bin/gcc-9 90 manual mode
    Press <enter> to keep the current choice[*], or type selection number:
  10. cobaohieu revised this gist May 27, 2021. 1 changed file with 3 additions and 3 deletions.
    6 changes: 3 additions & 3 deletions update_gcc.md
    Original file line number Diff line number Diff line change
    @@ -1,9 +1,9 @@
    Run the following commands as root or user with sudo access to update the packages list and install the prerequisites:
    To install the Development Tools packages, run the following command as root or user with sudo privileges :
    ```
    sudo apt update
    sudo apt install build-essential
    sudo apt-get install manpages-dev
    $ sudo apt update
    $ sudo apt install build-essential
    $ sudo apt-get install manpages-dev
    ```

    Verify that the GCC compiler is successfully installed by running the following command that prints the GCC version:
  11. cobaohieu revised this gist May 27, 2021. 1 changed file with 7 additions and 7 deletions.
    14 changes: 7 additions & 7 deletions update_gcc.md
    Original file line number Diff line number Diff line change
    @@ -9,7 +9,7 @@ sudo apt-get install manpages-dev
    Verify that the GCC compiler is successfully installed by running the following command that prints the GCC version:

    ```
    gcc --version
    $ gcc --version
    gcc (Ubuntu 9.3.0-17ubuntu1~20.04) 9.3.0
    Copyright (C) 2019 Free Software Foundation, Inc.
    This is free software; see the source for copying conditions. There is NO
    @@ -19,7 +19,7 @@ warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
    Installing Multiple GCC Versions

    ```
    sudo apt install gcc-8 g++-8 gcc-9 g++-9 gcc-10 g++-10 gcc-11 g++-11
    $ sudo apt install gcc-8 g++-8 gcc-9 g++-9 gcc-10 g++-10 gcc-11 g++-11
    ```
    change the default version

    @@ -46,11 +46,11 @@ lrwxrwxrwx 1 root root 21 Thg 5 27 09:22 /usr/bin/g++ -> /etc/alternatives/g++
    So we have 5 - use these in update-alernatives

    ```
    sudo update-alternatives --install /usr/bin/gcc gcc /usr/bin/gcc-7 70 --slave /usr/bin/g++ g++ /usr/bin/g++-7 --slave /usr/bin/gcov gcov /usr/bin/gcov-7
    sudo update-alternatives --install /usr/bin/gcc gcc /usr/bin/gcc-8 80 --slave /usr/bin/g++ g++ /usr/bin/g++-8 --slave /usr/bin/gcov gcov /usr/bin/gcov-8
    sudo update-alternatives --install /usr/bin/gcc gcc /usr/bin/gcc-9 90 --slave /usr/bin/g++ g++ /usr/bin/g++-9 --slave /usr/bin/gcov gcov /usr/bin/gcov-9
    sudo update-alternatives --install /usr/bin/gcc gcc /usr/bin/gcc-10 100 --slave /usr/bin/g++ g++ /usr/bin/g++-10 --slave /usr/bin/gcov gcov /usr/bin/gcov-10
    sudo update-alternatives --install /usr/bin/gcc gcc /usr/bin/gcc-11 110 --slave /usr/bin/g++ g++ /usr/bin/g++-11 --slave /usr/bin/gcov gcov /usr/bin/gcov-11
    $ sudo update-alternatives --install /usr/bin/gcc gcc /usr/bin/gcc-7 70 --slave /usr/bin/g++ g++ /usr/bin/g++-7 --slave /usr/bin/gcov gcov /usr/bin/gcov-7
    $ sudo update-alternatives --install /usr/bin/gcc gcc /usr/bin/gcc-8 80 --slave /usr/bin/g++ g++ /usr/bin/g++-8 --slave /usr/bin/gcov gcov /usr/bin/gcov-8
    $ sudo update-alternatives --install /usr/bin/gcc gcc /usr/bin/gcc-9 90 --slave /usr/bin/g++ g++ /usr/bin/g++-9 --slave /usr/bin/gcov gcov /usr/bin/gcov-9
    $ sudo update-alternatives --install /usr/bin/gcc gcc /usr/bin/gcc-10 100 --slave /usr/bin/g++ g++ /usr/bin/g++-10 --slave /usr/bin/gcov gcov /usr/bin/gcov-10
    $ sudo update-alternatives --install /usr/bin/gcc gcc /usr/bin/gcc-11 110 --slave /usr/bin/g++ g++ /usr/bin/g++-11 --slave /usr/bin/gcov gcov /usr/bin/gcov-11
    $ sudo update-alternatives --config gcc
    There are 2 choices for the alternative python (providing /usr/bin/python).
  12. cobaohieu revised this gist May 27, 2021. 2 changed files with 83 additions and 47 deletions.
    47 changes: 0 additions & 47 deletions PYTHON_DEFAULT.md
    Original file line number Diff line number Diff line change
    @@ -1,47 +0,0 @@
    Ubuntu 16 default python is *almost* python 3
    ===

    Loads of solutions exist, but for changing the system default, _alias_ is not the way to go.


    $ update-alternatives --list python
    update-alternatives: error: no alternatives for python

    ```
    ls -larth `which python`*
    -rwxr-xr-x 2 root root 4.3M Nov 17 19:23 /usr/bin/python3.5
    -rwxr-xr-x 1 root root 3.4M Nov 19 09:35 /usr/bin/python2.7
    lrwxrwxrwx 1 root root 24 Feb 5 09:36 /usr/bin/python -> /etc/alternatives/python
    ```

    So we have 2 - use these in update-alernatives

    ```
    sudo update-alternatives --install /usr/bin/python python /usr/bin/python2.7 1
    sudo update-alternatives --install /usr/bin/python python /usr/bin/python3.5 2
    $ sudo update-alternatives --config python
    There are 2 choices for the alternative python (providing /usr/bin/python).
    Selection Path Priority Status
    ------------------------------------------------------------
    * 0 /usr/bin/python3.5 2 auto mode
    1 /usr/bin/python2.7 1 manual mode
    2 /usr/bin/python3.5 2 manual mode
    Press <enter> to keep the current choice[*], or type selection number:
    ```
    Done

    ```
    $ python --version
    Python 3.5.2
    $ python2 --version
    Python 2.7.12
    $ python3 --version
    Python 3.5.2
    ```
    83 changes: 83 additions & 0 deletions update_gcc.md
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,83 @@
    Run the following commands as root or user with sudo access to update the packages list and install the prerequisites:
    To install the Development Tools packages, run the following command as root or user with sudo privileges :
    ```
    sudo apt update
    sudo apt install build-essential
    sudo apt-get install manpages-dev
    ```

    Verify that the GCC compiler is successfully installed by running the following command that prints the GCC version:

    ```
    gcc --version
    gcc (Ubuntu 9.3.0-17ubuntu1~20.04) 9.3.0
    Copyright (C) 2019 Free Software Foundation, Inc.
    This is free software; see the source for copying conditions. There is NO
    warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
    ```

    Installing Multiple GCC Versions

    ```
    sudo apt install gcc-8 g++-8 gcc-9 g++-9 gcc-10 g++-10 gcc-11 g++-11
    ```
    change the default version

    ```
    $ ls -larth `which gcc`*
    lrwxrwxrwx 1 root root 23 Thg 1 4 2019 /usr/bin/gcc-7 -> aarch64-linux-gnu-gcc-7
    lrwxrwxrwx 1 root root 23 Thg 3 10 2020 /usr/bin/gcc-8 -> aarch64-linux-gnu-gcc-8
    lrwxrwxrwx 1 root root 23 Thg 4 23 2020 /usr/bin/gcc-9 -> aarch64-linux-gnu-gcc-9
    lrwxrwxrwx 1 root root 24 Thg 4 15 19:21 /usr/bin/gcc-10 -> aarch64-linux-gnu-gcc-10
    lrwxrwxrwx 1 root root 24 Thg 4 29 01:05 /usr/bin/gcc-11 -> aarch64-linux-gnu-gcc-11
    lrwxrwxrwx 1 root root 21 Thg 5 27 09:22 /usr/bin/gcc -> /etc/alternatives/gcc
    ```

    ```
    $ ls -larth `which g++`*
    lrwxrwxrwx 1 root root 23 Thg 1 4 2019 /usr/bin/g++-7 -> aarch64-linux-gnu-g++-7
    lrwxrwxrwx 1 root root 23 Thg 3 10 2020 /usr/bin/g++-8 -> aarch64-linux-gnu-g++-8
    lrwxrwxrwx 1 root root 23 Thg 4 23 2020 /usr/bin/g++-9 -> aarch64-linux-gnu-g++-9
    lrwxrwxrwx 1 root root 24 Thg 4 15 19:21 /usr/bin/g++-10 -> aarch64-linux-gnu-g++-10
    lrwxrwxrwx 1 root root 24 Thg 4 29 01:05 /usr/bin/g++-11 -> aarch64-linux-gnu-g++-11
    lrwxrwxrwx 1 root root 21 Thg 5 27 09:22 /usr/bin/g++ -> /etc/alternatives/g++
    ```

    So we have 5 - use these in update-alernatives

    ```
    sudo update-alternatives --install /usr/bin/gcc gcc /usr/bin/gcc-7 70 --slave /usr/bin/g++ g++ /usr/bin/g++-7 --slave /usr/bin/gcov gcov /usr/bin/gcov-7
    sudo update-alternatives --install /usr/bin/gcc gcc /usr/bin/gcc-8 80 --slave /usr/bin/g++ g++ /usr/bin/g++-8 --slave /usr/bin/gcov gcov /usr/bin/gcov-8
    sudo update-alternatives --install /usr/bin/gcc gcc /usr/bin/gcc-9 90 --slave /usr/bin/g++ g++ /usr/bin/g++-9 --slave /usr/bin/gcov gcov /usr/bin/gcov-9
    sudo update-alternatives --install /usr/bin/gcc gcc /usr/bin/gcc-10 100 --slave /usr/bin/g++ g++ /usr/bin/g++-10 --slave /usr/bin/gcov gcov /usr/bin/gcov-10
    sudo update-alternatives --install /usr/bin/gcc gcc /usr/bin/gcc-11 110 --slave /usr/bin/g++ g++ /usr/bin/g++-11 --slave /usr/bin/gcov gcov /usr/bin/gcov-11
    $ sudo update-alternatives --config gcc
    There are 2 choices for the alternative python (providing /usr/bin/python).
    Selection Path Priority Status
    ------------------------------------------------------------
    * 0 /usr/bin/gcc-11 110 auto mode
    1 /usr/bin/gcc-10 100 manual mode
    2 /usr/bin/gcc-11 110 manual mode
    3 /usr/bin/gcc-7 70 manual mode
    4 /usr/bin/gcc-8 80 manual mode
    5 /usr/bin/gcc-9 90 manual mode
    Press <enter> to keep the current choice[*], or type selection number:
    ```
    Done

    ```
    $ gcc --version
    gcc (Ubuntu/Linaro 8.4.0-1ubuntu1~18.04) 8.4.0
    Copyright (C) 2018 Free Software Foundation, Inc.
    This is free software; see the source for copying conditions. There is NO
    warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
    $ g++ --version
    g++ (Ubuntu/Linaro 8.4.0-1ubuntu1~18.04) 8.4.0
    Copyright (C) 2018 Free Software Foundation, Inc.
    This is free software; see the source for copying conditions. There is NO
    warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
    ```
  13. @patrickmmartin patrickmmartin created this gist Feb 5, 2017.
    47 changes: 47 additions & 0 deletions PYTHON_DEFAULT.md
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,47 @@
    Ubuntu 16 default python is *almost* python 3
    ===

    Loads of solutions exist, but for changing the system default, _alias_ is not the way to go.


    $ update-alternatives --list python
    update-alternatives: error: no alternatives for python

    ```
    ls -larth `which python`*
    -rwxr-xr-x 2 root root 4.3M Nov 17 19:23 /usr/bin/python3.5
    -rwxr-xr-x 1 root root 3.4M Nov 19 09:35 /usr/bin/python2.7
    lrwxrwxrwx 1 root root 24 Feb 5 09:36 /usr/bin/python -> /etc/alternatives/python
    ```

    So we have 2 - use these in update-alernatives

    ```
    sudo update-alternatives --install /usr/bin/python python /usr/bin/python2.7 1
    sudo update-alternatives --install /usr/bin/python python /usr/bin/python3.5 2
    $ sudo update-alternatives --config python
    There are 2 choices for the alternative python (providing /usr/bin/python).
    Selection Path Priority Status
    ------------------------------------------------------------
    * 0 /usr/bin/python3.5 2 auto mode
    1 /usr/bin/python2.7 1 manual mode
    2 /usr/bin/python3.5 2 manual mode
    Press <enter> to keep the current choice[*], or type selection number:
    ```
    Done

    ```
    $ python --version
    Python 3.5.2
    $ python2 --version
    Python 2.7.12
    $ python3 --version
    Python 3.5.2
    ```