Getting the error in openvpn repo while running command apt-get update - apt

I am getting the following error while running command "apt-get update":
E: Type 'gpg' is not known on line 1 in source list /etc/apt/sources.list.d/openvpn-as-repo.list
E: The list of sources could not be read.
Can someone please help me solve this error?

The below answer is taken from: https://askubuntu.com/questions/96967/how-do-i-fix-this-e-type-is-not-known-on-line-in-source-list-update
The error indicates a malformed entry in a source file, which causes the update process to abort. To fix it, you have to either fix the entry (if you know what the right entry should look like) or remove it altogether (that's what I'm going to describe, as it's the fastest way to enable you to update your system again).
First, you need to open the file containing the bad entry. The filename is given in the error message, in your example /etc/apt/sources.list.d/some-ppa.list. Open a terminal, and type
sudo nano /etc/apt/sources.list.d/some-ppa.list
and press Enter. After entering your password, you should now see the file opened in the text editor nano.
Now you need to locate the malformed entry. It should be on the line number given in the error message - in your case that would be line 1.
This line should be incomplete and start with the unknown type the update process is complaining about (here ain). Just delete the whole line, and save/close the file with Ctrl+X.
That's it. You should now be able to successfully run the update process.

It seems something went wrong. Redo these commands again.
# wget must be available. If wget is not installed and apt update is broken skip apt update in the next line.
sudo apt update && sudo apt -y install ca-certificates wget net-tools
wget -qO - https://as-repository.openvpn.net/as-repo-public.gpg | sudo apt-key add -
sudo sh -c 'echo "deb http://as-repository.openvpn.net/as/debian bionic main">/etc/apt/sources.list.d/openvpn-as-repo.list'
sudo apt update && sudo apt -y install openvpn-as

Related

Trying to uninstall elasticsearch results error

sudo apt-get remove elasticsearch results to
E: Conflicting values set for option Signed-By regarding source https://artifacts.elastic.co/packages/5.x/apt/ stable: /usr/share/keyrings/elasticsearch-keyring.gpg !=
E: The list of sources could not be read.
ls /etc/apt/sources.list.d/
you can see your all .list files like
elastic-5.x.list
elastic-8.x.list
google-chrome.list
obsproject-ubuntu-obs-studio-jammy.list
sublime-text.list~
teamviewer.list
choose the one of them that has problem and remove it using the following command
sudo rm -r /etc/apt/sources.list.d/elastic-5.x.list
sudo apt remove -f elasticsearch

How to make apt assume yes and force yes for all installations in a bash script

I'm currently getting into linux and want to write a bash script which sets up a new machine just the way I want it to be.
In order to do that I want to install differnt things on it etc.
What I'm trying to achieve here is to have a setting at the top of the bash script which will make apt accept all [y/n] questions asked during the execution of the script
Question example I want to automatically accept:
After this operation, 1092 kB of additional disk space will be used. Do you want to continue? [Y/n]
I just started creating the file so here is what i have so far:
#!/bin/bash
# Constants
# Set apt to accept all [y/n] questions
>> some setting here <<
# Update and upgrade apt
apt update;
apt full-upgrade;
# Install terminator
apt install terminator
apt is meant to be used interactively. If you want to automate things, look at apt-get, and in particular its -y option:
-y, --yes, --assume-yes
Automatic yes to prompts; assume "yes" as answer to all prompts and run non-interactively. If an undesirable
situation, such as changing a held package, trying to install an
unauthenticated package or removing an essential package occurs then
apt-get will abort. Configuration Item: APT::Get::Assume-Yes.
See also man apt-get for many more options.
With apt:
apt -o Apt::Get::Assume-Yes=true install <package>
See: man apt and man apt.conf
If you indeed want to set it up once at the top of the file as you say and then forget about it, you can use the APT_CONFIG environment variable. See apt.conf.
echo "APT::Get::Assume-Yes=yes" > /tmp/_tmp_apt.conf
export APT_CONFIG=/tmp/_tmp_apt.conf
apt-get update
apt-get install terminator
...
You can set up API assume yes permanently as follow:
echo "APT::Get::Assume-Yes \"true\";\nAPT::Get::allow \"true\";" | sudo tee -a /etc/apt/apt.conf.d/90_no_prompt
Another easy way to set it at the top of the your script is to use the command alias apt-get="apt-get --assume-yes", which causes all subsequent invocations of apt-get to include the --assume-yes argument. For example apt-get upgrade would automatically get converted to apt-get --assume-yes upgrade" by bash.
Please note, that this may cause errors, because some apt-get subcommands do not accept the --assume-yes argument. For example apt-get help would be converted to apt-get --assume-yes help which returns an error, because the help subcommand can't be used together with --assume-yes.

Just to Update and Upgrade in terminal

so what i want to do is to create a shell script to update and upgrade for that i just created an .sh file in which there are three lines of command
sudo apt-get update
sudo apt-get upgrade
sudo apt-get dist-upgrade
after running .sh file it executes just fine.
but what i want to do more with it is - after successfully running update command and while running upgrade command it ask us to get the archive with 'Y/N'.
can i do something in .sh so that i don't have to type 'y' or 'n' . i want y to be default.
On a debian based installation on Raspberry i using the short form of IF THEN ELSE like this...
apt update && apt -y full-upgrade || echo 'Hm, something failed!'
...and "The Matrix" asking nothing.

Can I start atom from my ubuntu on windows terminal?

I have been following this class which has instructed me to open atom through my ubuntu terminal with the command "atom ." but it prints "command not found"
I know now that the ubuntu system and windows system run independently of each other, but still have no clue how to make it work.Here is the error
No command 'atom' found, did you mean:
Command 'atrm' from package 'at' (main)
Command 'atoms' from package 'horae' (multiverse)
Command 'atom4' from package 'atom4' (universe)
Command 'atobm' from package 'x11-apps' (main)
Command 'atop' from package 'atop' (universe)
atom: command not found
Install again if you have to (there is no hurt in doing so).
Try this link: atom install.
In summary, this is what the link says to do. (When executing these commands in your terminal, look to see if you get any output back. Observe if the terminal spits out errors.)
First in a terminal copy and paste the below then hit enter:
wget -qO - https://packagecloud.io/AtomEditor/atom/gpgkey | sudo apt-key add -
Then copy and paste the below into a term and hit enter:
sudo sh -c 'echo "deb [arch=amd64] https://packagecloud.io/AtomEditor/atom/any/ any main" > /etc/apt/sources.list.d/atom.list'
Then this:
sudo apt-get update
Then:
sudo apt-get install atom
Finally, see if you are able to open atom:
atom .

bash loop check command error then reiterate

Hi i'm writing a bash script that have to keep some installation process quick and easy for non dev-user.
I wrote this loop that has to check if the command sudo add-apt-repository give the error sudo: add-apt-repository: command not found and if so, need to run the command sudo apt-get install software-properties-common then reiterate the first command and go on with other instrucion
until sudo add-apt-repository; do
echo "sudo: add-apt-repository: command not found"
sudo apt-get install software-properties-common
done
...
other command
I tryed that loop but it don't run the second command under the echo. Can please someone help me fix that problem?
Thanks
Which behaviour do you have ? Because even if add-apt-repository is installed sudo add-apt-repository will fail
$ sudo add-apt-repository
Error: need a repository as argument
$ echo $?
1
Maybe, using "which" command is better, it returns 0 if the command exists and 1 if not.
Using conditional if instead of until should be enough to install the command.

Resources