Getting source code for package in Ubuntu

  1. Open /etc/apt/sources.list and uncomment deb-src lines of respective repositories
  2. Don't forget to retrieve the updated package lists:
    sudo apt update
  3. Install dpkg-dev:
    sudo apt-install dpkg-dev
  4. Go to your ~ folder and download the source (htop for example):
    sudo apt source htop