I uninstalled accidentally python3.10 using rm -rf python3.10 in /usr/bin my terminal is not working anymore
but can access through VSCode but it say
any suggestion? thank you in advanced
It is because /usr/bin/python3 is a soft link to /usr/bin/python3.10 which is the main binary that runs python3 on your machine.
This should help :
$ ls -l /usr/bin/python3
lrwxrwxrwx 1 root root 10 May 31 13:02 /usr/bin/python3 -> python3.10
You might need to install python again to get the binary.
If you have different version of python available that you want to use, create link to it like this:
ln -s file1 link1
which would be in case you have python3.10 re/installed
ln -s /usr/bin/python3.10 /usr/bin/python3
Considering you deleted python3.10 binary by mistake!
I'd like to add nvim (a snap) to update-alternatives. The problem is that snap seems to work in mysterious ways when determining which program to run:
$ sudo update-alternatives --install /usr/bin/vim vim /snap/bin/nvim 60
$ vim # works
$ vim hello.txt
error: unknown command "hello.txt", see 'snap help'.
If I look at /snap/bin/nvim it is a link to /usr/bin/snap:
$ ls -lah /snap/bin/nvim
lrwxrwxrwx 1 root root 13 Jan 25 15:02 /snap/bin/nvim -> /usr/bin/snap
But how does the snap executable determine it needs to run nvim
In order to use it like that you have to create a script that starts nvim like this:
#!/usr/bin/env bash
/usr/bin/snap run nvim ${#}
Lets say you call it nvim_start.sh. Now you can use this script in your update-alternatives commands (remember to enable the execution flag):
CUSTOM_NVIM_PATH=/usr/bin/nvim_start.sh
sudo chmod +x "${CUSTOM_NVIM_PATH}"
set -u
sudo update-alternatives --install /usr/bin/ex ex "${CUSTOM_NVIM_PATH}" 110
sudo update-alternatives --install /usr/bin/vi vi "${CUSTOM_NVIM_PATH}" 110
sudo update-alternatives --install /usr/bin/view view "${CUSTOM_NVIM_PATH}" 110
sudo update-alternatives --install /usr/bin/vim vim "${CUSTOM_NVIM_PATH}" 110
sudo update-alternatives --install /usr/bin/vimdiff vimdiff "${CUSTOM_NVIM_PATH}" 110
sudo update-alternatives --set ex "${CUSTOM_NVIM_PATH}"
sudo update-alternatives --set vi "${CUSTOM_NVIM_PATH}"
sudo update-alternatives --set view "${CUSTOM_NVIM_PATH}"
sudo update-alternatives --set vim "${CUSTOM_NVIM_PATH}"
sudo update-alternatives --set vimdiff "${CUSTOM_NVIM_PATH}"
I'm not sure why using /snap/bin/nvim does not work, even when called from inside the script. At least the workaround works OK.
I would like to remove php7.2-fpm from on boot start because Supervisor process manager will take care of starting php7.2-fpm. Do do this I had tried following commands but none of them worked for me. Ubuntu version is 14.04.
> sudo update-rc.d php7.2-fpm remove
Output: update-rc.d: /etc/init.d/php7.2-fpm exists during rc.d purge (use -f to force)
> sudo update-rc.d -f php7.2-fpm remove
Output: Removing any system startup links for /etc/init.d/php7.2-fpm ...
> sudo update-rc.d php7.2-fpm disable
Output: update-rc.d: warning: start runlevel arguments (none) do not match php7.2-fpm Default-Start values (2 3 4 5)
update-rc.d: warning: stop runlevel arguments (none) do not match php7.2-fpm Default-Stop values (0 1 6)
System start/stop links for /etc/init.d/php7.2-fpm do not exist.
> ls -al /etc/init.d/php7.2-fpm
Output: -rwxr-xr-x 1 root root 4793 Jan 13 10:58 /etc/init.d/php7.2-fpm
I'm not getting what's wrong in my commands.
Disable the service in case you need it in the future:
# prevent the script from being executed
sudo chmod -x /etc/init.d/php7.2-fpm
I have installed gcc-4.8 and gcc-6. The default gcc version is gcc-4.8, but I want to change the default gcc version to gcc-6, so I do the following:
$ sudo update-alternatives --remove-all gcc
$ sudo update-alternatives --install /usr/bin/gcc gcc /usr/bin/gcc-4.8 10
$ sudo update-alternatives --install /usr/bin/gcc gcc /usr/bin/gcc-6 20
then the default gcc version has changed to gcc-6, but when I run command
$ man gcc
the man page version of gcc is still gcc-4.8. How can I change the man page version of gcc to gcc-6? Thanks!
Sorry for my bad English.
I have found the solution:
Find the location of gcc-6 man page:
$ locate gcc-6 | grep 'man'
/usr/share/man/man1/gcc-6.1.gz
/usr/share/man/man1/x86_64-linux-gnu-gcc-6.1.gz
so the location of gcc-6 man page is /usr/share/man/man1/gcc-6.1.gz
Remove the file /usr/share/man/man1/gcc.1.gz if it exist:
$ sudo rm /usr/share/man/man1/gcc.1.gz
Create a symbolic link to /usr/share/man/man1/gcc-6.1.gz:
$ sudo ln -s /usr/share/man/man1/gcc-6.1.gz /usr/share/man/man1/gcc.1.gz
Then run comman:
$ man gcc
You will see the man page version of gcc has changed to gcc-6.
Sorry for my English.
I am writing a script that installs java on a remote machine. After i run the .bin file for the JRE, how can i set the alternatives --config java without the user having to input anything.
For instance, when you type in "alternatives --config java" you are prompted to select which java version you would like. Due to the way i installed java ("/usr/sbin/alternatives --install /usr/bin/java java /location/of/jdk1.6/bin/java 2") the #"2" option should always be the java that i want selected.
So, using an ssh command execution, how can i select the second option for java alternatives without the user having to choose the option. I want it fully automated.
This is in a bash script.
Thanks
Below is the code (working correctly now):
#install the jre
sshRetValue=`ssh -p "22" -i $HOME/sshids/idrsa-1.old ${1} " /home/geiser/jms_adapter/jre-6u25-linux-i586.bin "`;
sshRetValue=`echo $?`;
if [ "$sshRetValue" -eq 0 ];then
echo "java jre installed successfully";
#set the alternative and stuff if needed
ssh -p "22" -i $HOME/sshids/idrsa-1.old ${1} " /usr/sbin/alternatives --install /usr/bin/java java /root/jre1.6.0_25/bin/java 2 ";
echo 2 | ssh -p "35903" -i $HOME/sshids/idrsa-1.old ${1} " alternatives --config java ";
else
echo "java jre installation failed";
fi
You can run the alternatives command non-interactively too. Instead of --config, use the --set option to specify the path of the alternative directly.
sudo alternatives --set java /location/of/jdk1.6/bin/java
This worked for me with Java 8:
alternatives --install /usr/bin/java java /usr/lib/jvm/jre1.8.0_60/bin/java 3
alternatives --config java <<< '3'
Generally, you can feed any program that expects something on the standard input like this:
echo -e "line 1\nline 2\nline 3" | program
I did it using this script:
tmp=`mktemp`
echo 2 > $tmp
alternatives --config java < $tmp
rm -f $tmp
The < means that the content of the $tmp file will be passed to the input of the alternatives command.
Edit: You could simply use a single pipe as other suggested:
echo 2 | sudo alternatives --config java
I had couple java versions in my /usr/lib/jvm directory.
My script had to first remove old symlink, create new one and then specify the path of the alternative directly with update-alternatives (i did not manage to make alternatives work without update- prefix) My system - Debian 8.11
My script:
#!/bin/bash
echo "Removing old java 8 symlink.."
sudo unlink /usr/lib/jvm/java
echo "Linking new java.."
sudo ln -s /usr/lib/jvm/new_java /usr/lib/jvm/java
echo "Updating alternatives for java and java compiler"
sudo update-alternatives --set java /usr/lib/jvm/new_java/bin/java
sudo update-alternatives --set javac /usr/lib/jvm/new_java/bin/javac
The documentation says:
If you want to configure non-interactively you can use the --set
option instead (see below).
--set name path
Set the program path as alternative for name. This is
equivalent to --config but is non-interactive and thus
scriptable.
So, to set alacritty as the default terminal, use the following command:
sudo update-alternatives --install /usr/bin/x-terminal-emulator x-terminal-emulator $(which alacritty) 50
sudo update-alternatives --set x-terminal-emulator $(which alacritty)
In your case, use the following command:
sudo alternatives --install /usr/bin/java java $(which java) 70
sudo alternatives --set java $(which java)