Skip to content

Instantly share code, notes, and snippets.

@namelessenko
Last active June 10, 2023 13:46
Show Gist options
  • Save namelessenko/0e97fab9875137f76e9d9c85f816dbc8 to your computer and use it in GitHub Desktop.
Save namelessenko/0e97fab9875137f76e9d9c85f816dbc8 to your computer and use it in GitHub Desktop.
To set up a proxy server in Debian, you can follow these steps:
1. Open a terminal window.
2. Navigate to the directory where the proxy settings are stored by running the following command:
```
cd /etc/apt/
```
3. Create or edit the `apt.conf` file using a text editor such as Nano or Vim:
```
sudo nano apt.conf
```
4. Add the following lines to the `apt.conf` file, replacing "proxy_server" and "port_number" with the appropriate values for your proxy server:
```
Acquire::http::Proxy "http://proxy_server:port_number/";
Acquire::https::Proxy "http://proxy_server:port_number/";
```
5. Save the changes and exit the text editor. In Nano, you can do this by pressing Ctrl+O, Enter, and then Ctrl+X.
6. Test the proxy server configuration by running the following command:
```
sudo apt update
```
If the update command is successful, it means that the proxy server is set up correctly.
Note: The above steps configure the proxy settings for the APT package manager. If you want to set up a system-wide proxy for other applications as well, you may need to configure additional environment variables or modify specific application settings.
Remember to replace "proxy_server" and "port_number" with the actual values provided by your proxy server administrator.
It could yield the following error message
```
E: Could not get lock /var/lib/apt/lists/lock. It is held by process 58 (apt)
N: Be aware that removing the lock file is not a solution and may break your system.
E: Unable to lock directory /var/lib/apt/lists/
```
The error message you encountered suggests that the package management system (APT) is currently being used by another process, and therefore, it cannot acquire the necessary lock to perform the update. This situation commonly occurs when another instance of APT, such as the Software Updater or another terminal session running APT, is already running.
To resolve this issue, you can follow these steps:
1. Make sure that no other package management processes are running. Close any software update windows or other terminal sessions that might be using APT.
2. If you are certain that no other APT process is running, you can remove the lock files manually. Execute the following command to delete the lock files:
```
sudo rm /var/lib/apt/lists/lock
sudo rm /var/lib/dpkg/lock*
```
3. After removing the lock files, it is a good idea to update your package lists and upgrade any installed packages to ensure your system is up to date:
```
sudo apt update
sudo apt upgrade
```
4. If the issue persists, you may need to restart your system. Rebooting can help clear any lingering processes that might be holding the APT locks.
By following these steps, you should be able to resolve the lock-related error and successfully update your Debian system using APT.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment