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
Support period lengthened for the 6.6, 6.12, and 6.18 kernels
Linux 内核 6.6、6.12 和 6.18 版本的官方支持周期已延长。
根据内核官网的提交记录,6.6 内核的稳定更新支持将延长至 2027 年底,总计提供四年的支持。6.12 和 6.18 内核的稳定更新支持将延长至 2028 年底,分别提供四年和三年支持。
原文链接:https://lwn.net/Articles/1060271/
#Linux#内核#开源#技术维护
#AIGC
Read more
[$] More efficient removal of pages from the direct map
内核的直接映射(direct map)允许运行在内核模式的代码直接访问系统中安装的所有物理内存——至少在64位系统上是这样。这显然让内核开发者的工作更轻松,但直接映射也带来了一些自身的问题,其中大部分与安全相关。
多年来,人们一直有兴趣从直接映射中移除至少部分内存页。目前正在讨论的几个补丁集展示了从直接映射中移除的内存的一些用例,以及如何高效地管理这类内存。
原文链接:https://lwn.net/Articles/1064090/
#Linux#内核#内存管理#安全
#AIGC
Read more
📰 Steam Beta brings Big Picture Mode tweaks, Linux improvements and Steam Controller fixes
Valve released another new Steam Client Beta update for all platforms on May 13th, bringing with it a few styling changes to Big Picture Mode and various fixes.Read the full article on GamingOnLinux.
🔗 Source: https://www.gamingonlinux.com/2026/05/steam-beta-brings-big-picture-mode-tweaks-linux-improvements-and-steam-controller-fixes/
#linux#steam
📰 This $30 app is the best purchase I've made for my Steam Deck
Linux and Windows don't play nicely with each other, but this app solves that problem.
🔗 Source: https://www.xda-developers.com/this-app-is-the-best-purchase-ive-made-for-my-steam-deck/
#linux#steam
📰 Don't forget to claim your Amazon Prime games for May via Amazon Luna
Have Amazon Prime? You can claim some games to keep via Amazon Luna (formerly Prime Gaming) - here's what you can grab for Linux / SteamOS and Steam Deck.Read the full article on GamingOnLinux.
🔗 Source: https://www.gamingonlinux.com/2026/05/dont-forget-to-claim-your-amazon-prime-games-for-may-via-amazon-luna/
#linux#steam
📰 Steam Survey for April 2026 shows Linux still trending well
With the Steam Hardware & Software Survey for April 2026 now live, we've seen a decrease compared with the all-time high from last month but still a good trend.Read the full article on GamingOnLinux.
🔗 Source: https://www.gamingonlinux.com/2026/05/steam-survey-for-april-2026-shows-linux-still-trending-well/
#linux#steam