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
📰 Linux Scheduler Work Helping Boost Gaming Performance On Old "Potato" Hardware
Prominent Linux kernel engineer Peter Zijlstra of Intel has been working on a set of scheduler patches to help with enhancing the behavior and delivering better results, especially for aging hardware he described as a "potato" -- an Intel Sandy Bridge desktop CPU with AMD Radeon RX 580 Polaris graphics. Benchmark results are promising from this work for gaming on old hardware while other workloads may ultimately stand to benefit too...
🔗 Source: https://www.phoronix.com/news/Linux-Flatten-The-Pick
#amd#intel#kernel#linux
📰 Linux Drivers For The AMD Elan SoCs From The 1990s On Track For Retirement
Merged for the current Linux 7.1 cycle was beginning to phase out the Intel 486 processor support from the mainline kernel moving forward. That initial step with Linux 7.1 was dropping the various Kconfig options to allow compiling Linux kernel builds for targeting various i486 platforms. As part of that, the AMD Elan SoC configuration patches were dropped.
🔗 Source: https://www.phoronix.com/news/AMD-Elan-Linux-Driver-Removal
#amd#intel#kernel#linux
📰Many Wonderful Improvements Expected For Linux 7.1, Especially For AMD & Intel
With Linux 7.0 expected for release later today, in turn the Linux 7.1 merge window will kick off for the two week period of landing all sorts of exciting new features, changes, and removal of old features from the kernel. Here is a look at some of what is on the table for the Linux 7.1 merge window...
🔗 Source: https://www.phoronix.com/news/Linux-7.1-Features-Early-Look
#amd#intel#kernel#linux
📰Reverse Engineering Linux Distro REMnux Marks 15 Years With Major v8 Release Featuring AI Agent Support
Malware analysis Linux distro gets Ubuntu 24.04 base, a new installer, and many new tools.
🔗 Source: https://itsfoss.com/news/remnux-v8-release/
#distro#linux#ubuntu
https://www.linux.com/learn/intro-to-linux/2017/11/5-coolest-linux-terminal-emulators
5 Coolest #Linux Terminal Emulators
Sure, we can get by with boring old GNOME terminal, Konsole, and funny, rickety, old xterm. When you're in the mood to try something new, however, take a look at these five cool and useful Linux terminals.
#Xiki: http://bit.ly/2i8y7Jm
#Cool_Retro_Term: http://bit.ly/1tC7gBP
#Sakura: https://bugs.launchpad.net/sakura
#Terminology: https://www.enlightenment.org/about-terminology
#Tilda: https://github.com/lanoxx/tilda
👩💻101 ta Linux buyruqlari — CheatSheet (Kitob)
Linux terminalini o‘rganmoqchimisiz? Yoki siz allaqachon tajribali foydalanuvchimisiz? Unda quyidagi CheatSheet siz uchun!
Ushbu material yordamida siz quyidagilarni o‘rganasiz:
• Basics;
- File Hierarchy Standard (FHS);
- Commands;
• Disk and File System Management;
- General Disk Manipulation (non-LVM);
- Globs (Wildcards);
- Regex;
- Stream redirection;
• Text Readers & Editors;
- Less;
- VI;
• User and Group Management;
• File System Permissions;
• SSH;
• Cronjobs;
• Package Management;
- RPM;
- YUM;
• List of commands by category:
- Directory Navigation;
- File Commands;
- File and Directory Manipulation;
- Package archive and compression tools;
- System commands;
- Networking Commands;
- Package Management;
- User Information commands;
- Session commands;
- Getting Help;
- Applications.
🔗To‘liq material:
https://github.com/bobbyiliev/101-linux-commands-ebook
📌 Kitob ham yangi boshlovchilar, ham tajribali sysadminlar uchun foydalidir. Har bir bo‘lim aniq misollar bilan yoritilgan.
#Linux#Terminal#Buyruqlar#LinuxCommands#CheatSheet#OpenSource
💻@dasturlash_hayoti — bir xatoni tuzatib, ikkinchisiga tayyorlanish! 😅
📰Running Four Intel Graphics Cards Under Linux On Ubuntu 26.04
It's been nearly one year to the week since Intel introduced Project Battlematrix as their initiative for improving their Linux driver support for the Arc Pro B-Series with enhancements such as bettering the multi-GPU support in allowing up to eight Arc Pro GPUs per system as well as other open-source driver optimizations in the era of AI.
🔗 Source: https://www.phoronix.com/review/intel-arc-pro-b70-four
#intel#linux#opensource#ubuntu
#python#language_models#linux#machine_translation#nlp#open_source#python#transformers#translation
Argos Translate is a free, open-source tool that lets you translate text offline using your own computer. It works as a Python library, command-line tool, or with a graphical interface, and supports many languages. You can install language packages for direct translations, and it can even translate between languages that don’t have a direct package by using a middle language. This means you can translate more language pairs, though the quality might be a little lower. Argos Translate is fast, private, and does not need an internet connection after setup, making it useful for secure or offline translation needs.
https://github.com/argosopentech/argos-translate
📰 Aurora is the KDE side of Bluefin, and it might be the most polished Linux desktop right now
I'm a huge fan of Linux's KDE. It's my favorite desktop environment by far, and sometimes, simply learning that an OS uses KDE is enough of an excuse to give it a try. So, when I heard that the Bluefin distro had a KDE fork called Aurora, I knew I had to give it a try.
🔗 Source: https://www.xda-developers.com/aurora-is-the-kde-side-of-bluefin-and-it-might-be-the-most-polished-linux-desktop-right-now/
#distro#kde#linux