Advanced Users
You can modify the source code to remove the apt update
command.
Here is the code block you need to remove from the /usr/bin/add-apt-repository
file:
if update and not options.remove:
os.execvp("apt-get", ["apt-get", "update"])
sys.exit(0)
This will remove the update command.
NOTE: This piece of code comes two times in the file, you have to remove the LAST one. This piece of code in most files would be somewhere near line 198.
You can open the file using a text editor such as nano
and remove this piece of code.
You can also modify the code a bit, something like:
if update and not options.remove:
os.execvp("apt-get", ["apt-get", "moo"])
sys.exit(0)
NOTE: Edit this file with a terminal-text-editor like nano
instead of GUI editors like gedit
.
Beginners
Open a terminal using Ctrl + Alt + T
First, install nano:
sudo apt update
sudo apt install nano
Edit the file:
sudo nano /usr/bin/add-apt-repository
Press the down arrow key repeatedly,unless you reached the end of the file.
You'll find an if
statement which looks exactly like this:
if update and not options.remove:
os.execvp("apt-get", ["apt-get", "update"])
sys.exit(0)
Remove the whole if
code block mentioned above.
Press Ctrl + X and then select Y and press ENTER.
Test
Restore the file
Messed up?
No worry! If we run dpkg -S
on the file, we can see:
$ dpkg -S /usr/bin/add-apt-repository
software-properties-common: /usr/bin/add-apt-repository
So just run:
sudo apt update
sudo cp -r /usr/bin/add-apt-repository /tmp
sudo rm -rf /usr/bin/add-apt-repository
sudo apt install software-properties-common --reinstall