Python + bash
Если вам часто требуется запускать shell команды из Python-кода, какой способ вы используете?
Самый низкоуровневый это функция os.system(), либо os.popen(). Рекомендованный способ это subprocess.call(). Но это всё еще достаточно неудобно.
Советую обратить своё внимание на очень крутую библиотеку sh.
Что она умеет?
🔸 удобный синтаксис вызова команд как функций
# os
import os
os.system("tar cvf demo.tar ~/")
# subprocess
import subprocess
subprocess.call(['tar', 'cvf', 'demo.tar', '~/'])
# sh
import sh
sh.tar('cvf', 'demo.tar', "~/")
🔸 простое создание функции-алиаса для длинной команды
fn = sh.lsof.bake('-i', '-P', '-n')
output = sh.grep(fn(), 'LISTEN')
в этом примере также задействован пайпинг
🔸 удобный вызов команд от sudo
with sh.contrib.sudo:
print(ls("/root"))
Такой запрос спросит пароль. Чтобы это работало нужно соответствующим способом настроить юзера.
А вот вариант с вводом пароля через код.
password = "secret"
sudo = sh.sudo.bake("-S", _in=password+"\n")
print(sudo.ls("/root"))
Это не все фишки. Больше интересных примеров смотрите в документации.
Специально для Windows💀 юзеров
#libs#linux
📰 Further expanded AMD HDMI 2.1 support is coming to Linux now with FRL and DSC
Good news for Linux gamers and the upcoming Steam Machine, as it appears the AMD GPU kernel drivers are expanding their HDMI 2.1 support even further.Read the full article on GamingOnLinux.
🔗 Source: https://www.gamingonlinux.com/2026/05/further-expanded-amd-hdmi-2-1-support-is-coming-to-linux-now-with-frl-and-dsc/
#amd#kernel#linux#steam
📰 Archinstall 4.2 Shifts to Wayland-First Profiles, Leaving X.Org Behind
by George WhittakerThe Arch Linux installer continues evolving alongside the broader Linux desktop ecosystem. With the release of Archinstall 4.2, a notable change has arrived: Wayland is now the default focus for graphical installation profiles, while traditional X.Org-based profiles have been removed or deprioritized.
🔗 Source: https://www.linuxjournal.com/content/archinstall-42-shifts-wayland-first-profiles-leaving-xorg-behind
#arch#linux#wayland
📰 Archinstall 4.2 Shifts to Wayland-First Profiles, Leaving X.Org Behind
by George WhittakerThe Arch Linux installer continues evolving alongside the broader Linux desktop ecosystem. With the release of Archinstall 4.2, a notable change has arrived: Wayland is now the default focus for graphical installation profiles, while traditional X.Org-based profiles have been removed or deprioritized.
🔗 Source: https://www.linuxjournal.com/content/archinstall-42-shifts-wayland-first-profiles-leaving-xorg-behind
#arch#linux#wayland
📰 Flatpak 1.17.7 To Track The Age Of Configurations For Providing Much Better Performance
Flatpak 1.17.7 is now available for continuing to advance open-source app sandboxing and distribution on the Linux desktop. Some interesting new features are in tow with this Flatpak update plus there is also an updated XDG-Desktop-Portal release too...
🔗 Source: https://www.phoronix.com/news/Flatpak-1.17.7-Released
#flatpak#linux#opensource
📰 Arch Linux Users Can Now Upgrade to GNOME 50
GNOME 50 is now available for Arch Linux users, bringing the latest desktop release to systems ready for upgrade.
🔗 Source: https://linuxiac.com/arch-linux-users-can-now-upgrade-to-gnome-50
#linux#arch#gnome
📰 Ubuntu 26.04 LTS Beta Is Out Now with Linux Kernel 7.0 and GNOME 50
Ubuntu 26.04 LTS operating system is now available for public beta testing with the Linux 7.0 kernel, Mesa 26.0 graphics stack, and GNOME 50 desktop environment.
🔗 Source: https://9to5linux.com/ubuntu-26-04-lts-beta-is-out-now-with-linux-kernel-7-0-and-gnome-50
#gnome#ubuntu#linux#kernel
📰CachyOS skipped the Open Gaming Collective, and gamers rewarded it by making it the top Linux distro on Steam
The Open Gaming Collective wants to make Linux gaming better, but CachyOS is proving you can do that just fine with no strings attached.
🔗 Source: https://www.xda-developers.com/cachyos-skipped-open-gaming-initiative-gamers-rewarded-making-top-linux-distro-steam/
#distro#linux#steam
📰 I switched to Linux for unconventional reasons, and now I can't go back
I’ve been a fan of the Linux ecosystem ever since I got a taste of it with the Raspberry Pi OS (or Buster, as it was called back then) on my RPi Zero ages ago. Since then, it has been a fun journey involving distro-hopping shenanigans and virtualization experiments. But unlike most folks, my reasons for going down the slippery slope of Linux flavors were more than just dissatisfaction with Windows and a desire to bring old devices back to life...
🔗 Source: https://www.xda-developers.com/i-switched-to-linux-for-unconventional-reasons/
#distro#linux#raspberry
📰 Don't install another Linux distro until you've tried an immutable one
Sometimes, developers get so engrossed with making the best app possible that some of the basics get left behind. I understand it; if you're doing something amazing and you're going full steam ahead, all the small quality-of-life features seem like minor tweaks compared to all the glorious new tools and features you want to add to your app.
🔗 Source: https://www.xda-developers.com/dont-install-another-linux-distro-until-youve-tried-an-immutable-one/
#linux#steam#distro
📰 Troubleshooting "AppImages require FUSE to run" on Linux
AppImage complained of missing libfuse.so.2 even though fuse2 and fuse3 both were installed. Here's what I did to fix the issue.
🔗 Source: https://feed.itsfoss.com/link/24361/17306359/appimage-fuse-issue
#linux#appimage