How
to play a radio station on the command line and fix the error
"snap-confine has elevated permissions and is not confined but should
be. Refusing to continue to avoid permission escalation attacks".
Today we will cover pyradio, apt install, snap, snapd, apparmor,
and a few different service commands, such as enable the service, then
start the service. To find a package on the computer, to find the PID
number of the package and service and if needed the kill command to stop
it from running in it's tracks. #imisswindows
Pyradio;
Vitux.com writes; Pyradio is a free and open-source command line tool that lets you play your favorite radio stations through the Terminal. It is based on Python and now available on Snap from where you can install it easily.
Open your Ubuntu Terminal either through the Application Launcher search or by using the Ctrl+Alt+T shortcut. Enter the following command in order to refresh the list of available packages:
$ sudo apt update
$ sudo apt full-upgrade
$ sudo apt dist-upgrade
$ sudo apt-get install snapd && snap
$ sudo snap install pyradio
$ pyradio --play
https://vitux.com/three-ways-to-listen-to-radio-via-ubuntu-terminal/
I installed pyradio and I was happy that it worked for me. The next day when I turned on my machine and opened Tilix terminal, and entered the command;
$ pyradio --play
I got an Error Message;
"snap-confine has elevated permissions and is not confined but should be. Refusing to continue to avoid permission escalation attacks"
:Not the actual error message as it happens, just a pic of how I felt.
Google brought back a fix, as the issue is with snap and not the pyradio package.
https://github.com/ubuntu/microk8s/issues/249
Snap seems to have problems from time to time, as you progress with your knowledge and understanding (like me!) we can 'try' and fix the problem without uninstalling the package, but if things fail that's exactly what we will do.
Fix 1.
Install the following package apparmor
$ sudo apt-get install apparmor
$ systemctl enable --now apparmor.service
$ sudo systemctl start apparmor
$ sudo apparmor_parser -r /etc/apparmor.d/*snap-confine*
$ sudo apparmor_parser -r /var/lib/snapd/apparmor/profiles/snap-confine*
$ reboot
After rebooting.
$ pyradio --play
I got Error Message;
snap-update-ns failed with code 1"
Fix 2.
$ sudo snap refresh
$ pyradio --play
Error "cannot change profile for the next exec call: No such file or directory
snap-update-ns failed with code 1"
If this does not fix the issue then try the following command. There are a few different ways to uninstall and install a package in Linux, but they do the same thing in the end, and it's cool to know how to do the same thing using multiple methods. .
$ sudo apt reinstall snap snapd
or
$ sudo apt remove snap && sudo apt remove snapd
or
$ sudo apt remove snap
and when its done, run
$ sudo apt remove snapd
or
$ apt remove snapd|apt install snapd
After rebooting from reinstalling snap and snapd.
I got;
Error "cannot change profile for the next exec call: No such file or directory
snap-update-ns failed with code 1"
GitHub suggested to then do this.
$ systemctl enable --now apparmor.service
$ sudo systemctl enable --now apparmor.service
This command will bring up the password box, and I had to enter my password 3 times, but if you put sudo before the command then it asks you once, I did this for the above enable of the service and it didn't make a difference for getting the app to work.
$ sudo systemctl start apparmor
$ ps -u ranger | grep pyradio
$ ranger 10213 pyradio
$ service snapd force-reload
$ pyradio --play
I got;
Error "cannot change profile for the next exec call: No such file or directorysnap-update-ns failed with code 1"
From the GitHub article one user then suggested that this might solve the problem. But before this can be applied, it was also suggested beforehand to uninstall and reinstall snap, snapd & apparmor, then to apply the commads to enable, start the service. Sometimes I work on a problem all day, only to find out the next day that it works! This happened with NordVPN and why it would not login for me on the command line. Anyways,
I am adding this command.
$ sudo apparmor_parser -r /var/lib/snapd/apparmor/profiles/*
$ pyradio --play
After running the above command on my machine, IT WORKED!!
Pic: A screenshot of pyradio working and the stations available.
I am not going to leave you hanging in case your problem is not solved.
These are the steps I was going to run this command afterwards
$ systemctl enable --now snapd.apparmor.service
but as I am working I won't do it now, as I already enabled a similar service
$ sudo systemctl enable --now apparmor.service
If i have any issues after my next reboot, then I will run the above command with snadp.apparmor.service. If this didn't work then the next step would be below.
The ultimate fix so far would be.
A - Uninstall snap - snapd - apparmor - pyradio using a full removal of the package and all files and scripts associated with them.
B - To reinstall them.
C - To add the commands to enable and start the services, and then adding the three other commands to add the function to the profile to save this from happening. Why did it happen. God knows. Actually, he is the only one who can explain why it works then have a sleep and it doesn't.
D - $ apt purge snap snapd apparmor
How to Remove Directories (Folders)
To remove an empty directory, use either rmdir or rm -d followed by the directory name: rm -d dirname rmdir dirname.
To remove non-empty directories and all the files within them, use the rm command with the -r (recursive) option: rm -r dirname.
Find a process on Linux
$ top
$ htop
$ ps aux | grep apparmor
-
a = show processes for all users
-
u = display the process’s user/owner
-
x = also show processes not attached to a terminal
To kill a process
$ kill SIGNAL PID
The most common kill signals are:
Signal Name |
Single Value |
Effect |
SIGHUP |
1 |
Hangup |
SIGINT |
2 |
Interrupt from keyboard |
SIGKILL |
9 |
Kill signal |
SIGTERM |
15 |
Termination signal |
SIGSTOP |
17, 19, 23 |
Stop the process |
$ kill SIGKILL 13891
Find a file or package pid psid or psgrep
$ ps -u username | grep pyradio
$ ps -u | grep pyradio
$ pgrep radio
$ ps -aux – shows a lot of data
Use these links for research.
https://www.linux.com/training-tutorials/how-kill-process-command-line/
https://docs.oracle.com/cd/E19253-01/817-0403/eoizf/index.html
https://linuxize.com/post/how-to-remove-files-and-directories-using-linux-command-line/
No comments:
Post a Comment