output
stringlengths
9
26.3k
input
stringlengths
26
29.8k
instruction
stringlengths
14
159
perf and the kernel are tied fairly closely together, in fact perf is part of the kernel source code. At heart you should think of it as a kernel-specific tool; but packaging practice and requirements in Linux distributions means users end up thinking of it as a “standard” tool. There is no special perf-private interface between perf and the kernel, so the perf-supporting parts of the kernel have to follow the usual userspace-facing rules — i.e. maintain backward-compatibility; so in theory, it would be possible to run an older version of perf with a newer kernel, since the newer kernel is supposed to support whatever interface the older version of perf uses to communicate with it. However, in practice it turns out that if you need to use perf to investigate performance of a workload on a given kernel, you also need to be able to investigate all the performance-affecting features of that particular kernel; an older version of perf can’t support features which were added after it was released, so you would typically end up needing the matching version of perf anyway. As a result of all this, the pragmatic option is to require a version of perf matching the running kernel. Depending on your distribution’s packaging choices, perf may be a front-end which checks for an implementation of perf matching your running kernel, and fails if it can’t find one; or it may be some version of perf itself. I haven’t tested going back too far, but current versions of perf work fine on older kernels, for example perf 5.6.14 and 5.7.7 work fine with a 4.19 kernel.
If you try to run a random perf binary that does not match your currently running Linux kernel, it says: $ perf WARNING: perf not found for kernel 4.13.0-45Of course, if I get the perf for this version, it works. Looking at some popular resources like Linux perf Examples and the Perf wiki I couldn't find the answer for this specific question: why perf strictly needs to be in the same version as the kernel?
Why 'perf' needs to match the exact running Linux kernel version?
I solved this issue by re-installing Intel Parallel Studio XE which configures different performance library that I need. New install also configured libiomp5.so library, which wasn't configured with earlier install. Then adding path to this library in /etc/ld.so.conf and running sudo ldconfig solved the issue. Hopefully, this helps someone.
I was on CentOS 7.3 on x86_64 using perf compiled on the system itself from Kernel 4.13.7 source. It worked without any issue and was able to profile whichever application I wanted to. For some reason, system crashed and I had to re-configure it. I am back on CentOS 7.3 with same kernel as it was before i.e. 3.10. Now, when I downloaded Kernel 4.13.7 and compiled perf, it gives me following error when I try to profile any benchmark. error while loading shared libraries: libiomp5.so: cannot open shared object file: No such file or directoryAs far as I understand, this library belongs to omp or mkl which I don't need for perf and is not present on my system. As per different forums and search, it also seems that this library should come with Intel MKL, which is already configured on my system, but for sure system doesn't have this specific library. To debug more, I have another spare system with RHEL 6.9. On this system too compiling perf as I did for system described above and then profiling same benchmarks gives me same library error. I am clueless as to why this error is coming up now and wasn't there earlier before re-installing the operation system. I have updated the OS with all the latest packages. I don't get this error when I run benchmark standalone (whether CentOS or RHEL) or with numactl, and benchmarks do run-terminate successfully. Any suggestion why this may be happening?
Perf Error While Loading Shared Libraries
This appears to say that CPU is idle for plenty of time. Yes. Namely 87 % of all the time. But it does not mean that the processor does not work on other tasks and processes. 664,852,184,198 cycles:u # 2.604 GHz (50.03%) 19,323,811,463 stalled-cycles-frontend:u # 2.91% frontend cycles idle (50.02%) 578,178,881,331 stalled-cycles-backend:u # 86.96% backend cycles idle (50.02%) 110,595,196,687 instructions:u # 0.17 insn per cycleOptimizing programs to better utilize the CPU and memory accesses it complex task and without any code, it is impossible to answer you in more detail.
I have an application which normally reports (time command reports): real 1.59 user 1.42 sys 4.73But when I load a shared library and run it then the time goes up quite high (time command reports): real 28.51 user 106.22 sys 5.23While a certain level of increase (2 to 4 times is reported on CentOS and Ubuntu -- which is as expected) in run is expected due to my shared library's work, the above timing reported on Fedora 24 is too high. I attempted to use perf which reported: 255352.948615 task-clock:u (msec) # 3.895 CPUs utilized 0 context-switches:u # 0.000 K/sec 0 cpu-migrations:u # 0.000 K/sec 18,127 page-faults:u # 0.071 K/sec 664,852,184,198 cycles:u # 2.604 GHz (50.03%) 19,323,811,463 stalled-cycles-frontend:u # 2.91% frontend cycles idle (50.02%) 578,178,881,331 stalled-cycles-backend:u # 86.96% backend cycles idle (50.02%) 110,595,196,687 instructions:u # 0.17 insn per cycle # 5.23 stalled cycles per insn (50.00%) 28,361,633,658 branches:u # 111.068 M/sec (50.01%) 777,249,031 branch-misses:u # 2.74% of all branches (50.01%) 65.564158710 seconds time elapsedThis appears to say that CPU is idle for plenty of time. But I am trying to find where that happens in the code (I have access to the entire source code both of my application and the shared library in question). I have also seen perf report which reports the time spent in percentages in functions/system calls. But I am interested in even finer level i.e. which line(s) in those functions so that I can understand why. I appreciate it's not easy to provide any concrete advice given that I haven't provided much info on my application/shared library. I am only looking for suggestions/tools/ideas to figure out where the CPU is spending most of its time in the code (or being idle). It's a Fedora 24 Linux/x86_64 with glibc 2.23 (both my application and shared library are compiled with gcc 6.1.1 and glibc 2.23).
Understanding the CPU time spent by process in user/kernel space
You are right. It looks like using the flag -M should do the job. In your example, you used -M IPL, I'm not sure what IPL stands for. If you meant Instruction Level Parallelism, it should be ILP. So try using -M ILP
perf list shows a bunch of what it calls metrics. The list starts off with List of pre-defined events (to be used in -e):Metrics: BAClear_Cost [Average Branch Address Clear Cost (fraction of cycles)] C2_Pkg_Residency [C2 residency percent per package] C3_Core_Residency [C3 residency percent per core] C3_Pkg_Residency [C3 residency percent per package]I'd like to experiment with these but I can't get perf stat to use them. Since the first line says "(to be used in -e)", I tried the following, but it produces an error 103> perf stat -e IPL sleep 10 event syntax error: 'IPL' \___ parser errorThen I found some examples on the internet using -M, but this doesn't work either. 103 > perf stat -M IPL sleep 10 Cannot find metric or group `IPL' Usage: perf stat [<options>] [<command>] -M, --metrics <metric/metric group list> monitor specified metrics or metric groups (separated by ,)Can someone explain how to get perf to use these metrics? Thanks.
how to use metrics with perf stat
It has to do with how they operate. For a regular installation to a flash drive, you're limited by USB bandwidth, so unless you have a good USB 3.0 device, you're stuck at about 20MB/s (which is equivalent to traditional hard drives from around the late '90s). All changes get written to the device too, so you are sharing that USB bandwidth for reads and writes. A Live system however operates somewhat differently. At its core, a Live system consists of a base system image (usually a SquashFS image, as it's good for space efficiency) and an overlay mount on top of that to intercept changes and keep them in RAM. There are two specific ways this is handled:The base system image is loaded into RAM at startup, and everything runs from there afterwards. In this case, you can actually run faster than native speed (because you never access anything slower than RAM), but your startup takes a long time (because you're copying hundreds of MB of data into RAM.The base system image is kept on the flash drive, but certain parts of it get pre-loaded into the cache. In this case, you're not going to be quite as fast as native speed, but because you never write anything to the flash drive, you also almost never drop data from the cache and therefore you are running reasonably fast too.
Running Fedora 26 in a live environment almost feels like native speed to me, but when I install the OS to a thumb drive and boot into it, everything takes forever to startup. Once things start they're generally much faster but it's practically unusable. Is this considered normal?
Why is an OS installed on a USB thumb drive so much slower than a live OS running off the same thumb drive?
Note that the following stopped working for Debian bookworm (reasons below). Here is a way to create a Debian live USB drive with persistence. It will allow to install the missing packages which will from then on be available on every live boot using the persistence. Because we re-create the live ISO image filesystem contents on a read-write capable filesystem, we can change the bootloader configurations to enable persistence and set the keyboard layout on boot. The steps described here were tested to work on Debian stretch and buster and bullseye to create a Debian stretch live image. There are a lot of steps involved, but it seems that this method is still quite efficient. Disclaimer: You will lose the data on the target USB drive and if you mess up the commands below you might feel very sorry afterwards. I am not responsible for your actions. Feeling lucky If you feel particularly lucky today, you can try a bash script automating the process for you. Give it your ISO image path as first parameter and the USB drive block device name as the second. Note that this script is insanely dangerous and that you should not execute it without reading and understanding it first. TL;DR Get Debian live ISO image, install packages (apt install syslinux parted), then do the following: umount /dev/sdX* parted /dev/sdX --script mktable gpt parted /dev/sdX --script mkpart EFI fat16 1MiB 10MiB parted /dev/sdX --script mkpart live fat16 10MiB 4GiB parted /dev/sdX --script mkpart persistence ext4 4GiB 100% parted /dev/sdX --script set 1 msftdata on parted /dev/sdX --script set 2 legacy_boot on parted /dev/sdX --script set 2 msftdata onmkfs.vfat -n EFI /dev/sdX1 mkfs.vfat -n LIVE /dev/sdX2 mkfs.ext4 -F -L persistence /dev/sdX3mkdir /tmp/usb-efi /tmp/usb-live /tmp/usb-persistence /tmp/live-iso mount /dev/sdX1 /tmp/usb-efi mount /dev/sdX2 /tmp/usb-live mount /dev/sdX3 /tmp/usb-persistence mount -oro live.iso /tmp/live-isocp -ar /tmp/live-iso/* /tmp/usb-liveecho "/ union" > /tmp/usb-persistence/persistence.confgrub-install --no-uefi-secure-boot --removable --target=x86_64-efi --boot-directory=/tmp/usb-live/boot/ --efi-directory=/tmp/usb-efi /dev/sdXdd bs=440 count=1 conv=notrunc if=/usr/lib/syslinux/mbr/gptmbr.bin of=/dev/sdX syslinux --install /dev/sdX2mv /tmp/usb-live/isolinux /tmp/usb-live/syslinux mv /tmp/usb-live/syslinux/isolinux.bin /tmp/usb-live/syslinux/syslinux.bin mv /tmp/usb-live/syslinux/isolinux.cfg /tmp/usb-live/syslinux/syslinux.cfgsed --in-place 's#isolinux/splash#syslinux/splash#' /tmp/usb-live/boot/grub/grub.cfgsed --in-place '0,/boot=live/{s/\(boot=live .*\)$/\1 persistence/}' /tmp/usb-live/boot/grub/grub.cfg /tmp/usb-live/syslinux/menu.cfgsed --in-place '0,/boot=live/{s/\(boot=live .*\)$/\1 keyboard-layouts=de locales=en_US.UTF-8,de_DE.UTF-8/}' /tmp/usb-live/boot/grub/grub.cfg /tmp/usb-live/syslinux/menu.cfgumount /tmp/usb-efi /tmp/usb-live /tmp/usb-persistence /tmp/live-iso rmdir /tmp/usb-efi /tmp/usb-live /tmp/usb-persistence /tmp/live-isoIn Detail and with some explanation You will need to execute most of the following commands with elevated privileges, i.e., using sudo on most GNU/Linux systems. Download Download a Debian live ISO image with the window manager of your choice: https://cdimage.debian.org/debian-cd/current-live/amd64/iso-hybrid/ We'll refer to the downloaded ISO image simply as "live.iso". Determine target drive Find the device that is your USB drive using lsblk. We'll call that /dev/sdX. Unmount Unmount existing partitions on your drive using umount /dev/sdX* Create partitions We need an EFI boot partition for UEFI PCs to boot from the USB drive. Then we need a sufficiently large partition to hold the original live ISO filesystem image contents. That partition must have the legacy_boot flag set. Then we add the persistence partition, using up all the remaining space of the USB drive. You can do that with any GPT capable partitioning tool (mind the legacy_boot flag). Here is an example using parted: parted /dev/sdX --script mktable gpt parted /dev/sdX --script mkpart EFI fat16 1MiB 10MiB parted /dev/sdX --script mkpart live fat16 10MiB 4GiB parted /dev/sdX --script mkpart persistence ext4 4GiB 100% parted /dev/sdX --script set 1 msftdata on parted /dev/sdX --script set 2 legacy_boot on parted /dev/sdX --script set 2 msftdata onThis creates a GPT partition table and a protective MBR partition table. Create Filesystems We want FAT on the EFI and live partition and we want ext4 on the persistence parition and we require the label persistence for the persistence feature to work. mkfs.vfat -n EFI /dev/sdX1 mkfs.vfat -n LIVE /dev/sdX2 mkfs.ext4 -F -L persistence /dev/sdX3Mounting the resources We'll need to mount the source ISO and target partitions at temporary mount points. mkdir /tmp/usb-efi /tmp/usb-live /tmp/usb-persistence /tmp/live-iso mount /dev/sdX1 /tmp/usb-efi mount /dev/sdX2 /tmp/usb-live mount /dev/sdX3 /tmp/usb-persistence mount -oro live.iso /tmp/live-isoInstall live system Copy the live ISO filesystem content to the LIVE partition. cp -ar /tmp/live-iso/* /tmp/usb-livepersistence.conf Prepare the persistence filesystem with the required configuration file. The persistence feature will not work without this file. echo "/ union" > /tmp/usb-persistence/persistence.confGrub for UEFI support Install grub2 for UEFI booting support (this requires the grub-efi-amd64-bin package on Debian). We force grub-install to not use UEFI secure boot, which apparently does not work with the --removable option. grub-install --no-uefi-secure-boot --removable --target=x86_64-efi --boot-directory=/tmp/usb-live/boot/ --efi-directory=/tmp/usb-efi /dev/sdXSyslinux for legacy BIOS support Install syslinux gptmbr.bin bootloader to the drive (download syslinux or install package syslinux-common). Then install syslinux to the live partition. dd bs=440 count=1 conv=notrunc if=/usr/lib/syslinux/mbr/gptmbr.bin of=/dev/sdX syslinux --install /dev/sdX2Isolinux fixup Reuse the isolinux config of the original live ISO to work with syslinux. mv /tmp/usb-live/isolinux /tmp/usb-live/syslinux mv /tmp/usb-live/syslinux/isolinux.bin /tmp/usb-live/syslinux/syslinux.bin mv /tmp/usb-live/syslinux/isolinux.cfg /tmp/usb-live/syslinux/syslinux.cfgKernel parameters Now that we copied the live system files to an actual read-write filesystem, we can manipulate the grub and syslinux config. Add the persistence kernel parameter to menu.cfg and grub.cfg. In both files, add the keyword persistence at the end of the respective first line with boot=live in it. sed --in-place '0,/boot=live/{s/\(boot=live .*\)$/\1 persistence/}' /tmp/usb-live/boot/grub/grub.cfg /tmp/usb-live/syslinux/menu.cfgSet the keyboard-layout kernel parameter. In both files, add the keywords at the end of the respective first line with boot=live in it. sed --in-place '0,/boot=live/{s/\(boot=live .*\)$/\1 keyboard-layouts=de locales=en_US.UTF-8,de_DE.UTF-8/}' /tmp/usb-live/boot/grub/grub.cfg /tmp/usb-live/syslinux/menu.cfgGrub splash Fix the grub splash image (optional; we moved it into another directory). sed --in-place 's#isolinux/splash#syslinux/splash#' /tmp/usb-live/boot/grub/grub.cfgUnmounting and Cleanup umount /tmp/usb-efi /tmp/usb-live /tmp/usb-persistence /tmp/live-iso rmdir /tmp/usb-efi /tmp/usb-live /tmp/usb-persistence /tmp/live-isoWhy this should work for both UEFI and BIOS When starting in UEFI mode, the PC will scan the FAT partitions we defined in the GPT partition table. The first FAT partition carries the UEFI grub bootloader, which is found because it is located in the path specified by UEFI for removable drives (the --removable switch to grub-install did this). No UEFI boot entry is necessary for that to work, we only need to make the PC try to boot from the USB drive. That grub is configured to take it from there (load the grub.cfg, show the menu, etc.). When starting in BIOS mode and selecting to boot from the USB drive, the PC will execute the gptmbr.bin bootloader code we have written to the protective MBR of the USB drive. That bootloader looks for the GPT partition marked with the legacy_boot flag and chainload syslinux from that partition. Syslinux then takes over (load menu.cfg, show the menu, etc.). Encrypted Persistence Instead of using plain ext4 on the persistence partition, one could first encrypt the persistence partition with LUKS (using cryptsetup), then format that with ext4 (using the proper label). However, as the documentation says, the live system must include the cryptsetup package. Otherwise, the encrypted partition cannot be decrypted by the live system. This means one has to build a custom live ISO first. That is, however, out of the scope of this answer. History The --no-uefi-secure-boot option was previously not part of the call to grub-install. The stick worked fine for me, but that stopped with Debian buster, even though secure boot is still disabled on my machine. Noted that this approach stopped working for Debian bookworm. Symbolic links were introduced in the ISO image, which cannot be reproduced on the FAT filesystem. When changing the live filesystem to ext*, we need a different bootloader chain. Also, the isolinux boot menu was refactored, which requires adjustments of the sed commands setting the persistence and locale flags.
All of the information I currently find on this matter is insufficient for my taste. It is either outdated, misleading or even wrong, seems overly complicated or not covering this specific question. Goals:bootable USB drive (both UEFI and legacy BIOS supported) (based on) live Debian 9 (stretch), or buster or bullseye persistence (by default and for both UEFI and legacy BIOS) German keyboard layout per default fit for troubleshooting other GNU/Linux systemsReasons:having to setup the keyboard layout on every use is a real headache cryptsetup and efibootmgr are missing in the default Debian live images gnome-terminal has this annoying white background per defaultNo solutions:(re)building custom debian live image (it seems tedious, although I did not try it yet) unetbootin (asks for an unknown password when starting up on debian stretch and I think it does not support UEFI anyways) some foreign automated process where I don't see what is happeningDebian live and install images are isohybrid and can be conveniently written to block devices using dd. And they do work from USB drives like that, which is very nice! However, there will be no persistence and no way to start with a non-english keyboard layout per default without editing the grub and isolinux config, which is included in the very read-only ISO9660 filesystem of the live ISO image. So even after writing the live ISO to a USB drive, these parameters still cannot be changed.
UEFI + BIOS bootable live Debian stretch/buster/bullseye amd64 with persistence
POSIXly, you can do: # save export -p > saved-env...# restore blacklisted () { case $1 in PWD|OLDPWD|SHELL|STORAGE|-*) return 0 ;; *) return 1 ;; esac }eval ' export() { blacklisted "${1%%=*}" || unset -v "${1%%=*}" } '"$(export -p)" export() { blacklisted "${1%%=*}" || command export "$@" } . saved-env unset -f exportNote that for bash not invoked as sh, you'd need to issue a set -o posix for that to work properly. Also with bash versions prior to 4.4, sourcing the output of export -p is potentially unsafe: $env -i 'a;reboot;=1' /bin/bash -o posix -c 'export -p' export OLDPWD export PWD="/" export SHLVL="1" export a;reboot;ksh93 has a similar problem. yash doesn't have that particular one, but still has problems with variable names starting with -: $env -i -- '-p=' yash -c 'export -p' export '-p'='' export OLDPWD export PWD='/'Also beware of potential problems if you're not in the same locale when saving and restoring the variables. bash-4.3$ locale charmap ISO-8859-15 bash-4.3$ export Stéphane=1 bash-4.3$ export -p > a bash-4.3$ LC_ALL=en_GB.UTF-8 bash -c '. ./a' ./a: line 5: export: `Stéphane=1': not a valid identifier
I would like to be able to save my current environment in a file (for a running interactive session), so that I can:Save it, export/modify/delete variables at will in the running session, then restore the saved environment Switch at will between multiple environment Detect differences between two environmentI am only interested in exported variables. As I want to be able to restore the environment it have to be a shell function, I am using bash. Ideally, it would not depends on external programs, and would work on versions of bash from v3.2.25 to current. For now, to save my environment I use the following function: env_save () { export -p > "$STORAGE/$1.sh" }That I use as env_save <filename> in a running session. I have some boilerplate code to keep backups, but let's ignore that. However, I then have difficulties with loading the environment back: env_restore () { source "$STORAGE/$1.sh" }As this would not remove spurious variables that I created in the mean time. That is, calling export -p after env_restore <filename> might not give the same output than cat $STORAGE/$1.sh. Is there a clean way to handle that problem? I will probably need to blacklist some variables such as PWD, OLDPWD, SHELL, SHLVL, USER, SSH_*, STORAGE, etc... That is, those variable should not be saved and should not be changed when restoring as they are special variables. I cannot use a whitelist as I do not know what variables will be there.
How to store / load exported environment variables to / from a file
I eventually used the live-build tools in Debian itself to build a custom image on a separate Debian system. I discovered that using the hdd option to build a binary that consists of separate files (as opposed to an ISO image), and then copying that to the pen drive and setting up Grub legacy on the pen drive, works perfectly. A separate kludge is necessary to boot on UEFI systems. That's what I'm using now.
For the last six years, my main workstation has consisted of a pen drive running the Debian Live images with a persistent partition. The images were simple, brilliant and reliable, and the online web builder for images was perfect for my use. Recently I was looking to update my core system and discovered that Debian Live has undergone an "abrupt end." Both that article and other mails mention alternatives; some imply that live.debian.net is still active, but it just redirects to the main Debian wiki, which in turn only refers to the official CD images. Another article mentions that vmdebootstrap is being updated to be the replacement for live-build and other Debian Live tools, but I can't find any useful documentation on that either. And no one seems to be running a web image builder any more. Can someone point me to alternatives? In an ideal world, there would be some straightforward workflow to produce custom images similar to those that Debian Live used to make possible, and with the kernel options that it supported (some of which are very useful in a persistent USB situation). Is that possible in Debian any more? Can someone point me to a sequence of steps for that?
Alternatives to Debian Live for persistent Debian system on USB
You may want to check Easy2Boot. It's the most versatile and probably also best-documented tool for multiboot things. Specifically, it supports in particularBoot multiple linux ISOs each with separate persistence files[in addition, the author is also pretty helpful and really responsive even for in-depth questions] You could misuse that to reference the same casper-rw file for each of the systems. For more details also see http://www.easy2boot.com/add-payload-files/linux-isos/linux-with-persistence/ and http://www.easy2boot.com/add-payload-files/persistence/ For similar topics, you might want to check the following links:http://www.linuxquestions.org/questions/linux-general-1/yumi-multiboot-linux-persistence-persistent-question-948902/ http://ubuntuforums.org/showthread.php?t=1905449 http://cafeninja.blogspot.de/2012/01/multiboot-liveusb-multiple-iso.html http://forums.fedoraforum.org/showthread.php?t=269841
I'm installing multiple operating systems on a usb drive I recently purchased for this purpose and was wondering how to create a usb drive with multiple persistent OS's that will be linux based and have a capacity > 4gb of the casper-rw file and was wondering 1. if this was possible (I have read from 1 source that it wasnt but it was not one that was overly trustworthy), and 2. how to go about doing it (answers should be aimed at ubuntu being the system I create the drive on)
how to create multiboot usb w/ persistence for multiple OS
In general, you can edit the active iptables rules for IPv4 with a text editor by using the iptables-save command to write the rules to a file and then using the iptables-restore command to reload the new rules after you're done, e.g.: user@host:~$ iptables-save > rules.v4 user@host:~$ vim rules.v4 user@host:~$ iptables-restore rules.v4For IPv6 you would use the analogous commands ip6tables-save and ip6tables-restore, i.e.: user@host:~$ ip6tables-save > rules.v6 user@host:~$ vim rules.v6 user@host:~$ ip6tables-restore rules.v6The iptables-persistent service checks in the following locations: /etc/iptables/rules.v4 /etc/iptables/rules.v6So to apply your rules and have them persist you would follow the same steps as above, but edit the iptables-persistent files instead, e.g.: user@host:~$ iptables-save > /etc/iptables/rules.v4 user@host:~$ vim /etc/iptables/rules.v4 user@host:~$ iptables-restore /etc/iptables/rules.v4I don't know of an interactive command for editing iptables rules like what you're describing, but it should be pretty easy to roll your own. Here is a simple example: #!/usr/bin/env bash# iptables-e.sh# Create a temporary file to store the new rules TEMPFILE=$(mktemp)# Save the current rules to a file iptables-save > "${TEMPFILE}"# Edit the rules interactively with a text editor "${EDITOR}" "${TEMPFILE}" # Try to load the rules and update the persistent rules if no errors occur iptables-restore "${TEMPFILE}" && cat "${TEMPFILE}" > /etc/iptables/rules.v4This actually isn't too much different from how crontab -e works, which just automatically saves the active crontab to a file in the /var/spool/cron/crontabs directory, which is what causes the crontab to be persistent. See the following post for further discussion of this subject:Where is the user crontab stored?You might also be interested in the following script:iptables wizardI can't vouch for it though. I've never used it. It's just the only thing I found by searching for interactive iptables editing.
I've just read about iptables-persistent and I'm completely lost w.r.t. the design. I'm not the only one, who didn't understand how it works, but actually it seems to be way beyond my imagination. I imagined something like crontab -e: You edit a set of rules and they get persisted and applied when the editor gets closed. They get stored somewhere and I as a user have no idea where. Don't tell me; it's perfect this way. Is there such a tool? Why does iptables-persistent work in this hard to follow way?
Persistent iptables
ISO files cannot be mounted and then written to. ISO 9660 is a read-only file system. So you'd need to situate a casper-rw file (it's a single file with a filesystem within too) in a location that's physically on the USB drive. Making a writable filesystem The Pendrive Linux website shows some details on how to go about creating a casper-rw filesystem. The article is titled: Create a larger casper-rw loop file in Linux. NOTE: A casper-rw filesystem is just a regular filesystem that's been tucked inside a single file. In that example they're using a EXT3 filesystem within it. ExampleMake the "casper-rw" image $ dd if=/dev/zero of=casper-rw bs=1M count=1024 1024+0 records in 1024+0 records out 1073741824 bytes (1.1 GB) copied, 10.958 s, 98.0 MB/s$ ls -l casper-rw -rw-rw-r--. 1 saml saml 1073741824 Apr 2 19:56 casper-rwFormat it as EXT3 $ mkfs.ext3 -F casper-rw mke2fs 1.42.7 (21-Jan-2013) Discarding device blocks: done Filesystem label= OS type: Linux Block size=4096 (log=2) Fragment size=4096 (log=2) Stride=0 blocks, Stripe width=0 blocks 65536 inodes, 262144 blocks 13107 blocks (5.00%) reserved for the super user First data block=0 Maximum filesystem blocks=268435456 8 block groups 32768 blocks per group, 32768 fragments per group 8192 inodes per group Superblock backups stored on blocks: 32768, 98304, 163840, 229376Allocating group tables: done Writing inode tables: done Creating journal (8192 blocks): done Writing superblocks and filesystem accounting information: doneMount it $ sudo mount -o loop casper-rw /mnt/Check it out $ ls /mnt/ lost+found$ df -h /mnt/ Filesystem Size Used Avail Use% Mounted on /dev/loop0 976M 1.3M 924M 1% /mnt
I have my USB stick setup using Easy2Boot. It allows me to drop ISO files onto the USB drive and boot from there no config or tweaking needed. I have been doing research on making it persistent. I have found that you can use a file or a partition called casper-rw. It has info on how to use the file, but my question is. Can you have the casper-rw file directly in the root of the bootable ISO or does it need to go into a special folder on the ISO? For that matter can I even have the file in the ISO or do I need to have it directly on the USB drive?
How to use casper-rw file for persistence
The Arch Wiki page on CPU frequency scaling suggests a couple of different ways to make changes performed in cpupower persistent.One of those, as you mentioned, is adding a kernel module. But there are other simpler options that should be easier. The simpler is just to enable cpufreq's systemd service, as suggested in the Arch Wiki. Just runsudo systemctl enable cpupower and the service will be started every time you boot up the machine. I am not running in a machine with systemd right now, so I cannot perform any tests.The second option is to add a udev rule. I've tested this one right now and it works perfectly. Just edit the file named /etc/udev/rules.d/50-scaling-governor.rules or similar (create it if it does not exist) and add the following content to it:SUBSYSTEM=="module", ACTION=="add", KERNEL=="acpi_cpufreq", RUN+="/bin/sh -c 'echo 2000000 | tee /sys/devices/system/cpu/cpu0/cpufreq/scaling_max_freq'" This will change the maximum frequency of CPU0 to the value written. In your case, 2000000, or 2.0 GHz. To do the same for every CPU in your machine, just change the previous command to SUBSYSTEM=="module", ACTION=="add", KERNEL=="acpi_cpufreq", RUN+="/bin/sh -c 'echo 2000000 | tee /sys/devices/system/cpu/cpu*[0-9]/cpufreq/scaling_max_freq'" and this will change the maximum frequency for every CPU in your system.
I have been fiddling with power management and I can't find a way to make the changes I want persistent. For example, I have set the maximum cpu frequency with this command: sudo cpupower frequency-set --max 2GHzbut the value goes back to its original value on every reboot. Is there a standard way to make this change persistent? I have read about kernel modules but I don't know how they work... can anyone help me? Note. My machine is running Ubuntu 20.04.
Making cpupower changes persistent
There is a difference between the data in the first block of a persistent vs transient dmsetup snapshot device: Given these devices: $ losetup NAME SIZELIMIT OFFSET AUTOCLEAR RO BACK-FILE DIO /dev/loop1 0 0 0 0 /home/var/ravi/tmp/issue/snap-dev 0 /dev/loop0 0 0 0 0 /home/var/ravi/tmp/issue/base-dev 0And an initially zeroed-out snapshot device backing file: $ od -xc snap-dev 0000000 0000 0000 0000 0000 0000 0000 0000 0000 \0 \0 \0 \0 \0 \0 \0 \0 \0 \0 \0 \0 \0 \0 \0 \0 * 3751613000Here's what happens when using the non-persistent N flag: $ sudo dmsetup -v create snapdev --table '0 8 snapshot /dev/loop0 /dev/loop1 N 1' Name: snapdev State: ACTIVE Read Ahead: 256 Tables present: LIVE Open count: 0 Event number: 0 Major, minor: 254, 5 Number of targets: 1$ od -xc snap-dev 0000000 0000 0000 0000 0000 0000 0000 0000 0000 \0 \0 \0 \0 \0 \0 \0 \0 \0 \0 \0 \0 \0 \0 \0 \0 * 3751613000Note that the backing file is unchanged - it's all still \0 bytes. Now, trying again with the P flag for persistence: $ sudo dmsetup remove snapdev $ sudo dmsetup -v create snapdev --table '0 8 snapshot /dev/loop0 /dev/loop1 P 1' Name: snapdev State: ACTIVE Read Ahead: 256 Tables present: LIVE Open count: 0 Event number: 0 Major, minor: 254, 5 Number of targets: 1$ od -xc snap-dev 0000000 6e53 7041 0001 0000 0001 0000 0001 0000 S n A p 001 \0 \0 \0 001 \0 \0 \0 001 \0 \0 \0 0000020 0000 0000 0000 0000 0000 0000 0000 0000 \0 \0 \0 \0 \0 \0 \0 \0 \0 \0 \0 \0 \0 \0 \0 \0 * 3751613000In this case, the first bytes of the device are SnAp\001.My guess is that persistent data is stored in the first block or blocks of the snapshot device itself.
The dmsetup snapshot documentation says:<persistent?> is P (Persistent) or N (Not persistent - will not survive after reboot). O (Overflow) can be added as a persistent store option to allow userspace to advertise its support for seeing "Overflow" in the snapshot status. So supported store types are "P", "PO" and "N".The difference between persistent and transient is with transient snapshots less metadata must be saved on disk - they can be kept in memory by the kernel.Where is this persistent data stored?
dmsetup: Where is persistent metadata stored?
Save output to local file, then rsync --partial --append on that file to keep pushing it up to the server?
I'm on a laptop with intermittent internet connectivity. (i.e. I sometimes don't have network for a week.) I want the output of a process on my laptop to end up on my server. It all needs to get there, eventually, through SSH, and without me having to think about it. How can I do this?Test-case # print current date to FIFO every second while true; do sleep 1; date; done > magic-fifoLeave that running, disconnect from the internet for a week (or sufficiently long to be convincing), then reconnect. All data should be sent immediately while connected, but buffered until reconnection whenever not. An attempt mkfifo magic-fifocat magic-fifo \ | pv --buffer-size 1g --buffer-percent \ | AUTOSSH_POLL=10 AUTOSSH_PORT=50000 autossh user 'cat >> log'pv is just here to buffer up to 1 GiB of data, in case a week's data fills the kernel pipe buffer. autossh wraps ssh and keeps it running by killing/resurrecting it if the network is down. This drops some data at disconnect, but works otherwise. I presume the reason for data loss is that ssh reads it, realises it cannot send it, then gets killed by autossh.I don't necessarily expect the data to persist across reboots, though that would be a nice bonus.
How do I ensure all data to an SSH pipe is sent, despite lengthy disconnects?
Get a faster USB 3 pendrive, or maybe even a USB SSD :-) You can easily improve reading from the image of the iso file (after a slow start), put all the content of the squash file system into RAM with the boot option toram, but I don't think it is easy or meaningful to do that with the content of the file/partition for persistence. See this link for more details.The following screenshot of the grub menu of a persistent live system made by mkusb is from Ubuntu, but looks very similar for Debian. There is already a menuentry for toram.
I created a persistent Debian 9 live usb. The persistence is configured with / union. An unexpected consequence, although obvious in hindsight, is the system lags on non-cached reads: holmes@bakerst:~$ # WRITE to disk holmes@bakerst:~$ dd if=/dev/zero of=tempfile bs=1M count=1024; sync 1024+0 records in 1024+0 records out 1073741824 bytes (1.1 GB, 1.0 GiB) copied, 0.417477 s, 2.6 GB/sholmes@bakerst:~$ # READ from buffer holmes@bakerst:~$ dd if=tempfile of=/dev/null bs=1M count=1024 1024+0 records in 1024+0 records out 1073741824 bytes (1.1 GB, 1.0 GiB) copied, 0.0907808 s, 11.8 GB/sholmes@bakerst:~$ # Clear cache, non-cached READ speed holmes@bakerst:~$ sudo /sbin/sysctl -w vm.drop_caches=3 vm.drop_caches = 3 holmes@bakerst:~$ dd if=tempfile of=/dev/null bs=1M count=1024 1024+0 records in 1024+0 records out 1073741824 bytes (1.1 GB, 1.0 GiB) copied, 15.3935 s, 69.8 MB/sThere is a 169X difference between cached and non-cached read operations! What can I do, if anything, to improve performance?
Speed up persistent live usb disk operations
If you did it correctly then all your changes are in your $HOME. Just copy that $HOME folder around and your done. If you don't want to copy the entire folder then ~/.local/config is a good place to start, but your better off just copying over the entire folder.
I'm wondering how I can persist my perfect configured desktop system. I have - installed a fresh new debian - installed all my applications and tools I need (from vim to eclipse) - override my systems bashrc/-.profile etc - installed and configured my wm (fluxbox and themes) So now this was a lot of work and Im looking for a way to "save" /export that state. I want to be able to recover my system after a reinstall or dublicate it (in case of using it in VMs). I was thinking of exporting the list of installed packages as well as some dot-files but im not sure, that this is the best choice. What would you recomend?
Save a perfect configured desktop
Consolidating comments into an answer Based on comments from @dirkt and @berndbausch, it seems like the bottomline is: There is no tc-specific way of persisting rules that are put in place using tc. The specifics of how to do so the Right Way will vary depending on your distro, but it will come down to re-running the tc commands as part of some file at boot time (for example, /etc/network/interfaces).
I am trying to determine whether rules put in place using tc persist beyond a reboot (I do not believe they do by default), and whether there is any way to cause them to persist, or if the best you can do is to re-execute the commands at boot in order to put them in place again. Also: how/where do these rules get persisted? (assuming there is in fact a way to do so)
Can TC rules persist beyond a reboot? Where?
You can use crontab. Crontab can start a process every minute, the process should check if it is already running and exit if it is. http://linux.die.net/man/1/crontab
I have a virtual server running Ubuntu 14.04 LTS x64 and I want to create a persistent process that restarts with the system and when it crashes. To do that, I've added the following lines to the "inittab" in the etc-directory: test:5:respawn:echo "HELLO TEST" > /test.log sometestname:234:/var/path/to/process/myprocessAfter running "init q" or "telinit q", nothing happens. The test.log file isn't created, the process isn't started (It's not listed when using pstree) and there's nothing in the syslog either. Restarting the server also doesn't help. I've also tried to use systemd to create a new service, by creating a new "myprocess.service" in "/etc/systemd/system/" with these commands: [Unit] Description=Process Name[Service] ExecStart=/var/path/to/process/myprocess Restart=restart-always[Install] WantedBy=multi-user.targetAgain, after a server restart the process isn't there. Are there any other ways to create a persistent process in Ubuntu? Also, the process acts as a server, but can also accept user inputs. Since it'll run as a background process most of the time, is it possible to "attach" it to the main console at whim to run some commands, and detach it later on? I'm using putty for remote access to the server.
Create persistent process without inittab
The solution I got working was in fact to us fstab, but the important bit is using aufs, as explained here. Final fstab looks like # <file system> <mount point> <type> <options> <dump> <pass> /lib/live/mount/medium/home.img /mnt/homeRO ext4 ro,auto 0 0 none /mnt/ramFS tmpfs size=50M 0 0 none /home aufs br:/mnt/ramFS:/mnt/homeRO=ro 0 0Unsure if it would be better to put the tmpfs in /tmp or in /run/shm or something, but it's running and I don't care.
I have a working liveboot usb, with persistence. It has two partitions, one being the actual os, the other containing an image file that is the persistence. The desired result is a live usb with one partition, and in the root of that partition is an image that is mounted read only to /home. This is so I can easily swap out configs in /home/user, without having to run lb build each time, and then dd it to each flash drive. I've spent a bit of time trying to get it working with persistence, but there are two problems. Firstly, when booting, live debian seems to not check for a persistence file in the root of the live medium. Furthermore, I can't get it to do persistence read only. I had been trying with the persistent-read-only boot flag. Couldn't find much documentation on it, but it's mentioned here. Does not work, however. At this point, I'm pretty sure persistence is not the correct way to go, and the better option would be some kind of boot script to mount an image to /home. This is theoretically simple enough, as the root of the medium is always at /lib/live/mount/medium, but I'm unsure of the correct way to go about actually mounting an image. The two options as I see them are:a boot script If I were to try to use init.d, it needs you to run update-rc.d, which I can't do here silly option would be to put a script in /etc/skel/.bashrc or whatever, and have it rm everything in /home and then mount the image, but that's a wee bit horrifying. Live-Build startup scripts are only mentioned here , which is extremely outdated, and obviously useless. This looks to have been replaced by boot hooks, but I don't have /lib/live/config/ to examine, and I'm going to wait on a suggestion for the proper method before attempting to follow up on thisfstabUnsure if using fstab to mount an image to /home would happen before or after live debian creates a new user from /etc/skel, as trying to mount to a populated directory isn't going to work.So either how do I get a boot script to run in a not horrifying way, or would just copying the fstab from a running live version, modifying it to have an image, and putting that in config/includes.chroot/ect/fstab work? UPDATE: So I tried using fstab, and it was mounted read only, and then I couldn't login on the gui portion of the system as it couldn't lock .Xauthority. Unsure how to proceed, I think it will be learning how the live system can pretend to accept changes, and then not write them and do that. Unsure how to do that or word the query, however.
Debian live-build mounting /home
I found myself a solution for this. Tiny Core Linux has a different persistence style, the kernel and the root fs are always load from the default safe version, all the changes have to be applied in other way. In this way, I found a script in /mnt/vda1/opt/bootlocal.sh that suggests adding other system startup commands there, so, I liked a copy of my script in /home/tc/. The original content of the file: #!/bin/sh # put other system startup commands hereSo, I just added my script call below: #!/bin/sh # put other system startup commands here sh /home/tc/script_name.shSo, from there the right commands or script calls can be added. This scripts better should be saved in /home or in that same /mnt/vda/opt directories
I need a very lightweight, and I found Tiny Core Linux, which I installed following this guide, but I have several problems, related to adding SysVinit (in which is based) startup scripts:Anything I write in /etc/init.d/ is lost after reboot There are no /etc/rcX.d/ directories for the different runlevels. I tried to avoid the 2nd problem calling my scripts at the end of the ones in /etc/init.d/, but because of the 1st problem, everything is lost when restarting.After this, I checked the mounted devices, and the disk I selected to install, /dev/vda1, is mounted in /mnt/vda1, /home and /opt, and / corresponds to a rootfs: rootfs on / type rootfs (rw,size=460176k,nr_inodes=163912)Before these tests, I had tried other install ways instead of Frugal, like USB-HDD, but similar results, so, I think I am not understanding well how to work with this distro.
Tiny Core: startup script and persistence
It seems you need named pipes: https://askubuntu.com/questions/449132/why-use-a-named-pipe-instead-of-a-file Basically, you create a named pipe, run the process which gets input from the named pipe, and then pass whatever you want TO the named pipe for it to be processed by the process. For example: mkfifo /tmp/namedpipe tail -f /tmp/namedpipe & echo "BOO"> /tmp/namedpipe echo "this" > /tmp/namedpipe... This will echo (by tail) to stdout everything that is sent to the /tmp/namedpipe. I use tail instead of cat, because cat will exit the process when it receives EOF. UPD. Clarification. To pass this to your process you need to do something like this: tail -f /tmp/namedpipe | yourprocess &UP2. So in your case the sequence would be like this: mkfifo /tmp/namedpipe --- this will be the entry point through which you can send data to your process. tail -f /tmp/namedpipe | /usr/lib/w3m/w3mimgdisplay &-- this will then create the persistent process that you want, and will in future feed to it antyhing you send through the pipe. echo -e '0;1;0;0;0;0;0;0;0;0;file.png\n4;\n3;' > /tmp/namedpipeShould show you the image on the screen. From now on, any further things that you will send to /tmp/namedpipe will be like new lines echoed to the command and should likewise appear on the screen.
Say you run an executable file in this way: $ echo <params> | <process>If process is not run as a pipe, then you type $ process & and it will stay running. What is needed in the command line above to launch process persistently? Update: More precisely, w3mimgdisplay can be run as a persistent process, that's how w3m keeps the images displayed on a terminal after scrolling. How can this program be run in such a way from the command line? echo -e '0;1;0;0;0;0;0;0;0;0;file.png\n4;\n3;' | /usr/lib/w3m/w3mimgdisplay
How to launch a pipe as a persistent process
You can use systemd Create a file for example /etc/systemd/system/yourapplication.service [Unit] Description=Your Super application After=network-online.target Wants=network-online.target systemd-networkd-wait-online.serviceStartLimitIntervalSec=500 StartLimitBurst=5[Service] Restart=on-failure RestartSec=5sExecStart=/path/to/application[Install] WantedBy=multi-user.targetOr the oldy way is to launch your application using init. Add to init script a line ap:2345:respawn:/bin/sh /somewhere/start-appWith ap the id of your service (max 2 letters) 2345 Lists the run levels to which this entry applies.2 Multi-User Mode Does not configure network interfaces or start daemons. 3 Multi-User Mode with Networking Starts the system normally. 4 Undefined Not used/User-definable 5 X11 As runlevel 3 + display manager(X)respawn for the action then the command to run
For my particular use case, I liked to use docker-compose up to provide retry logic for a couple of apps. When shifting gears and pivoting to easy to use CDN infrastructure, it seems as if running shell commands to start everything up in a single docker container will be simpler. However, the only thing I have found that corresponds to anything like "always up" logic is: while true; do start-app || sleep 1; doneWhat I was curious about was if there is truly some sort of Unix/BASH 'retry' tool that will make sure a command is always running in addition to whatever the useful features there are for that kind of system-level operation?
BASH/Linux: Always Up or Retry a command?
Check out the Debian Live manual, especially the Using the space left on a USB stick and the Persistence sections, which explain creating a new partition and using it for persistence. Above links for the stable version in English, other combinations are also available from the project page (now redirect to the new homepage). Main points:a special boot parameter to be specified at boot time: persistence the volume label for overlays must be persistence but it will be ignored unless it contains in its root a file named persistence.conf to make /home persistent, persistence.conf could simply contain: /homeneither /lib, /lib/live (or any of their sub-directories) nor / can be made persistent using custom mounts. As a workaround for this limitation you can add / union to your persistence.conf file to achieve full persistence.
I have installed Debian Live onto a USB drive and am wondering how to now create a persistence so that updates and other file are not wiped at reboot. I have looked at How to create a Debian Live USB with persistence, but it is talking about Debian on Linux. I install Debian with the Universal USB Installer
Debian create live persistence through Windows
A little longer answer ... Yes, you can loop mount the file for persistence, when the pendrive is connected to another Linux system. But Windows refuses to 'see' Linux file systems (there is probably an ext2, ext3 or ext4 file system). sudo mkdir /mnt/lp1 # do this only once in your other Linux systemsudo mount -o loop /path/to/casper-rw /mnt/lp1 # loop mountReplace /path/to with the real path in your other Linux system. Now you can access the files in your file for persistence via the mountpoint /mnt/lp1via command line or via a file browser.Anyway, have a look atmkusb in Linux Mint, Ubuntu or Debian, Rufus in Windows,that can create a partition for persistence: There is no size limit except the size of the pendrive (or SSD). mkusb can also create an NTFS 'usbdata' partition alongside the partition for persistence, and this 'usbdata' partition has read/write access from both Linux and Windows.Please tell me if you have another Linux system, or if you need access from Windows, or if there is some other problems, and I can add details to this answer.
I have installed Linux Mint on USB pendrive with universal usb installer. I have also specified size of the file for persistance during installation. Is it possible to access data stored on this file without running the system?
How to access persistent data from Linux installation on USB pendrive?
Original advice You can use mkusb to create a persistent live drive from the current Debian live iso files.mkusb-dus and select 'dus-persistent' This 'classic mkusb' method creates partition table and several partitions. See details at this link and that link.mkusb-plug and select 'persistent' (or in mkusb-sedd '--pder') This method 'semi-clones' the iso file using sed to get the boot option persistent into the otherwise cloned content from the iso file to the target device. In addition to that the remaining part of the drive 'behind' the copy of the iso file will be formatted into a file system that will provide persistence.It should be straight-forward. mkusb-dus works both in graphical mode and text mode. mkusb-plug works only in graphical mode, but you can use mkusb-sedd 'manually' in text mode and get the same result, because mkusb-plug is a graphical front end of mkusb-sedd. See details at this link. Advice modified after discussion with the OP After a discussion (in comments) I suggest the following method to create a persistent live Lubuntu system in a drive with Ubuntu Server. (You may prefer another Ubuntu flavour, all current official Ubuntu desktop systems and community flavours should work here.)I created an Ubuntu Server 22.04 LTS by extracting jammy-preinstalled-server-amd64.img.xz and cloning it to an SSD. It is convenient with mkusb.I booted into Ubuntu Server and checked that it works correctly. The user name is 'ubuntu'. In this process I also changed password from 'ubuntu' to something else. The server expanded its root partition automatically to use the whole drive.I see no good way to use a file for persistence, instead I suggest to boot from another drive and use gparted to shrink the root partition of Ubuntu Server (by moving its tail end), and in the unallocated space created, create a new partition with the ext4 file system and label it writable.You can see a padlock symbol for /dev/sdc1. It indicates that the partition is mounted, and you must unmount it before you can shrink it.Then boot into the Ubuntu Server and create a directory Live in the home directory: /home/ubuntu/LiveGet lubuntu-22.04-desktop-amd64.iso for example via sftp into this directory.create a menuentry for the persistent live system sudo nano /etc/grub.d/40_customand make it look something like the following #!/bin/sh exec tail -n +3 $0 # This file provides an easy way to add custom menu entries. Simply type the # menu entries you want to add after this comment. Be careful not to change # the 'exec tail' line above. # menuentry "Lubuntu 22.04 ISO" { set isofile="/home/ubuntu/Live/lubuntu-22.04-desktop-amd64.iso" # or set isofile="/<username>/Live/lubuntu-22.04-desktop-amd64.iso" # if you use a single partition for your $HOME rmmod tpm search --set=root --fs-uuid cc633893-7fde-4185-b852-7b886f51ff7f loopback loop ($root)/$isofile linux (loop)/casper/vmlinuz boot=casper iso-scan/filename=$isofile noprompt noeject persistent initrd (loop)/casper/initrd } set timeout_style=menu set timeout=10Please notice thatI use the UUID of the root partition of Ubuntu Server cc633... in order to identify the target device in a reliable way. You can find this UUID via lsblk -o name,size,uuidyou should modify this UUID to match your particular system.persistent is added to the 'standard' live linux command line.The two last lines provide a 'hard' way to make the grub menu be displayed.These edits of /etc/grub.d/40_custom will be activated by running sudo update-gruband you should notice it the next time you boot (or reboot).
I want to make a persistent live boot in which I can store my data on a debian iso booted from a hard drive. So I downloaded debian-live (here), modified the grub entry to be able to boot into the live-system:` menuentry "Debian modified" { set iso_path="/live-boot/debian-live.iso" export iso_path loopback loop $iso_path set root=(loop) set loopback="findiso=${iso_path}" export loopback linux /live/vmlinuz-5.10.0-13-amd64 boot=live persistence components keyboard-layouts=de splash verbose "$loopback" initrd /live/initrd.img-5.10.0-13-amd64 }I can boot into my live system but when I want to store data in it, after a reboot the data is lost. Am I doing something wrong in the grub entry here? Here could be also useful information for you, df -ha on the live boot gives me the following output (shortened to relevant parts): FS Size Used Avail Use Mounted on /dev/sda1 ... ... ... ... /run/live/persistence/sda1 <= my main partition (also from where the boot is happening) /dev/loop0 .. ... ... ... /run/live/medium /dev/loop1 .. ... ... ... /run/live/rootfs/filesystem.squashfs tmpfs ... ... ... ... /run/live/overlay overlay ... ... ... ... / tmpfs ... ... ... ... /usr/lib/live/mount /dev/loop0 .. ... ... ... /usr/lib/live/mount/medium /dev/loop1 .. ... ... ... /usr/lib/live/mount/rootfs/filesystem.squashfs /dev/sda1 .. ... ... ... /usr/lib/live/mount/persistence/sda1 tmpfs ... ... ... ... /usr/lib/live/mount/overlayand the fstab on the live boot gives me the following output: overlay / overlay rw 0 0 tmpfs /tmp tmpfs nosuid,nodev 0 0The mount | grep overlay returns: tmpfs on run/live/overlay type tmpfs (rw,noatime,mode=755) overlay on / type overlay (rw,noatime,lowerdir=/run/live/rootfs/filesystem.squashfs/,upperdir=/run/live/overlay/rw,workdir=/run/live/overlay/work) tmpfs on /usr/lib/live/mount/overlay type tmpfs (rw,noatime,mode=755)I also manually tried to mount the overlay directly to the persistent partition (sda1) with the persistent storage as upperdir / workdir which results in overlay on / type overlay (rw,noatime,lowerdir=/run/live/rootfs/filesystem.squashfs/,upperdir=/run/live/persitence/sda1/rw,workdir=/run/live/persistence/sda1/workof course, I created those directories there on the persistent partition ;-) ... but it is still not working to store data persistently and I don't know what to do. So how can I modify this all to be able to store data on the live-iso and when rebooting without losing the data stored?
Persistent Debian Live HDD
The Pro Audio profile provides "raw device access with the maximum number of channels and no mixer controls" (from the release notes with the feature). Based on the code creating this profile, it looks like it adds direct mappings from each PCM device provided by ALSA to a corresponding input or output channel in PipeWire. This is in contrast with higher-level options such as the ALSA Use Case Manager, which would associate some of these channels to particular combinations of device type and verb (e.g. "Mic" and "Voice Call", respectively). The main reason someone might want to use the Pro Audio profile is to access all the channels of interfaces with more than a single stereo input/output; for example, a USB mixer with 8 channels, which may not all be usable through the default profile. By using Pro Audio, these extra channels could be connected to various other applications with PipeWire's graph architecture. Here's an additional source describing the use of PipeWire for professional audio work, showing that not all channels are available by default. As of 2022, there is now a FAQ entry on the PipeWire wiki on this topic.
After upgrading from PulseAudio to PipeWire my sound devices now feature the "Pro Audio" profile however I've Googled for it and haven't found anything interesting. You can find it by running PulseAudio Volume Control and see it under the Configuration tab for your devices. Would be nice if someone could, I don't know, glance over PipeWire sources (I'm not a C programmer per se and I don't really understand digital audio aside from the very basics) and explain what it is and why the user may want to use it instead of e.g. something which is offered by default.
The "Pro Audio" profile in PipeWire for audio devices / sound cards
The relevant configuration file is /usr/share/wireplumber/main.lua.d/50-alsa-config.lua, but don't edit the system version of it! You need to copy it into /etc/wireplumber/main.lua.d/ (global config) or ~/.config/wireplumber/main.lua.d/ (user config) and make the necessary changes. The easiest way is to copy it into the global config location so that it applies to all user accounts: sudo cp -a /usr/share/wireplumber/main.lua.d/50-alsa-config.lua /etc/wireplumber/main.lua.d/50-alsa-config.lua sudo nano /etc/wireplumber/main.lua.d/50-alsa-config.luaYou then need to scroll down to the bottom of the file, inside the apply_properties section, and add a line there which says: ["session.suspend-timeout-seconds"] = 0I've done a lot more changes and customized it for my own personal hardware. Here's my configuration for reference, but this config is only useful for my exact devices. You actually only need the line above to disable the auto-suspend. Add it to your own default config. Do not copy my config. The other changes I've made are unrelated. alsa_monitor.properties = { ["alsa.jack-device"] = true, ["alsa.reserve"] = true, ["alsa.midi.monitoring"] = true }alsa_monitor.rules = { { matches = { { { "device.name", "matches", "alsa_card.*" } } }, apply_properties = { ["api.alsa.use-acp"] = true, ["api.acp.auto-profile"] = false, ["api.acp.auto-port"] = false } }, { matches = { { { "node.name", "matches", "alsa_output.pci-0000_0c_00.4.iec958-ac3-surround-51" } } }, apply_properties = { ["api.alsa.period-size"] = 128, ["api.alsa.headroom"] = 2048, ["session.suspend-timeout-seconds"] = 0 } }, { matches = { { { "node.name", "matches", "alsa_input.usb-BEHRINGER_UMC202HD_192k-00.analog-mono" } } }, apply_properties = { ["api.alsa.period-size"] = 128 } } }Setting the session.suspend-timeout-seconds property to 0 prevents the suspension/sleep behavior. It completely disables the behavior, as can be seen in WirePlumber's source code. WirePlumber has to be restarted in order for changes to take effect: systemctl --user restart wireplumber
In Fedora 35, WirePlumber has replaced pipewire-media-session as the audio session manager. There is a highly annoying problem with audio on many built-in soundcards on Linux where the audio sink is suspended after nothing is played for 3 seconds. Upon resuming playback after 3 seconds have passed, audio is delayed or pops in. How do we fix this default behavior?
How do I disable audio sink suspend on idle using WirePlumber in Fedora 35 so that audio isn't delayed when starting playback?
I had the same issue but found this thread, and switched to pw-play. I realized something like this snippet works as expected: pw-play --volume=0.5 ~/soundfiles/notification.wav
I recently installed Fedora 36. I have a script that plays certain sound files. The script was used under Ubuntu 20.04 before, showing the expected behaviour. Inside the script, I use the following command: paplay --volume=65536 -d alsa_output.pci-0000_33_00.6.HiFi__hw_Generic_1__sink ~/soundfiles/notification.wavOn Ubuntu, this led to the notification being played on maximum volume due to the --volume=65536 setting, but since I switched to Fedora, this setting is no longer having any effect. No matter what value I give (even lower ones), the notification sound will always play with the current default system volume. I tried with canberra-gtk-play, but that shows the same behaviour: no matter if I try canberra-gtk-play -f ~/soundfiles/notification.wav --volume=5 or canberra-gtk-play -f ~/soundfiles/notification.wav --volume=10, the sound will always play on the default system volume level. Anybody got any idea why that might be?
paplay: --volume option does not take effect
Experienced the same issue. Was able to resolve it thanks to this reddit forum. The issue is related to the AAC codecs, which aren't included in PipeWire by default due to licensing issues which prevented the owners from actually compiling the implementation, even though it is still in the official repository. You can either (1) install this package, which is a re-compilation of PipeWire's dependency to include the AAC (and aptX) codecs (more info here), however this may involve tampering with existing OS installations. Alternatively, you can (2) install the libfdk-aac-dev library and download the precompiled binary dependency of the said package, extract it and all its sub-compressions, and place /.../libspa-0.2-bluetooth_0.3.65-4~glasgall1_amd64/usr/lib/x86_64-linux-gnu/spa-0.2/bluez5/libspa-codec-bluez5-aac.so in /usr/lib/x86_64-linux-gnu/spa-0.2/bluez5/. Then, just give the computer a good ole' reboot. After either method you should be able to pick the AAC codec: P.S.: Or you can (3) rebuild libspa from scratch yourself with the AAC codec if you're up for the challenge, though I do not recommend. :)
I'm currently trying to move from Ubuntu 22.04.2 LTS to Debian 12, and everything is so much more stable and reliable here. But there is one problem: My Airpods Pro (Generation 2) don't really work. Let me elaborate. With stock settings, they cannot connect at all, so I added this line to the bluetooth config file (/etc/bluetooth/main.conf) at the right place: ControllerMode = bredr I got this information from this AskUbuntu Post: https://askubuntu.com/a/1429341 This fixed the problem of not being able to connect the Airpods, and made them work with A2DP on Ubuntu. But here on Debian, only the Hands-Free audio is working (which sounds horrible). I tried following some advice from this arch wiki page in a live install, because I didn't want to break my system, and it didn't really help: https://wiki.archlinux.org/title/bluetooth_headset I tried connecting my other pair of Bluetooth Headphones, Sennheiser 450BT, and they worked flawlessly. I also tried switching btmgmt ssp on and btmgmt ssp off, the second one broke everything and I had to restart the live session. I don't know what is different on Ubuntu 22.04.2 LTS, and why my Airpods Pro 2 work there, but not here. Suspicion: The Airpods send some sort of non-standard/proprietary signal, and if they get the response that they are not connected to an iThing they start mocking up. I'd like to add that the experience on Ubuntu wasn't flawless either, and they would disconnect/the audio would glitch to static noise/corruption every now and then. I would guess around every 3-4 hours of use once, but sometimes 4-5 times in a row. Then you'd have to restart bluetooth and connect them again. It was a bit annoying, but acceptable. So can anybody help me with this problem? I'd greatly appreciate it! I'm using a Lenovo ThinkPad Yoga 12.
Bluetooth Issues with Airpods Pro 2 on Debian 12
Changing sound servers under linux is likely to confuse KDE-Plasma's pre-selection of the preferred devices / associated gain… for audio/video playback/recording. If running KDE-5 < 5.17, resort to the phonon dialog app (either found under the global menu or firing /usr/bin/phononsettings under konsole) Then reorganize the priority of the devices in the Audio Playback > Notifications list as what suits you best. Since phononsettings went deprecated with 5.17, you should now resort to kde-plasma-5 System-Settings under the Hardware / Audio category. Options offered for you (at least a volume setting slider), stand on the rightmost window labeled Playback Streams / Notification Sounds.
I'm running Debian 12 with pipewire installed. However the moment I remove pulseaudio and install pipewire, KDE system sounds (like volume change, critical battery alert...) no longer play. I have even tried with pipewire-pulse, but nothing changed. I have installed pipewire according to the Debian documentation. Here is what I get in the logs after a while from pressing volume up/down: pipewire-pulse[1572]: mod.protocol-pulse: client 0x557e2b3ffcb0 [libcanberra]: ERROR command:18 (PLAY_SAMPLE) tag:10 error:25 (Input/output error)
No system sounds on KDE plasma when using pipewire
Found a solution and wrote a short script for it if [[ $(pactl list | grep "Active Port: analog-output") == *"headphones"* ]]; then pactl set-sink-port 0 analog-output-lineout else pactl set-sink-port 0 analog-output-headphones fiAlso added this to my i3config: bindsym F6 exec --no-startup-id sh ~/path/to/script/switch_output.sh
I've been going down the i3wm road of pain and can't for the life of me understand how to change the output device with cli commands. Setup:Using i3-gaps (Base Distro is Garuda Linux) pipewire is the audio provider When using pavucontrol I can switch between my Headphones and Speakers as the output port but can't seem to figure what is changing in the background with pactl, wpctl, aplay I have headphones connected to my front aux panel and speakers connected to the rear aux panel.Any help would be appreciated :) Update: Found a solution and posted it in the comments
Having trouble using cli to switch between playback devices with pipewire
IF YOU WANT REVERT TO PURE PULSEAUDIO 1/ disable the service systemctl --user disable wireplumber.service2/ mask the service for dependency activation - mask is to prevent any kind of activation, even manual... systemctl --user mask wireplumber.service3/ & stop for current session if we want not use it before restart systemctl --user stop wireplumber.service4/ check if unit/service has no .socket or .timer which will trigger it - need to disable/mask those too 5/ restore pulseaudio systemctl --user unmask pulseaudio.service systemctl --user enable pulseaudio.servicesystemctl --user unmask pulseaudio.socket systemctl --user enable pulseaudio.socketTO FIX PIPEWIRE install package pipewire-pulseaudio
Recently I'm having sound issues on Fedora 35. After booting I don't have any sound. The output of sudo fuser -v /dev/snd/* is: USER PID ACCESS COMMAND /dev/snd/controlC0: root 1036 f.... alsactl iljarotar 2160 F.... wireplumber iljarotar 3209 F.... pulseaudio /dev/snd/controlC1: root 1036 f.... alsactl iljarotar 2160 F.... wireplumber iljarotar 3209 F.... pulseaudio /dev/snd/seq: iljarotar 2159 F.... pipewireTyping systemctl --user stop wireplumber.service and restarting pulseaudio solves the problem. So I tried to disable wireplumber and enable pulseaudio but it doesn't seem to work. Right after booting wireplumber is running again. It's only two commands to type, but it becomes quite annoying to do this every time I start my computer. The first time this occured was after installing ardour following this guide: https://ardour.org/building_linux.html and making an update. So I don't know for sure what caused it. I would really appreciate any help you can give.
Disable wireplumber.service and autostart pulseaudio
Helvum is not persistent with connections. Use qpwgraph. Make your connections, then click on ''activate'and ''exclusive'' and then - THIS IS IMPORTANT- use the 'patchbay' tab to save . Qpwgraph should save your set up and connect correctly when sources come and go. You can either have all the sources you might use running , and then connect them as you wish,and then save, or add each new source as you go but don't forget to update your saved setup each time a new source is added. In my experience pipewire is still fickle, so don't be put off if it doesn't work first time. I sometimes save the same setup a couple of times to be sure. Pipewire usually connects all outputs and inputs, so I find if I dont want all the inputs/outputs I send the outputs i dont need to an input I dont use :-) good luck
I'm trying to play VR games on my Oculus Quest 2 via Air Link. This is done using a free source code software called ALVR. I was able to connect by headset to this software with no much problems at all, except the audio part. After some effort, I was able to make it run using a virtual sink created by ALVR with Pipewire. The problem is that this virtual sink is only created when the headset is placed on my head, and it is destroyed when I remove the headset from it. This causes that every time it is destroyed, all audio sources (Steam, Beat Saber, and so on) disconnects from this sink, so when I place again the headset I have to manually reconnect them using the program Helvum. I attached a screenshot of the Helvum program when the headset is connected (audio sink is alsa-jack.jackC.11829). As you can see, 'Beat Saber.exe' isn't connected automatically when the sink is created.
Pipewire: autoconnect all audio sources to jack sink (instead of manually doing it with Helvum)
Fixed in wireplumber 0.5.3. Bug report: https://gitlab.freedesktop.org/pipewire/wireplumber/-/issues/655
Volume for individual streams (applications) keeps defaulting (being reset) to 46% (0.46), whenever applications are closed and reopened. This is independent to the internal volume control to whatever application (Chrome, mpv, etc.), which are all at 100%. wpctl get-volume 81 Volume: 0.46wpctl get-volume 84 Volume: 0.46wpctl get-volume 88 Volume: 0.46This is even though Output of wpctl settings node.stream.default-playback-volume is set to 1.0, not to 0.46. - Name: node.stream.default-playback-volume Desc: The default volume for playback nodes Type: Float Default: 1.0 [Min: 0.0, Max: 1.0] Value: 1.0It happens only on Budgie (Ubuntu 24.04) not on the default Ubuntu session, and only with USB speakers, not with internal speakers. I have posted the original issue on Budgie discourse, but is there a way to set default volume for indivdual applications (not master volume) from 46% to 100%, as a workaround? wpctl status:PipeWire 'pipewire-0' [1.0.5, user@home, cookie:301889472] └─ Clients: 32. WirePlumber [1.0.5, user@home, pid:1380] 36. pipewire [1.0.5, user@home, pid:1382] 46. WirePlumber [export] [1.0.5, user@home, pid:1380] 57. GNOME Volume Control Media Keys [1.0.5, user@home, pid:1661] 58. Budgie Volume Control [1.0.5, user@home, pid:1818] 59. Budgie Volume Control [1.0.5, user@home, pid:1818] 60. Budgie Volume Control [1.0.5, user@home, pid:1818] 61. budgie-wm [1.0.5, user@home, pid:1786] 62. linphone [1.0.5, user@home, pid:2137] 63. plank [1.0.5, user@home, pid:2151] 64. Chromium input [1.0.5, user@home, pid:2958] 65. Terminal [1.0.5, user@home, pid:3130] 66. Mutter [1.0.5, user@home, pid:1786] 75. wpctl [1.0.5, user@home, pid:3591] 79. mpv [1.0.5, user@home, pid:3566]Audio ├─ Devices: │ 50. Built-in Audio [alsa] │ 82. USB Audio [alsa] │ ├─ Sinks: │ 54. Built-in Audio Analog Stereo [vol: 0.80] │ * 67. USB Audio Analog Stereo [vol: 0.58] │ ├─ Sources: │ 55. Built-in Audio Analog Stereo [vol: 1.00] │ ├─ Filters: │ **└─ Streams: 81. mpv 78. output_FL > USB Audio:playback_FL [active] 80. output_FR > USB Audio:playback_FR [active] 84. Chromium 70. output_FR > USB Audio:playback_FR [active] 83. output_FL > USB Audio:playback_FL [active] 88. io.github.celluloid_player.Celluloid 89. output_FL > USB Audio:playback_FL [active] 90. output_FR > USB Audio:playback_FR [active]**Video ├─ Devices: │ ├─ Sinks: │ ├─ Sources: │ ├─ Filters: │ └─ Streams:Settings └─ Default Configured Devices: 0. Audio/Sink alsa_output.usb-10ae_USB_Audio-00.analog-stereo BlockquoteUPDATE I upgraded wireplumber with the debian experimental package (0.5.2), to use wpctl settings, which is not implemented in yet in the ubuntu package (0.4.7). I made this ugly workaround, which I have set to a keyboard hotkey, which I press after starting to play an audio file: for i in $(wpctl status | grep -A 10 Streams | cut -c 9,10); do wpctl set-volume $i 90%; donetake the first 10 lines after the subheading 'Streams' wpctl status | grep -A 10 Streams, for each line take only the 9th and 10th characters cut -c 9,10, which on some lines, will be the ID number of a stream; for each, then set the volume to 90%, wpctl set-volume $i 90%Better suggestions, or an answer to the original problem (why default volume is 0.46 even though it is set to 1.0), would be appreciated.
Why is default volume for individual streams being ignored? (wireplumber / pipewire)
Of all the "portals" we only have to install xdg-desktop-portal-wlr: sudo apt install xdg-desktop-portal xdg-desktop-portal-wlrNote: "Portal" xdg-desktop-portal-gnome is very large and will also install an entire Gnome desktop! So do not install this one unkless you use Gnome. In this case it will not make a difference for you.This will also install a "portal" configuration file in /usrl/share/xdg-desktop/portal/portals/wlr.portal. Inside there is a list variable UseInwhich contains sway and instructs xdg-desktop-portal to use this "portal" if it detects environmental variables XDG_CURRENT_DESKTOP=sway, XDG_SESSION_DESKTOP=sway. And then we have to export enviromental desktop variables by putting this line in the Sway configuration file ~/.config/sway/config: exec dbus-update-activation-environment --systemd WAYLAND_DISPLAY DISPLAY SWAYSOCK XDG_CURRENT_DESKTOP=sway XDG_SESSION_DESKTOP=swayAttention: These enviromental variables will not work if they are only exported using the /etc/environment. If we want to do it like this, then we also have to import them in Sway by using this line of code in the ~/.config/sway/config: exec systemctl --user import-environment"
I am on Debian 12 / SWAY desktop which is WLR based.I first install the "OBS Studio" version 29.0 with: ┌───┐ │ $ │ ziga > ziga--workstation > ~ └─┬─┘ /dev/pts/4 └─> sudo apt install obs-studio"OBS Studio" can now be started with terminal command: ┌───┐ │ $ │ ziga > ziga--workstation > ~ └─┬─┘ /dev/pts/4 └─> obsIf "OBS Studio" is configured to run on "Xorg" by default we will not see our display! If this is the case we can still force it to run on "Wayland" like this: ┌───┐ │ $ │ ziga > ziga--workstation > ~ └─┬─┘ /dev/pts/4 └─> env QT_QPA_PLATFORM=wayland obsNow it is surely using "Wayland" but this is still not enough for it to detect the desktop! I tried installing packages: ┌───┐ │ $ │ ziga > ziga--workstation > ~ └─┬─┘ /dev/pts/0 └─> sudo apt install xdg-desktop-portal xdg-desktop-portal-wlrAttention: "Sway" is based on "WLR" and therefore we installed xdg-desktop-portal-wlr "portal" implementation for xdg-desktop-portal. Different "portal" implementations exist and should be installed for different desktops. Debian supports "portals" for "KDE" (xdg-desktop-portal-kde), "GTK" (xdg-desktop-portal-gtk) or "Gnome" (xdg-desktop-portal-gnome).I tested and made a conclusion that it does not matter which "Pipewire session manager" is used. By default people use pipewire-media-session but I use wireplumber which deprecates pipewire-media-session (link). At this point I get no screens shown in "OBS Studio"! But I am able to record my screen and microphone using a simple CLI video recorder like this: ┌───┐ │ $ │ ziga > ziga--workstation > ~ └─┬─┘ /dev/pts/0 └─> sudo apt install wl-recorder ┌───┐ │ $ │ ziga > ziga--workstation > ~ └─┬─┘ /dev/pts/0 └─> pw-jack wf-recorder -aAnd this works like a charm... It is just "OBS Studio" that fails to work...
Using OBS studio on Sway with Pipewire
Of course, once you formulate your own question, it sort of gives you an idea of what to look out for. First of all, I needed to create two virtual devices which will serve as a base of operations. This file will be named ~/.config/pipewire/pipewire.conf.d/10-coupled-skype-stream.conf . How did I come to that conclusion, you may ask? The source of truth finds itself in /usr/share/pipewire! Now, onto the file contents: context.modules = [ { name = libpipewire-module-loopback args = { node.description = "Steinberg Front Left" capture.props = { node.name = "capture.mono-micorphone" audio.position = [ FL ] target.object = "alsa_input.usb-Yamaha_Corporation_Steinberg_UR22mkII-00.analog-stereo" stream.dont-remix = true node.passive = true } playback.props = { media.class = "Audio/Source" node.name = "mono-microphone" audio.position = [ MONO ] } } } { name = libpipewire-module-loopback args = { audio.position = [ FL FR ] capture.props = { media.class = Audio/Sink node.name = skype_sink node.description = "Virtual Skype sink" } } } ]I found the name of the devices with the help of a simple program called Simple Wireplumber GUI. What the first pair will do is that it will create a tether from the left channel of the source to a new, virtual, MONO one. The second part of the configuration file creates something called a sink, which is just a place where you dump the audio stuff you want everyone to hear. Now, you use a piece of software called qpwgraph or Helvum to tether what you want everyone to hear to the sink. Left channel goes to the left channel, right channel goes to the right. For the MONO source, it goes to both channels. Once you had enough of hearing your voice for testing, look around the aforementioned program for a loopback tether and sever it. Hope this will be of help to others.
Good evening! I'm trying to create a streaming setup for me and my buddies to hang out via Skype and I'm really struggling with the audio part. There are two problems :The microphone only transmits on the left channel. I would like for my microphone to be transmitted to both audio channels. For this, according to the documentation, ( https://gitlab.freedesktop.org/pipewire/pipewire/-/wikis/Virtual-Devices ) I need to create a mono-sink where I pour in the microphone then transmit it to my friend sink. This blogpost ( https://blogshit.baka.fi/2021/07/pipewire-microphone/ ) seems to cover this use case but I have no media-session.d file. I would like to pour in some applications and other audio sources such as my guitar in the friend sink and I would like to hear what's in it, except for my microphone (maybe only hear my microphone as a one time test).How do I achieve this? How do I know how to name the configuration file since they seem to have specific names in the documentation? How do I pour my application audio? Do I need a separate sink for myself? How do I find the device names for pipewire? Here is my pactl info output shaddox@pop-os:/usr/share/pipewire$ pactl info Server String: /run/user/1000/pulse/native Library Protocol Version: 35 Server Protocol Version: 35 Is Local: yes Client Index: 660 Tile Size: 65472 User Name: shaddox Host Name: pop-os Server Name: PulseAudio (on PipeWire 0.3.79) Server Version: 15.0.0 Default Sample Specification: float32le 2ch 48000Hz Default Channel Map: front-left,front-right Default Sink: alsa_output.usb-Grace_Design_SDAC-00.iec958-stereo Default Source: alsa_input.usb-Yamaha_Corporation_Steinberg_UR22mkII-00.analog-stereo Cookie: 3fff:d574If it helps, here is my arecord -l output shaddox@pop-os:/usr/share/pipewire$ arecord -l **** List of CAPTURE Hardware Devices **** card 0: PCH [HDA Intel PCH], device 0: ALC887-VD Analog [ALC887-VD Analog] Subdevices: 1/1 Subdevice #0: subdevice #0 card 0: PCH [HDA Intel PCH], device 2: ALC887-VD Alt Analog [ALC887-VD Alt Analog] Subdevices: 1/1 Subdevice #0: subdevice #0 card 3: Webcam [C922 Pro Stream Webcam], device 0: USB Audio [USB Audio] Subdevices: 1/1 Subdevice #0: subdevice #0 card 4: UR22mkII [Steinberg UR22mkII], device 0: USB Audio [USB Audio] Subdevices: 0/1 Subdevice #0: subdevice #0And here is my aplay -l output: shaddox@pop-os:/usr/share/pipewire$ aplay -l **** List of PLAYBACK Hardware Devices **** card 0: PCH [HDA Intel PCH], device 0: ALC887-VD Analog [ALC887-VD Analog] Subdevices: 1/1 Subdevice #0: subdevice #0 card 0: PCH [HDA Intel PCH], device 1: ALC887-VD Digital [ALC887-VD Digital] Subdevices: 1/1 Subdevice #0: subdevice #0 card 1: SDAC [SDAC], device 0: USB Audio [USB Audio] Subdevices: 0/1 Subdevice #0: subdevice #0 card 2: NVidia [HDA NVidia], device 3: HDMI 0 [22M35] Subdevices: 1/1 Subdevice #0: subdevice #0 card 2: NVidia [HDA NVidia], device 7: HDMI 1 [HDMI 1] Subdevices: 1/1 Subdevice #0: subdevice #0 card 2: NVidia [HDA NVidia], device 8: HDMI 2 [HDMI 2] Subdevices: 1/1 Subdevice #0: subdevice #0 card 2: NVidia [HDA NVidia], device 9: HDMI 3 [HDMI 3] Subdevices: 1/1 Subdevice #0: subdevice #0 card 4: UR22mkII [Steinberg UR22mkII], device 0: USB Audio [USB Audio] Subdevices: 1/1 Subdevice #0: subdevice #0I only use the Steinberg UR22mkII for guitar recording and the microphone while the SDAC one is where I listen to.
Chaining pipewire sinks for a streaming setup
I feel like this should be a function of sof. But I could be totally wrong here. Filed an issue anyway on it, https://github.com/thesofproject/sof/issues/8195 If it should be filed elsewhere, I'll take it elsewhere. But the sound driver should know when the source volume is 0, and it should be able to trigger a light without me writing wrapper that keeps state or tracks it externally.
Give these two commands, the command for set-sink-mute turns on the muted light on my keyboard for audio pactl set-sink-mute @DEFAULT_SINK@ toggle pactl set-source-mute @DEFAULT_SOURCE@ toggleBut set-source-mute does not turn on the microphone mute light. Is there a way to fix this. I'm using an Lenovo ThinkPad X1 Carbon with Debian.
How can I activate my keyboard's microphone mute light when using set-source-mute?
This problem is solved by following the instructions in an existing answer. In /etc/modprobe.d/alsa-base.conf replace options snd-hda-intel model=genericwith # options snd-hda-intel model=generic options snd-hda-intel probe_mask=1When doing this I also noticed that the first line existed only as a result of a previous attempt to solve this exact problem.
Since upgrading a Macbook Air (2012) from Ubuntu 22.04 to 22.10 which replaced PulseAudio with Pipewire and Wireplumber I can't seem to get any sound through the built-in speakers, and the audio seems to be constantly routed to the headphones jack no matter what. Even the DisplayPort/HDMI output doesn't output any sound. In other words: as soon as I switch to the combined internal speakers/headphones output and plug in external speakers in the headphones jack I get a signal. The Settings app correctly detects whenever a plug is inserted or pulled out (the output's name changes), and additionally shows output activity in the bar graph whenever the speakers ("Built-in Audio") are selected and nothing is connected to the headphones jack. Speakers work fine in other OSes -- including 22.04 -- as well as when booting the 22.10 live USB installer, so there's no hardware problem. I've tried reinstalling pipewire and wireplumber but since then I've quickly run out of ideas. Some configuration seems to be missing. I tried to dpkg-reconfigure pipewire wireplumber but that was just a shot in the dark. How do I troubleshoot this problem?
Sound always routed through headphones jack with Pipewire
When the buffer is small, It fills up more quickly and empties out more quickly. This is why the latency shrinks. However, the processes that put data into the buffer and take data out of the buffer will be triggered more often. So you may see higher consumption of your computer's CPU by the audio software when you make the buffer too small. In extreme cases, using the audio system with a small buffer can make the other software on your computer respond slower, or perhaps "choppy" or "stuttering" where it alternates between smooth and frozen. A small buffer can also cause the audio stream to stutter if the process that puts audio data into the buffer can't respond fast enough and the buffer goes completely empty for brief moments. The process that's taking the audio data out of the buffer and passing it through the output to your speakers (or headphones) will run out of data and there will be interruptions in the sound (often called "drop outs"). It's hard to predict what size will be "too small", so you may have to experiment and see what compromise gives you the shortest latency without impacting the audio streams and the rest of your computer.
I see that with audio servers (in my case, pipewire) you can alter the "latency". (please forgive me, I am not very knowledgeable with these things.) PIPEWIRE_LATENCY="128/48000" The Arch Linux wiki described this as "request[ing] a custom buffer size". I was wondering, is there a "downside" to setting the latency really low. Is it simply more responsive audio a higher cost of resources?
Downside of decreasing audio latency
Make sure you have wireplumber First make sure you follow the directions on the Debian testing wiki for setting up PulseAudio. Note you do not want to pipewire-media-session. Make sure that's totally gone (taking one command from the wiki), apt install wireplumber pipewire-media-session-Confirm service is running Make sure the pipewire-pulse service is started, systemctl --user status pipewire-pulse.socket pipewire-pulse.serviceThat should return something like this, ● pipewire-pulse.service - PipeWire PulseAudio Loaded: loaded (/usr/lib/systemd/user/pipewire-pulse.service; enabled; vendor pr> Active: active (running) since Sat 2022-07-02 12:35:10 CDT; 2min 21s agoTo be properly configured either,The service should be active, or The socket should be active. Or both, ;)If it's not, you can start just the socket, preferred -- if nothing uses it nothing happens (the daemon is lazy-loaded) systemctl start --user pipewire-pulse.socketOr, just start both (NOT preferred, no real gain just not lazy) systemctl start --user pipewire-pulse.socket pipewire-pulse.service
Currently, I do not think my PulseAudio shim for PipeWire is working. When I run pactl info, I'm getting a "Connection refused" error, $ pactl info Connection failure: Connection refused pa_context_connect() failed: Connection refusedWhen I try to run pavumixer, I getEstablishing connection to PulseAudio. Please wait...How can I resolve this?
How can I configure PipeWire for PulseAudio comparability?
Apparently, I had PULSE_SERVER="" in my /etc/environment file. I removed that line and rebooted. Then, everything worked.
One time when I rebooted my computer, suddenly, the audio won't change and the audio settings only say No output or input devices found. I have replaced pulseaudio with pipewire, but it stilled worked after a reboot following the replacement. When using kmix and rebooting again, the audio can be changed, but the audio applet in KDE Plasma shows the same message. I can still hear audio, but I need to manually change it with programs like alsamixer or kmix. Also, I tried making the same conditions on Virtualbox with pipewire instead of pulseaudio, and the audio worked in the virtual machine. How can I fix plasma-pa's audio problem? My Linux distribution is Debian Sid. Output of pactl info: Connection failure: Invalid server pa_context_connect() failed: Invalid serverVersion of packages: plasma-pa: 4:5.27.10-1+b2 pipewire: 1.0.5-1+b1 pipewire-pulse: 1.0.5-1+b1
Cannot change volume or access audio settings in KDE Plasma suddenly
I have found a way to load rnnoise as a pipewire plugin for all users. Step 1: On this page you can download the rnnoise drivers compiled for X86 linux. This is not the last version of rnnoise. If you want the latest version, i think you have to perform compilation by yourself from the official github repo. Step 2: In the downloaded archive, you will find the needed linux libs. Always take mono libs. You probably have only one microphone! I propose to store them in /usr/lib/audio/ So you will have to create the folder audio. As i renamed the files, i have now in this folder:ladspa.so lv2.so vst3.so vst.soStep 3 Create the 2 pipewire folders to get this path: /etc/pipewire/pipewire.conf.d/Step 4 In this folder create the file 99-mic-denoising.conf. In this file paste this content: context.modules = [ {name = libpipewire-module-filter-chain args = { node.description = "Noise Canceling source" media.name = "Noise Canceling source" filter.graph = { nodes = [ { type = ladspa name = rnnoise plugin = /usr/lib/audio/ladspa.so label = noise_suppressor_mono control = { "VAD Threshold (%)" = 90.0 "VAD Grace Period (ms)" = 200 "Retroactive VAD Grace (ms)" = 0 } } ] } capture.props = { node.name = "capture.rnnoise_source" node.passive = true audio.rate = 48000 } playback.props = { node.name = "rnnoise_source" media.class = Audio/Source audio.rate = 48000 } } } ]Step 5 Restart pipewire deamon: systemctl restart --user pipewire.serviceNow in gnome settings you can choose the microphone with noise cancelled. CommentsWe so use the pipewire filter-chain module. Check the documentation, it's very useful. Each application (which use audio) has been designed to use a standard (called audio plugin API):ladspa: open standard...but it's not the newest one lv2: open standard...the newest one vst3: proprietary standard (you should not see it with open source programs) vst: proprietary standard (you should not ....)So the solution I provided, doesn't cover applications using lv2 audio plugin (i don't care about proprietary standards). Any help for lv2 is welcome.
With pulseaudio, it was easy to load a module for microphone noise reduction. This link explains it clearly: https://askubuntu.com/questions/18958/realtime-noise-removal-with-pulseaudio I want to add rnnoise as a plugin of pipewire to cancel the noise of the microphone for all users. I'm looking for a minimalist solution and would like to avoid applications. Like this one: https://github.com/noisetorch/NoiseTorch?tab=readme-ov-file
Reducing microphone noise using pipewire modules
Add PULSE_SERVER= to /etc/environment and reboot. The problem is solved as the variable PULSE_SERVER is not even set in the environment variables.
For this problem, I had trouble with getting bb to work with pipewire. Executing the command pasuspender -- env PULSE_SERVER= bb returns Failure to suspend: No such entity. How do I enable bb with sound when using pipewire?
Cannot enable sound with bb even with pasuspender
I had the same problem with the same chipset, adding snd_hda_intel.power_save=0to the kernel command line solved it. Basically, what seemed to happen for me was that the sound chip got powered down, but the headphone amplifier wasn't, then amplifying the noise picked up by the lines that weren't properly terminated anymore.
I have installed Debian 12.5.0 (i386) on an old Sony laptop (VAIO VGN-FS742/W), using the netinst ISO. There is an issue with the audio: A repeating crackling sound when no sound is playing. That crackling sound disappear during any audio play (VLC, browser, …) and comes back after the audio stops. But that annoying sound only plays on the left channel (whether I'm on speaker or headphones). At the start of the system, it's a two-cracks burst every second. But after some time that number increase, and the frequency increase and cease to be periodic. I did not tinker with any audio config so far. I have the default Debian audio setup (i.e. the “PipeWire” framework). In the AlsaMixer console, I see the Headphone playback level jumping between its current level and 0% or 100%, in sync with the cracks. If I touch the Master or PCM playback levels, they start to do the same. #> aplay -l **** List of PLAYBACK Hardware Devices **** card 0: Intel [HDA Intel], device 0: ALC260 Analog [ALC260 Analog] Subdevices: 1/1 Subdevice #0: subdevice #0At some point I made a change which caused the “Headphone” channel to start at 0. This was good because when I boot that way, enabling back the channel after boot fix the issue until next boot (“Headphone” actually controls speaker & jack). All in all, this looks like a software issue. how can I fix this?
Repeated crackling sound when nothing is playing
I also posted this question on the debian forums: In that forum, user FreewheelinFrank suggested trying out a debian testing image after mentioning that support for the ESSX8336 chip/codec is still under development. On this testing image, audio worked out of the box.
I have no sound on a fresh debian 12 install on a mini-pc. The PC is connected via HDMI to a TV. I've tried testing with pipewire, with alsa-only, with pipewire-pulse. I also tried testing plugging in headphones via the AUX port. There is never any sound hardware info █[coolby][~][0]$ inxi CPU: dual core Intel Celeron N3350 (-MCP-) speed/min/max: 2391/800/2400 MHz Kernel: 6.1.0-17-amd64 x86_64 Up: 1d 21h 29m Mem: 1786.0/5773.7 MiB (30.9%) Storage: 58.23 GiB (22.5% used) Procs: 191 Shell: Bash inxi: 3.3.26 █[coolby][~][0]$ inxi -SAG System: Host: coolby Kernel: 6.1.0-17-amd64 arch: x86_64 bits: 64 Desktop: N/A Distro: Debian GNU/Linux 12 (bookworm) Graphics: Device-1: Intel HD Graphics 500 driver: i915 v: kernel Display: x11 server: X.Org v: 1.21.1.7 driver: X: loaded: modesetting unloaded: fbdev,vesa dri: iris gpu: i915 resolution: 1920x1080~60Hz API: OpenGL v: 4.6 Mesa 22.3.6 renderer: Mesa Intel HD Graphics 500 (APL 2) Audio: Device-1: Intel Celeron N3350/Pentium N4200/Atom E3900 Series Audio Cluster driver: sof-audio-pci-intel-apl API: ALSA v: k6.1.0-17-amd64 status: kernel-api Server-1: PipeWire v: 0.3.65 status: active █[coolby][~][0]$os Distributor ID: Debian Description: Debian GNU/Linux 12 (bookworm) Release: 12 Codename: bookwormfirmware [coolby][~][1]$ sudo journalctl -k | grep -Ei "ALSA|HDA|sof[-]|HDMI|snd[_-]|sound|hda.codec|hda.intel" Jan 27 03:43:17 coolby kernel: snd_hda_intel 0000:00:0e.0: DSP detected with PCI class/subclass/prog-if info 0x040100 Jan 27 03:43:17 coolby kernel: snd_soc_skl 0000:00:0e.0: DSP detected with PCI class/subclass/prog-if info 0x040100 Jan 27 03:43:17 coolby kernel: sof-audio-pci-intel-apl 0000:00:0e.0: DSP detected with PCI class/subclass/prog-if info 0x040100 Jan 27 03:43:17 coolby kernel: sof-audio-pci-intel-apl 0000:00:0e.0: DSP detected with PCI class/subclass/prog-if 0x040100 Jan 27 03:43:17 coolby kernel: sof-audio-pci-intel-apl 0000:00:0e.0: bound 0000:00:02.0 (ops i915_audio_component_bind_ops [i915]) Jan 27 03:43:17 coolby kernel: sof-audio-pci-intel-apl 0000:00:0e.0: use msi interrupt mode Jan 27 03:43:17 coolby kernel: sof-audio-pci-intel-apl 0000:00:0e.0: NHLT_DEVICE_I2S detected, ssp_mask 0x1 Jan 27 03:43:17 coolby kernel: sof-audio-pci-intel-apl 0000:00:0e.0: Overriding topology with MCLK mask 0x2 from NHLT Jan 27 03:43:17 coolby kernel: sof-audio-pci-intel-apl 0000:00:0e.0: hda codecs found, mask 4 Jan 27 03:43:17 coolby kernel: sof-audio-pci-intel-apl 0000:00:0e.0: firmware: direct-loading firmware intel/sof/sof-apl.ri Jan 27 03:43:17 coolby kernel: sof-audio-pci-intel-apl 0000:00:0e.0: Firmware info: version 2:2:0-57864 Jan 27 03:43:17 coolby kernel: sof-audio-pci-intel-apl 0000:00:0e.0: Firmware: ABI 3:22:1 Kernel ABI 3:23:0 Jan 27 03:43:17 coolby kernel: sof-audio-pci-intel-apl 0000:00:0e.0: unknown sof_ext_man header type 3 size 0x30 Jan 27 03:43:17 coolby kernel: sof-audio-pci-intel-apl 0000:00:0e.0: Firmware info: version 2:2:0-57864 Jan 27 03:43:17 coolby kernel: sof-audio-pci-intel-apl 0000:00:0e.0: Firmware: ABI 3:22:1 Kernel ABI 3:23:0 Jan 27 03:43:17 coolby kernel: sof-essx8336 sof-essx8336: quirk mask 0x0 Jan 27 03:43:17 coolby kernel: sof-essx8336 sof-essx8336: quirk SSP0 Jan 27 03:43:17 coolby kernel: sof-audio-pci-intel-apl 0000:00:0e.0: firmware: direct-loading firmware intel/sof-tplg/sof-apl-es8336-ssp0.tplg Jan 27 03:43:17 coolby kernel: sof-audio-pci-intel-apl 0000:00:0e.0: Topology: ABI 3:22:1 Kernel ABI 3:23:0 Jan 27 03:43:17 coolby kernel: sof-essx8336 sof-essx8336: ASoC: Parent card not yet available, widget card binding deferred Jan 27 03:43:17 coolby kernel: input: sof-essx8336 Headset as /devices/pci0000:00/0000:00:0e.0/sof-essx8336/sound/card0/input21 Jan 27 03:43:17 coolby kernel: input: sof-essx8336 HDMI/DP,pcm=5 as /devices/pci0000:00/0000:00:0e.0/sof-essx8336/sound/card0/input22 Jan 27 03:43:17 coolby kernel: input: sof-essx8336 HDMI/DP,pcm=6 as /devices/pci0000:00/0000:00:0e.0/sof-essx8336/sound/card0/input23 Jan 27 03:43:17 coolby kernel: input: sof-essx8336 HDMI/DP,pcm=7 as /devices/pci0000:00/0000:00:0e.0/sof-essx8336/sound/card0/input24pavucontrol Pavucontrol via pipewire-pulse appears to show the sound bar moving but there is no sound, even after switching to various outputs and configurations.There is no "HDMI" configuration or profile, only "Speakers" and "Pro Audio", neither of which appears to deliver any sound:sound cards █[coolby][~][0]$ sudo cat /proc/asound/cards 0 [sofessx8336 ]: sof-essx8336 - sof-essx8336 intel-AB2L-Defaultstring█[coolby][~][130]$ aplay -l **** List of PLAYBACK Hardware Devices **** card 0: sofessx8336 [sof-essx8336], device 0: ES8336 (*) [] Subdevices: 0/1 Subdevice #0: subdevice #0 card 0: sofessx8336 [sof-essx8336], device 5: HDMI 1 (*) [] Subdevices: 1/1 Subdevice #0: subdevice #0 card 0: sofessx8336 [sof-essx8336], device 6: HDMI 2 (*) [] Subdevices: 1/1 Subdevice #0: subdevice #0 card 0: sofessx8336 [sof-essx8336], device 7: HDMI 3 (*) [] Subdevices: 1/1 Subdevice #0: subdevice #0 █[coolby][~][0]$aplay -L list several cards, none of which contains HDMI in their name: █[coolby][~][1]$ aplay -L null Discard all samples (playback) or generate zero samples (capture) lavrate Rate Converter Plugin Using Libav/FFmpeg Library samplerate Rate Converter Plugin Using Samplerate Library speexrate Rate Converter Plugin Using Speex Resampler jack JACK Audio Connection Kit oss Open Sound System pipewire PipeWire Sound Server pulse PulseAudio Sound Server speex Plugin using Speex DSP (resample, agc, denoise, echo, dereverb) upmix Plugin for channel upmix (4,6,8) vdownmix Plugin for channel downmix (stereo) with a simple spacialization default Default ALSA Output (currently PipeWire Media Server) hw:CARD=sofessx8336,DEV=0 sof-essx8336, Direct hardware device without any conversions hw:CARD=sofessx8336,DEV=5 sof-essx8336, Direct hardware device without any conversions hw:CARD=sofessx8336,DEV=6 sof-essx8336, Direct hardware device without any conversions hw:CARD=sofessx8336,DEV=7 sof-essx8336, Direct hardware device without any conversions plughw:CARD=sofessx8336,DEV=0 sof-essx8336, Hardware device with all software conversions plughw:CARD=sofessx8336,DEV=5 sof-essx8336, Hardware device with all software conversions plughw:CARD=sofessx8336,DEV=6 sof-essx8336, Hardware device with all software conversions plughw:CARD=sofessx8336,DEV=7 sof-essx8336, Hardware device with all software conversions sysdefault:CARD=sofessx8336 sof-essx8336, Default Audio Device dmix:CARD=sofessx8336,DEV=0 sof-essx8336, Direct sample mixing device dmix:CARD=sofessx8336,DEV=5 sof-essx8336, Direct sample mixing device dmix:CARD=sofessx8336,DEV=6 sof-essx8336, Direct sample mixing device dmix:CARD=sofessx8336,DEV=7 sof-essx8336, Direct sample mixing device usbstream:CARD=sofessx8336 sof-essx8336 USB Stream Output █[coolby][~][0]$I tried piping each one of those sound cards through speaker-test, but there was never a sound. I also plugged in speakers/headphones via the AUX cable, no sound. Also, pactl list-sinks only lists a single card: █[coolby][~][0]$ pactl list sinks Sink #41 State: IDLE Name: alsa_output.pci-0000_00_0e.0-platform-sof-essx8336.stereo-fallback Description: Celeron N3350/Pentium N4200/Atom E3900 Series Audio Cluster Stereo Driver: PipeWire Sample Specification: s32le 2ch 48000Hz Channel Map: front-left,front-right Owner Module: 4294967295 Mute: no Volume: front-left: 47038 / 72% / -8.64 dB, front-right: 47038 / 72% / -8.64 dB balance 0.00 Base Volume: 65536 / 100% / 0.00 dB Monitor Source: alsa_output.pci-0000_00_0e.0-platform-sof-essx8336.stereo-fallback.monitor Latency: 0 usec, configured 0 usec Flags: HARDWARE HW_MUTE_CTRL HW_VOLUME_CTRL DECIBEL_VOLUME LATENCY Properties: alsa.card = "0" alsa.card_name = "sof-essx8336" alsa.class = "generic" alsa.device = "0" alsa.driver_name = "snd_soc_sof_es8336" alsa.id = "ES8336 (*)" alsa.long_card_name = "intel-AB2L-Defaultstring" alsa.name = "" alsa.resolution_bits = "16" alsa.subclass = "generic-mix" alsa.subdevice = "0" alsa.subdevice_name = "subdevice #0" api.alsa.card.longname = "intel-AB2L-Defaultstring" api.alsa.card.name = "sof-essx8336" api.alsa.path = "hw:0" api.alsa.pcm.card = "0" api.alsa.pcm.stream = "playback" audio.channels = "2" audio.position = "FL,FR" card.profile.device = "6" device.api = "alsa" device.class = "sound" device.id = "40" device.profile.description = "Stereo" device.profile.name = "stereo-fallback" device.routes = "2" factory.name = "api.alsa.pcm.sink" media.class = "Audio/Sink" device.description = "Celeron N3350/Pentium N4200/Atom E3900 Series Audio Cluster" node.name = "alsa_output.pci-0000_00_0e.0-platform-sof-essx8336.stereo-fallback" node.nick = "Stereo" node.pause-on-idle = "false" object.path = "alsa:pcm:0:hw:0:playback" priority.driver = "1000" priority.session = "1000" factory.id = "18" clock.quantum-limit = "8192" client.id = "33" node.driver = "true" factory.mode = "merge" audio.adapt.follower = "" library.name = "audioconvert/libspa-audioconvert" object.id = "41" object.serial = "41" node.max-latency = "4096/48000" api.alsa.period-size = "1024" api.alsa.period-num = "8" api.alsa.headroom = "0" api.acp.auto-port = "false" api.acp.auto-profile = "false" api.alsa.card = "0" api.alsa.use-acp = "true" api.dbus.ReserveDevice1 = "Audio0" device.bus = "pci" device.bus_path = "pci-0000:00:0e.0-platform-sof-essx8336" device.enum.api = "udev" device.icon_name = "audio-card-analog-pci" device.name = "alsa_card.pci-0000_00_0e.0-platform-sof-essx8336" device.nick = "sof-essx8336" device.plugged.usec = "30160517" device.product.id = "0x5a98" device.product.name = "Celeron N3350/Pentium N4200/Atom E3900 Series Audio Cluster" device.subsystem = "sound" sysfs.path = "/devices/pci0000:00/0000:00:0e.0/sof-essx8336/sound/card0" device.vendor.id = "0x8086" device.vendor.name = "Intel Corporation" device.string = "0" Ports: analog-output-speaker: Speakers (type: Speaker, priority: 10000, not available) analog-output-headphones: Headphones (type: Headphones, priority: 9900, availability group: Legacy 1, availability unknown) Active Port: analog-output-headphones Formats: pcmDisplay The system is connected via HDMI to a TV with speakers, sound on this TV works fine with other devices: █[coolby][~][0]$ xrandr -q Screen 0: minimum 320 x 200, current 1920 x 1080, maximum 16384 x 16384 DP-1 disconnected primary (normal left inverted right x axis y axis) HDMI-1 disconnected (normal left inverted right x axis y axis) HDMI-2 connected 1920x1080+0+0 (normal left inverted right x axis y axis) 853mm x 480mm 1920x1080 60.00*+ 59.94 30.00 24.00 29.97 23.98 1920x1080i 60.00 59.94 1680x1050 59.88 1280x1024 75.02 60.02 1440x900 59.90 1280x960 60.00 1360x768 60.02 1280x800 59.91 1152x864 75.00 1280x720 60.00 60.00 59.94 1024x768 75.03 70.07 60.00 800x600 72.19 75.00 60.32 720x480 60.00 59.94 720x480i 60.00 59.94 640x480 75.00 72.81 60.00 59.94 720x400 70.08 █[coolby][~][0]$speaker test These appear to succeed but there is no sound. █[coolby][~][1]$ speaker-test -l5 -D plughw:0,5speaker-test 1.2.8Playback device is plughw:0,5 Stream parameters are 48000Hz, S16_LE, 1 channels Using 16 octaves of pink noise Rate set to 48000Hz (requested 48000Hz) Buffer size range from 96 to 16384 Period size range from 48 to 4096 Using max buffer size 16384 Periods = 4 was set period_size = 4096 was set buffer_size = 16384 0 - Front Left Time per period = 2.646839 0 - Front Left Time per period = 2.985025 0 - Front Left Time per period = 2.986957 0 - Front Left Time per period = 2.986913 0 - Front Left Time per period = 2.985883 █[coolby][~][0]$ speaker-test -l5 -D plughw:0,6speaker-test 1.2.8Playback device is plughw:0,6 Stream parameters are 48000Hz, S16_LE, 1 channels Using 16 octaves of pink noise Rate set to 48000Hz (requested 48000Hz) Buffer size range from 96 to 16384 Period size range from 48 to 4096 Using max buffer size 16384 Periods = 4 was set period_size = 4096 was set buffer_size = 16384 0 - Unknown Time per period = 2.645836 0 - Unknown Time per period = 2.985933 0 - Unknown Time per period = 2.986965 0 - Unknown Time per period = 2.986956 0 - Unknown Time per period = 2.981944 █[coolby][~][0]$ speaker-test -l5 -D plughw:0,7speaker-test 1.2.8Playback device is plughw:0,7 Stream parameters are 48000Hz, S16_LE, 1 channels Using 16 octaves of pink noise Rate set to 48000Hz (requested 48000Hz) Buffer size range from 96 to 16384 Period size range from 48 to 4096 Using max buffer size 16384 Periods = 4 was set period_size = 4096 was set buffer_size = 16384 0 - Unknown Time per period = 2.646129 0 - Unknown Time per period = 2.986089 0 - Unknown Time per period = 2.986616 0 - Unknown Time per period = 2.986962 0 - Unknown Time per period = 2.984837 █[coolby][~][0]$Product details Coolby Yealbox MINI PC Intel Celeron N3350 Processor Windows 10 system 6GB RAM 64GB ROM M.2 Slot 4K HD Office Desktop MINI Computer Details Save Report this item Power Mode: Power Supply Operating Voltage: 110V/220V Plug Specification: US Plug Connectivity Technology: USB CPU Manufacturer: Intel Wireless Communication Standard: 2.4 ghz radio frequency Processor Type: Intel Celeron* Graphics Processor Manufacturer: Intel Graphics Type: Integrated Usage: Multimedia Wireless Connection Type: Wifi Hard Drive Type: Ssd Graphics Processor: Inteluhdgraphics600 Memory Technology: Ddr3 Operating System: Windows10pro Graphics Card Interface: Integrated Total Video Out Ports: 1 Battery Properties: Without Battery Brand: Coolby Connectivity Type: None Wireless Property: With Wi-Fi functionHow can I further troubleshoot audio on this mini PC?
No sound on fresh install of Debian 12
Is it possible for 2 processes, each trying to send audio to the single output device, to share (mix) the audio streams?Yes, that's what an audio server is for. So, using pipewire instantly solves this – it even offers a (software-implemented) ALSA pseudodevice that any ALSA-using program can use.
Is it possible for 2 processes, each trying to send audio to the single output device, to share (mix) the audio streams? I'm running AlmaLinux 9 and have paired back to basic ALSA only. But if needed I can add (back) pipewire. I want to test using 'aplay' but the solution should work with any process' audio output.
Share audio output device between two processes
I just had the same return when installing deluged on arch, I typed: systemctl start delugedI tried with sudo and it worked fine. Seems to be a group permissions issue. All I did was enable permissions for my user account and then typed: sudo systemctl start delugedworked like a charm.
When attempting to launch system-config-users from command line, I get the following warning, and the tool does not open. I'm using CentOS 7 with Mate 1.8.1.WARNING **: Error enumerating actions: GDBus.Error:org.freedesktop.DBus.Error.ServiceUnknown: The name org.freedesktop.PolicyKit1 was not provided by any .service files Error checking for authorization org.freedesktop.policykit.exec: GDBus.Error:org.freedesktop.DBus.Error.ServiceUnknown: The name org.freedesktop.PolicyKit1 was not provided by any .service filesyum list polkit* Installed Packages polkit.x86_64 0.112-5.el7 @anaconda polkit-devel.x86_64 0.112-5.el7 @base polkit-docs.noarch 0.112-5.el7 @base polkit-gnome.x86_64 0.105-6.el7 @epel polkit-pkla-compat.x86_64 0.1-4.el7 @anacondaWhat is missing from my system to cause this error?
The name > org.freedesktop.PolicyKit1 was not provided by any .service files
ConsoleKit (documentation) was a service which tracks user sessions (i.e. where a user is logged in). It allows switching users without logging out (many users can be logged in on the same hardware at the same time with one user active). It is also used to check if a session is "local" i.e. if a user has direct access to hardware (which may be considered more secure than remote access). Currently the ConsoleKit is largely replaced by logind, which is part of systemd, although there is standalone version elogind. polkit (née PolicyKit) documentation allows fine-tuned capabilities in a desktop environment. Traditionally only a privileged user (root) was allowed to configure network. However, while in a server environment it is a reasonable assumption that it would be too limiting to not be allowed to connect to a hotspot on laptop, for example. However, you may still not want to give full privileges to this person (like installing programs) or may want to limit options for some people (for example on your children laptops only 'trusted' networks with parental filters can be used). As far as I remember it works like:Program send message to daemon via dbus about action Daemon uses polkit libraries/configuration (in fact polkit daemon) to determine if a user is allowed to perform an action. It may happen that certain conditions must be fulfilled (like entering password or hardware access). Daemon performs action according to it (returns auth error or performs action)
I have seen that recent GNU/Linux are using ConsoleKit and PolicyKit. What are they for? How do they work? The best answer should explain what kind of problem each one tries to solve, and how they manage to solve it. I am a long-time GNU/Linux user, from a time when such things did not exist. I have been using Slackware and recently Gentoo. I am an advanced user/admin/developer, so the answer can (and should!) be as detailed and as accurate as possible. I want to understand how these things work, so I can use them (as a user or as a developer) the best possible way.
What are ConsoleKit and PolicyKit? How do they work?
EDIT: Please use the upvoted answer and not this one. OLD ANSWER: I found this bug and some workarounds here: https://bugzilla.redhat.com/show_bug.cgi?id=1149893 More specific you have to place a .rules file in /etc/polkit-1/rules.d/ (Select a filename and just givr the .rules extension) and give the rules: polkit.addRule(function(action, subject) { if ((action.id == "org.freedesktop.color-manager.create-device" || action.id == "org.freedesktop.color-manager.create-profile" || action.id == "org.freedesktop.color-manager.delete-device" || action.id == "org.freedesktop.color-manager.delete-profile" || action.id == "org.freedesktop.color-manager.modify-device" || action.id == "org.freedesktop.color-manager.modify-profile") && subject.isInGroup("ATTENTION")) { return polkit.Result.YES; } });Then you have to Replace the word "ATTENTION" with your user's group.
I am running a fresh install of CentOS 7 GNOME so I could RDP from Windows. Ifollowed the “Connect to GNOME desktop environment via XRDP” instructions, but when I connect I get an additional login that says authentication is required to create a color profileHow do I remove this additional login? In an attempt to solve this problem I tried a solution at “Griffon's IT Library”, but it did not work because link is a lot more then just a solution to this problem. Ipasted thesolution below.When you login into your system via remote session, you will see this message popping up. You can simply cancel and you will be able to proceed till the next time you login and start a new session. To avoid this prompt, we will need to change the polkit configuration. Using admin privileges, create a file called 02-allow-colord.conf under the following directory /etc/polkit-1/localauthority.conf.d/ The file should contains [sic] the following instructions and you should not be prompted anymore with such authentication request while remoting into your system polkit.addRule(function(action, subject) { if ((action.id == “org.freedesktop.color-manager.create-device” || action.id == “org.freedesktop.color-manager.create-profile” || action.id == “org.freedesktop.color-manager.delete-device” || action.id == “org.freedesktop.color-manager.delete-profile” || action.id == “org.freedesktop.color-manager.modify-device” || action.id == “org.freedesktop.color-manager.modify-profile”) && subject.isInGroup(“{group}”)) { return polkit.Result.YES; } });
Authentication is required to create a color profile
To achieve that the user techops can control the service publicapi.service without giving a password, you have different possiblities. Which one is suitable for you cannot be answered as you have to choose on your own. The classical sudo approach is maybe the most used, as it is there for a long time. You would have to create e.g. the file as follows. Note that the drop-in directory /etc/sudoers.d is only active when #includedir /etc/sudoers.d is set in /etc/sudoers. But that should be the case if you are using a modern Ubuntu distribution. As root execute: cat > /etc/sudoers.d/techops << SUDO techops ALL= NOPASSWD: /bin/systemctl restart publicapi.service techops ALL= NOPASSWD: /bin/systemctl stop publicapi.service techops ALL= NOPASSWD: /bin/systemctl start publicapi.service SUDONow you should be able to run the systemctl commands as user techops without giving a password by prepending sudo to the commands. sudo systemctl start publicapi.service sudo systemctl stop publicapi.service sudo systemctl restart publicapi.serviceThe second method would be to use PolKit (was renamed from PolicyKit) to allow the user techops to control systemd services. Depending on the version of polit, you can give normal users control over systemd units. To check the polkit version, just run pkaction --version.with polkit version 0.106 and higher, you can allow users to control specific systemd units. To do so, you could create a rule as root: cat > /etc/polkit-1/rules.d/10-techops.rules << POLKIT polkit.addRule(function(action, subject) { if (action.id == "org.freedesktop.systemd1.manage-units" && action.lookup("unit") == "publicapi.service" && subject.user == "techops") { return polkit.Result.YES; } }); POLKITwith polkit version 0.105 and lower: you can allow users to control systemd units. This unfortunately includes all systemd units and you might not want to do this. Not sure if there is a way to limit access to specific systemd units with version 0.105 or lower, but maybe someone else can clarify. To enable this, you could create a file as root: cat > /etc/polkit-1/localauthority/50-local.d/org.freedesktop.systemd1.pkla << POLKIT [Allow user techops to run systemctl commands] Identity=unix-user:techops Action=org.freedesktop.systemd1.manage-units ResultInactive=no ResultActive=no ResultAny=yes POLKITIn both cases you can run systemctl [start|stop|restart] publicapi.service as user techops without giving a password. In the latter case ( polkit <= 0.105 ) the user techops could control any systemd unit.A third option would be to make the service a user service, which does not need sudo or polkit configurations. This puts everything under the control of the user and only works if your actual service that is started with /home/techops/publicapi start can run without root privileges. First you have to enable lingering for the user techops. This is needed to startup the user service on boot. As root execute: loginctl enable-linger techopsNext you have to move the systemd unit file into the techops user directory. As user techops execute the commands as follows. mkdir -p ~/.config/systemd/usercat > ~/.config/systemd/user/publicapi.service << UNIT [Unit] Description=public api startup script[Service] Type=oneshot RemainAfterExit=yes EnvironmentFile=-/etc/environment WorkingDirectory=/home/techops ExecStart=/home/techops/publicapi start ExecStop=/home/techops/publicapi stop[Install] WantedBy=default.target UNITNote that the WantedBy has to be default.target as there is no multi-user.target in the user context. Now reload the configuration and enable the service. Again as user techops execute the commands. systemctl --user daemon-reload systemctl --user enable publicapi.service systemctl --user start publicapi.serviceIn general you should place your systemd units in /etc/systemd/system/ not directly in /etc/systemd/system/multi-user.target.wants. When you execute systemctl enable publicapi.service a symbolic link will be created in etc/systemd/system/multi-user.target.wants or whatever target is specified for that unit. As already mentioned, if the service/process itself can be run without root privileges you should consider adding User=techops to your unit file to run the process with a non-privileged user account.
I created some systemd services which basically works: location: /etc/systemd/system/multi-user.target.wants/publicapi.servicecontent: [Unit] Description=public api startup script[Service] Type=oneshot RemainAfterExit=yes EnvironmentFile=-/etc/environment WorkingDirectory=/home/techops ExecStart=/home/techops/publicapi start ExecStop=/home/techops/publicapi stop[Install] WantedBy=multi-user.targetWhen I try to restart the service as techops user in the command line, I get the following output: ==== AUTHENTICATING FOR org.freedesktop.systemd1.manage-units === Authentication is required to start 'publicapi.service'. Multiple identities can be used for authentication: 1. Myself,,, (defaultuser) 2. ,,, (techops) Choose identity to authenticate as (1-2):I want that only techops can restart services and I want that this prompt does not appear when being logged in as techops. How can I do that? I read that there are different approaches with polkit-1 or sudoers, but I'm unsure. [UPDATE] 2019-01-27 4:40pm Thanks for this comprehensive answer to Thomas and Perlduck. It helped me to improve my knowledge of systemd. According to the approach to start the service without a password prompt, and I want to apologize that I did not emphasize the real problem enough: Actually, what is most important for me is that no other user than techops should stop or start the service. But at least with the first two approaches I can still run service publicapi stop and I get the prompt ==== AUTHENTICATING FOR org.freedesktop.systemd1.manage-units === again. When I choose the defaultuser and know the password, I could stop all the services. I want to deny this user from doing that, even if he has the password. Important background info to better understand why this is the more important part for me: The defaultuser is the only user which is exposed to ssh but this user cannot do anything else (except changing to other users if you have the password of these other users). But at the moment, he can start or stop the services, but this user must not to do this. If someone gets the password of defaultuser and logs in via ssh, then he could stop all the services at the moment. This is what I meant with "I want that only techops can restart services". Sorry, that I was no that exact at my initial question. I thought that sudoing the techops user would maybe bypass this problem, but it does not. The problem itself is not to run the command without password prompt. (I could easily do that as techops user when I just execute /home/techops/publicapi start). The problem itself is to lock out the defaultuser from starting these services. And I hoped that any of the solutions could do that. I started with the approaches of Thomas. The approach with sudo works when I don't want to get asked for the password for the user techops when I execute the commands as explained, e.g. sudo systemctl start publicapi.service sudo systemctl stop publicapi.serviceThe second approach does not work for me yet. I cannot start the service without password prompt ==== AUTHENTICATING FOR org.freedesktop.systemd1.manage-units === and I stall can login as defaultuser when I have the password of this user. With the third approach, the service does not even start at boot process anymore so I'm not sure if this approach is the right one for me at all. I cannot even able it with systemctl enable publicapi.service which leads me to the following error: Failed to enable unit: Unit file mycuisine-publicapi.service does not exist.The error does no occur when I move all the services back into /etc/systemd/system/ and execute systemctl enable publicapi.service. Then the service starts again at boot. All these approaches will more or less help to bypass the password prompt for the techops user but when I run service publicapi stop or systemctl stop publicapi with defaultuser, I can stop the services if I have the password. But my target is to lock out defaultuser from starting or stopping services at all.
Restarting systemd service only as a specific user?
It depends on your Display Manager! (i.e. KDM, GDM) Please bear in mind your DM runs as root! (it needs root privileges in order to run your session process as the user you log in) When you click shutdown in KDE or GNOME, your DE sends a signal to your DM to power off or restart after the session has terminated. Then, your DE tells every program to end and once all other process has terminated (or expired a timeout), the last process of your DE -- the session process -- terminates. The session process is the first process started in an X11 session. When it's killed or it terminates, the session terminates. Have you ever seen that xterm when running X without DE? That is a session process. This process is called kdeinit in KDE and gnome-session in GNOME. Once the session has terminated, control is returned to your DM (which has been waiting for the X process to end), and it checks what the DE told him to do. If it told it to power off or restart, it will do that. In other case, it will just start a new login screen in X. This is also related with problems you may have had in the past, with some DE not being able to power off or restart, just to log out, when used in combination with some other DMs. In any case, this is not so bad documented. GDM has a manual page "gdm-control(1)" of a command which allows you to tell it to shut down just like I told before (gdm-control). KDM has excellent documentation too and has a similar (a little more complex) utility named kdmctl.Shutdown and restart is possible without PolicyKit, but PolicyKit serves many purposes needed on nowadays systems like mounting disks without being root, suspend or hibernate the computer. And it neither is bad documented! Check out this if you want to know more about what is PolicyKit and how does it work: http://www.freedesktop.org/software/polkit/docs/latest/polkit.8.html
I have been banging my head against this for quite a while now. It's related to this question. I would like to find out exactly what happens when I choose to shut down my Linux box from the GUI. This seems to be poorly (if at all) documented. Ideally, I'm hoping for a DE- and OS-agnostic answer. Barring that, I'm interested in the specific case of Mandriva 2010.1 and Debian 6.x (Squeeze) and 7.0 (Wheezy) all running Gnome. (If you're paying close attention, yes that's Gnome 2 and Gnome 3) Basically, I would like to know which command/script/sequence of scripts is started when I press "Shut Down" or "Restart" so I can modify their behavior. Some forum posts I looked at suggest hacking /etc/polkit-1/* but this directory structure is only a skeleton on my Debian (Squeeze) box, for example. Can anyone help?EDIT What I have tried so farReplaced the shutdown executable with a script of my own. This doesn't work: when I press shutdown Gnome logs out without executing my script. Tried editing the Gnome 2 menu. No joy: the "Shutdown", "Log out" and "Lock Screen" options do not appear in the menu editor. Looked at /usr/share/menu, nothing helpful there.Possible avenues for the solutionstraceing the GUI options (is this even possible?) Looking at shutdown's source code Looking at gnome-session's source codeUpdate As per my comments on the answer below, I have looked into polkit actions under /usr/share/polkit-1/actions/ and found (in the file org.freedesktop.consolekit.policy) an action called org.freedesktop.consolekit.system.stop-multiple-users that throws the message System policy prevents stopping the system when other users are logged inI'm thinking (due to the org.freedesktop.* naming convention) that this is some kind of signal sent to the DM via D-BUS. Moreover, this message appears when trying to shutdown graphically while other users are logged in, so the mechanism that triggers it must be the same mechanism triggered when "Shut Down" or "Power Off" is selected from the GUI. Can anyone confirm/refute? Is there a possibility of somehow intercepting this signal or modifying it?
What happens when I press "Shut Down" from the GUI?
This is an issue with polkit.service; it was not starting for me. After further investigation I found that the polkitd user did not exist. Then yum reinstall polkit and systemctl start polkit fixed the issue. I debugged this by running polkitd directly: /usr/lib/polkit-1/polkitd
I'm running CentOS 7.2; see below: # systemctl stop firewalld Error getting authority: Error initializing authority: Error calling StartServiceByName for org.freedesktop.PolicyKit1: Timeout was reached (g-io-error-quark, 24) Failed to stop firewalld.service: Connection timed out Failed to get load state of firewalld.service: Connection timed outjournalctl just reports the following error: [system] Failed to activate service 'org.freedesktop.PolicyKit1': timed out I found this bug for Ubuntu and a possible related one for a RHEL 7 bug.
systemctl keeps timing out on service restart
As weird as it may seem, trying running systemctl --force --force rebootIt has popped up in a couple of searches I made. It may be related to issues with a DBus service restarting. Can't reboot. Slow and timing out. Failed to start reboot.target: Connection timed out
I tried rebooting my CentOS 7 server but it gives ridiculous error messages. As root (of course): # systemctl reboot Authorization not available. Check if polkit service is running or see debug message for more information. Failed to start reboot.target: Connection timed out See system logs and 'systemctl status reboot.target' for details. Exit 1Does polkit need to check whether root has the right to reboot the machine??? If so, why? # systemctl status reboot.target ● reboot.target - Reboot Loaded: loaded (/usr/lib/systemd/system/reboot.target; disabled; vendor preset: disabled) Active: inactive (dead) Docs: man:systemd.special(7) Exit 3Do I need to enable the reboot target? Why would this be disabled by default? Perhaps this will work? # systemctl start reboot.target Authorization not available. Check if polkit service is running or see debug message for more information. Failed to start reboot.target: Connection timed out See system logs and 'systemctl status reboot.target' for details. Exit 1OK, force it, then: # systemctl --force reboot Authorization not available. Check if polkit service is running or see debug message for more information. Failed to execute operation: Connection timed out Exit 1And the server is still up.
How can I reboot a server with systemctl if systemctl reboot fails?
This is done via an authorization manager called polkit:polkit provides an authorization API intended to be used by privileged programs (“MECHANISMS”) offering service to unprivileged programs (“SUBJECTS”) often through some form of inter-process communication mechanism.With systemd and polkit users with non-remote session can issue power related commands. You can list all polkit registered actions and get details about any of them with pkaction (invoked with no arguments it will list all action ids). In this particular case the action id is org.freedesktop.login1.reboot so if you run: pkaction --action-id org.freedesktop.login1.reboot --verbosethe output should be something like: org.freedesktop.login1.reboot: description: Reboot the system message: Authentication is required for rebooting the system. vendor: The systemd Project vendor_url: http://www.freedesktop.org/wiki/Software/systemd icon: implicit any: auth_admin_keep implicit inactive: auth_admin_keep implicit active: yesHere, active: yes means the user in the active session is authorized to reboot the system (details about implicit authorizations on polkit page). You can check if your session is active with: loginctl show-session $XDG_SESSION_ID --property=Active Active=yes
I am reading the book Linux kernel development, in chapter 5 "System Call Implementation" page 77 says For example, capable(CAP_SYS_NICE) checks whether the caller has the ability to modify nice values of other processes. By default, the superuser possesses all capabilities and nonroot possesses none. For example, here is the reboot() system call. Note how its first step is ensuring that the calling process has the CAP_SYS_REBOOT . If that one conditional statement were removed, any process could reboot the system.However, in my Debian Sid I can reboot my machine by using gnome or by executing /sbin/reboot without sudo or su. How is this possible? Maybe with systemctl? ls -l /sbin/reboot lrwxrwxrwx 1 root root 14 Jun 28 04:23 /sbin/reboot -> /bin/systemctlEDIT: My user groups [damian@xvz:~]$ groups damian sudo wireshark bumblebeeEDIT 2: systemctl permissions [damian@xvz:~]$ ls -l /bin/systemctl -rwxr-xr-x 1 root root 626640 Jun 28 04:23 /bin/systemctl
How does gnome reboot without root privileges?
From section DECLARING ACTIONS of polkit - Authorization Framework:defaults This element is used to specify implicit authorizations for clients. Elements that can be used inside defaults includes: allow_any Implicit authorizations that apply to any client. Optional. allow_inactive Implicit authorizations that apply to clients in inactive sessions on local consoles. Optional. allow_active Implicit authorizations that apply to clients in active sessions on local consoles. Optional. Each of the allow_any, allow_inactive and allow_active elements can contain the following values: no Not authorized. yes Authorized. auth_self Authentication by the owner of the session that the client originates from is required. auth_admin Authentication by an administrative user is required. auth_self_keep Like auth_self but the authorization is kept for a brief period. auth_admin_keep Like auth_admin but the authorization is kept for a brief period.I hope this makes it clear for you.
I am using Ubuntu 16.04. There is a file located at /usr/share/polkit-1/actions/org.freedesktop.login1.policy which seems to control the permissions regarding shutdown/suspend/hibernate options. In this file, the revelant options are in this format: <defaults> <allow_any>no</allow_any> <allow_inactive>auth_admin_keep</allow_inactive> <allow_active>yes</allow_active> </defaults>corresponding to every action (shutdown, suspend etc.). Here is the full version of that file. I want to know the meaning of allow_any, allow_inactive and allow_active options. What do they mean exactly ? The reason for my curiosity is that I want to hibernate non-interactively without root (from cron), but am getting authorization errors. And it seems that those errors can be solved by modifying this file.
Explanation of file - org.freedesktop.login1.policy
With the visudo command you edited the file /etc/sudoers, which only applies if you prefix your commands with sudo, in your case sudo service nginx start.
I'm pretty new to the deployment world but this is what's going on. I have a new Ubuntu (Ubuntu 16.04.4 LTS) droplet from DigitalOcean. I installed and configured nginx and everything is working smooth. I turn it on and off with: service nginx start/service nginx stop but I need to be able to do this with a different user called pepito. When I try to run service nginx start with pepito I get: ~# service nginx restart ==== AUTHENTICATING FOR org.freedesktop.systemd1.manage-units === Authentication is required to restart 'nginx.service'. Authenticating as: pepito Password: But I'm going to be running this from Capistrano so I don't want to be asked to enter the password, so I added this to visudo like this: pepito ALL=(ALL) NOPASSWD: /usr/sbin/service nginx*Tried again and same problem. Keep googling and reading and find out that ==== AUTHENTICATING FOR org.freedesktop.systemd1.manage-units === is a message from Polkit so I read a little about it and created the following file in: /etc/polkit-1/localauthority/50-local.d/nginx.pkla Identity=unix-user:pepito Action=org.freedesktop.systemd1.manage-units ResultInactive=yes ResultActive=yesOf course it doesn't work when I try to start and stop nginx from pepito. I don't know what else to try!
Trying to run "service nginx restart" from a non root user
it's not possible. This feature was implemented for the .rules-variant only https://github.com/systemd/systemd/pull/1159
I'm trying to allow users of a somegroup to manage someunit systemd service. In polkit (>=0.106), this can be done by adding rules: /etc/polkit-1/rules.d/20-someunit.rules --- polkit.addRule(function(action, subject) { if (action.id == "org.freedesktop.systemd1.manage-units" && subject.isInGroup("somegroup") && (action.lookup("unit") == "someunit.service") ) { var verb = action.lookup("verb"); if (verb == "start" || verb == "stop" || verb == "restart") { return polkit.Result.YES; } } });However, I'm on Debian stretch/buster where we have been on polkit 0.105 since 2012. polkit(<0.106) doesn't support the rules.d/* files. Instead, we rely on /etc/polkit-1/localauthority/50-local.d/*.pkla. Following some examples in pklocalauthority(8), I'm able to get most of this working in an equivalent pkla file: /etc/polkit-1/localauthority/50-local.d/manage-units.pkla ---- [Allow users to manage services] Identity=unix-group:somegroup Action=org.freedesktop.systemd1.manage-units ResultActive=yesHowever, this grants access for ALL actions on ALL services. Is there an equivalent to permitting specific action.lookup() features? I did try out systemctl enable and systemctl edit, of which both still failed (that's good). So action.lookup("verb") may not be required, but action.lookup("unit") is still quite important. There are a lot of unanswered questions on this subject:https://askubuntu.com/questions/536591 https://askubuntu.com/questions/875522 polkit rule is not working
systemd service management using pkla equivalents to polkit's rules on Debian
The Arch Wiki has a section on the udev page that covers the many ways you can set up automounting. With a minimal install (without a DE), you can use a udev rule—there are several examples included on the page—or udisks and one of the wrappers like udiskie, or something even simpler like ldm that requires no other tools. My preference is for udiskie and the storage group. Essentially, it is just a matter of starting udiskie in your .xinitrc and creating /etc/polkit-1/localauthority/50-local.d/10-udiskie.pkla: [Local Users] Identity=unix-group:storage Action=org.freedesktop.udisks.* ResultAny=yes ResultInactive=no ResultActive=yes Anyone in the storage group will now be able to mount and unmount devices.
I just setup a minimal installation of Arch , installed gvfs , thunar-volman. But mounting disk requires password , this shouldn't happen. How should I work it out ?
Arch Linux , mount disks with thunar , without password
This is pretty complicated. Let's explain the commands in order you've enumerated them.telinit Various arguments to telinit directly translate to various (different) subcommands of systemctl. As per telinit(8) (documentation from systemd package):2, 3, 4, 5 Change the SysV runlevel. This is translated into an activation request for runlevel2.target, runlevel3.target, ... and is equivalent to systemctl isolate runlevel2.target, systemctl isolate runlevel3.target, ...So, these commands translate to systemctl isolate, which itself is governed by polkit action org.freedesktop.systemd1.manage-units. Privileges for that action default to requiring admin authentication — both for active sessions, inactive sessions and processes outside of any session. (BTW, by default polkit is configured such that it treats any user in wheel group as an admin. Thus you were prompted to authenticate for yourself.) halt, poweroff, reboot Commands poweroff and reboot work in two steps:if invoked under a non-root-user and logind is available, logind is asked to perform the action, using polkit actions org.freedesktop.login1.*; otherwise, the almost-equivalent of systemctl poweroff or systemctl reboot is executed, but without consulting polkit.halt is similar, but it always goes the second route (almost-equivalent of systemctl halt). There is no method for halting via logind. Note the "almost-equivalent". In case you dopoweroff under a non-root without logind, reboot under a non-root without logind, halt under a non-root,you get a "Must be root." instead of authenticating for org.freedesktop.systemd1.manage-units via polkit. At the same time, with systemctl poweroff, systemctl reboot or systemctl halt you will be given a chance to authenticate via polkit. This is probably a bug. shutdown This tool can be used to schedule a delayed poweroff, halt or reboot. If invoked without arguments, a delay of 1 minute is implied. The default action is power-off. From shutdown(8):The time string may either be in the format "hh:mm" for hour/minutes specifying the time to execute the shutdown at, specified in 24h clock format. Alternatively it may be in the syntax "+m" referring to the specified number of minutes m from now. "now" is an alias for "+0", i.e. for triggering an immediate shutdown. If no time argument is specified, "+1" is implied.If timeout and wall message are not specified, shutdown is equivalent to one of poweroff, halt or reboot (see #2). If either a timeout or a wall message is specified, shutdown requires root privileges. poweroff doesn't power off It really should. This is probably a kernel bug.
On Arch Linux, with systemd, the following commands are all symlinks to systemctl: /usr/bin/telinit /usr/bin/poweroff /usr/bin/runlevel /usr/bin/reboot /usr/bin/halt /usr/bin/shutdownI find their behaviour with respect to authorization confusing: $ shutdown Must be root. $ halt Must be root. $ telinit 3 # Asks for Polkit authorizationNeither poweroff nor reboot asks for authorization. poweroff doesn't actually turn off my system, the laptop remains on with text on the screen stating it is powering off - indefinitely. I haven't tinkered with Polkit rules, so I wonder why their behaviour is so.All commands were tried with my non-root admin user, who's a member of wheel. /etc/polkit-1/rules.d only seems to contain a default ruleset: # tail /etc/polkit-1/rules.d/* // DO NOT EDIT THIS FILE, it will be overwritten on update // // Default rules for polkit // // See the polkit(8) man page for more information // about configuring polkit.polkit.addAdminRule(function(action, subject) { return ["unix-group:wheel"]; });On closer inspection, /usr/share/polkit-1/actions/org.freedesktop.login1.policy has sections for poweroff, reboot, suspend and hibernate, with allow_active set to yes. But there are no sections for shutdown. If this is the cause, why is it so?
What are the default Polkit privileges on Arch Linux for shutdown, halt, etc., and why are they so?
Old answer.: May you take pkexec out of the script? Try create next script where you paste your code (without pkexec) and execute him via pkexec from your script. your script: #!/bin/bash pkexec ./new_script new script: #!/bin/bash your command: Edit.: New Answer After your conversation with @Thrig, I guess what you are going to do. You want to run both programs on root permissions without double authentication (only once). These two programs are: "virsh" and "gnome-boxes". My previous (above) solution is ok, but not in this case. You wrote to @Thrig that you are considering using "sudo". Why not use "pkexec" and "sudo" together. With the proper completion of "/ etc / sudoers" you will not need to authenticate when you use the "sudo" command in the script. I let myself improve your idea. I hope you like it. I will describe everything step by step. 1. Create three scripts: a) main.sh - set up the connection, destroy the connection, run gnome-boxes. everything as root b) net.sh - execute the order c) die.sh - execute the order a) #!/Bin/bash sudo /home/ham/..your..path../net.sh && pkexec /usr/bin/gnome-boxes; sudo /home/ham/..your..path../die.sh; exitwhy that? description of operators b) #!/Bin/bash virsh net-start defaultc) #!/Bin/bash virsh net-destroy default2. Edit the "sudoers" file to make the script: b) c) run with root privileges: $ sudo nano /etc/sudoers %sudo ALL=(root) NOPASSWD: /home/..your..path../net.sh %sudo ALL=(root) NOPASSWD: /home/..your..path../die.sh 3. Change the owner of the scripts b) c) to root: $ sudo chown 700 /home/ham/..your..path../net.sh $ sudo chown 700 /home/ham/..your..path../die.sh;4. Create a rule in polkit for gnome-boxes. The answer: "how to do it?" is here: simple_polkit_rule 5. Edit files:org.gnome.Boxes.service Exec=/home/..your..path../start.sh org.gnome.Boxes.desktop Exec=/home/..your..path../start.sh6. Now run the gnome-boxes application by clicking on its shortcut icon. Finished. From myself I added auto turn off connection when you close the gnome-boxes application.
Someone could answer me how make one prompt via pkexec when I've to use two command with authentication? My easy sample script: pkexec virsh net-start default; pkexec "/home/user/program";I'm new in linux environmen, Thanks :)
One prompt pkexec - two command
Problem was due to /proc mount option hidepid. Mint 17.3 to 18 changed the init system to systemd and systemd has no support for hidepid.
The polkit-gnome-authentication-agent-1 doesn't autostart while it has correct /etc/xdg/autostart/polkit-gnome-authentication-agent-1.desktop file with this content [Desktop Entry] Name=PolicyKit Authentication Agent Comment=PolicyKit Authentication Agent Exec=/usr/lib/policykit-1-gnome/polkit-gnome-authentication-agent-1 Terminal=false Type=Application Categories= NoDisplay=true OnlyShowIn=GNOME;XFCE;Unity; X-GNOME-AutoRestart=true AutostartCondition=GNOME3 unless-session gnome X-Ubuntu-Gettext-Domain=polkit-gnome-1The user doesn't have a ~/.config/autostart/polkit-gnome-authentication-agent-1.desktop file This breaks synaptic-pkexec and other tools that rely on policykit. Problem seems similar to this, but this post is without resolution. Launching process manually works and functionality is restored for that session or until the terminal used to launch the process manually is closed. Here are dpkg.log and apt history.log
polkit-gnome-authentication-agent-1 doesn't auto start after upgrade
As nc3b already pointed out, this gets controlled by PolicyKit. The policy for disks is located at: /usr/share/polkit-1/actions/org.freedesktop.udisks.policy and can be adjusted. Open it with root rights and search for the line: <action id="org.freedesktop.udisks.change">, either comment out the whole block: <!-- [udisks.change-block] -->, or set <allow_active> to 'no', save and exit. Check if it's disabled: $ pkaction --verbose --action-id org.freedesktop.udisks.change No action with action id org.freedesktop.udisks.changeOr if you've set no: ... implicit active: noGood, next time you try to format a device as a non-root user, either over the context menu or over 'Disk Utility', an error message will appear an disallow it. This step will still allow the non-root user to read/write the device.If you still want to allow formating of devices, but with a higher security level, you can force PolicyKit to ask for a password every time. Open the same file and go to the same section, substitute the 'yes' with 'auth_admin' in allow_active: <allow_active>auth_admin</allow_active>Check: $ pkaction --verbose --action-id org.freedesktop.udisks.change ... implicit active: auth_adminExcellent! Note: I've only tested this on Ubuntu, but Fedora also uses PolicyKit, so try it with a dummy drive first.
Few days back I mistakenly formatted a partition on my external hard drive by clicking Format from the Context menu in Computer. I want to know that how can I prevent non-root user from being able to do so. At the same time I need the non-root user to be able to read and write on the partition. I use Fedora 14. Thanks.
Prevent non-root user from formatting a partition
Unfortunately the timeout appears to be hard-coded as 5 minutes in the PolicyKit upstream source, in file src/polkitbackend/polkitbackendinteractiveauthority.c. On lines 3231-3236 it says: /* TODO: right now the time the temporary authorization is kept is hard-coded - we * could make it a propery on the PolkitBackendInteractiveAuthority class (so * the local authority could read it from a config file) or a vfunc * (so the local authority could read it from an annotation on the action). */ expiration_seconds = 5 * 60;So, the timeout is set to 5 minutes within the source code, and there are currently no provisions for changing it without recompiling the appropriate parts of PolicyKit. On the other hand, OpenSuSE Leap 15 seems to have extended this functionality. They seem to have re-interpreted the ..._keep actions to mean "remember authentication while the asking process is running", and added ..._keep_session and ..._keep_always actions to mean "remember for the entirety of this specific login session" and "remember forever", respectively.
I was just reading the reference manual written by David Z for pkexec on freedesktop.org: https://www.freedesktop.org/software/polkit/docs/latest/polkit.8.html and https://www.freedesktop.org/software/polkit/docs/latest/pkexec.1.html Manual says that using the auth_admin_keep option will only keep your password for 5 to 15 minutes and that if we want to set custom timeouts we have write custom rules. Would anyone know how I can go about writing a custom rules for the timeout? I tried to follow along with the manual but I'm not a coder and I wasn't being able to understand the synthax, no were there any mentions made of timeout related synthax.
pkexec - how do I set a custom timeout for auth_admin_keep when writting a pkexec policy
I think you can do in this way: in /etc/libvirt/libvirtd.conf unix_sock_group = "libvirt" unix_sock_rw_perms = "0770" auth_unix_rw = "none"After that restart the libvirtd daemon
I've installed Xen and libvirt on a CentOS 6.6 machine. All the tools (virt-manager, virsh etc) work perfectly as root (directly or via sudo) but I cannot allow another user to connect (failed to connect/DBus error). My Configuration I followed the procedure for allowing user access by creating a group and allowing this through polkit so I've: groupadd virtadmin usermod -a -G virtadmin davecI also added myself to the KVM group (a suggestion found somewhere). The group is created and I'm in it as id outputs: uid=500(davec) gid=500(davec) groups=500(davec),36(kvm),501(virtadmin)To allow this in polkit I added the file /etc/polkit-1/localauthority/50-local.d/50-libvert-remote-access.pkla content: Remote libvirt SSH access] Identity:unix-group:virtadmin Action:org.libvirt.unix.manage ResultAny=yes ResultInactive=yes ResultActive=yesAfter this didn't work some googling told me that newer polkit versions (yum tells me I have 0.96) use a rules-based approach so I've also created a folder /etc/polkit-1/rules.d and added the file 80-libvirt-manage.rules containing: polkit.addRule(function(action, subject) { if (action.id == "org.libvirt.unix.manage" && subject.local && subject.active && subject.isInGroup("virtadmin")) { return polkit.Result.YES; } });Now it may be that there is some problem with these but I can't find a log or any way it seems to test/verify/watch them. So, according to the docs I've found, with that setup user davec should be able to access libvirt and run virsh or virt-manager. The Error [davec@polar rules.d]$ virsh -c xen:/// error: failed to connect to the hypervisor error: internal error: DBus support not compiled into this binaryThis is exactly the same error virt-manager gives when I try and connect. Most of the online info about the DBus error refers to a problem with the hypervisor running/anyone connecting however root connects perfectly. [davec@polar rules.d]$ sudo virsh -c xen:/// Welcome to virsh, the virtualization interactive terminal.Exactly the same applies for SSH connections (which isn't surprising as SSH just tunnels I believe when you use a xen+ssh URI), root works non-root but group added user doesn't. No doubt it's something simple and I'm being an idiot but... after a few days of Google not being my friend; any help truly appreciated. The Answer See below for c4f4t0r's correct (and accepted) answer which wins the bounty but just for info of anyone reading this it turns out to be nothing to do with polkit which doesn't appear to be configured/compiled/working with my libvirtd. Was an in-built permissions (socket permissions) issue.
Xen libvirt access for non-root user
According to this Debian bug report, this is due to an upstream change in ConsoleKit between versions 0.4.1 and 0.4.2. The thread contains a few suggestions and workarounds, one of which is to install a display manager (like GDM or lightdm) that talks with ConsoleKit directly.
I found the following command line to shut down a Debian/GNU Linux system dbus-send \ --system \ --dest=org.freedesktop.ConsoleKit \ --type=method_call \ --print-reply \ --reply-timeout=2000 \ /org/freedesktop/ConsoleKit/Manager \ org.freedesktop.ConsoleKit.Manager.StopIt works if I execute the command as superuser, but as a non-privileged user it says: Error org.freedesktop.ConsoleKit.Manager.NotPrivileged: Not AuthorizedI would like to know if it is possible to modify such a command in such a way that, interacting with PolicyKit, it can grant the privilege to shut down the system to a normal user.
How do I shut down a system through a ConsoleKit DBus message as user?
Uff. Solved this one, thanks to the help of another programmer who sent links to good manual pages: https://www.freedesktop.org/software/polkit/docs/latest/polkit.8.html and mainly https://developer.mozilla.org/en-US/docs/Web/JavaScript/Guide/Regular_Expressions which explains relevant things from JavaScript programming language. As expected, I only changed one line that deals with name of the service. polkit.addRule(function(action, subject) { if (action.id == "org.freedesktop.systemd1.manage-units" && RegExp('my-daemon@[A-Za-z0-9_-]+.service').test(action.lookup("unit")) === true && subject.user == "foo1") { return polkit.Result.YES; } });RegExp() is a function, and .test in the middle of the line tests the regular expression in ' ' to another string, which is function asking for name of the service. Hope it helps someone else stuck on similar issues.
I am trying to use polkit to allow specific user to start/stop/restart specific services. Those services are defined via systemd template, so for example user can run this command: systmctl stop my-daemon@<parameter>.service. Parameter is alphanumeric string, user defined. This polkit rule works perfectly: polkit.addRule(function(action, subject) { if (action.id == "org.freedesktop.systemd1.manage-units" && action.lookup("unit") == "[emailprotected]" && subject.user == "user1") { return polkit.Result.YES; }However, it's for static parameter, foo1 and it won't work with any other parameter. I have tried regexp to make the rule generic, here are some examples of critical, third line of the rule: action.lookup("unit") == "my-daemon@*" && action.lookup("unit") == "my-daemon@[:alnum:]+" && action.lookup("unit") == "my-daemon@foo[0-9]" &&None of the above works. Seems to me polkit does not allow regexp in this place. I have read Polkit rule for systemd template unit files, but it isn't a solution for me - author is testing filename, not directly unit name. What am I doing wrong? This is continuation of my previous question Controlling systemd system service as user, however before I had old systemd and it wasn't possible to write even the static rule. Now it should be possible and I am failing miserably. OS Suse 12.5 Polkit version 0.113 Systemd version 228
Polkit rule for systemd template files - how to
Rules of this sort, whether polkit or udev are no longer necessary if you have an active session under systemd/logind. Originally, rules of this sort were a workaround for non-consolekit sessions, but now Arch has moved to systemd they are no longer necessary and are more likely to inhibit correct automounting behaviour rather than assist it. You can check that you have an active session with: loginctl show-session $XDG_SESSION_ID which should show amongst its output: Remote=no Active=yes If this doesn't show, and you are not using a display manager, you need to ensure that when you start X your session is preserved—so X must be run on the same TTY where login occurred. See this entry on the Arch Wiki.
Today, I got a Not authorized to perform operation. message when I tried to mount a drive in Thunar. # cat /etc/polkit-1/localauthority/50-local.d/10-udiskie.pkla [Local Users] Identity=unix-group:storage Action=org.freedesktop.udisks2.* ResultAny=yes ResultInactive=no ResultActive=yesI'm in the storage group.
Can't mount drive in Thunar anymore
It's customary that building a program doesn't require root access, but installing it often does. So it's pretty normal to run make sudo make installOr, when building software to include into a package, something like: make mkdir install-root fakeroot -- sh -c 'make PREFIX="$PWD/install-root/usr/local" install && cd install-root && tar -czf ../package.tgz .'
I understand that a Makefile should not require the user to be root. So I'm using /usr/local like this: PREFIX=/usr/localinstall: install -D example $(PREFIX)/bin/exampleThat works fine. But I also need to install a policy file for polkit. And the only valid path for those is /usr/share/polkit-1/actions/. If I try to use install, I get the following error: install: cannot create regular file '/usr/share/polkit-1/actions/com.example.policy': Permission deniedHow am I supposed to install my policy file if I can't ask the user to run make as root?
If make isn't supposed to run as root, then how can I install a policy file?
In systemd and related utilities, the actions that might require privileged access are routed through PolicyKit. Run pkaction without any parameters to see the list of all the possible actions handled by PolicyKit. To see the current policy for a specific action, use pkaction --verbose --action-id <action identifier. For example, changing the hostname: # pkaction | grep host org.freedesktop.hostname1.set-hostname org.freedesktop.hostname1.set-machine-info org.freedesktop.hostname1.set-static-hostname# pkaction --verbose --action-id org.freedesktop.hostname1.set-hostname org.freedesktop.hostname1.set-hostname: description: Set host name message: Authentication is required to set the local host name. vendor: The systemd Project vendor_url: http://www.freedesktop.org/wiki/Software/systemd icon: implicit any: auth_admin_keep implicit inactive: auth_admin_keep implicit active: auth_admin_keepSo the current policy on my system for hostname changes is auth_admin_keep - that is, require a password of an administrator unless the user has very recently successfully passed a similar check (just like sudo it can avoid consecutive password requests). And who is an administrator whose password can authorize these actions? On my Debian 9 system, this is determined by files in /etc/polkit-1/localauthority.conf.d/ directory - by default, only root and members of the sudo user group will qualify. If you don't like this policy, you can easily change it by writing some custom PolicyKit configuration files. PolicyKit can be configured to require any the following "security levels" for any action managed by it:yes - user can always do it, no questions asked auth_self_keep - if the user hasn't recently done anything requiring a password check, request user's password to ensure it's really him/her. If multiple consecutive actions of this level are executed within a few-minute window, the checks can be skipped after the first one. auth_self - always require user's password check auth_admin_keep - require the password of an administrative user. Just like auth_self_keep, after the password (and optionally the admin username) is entered once, the user can execute multiple actions of this level within a brief time window without further password requests auth_admin- always require a password check, and the user responding to the password check must be one of the administrative users no - the action is rejected without any further questions. The time the ..._keep results are maintained is apparently hard-coded in PolicyKit upstream code: here's a link to PolicyKit Git. /* TODO: right now the time the temporary authorization is kept is hard-coded - we * could make it a propery on the PolkitBackendInteractiveAuthority class (so * the local authority could read it from a config file) or a vfunc * (so the local authority could read it from an annotation on the action). */ expiration_seconds = 5 * 60;There does not currently seem to be any provisions for configuring this value at run-time, nor for extending the authentication time-stamp once it's set. OpenSuSE seems to have extended this with ...keep_session and ...keep_always results. Apparently they've also reinterpreted the ...keep actions to mean "remember the result for as long as the asking process keeps running."
It seems that the new way to change the hostname with systemd is: hostnamectl set-hostname NEWNAMEHowever, this does not require a password when logged in as a user with admin rights (not sure which group counts). In the case of non-admin users, it pops up a dialog requesting the password for one of the privileged users. I think "shutdown -h now" even works for non-admin users. I assume these are both new systemd-related commands. How do they check if the user submitting the commands has the rights to run them? How can I make them ask for a password or require sudo?
Why does hostnamectl not require a password to change the hostname?
The directory /etc/polkit-1/localauthority.conf.d is reserved for configuration files. You should put your file in a subdirectory of /var/lib/polkit-1/localauthority and with extension .pkla. The directory /etc/polkit-1/localauthority should be ok too, but can be modified by updagraded/installed packages, so better to avoid it.
On OpenSUSE 12.1 x86_64, Gnome 3.2 . I want to remove the suspend and hibernate options from the Gnome (Shell) menu assuspend makes no sense IMO for a desktop hibernate has a slight tendency to lock upI've found that I should configure these privileges using polkit. I've dropped a file named 90-disable-suspend.conf ( also tried 90-disable-suspend.pkla ) in /etc/polkit-1/localauthority.conf.d with the following contents: [Disable Suspend] Identity=unix-user:* Action=org.freedesktop.upower.hibernate;org.freedesktop.upower.suspend ResultAny=no ResultInactive=no ResultActive=noHowever, running pkcheck --action-id org.freedesktop.upower.suspend --process $$ prints nothing and has an exit code of 0 , and the menu entries are still present. AFAICT these are provided by gnome-shell-extension-alt-status-menu package. How can I remove the suspend and hibernate entries from the Gnome Shell menu and leave only Power Off?
Removing supend and hibernate privileges
D-Bus Check that there are no dbus policies in /usr/share/dbus-1/system.d or /etc/dbus-1/system.d that explicitly deny unprivileged access to members of org.freedesktop.login1 related to the system suspension. You can use the following policy to allow unprivileged users to invoke org.freedesktop.login1.Manager.Suspend and org.freedesktop.login1.Manager.SuspendWithFlags <?xml version="1.0"?> <!--*-nxml-*--> <!DOCTYPE busconfig PUBLIC "-//freedesktop//DTD D-BUS Bus Configuration 1.0//EN" "https://www.freedesktop.org/standards/dbus/1.0/busconfig.dtd"> <busconfig> <policy context="default"> <allow send_destination="org.freedesktop.login1" send_interface="org.freedesktop.login1.Manager" send_member="Suspend"/> <allow send_destination="org.freedesktop.login1" send_interface="org.freedesktop.login1.Manager" send_member="SuspendWithFlags"/> </policy> </busconfig>Save this policy file as /etc/dbus-1/system.d/org.freedesktop.login1.conf and reload the dbus daemon with systemctl reload dbus. Polkit You can add the following rule to allow regular users to suspend the system without authentication. // vi: ft=javascript Array.prototype.includes = function (variable) { for (var i = 0; i < this.length; i++) { if (this[i] === variable) return true; } return false; }polkit.addRule(function (action, subject) { if ( [ "org.freedesktop.login1.suspend", "org.freedesktop.login1.suspend-ignore-inhibit", "org.freedesktop.login1.suspend-multiple-sessions" ].includes(action.id) && // Allow user named "user_name" or users in group "wheel" to suspend this system, // Modify accordingly to suit your system (subject.user == "user_name" || subject.isInGroup("wheel")) ) { return polkit.Result.YES; } });Change "user_name" to your username Save this rule as /etc/polkit-1/rules.d/01-suspend.rules, it will take effect immediately.
After a recent update on an Ubuntu 20.04: $ systemctl suspend Call to Suspend failed: Access deniedSome weeks ago worked fine this way, without any root privileges. On journal:dbus-daemon[1310]: [system] Rejected send message, 2 matched rules; type="method_call", sender=":1.991" (uid=1000 pid=683426 comm="systemctl suspend " label="unconfined") interface="org.freedesktop.login1.Manager" member="SuspendWithFlags" error name="(unset)" requested_reply="0" destination="org.freedesktop.login1" (uid=0 pid=1512 comm="/lib/systemd/systemd-logind " label="unconfined")FromThe "rejected send message" is the dbus equivalent of "permission denied". And the reason why the permission is denied depend on the sender, the destination, the interface and the member.A simple search return mostly issues related with hibernate. One way (1, 2) could be to add NOPASSWD to sudoers file (not the same), but seems a polkit issue. What package update cause this behavior? There is other (maybe more elegant) solution other than editing sudoer file? Edit: $ grep -ri org.freedesktop.login1.suspend /usr/share/polkit-1/ /usr/share/polkit-1/actions/org.freedesktop.login1.policy: <action id="org.freedesktop.login1.suspend"> /usr/share/polkit-1/actions/org.freedesktop.login1.policy: <action id="org.freedesktop.login1.suspend-multiple-sessions"> /usr/share/polkit-1/actions/org.freedesktop.login1.policy: <annotate key="org.freedesktop.policykit.imply">org.freedesktop.login1.suspend</annotate> /usr/share/polkit-1/actions/org.freedesktop.login1.policy: <action id="org.freedesktop.login1.suspend-ignore-inhibit"> /usr/share/polkit-1/actions/org.freedesktop.login1.policy: <annotate key="org.freedesktop.policykit.imply">org.freedesktop.login1.suspend</annotate>$ grep -i suspend /usr/share/dbus-1/system.d/org.freedesktop.login1.conf send_member="Suspend"/> send_member="SuspendThenHibernate"/> send_member="CanSuspend"/> send_member="CanSuspendThenHibernate"/>For some reason, using other similar regular user systemctl suspend -i works flawlessly. Tried also this with Result.YES. Using busctl monitor: ‣ Type=error ... Sender=org.freedesktop.DBus Destination=:1.4594 ErrorName=org.freedesktop.DBus.Error.AccessDenied ErrorMessage="Rejected send message, 2 matched rules; type="method_call", sender=":1.4594" (uid=1000 pid=636652 comm="systemctl suspend -i " label="unconfined") interface="org.freedesktop.login1.Manager" member="SuspendWithFlags" error name="(unset)" requested_reply="0" destination="org.freedesktop.login1" (uid=0 pid=1512 comm="/lib/systemd/systemd-logind " label="unconfined")" MESSAGE "s" { STRING "Rejected send message, 2 matched rules; type="method_call", sender=":1.4594" (uid=1000 pid=636652 comm="systemctl suspend -i " label="unconfined") interface="org.freedesktop.login1.Manager" member="SuspendWithFlags" error name="(unset)" requested_reply="0" destination="org.freedesktop.login1" (uid=0 pid=1512 comm="/lib/systemd/systemd-logind " label="unconfined")"; };I had the same issue with systemctl reboot/RebootWithFlags. Same solution, added to /usr/share/dbus-1/system.d/org.freedesktop.login1.conf (part of systemd package).
systemctl suspend, Call to Suspend failed: Access denied
Ok thinking on this, probably “guest” is sudoer. Remove guest from sudoer: -sudo visudo and add comment # on guest line -remove gest from sudo group using sudo usermod -G guest guest ( look at usermod manual to see proper way to keep all groups but sudo, if other groups are present) Then try again to mount If admin password asked and you do not remember root password just do sudo su then passwd and add a new password Mount the disk with Admin password
I am on Debian 10 Buster. When using Nautilus (aka Files), I am always asked for my password when trying to mount another HDD. All normal. A few days ago, I am not asked for my account password anymore, but for another account password. So, my main account is in the sudo group. I also have a second account named 'guest'. I am not sure what happened so now every time I try to mount a secondary HDD I am asked for the 'Guest' password instead of my main account password (where I am logged in). Any help? Thanks Edit: If anyone want to know more about this, you can also read the answers on this question: question
Why I am asked for the password of a different account when trying to mount a disk?
Debian Testing Buster use polkit 1.05, so there is no rule files and no js syntax. You must use the old policykit ini-style. To prevent users to start shutdown or reboot when another user is logged in, you must create two pkla files in /etc/polkit-1/localauthority/50-local.d/ cat /etc/polkit-1/localauthority/50-local.d/Reject_All_Users_To_login1_power-off-multiple-sessions.pkla [Reject all users to use login1_power-off-multiple-sessions] Identity=unix-user:* Action=org.freedesktop.login1.power-off-multiple-sessions ResultAny=no ResultInactive=no ResultActive=nocat /etc/polkit-1/localauthority/50-local.d/Reject_All_Users_To_login1_reboot-multiple-sessions.pkla [Reject all users to use login1_reboot-multiple-sessions] Identity=unix-user:* Action=org.freedesktop.login1.reboot-multiple-sessions ResultAny=no ResultInactive=no ResultActive=noBut, it is not enough, because xfce too install a action to shutdown or reboot in /usr/share/polkit-1/actions/org.xfce.session.policy. You must also create a pkla file for this action in /etc/polkit-1/localauthority/50-local.d/ cat /etc/polkit-1/localauthority/50-local.d/Reject_All_Users_To_Use_Xfce_Session_Policy.pkla [Reject all users to use xfce_session_policy] Identity=unix-user:* Action=org.xfce.session.xfsm-shutdown-helper ResultAny=no ResultInactive=no ResultActive=no
I want to prevent users to start shutdown or reboot when another user is logged in. Users can be a TTY user (Ctrl+Alt+F3) or a ssh user from a client host. In OpenBSD, I use polkit org.xfce.session.policy with a rule file to prevent such actions. I need to find how to do this in Debian Testing (aka Buster). I found org.freedesktop.login1.policy with actions org.freedesktop.login1.power-off org.freedesktop.login1.power-off-multiple-sessions.and made rule files for these actions but it does not block shutdown or restart. It seems to me that polkit is not responsible alone for these actions. I don't know where to look for this; perhaps systemd or PAM ? EDIT On OpenBSD and NetBSD, by default, nobody is allowed to shutdown or reboot from GUI. You must create a rule file in /usr/local/share/polkit-1/rules.d/ like this one : polkit.addRule (function (action, subject) { if (action.id == "org.xfce.session.xfsm-shutdown-helper") { return polkit.Result.YES; } });On Debian, by default, all users can shutdown or reboot from GUI. There is no rule file for org.xfce.session.xfsm-shutdown-helper or org.freedesktop.login1.power-off. I try to add my rule file with return polkit.Result.NO; with no avail On debian, i use lightdm and on BSD, i use xdm.
How to block shutdown or reboot in Debian xfce when other users logged in
Presumably the commands run by at are in a different environment, without access to your tty device and dbus settings and so on. Systemd has its own version of the at command. You can use it to run your command in an environment that seems to be ok for further systemd commands. So use the equivalent command: systemd-run --user --on-active=5min /bin/systemctl suspendFor perfect accuracy in the wait time of 5 minutes, you need to add option --timer-property=AccuracySec=1.
I'd like to suspend my laptop using at: echo "systemctl suspend" | at now + 5 minutesSuspension does not happen, instead I find a mail from at in /var/spool/mail/me: Failed to set wall message, ignoring: Interactive authentication required. Failed to suspend system via logind: Interactive authentication required. Failed to start suspend.target: Interactive authentication required. See system logs and 'systemctl status suspend.target' for details.Alright, logind requires authentication when at runs systemctl suspend. This is interesting since when I run systemctl suspend directly, without at, no authentication is required and the machine goes into suspension. I've made sure that the commands executed with at are run by the same non-root user as the commands run directly using echo "echo $(who) > who.txt" | at now. Suspecting that authentication is required in at because it runs the commands via /bin/sh (which is an alias for bash), I executed systemctl suspend after starting /bin/sh: Suspending happens immediately without authentication, indicating that the nested shell is not the reason why suspending fails when done with at. I get the same behavior and very similar mails when doing echo "reboot" | at now and echo "shutdown now" | at now. My question is: How does logind figure out that it's at that tries to suspend, reboot, or shut down the machine and how can I tell logind that it should allow at to execute those commands without authentication?I'm on Arch Linux 4.18.1 with at version 3.1.19.
Shutdown, suspend require authentication when scheduled in at
I think I have figured out what the issue was with this. It seems that after the system update, polkitd wasn't being started on boot, which is obviously why the authentication agent wasn't able to connect. I re-installed the polkit package and now polkitd is starting correctly. (I have no idea what was causing it to not start previously though)
I am using Arch Linux on an x86_64 desktop. Since a recent full system update, it seems my polkit-mate-authentication-agent will not start. If I try to start it manually from the command line, I get the following error: $ ./polkit-mate-authentication-agent-1 (polkit-mate-authentication-agent-1:2709): polkit-mate-1-WARNING **: 19:55:48.909: Error getting authority: Error initializing authority: Error calling StartServiceByName for org.freedesktop.PolicyKit1: Launch helper exited with unknown return code 127Does anyone know what the problem might be, or how I can diagnose it?
polkit-mate-authentication-agent won't start - "Error getting authority"
I use dwm as well, I have in a .xinitrc file, with a polkit to start at login. I use the xfce-polkit. /usr/lib/xfce-polkit/xfce-polkit &As an example I also use Thunar as my file manager and have a custom action that calls a root session of Thunar using pkexec. Using the polkit will give you the same DE behaviour with dwm.
I am really struggling to get the session polkit to work. I am not really familiar with how it works, but I have been using gnome before switching to dwm and in gnome it worked perfectly, so I wanted to replicate that. First of all: As I understood it, the polkit is responsible for giving momentary privilege escalation to the user, by prompting him for the root password. Is this correct? How can I replicate that behavior without a DE but with a WM like dwm?
dwm - session polkit
The encountered error which is missing policykit-authentication-agent dependency package does not look essential to run gparted. You can try dnf download gparted sudo rpm -i gparted-downloaded-package-name.rpm --nodeps sudo gparted
In CentOS 8.0 Server with desktop, I am trying to install gparted. It's not in the native software app, so I tried: sudo yum install epel-release sudo yum install gpartedand when I ran the latter, I see Error: Problem: conflicting requests - nothing provides PolicyKit-authentication-agent needed by gparted-1.0.0.4.el8.x86_64 (try to add '--skip-broken' to skip uninstallables packages)When I did, I saw: Last metadata expiration check: 1 day, 2:43:25 ago,..... Dependencies resolved. Nothing to do. Complete!but sudo yum install gparted still fails in the same way.
CentOS 8 install gparted fails
While creating the question, I noticed polkitd running in the Successful system, but not in any Failing one. I knew the problem has much to do with polkit, so I gave it a try in one Debian of the Failing group: sudo apt-get install polkitdAnd yes, this is it, problem solved. Now I can use systemd-inhibit --what=idle as a regular user. I think on the Successful Debian polkitd was installed because of other packages (e.g. network-manager) that depend on it. Originally the question was not supposed to be self-answered, I genuinely needed help. An example of rubber duck debugging, I guess.
Problem On Debian 12 I use IdleAction=poweroff and IdleActionSec=… in logind.conf. This works as intended, the machine powers itself off when it's been idle for long enough. I want to be able to use systemd-inhibit --what=idle as a regular user. I have found claims that it should be possible (example). Indeed, in one of my Debian 12 systems it is possible, let's call this Debian Successful; but there are other Debian 12 systems where I get Access denied, let's call these Failing. The machine where I really need this functionality is in the Failing group. It's not a temporary quirk (because of "needing to reboot" or something). I have just rebooted the Successful machine and one Failing, the behavior persists. Why the difference? What can I do to make a Failing system behave like the Successful one? I'm not really interested in workarounds like sudo or some custom wrapper. I'd like systemd-inhibit --what=idle to "just work", like it does on the Successful system. I'd like to adjust its behavior as much "by the systemd/polkit book" as possible.Current behavior This is how it works on the Successful system. This is what I want: $ SYSTEMD_LOG_LEVEL=7 systemd-inhibit --what=idle true Bus n/a: changing state UNSET → OPENING sd-bus: starting bus by connecting to /run/dbus/system_bus_socket... Bus n/a: changing state OPENING → AUTHENTICATING Bus n/a: changing state AUTHENTICATING → HELLO Sent message type=method_call sender=n/a destination=org.freedesktop.DBus path=/org/freedesktop/DBus interface=org.freedesktop.DBus member=Hello cookie=1 reply_cookie=0 signature=n/a error-name=n/a error-message=n/a Got message type=method_return sender=org.freedesktop.DBus destination=:1.75 path=n/a interface=n/a member=n/a cookie=1 reply_cookie=1 signature=s error-name=n/a error-message=n/a Bus n/a: changing state HELLO → RUNNING Sent message type=method_call sender=n/a destination=org.freedesktop.login1 path=/org/freedesktop/login1 interface=org.freedesktop.login1.Manager member=Inhibit cookie=2 reply_cookie=0 signature=ssss error-name=n/a error-message=n/a Got message type=method_return sender=:1.7 destination=:1.75 path=n/a interface=n/a member=n/a cookie=149 reply_cookie=2 signature=h error-name=n/a error-message=n/a Successfully forked off '(inhibit)' as PID 3384. Skipping PR_SET_MM, as we don't have privileges. true succeeded. Bus n/a: changing state RUNNING → CLOSED $ echo $? 0 $This is how it fails on the Failing systems: $ SYSTEMD_LOG_LEVEL=7 systemd-inhibit true Bus n/a: changing state UNSET → OPENING sd-bus: starting bus by connecting to /run/dbus/system_bus_socket... Bus n/a: changing state OPENING → AUTHENTICATING Bus n/a: changing state AUTHENTICATING → HELLO Sent message type=method_call sender=n/a destination=org.freedesktop.DBus path=/org/freedesktop/DBus interface=org.freedesktop.DBus member=Hello cookie=1 reply_cookie=0 signature=n/a error-name=n/a error-message=n/a Got message type=method_return sender=org.freedesktop.DBus destination=:1.44 path=n/a interface=n/a member=n/a cookie=1 reply_cookie=1 signature=s error-name=n/a error-message=n/a Bus n/a: changing state HELLO → RUNNING Sent message type=method_call sender=n/a destination=org.freedesktop.login1 path=/org/freedesktop/login1 interface=org.freedesktop.login1.Manager member=Inhibit cookie=2 reply_cookie=0 signature=ssss error-name=n/a error-message=n/a Got message type=error sender=:1.1 destination=:1.44 path=n/a interface=n/a member=n/a cookie=464 reply_cookie=2 signature=s error-name=org.freedesktop.DBus.Error.AccessDenied error-message=Permission denied Failed to inhibit: Access denied Bus n/a: changing state RUNNING → CLOSED $ echo $? 1 $true is just an example. Ultimately I want to invoke some long-running command for which inhibiting makes perfect sense.DetailsSuccessful and Failing are Debian 12.The kernel on Successful and on each Failing is 6.1.0-17-amd64.The output of id: @Successful $ id uid=1000(kamil) gid=1000(kamil) groups=1000(kamil),24(cdrom),25(floppy),27(sudo),29(audio),30(dip),44(video),46(plugdev),100(users),106(netdev),111(bluetooth),113(lpadmin),117(scanner),124(pcspkr)@Failing1 $ id uid=1000(kamil) gid=1000(kamil) groups=1000(kamil),4(adm),24(cdrom),25(floppy),27(sudo),29(audio),30(dip),44(video),46(plugdev),108(netdev)On each system /usr/bin/systemd-inhibit gives the same md5sum, I conclude the files are identical between Successful and Failing; they have not been tampered with. ls -l /usr/bin/systemd-inhibit prints: -rwxr-xr-x 1 root root 22928 11-10 01:25 /usr/bin/systemd-inhibitOn each system /usr/share/dbus-1/system.d/org.freedesktop.login1.conf gives the same md5sum, I conclude the files are identical between Successful and Failing; they have not been tampered with. The relevant(?) parts: <busconfig> <policy user="root"> <allow own="org.freedesktop.login1"/> <allow send_destination="org.freedesktop.login1"/> <allow receive_sender="org.freedesktop.login1"/> </policy> <policy context="default"> <deny send_destination="org.freedesktop.login1"/> [...] <allow send_destination="org.freedesktop.login1" send_interface="org.freedesktop.login1.Manager" send_member="Inhibit"/> [...] <allow receive_sender="org.freedesktop.login1"/> </policy></busconfig>On each system /usr/share/polkit-1/actions/org.freedesktop.login1.policy gives the same md5sum, I conclude the files are identical between Successful and Failing; they have not been tampered with. The relevant(?) parts: <policyconfig> [...] <action id="org.freedesktop.login1.inhibit-block-idle"> <description gettext-domain="systemd">Allow applications to inhibit automatic system suspend</description> <message gettext-domain="systemd">Authentication is required for an application to inhibit automatic system suspend.</message> <defaults> <allow_any>yes</allow_any> <allow_inactive>yes</allow_inactive> <allow_active>yes</allow_active> </defaults> </action> [...] </policyconfig>I guess this <allow_any>yes</allow_any> is responsible for the alleged ability of a regular user to use systemd-inhibit --what=idle. Still on Failing systems it seems to be ignored.The Successful Debian uses its hardware directly. One Failing Debian is installed on HP ProLiant DL380 G5; other Failing Debians are virtual machines in VMware ESXi 7.I use ssh to connect to the Successful system and to each Failing one. The Successful system provides a GUI but it's "just in case"; currently sddm only sits there and I don't log in this way.The output of pstree -lu: @Successful $ pstree -lu systemd-+-ModemManager---2*[{ModemManager}] |-NetworkManager---2*[{NetworkManager}] |-accounts-daemon---2*[{accounts-daemon}] |-atop |-atopacctd |-avahi-daemon(avahi)---avahi-daemon |-blkmapd |-bluetoothd |-cron |-cups-browsed---2*[{cups-browsed}] |-cupsd |-dbus-daemon(messagebus) |-dhcpd |-exim4(Debian-exim) |-hostapd |-nfsdcld |-openvpn |-polkitd(polkitd)---2*[{polkitd}] |-rpc.idmapd |-rpc.mountd |-rpc.statd(statd) |-rpcbind(_rpc) |-rtkit-daemon(rtkit)---2*[{rtkit-daemon}] |-sddm-+-Xorg---10*[{Xorg}] | |-sddm-helper---sddm-greeter(sddm)---11*[{sddm-greeter}] | `-{sddm} |-smartd |-sshd-+-sshd---sshd(bisztynek) | `-sshd---sshd(kamil)---bash---tmux: client |-systemd(sddm)-+-(sd-pam) | |-dbus-daemon | `-pulseaudio-+-gsettings-helpe---3*[{gsettings-helpe}] | `-2*[{pulseaudio}] |-systemd(kamil)-+-(sd-pam) | |-dbus-daemon | `-pulseaudio-+-gsettings-helpe---3*[{gsettings-helpe}] | `-{pulseaudio} |-systemd(bisztynek)-+-(sd-pam) | |-dbus-daemon | `-pulseaudio-+-gsettings-helpe---3*[{gsettings-helpe}] | `-{pulseaudio} |-systemd-journal |-systemd-logind |-systemd-timesyn(systemd-timesync)---{systemd-timesyn} |-systemd-udevd |-tmux: server(kamil)---bash---pstree |-transmission-da(debian-transmission)---3*[{transmission-da}] |-udisksd---4*[{udisksd}] |-upowerd---2*[{upowerd}] `-wpa_supplicant@Failing1 $ pstree -lu systemd-+-VGAuthService |-agetty |-cron |-dbus-daemon(messagebus) |-dhclient |-nmbd |-rsyslogd---3*[{rsyslogd}] |-smbd-+-cleanupd | |-smbd | `-smbd-notifyd |-sshd---sshd---sshd(kamil)---bash---tmux: client |-systemd(kamil)---(sd-pam) |-systemd-journal |-systemd-logind |-systemd-timesyn(systemd-timesync)---{systemd-timesyn} |-systemd-udevd |-tmux: server(kamil)-+-2*[bash---nano] | `-bash---pstree `-vmtoolsd---2*[{vmtoolsd}]Other systems from the Failing group may run slightly different sets of tasks, they are all similarly minimalistic though.Observation One big difference between the Successful Debian and each Failing one is the GUI. There are Xorg, sddm and related processes on Successful. But as I said, I don't log in to the GUI at all. I don't know if it has anything do do with the problem. Maybe it's just a red herring.
Access denied for `systemd-inhibit --what=idle`
After multiple tests and research, I can finally answer myself. 1) Not possible in itself. No way to write something that resembles [a-zA-Z0-9_-]* regexp. It would be possible if I knew precisely how many characters the string should have, but it varies. 2) As said in my comment, option 2 is out too, there isn't required systemd support in my version of systemd. Upgrading required system packages would be possible, but not in the time I have. So I went with the option one with a twist. I don't allow user to control service directly, I allow to start script that does all the checking I can't do in sudo. If everything is OK, then the service is called.
I have several services that need to be user-controlled and I can't use them as user services (their requirement is system service with root access), plus there is weird GROUP/216 bug that I haven't been able to fix no matter what I try. I have created template service with name [emailprotected], so it has to be launched as systemctl start my-daemon@<parameter>.service. The parameter is alphanumeric string, no spaces, tabs, special characters, etc. I have read Restarting systemd service only as a specific user? and tried the "sudo approach", but as I am using template service, it creates conciderable security problems. Example sudo line that allows user username to stop one service: username ALL= NOPASSWD: /bin/systemctl stop my-daemon@*.service However, I am perfectly aware that this line is security nightmare, as it lets me do this command too: sudo systemctl stop my-daemon@xyz firewalld.service And here are two example polkit files, one with static service name and second is template. Both are in /etc/polkit-1/rules.d/ : polkit.addRule(function(action, subject) { if (action.id == "org.freedesktop.systemd1.manage-units" && action.lookup("unit") == "my-daemon2.service" && subject.user == "username") { return polkit.Result.YES; } }); polkit.addRule(function(action, subject) { if (action.id == "org.freedesktop.systemd1.manage-units" && action.lookup("unit") == "[emailprotected]" && subject.user == "username") { return polkit.Result.YES; } }); Questions:How can I fix the sudo statement so it will only allow me to run selected services as user username? I read the man, tried and failed to fix it myself. I would much prefer to use polkit, I have polkit version 0.112, through journalctl I can see polkit added new rules but I can't get the rules right, even when I try static service name it doesn't allow me to control it. What am I doing wrong?
Controlling systemd system service as user
After doing a few test, I got this results:polkitd is a nologin user If I execute this command, to execute my script with polkitd user, shows an error: sudo su polkitd -s /bin/bash -c aux_scripts/send_notify.sh almu Error executing command as another user: Not authorized This incident has been reported.So, I think that polkitd user is a limited account, who it can't execute commands as other user As a conclusion, I determine that this action isn't possible to do without modify system internal. I can't allow this in my application, so I can't launch commands as another user from polkit
As continuation of this question (How can I send a notification with polkit 0.106?), I've discovered that I have to execute notify-send as the user who I want to send notification. But, with my current config, I can't do this, because polkit execute the script as polkitd user, and I can't do su $user without known user password. By this reason, I need to create a new polkit action, to allow execute notify-send as other user from polkitd. My polkit rule is this: polkit.addRule(function(action, subject) { if (action.id == "org.freedesktop.consolekit.system.stop" || action.id == "org.freedesktop.login1.power-off" || action.id == "org.freedesktop.login1.power-off-multiple-sessions" || action.id == "org.xfce.session.xfsm-shutdown-helper") { try{ polkit.spawn(["/usr/bin/pendrive-reminder/check_pendrive.sh", subject.user]); return polkit.Result.YES; }catch(error){ polkit.spawn(["/usr/bin/pendrive-reminder/send_notify.sh", subject.user]); return polkit.Result.NO; } } });This polkit rule must lock shutdown option in shutdown menu, and shows a notification with notify-send, with send_notify.sh script, which execute this: #!/bin/bashexport DISPLAY=":0"user=$1 pkexec --user $user notify-send "Pendrive Reminder" "Shutdown lock enabled. Disconnect pendrive to enable shutdown" -u criticalexit 0I tried to add this polkit policy file: <policyconfig> <action id="org.freedesktop.notify-send"> <description>Launch notify-send command</description> <defaults> <allow_any>yes</allow_any> <allow_inactive>yes</allow_inactive> <allow_active>yes</allow_active> </defaults> <annotate key="org.freedesktop.policykit.exec.path">/usr/bin/notify-send</annotate> <annotate key="org.freedesktop.policykit.exec.allow_gui">true</annotate> </action> </policyconfig>I put this file in /usr/share/polkit-1/actions/org.freedesktop.policykit.notify-send.policy But, after put policy file in /usr/share/polkit-1/rules.d/ and press shutdown button, the shutdown menu took a long time to be showed, and notification didn't appeared. The shutdown option is locked correctly How can I get that polkit can call notify-send from my script?
How to allow running notify-send as another user with pkexec?
Finally, I created a dbus client, launched as user, which receives signal from systembus and shows notification to user. The dbus client code is in https://github.com/AlmuHS/Pendrive_Reminder/blob/work-in-progress/dbus-client/client.py In the send-notify.sh script, I only added dbus-send --system /org/preminder/mensaje org.preminder.AppExecuting the dbus client as user, the notification is showed correctly Now I'm try that the client can be launched automatically when user connect pendrive Continue in How to launch a dbus client from a script?
I am developing a application to don't forget the pendrive. This app must lock the shutdown if a pendrive is connected to the machine. As this form, if the user wants to shutdown the system while a pendrive is connected, the system shows a notification to alert about it must disconnect the pendrive to unlock shutdown. To detect the shutdown event, I set a polkit rule what call a script to check if any pendrive are connected to the system. If there are any pendrive connected, the polkit rule calls to notify-send through the script send_notify.sh, which execute this command: notify-send "Pendrive-Reminder" "Extract Pendrive to enable shutdown" -t 5000 The polkit rule is this: polkit.addRule(function(action, subject) { if (action.id == "org.freedesktop.consolekit.system.stop" || action.id == "org.freedesktop.login1.power-off" || action.id == "org.freedesktop.login1.power-off-multiple-sessions" || action.id == "org.xfce.session.xfsm-shutdown-helper") { try{ polkit.spawn(["/usr/bin/pendrive-reminder/check_pendrive.sh", subject.user]); return polkit.Result.YES; }catch(error){ polkit.spawn(["/usr/bin/pendrive-reminder/send_notify.sh", subject.user]); return polkit.Result.NO; } } }But. after put this polkit rule and press shutdown button, my user don't receive any notification. I debug the rule and I checked that second script It's executed, but the notify-send don't shows the notification to my user. How can I solve this? UPDATE: I tried to modify the script as this: #!/bin/bashuser=$1XAUTHORITY="/home/$user/.Xauthority" DISPLAY=$( who | grep -m1 $user.*\( | awk '{print $5}' | sed 's/[(|)]//g')notify-send "Extract Pendrive to enable shutdown" -t 5000exit 0The user is passed as parameter by pòlkit But the problem continues UPDATE: I've just seen this bug https://bugs.launchpad.net/ubuntu/+source/libnotify/+bug/160598 that don't allows to send notifications as root. Later I'll test to modify workaround changing user UPDATE2: After change code to this. the problem continues: #!/bin/bashexport XAUTHORITY="/home/$user/.Xauthority" export DISPLAY=$(cat "/tmp/display.$user")user=$1 su $user -c 'notify-send "Pendrive Reminder" "Shutdown lock enabled. Disconnect pendrive to enable shutdown" -u critical'
How can I send a notification with polkit 0.106?
polkit_authority_check_authorization_sync simply checks whether the caller is authorized to perform the action based on the polkit rules and that's it. This usually means an application/daemon that is already running as root wants to check whether the caller is actually allowed to perform certain action and then performs it on the behalf of the caller. Polkit itself doesn't grant any extra permission, your application already needs to be able to perform the action. pkexec <command> works because pkexec is a setuid binary so the process runs as root and only checks if you are authorized to run the command you are trying to run.
I want to let my user edit a configuration file in /etc from my graphical C application. One method is: fprintf( fopen("/tmp/tmpfile", "w+") , "content\n"); // Write to a tmpfile system("pkexec mv /tmp/tmpfile /etc/myapp.conf"); // Use pkexec to move that tmpfile to our fileHowever, I'd like to implement a polkit client (as what I have to do is a little more complicated than a single write).This will cause the desktop's polkit agent to pop-up asking to authenticate as the administrator (root). Once authenticated, it will perform the action, then return to unprivileged use. I've implemented client reference API and added /usr/share/polkit-1/actions up until the point where this function (simplified version here) returns TRUE; int IsAuthorized(const char* action) { PolkutAuthorizationResult* r = polkit_authority_check_authorization_sync( polkit_authority_get_sync(NULL, &error), polkit_unix_process_new_for_owner( getpid(), 0, getuid() ), "org.myapp.editconfig", NULL, /* details */ POLKIT_CHECK_AUTHORIZATION_FLAGS_ALLOW_USER_INTERACTION, NULL, /* cancellable */ &error ); return polkit_authorization_result_get_is_authorized( r ); }This authorizes this action: <action id="org.myapp.editconfig"> <description>Edit myapp config</description> <message>Authentication is required to edit this system-wide config file</message> <defaults> <allow_any>auth_admin</allow_any> <allow_inactive>auth_admin</allow_inactive> <allow_active>auth_admin</allow_active> </defaults> </action>But my question is: now what? I'm not sure what "being authorized" did for me. If I try to open a root:root file for writing, I get permission denied. If I create a new file, it's owned by the user, not root. Looking into the sources of pkexec I see it changes the uid/gid of itself. Does authentication simply give CAP_SETUID and CAP_SETGID to the process? Assuming this is true, I tried to use setreuid() and setregid(): int uid = getuid(); int euid = geteuid(); int gid = getgid(); int egid = getegid();setregid(0,0); // Switch to root setreuid(0,0);fprintf( fopen("/etc/myapp.conf", "w+"), "content\n"); // Write the filesetregid(gid,egid); // Switch back setreuid(uid,euid);I find that setreuid(0,0) fails and I never switch users like pkexec does. Note I skipped a few things pkexec does such as set the environment, and set_close_exec for all file descriptors. I must be missing something.
What does polkit authorization do to a process?
It is not possible. This is not a massively common type of security policy - whether for polkit or anything else. A lot of stuff either uses a group, or a polkit password prompt. I've only noticed this type of policy being used for PackageKit. (I guess the administrator group is specified by the distribution, when it compiles PackageKit).
polkit is configured using rules files, written in javascript. You write custom functions, and pass them as the argument to polkit.addRule(). When a polkit action is performed, the functions are called in order, until one returns a result. (Otherwise the defaults are used). Your rule function is called with two parameters: the name of the action, and a subject object. You can use subject.isInGroup("wheel") to test whether the user is in the "wheel" group. The polkit defaults use a concept of whether a user is an "administrator" or not. What this concept means can be modified using polkit.addAdminRule(), in a somewhat weird way. The default for this varies between distributions. In some distributions, administrators are placed in the "wheel" group. In other distributions, the "sudo" group are considered to be administrators. Is it possible to write a function for polkit.addRule() in a portable style, which tests whether the subject is in the distribution's administrator group, instead of hard-coding the "wheel" or "sudo" group?
polkit rule: determine if user is an admin?
Apparently we get to write Javascript. Isn't that fun? I think this will work: # /etc/polkit-1/rules.d/10-disable-networkmanager.rulespolkit.addRule(function(action, subject) { if (action.id.indexOf("org.freedesktop.NetworkManager.") == 0) { return polkit.Result.NO; } });https://doc.opensuse.org/documentation/leap/security/html/book.security/cha.security.policykit.html https://wiki.archlinux.org/index.php/Polkit#Examples https://blog.christophersmart.com/2014/01/06/policykit-javascript-rules-with-catchall/ A quick rpm -q --dump NetworkManager | grep -i pol shows the policy file is /usr/share/polkit-1/actions/org.freedesktop.NetworkManager.policy. Searching it for <allow_inactive>yes will point out the actions allowed for known remote login users. E.g. on Fedora Workstation 29, these appear to beorg.freedesktop.NetworkManager.network-control org.freedesktop.NetworkManager.settings.modify.own org.freedesktop.NetworkManager.settings.modify.system<allow_active> corresponds roughly to users who are logged in locally. <allow_any> corresponds to users who are not logged in. "logged in" means pam_systemd. Basically "logged in" will mean GUI or shell logins, but probably not when you configure PAM logins for something else like Apache :-).
What is the correct way, with a single command or a small polkit addition, to limit all unprivileged users to read-only usage of nmcli? Edit: Allowing only a privileged unix group, in addition to root, such as 'netadmins', would also be nice. The main issue, however, is blocking all non-read-only changes by general unprivileged users. Background Like most sysadmins I know, for server deployments I generally disabled NetworkManager and ran the 'network' service, instead using configuration files and network scripts to configure interfaces, bridges, bonds, etc., This was simple, reproducible, reliable, and very un-black-boxy even for advanced configurations. With EL 8, legacy network configuration is deprecated in favor of NetworkManager. At the same time, EL distributions (currently EL 7.5) now ship allowing non-root users to create, modify, and delete interfaces and make almost unlimited changes to existing configuration. For servers acting as compute head nodes, this allows one user to interfere with the effective operation of the entire machine. For servers offering border services, this increases the potential severity and security implications of unprivileged compromises. I have read some of the documentation regarding changing polkit configuration for NetworkManager, but most of it is geared toward getting around some wireless issue on a laptop.
The *correct* way to require root for changes via nmcli to NetworkManager
I assume you want to find out if your system is using the CFS CPU scheduler. The scheduling policy is the policy the CFS or some other scheduler uses. On my Ubuntu 16.04 box I have /proc/sched_debug. Maybe you can get a hint out of: cat /proc/sched_debugIf your system is using the CFS scheduler the output should contain something like: cfs_rq[CORE_NUMBER]: ...
I am testing a ARM based embedded target running with customized embedded linux version 3.14. Is there any way that I can find out which scheduling policy my linux is using at runtime? I see some /proc/sys entries like these on target. But I am not sure whether it is CFS: sched_child_runs_first sched_domain/ sched_latency_ns sched_migration_cost_ns sched_min_granularity_ns sched_nr_migrate sched_rr_timeslice_ms sched_rt_period_us sched_rt_runtime_us sched_shares_window_ns sched_time_avg_ms sched_tunable_scaling sched_wakeup_granularity_nsCan anyone help?
How verify the current scheduling policy running in a embedded Linux?
Run the window manager in a ConsoleKit session: exec ck-launch-session blackbox
In the file manager PCManFM I can access discs in my USB DVD drive but I cannot eject them or access other USB storage devices - I get the error message "Not Authorized". Any clues? I use Debian 7.7.0 and my window manager is launched by .xinitrc with exec dbus-launch --exit-with-session blackbox
Allowing normal user to mount and eject devices
I solved the problem but am a bit unsure on how. Here's what I did:Upgraded all packages and Nomachine on both machines to newest versions (they were different but this didn't interfere w/ using them (till they worked)). Rebooted. This alone bought me nothing.Took a look at the server's configuration file (on B) at /usr/NX/etc/server.cfg, which contained some suspicious key values. Made some changes, includingEnableNetworkBroadcast 1 CreateDisplay 0 WebAccessType unrestrictedRebooted. Again, nothing. I "forgot" the whole business for a couple of days and when I fired the computers up -- bang! It worked. I have some theories concerning all this. The first, obvious one is that the computer (probably B) needed multiple reboots. Possibly, the shutdown after the first reboot fixed some settings on B, and it rebooted correctly after that. Also possibly (but more unlikely), leaving the network cable disconnected on one of the reboots flushed some corrupted settings, and things worked after that. There's also a very slight possibility that I didn't reboot after changing B's /usr/NX/etc/server.cfg but e.g. did a logout. As to the root cause of the mess, I have three theories:When B crashed (as it occasionally does), Nomachine's server settings were corrupted / overwritten on next reboot.In Nomachine, I've since seen a dialog "Cannot detect a display on server xxxxx. Always create a new display for this server?". Maybe I unconciously clicked Yes to the question, which might explain an unability to connect to an existing session and CreateDisplay 1 in /usr/NX/etc/server.cfg (doesn't explain an unability to connect to the internet, though).B's SSD is having some problems (my Linux partition there didn't boot up today before I did fsck -fy to it). This may have corrupted something, too.
I've used Nomachine for years to connect my 2 Linux laptops. The client machine A has always connected to an existing X session in the server machine B displaying it in both A and B. However, lately it always creates a new session on B while showing it on A only. To my knowledge, I haven't done (installed, removed, changed, etc.) anything to deserve this. Upon connecting, I lately also sometimes get warnings either about a keyring or not being allowed to control network, so I suspect a polkit issue. If I open a web browser in the B session displayed only in A, the browser opens only in the existing X session on B (this is the only way I can interact w/ the X session there). So it seems that something's preventing me from accessing the web over Nomachine, creating a new webless X session instead. What I've done To get rid of the keyring nag: mv /home/j/.local/share/keyrings/login.keyring /home/j/.local/share/keyrings/login.keyring.bak To ensure network control:created /etc/polkit-1/localauthority/50-local.d/50-allow-network-manager.pkla:[Network Manager all Users] Identity=unix-user:* Action=org.freedesktop.NetworkManager.settings.modify.system;org.freedesktop.NetworkManager.network-control ResultAny=yes ResultInactive=yes ResultActive=yes(tried also versions w/ ResultAny=no and ResultInactive=no)commented out the following value of allow_any of<action id="org.freedesktop.NetworkManager.network-control"> <_description>Allow control of network connections</_description> <_message>System policy prevents control of network connections</_message>(this is a message I sometimes got) in /usr/share/polkit-1/actions/org.freedesktop.NetworkManager.policy: <defaults> <!-- <allow_any>auth_admin</allow_any>--> <allow_inactive>yes</allow_inactive> <allow_active>yes</allow_active> </defaults>This has suppressed the "System policy prevents control of network connections" messages and temporarily fixed the keyring nag (login.keyring gets re-created and sometimes fires the nag again) but hasn't enabled me to connect to an existing X session on B. Needless to say, I've rebooted both machines many times. Any ideas on how to proceed?
Unable to connect to an existing X session w/ Nomachine
polkit doesn’t grant privileges to non-privileged processes, it authenticates users and controls access to actions provided by privileged processes. It doesn’t use capabilities for this. pkexec can run a process as another user, but it does so using mechanisms similar to sudo: it’s setuid root.
I know that some authentication programs like KDE's KAuth can use polkit as the backend.And what makes polkit special is that it can grant some specific privileges to a non-privileged process.A functionality that reminds me of capabilities(7). But does polkit make use of capabilities or another infra-structure? Thanks.
Does "Polkit" make use of linux capabilities?
On Slackware, it is started by dbus-daemon, which in turn is started by rc.d/rc.messagebus.
On Linux "who" start daemons? Suse, RockyLinux, Debian use systemd Devuan use scripts in /etc/rc*.d/* which are symlinks from /etc/init.d Slackware: use scripts in /etc/rc.d/rc.* (for example rc.M start a lot of daemons, rc.sshd start sshd, etc..) On my Slackware I see polkitd start at the boot. But who or what start it? ps -ef|grep pol polkitd 2210 1 0 set04 ? 00:00:00 /usr/lib/polkit-1/polkitd --no-debugpolkit is not defined in any script grep -irl polkit /etc/rc.d/ grep -irl polkit /etc/init.d
Who or what start polkitd in Slackware?
As far as I've understood, a session is considered as local by polkit if it is associated with a local seat. By default, seat0 is the only existing seat. You can view the devices associated with a seat by e.g.: loginctl seat-status seat0To associate a device with a seat, it should have a udev tag seat added to it in udev rules. You can view the udev tags of a device with e.g.: udevadm info -q property --property=TAGS,CURRENT_TAGS -n /dev/ttyS0 By default, TTY devices (and thus serial consoles) don't seem to be associated with any seats, so a serial console login will be no different from a remote SSH login, as far as polkit is concerned.
Are serial consoles considered local by polkit? Could that be configured e.g. via /etc/securetty?
Polkit and local serial consoles
Turned out it was a bug in the particular version of pppd that was being used in the distro. I checked and previous and later versions of pppd do not have this problem. Also the problem is not specific to this arch and platform or tmux. If pppd is being run inside a shell script, It does not handle Ctrl-C, while outside shell, it has no problem.
I have a Mini2440 ARM Board, and I have put a base Debian 6.0 system on it using multistrap. I have used tmux to run several processes in defferent windows from /etc/rc.local. I connect to the board using its serial port and an inittab entry to run getty on that port. I use picocom as serial communicator. When root logs in, ~/.bashrc attaches him to the already running tmux server, and processes can be easily monitored. the actual command is exec tmux attach-session -t "main". tmux runs with default config. Everything works, except one of the processes (a shell script around pppd) does not receive Ctrlc from terminal, while other processes do. Also Ctrl\ works. also kill -INT <pppd_pid> works, but kill -INT <shellscript_pid> does not. I really need Ctrlc to work. What is wrong with this setup? Edit: here is the output of stty -a in the shell script, right before pppd: speed 38400 baud; rows 23; columns 80; line = 0; intr = ^C; quit = ^\; erase = ^?; kill = ^U; eof = ^D; eol = <undef>; eol2 = <undef>; swtch = <undef>; start = ^Q; stop = ^S; susp = ^Z; rprnt = ^R; werase = ^W; lnext = ^V; flush = ^O; min = 1; time = 0; -parenb -parodd cs8 -hupcl -cstopb cread -clocal -crtscts -ignbrk brkint -ignpar -parmrk -inpck -istrip -inlcr -igncr icrnl ixon -ixoff -iuclc -ixany imaxbel -iutf8 opost -olcuc -ocrnl onlcr -onocr -onlret -ofill -ofdel nl0 cr0 tab0 bs0 vt0 ff0 isig icanon iexten echo echoe echok -echonl -noflsh -xcase -tostop -echoprt echoctl echokesince it's just pppd process that has this issue, I think it has something to do with it or its configuration, but when I run pppd outside of tmux, Ctrl-C works. pppd runs with nodetach option, so it stays in terminal foreground. I also tested it on my dev machine (Debian 6.0 on amd64) with the same results.
Ctrl-C does not work with pppd non-detached session
Just remove the IPv4 and IPv6 addresses with ip addr flush dev eth1 and ip -6 addr flush dev eth1.
I have CentOS 6.3 running in a (virtual) machine with two Ethernet adapters. I have eth0 connected to a TCP/IP LAN and eth1 connected to a DSL modem. The system is intended as a dedicated router/firewall, and has iptables set up to do SNAT, DNAT, and the desired filtering. This was working great but I changed DSL modems and unfortunately the new (faster) one is idiotproofed and so automatically does NAT and will not allow me to pass my public IP along to eth1. I can't tolerate double NAT so I did some research and read that this modem can be 'tricked' into giving my computer a public IP by doing the PPPoE on the computer. I therefore set up pppd to use eth1, creating the ppp0 connection which I then substitute for eth1 in my custom iptables config script. This seems to work to a degree but I had to open up the firewall to get it to work, and it's flaky. Partly to help in troubleshooting, I want to totally rule out the possibility of any TCP/IP traffic being directly routed to eth1 where my 'friendly' modem will happily NAT it. To the best of my knowledge, PPPoE sits below, not above IP - on the physical interface it deals directly in Ethernet frames. Therefore I should not even have to have IP networking configured on eth1 at all in order for pppd to work, and IP networking running on eth1 therefore is just complicating matters needlessly. Here's where I discover, silly me, I don't know how to disable the TCP/IP stack on Linux! I know on a Windows box you can just uncheck the TCP/IP protocol in the adapter properties, but here I am running a text-only CentOS and I have no idea how to do it. Apparently it's not a very common desire, because I've been searching the Internet to no avail. It seems like a hard-wired assumption that an Ethernet adapter is a TCP/IP connection. Well, usually... Thanks for any help! Kevin
How can I disable TCP/IP for an Ethernet adapter?
The best bet I found was the "unit" option in the /etc/ppp/peers/... file. This option is an integer which names the interface pppX where X is the int after "unit". I ended up just naming the interfaces pppX in /etc/network/interfaces and using "unit" in the peers files to ensure they are named that way.
I have two PPP peers, dsl-line1 and dsl-line2 which are configured with pppd on Ubuntu (Server) Linux. They are brought up by the /etc/network/interfaces file with the auto thingy however each PPP connection chooses the name pppX where X varies depending on which comes up first. I would like to make it such that dsl-line1 comes up with a name such as "dsl0" and dsl-line2 with a name like "dsl1" so that I can create firewall rules more easily for each and set up routing (as well as having it easier to configure). My question is how can I get the pppd's interfaces to name themselves? /etc/ppp/peers/dsl-line1 (dsl-line2 is basically the same apart from the default route being removed and the ethernet interface being different) noipdefault defaultroute replacedefaultroute hide-password #lcp-echo-interval 30 #lcp-echo-failure 4 lcp-echo-interval 10 lcp-echo-failure 3 noauth persist #mtu 1492 #persist #maxfail 0 #holdoff 20 plugin rp-pppoe.so eth1 user "[emailprotected]"/etc/network/interfaces (the line1 part, again, 2 is very similar) auto dsl0 iface dsl0 inet ppp pre-up /sbin/ifconfig eth1 up # line maintained by pppoeconf post-up /bin/sh /home/callum/ppp0_up.sh # Route everything post-up /bin/sh /etc/miniupnpd/ppp0_up.sh # Start miniupnpd (if not alr$ provider dsl-line1Thanks in advance.
Naming PPP interfaces
In all likelihood the culprit is NetworkManager -- it rebuilds /etc/resolv.conf on startup/shutdown and whenever your managed network connections change. Your best bet, unless you want to strip parts of your install out of your system, is to add your user to the netdev group (sudo adduser myuser netdev will do the trick) and then using network-manager-gnome or network-manager-kde depending on your preferred flavor to manage settings and specify your DNS servers. A useful tutorial can be found here. Alternately, you can dig into /etc/network/interfaces and specify that the network connection you use to connect to the internet is not to be managed by NetworkManager, then add the keyword dns-nameservers to the stanza for that interface.
My ISP asked me to use custom nameserver settings. I have placed these in /etc/resolv.conf. Unfortunately, every time I reboot the computer, the contents of this file is changed. To connect to the Internet, I must first edit that file. How can I ensure that this file does not change?
/etc/resolv.conf changes during reboot
Important: you can always override your default options with local options. from man pppd /etc/ppp/options System default options for pppd, read before user default options or command-line options.and also ~/.ppprc /etc/ppp/options.ttyname /etc/ppp/peersyou should enable debug options (sometimes also kdebug) debug Enables connection debugging facilities. If this option is given, pppd will log the contents of all control packets sent or received in a readable form. The packets are logged through syslog with facility daemon and level debug. This information can be directed to a file by setting up /etc/syslog.conf appropriately (see sys-log.conf(5)).your exit codes EXIT STATUS 16 The link was terminated by the modem hanging up.and so on. Your error is LCP terminated by peer there are several links which explain how to fix it: you'll need to pass "refuse-eap" option to pppd. ubuntu lcp_term_authentication or simply check your credentials.
I'm using pppd and wvdial on my ARM Linux embedded system. I have a CDMA modem connected via a serial port and am connecting to the Verizon network. I am seeing that several times per day pppd exits with exit code 16 (see exact message from log below). How do I work out what is causing these disconnects? In particular what does the LCP terminated by peer message indicate? Feb 18 12:31:04 ts7600-47aad3 pppd[3242]: LCP terminated by peer Feb 18 12:31:04 ts7600-47aad3 pppd[3242]: Connect time 0.6 minutes. Feb 18 12:31:04 ts7600-47aad3 pppd[3242]: Sent 1044 bytes, received 0 bytes. Feb 18 12:31:04 ts7600-47aad3 pppd[3242]: restoring old default route to eth0 [1 92.168.98.1] Feb 18 12:31:07 ts7600-47aad3 pppd[3242]: Connection terminated. Feb 18 12:31:07 ts7600-47aad3 pppd[3242]: Modem hangup Feb 18 12:31:07 ts7600-47aad3 pppd[3242]: Exit. Feb 18 12:31:07 ts7600-47aad3 wvdial: Disconnecting at Tue Feb 18 12:31:07 2014 Feb 18 12:31:07 ts7600-47aad3 wvdial: The PPP daemon has died: A modem hung up t he phone (exit code = 16) Feb 18 12:31:07 ts7600-47aad3 wvdial: man pppd explains pppd error codes in more detail.
Linux PPP : how to debug disconnects with exit code = 16?
You can refer to this wiki that explain a very simple and complete way of acheving what you want with iptables, This explain how to Nat your wifi interface behind you ppo interface. Edit 1: You can also make your two interface working as a bridge aka switch but it would probably be a bit more tricky, some info about that here
On my Debian Linux device, I have a USB-modem that is connected to the Internet. Its interface name is ppp0. I also have a USB-wireless adapter, where I am hosting a Access Point. Its interface name is wlan0. How to I route traffic between these interfaces, so that if my phone is connected to this AP, that I can access the Internet via ppp0? EDIT 1: I tried setting up some routing, but does not seem to work. Here are the details: # iptables --list-rules -P INPUT ACCEPT -P FORWARD ACCEPT -P OUTPUT ACCEPT -A FORWARD -i ppp0 -o wlan0 -m state --state RELATED,ESTABLISHED -j ACCEPT -A FORWARD -i wlan0 -o ppp0 -j ACCEPT# iptables --list-rules -t nat -P PREROUTING ACCEPT -P INPUT ACCEPT -P OUTPUT ACCEPT -P POSTROUTING ACCEPT -A POSTROUTING -o ppp0 -j MASQUERADEEDIT 2 SOLVED: I was able to solve my problem. I was using the same subnet for wlan0 and ppp0. When using different subnets for wlan0 and ppp0, everything worked fine. I also found this article useful: http://elinux.org/RPI-Wireless-Hotspot
Internet routing between wlan0 and ppp0?
You don't need to list any nameserver other than 127.0.0.1 in /etc/resolv.conf. What you need to inform dnsmasq of the upstream DNS server, and it will relay and cache requests to the ISP's server. If your ISP's DNS providers don't change (they rarely do), you can declare them in the Dnsmasq configuration file (/etc/dnsmasq.conf), with lines like server=203.0.113.1. If your ppp or dhcp daemon drops the addresses of your ISP's providers in a file, say /etc/ppp/resolv.conf, then reference that file in dnsmasq.conf: resolv-file=/etc/ppp/resolv.conf. You'll find instructions for most common setups in the Dnsmasq setup documentation, and the complete list of options in the example configuration file. If you're running Debian, Ubuntu or some other distribution with a resolvconf package, install it. Resolvconf automatically manages adding and removing entries from the DNS configuration when you connect or disconnect to a network.
I'm trying to setup dnsmasq to accelerate DNS resolving , but since i use a PPPoE connection , there're both dns server provided by ISP , and the 127.0.0.1. So how can i place the local dns server as the first line in /etc/resolv.conf automatically ? And please don't let me use a static dns server configuration .. Thanks !
Adding custom DNS server for pppd client connection?
Found an issue with the ppp/peers/provider file Removing updetach from the provider file fixed it. updetach With this option, pppd will detach from its controlling terminal once it has successfully established the ppp connection (to the point where the first network control protocol, usually the IP control protocol, has come up). Can anyone explain why this fixed my problem :)? Solved it but not 100% sure why this worked.
Trying to automate making a ppp connection on boot. I have a cell modem (skywire LE910 SVG) that I have working manually using pon. My ppp/peers/isp is configured and the corresponding chatscript is working. After my device boots (beaglebone black running 3.8.13 Debian wheezy) I can run pon verizon (name of isp) and then see my established ppp0 via ifconfig. How do I make this happen on boot?
Establish a PPP connection on boot
I guess the problem is a bug specific to pppd version 2.4.5, which is the one that comes with Debian 7. I tested versions 2.4.4 and 2.4.6 (which is the latest as of now) on the same and other machines and they work as expected. pppd package seems to have a lot of signal handler manipulation code in it, which I guess could lead to these kind of bugs. I'm just happy that it's been fixed by now.
I'm trying to connect to GPRS network through a serial port connected GSM modem. When I call /usr/sbin/pppd call <peer_name> from the command line, it correctly receives and handles Ctrl+C from keyboard. But when I put the exact same command in an empty shell script (with or without the shebang #! at the top), chmod +x it and run it from the shell prompt, then pppd starts to run - But it totally ignores Ctrl+C key combination. Ctrl+Z works normally though. This is the contents of the pppd peer file nodetach dump connect "connect_script" disconnect "disconnect_script" /dev/ttyS0 noauthI tested another peer file which I had created to connect to a PPTP VPN server - with the same result. PPTP does not need a chat script, so I'm ruling out problems with chat command or serial port link properties. OS is debian 7. Any ideas what is happening here?
Ctrl-C is ignored by pppd when put in a shell script
After trying several different methods of fixing, none working, I finally came across a forum post on the Gentoo forums about the same issue. It seems that the issue is that some files are named incorrectly and so a symbolic link needs to be created in order to successfully connect. Link to thread. To create a symbolic link to connect with NetExtender successfully you need to: cd /etc/ppp/ip-up.d ln -s sslvpnroute sslvpnroute.shThis should allow you to get past the Connecting to tunnel... part. Once connected, NetExtender will create a file called sslvpnroutecleanup. You also need to link this file, so cd /etc/ppp/ip-down.d ln -s sslvpnroutecleanup sslvpnroutecleanup.shNote, you can only do that once you're successfully connected to the route. These steps fixed the issue for me.
At work we have to use Dell's SonicWall NetExtender software to connect to the company VPN. Some people use Windows and contractors (like myself), use whatever, which in my case is Manjaro (Arch-based) Linux. The issue is that I seem to be the only who can not connect via the client or CLI. What happens is the connection just hangs forever at Connecting to tunnel. Diagnostic outputs: netExtender log: 08/31/2017 10:01:32.792 [connect warn 4847] SSL_get_peer_certificate: err= (success?) self signed certificate in certificate chain 08/31/2017 10:01:32.793 [general notice 4847] Connected. 08/31/2017 10:01:32.793 [general notice 4847] Logging in... 08/31/2017 10:01:32.886 [general notice 4847] Login successful. 08/31/2017 10:01:32.928 [general error 4847] Version header not found 08/31/2017 10:01:32.928 [epc info 4847] Server don't support EPC check. Just pass EPC check 08/31/2017 10:01:33.047 [general notice 4847] SSL Connection is ready 08/31/2017 10:01:34.049 [general info 4847] Using new PPP frame encoding mechanism 08/31/2017 10:01:34.050 [general info 4847] Using PPP async mode (chosen by server) 08/31/2017 10:01:34.050 [general info 4847] Connecting tunnel...It stays this way without errors or timeouts for however long I let it run. journalctl -u NetworkManager seems to have no useful output for ppp, or anything related. journalctl -b --no-pager | grep pppd: aug 31 10:01:34 daniel-pc pppd[4893]: pppd 2.4.7 started by daniel, uid 1000 aug 31 10:01:34 daniel-pc pppd[4893]: Using interface ppp0 aug 31 10:01:34 daniel-pc pppd[4893]: Connect: ppp0 <--> /dev/pts/1 aug 31 10:01:34 daniel-pc pppd[4893]: Cannot determine ethernet address for proxy ARP aug 31 10:01:34 daniel-pc pppd[4893]: local IP address <local ip> aug 31 10:01:34 daniel-pc pppd[4893]: remote IP address <remote ip> aug 31 10:19:46 daniel-pc pppd[4893]: Modem hangup aug 31 10:19:46 daniel-pc pppd[4893]: Connect time 18.2 minutes. aug 31 10:19:46 daniel-pc pppd[4893]: Sent 80 bytes, received 0 bytes. aug 31 10:19:46 daniel-pc pppd[4893]: Connection terminated. aug 31 10:19:46 daniel-pc pppd[4893]: Exit.The happens once I terminate the netExtender process. The same process worked previously on a previous installment of the same OS and Windows also, which is why I suspect an issue elsewhere. Output of uname -a: Linux daniel-pc 4.9.44-1-MANJARO #1 SMP PREEMPT Thu Aug 17 08:23:52 UTC 2017 x86_64 GNU/Linux
SonicWall NetExtender hangs on Connecting to tunnel