title
stringlengths
1
61
section
stringlengths
2
92
content
stringlengths
6
236k
ASUS Zenbook UX430/UX530
Intro
# ASUS Zenbook UX430/UX530 \[ ] 1 language * [日本語](https://wiki.archlinux.jp/index.php/ASUS_Zenbook_UX430/UX530 "ASUS Zenbook UX430/UX530 – 日本語") From ArchWiki < [ASUS Zenbook UX430](../../en/ASUS_Zenbook_UX430/UX530.html "ASUS Zenbook UX430") ![](../../File:Tango-edit-clear.svg)**This article or section does not follow the [Laptop page guidelines](../../en/Help:Laptop_page_guidelines.html "Help:Laptop page guidelines").** **Reason:** Some missing sections, such as the function keys section. (Discuss in [Talk:ASUS Zenbook UX430/UX530](../../en/Talk:ASUS_Zenbook_UX430/UX530.html)) | Device | PCI/USB ID | Working? | | -------------------- | ---------- | --------- | | Intel | | Yes | | GPU (nvidia) | | Yes | | Ethernet (via USB) | | Yes | | Wireless | | Yes | | Audio | | Yes | | Touchpad | | Yes | | Webcam | | Yes | | SD-card reader | | Yes | | Bluetooth | | Yes | | Fingerprint reader | | Partially | | Ambient light sensor | | Partially | ASUS [announced](https://www.asus.com/News/q0npwWGXCqpxoVf8) UX430 and UX530 models. Since these models share almost the same hardware (the only difference is screen size and discrete NVidia GPU), this article covers hardware specific configuration for all UX430UA, UX430UQ, UX530UQ and UX530UX models.
ASUS Zenbook UX430/UX530
Configuration
## Configuration ### Secure Boot (option) In order to boot any Linux operating system, navigate to BIOS, then hit `F7` or click on *Advanced Menu*, then the *Security* tab and set *Secure Boot* to `Off`. If the aforementioned *Secure Boot* option is a menu rather than an on-or-off option, click on *Secure Boot*, *Key Management*, then *Reset to Setup Mode* and confirm in the dialog. ### Video See [Intel Graphics](../../en/Intel_graphics.html#Installation "Intel graphics") and [Hardware Acceleration](../../en/Hardware_video_acceleration.html "Hardware video acceleration"). For models with discrete Nvidia graphics card, also see [NVIDIA Optimus](../../en/NVIDIA_Optimus.html "NVIDIA Optimus"). ### Audio See [PulseAudio](../../en/PulseAudio.html "PulseAudio"). ### Touchpad See [Libinput](../../en/Libinput.html "Libinput"). ### Fingerprint sensor **Note:** This is likely not going to work at all. See [Talk:ASUS Zenbook UX430/UX530#Fingerprint Reader](../../en/Talk:ASUS_Zenbook_UX430/UX530.html#Fingerprint_Reader "Talk:ASUS Zenbook UX430/UX530"). The fingerprint sensor is supported since [Fprint](../../en/Fprint.html "Fprint") v0.99.0, even through it is supported it does not work reliably. This is due to the fingerprint small sensor[\[1\]](https://github.com/iafilatov/libfprint/tree/e459992e76ab322d9f92e1885215f2da7c1d0a59#common-problems). ### Ambient Light Sensor The Ambient Light Sensor should work on UX430UQ[\[2\]](https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/commit/?id=db2582afa7444a0ce6bb1ebf1431715969a10b06) and UX430UNR[\[3\]](https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/commit/?id=02a5e9bc86dee8c7698ac2cfd9e29650eb318442). ### Battery charge threshold See [Laptop/ASUS#Battery charge threshold](../../en/Laptop/ASUS.html#Battery_charge_threshold "Laptop/ASUS").
ASUS Zenbook UX430/UX530
Troubleshooting
## Troubleshooting ### Microcode During boot you might get the message `[Firmware Bug]: TSC_DEADLINE disabled due to Errata; please update microcode to version: 0x52 (or later)`. See [Microcode](../../en/Microcode.html "Microcode") to resolve it. ### Nvidia issues with Bumblebee It is likely that it is one of these issues: * You used a power management application (especially [Powertop](../../en/Powertop.html "Powertop")). See [bumblebee#Broken power management with kernel 4.8](../../en/Bumblebee.html#Broken_power_management_with_kernel_4.8 "Bumblebee") for more information. * You suspended your laptop and resumed, and are now unable to start your GPU, see [Bumblebee#Failed to initialize the NVIDIA GPU at PCI:1:0:0 (Bumblebee daemon reported: error: \[XORG\] (EE) NVIDIA(GPU-0))](../../en/Bumblebee.html#Failed_to_initialize_the_NVIDIA_GPU_at_PCI:1:0:0_\(Bumblebee_daemon_reported:_error:_\[XORG]_\(EE\)_NVIDIA\(GPU-0\)\) "Bumblebee"). ### Headset Microphone You may encounter an issue where your headset microphone is not being detected. To fix this, use `model=dell-headset-multi` as explained in [Advanced Linux Sound Architecture#Correctly detect microphone plugged in a 4-pin 3.5mm (TRRS) jack](../../en/Advanced_Linux_Sound_Architecture.html#Correctly_detect_microphone_plugged_in_a_4-pin_3.5mm_\(TRRS\)_jack "Advanced Linux Sound Architecture"). ### No sound after Windows reboot There seems to be a bug in the firmware that prevents the embedded sound card from working in Arch after Windows has been restarted. The sound system works, and you can hear sounds from, say, wireless headphones, but the embedded sound card either plays no sounds at all, or plays sounds for a couple seconds before quickly "fading out" to silence. Unlike [some other models](../../en/ASUS_N550JV.html#Dual_boot "ASUS N550JV"), suspending and resuming makes no difference. Instead, following are the known workarounds: * If you haven't exited Windows yet and plan to boot into Arch next, do a Windows shutdown instead of restart, and then boot into Arch. - If you're already booted into Arch, do an Arch shutdown/poweroff and then boot back into it (an Arch reboot won't work). As a general rule of thumb, if the sound card isn't working, boot into Arch via a complete shutdown (as opposed to a restart) to fix it. **NOTE:** From the workarounds above, it might seem correct to generalize that rebooting is the problem and a complete shutdown is the fix, but it's not entirely accurate, and hence a false general conclusion. For example, if you're running Arch with working embedded sound card and you do a reboot back into Arch, the sound card still works. ### Suspend See [Power management/Suspend and hibernate#Changing suspend method](../../en/Power_management/Suspend_and_hibernate.html#Changing_suspend_method "Power management/Suspend and hibernate"). ### Fan always active See [Fan speed control#NBFC](../../en/Fan_speed_control.html#NBFC "Fan speed control").
ASUS Zenbook UX430/UX530
Tips and tricks
## Tips and tricks ### Power saving and performance As advertised by ASUS, both laptops are capable to last up to 9 hours on battery. In order to achieve this, see: * BIOS update - It is generally recommended to update BIOS, as it usually brings performance, power-saving and security features. - [Power Saving](../../en/Power_management.html "Power Saving") - List of general recommendations to increase battery life. * [Improving performance](../../en/Improving_performance.html "Improving performance") - List of general recommendations to increase performance. - [SSD](../../en/Solid_state_drive.html "SSD") - Tips and tricks for Solid State Drives. Both laptops ship M.2 SSD by default. * [Undervolting CPU](../../en/Undervolting_CPU.html "Undervolting CPU") - Decrease voltage for Intel CPU (reduce battery drain, reduce heat and therefore - reduce fan speed) ### Extract Windows 10 license key The laptop comes with Windows 10 preinstalled and the activation key is hardcoded into the firmware. If you replace Windows with Linux, then hardcoded activation key is useless. You might want to extract it and use somewhere else (e.g. virtualized Windows 10): ``` # grep -aPo '[\w]{5}-[\w]{5}-[\w]{5}-[\w]{5}-[\w]{5}' /sys/firmware/acpi/tables/MSDM ``` **Note:** Microsoft online support confirmed that the code is valid, but because you are unable to activate it (Windows fails to activate and asks for another code), they offered 2 options - replace activation code with another one for 40$ or contact OEM (ASUS) about this issue. ASUS confirmed, that in order to "use" this activation key, you need to bring this laptop to repair service so they can "restore" system using ASUS OEM Windows 10 image. They do not provide this image for download. [Category](../../Special:Categories.html "Special:Categories"): * [ASUS](../../en/Category:ASUS.html "Category:ASUS") Hidden category: * [Pages or sections flagged with Template:Laptop style](../../en/Category:Pages_or_sections_flagged_with_Template:Laptop_style.html "Category:Pages or sections flagged with Template:Laptop style") - Retrieved from "<https://wiki.archlinux.org/index.php?title=ASUS_Zenbook_UX430/UX530&oldid=798520>" - This page was last edited on 28 January 2024, at 12:56. - Content is available under [GNU Free Documentation License 1.3 or later](https://www.gnu.org/copyleft/fdl.html) unless otherwise noted. * [Privacy policy](https://terms.archlinux.org/docs/privacy-policy/) * [About ArchWiki](../../en/ArchWiki:About.html) * [Disclaimers](../../en/ArchWiki:General_disclaimer.html) * [Code of conduct](https://terms.archlinux.org/docs/code-of-conduct/ "archlinux-service-agreements:code-of-conduct") * [Terms of service](https://terms.archlinux.org/docs/terms-of-service/ "archlinux-service-agreements:terms-of-service") - [![GNU Free Documentation License 1.3 or later](/resources/assets/licenses/gnu-fdl.png)](https://www.gnu.org/copyleft/fdl.html) - ![](/resources/assets/poweredby_mediawiki_88x31.png) * Toggle limited content width
Advanced Linux Sound Architecture/Configuration examples
Intro
# Advanced Linux Sound Architecture/Configuration examples \[ ] 3 languages * [Italiano](../../it/Advanced_Linux_Sound_Architecture/Configuration_examples.html "Advanced Linux Sound Architecture (Italiano)/Configuration examples – italiano") * [日本語](https://wiki.archlinux.jp/index.php/Advanced_Linux_Sound_Architecture/%E8%A8%AD%E5%AE%9A%E4%BE%8B "Advanced Linux Sound Architecture/設定例 – 日本語") * [Português](../../pt/Advanced_Linux_Sound_Architecture/Configuration_examples.html "Advanced Linux Sound Architecture (Português)/Configuration examples – português") From ArchWiki < [Advanced Linux Sound Architecture](../../en/Advanced_Linux_Sound_Architecture.html "Advanced Linux Sound Architecture") The following should serve as a guide for more advanced [ALSA](../../en/Advanced_Linux_Sound_Architecture.html "ALSA") setups. The configuration takes place in `/etc/asound.conf` as mentioned in the main article. None of the following configurations are guaranteed to work. **Note:** Most things discussed here are much easier to accomplish using alsa plugins like upmix which are explained in the main article.
Advanced Linux Sound Architecture/Configuration examples
Upmixing of stereo sources to 7.1 using dmix while saturated sources do not get upmixed
## Upmixing of stereo sources to 7.1 using dmix while saturated sources do not get upmixed ``` # 2008-11-15 # # This .asoundrc will allow the following: # # - upmix stereo files to 7.1 speakers. # - playback real 7.1 sounds, on 7.1 speakers, # - allow the playback of both stereo (upmixed) and surround(7.1) sources at the same time. # - use the 6th and 7th channel (side speakers) as a separate soundcard, i.e. for headphones # (This is called the "alternate" output throughout the file, device names prefixed with 'a') # - play mono sources in stereo (like skype & ekiga) on the alterate output # # Make sure you have "8 Channels" and NOT "6 Channels" selected in alsamixer! # # Please try the following commands, to make sure everything is working as it should. # # To test stereo upmix : speaker-test -c2 -Ddefault -twav # To test surround(5.1): speaker-test -c6 -Dplug:dmix6 -twav # To test surround(7.1): speaker-test -c6 -Dplug:dmix8 -twav # To test alternative output: speaker-test -c2 -Daduplex -twav # To test mono upmix: speaker-test -c1 -Dmonoduplex -twav # # # It may not work out of the box for all cards. If it doesnt work for you, read the comments throughout the file. # The basis of this file was written by wishie of #alsa, and then modified with info from various sources by # squisher. Svenstaro modified it for 7.1 output support. #Define the soundcard to use pcm.snd_card { type hw card 0 device 0 } # 8 channel dmix - output whatever audio, to all 8 speakers pcm.dmix8 { type dmix ipc_key 1024 ipc_key_add_uid false ipc_perm 0660 slave { pcm "snd_card" rate 48000 channels 8 period_time 0 period_size 1024 buffer_time 0 buffer_size 5120 } # Some cards, like the "nforce" variants require the following to be uncommented. # It routes the audio to the correct speakers. # bindings { # 0 0 # 1 1 # 2 4 # 3 5 # 4 2 # 5 3 # 6 6 # 7 7 # } } # upmixing - duplicate stereo data to all 8 channels pcm.ch71dup { type route slave.pcm dmix8 slave.channels 8 ttable.0.0 1 ttable.1.1 1 ttable.0.2 1 ttable.1.3 1 ttable.0.4 0.5 ttable.1.4 0.5 ttable.0.5 0.5 ttable.1.5 0.5 ttable.0.6 1 ttable.1.7 1 } # this creates a six channel soundcard # and outputs to the eight channel one # i.e. for usage in mplayer I had to define in ~/.mplayer/config: # ao=alsa:device=dmix6 # channels=6 pcm.dmix6 { type route slave.pcm dmix8 slave.channels 8 ttable.0.0 1 ttable.1.1 1 ttable.2.2 1 ttable.3.3 1 ttable.4.4 1 ttable.5.5 1 ttable.6.6 1 ttable.7.7 1 } # share the microphone, i.e. because virtualbox grabs it by default pcm.microphone { type dsnoop ipc_key 1027 slave { pcm "snd_card" } } # rate conversion, needed i.e. for wine pcm.2chplug { type plug slave.pcm "ch71dup" } pcm.a2chplug { type plug slave.pcm "dmix8" } # routes the channel for the alternative # 2 channel output, which becomes the 7th and 8th channel # on the real soundcard #pcm.alt2ch { # type route # slave.pcm "a2chplug" # slave.channels 8 # ttable.0.6 1 # ttable.1.7 1 #} # skype and ekiga are only mono, so route left channel to the right channel # note: this gets routed to the alternative 2 channels pcm.mono_playback { type route slave.pcm "a2chplug" slave.channels 8 # Send Skype channel 0 to the L and R speakers at full volume #ttable.0.6 1 #ttable.0.7 1 } # 'full-duplex' device for use with aoss pcm.duplex { type asym playback.pcm "2chplug" capture.pcm "microphone" } #pcm.aduplex { # type asym # playback.pcm "alt2ch" # capture.pcm "microphone" #} pcm.monoduplex { type asym playback.pcm "mono_playback" capture.pcm "microphone" } # for aoss pcm.dsp0 "duplex" ctl.mixer0 "duplex" # softvol manages volume in alsa # i.e. wine likes this pcm.mainvol { type softvol slave.pcm "duplex" control { name "2ch-Upmix Master" card 0 } } #pcm.!default "mainvol" # set the default device according to the environment # variable ALSA_DEFAULT_PCM and default to mainvol pcm.!default { @func refer name { @func concat strings [ "pcm." { @func getenv vars [ ALSA_DEFAULT_PCM ] default "mainvol" } ] } } # uncomment the following if you want to be able to control # the mixer device through environment variables as well #ctl.!default { # @func refer # name { @func concat # strings [ "ctl." # { @func getenv # vars [ ALSA_DEFAULT_CTL # ALSA_DEFAULT_PCM # ] # default "duplex" # } # ] # } #} ```
Advanced Linux Sound Architecture/Configuration examples
Surround51 incl. upmix stereo & dmix, swap L/R, bad speaker position in room
## Surround51 incl. upmix stereo & dmix, swap L/R, bad speaker position in room Bad practice but works fine for almost everything without additional per-program/file customization: ``` pcm.!default { type route ## forwards to the mixer pcm defined below slave.pcm dmix51 slave.channels 6 ## "Native Channels" stereo, swap left/right ttable.0.1 1 ttable.1.0 1 ## original normal left/right commented out # ttable.0.0 1 # ttable.1.1 1 ## route "native surround" so it still works but weaken signal (+ RL/RF swap) ## because my rear speakers are more like random than really behind me ttable.2.3 0.7 ttable.3.2 0.7 ttable.4.4 0.7 ttable.5.5 0.7 ## stereo => quad speaker "upmix" for "rear" speakers + swap L/R ttable.0.3 1 ttable.1.2 1 ## stereo L+R => join to Center & Subwoofer 50%/50% ttable.0.4 0.5 ttable.1.4 0.5 ttable.0.5 0.5 ttable.1.5 0.5 ## to test: "$ speaker-test -c6 -twav" and: "$ speaker-test -c2 -twav" } pcm.dmix51 { type dmix ipc_key 1024 # let multiple users share ipc_key_add_uid false # IPC permissions (octal, default 0600) # I think changing this fixed something - but I'm not sure what. ipc_perm 0660 # slave { ## this is specific to my hda_intel. Often hd:0 is just allready it; To find: $ aplay -L pcm surround51 # this rate makes my soundcard crackle # rate 44100 # this rate stops flash in firefox from playing audio, but I do not need that rate 48000 channels 6 ## Any other values in the 4 lines below seem to make my soundcard crackle, too period_time 0 period_size 1024 buffer_time 0 buffer_size 4096 } } ```
Advanced Linux Sound Architecture/Configuration examples
Loopback interface with dmix external interface
## Loopback interface with dmix external interface Used to control which output goes to external, loopback, or both. Others have reported working setups without specifying format [\[1\]](https://unix.stackexchange.com/questions/194547/how-can-i-use-alsa-dmix-and-multi-plugins-together) ``` # Use this to output to external pcm.dmixerout { type dmix ipc_key 1024 ipc_key_add_uid false slave { pcm "hw:CARDNAME,0" channels 2 period_time 0 period_size 1024 buffer_size 4096 rate 44100 } bindings { 0 0 1 1 } } # Use this to output to loopback pcm.dmixerloop { type dmix ipc_key 2048 ipc_key_add_uid false slave { pcm "hw:Loopback,0,0" channels 2 period_time 0 period_size 1024 buffer_size 4096 # If format is absent ALSA gives me slave PCM not usable, but it works w/o it for others format S32_LE rate 44100 } bindings { 0 0 1 1 } } # Sends to the two dmix interfaces pcm.quad { type multi # Necessary to have both slaves be dmix; both as hw doesn't give errors, but wouldn't slaves.a.pcm "dmixerout" slaves.a.channels 2 slaves.b.pcm "dmixerloop" slaves.b.channels 2 bindings { 0 { slave a; channel 0; } 1 { slave a; channel 1; } 2 { slave b; channel 0; } 3 { slave b; channel 1; } } } # Duplicates to quad, use this to output to loopback & external pcm.stereo2quad { type route slave.pcm "quad" # ttable.A.B G # where A - input channel # B - output channel # G - volume gain (1.0 = original) ttable.0.0 1 ttable.1.1 1 ttable.0.2 1 ttable.1.3 1 } # Listens to loopback # trying to play to stereo2quad when something is already listening gives me slave PCM not usable # but listening when something is already playing on stereo2quad works # and so does starting to listen, then playing to dmixerloop pcm.loopin { type dsnoop ipc_key 1111 ipc_key_add_uid false slave.pcm "hw:Loopback,1" } pcm.!default { type asym playback.pcm "plug:stereo2quad" capture.pcm "plug:loopin" } ``` [Category](../../Special:Categories.html "Special:Categories"): * [Sound](../../en/Category:Sound.html "Category:Sound") - Retrieved from "<https://wiki.archlinux.org/index.php?title=Advanced_Linux_Sound_Architecture/Configuration_examples&oldid=658725>" - This page was last edited on 10 April 2021, at 09:22. - Content is available under [GNU Free Documentation License 1.3 or later](https://www.gnu.org/copyleft/fdl.html) unless otherwise noted. * [Privacy policy](https://terms.archlinux.org/docs/privacy-policy/) * [About ArchWiki](../../en/ArchWiki:About.html) * [Disclaimers](../../en/ArchWiki:General_disclaimer.html) * [Code of conduct](https://terms.archlinux.org/docs/code-of-conduct/ "archlinux-service-agreements:code-of-conduct") * [Terms of service](https://terms.archlinux.org/docs/terms-of-service/ "archlinux-service-agreements:terms-of-service") - [![GNU Free Documentation License 1.3 or later](/resources/assets/licenses/gnu-fdl.png)](https://www.gnu.org/copyleft/fdl.html) - ![](/resources/assets/poweredby_mediawiki_88x31.png) * Toggle limited content width
Advanced Linux Sound Architecture/Troubleshooting
Intro
# Advanced Linux Sound Architecture/Troubleshooting \[ ] 2 languages * [日本語](https://wiki.archlinux.jp/index.php/Advanced_Linux_Sound_Architecture/%E3%83%88%E3%83%A9%E3%83%96%E3%83%AB%E3%82%B7%E3%83%A5%E3%83%BC%E3%83%86%E3%82%A3%E3%83%B3%E3%82%B0 "Advanced Linux Sound Architecture/トラブルシューティング – 日本語") * [中文(简体)](https://wiki.archlinuxcn.org/wiki/Advanced_Linux_Sound_Architecture/Troubleshooting "Advanced Linux Sound Architecture/Troubleshooting – 中文(简体)") From ArchWiki < [Advanced Linux Sound Architecture](../../en/Advanced_Linux_Sound_Architecture.html "Advanced Linux Sound Architecture")
Advanced Linux Sound Architecture/Troubleshooting
Volume
## Volume ### No output If `speaker-test` produces sound but some other program does not, determine whether [PulseAudio](../../en/PulseAudio.html "PulseAudio") is being used: ``` # fuser -v /dev/snd/* ``` If it is, try using [apulse](https://aur.archlinux.org/packages/apulse/)AUR, as described in [Advanced Linux Sound Architecture#PulseAudio compatibility](../../en/Advanced_Linux_Sound_Architecture.html#PulseAudio_compatibility "Advanced Linux Sound Architecture"). Alternatively, killing the PulseAudio process may cause sound to start working in the desired process. ### Output is muted after reboot Run the following command: ``` # alsactl restore ``` If the problem persists, verify that the `Auto-Mute` option in *alsamixer* is set to `Disabled`. ### Volume is too low Run *alsamixer* and try to increase the value of the sliders, unmuting channels if necessary. Note that if you have many sliders, you may have to scroll to the right to see any missing sliders. If all the sliders are maxed out, and the volume is still too low, you can try running the following script to reset your codec settings: ``` $ wget -O hda-analyzer.py https://git.alsa-project.org/?p=alsa.git;a=blob_plain;f=hda-analyzer/run.py ``` Close the analyzer, and when prompted as to whether you want to reset the codecs, say "yes". If the volume is still too low, run *alsamixer* again: resetting the codecs may have caused new sliders to become enabled and some of them may be set to a low value. ### Volume is still too low If you are facing low volume even after maxing out your speakers/headphones, you can give the softvol plugin a try. Add the following to `/etc/asound.conf`. ``` /etc/asound.conf ``` ``` pcm.!default { type plug slave.pcm "softvol" } pcm.softvol { type softvol slave { pcm "dmix" } control { name "Pre-Amp" card 0 } min_dB -5.0 max_dB 20.0 resolution 6 } ``` **Note:** You will probably have to restart the computer, as restarting the alsa daemon did not load the new configuration. Also, if the configuration does not work even after restarting, try changing `plug` with `hw` in the above configuration. After the changes are loaded successfully, you will see a `Pre-Amp` section in alsamixer. You can adjust the levels there. **Note:** * Setting a high value for `Pre-Amp` can cause sound distortion, so adjust it according to the level that suits you. * Some audio codecs may need to have settings adjusted in the HDA Analyzer (see [#Volume is too low](#Volume_is_too_low)) in order to achieve proper volume without distortion. Checking the HP option under widget control in the Playback Switch (Node\[0x14] PIN in the ALC892 codec, for instance) can sometimes improve audio quality and volume significantly. ### Random lack of sound on startup You can quickly test sound by running `speaker-test`. If there is no sound, you may see something similar to: ``` ALSA lib pcm_dmix.c:1022:(snd_pcm_dmix_open) unable to open slave Playback open error: -16 Device or resource busy ``` If you have no sound on startup, this may be because your system has multiple sound cards, and their order may sometimes change on startup. If this is the case, try [setting the default sound card](../../en/Advanced_Linux_Sound_Architecture.html#Set_the_default_sound_card "ALSA"). If you use [MPD](../../en/Music_Player_Daemon.html "MPD") and the above configuration tips do not work, try following <https://mpd.wikia.com/wiki/Configuration#ALSA_MPD_software_volume_control>.
Advanced Linux Sound Architecture/Troubleshooting
Microphone
## Microphone ### No microphone input In alsamixer, make sure that all the volume levels are up under recording, and that CAPTURE is toggled active on the microphone (e.g. Mic, Internal Mic) and/or on Capture (in alsamixer, select these items and press space). Try making positive Mic Boost and raising Capture and Digital levels higher; this may make static or distortion, but then you can adjust them back down once you are hearing *something* when you record As the pulseaudio wrapper is shown as "default" in alsamixer, you may have to press F6 to select your actual soundcard first. You may also need to enable and increase the volume of Line-in in the Playback section. To test the microphone, run these commands (see [arecord(1)](https://man.archlinux.org/man/arecord.1) for further information): ``` $ arecord --duration=5 --format=dat test-mic.wav $ aplay test-mic.wav ``` Alternatively, you can run this command: ``` $ arecord -vv --format=dat /dev/null ``` alongside alsamixer to easily identify channel which you should select and unmute. To test a particular device, use the `--device` parameter followed by the hardware PCM name in the form `hw:C,D` for card *C* device *D*, or `plughw:C,D` for plugged hardware. For instance: ``` $ arecord -vvv --format=dat --device=plughw:0,0 /dev/null ``` If all fails, you may want to eliminate hardware failure by testing the microphone with a different device. For at least some computers, muting a microphone (MM) simply means its input does not go immediately to the speakers. It still receives input. Many Dell laptops need "-dmic" to be appended to the *model* [kernel module parameter](../../en/Kernel_module.html#Setting_module_options "Kernel module parameter"): ``` options snd-hda-intel model=dell-m6-dmic ``` Some programs use try to use OSS as the main input software. If you have enabled the `snd_pcm_oss`, `snd_mixer_oss` or `snd_seq_oss` [kernel modules](../../en/Kernel_module.html "Kernel modules") previously (they are not loaded by default), try unloading them. See also: * <https://www.alsa-project.org/main/index.php/SoundcardTesting> * <https://alsa.opensrc.org/Record_from_mic> ### Setting the default microphone/capture device Some applications (Pidgin, Adobe Flash) do not provide an option to change the capture device. It becomes a problem if your microphone is on a separate device (e.g. USB webcam or microphone) than your internal sound card. To change only the default capture device, leaving the default playback device as is, you can modify your `~/.asoundrc` file to include the following: ``` ~/.asoundrc ``` ``` pcm.usb { type hw card U0x46d0x81d } pcm.!default { type asym playback.pcm { type plug slave.pcm "dmix" } capture.pcm { type plug slave.pcm "usb" } } ``` Replace *U0x46d0x81d* with your capture device's card name in ALSA. You can use `arecord -L` to list all the capture devices detected by ALSA. ### Internal microphone not working First make sure the volume is enabled under the `Capture` view in *alsamixer*. In some cases, the "Internal Microphone" is not displayed in the capture list available when pressing F4. If so, specifying the card number given by `aplay -l` to start *alsamixer* (for example `alsamixer -c 0` ) can make it appear. If still unsucessful, add the following [kernel module parameter](../../en/Kernel_module.html#Setting_module_options "Kernel module parameter"): ``` /etc/modprobe.d/snd-hda-intel.conf ``` ``` options snd-hda-intel enable_msi=1 ``` Then reload the module: ``` # rmmod snd-hda-intel && modprobe snd-hda-intel ``` Now there should be an additional input under the previously mentioned `Capture` view. ### Crackling microphone If you are getting a crackling or popping sound from your microphone that cannot be resolved with ALSA settings or cleaning your microphone jack, try adding the following [kernel module parameter](../../en/Kernel_module.html#Setting_module_options "Kernel module parameter"): ``` options snd-hda-intel model=MODEL position_fix=3 ``` This option will fix crackling on pure ALSA, but will cause issues with PulseAudio. To let PulseAudio use these settings effectively, edit `/etc/pulse/default.pa` and add the `tsched=0` parameter to `module-udev-detect`: ``` /etc/pulse/default.pa ``` ``` load-module module-udev-detect tsched=0 ``` See <https://docs.kernel.org/sound/hd-audio/notes.html#dma-position-problem>
Advanced Linux Sound Architecture/Troubleshooting
Audio Quality
## Audio Quality ### Crackling sound through mini-jack (headphones connector) Following [Advanced Linux Sound Architecture#Simultaneous output](../../en/Advanced_Linux_Sound_Architecture.html#Simultaneous_output "Advanced Linux Sound Architecture") might lead to crackling sound through headphones or external speakers. This can be fixed by muting **or** setting the volume to 0% on *Mic*. Use `alsamixer` or `amixer`: ``` $ amixer sset "Mic" 0% $ amixer sset "Mic" mute ``` ### Popping sound after resuming from suspension You might hear a popping sound after resuming the computer from suspension. This can be fixed by editing `/etc/pm/sleep.d/90alsa` and removing the line that says `aplay -d 1 /dev/zero` ### Sound skipping during playback Run *alsamixer*, and if channels exist for nonexistent output devices then disable them (e.g. *alsamixer* showing a center speaker but you not having one). ### Poor sound quality or clipping If you experience poor sound quality, try setting the PCM volume (in alsamixer) to a level such that gain is 0. If snd-usb-audio driver has been loaded, you could try to enable `softvol`: ``` /etc/asound.conf ``` ``` pcm.!default { type plug slave.pcm "softvol" } pcm.dmixer { type dmix ipc_key 1024 slave { pcm "hw:0" period_size 4096 buffer_size 131072 rate 50000 } bindings { 0 0 1 1 } } pcm.dsnooper { type dsnoop ipc_key 1024 slave { pcm "hw:0" channels 2 period_size 4096 buffer_size 131072 rate 50000 } bindings { 0 0 1 1 } } pcm.softvol { type softvol slave { pcm "dmixer" } control { name "Master" card 0 } } ctl.!default { type hw card 0 } ctl.softvol { type hw card 0 } ctl.dmixer { type hw card 0 } ``` ### Pops when starting and stopping playback Some modules (e.g. `snd_ac97_codec` and `snd_hda_intel`) can power off your sound card when it is not used. This can make an audible noise (like a crack/pop/scratch) when turning on/off your sound card. Sometimes even when moving the volume slider or opening and closing windows on some desktop environments. If you find this annoying, try `modinfo your_module` and look for a module option that adjusts or disables this feature. For example, to disable the power saving mode for the `snd_hda_intel` module, add the following [kernel module parameter](../../en/Kernel_module.html#Setting_module_options "Kernel module parameter"): ``` options snd_hda_intel power_save=0 ``` You may also need to disable power saving for the audio card controller: ``` options snd_hda_intel power_save=0 power_save_controller=N ``` You may also have to unmute the 'Line' ALSA channel for this to work. Any value will do (other than '0' or something too high). For example, on an onboard VIA VT1708S (using the `snd_hda_intel` module) these cracks occurred even when `power_save` was set to 0. Unmuting the 'Line' channel and setting a value of '1' solved the problem. See <https://docs.kernel.org/sound/designs/powersave.html> ### Sound skipping while using dynamic CPU frequency scaling ![](../../File:View-refresh-red.svg)**This article or section is out of date.** **Reason:** The `ondemand` governor was the default for a while, but has [been replaced](https://gitlab.archlinux.org/archlinux/packaging/packages/linux/-/commit/83345a2f829af62ce6fd4b4fa3a875b8f6560f43) for years by `schedutil`, is this still applicable? (Discuss in [Talk:Advanced Linux Sound Architecture/Troubleshooting](../../en/Talk:Advanced_Linux_Sound_Architecture/Troubleshooting.html)) Some combinations of ALSA drivers and chipsets may cause audio from all sources to skip when used in combination with a dynamic frequency [scaling governor](../../en/CPU_frequency_scaling.html#Scaling_governors "Scaling governor") such as `ondemand` or `conservative`. Currently, the solution is to switch back to the `performance` governor. Refer to [CPU frequency scaling](../../en/CPU_frequency_scaling.html "CPU frequency scaling") for more information.
Advanced Linux Sound Architecture/Troubleshooting
Hardware and Cards
## Hardware and Cards ### Verifying output parameters Check the contents of `/proc/asound/cardX/pcmYp/subZ/hw_params`, where `X`, `Y`, and `Z` are system dependent. In order to find this file, execute the following command while outputting anything via ALSA: ``` $ find /proc/asound/ -name hw_params | xargs -I FILE grep -v -l "closed" FILE | grep '/proc/asound/card./pcm.p/sub./hw_params' ``` If nothing is playing there should be no results. Here is an example output for audio with a [bit depth](https://en.wikipedia.org/wiki/Audio_bit_depth "wikipedia:Audio bit depth") of 24 bits and a [sampling frequency](https://en.wikipedia.org/wiki/Sampling_frequency "wikipedia:Sampling frequency") of 44.1 kilohertz: ``` $ cat /proc/asound/card1/pcm0p/sub0/hw_params ``` ``` access: RW_INTERLEAVED format: S24_3LE subformat: STD channels: 2 rate: 44100 (44100/1) period_size: 5513 buffer_size: 22050 ``` More info is available in the [ALSA documentation](https://alsa.opensrc.org/Proc_asound_documentation). ### Error 'Unknown hardware' appears after kernel update The following messages may be displayed during ALSA's initialization: ``` Unknown hardware "foo" "bar" ... Hardware is initialized using a guess method /usr/bin/alsactl: set_control:nnnn:failed to obtain info for control #mm (No such file or directory) ``` or: ``` Found hardware: "HDA-Intel" "VIA VT1705" "HDA:11064397,18490397,00100000" "0x1849" "0x0397" Hardware is initialized using a generic method /usr/bin/alsactl: set_control:1328: failed to obtain info for control #1 (No such file or directory) /usr/bin/alsactl: set_control:1328: failed to obtain info for control #2 (No such file or directory) /usr/bin/alsactl: set_control:1328: failed to obtain info for control #25 (No such file or directory) /usr/bin/alsactl: set_control:1328: failed to obtain info for control #26 (No such file or directory) ``` Simply store ALSA mixer settings again: ``` # alsactl -f /var/lib/alsa/asound.state store ``` It may be necessary configure ALSA again with alsamixer ### Fix wrong audio pin mapping If the mappings to your audio pins(plugs) do not correspond but ALSA works fine, you could try HDA Analyzer -- a pyGTK2 GUI for HD-audio control can be found [at the ALSA wiki](https://www.alsa-project.org/main/index.php/HDA_Analyzer). Try tweaking the Widget Control section of the PIN nodes, to make microphones IN and headphone jacks OUT. Referring to the Config Defaults heading is a good idea. **Note:** The script is incompatible with Python 3, which is the default Python implementation on Arch Linux. In order to use the script, replace all occurrences of `python` in the `run.py` file with `python2` to point the script to the Python 2 version. Then make the script [executable](../../en/File_permissions_and_attributes.html#Changing_permissions "Chmod") and run it. ### S/PDIF output does not work If the optical/coaxial digital output of your motherboard/sound card is not working or stopped working, and have already enabled and unmuted it in alsamixer, try running the following: ``` $ iecset audio on ``` You can also put this command in an enabled [systemd](../../en/Systemd.html "Systemd") service as it sometimes it may stop working after a reboot. ### Conflicting PC speaker If you are sure nothing is muted, that your drivers are installed correctly, and that your volume is right, but you still do not hear anything, then try the following [kernel module parameters](../../en/Kernel_module.html#Setting_module_options "Kernel module parameter"): ``` options snd-NAME-OF-MODULE ac97_quirk=0 ``` The above fix has been observed to work with `via82xx` ``` options snd-NAME-OF-MODULE ac97_quirk=1 ``` The above fix has been reported to work with `snd-intel8x0` ### HP TX2500 Use these [kernel module parameters](../../en/Kernel_module.html#Setting_module_options "Kernel module parameter"): ``` options snd-cmipci mpu_port=0x330 fm_port=0x388 options snd-hda-intel index=0 model=toshiba position_fix=1 options snd-hda-intel model=hp (works for tx2000cto) ``` ### No sound when S/PDIF video card is installed Discover available modules and their order: ``` $ cat /proc/asound/modules ``` ``` 0 snd_hda_intel 1 snd_ca0106 ``` Disable the undesired video card audio codec in `/etc/modprobe.d/modprobe.conf`: ``` /etc/modprobe.d/modprobe.conf ``` ``` install snd_hda_intel /bin/false ``` If both devices use the same module then you can use the `enable` [kernel module parameter](../../en/Kernel_module.html#Setting_module_options "Kernel module parameter") from snd\_hda\_intel module; it is an array of booleans that can enable/disable the desired sound card. ``` options snd_hda_intel enable=1,0 ``` ### Wrong sound card model type Although ALSA detects your soundcard through the BIOS, at times ALSA may not be able to recognize your [model type](https://docs.kernel.org/sound/hd-audio/models.html). The soundcard chip can be found in `alsamixer` (e.g. ALC662) and the model can be set as [kernel module parameters](../../en/Kernel_module.html#Setting_module_options "Kernel module parameter"): ``` options snd-hda-intel model=MODEL ``` There are other model settings too. For most cases ALSA defaults will do. If you want to look at more specific settings for your soundcard take a look at the [ALSA Soundcard List](https://bugtrack.alsa-project.org/main/index.php/Matrix:Main) find your model, then Details, then look at the "Setting up modprobe..." section. Enter these values in `/etc/modprobe.d/modprobe.conf`. For example, for an Intel AC97 audio: ``` # ALSA portion alias char-major-116 snd alias snd-card-0 snd-intel8x0 # module options should go here # OSS/Free portion alias char-major-14 soundcore alias sound-slot-0 snd-card-0 # card #1 alias sound-service-0-0 snd-mixer-oss alias sound-service-0-1 snd-seq-oss alias sound-service-0-3 snd-pcm-oss alias sound-service-0-8 snd-seq-oss alias sound-service-0-12 snd-pcm-oss ``` ### Intel onboard sound #### No sound with onboard Intel sound card There may be a problem with two conflicting modules loaded, namely `snd-intel8x0` and `snd-intel8x0m`. In this case, [blacklist](../../en/Kernel_module.html#Blacklisting "Blacklist") `snd-intel8x0m`. *Muting* the "External Amplifier" in `alsamixer` or `amixer` may also help. See [the ALSA wiki](https://alsa.opensrc.org/Intel8x0#Dell_Inspiron_8600_.28and_probably_others.29). Unmuting the "Mix" setting in the mixer might help, also. #### No headphone sound with onboard intel sound card With some laptops, you may need to add the following [kernel module parameter](../../en/Kernel_module.html#Setting_module_options "Kernel module parameter"): ``` options snd-hda-intel model=model ``` Where *model* is any of the ones listed in the [kernel documentation](https://docs.kernel.org/sound/hd-audio/models.html), but check that it is the correct version of that document for your kernel version. **Note:** It may be necessary to put this "options" line below (after) any "alias" lines about your card. To know your chip name type the following command (with \* being corrected to match your files). Note that some chips could have been renamed and do not directly match the available ones in the file. ``` $ grep Codec /proc/asound/card*/codec* ``` Note that there is a high chance none of the input devices (all internal and external mics) will work if you choose to do this, so it is either your headphones or your mic. Please report to ALSA if you are affected by this bug. And also, if you have problems getting beeps to work (pcspkr): ``` options snd-hda-intel model=model enable=1 index=0 ``` ### HDMI #### HDMI Output does not work The procedure described below can be used to test HDMI audio. Before proceeding, make sure you have enabled and unmuted the output with `alsamixer`. Connect your PC to the Display via HDMI cable and enable the display with [xrandr](../../en/Xrandr.html "Xrandr"). Use `aplay -l` to discover the card and device number. For example: ``` $ aplay -l ``` ``` **** List of PLAYBACK Hardware Devices **** card 0: SB [HDA ATI SB], device 0: ALC892 Analog [ALC892 Analog] Subdevices: 1/1 Subdevice #0: subdevice #0 card 0: SB [HDA ATI SB], device 1: ALC892 Digital [ALC892 Digital] Subdevices: 1/1 Subdevice #0: subdevice #0 card 1: Generic [HD-Audio Generic], device 3: HDMI 0 [HDMI 0] Subdevices: 1/1 Subdevice #0: subdevice #0 ``` Send sound to the device. Following the example in the previous step, you would send sound to `card 1`, `device 3`: ``` $ aplay -D plughw:1,3 /usr/share/sounds/alsa/Front_Center.wav ``` If aplay does not output any errors, but still no sound is heard, "reboot" the receiver, monitor or tv set. Since the HDMI interface executes a handshake on connection, it might have noticed before that there was no audio stream embedded, and disabled audio decoding. If you are using a standalone window manager, you may need to have sound playing while plugging in the HDMI cable. mplay and other application could be configured to use special HDMI device as audio output. But flashplugin could only use default device. The following method is used to override default device. But you need to change it back when your TV is disconnected from HDMI port. If the test is successful, create or edit your `~/.asoundrc` file to set HDMI as the default audio device. ``` ~/.asoundrc ``` ``` pcm.!default { type hw card 1 device 3 } ``` Or if the above configuration does not work try: ``` ~/.asoundrc ``` ``` defaults.pcm.card 1 defaults.pcm.device 3 defaults.ctl.card 1 ``` Or if you alternatively succeed with ``` $ speaker-test -Dplug:hdmi ``` for your HDMI or DisplayPort port the following configuration will work (successfully tested on Lenovo ThinkPad T430s): ``` ~/.asoundrc ``` ``` pcm.!default { type plug slave.pcm "hdmi" } ``` #### PCM through HDMI does not work (Intel Gfx) As of Linux 3.1 multi-channel PCM output through HDMI with a Intel card (Intel Eaglelake, IbexPeak/Ironlake,SandyBridge/CougarPoint and IvyBridge/PantherPoint) is not yet supported. Support for it has been recently added and expected to be available in Linux 3.2. To make it work in Linux 3.1 you need to apply the following patches: * [drm: support routines for HDMI/DP ELD](https://git.kernel.org/?p=linux/kernel/git/torvalds/linux.git;a=patch;h=76adaa34db407f174dd06370cb60f6029c33b465) * [drm/i915: pass ELD to HDMI/DP audio driver](https://git.kernel.org/?p=linux/kernel/git/torvalds/linux.git;a=patch;h=e0dac65ed45e72fe34cc7ccc76de0ba220bd38bb) #### HDMI 5.1 sound goes to wrong speakers Sound can be redirected to the intended speakers using ALSA's `remap` function. ``` /etc/asound.conf ``` ``` pcm.!hdmi-remap { type asym playback.pcm { type plug slave.pcm "remap-surround51" } } pcm.!remap-surround51 { type route slave.pcm "hw:0,3" ttable { 0.0= 1 1.1= 1 2.4= 1 3.5= 1 4.2= 1 5.3= 1 } } ``` ### Intel Cannon Lake PCH cAVS ![](../../File:View-refresh-red.svg)**This article or section is out of date.** **Reason:** User reports of the kernel parameter no longer being needed. No bug report linked to follow up… (Discuss in [Talk:Advanced Linux Sound Architecture/Troubleshooting](../../en/Talk:Advanced_Linux_Sound_Architecture/Troubleshooting.html)) On Intel Cannon Lake (eg. HP ZBook 15 G6), the integrated sound chipset requires [ALSA firmware](../../en/Advanced_Linux_Sound_Architecture.html#ALSA_firmware "ALSA firmware"), and the following [kernel module parameters](../../en/Kernel_module.html#Setting_module_options "Kernel module parameter") are required: ``` options snd-hda-intel dmic_detect=0 options snd-hda-intel model=laptop-amic enable=yes ``` That should enable both sound and microphone.
Advanced Linux Sound Architecture/Troubleshooting
Applications
## Applications ### SDL: No sound with SDL applications If you get no sound using SDL based applications, try setting the [environment variable](../../en/Environment_variables.html "Environment variable") `SDL_AUDIODRIVER` to `alsa`. ### OpenAL: No sound in applications that use OpenAL OpenAL defaults to PulseAudio. To instruct it to try ALSA first: ``` /etc/openal/alsoft.conf ``` ``` drivers=alsa,pulse ``` ### VirtualBox: Virtual machine has no sound If you experience problems with VirtualBox, the following command might be helpful: ``` $ alsactl init ``` ``` Found hardware: "ICH" "SigmaTel STAC9700,83,84" "AC97a:83847600" "0x8086" "0x0000" Hardware is initialized using a generic method ``` You might need to activate the ALSA output in your audio software as well. You might also try selecting different sound devices in your virtual machine settings to find one that works. ### Others: Generic application problems For other applications who insist on their own audio setup, e.g., XMMS or MPlayer, you would need to set their specific options. For [MPlayer](../../en/MPlayer.html "MPlayer") or [mpv](../../en/Mpv.html "Mpv"), add the following line to the respective configuration file: ``` ao=alsa ``` Eg. for XMMS2, go into their options and make sure the sound driver is set to ALSA, not oss. To do this in XMMS: * Open XMMS * Options > Preferences. * Choose the ALSA output plugin. For applications which do not provide a ALSA output, you can use aoss from the alsa-oss package. To use aoss, when you run the program, prefix it with `aoss`, e.g.: ``` aoss realplay ``` pcm.!default{ ... } doesnt work for me anymore. but this does: ``` pcm.default pcm.dmixer ```
Advanced Linux Sound Architecture/Troubleshooting
Other Issues
## Other Issues ### Simultaneous playback problems If you are having problems with simultaneous playback, and if [PulseAudio](../../en/PulseAudio.html "PulseAudio") is installed, its default configuration is set to "hijack" the soundcard. Some users of ALSA may not want to use [PulseAudio](../../en/PulseAudio.html "PulseAudio") and are quite content with their current ALSA settings. One fix is to edit `/etc/asound.conf` and comment out the following lines: ``` # Use PulseAudio by default pcm.!default { type pulse fallback "sysdefault" hint { show on description "Default ALSA Output (currently PulseAudio Sound Server)" } } ``` Commenting the following out also may help: ``` ctl.!default { type pulse fallback "sysdefault" } ``` This may be a much simpler solution than completely uninstalling [PulseAudio](../../en/PulseAudio.html "PulseAudio"). Effectively, here is an example of a working `/etc/asound.conf`: ``` pcm.dmixer { type dmix ipc_key 1024 ipc_key_add_uid 0 ipc_perm 0660 } pcm.dsp { type plug slave.pcm "dmix" } ``` **Note:** This `/etc/asound.conf` file was intended for and used successfully with a global [MPD](../../en/Music_Player_Daemon.html "MPD") configuration. See [#Problems with availability to only one user at a time](#Problems_with_availability_to_only_one_user_at_a_time). **Note:** Alternatively, if you do **not** have PulseAudio installed, and just want to get `dmix` to work with vanilla ALSA, see the [upstream documentation](https://www.alsa-project.org/main/index.php/Asoundrc#dmix). In particular, you probably want to replace `dsp` in the above config with `!default`. Also, if you notice this causes certain applications to skip while playing (i.e. sound "glitchy"), and complain about underrun occurring, you may want to tweak the `slave.buffer_size` inside `pcm.dmixer`. ### Removing old ALSA state file (asound.state) The [alsa-utils](https://archlinux.org/packages/?name=alsa-utils) package provides `alsa-store.service` which automatically stores the current ALSA state to `/var/lib/alsa/asound.state` upon system shutdown. This can be problematic for users who are trying to reset their current ALSA state as the `asound.state` file will be recreated with the current state upon every shutdown (e.g., attempting to remove user-defined channels from the mixer). The `alsa-store.service` service may be temporarily disabled by creating the following empty file: ``` # mkdir -p /etc/alsa # touch /etc/alsa/state-daemon.conf ``` The presence of `state-daemon.conf` prevents `alsa-store.service` from saving `asound.state` during shutdown. After disabling this service, the `asound.state` file may be removed as such: ``` # rm /var/lib/alsa/asound.state ``` After rebooting, the previous ALSA state should be lost and the current state should be reset to defaults. Re-enable `alsa-store.service` by deleting the condition file we created: ``` # rm /etc/alsa/state-daemon.conf ``` On the next shutdown, the `asound.state` file should be recreated with ALSA defaults. The file may also be generated immediately using: ``` # alsactl store ``` If you want to clean ALSA state without rebooting, you can use `rmmod` to remove the sound driver module, then manually delete the unwanted entries in `asound.state`, and then use `modprobe` to reinstall the sound driver module. ### Problems with availability to only one user at a time You might find that only one user can use the dmixer at a time. This is probably ok for most, but for those who run [mpd](../../en/Music_Player_Daemon.html "Mpd") as a separate user this poses a problem. When mpd is playing a normal user cannot play sounds though the dmixer. While it is quite possible to just run mpd under a user's login account, another solution has been found. Adding the line `ipc_key_add_uid 0` to the `pcm.dmixer` block disables this locking. The following is a snippet from `asound.conf`, the rest is the same as above. ``` ... pcm.dmixer { type dmix ipc_key 1024 ipc_key_add_uid 0 ipc_perm 0660 slave { ... ``` ### Crackling/popping on Dell laptops Check if you have [i8kutils](https://aur.archlinux.org/packages/i8kutils/)AUR installed and if anything (e.g. `i8kmon.service`) is reading or writing to the interface exposed by the module, as i8kutils BIOS system calls block the kernel for a moment on some systems. See warning in [Fan speed control#Dell laptops](../../en/Fan_speed_control.html#Dell_laptops "Fan speed control") for more details. [Category](../../Special:Categories.html "Special:Categories"): * [Sound](../../en/Category:Sound.html "Category:Sound") Hidden category: * [Pages or sections flagged with Template:Out of date](../../en/Category:Pages_or_sections_flagged_with_Template:Out_of_date.html "Category:Pages or sections flagged with Template:Out of date") - Retrieved from "<https://wiki.archlinux.org/index.php?title=Advanced_Linux_Sound_Architecture/Troubleshooting&oldid=809018>" - This page was last edited on 22 May 2024, at 15:33. - Content is available under [GNU Free Documentation License 1.3 or later](https://www.gnu.org/copyleft/fdl.html) unless otherwise noted. * [Privacy policy](https://terms.archlinux.org/docs/privacy-policy/) * [About ArchWiki](../../en/ArchWiki:About.html) * [Disclaimers](../../en/ArchWiki:General_disclaimer.html) * [Code of conduct](https://terms.archlinux.org/docs/code-of-conduct/ "archlinux-service-agreements:code-of-conduct") * [Terms of service](https://terms.archlinux.org/docs/terms-of-service/ "archlinux-service-agreements:terms-of-service") - [![GNU Free Documentation License 1.3 or later](/resources/assets/licenses/gnu-fdl.png)](https://www.gnu.org/copyleft/fdl.html) - ![](/resources/assets/poweredby_mediawiki_88x31.png) * Toggle limited content width
Apache HTTP Server/mod fcgid
Intro
# Apache HTTP Server/mod fcgid \[ ] 2 languages * [Español](../../es/Apache_HTTP_Server/mod_fcgid.html "Apache HTTP Server (Español)/mod fcgid – español") * [日本語](https://wiki.archlinux.jp/index.php/Apache_HTTP_Server/mod_fcgid "Apache HTTP Server/mod fcgid – 日本語") From ArchWiki < [Apache HTTP Server](../../en/Apache_HTTP_Server.html "Apache HTTP Server") ![](../../File:Tango-edit-clear.svg)**This article or section needs language, wiki syntax or style improvements. See [Help:Style](../../en/Help:Style.html "Help:Style") for reference.** **Reason:** bad style (Discuss in [Talk:Apache HTTP Server/mod fcgid](../../en/Talk:Apache_HTTP_Server/mod_fcgid.html)) [mod\_fcgid](https://httpd.apache.org/mod_fcgid/) is a FastCGI module for Apache with a GPL license. [apache](https://archlinux.org/packages/?name=apache) 2.4 now provides an official module, [mod\_proxy\_fcgi](https://httpd.apache.org/docs/2.4/mod/mod_proxy_fcgi.html). See [configuration example for php-fpm](https://wiki.apache.org/httpd/PHP-FPM) and [Apache HTTP Server#Using php-fpm and mod\_proxy\_fcgi](../../en/Apache_HTTP_Server.html#Using_php-fpm_and_mod_proxy_fcgi "Apache HTTP Server").
Apache HTTP Server/mod fcgid
Installation
## Installation [Install](../../en/Help:Reading.html#Installation_of_packages "Install") the [mod\_fcgid](https://aur.archlinux.org/packages/mod_fcgid/)AUR package.
Apache HTTP Server/mod fcgid
Usage
## Usage First you need to load the fastcgi module. Make sure that the following is **present** and **uncommented** in your `httpd.conf`: ``` LoadModule fcgid_module modules/mod_fcgid.so ``` Then you need to tell Apache when to use FastCGI. For example you can ask Apache to treat all .fcgi files as fastcgi applications: ``` <IfModule fcgid_module> AddHandler fcgid-script .fcgi # you can put whatever extension you want </IfModule> ``` Remember that standard CGI restrictions apply, files must be in an ExecCGI enabled directory to execute.
Apache HTTP Server/mod fcgid
Troubleshooting
## Troubleshooting It does not work? Apache error log (`/var/log/httpd/error_log`) should help you find the problem.
Apache HTTP Server/mod fcgid
See also
## See also * [lighttpd#FastCGI](../../en/Lighttpd.html#FastCGI "Lighttpd") * [Apache HTTP Server#Using php-fpm and mod\_proxy\_fcgi](../../en/Apache_HTTP_Server.html#Using_php-fpm_and_mod_proxy_fcgi "Apache HTTP Server") [Category](../../Special:Categories.html "Special:Categories"): * [Web server](../../en/Category:Web_server.html "Category:Web server") Hidden category: * [Pages or sections flagged with Template:Style](../../en/Category:Pages_or_sections_flagged_with_Template:Style.html "Category:Pages or sections flagged with Template:Style") - Retrieved from "<https://wiki.archlinux.org/index.php?title=Apache_HTTP_Server/mod_fcgid&oldid=746047>" - This page was last edited on 13 September 2022, at 09:28. - Content is available under [GNU Free Documentation License 1.3 or later](https://www.gnu.org/copyleft/fdl.html) unless otherwise noted. * [Privacy policy](https://terms.archlinux.org/docs/privacy-policy/) * [About ArchWiki](../../en/ArchWiki:About.html) * [Disclaimers](../../en/ArchWiki:General_disclaimer.html) * [Code of conduct](https://terms.archlinux.org/docs/code-of-conduct/ "archlinux-service-agreements:code-of-conduct") * [Terms of service](https://terms.archlinux.org/docs/terms-of-service/ "archlinux-service-agreements:terms-of-service") - [![GNU Free Documentation License 1.3 or later](/resources/assets/licenses/gnu-fdl.png)](https://www.gnu.org/copyleft/fdl.html) - ![](/resources/assets/poweredby_mediawiki_88x31.png) * Toggle limited content width
Apache HTTP Server/mod\_gnutls
Intro
# Apache HTTP Server/mod\_gnutls \[ ] 2 languages * [Español](../../es/Apache_HTTP_Server/mod_gnutls.html "Apache HTTP Server (Español)/mod gnutls – español") * [日本語](https://wiki.archlinux.jp/index.php/Mod_gnutls "Mod gnutls – 日本語") From ArchWiki < [Apache HTTP Server](../../en/Apache_HTTP_Server.html "Apache HTTP Server") From [mod\_gnutls wiki](https://mod.gnutls.org/wiki): * * mod\_gnutls is an extension for ​Apache's httpd uses the ​GnuTLS library to provide HTTPS. * It is similar to ​mod\_ssl in purpose, but it supports some features and protocols that mod\_ssl does not, and it does not use ​OpenSSL.
Apache HTTP Server/mod\_gnutls
Installation
## Installation Install [mod\_gnutls](https://aur.archlinux.org/packages/mod_gnutls/)AUR, available in the [Arch User Repository](../../en/Arch_User_Repository.html "Arch User Repository"). ### Configure Apache Add these lines to `/etc/httpd/conf/httpd.conf`: ``` LoadModule gnutls_module modules/mod_gnutls.so Include conf/extra/httpd-gnutls.conf ``` Make sure that the following line is commented in `/etc/httpd/conf/httpd.conf`: ``` Include conf/extra/httpd-ssl.conf ``` Make sure no vhost definitions include mod\_ssl. Create the file `/etc/httpd/conf/extra/httpd-gnutls.conf` with the following content: ``` /etc/httpd/conf/extra/httpd-gnutls.conf ``` ``` Listen 443 AddType application/x-x509-ca-cert .crt AddType application/x-pkcs7-crl .crl GnuTLSCache dbm "/var/run/httpd/gnutls_scache" GnuTLSCacheTimeout 600 <VirtualHost _default_:443> DocumentRoot "/srv/http" ServerName www.example.org ServerAdmin youremail@example.org ErrorLog "/var/log/httpd/error_log" TransferLog "/var/log/httpd/access_log" GnuTLSEnable on GnuTLSPriorities NORMAL GNUTLSExportCertificates on GnuTLSCertificateFile /path/to/certificate/domain.tld.crt GnuTLSKeyFile /path/to/certificate/domain.tld.key </VirtualHost> ``` [Restart](../../en/Help:Reading.html#Control_of_systemd_units "Restart") `httpd.service`. Check that Apache loaded correctly and answers on port 443. Additional documentation of configuration directives is on the [outoforder.cc mod\_gnutls](https://web.archive.org/web/20190917191240/http://www.outoforder.cc/projects/apache/mod_gnutls/docs/) documentation page.
Apache HTTP Server/mod\_gnutls
Testing
## Testing You can test or verify your https configuration via [SSL Labs analyze tool](https://www.ssllabs.com/ssltest/analyze.html). [Category](../../Special:Categories.html "Special:Categories"): * [Web server](../../en/Category:Web_server.html "Category:Web server") - Retrieved from "<https://wiki.archlinux.org/index.php?title=Apache_HTTP_Server/mod_gnutls&oldid=658100>" - This page was last edited on 7 April 2021, at 17:04. - Content is available under [GNU Free Documentation License 1.3 or later](https://www.gnu.org/copyleft/fdl.html) unless otherwise noted. * [Privacy policy](https://terms.archlinux.org/docs/privacy-policy/) * [About ArchWiki](../../en/ArchWiki:About.html) * [Disclaimers](../../en/ArchWiki:General_disclaimer.html) * [Code of conduct](https://terms.archlinux.org/docs/code-of-conduct/ "archlinux-service-agreements:code-of-conduct") * [Terms of service](https://terms.archlinux.org/docs/terms-of-service/ "archlinux-service-agreements:terms-of-service") - [![GNU Free Documentation License 1.3 or later](/resources/assets/licenses/gnu-fdl.png)](https://www.gnu.org/copyleft/fdl.html) - ![](/resources/assets/poweredby_mediawiki_88x31.png) * Toggle limited content width
Apache HTTP Server/mod\_perl
Intro
# Apache HTTP Server/mod\_perl \[ ] 2 languages * [Español](../../es/Apache_HTTP_Server/mod_perl.html "Apache HTTP Server (Español)/mod perl – español") * [日本語](https://wiki.archlinux.jp/index.php/Mod_perl "Mod perl – 日本語") From ArchWiki < [Apache HTTP Server](../../en/Apache_HTTP_Server.html "Apache HTTP Server") From the [project](https://perl.apache.org/): * mod\_perl brings together the full power of the Perl programming language and the [Apache HTTP Server](../../en/Apache_HTTP_Server.html "Apache HTTP Server"). You can use Perl to manage Apache, respond to requests for web pages and much more.
Apache HTTP Server/mod\_perl
Installation
## Installation Install the [mod\_perl](https://aur.archlinux.org/packages/mod_perl/)AUR package.
Apache HTTP Server/mod\_perl
Configuration
## Configuration Load the module via the main Apache configuration file: ``` httpd.conf ``` ``` LoadModule perl_module modules/mod_perl.so ``` ### Allow perl to execute scripts for certain directories There are two possible methods to enable the `mod_perl` module: * [#Using virtual hosts](#Using_virtual_hosts), or * [#For a subdirectory](#For_a_subdirectory). #### Using virtual hosts Add a virtual host with settings. For example: ``` /etc/httpd/conf/extra/httpd-vhosts.conf ``` ``` <VirtualHost perlwebtest:80> Servername perlwebtest DocumentRoot /srv/http/perlwebtest ErrorLog /var/log/httpd/perlwebtest-error.log CustomLog /var/log/httpd/perlwebtest-access.log combined <Directory /srv/http/perlwebtest> AddHandler perl-script .pl PerlResponseHandler ModPerl::Registry Options +ExecCGI PerlOptions +ParseHeaders AllowOverride All Order allow,deny Allow from all </Directory> </VirtualHost> ``` Ensure `/etc/httpd/conf/httpd.conf` includes the created virtual host: ``` Include conf/extra/httpd-vhosts.conf ``` Make sure it does not have `Options Indexes FollowSymLinks`! Add "perlwebtest" as localhost in `/etc/hosts`, using the machine's hostname for `yourhostname`: ``` 127.0.0.1 localhost yourhostname perlwebtest ``` #### For a subdirectory Add the following to the main configuration file: ``` /etc/httpd/conf/httpd.conf ``` ``` Alias /perlwebtest/ /srv/http/perlwebtest/ <Location /perlwebtest/> AddHandler perl-script .pl AddHandler perl-script .cgi PerlResponseHandler ModPerl::Registry PerlOptions +ParseHeaders Options +ExecCGI Order allow,deny Allow from all </Location> ``` ### Turn on perl for directory listings Create `/etc/httpd/conf/extra/perl_module.conf` as well: ``` /etc/httpd/conf/extra/perl_module.conf ``` ``` # Required modules: dir_module, perl_module <IfModule dir_module> <IfModule perl_module> DirectoryIndex index.pl index.html </IfModule> </IfModule> ``` Then include it in `/etc/httpd/conf/httpd.conf`: ``` /etc/httpd/conf/httpd.conf ``` ``` # Perl Include conf/extra/perl_module.conf ``` ### Try it out Create `index.pl` in `/srv/http/perlwebtest`: ``` #!/usr/bin/perl print "Content-type: text/plain\n\n"; print "mod_perl now works\n"; ``` [Restart](../../en/Help:Reading.html#Control_of_systemd_units "Restart") Apache's `httpd.service` and let it [reload](../../en/Help:Reading.html#Control_of_systemd_units "Reload") the configuration. Finally, depending on chosen alternative configuration, visit * <http://perlwebtest> for [#Using virtual hosts](#Using_virtual_hosts), or * <http://localhost/perlwebtest> for [#For a subdirectory](#For_a_subdirectory). [Category](../../Special:Categories.html "Special:Categories"): * [Web server](../../en/Category:Web_server.html "Category:Web server") - Retrieved from "<https://wiki.archlinux.org/index.php?title=Apache_HTTP_Server/mod_perl&oldid=795547>" - This page was last edited on 30 December 2023, at 01:05. - Content is available under [GNU Free Documentation License 1.3 or later](https://www.gnu.org/copyleft/fdl.html) unless otherwise noted. * [Privacy policy](https://terms.archlinux.org/docs/privacy-policy/) * [About ArchWiki](../../en/ArchWiki:About.html) * [Disclaimers](../../en/ArchWiki:General_disclaimer.html) * [Code of conduct](https://terms.archlinux.org/docs/code-of-conduct/ "archlinux-service-agreements:code-of-conduct") * [Terms of service](https://terms.archlinux.org/docs/terms-of-service/ "archlinux-service-agreements:terms-of-service") - [![GNU Free Documentation License 1.3 or later](/resources/assets/licenses/gnu-fdl.png)](https://www.gnu.org/copyleft/fdl.html) - ![](/resources/assets/poweredby_mediawiki_88x31.png) * Toggle limited content width
Apache HTTP Server/mod\_wsgi
Intro
# Apache HTTP Server/mod\_wsgi \[ ] 2 languages * [Español](../../es/Apache_HTTP_Server/mod_wsgi.html "Apache HTTP Server (Español)/mod wsgi – español") * [日本語](https://wiki.archlinux.jp/index.php/mod_wsgi "mod wsgi – 日本語") From ArchWiki < [Apache HTTP Server](../../en/Apache_HTTP_Server.html "Apache HTTP Server") According to the [project's site](https://github.com/GrahamDumpleton/mod_wsgi): * The aim of mod\_wsgi is to implement a simple to use Apache module which can host any Python application which supports the Python WSGI interface. The module would be suitable for use in hosting high performance production web sites, as well as your average self managed personal sites running on web hosting services. mod\_wsgi is an [Apache HTTP Server](../../en/Apache_HTTP_Server.html "Apache HTTP Server") module that embeds a [Python](https://www.python.org) application within the server and allow them to communicate through the Python WSGI interface as defined in the [Python PEP 333](https://www.python.org/dev/peps/pep-0333/). WSGI is one of the Python ways to produce high quality and high performance web applications. WSGI provide a standard way to interface different web-apps without hassle. Several well-know python applications or frameworks provide wsgi for easy deployment and embedding. It means that you can embed your Django-powered blog and your project's Trac into a single Pylons application that wraps around them to deals with, say, authentication without modifying the formers. Example: * [Pylons](https://www.pylonsproject.org/) * [Django](https://www.djangoproject.com/) * [Turbo-gear](https://turbogears.org/) * [Trac](https://trac.edgewall.org/) * [Moin-moin](https://moinmo.in/) * [Zope](https://www.zope.org/)
Apache HTTP Server/mod\_wsgi
Installation
## Installation [Install](../../en/Help:Reading.html#Installation_of_packages "Install") [mod\_wsgi](https://aur.archlinux.org/packages/mod_wsgi/)AUR which provides the module working with all common versions of Python (3.x).
Apache HTTP Server/mod\_wsgi
Apache configuration
## Apache configuration As indicated during installation, add the following line to the configuration file of Apache: ``` /etc/httpd/conf/httpd.conf ``` ``` LoadModule wsgi_module modules/mod_wsgi.so ``` [Restart](../../en/Help:Reading.html#Control_of_systemd_units "Restart") `httpd.service`. Check that Apache is running properly. If the previous command returned nothing, it means that the launch of Apache went well. Otherwise, you can see errors with the `httpd.service` [unit status](../../en/Help:Reading.html#Control_of_systemd_units "Unit status").
Apache HTTP Server/mod\_wsgi
Module test
## Module test Add this line in Apache configuration file: ``` /etc/httpd/conf/httpd.conf ``` ``` WSGIScriptAlias /wsgi_app /srv/http/wsgi_app.py ``` Create a test file: ``` /srv/http/wsgi_app.py ``` ``` #-*- coding: utf-8 -*- def wsgi_app(environ, start_response): import sys output = sys.version.encode('utf8') status = '200 OK' headers = [('Content-type', 'text/plain'), ('Content-Length', str(len(output)))] start_response(status, headers) yield output # mod_wsgi need the *application* variable to serve our small app application = wsgi_app ``` [Restart](../../en/Help:Reading.html#Control_of_systemd_units "Restart") `httpd.service` You can check the proper functioning by going to the following address : <http://localhost/wsgi_app>
Apache HTTP Server/mod\_wsgi
See Also
## See Also * [LAMP](../../en/Category:Web_applications.html "LAMP") * [Quick Configuration Guide](https://modwsgi.readthedocs.org/en/develop/user-guides/quick-configuration-guide.html) [Category](../../Special:Categories.html "Special:Categories"): * [Web server](../../en/Category:Web_server.html "Category:Web server") - Retrieved from "<https://wiki.archlinux.org/index.php?title=Apache_HTTP_Server/mod_wsgi&oldid=726435>" - This page was last edited on 14 April 2022, at 17:09. - Content is available under [GNU Free Documentation License 1.3 or later](https://www.gnu.org/copyleft/fdl.html) unless otherwise noted. * [Privacy policy](https://terms.archlinux.org/docs/privacy-policy/) * [About ArchWiki](../../en/ArchWiki:About.html) * [Disclaimers](../../en/ArchWiki:General_disclaimer.html) * [Code of conduct](https://terms.archlinux.org/docs/code-of-conduct/ "archlinux-service-agreements:code-of-conduct") * [Terms of service](https://terms.archlinux.org/docs/terms-of-service/ "archlinux-service-agreements:terms-of-service") - [![GNU Free Documentation License 1.3 or later](/resources/assets/licenses/gnu-fdl.png)](https://www.gnu.org/copyleft/fdl.html) - ![](/resources/assets/poweredby_mediawiki_88x31.png) * Toggle limited content width
Arch package guidelines/Security
Intro
# Arch package guidelines/Security \[ ] 2 languages * [日本語](https://wiki.archlinux.jp/index.php/Arch_%E3%83%91%E3%83%83%E3%82%B1%E3%83%BC%E3%82%B8%E3%82%AC%E3%82%A4%E3%83%89%E3%83%A9%E3%82%A4%E3%83%B3/%E3%82%BB%E3%82%AD%E3%83%A5%E3%83%AA%E3%83%86%E3%82%A3 "Arch パッケージガイドライン/セキュリティ – 日本語") * [Português](../../pt/Arch_package_guidelines/Security.html "Arch package guidelines (Português)/Security – português") From ArchWiki < [Arch package guidelines](../../en/Arch_package_guidelines.html "Arch package guidelines") This page describes security packaging guidelines for Arch Linux packages. For C/C++ projects the compiler and linker can apply security hardening options. Arch Linux applies PIE, Fortify source, stack protector, nx and relro by default.
Arch package guidelines/Security
Usage
## Usage Hardening protections can be reviewed by running [checksec](https://archlinux.org/packages/?name=checksec). ``` $ checksec --file=/usr/bin/cat ```
Arch package guidelines/Security
RELRO
## RELRO RELRO is a generic mitigation technique to harden the data sections of an ELF binary/process. When a program is loaded several ELF memory sections need to be written to by the linker but can be turned read-only before turning control over to the program. This prevents attackers of overriding some ELF sections. There are two different RELRO modes: * Partial RELRO (`-Wl,-z,relro`) some sections are marked as read-only after program load except the GOT (`.got.plt`) is still writeable. * Full RELRO (`-Wl,-z,now`) during program load all dynamic symbols are resolved, allowing for the complete GOT to be marked read-only. If an application reports partial relro, investigate if the build toolchain passes our LDFLAGS or allows overriding LDFLAGS. For Go packages investigate if the build method uses `build.go` as pure golang Makefile replacement which does not allow passing of LDFLAGS. ### Haskell For Haskell it is not clear how to achieve Full RELRO at the moment. ### Go See [Go package guidelines#Flags and build options](../../en/Go_package_guidelines.html#Flags_and_build_options "Go package guidelines").
Arch package guidelines/Security
Stack canary
## Stack canary A [stack canary](https://en.wikipedia.org/wiki/Stack_canary "wikipedia:Stack canary") is added by the compiler between the buffer and control data on the stack. If this well known value is corrupted, a buffer overflow occurred and the running program segfaults to prevent possible arbitrary code execution. The [gcc](https://archlinux.org/packages/?name=gcc) package has it enabled stack protection by default with the [--enable-default-ssp](https://github.com/archlinux/svntogit-packages/blob/packages/gcc/trunk/PKGBUILD#L100) compile option.
Arch package guidelines/Security
NX
## NX ### C/C++ Executable-space protection marks memory regions as non-executable, such that an attempt to execute machine code in these regions will cause an exception. It makes use of hardware features such as the NX bit (no-execute bit), or in some cases software emulation of those features.
Arch package guidelines/Security
PIE
## PIE ### C/C++ The [gcc](https://archlinux.org/packages/?name=gcc) package has it enabled by default for C/C++ with [--enable-default-pie](https://github.com/archlinux/svntogit-packages/blob/packages/gcc/trunk/PKGBUILD#L99). ### Golang Pass the following flags to `go build`: ``` export GOFLAGS='-buildmode=pie' export CGO_CPPFLAGS="-D_FORTIFY_SOURCE=3" export CGO_LDFLAGS="-Wl,-z,relro,-z,now" ``` ### Haskell Pass the following flag to `runhaskell Setup.hs configure`: ``` --ghc-option='-pie' ```
Arch package guidelines/Security
RPATH/RUNPATH
## RPATH/RUNPATH RUNPATH/RPATH provides further search paths for the object it is listed in (it can be used both for executable and for shared objects). ``` $ objdump -x /usr/bin/perl | grep -E 'RPATH|RUNPATH' ``` If the RPATH value contains a path within an attackers control it can possibly execute code by installing a malicious library in that directory for example [CVE-2006-1566](https://nvd.nist.gov/vuln/detail/CVE-2006-1566) [CVE-2005-4280](https://www.cvedetails.com/cve/CVE-2005-4280/). See [Debian:RpathIssue](https://wiki.debian.org/RpathIssue "debian:RpathIssue"). The RPATH entry is set by the linker by passing for example the following string to LDFLAGS `-Wl,-rpath -Wl,/usr/local/lib`. To make an RUNPATH entry append `--enable-new-dtags` to the linker flags.
Arch package guidelines/Security
FORTIFY
## FORTIFY Fortify source is a macro that adds buffer overflow protection in various functions that perform operations on memory and strings. It checks whether an attacker tries to copy more bytes to overflow a buffer and then stops the execution of the program. This protection is enabled with the default `CPPFLAGS`: ``` makepkg.conf ``` ``` CPPFLAGS="-D_FORTIFY_SOURCE=3" ``` See [makepkg#Configuration](../../en/Makepkg.html#Configuration "Makepkg").
Arch package guidelines/Security
systemd services
## systemd services ![](../../File:Tango-go-next.svg)**This article or section is a candidate for moving to [systemd/Sandboxing](/index.php?title=Systemd/Sandboxing\&action=edit\&redlink=1 "Systemd/Sandboxing (page does not exist)").** **Notes:** Covers the same topic as [systemd#Sandboxing application environments](../../en/Systemd.html#Sandboxing_application_environments "Systemd"). Both could be merged and moved to a dedicated page. See [User:NetSysFire/systemd sandboxing](../../User:NetSysFire/systemd_sandboxing.html "User:NetSysFire/systemd sandboxing") for a proposed draft. (Discuss in [Talk:Security#systemd unit hardening and system.conf tweaks](../../en/Talk:Security.html#systemd_unit_hardening_and_system.conf_tweaks "Talk:Security")) If a [systemd](../../en/Systemd.html "Systemd") service file is shipped with the package due to upstream not providing any, look into applying the following systemd service hardening features. Systemd provides a way to analyse security features which are enabled for a service. ``` $ systemd-analyze security reflector.service ``` ### File access A service can be hardened by restricting file system access. Set up a new file system namespace for the executed process and mounts private `/tmp` and `var/tmp` directories inside it that is not shared by processes outside the namespace. Useful for programs which write data to `/tmp`. ``` PrivateTmp=true ``` ProtectSystem has three different varieties of mounting directories as read-only for the executed process. The "full" option mounts `/usr`, `/boot` and `/etc` read only. ProtectHome makes `/home`, `/root` and `/run/user` inaccessible to the executed process. ``` ProtectSystem=strict ProtectHome=true ``` Sets up a new `/dev` namespace for the executed process and only adds API pseudo devices such as `/dev/null`, `/dev/zero` or `/dev/random`, but not for physical devices or system memory, system ports and others. This is useful to secure the execute process from writing directly to physical devices, systemd also adds a system call filter for calls within the `@raw-io` set. ``` PrivateDevices=true ``` These options make the executed process unable to change kernel variables accessible through `/proc/sys`, `/sys`, etc. ProtectControlGroups makes the `/sys/fs/cgroup` hierarchy read-only. ``` ProtectKernelTunables=true ProtectControlGroups=true ``` Making file paths inaccessible can be done as following: ``` InaccessiblePaths=/etc ``` More detailed information can be found in [systemd.exec(5)](https://man.archlinux.org/man/systemd.exec.5). ### User Ensure that the executed process and its children can never gain new privileges through [execve(2)](https://man.archlinux.org/man/execve.2). ``` NoNewPrivileges=true ``` ### Memory Prohibit attempts to create memory mappings that are both writable and executable, to change mappings to be executable or to create executable shared memory. This sandboxes a process against allowing an attacker to write in to memory which is also executed. Note that enabling this is not compatible with all applications which rely on a [JIT](https://en.wikipedia.org/wiki/JIT_\(computing\) "wikipedia:JIT (computing)"). ``` MemoryDenyWriteExecute=true ``` ### System calls Locks down the [personality(2)](https://man.archlinux.org/man/personality.2) system call so that the kernel execution domain can not be changed. ``` LockPersonality=true ``` System calls can be restricted in a service as well, systemd can display syscalls to filter on: ``` $ systemd-analyze syscall-filter ``` Predefined groups are available, e.g. to use the recommended starting point for whitelisting system calls for system services use: ``` SystemCallFilter=@system-service ``` System calls can be restricted by their architecture such as to prevent 32-bit binaries from executing on 64-bit machines (no non-native binaries): ``` SystemCallArchitectures=native ``` ### Network If the running process does not require any network access it can be fully disabled by setting up a new network namespace for the process and only configuration a loopback interface. ``` PrivateNetwork=true ``` If network is required, the type of address families used can be restricted for the [socket(2)](https://man.archlinux.org/man/socket.2) system call by for example only allowing UNIX sockets. ``` RestrictAddressFamilies=AF_UNIX ``` For when only network to localhost or specific IP ranges is required a process can be restricted by only allowing network access to localhost. ``` IPAddressAllow=localhost IPAddressDeny=any ``` More information about network filtering can be found in [systemd.resource-control(5)](https://man.archlinux.org/man/systemd.resource-control.5). ### Various Sets up a new UTS namespace for the execute process and disallows changing the hostname or domainname. ``` ProtectHostname=true ``` [Categories](../../Special:Categories.html "Special:Categories"): * [Arch package guidelines](../../en/Category:Arch_package_guidelines.html "Category:Arch package guidelines") * [Security](../../en/Category:Security.html "Category:Security") Hidden category: * [Pages or sections flagged with Template:Move](../../en/Category:Pages_or_sections_flagged_with_Template:Move.html "Category:Pages or sections flagged with Template:Move") - Retrieved from "<https://wiki.archlinux.org/index.php?title=Arch_package_guidelines/Security&oldid=783716>" - This page was last edited on 26 July 2023, at 05:40. - Content is available under [GNU Free Documentation License 1.3 or later](https://www.gnu.org/copyleft/fdl.html) unless otherwise noted. * [Privacy policy](https://terms.archlinux.org/docs/privacy-policy/) * [About ArchWiki](../../en/ArchWiki:About.html) * [Disclaimers](../../en/ArchWiki:General_disclaimer.html) * [Code of conduct](https://terms.archlinux.org/docs/code-of-conduct/ "archlinux-service-agreements:code-of-conduct") * [Terms of service](https://terms.archlinux.org/docs/terms-of-service/ "archlinux-service-agreements:terms-of-service") - [![GNU Free Documentation License 1.3 or later](/resources/assets/licenses/gnu-fdl.png)](https://www.gnu.org/copyleft/fdl.html) - ![](/resources/assets/poweredby_mediawiki_88x31.png) * Toggle limited content width
Bash/Functions
Intro
# Bash/Functions \[ ] 4 languages * [Español](../../es/Bash/Functions.html "Bash (Español)/Functions – español") * [日本語](https://wiki.archlinux.jp/index.php/Bash/%E9%96%A2%E6%95%B0 "Bash/関数 – 日本語") * [Русский](../../ru/Bash/Functions.html "Bash (Русский)/Functions – русский") * [中文(简体)](https://wiki.archlinuxcn.org/wiki/Bash/Functions "Bash/Functions – 中文(简体)") From ArchWiki < [Bash](../../en/Bash.html "Bash") [Bash](../../en/Bash.html "Bash") also supports functions. Add the functions to `~/.bashrc`, or a separate file which is [sourced](../../en/Help:Reading.html#Source "Source") from `~/.bashrc`. More Bash function examples can be found in [BBS#30155](https://bbs.archlinux.org/viewtopic.php?id=30155).
Bash/Functions
Display error codes
## Display error codes To set `trap` to intercept a non-zero return code of the last program run: ``` EC() { echo -e '\e[1;33m'code $?'\e[m\n' } trap EC ERR ```
Bash/Functions
Compile and execute a C source on the fly
## Compile and execute a C source on the fly The following function will compile (within the `/tmp/` directory) and execute the [C](https://en.wikipedia.org/wiki/C_\(programming_language\) "wikipedia:C (programming language)") source argument on the fly (and the execution will be without arguments). And finally, after program terminates, will remove the compiled file. ``` # Compile and execute a C source on the fly csource() { [[ $1 ]] || { echo "Missing operand" >&2; return 1; } [[ -r $1 ]] || { printf "File %s does not exist or is not readable\n" "$1" >&2; return 1; } local output_path=${TMPDIR:-/tmp}/${1##*/}; gcc "$1" -o "$output_path" && "$output_path"; rm "$output_path"; return 0; } ```
Bash/Functions
Extract
## Extract The following function will extract a wide range of compressed file types. Use it with the syntax `extract <file1> <file2> ...` ``` extract() { local c e i (($#)) || return for i; do c='' e=1 if [[ ! -r $i ]]; then echo "$0: file is unreadable: \`$i'" >&2 continue fi case $i in *.t@(gz|lz|xz|b@(2|z?(2))|a@(z|r?(.@(Z|bz?(2)|gz|lzma|xz|zst))))) c=(bsdtar xvf);; *.7z) c=(7z x);; *.Z) c=(uncompress);; *.bz2) c=(bunzip2);; *.exe) c=(cabextract);; *.gz) c=(gunzip);; *.rar) c=(unrar x);; *.xz) c=(unxz);; *.zip) c=(unzip);; *.zst) c=(unzstd);; *) echo "$0: unrecognized file extension: \`$i'" >&2 continue;; esac command "${c[@]}" "$i" ((e = e || $?)) done return "$e" } ``` **Note:** Make sure `extglob` is enabled: `shopt -s extglob`, by adding it to the `~/.bashrc` (see [gregswiki:glob#Options which change globbing behavior](https://mywiki.wooledge.org/glob#Options_which_change_globbing_behavior "gregswiki:glob")). Another way to do this is to install a specialized package, see [Archiving and compression tools#Convenience tools](../../en/Archiving_and_compression.html#Convenience_tools "Archiving and compression tools").
Bash/Functions
cd and ls in one
## cd and ls in one Very often changing to a directory is followed by the `ls` command to list its contents. Therefore it is helpful to have a second function doing both at once. In this example we will name it `cl` (change list) and show an error message if the specified directory does not exist. ``` cl() { local dir="$1" local dir="${dir:=$HOME}" if [[ -d "$dir" ]]; then cd "$dir" >/dev/null; ls else echo "bash: cl: $dir: Directory not found" fi } ``` Of course the *ls* command can be altered to fit your needs, for example `ls -hall --color=auto`.
Bash/Functions
Simple note taker
## Simple note taker ``` note () { # if file doesn't exist, create it if [[ ! -f $HOME/.notes ]]; then touch "$HOME/.notes" fi if ! (($#)); then # no arguments, print file cat "$HOME/.notes" elif [[ "$1" == "-c" ]]; then # clear file printf "%s" > "$HOME/.notes" else # add all arguments to file printf "%s\n" "$*" >> "$HOME/.notes" fi } ```
Bash/Functions
Simple task utility
## Simple task utility Inspired by [#Simple note taker](#Simple_note_taker) ``` todo() { if [[ ! -f $HOME/.todo ]]; then touch "$HOME/.todo" fi if ! (($#)); then cat "$HOME/.todo" elif [[ "$1" == "-l" ]]; then nl -b a "$HOME/.todo" elif [[ "$1" == "-c" ]]; then > $HOME/.todo elif [[ "$1" == "-r" ]]; then nl -b a "$HOME/.todo" eval printf %.0s- '{1..'"${COLUMNS:-$(tput cols)}"\}; echo read -p "Type a number to remove: " number sed -i ${number}d $HOME/.todo "$HOME/.todo" else printf "%s\n" "$*" >> "$HOME/.todo" fi } ```
Bash/Functions
Calculator
## Calculator ``` calc() { echo "scale=3;$@" | bc -l } ```
Bash/Functions
IP info
## IP info Detailed information on an IP address or hostname in bash via <https://ipinfo.io>: ``` ipif() { if grep -P "(([1-9]\d{0,2})\.){3}(?2)" <<< "$1"; then curl ipinfo.io/"$1" else ipawk=($(host "$1" | awk '/address/ { print $NF }')) curl ipinfo.io/${ipawk[1]} fi echo } ``` **Note:** Bash is limited to extended regular expressions; this example uses perl regular expressions with *grep*. [\[1\]](https://unix.stackexchange.com/questions/84477/forcing-bash-to-use-perl-regex-engine) [Category](../../Special:Categories.html "Special:Categories"): * [Command-line shells](../../en/Category:Command-line_shells.html "Category:Command-line shells") - Retrieved from "<https://wiki.archlinux.org/index.php?title=Bash/Functions&oldid=806150>" - This page was last edited on 16 April 2024, at 15:31. - Content is available under [GNU Free Documentation License 1.3 or later](https://www.gnu.org/copyleft/fdl.html) unless otherwise noted. * [Privacy policy](https://terms.archlinux.org/docs/privacy-policy/) * [About ArchWiki](../../en/ArchWiki:About.html) * [Disclaimers](../../en/ArchWiki:General_disclaimer.html) * [Code of conduct](https://terms.archlinux.org/docs/code-of-conduct/ "archlinux-service-agreements:code-of-conduct") * [Terms of service](https://terms.archlinux.org/docs/terms-of-service/ "archlinux-service-agreements:terms-of-service") - [![GNU Free Documentation License 1.3 or later](/resources/assets/licenses/gnu-fdl.png)](https://www.gnu.org/copyleft/fdl.html) - ![](/resources/assets/poweredby_mediawiki_88x31.png) * Toggle limited content width
Bash/Prompt customization
Intro
# Bash/Prompt customization \[ ] 4 languages * [Deutsch](https://wiki.archlinux.de/title/Bash-Prompt_anpassen "Bash-Prompt anpassen – Deutsch") * [Español](../../es/Bash/Prompt_customization.html "Bash (Español)/Prompt customization – español") * [日本語](https://wiki.archlinux.jp/index.php/Bash/%E3%83%97%E3%83%AD%E3%83%B3%E3%83%97%E3%83%88%E3%81%AE%E3%82%AB%E3%82%B9%E3%82%BF%E3%83%9E%E3%82%A4%E3%82%BA "Bash/プロンプトのカスタマイズ – 日本語") * [Русский](../../ru/Bash/Prompt_customization.html "Bash (Русский)/Prompt customization – русский") From ArchWiki < [Bash](../../en/Bash.html "Bash") Related articles * [Bash](../../en/Bash.html "Bash") * [Environment variables](../../en/Environment_variables.html "Environment variables") * [Git#Git prompt](../../en/Git.html#Git_prompt "Git") Bash has several prompts which can be customized to increase productivity, aesthetic appeal, and nerd cred.
Bash/Prompt customization
Prompts
## Prompts Bash has five *prompt strings* that can be customized: * `PS0` is displayed after each command, before any output. * `PS1` is the primary prompt which is displayed before each command, thus it is the one most people customize. * `PS2` is the secondary prompt displayed when a command needs more input (e.g. a multi-line command). * `PS3` is not very commonly used. It is the prompt displayed for Bash's `select` built-in which displays interactive menus. Unlike the other prompts, it does not expand [Bash escape sequences](#Bash_escape_sequences). Usually you would customize it in the script where the `select` is used rather than in your `.bashrc`. * `PS4` is also not commonly used. It is displayed when debugging bash scripts to indicate levels of indirection. The first character is repeated to indicate deeper levels. All of the prompts are customized by setting the corresponding variable to the desired string (usually in `~/.bashrc`), for example ``` PS2='> ' ```
Bash/Prompt customization
Techniques
## Techniques While one can simply set their prompt to a plain string, there are a variety of techniques for making the prompt more dynamic and useful. ### Bash escape sequences When printing the prompt string, Bash looks for certain backslash-escaped characters and will expand them into special strings. For example, `\u` is expanded into the current username and `\A` is expanded to the current time. So a PS1 of `'\A \u $ '` would be printed like `17:35 username $ `. See the man page [bash(1) § PROMPTING](https://man.archlinux.org/man/bash.1#PROMPTING) or the [Bash reference manual](https://www.gnu.org/software/bash/manual/html_node/Controlling-the-Prompt.html) for a complete list of escape sequences. ### Terminfo escape sequences Aside from the escape characters recognized by Bash, most terminals recognize special escape sequences that affect the terminal itself rather than printing characters. For example they might change the color of subsequent printed characters, move the cursor to an arbitrary location, or clear the screen. These escape sequences can be somewhat illegible and can vary from terminal to terminal, so they are documented in the terminfo database. To see what capabilities your terminal supports, run ``` $ infocmp ``` The capability names (the part before the =) can be looked up in [terminfo(5)](https://man.archlinux.org/man/terminfo.5) for a description of what they do. For example, `setaf` sets the foreground color of whatever text is printed after it. To get the escape code for a capability, you can use the `tput` command. For example ``` $ tput setaf 2 ``` Prints the escape sequence to set the foreground color to green. **Note:** If tput commands are failing for you, ensure that you have set the correct `TERM` value for your shell. For example, if you have set `xterm` instead of `xterm-256color`, `tput setaf` will only work with color numbers 0-7. To practically incorporate these capabilities into your prompt, you can use Bash's command substitution and string interpolation. For example ``` GREEN="\[$(tput setaf 2)\]" RESET="\[$(tput sgr0)\]" PS1="${GREEN}my prompt${RESET}> " ``` my prompt> **Note:** Wrapping the tput output in `\[ \]` is recommended by the Bash man page. This helps Bash ignore non-printable characters so that it correctly calculates the size of the prompt. The wrap will not work with command substitution, in which case [the raw `\1 \2`](https://superuser.com/a/301355) must be used. ### ANSI escape sequences Unfortunately, valid ANSI escape sequences may be missing from your terminal's terminfo database. This is especially common with escape sequences for newer features such as 256 color support. In that case you cannot use tput, you must input the escape sequence manually. See [Wikipedia:ANSI escape code](https://en.wikipedia.org/wiki/ANSI_escape_code "wikipedia:ANSI escape code") for examples of escape sequences. Every escape sequence starts with a literal escape character, which you can input using the Bash escape sequence `\e`. So for example,`\e[48;5;209m` sets the background to a peachy color (if you have 256 color support) and `\e[2;2H` moves the cursor near the top-left corner of the screen. In cases where Bash escape sequences are not supported (such as PS3) you can get a literal escape character using Bash's printf builtin: ``` ESC=$(printf "\e") PEACH="$ESC[48;5;209m" ``` ### Embedding commands If you want to add the output of some command to your prompt, you might be tempted to use command substitution. For example, to add the amount of free memory to your prompt you might try: ``` PS1="$(awk '/MemFree/{print $2}' /proc/meminfo) prompt > " ``` ``` 53718 prompt > 53718 prompt > 53718 prompt > ``` But this does not work; the amount of memory shown is the same every time! This is because the command is run once, when PS1 is first set, and never again. The trick is to simply prevent the substitution either by escaping the `$` or by defining it in single quotes — either way it will be substituted when the prompt is actually displayed: ``` PS1="\$(awk '/MemFree/{print \$2}' /proc/meminfo) prompt > " # or PS1='$(awk "/MemFree/{print \$2}" /proc/meminfo) prompt > ' ``` To prevent long commands from making your PS1 huge, you can define functions: ``` free_mem() { awk '/MemFree/{print $2}' /proc/meminfo } PS1='$(free_mem) prompt > ' ``` **Note:** You can use terminfo/ANSI escape sequences inside substituted functions but **not** Bash escapes. In particular `\[ \]` will not work for surrounding non-printable characters. Instead you can use the octal escapes `\001` and `\002` (e.g. using `printf` or `echo -e`). ### PROMPT\_COMMAND If the `PROMPT_COMMAND` variable or array is set, it will be evaluated right before PS1 is displayed. This can be used to achieve quite powerful effects. For example it can reassign PS1 based on some condition, or perform some operation on your Bash history every time you run a command. **Note:** `PROMPT_COMMAND` generally should not be used to print characters directly to the prompt. Characters printed outside of PS1 are not counted by Bash, which will cause it to incorrectly place the cursor and clear characters. Either use `PROMPT_COMMAND` to set PS1 or look at [embedding commands](#Embedding_commands). **Tip:** If the `PROMPT_COMMAND` becomes too complicated, [bash-preexec](https://github.com/rcaloras/bash-preexec) (an implementation of [Zsh](../../en/Zsh.html "Zsh")'s `preexec` and `precmd` hook functions for Bash) may make it more maintainable. ### Escapes between command input and output You can affect your input text in Bash by not resetting the text properties at the end of your PS1. For example, inserting `tput blink` at the end of your PS1 will make your typed commands blink. However this effect will also continue through the command's output since the text properties are not reset when you hit Enter. In order to insert escape sequences after you type a command but before the output is displayed, you can set PS0. Alternatively, you can trap Bash's DEBUG signal, which is sent right before each command is executed: ``` $ trap 'tput sgr0' DEBUG ``` ### Customizing root prompts To ensure that you know when you are running as root, you can customize your root prompt to make it clearly stand out (perhaps blinking red?). This is done by customizing the Bash prompt as usual but in root's home directory, `/root`. Start off by copying the skeleton files `/etc/skel/.bash_profile` and `/etc/skel/.bashrc` to `/root`, then edit `/root/.bashrc` as desired.
Bash/Prompt customization
Examples
## Examples ### Colors ![](../../File:Tango-edit-clear.svg)**This article or section needs language, wiki syntax or style improvements. See [Help:Style](../../en/Help:Style.html "Help:Style") for reference.** **Reason:** Too much duplication with [Color output in console](../../en/Color_output_in_console.html "Color output in console") WRT listing colors. Should be trimmed to zsh length. (Discuss in [Talk:Bash/Prompt customization](../../en/Talk:Bash/Prompt_customization.html)) **Tip:** `infocmp` shows the number of colors `tput` works with, for example `colors#8`. To see the full range of colors your terminal supports, you can use a simple loop with tput (change `setab` to `setaf` for text foregrounds): ``` for C in {0..255}; do tput setab $C echo -n "$C " done tput sgr0 echo ``` If that does not work (and you cannot fix it by setting the [correct TERM value](#Terminfo_escape_sequences)), you can test the different manual escape sequences: ``` # standard colors for C in {40..47}; do echo -en "\e[${C}m$C " done # high intensity colors for C in {100..107}; do echo -en "\e[${C}m$C " done # 256 colors for C in {16..255}; do echo -en "\e[48;5;${C}m$C " done echo -e "\e(B\e[m" ``` To change the manual escapes from background to foreground, the standard color range is `30..37`, the high intensity range is `90..97`, and the 48 should be changed to 38 for 256 colors. ### Common capabilities The following [terminfo capabilities](#Terminfo_escape_sequences) are useful for prompt customization and are supported by many terminals. **#1** and **#2** are placeholders for numeric arguments. | Capability | Escape sequence | Description | | ------------------- | ------------------ | ------------------------------------------------ | | Text attributes | | | | blink | \e\[5m | blinking text on | | bold | \e\[1m | bold text on | | dim | \e\[2m | dim text on | | rev | \e\[7m | reverse video on (switch text/background colors) | | sitm | \e\[3m | italic text on | | ritm | \e\[23m | italic text off | | smso | \e\[7m | highlighted text on | | rmso | \e\[27m | highlighted text off | | smul | \e\[4m | underlined text on | | rmul | \e\[24m | underlined text off | | setab **#1** | \e\[4**#1**m | set background color **#1** (0-7) | | setaf **#1** | \e\[3**#1**m | set text color **#1** (0-7) | | sgr0 | \e(B\e\[m | reset text attributes | | Cursor movement | | | | sc | \e7 | save cursor position | | rc | \e8 | restore saved cursor position | | clear | \e\[H\e\[2J | clear screen and move cursor to top left | | cuu **#1** | \e\[**#1**A | move cursor up **#1** rows | | cud **#1** | \e\[**#1**B | move cursor down **#1** rows | | cuf **#1** | \e\[**#1**C | move cursor right **#1** columns | | cub **#1** | \e\[**#1**D | move cursor left **#1** columns | | home | \e\[H | move cursor to top left | | hpa **#1** | \e\[**#1**G | move cursor to column **#1** | | vpa **#1** | \e\[**#1**d | move cursor to row **#1**, first column | | cup **#1** **#2** | \e\[**#1**;**#2**H | move cursor to row **#1**, column **#2** | | Removing characters | | | | dch **#1** | \e**#1**P | remove **#1** characters (like backspacing) | | dl **#1** | \e**#1**M | remove **#1** lines | | ech **#1** | \e**#1**X | clear **#1** characters (without moving cursor) | | ed | \eE\[J | clear to bottom of screen | | el | \e\[K | clear to end of line | | el1 | \e\[1K | clear to beginning of line | ### Visualizing exit codes Using the same trick from [embedding commands](#Embedding_commands) you can delay the interpolation of special Bash variables like `$?`. So the following prompt shows the exit code of the previous command: ``` PS1="\$? > " # or PS1='$? > ' ``` 0 > true\ 0 > false\ 1 > This can be made more interesting using conditionals and functions: ``` exitstatus() { if [[ $? == 0 ]]; then echo ':)' else echo 'D:' fi } PS1='$(exitstatus) > ' ``` :) > true\ :) > false\ D: > ### Positioning the cursor It is possible to move the cursor around the screen inside of PS1 to make different parts of the prompt appear in different locations. However, to ensure that Bash positions the cursor and output in the right position, you must move the cursor back to the original position after you are done printing elsewhere. This can be done using the tput capabilities `sc` and `rc` to save and restore the cursor position. The general pattern for a prompt that moves the cursor is ``` PS1="\[$(tput sc; cursor-moving code) positioned prompt stuff $(tput rc)\] normal prompt stuff" ``` where the entire block of repositioned prompt is wrapped in `\[ \]` to prevent Bash from counting it as part of the regular prompt. #### Right-justified text The simplest way to print text on the right side of the screen is to use printf ``` rightprompt() { printf "%*s" $COLUMNS "right prompt" } PS1='\[$(tput sc; rightprompt; tput rc)\]left prompt > ' ``` left prompt > right prompt This creates a right-justified variable-sized field `%*s` and sets its size to the current number of columns of the terminal `$COLUMNS`. #### Arbitrary positioning The `cup` capability moves the cursor to a specific position on the screen, for example `tput cup 20 5` moves the cursor to line 20, column 5 (where 0 0 is the top left corner). `cuu`, `cud`, `cuf`, and `cub` (up, down, forward, back) move the cursor relative to its current position. For example `tput cuf 10` moves the cursor 10 characters to the right. You can use the `LINES` and `COLUMNS` variables in the arguments to move the cursor relative to the bottom and right edges. For example, to move 10 lines and 5 columns away from the bottom right corner: ``` $ tput cup $((LINES - 11)) $((COLUMNS - 6)) ``` ### Customizing the terminal window title The terminal window title can be customized in much the same way as the prompt: by printing escape sequences in the shell. Thus it is common for users to include window title customizations in their prompt. Although this is technically a feature of xterm, many modern terminals support it. The escape sequence to use is `ESC]2;new titleBEL` where `ESC` and `BEL` are the escape and bell characters. Using [#Bash escape sequences](#Bash_escape_sequences), changing the title in your prompt looks like ``` PS1='\[\e]2;new title\a\]prompt > ' ``` Of course your window title string can include output from [embedding commands](#Embedding_commands) or variables such as `$PWD`, so that the title changes with each command.
Bash/Prompt customization
See also
## See also * Community examples and screenshots in the Forum thread: [What's your PS1?](https://bbs.archlinux.org/viewtopic.php?id=50885) (only accessible if logged in) * [Gentoo's /etc/bash/bashrc](https://gitweb.gentoo.org/repo/gentoo.git/tree/app-shells/bash/files/bashrc). See also [gentoo-bashrc](https://aur.archlinux.org/packages/gentoo-bashrc/)AUR. * [tput(1)](https://man.archlinux.org/man/tput.1) * [Colours and Cursor Movement With tput](https://tldp.org/HOWTO/Bash-Prompt-HOWTO/x405.html) * [Bash Prompt HOWTO](https://www.tldp.org/HOWTO/Bash-Prompt-HOWTO/x329.html) * [Giles Orr's collection of sample prompts](https://gilesorr.com/bashprompt/prompts/index.html) * [Bash tips: Colors and formatting](https://misc.flogisoft.com/bash/tip_colors_and_formatting) * [Liquid Prompt — a useful adaptive prompt for Bash & zsh](https://github.com/nojhan/liquidprompt) * [Bash POWER PROMPT](https://www.askapache.com/linux/bash-power-prompt/) * [Wikipedia:ANSI escape code](https://en.wikipedia.org/wiki/ANSI_escape_code "wikipedia:ANSI escape code") * [GNU Bash manual: Controlling the Prompt](https://www.gnu.org/software/bash/manual/html_node/Controlling-the-Prompt.html) [Categories](../../Special:Categories.html "Special:Categories"): * [Eye candy](../../en/Category:Eye_candy.html "Category:Eye candy") * [Command-line shells](../../en/Category:Command-line_shells.html "Category:Command-line shells") Hidden category: * [Pages or sections flagged with Template:Style](../../en/Category:Pages_or_sections_flagged_with_Template:Style.html "Category:Pages or sections flagged with Template:Style") - Retrieved from "<https://wiki.archlinux.org/index.php?title=Bash/Prompt_customization&oldid=789850>" - This page was last edited on 13 October 2023, at 12:09. - Content is available under [GNU Free Documentation License 1.3 or later](https://www.gnu.org/copyleft/fdl.html) unless otherwise noted. * [Privacy policy](https://terms.archlinux.org/docs/privacy-policy/) * [About ArchWiki](../../en/ArchWiki:About.html) * [Disclaimers](../../en/ArchWiki:General_disclaimer.html) * [Code of conduct](https://terms.archlinux.org/docs/code-of-conduct/ "archlinux-service-agreements:code-of-conduct") * [Terms of service](https://terms.archlinux.org/docs/terms-of-service/ "archlinux-service-agreements:terms-of-service") - [![GNU Free Documentation License 1.3 or later](/resources/assets/licenses/gnu-fdl.png)](https://www.gnu.org/copyleft/fdl.html) - ![](/resources/assets/poweredby_mediawiki_88x31.png) * Toggle limited content width
Binfmt misc for Java/Wrapper examples
Intro
# Binfmt misc for Java/Wrapper examples \[ ] 1 language * [日本語](https://wiki.archlinux.jp/index.php/Java_%E3%81%AE_binfmt_misc/%E3%83%A9%E3%83%83%E3%83%91%E3%83%BC%E3%81%AE%E4%BE%8B "Java の binfmt misc/ラッパーの例 – 日本語") From ArchWiki < [Binfmt misc for Java](../../en/Binfmt_misc_for_Java.html "Binfmt misc for Java") These are examples of wrappers and C code which can be used to run [Java](../../en/Java.html "Java") programs via `binfmt_misc`.
Binfmt misc for Java/Wrapper examples
jarwrapper
## jarwrapper ``` #!/bin/bash # /usr/local/bin/jarwrapper - the wrapper for binfmt_misc/jar # set path to java using JAVA_HOME if available, otherwise assume it's on the PATH JAVA_PATH=${JAVA_HOME:+$JAVA_HOME/jre/bin/}java $JAVA_PATH -jar "$@" ```
Binfmt misc for Java/Wrapper examples
javawrapper
## javawrapper ``` #!/bin/bash # /usr/local/bin/javawrapper - the wrapper for binfmt_misc/java if [ -z "$1" ]; then exec 1>&2 echo Usage: $0 class-file exit 1 fi CLASS=$1 FQCLASS=`/usr/local/bin/javaclassname $1` FQCLASSN=`echo $FQCLASS | sed -e 's/^.*\.\([^.]*\)$/\1/'` FQCLASSP=`echo $FQCLASS | sed -e 's-\.-/-g' -e 's-^[^/]*$--' -e 's-/[^/]*$--'` # for example: # CLASS=Test.class # FQCLASS=foo.bar.Test # FQCLASSN=Test # FQCLASSP=foo/bar unset CLASSBASE declare -i LINKLEVEL=0 while :; do if [ "`basename $CLASS .class`" == "$FQCLASSN" ]; then # See if this directory works straight off cd -L `dirname $CLASS` CLASSDIR=$PWD cd $OLDPWD if echo $CLASSDIR | grep -q "$FQCLASSP$"; then CLASSBASE=`echo $CLASSDIR | sed -e "s.$FQCLASSP$.."` break; fi # Try dereferencing the directory name cd -P `dirname $CLASS` CLASSDIR=$PWD cd $OLDPWD if echo $CLASSDIR | grep -q "$FQCLASSP$"; then CLASSBASE=`echo $CLASSDIR | sed -e "s.$FQCLASSP$.."` break; fi # If no other possible filename exists if [ ! -L $CLASS ]; then exec 1>&2 echo $0: echo " $CLASS should be in a" \ "directory tree called $FQCLASSP" exit 1 fi fi if [ ! -L $CLASS ]; then break; fi # Go down one more level of symbolic links let LINKLEVEL+=1 if [ $LINKLEVEL -gt 5 ]; then exec 1>&2 echo $0: echo " Too many symbolic links encountered" exit 1 fi CLASS=`ls --color=no -l $CLASS | sed -e 's/^.* \([^ ]*\)$/\1/'` done if [ -z "$CLASSBASE" ]; then if [ -z "$FQCLASSP" ]; then GOODNAME=$FQCLASSN.class else GOODNAME=$FQCLASSP/$FQCLASSN.class fi exec 1>&2 echo $0: echo " $FQCLASS should be in a file called $GOODNAME" exit 1 fi if ! echo $CLASSPATH | grep -q "^\(.*:\)*$CLASSBASE\(:.*\)*"; then # class is not in CLASSPATH, so prepend dir of class to CLASSPATH if [ -z "${CLASSPATH}" ] ; then export CLASSPATH=$CLASSBASE else export CLASSPATH=$CLASSBASE:$CLASSPATH fi fi shift # set path to java using JAVA_HOME if available, otherwise assume it's on the PATH JAVA_PATH=${JAVA_HOME:+$JAVA_HOME/jre/bin/}java $JAVA_PATH $FQCLASS "$@" ```
Binfmt misc for Java/Wrapper examples
javaclassname (support for javawrapper)
## javaclassname (support for javawrapper) This program is used by the *javawrapper* script above. Compile it with the command ``` $ gcc -O2 -o javaclassname javaclassname.c ``` and move the executable to `/usr/local/bin`. ``` /* javaclassname.c * * Extracts the class name from a Java class file; intended for use in a Java * wrapper of the type supported by the binfmt_misc option in the Linux kernel. * * Copyright (C) 1999 Colin J. Watson <cjw44@cam.ac.uk>. * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation; either version 2 of the License, or * (at your option) any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */ #include <stdlib.h> #include <stdio.h> #include <stdarg.h> #include <sys/types.h> /* From Sun's Java VM Specification, as tag entries in the constant pool. */ #define CP_UTF8 1 #define CP_INTEGER 3 #define CP_FLOAT 4 #define CP_LONG 5 #define CP_DOUBLE 6 #define CP_CLASS 7 #define CP_STRING 8 #define CP_FIELDREF 9 #define CP_METHODREF 10 #define CP_INTERFACEMETHODREF 11 #define CP_NAMEANDTYPE 12 /* Define some commonly used error messages */ #define seek_error() error("%s: Cannot seek\n", program) #define corrupt_error() error("%s: Class file corrupt\n", program) #define eof_error() error("%s: Unexpected end of file\n", program) #define utf8_error() error("%s: Only ASCII 1-255 supported\n", program); char *program; long *pool; u_int8_t read_8(FILE *classfile); u_int16_t read_16(FILE *classfile); void skip_constant(FILE *classfile, u_int16_t *cur); void error(const char *format, ...); int main(int argc, char **argv); /* Reads in an unsigned 8-bit integer. */ u_int8_t read_8(FILE *classfile) { int b = fgetc(classfile); if(b == EOF) eof_error(); return (u_int8_t)b; } /* Reads in an unsigned 16-bit integer. */ u_int16_t read_16(FILE *classfile) { int b1, b2; b1 = fgetc(classfile); if(b1 == EOF) eof_error(); b2 = fgetc(classfile); if(b2 == EOF) eof_error(); return (u_int16_t)((b1 << 8) | b2); } /* Reads in a value from the constant pool. */ void skip_constant(FILE *classfile, u_int16_t *cur) { u_int16_t len; int seekerr = 1; pool[*cur] = ftell(classfile); switch(read_8(classfile)) { case CP_UTF8: len = read_16(classfile); seekerr = fseek(classfile, len, SEEK_CUR); break; case CP_CLASS: case CP_STRING: seekerr = fseek(classfile, 2, SEEK_CUR); break; case CP_INTEGER: case CP_FLOAT: case CP_FIELDREF: case CP_METHODREF: case CP_INTERFACEMETHODREF: case CP_NAMEANDTYPE: seekerr = fseek(classfile, 4, SEEK_CUR); break; case CP_LONG: case CP_DOUBLE: seekerr = fseek(classfile, 8, SEEK_CUR); ++(*cur); break; default: corrupt_error(); } if(seekerr) seek_error(); } void error(const char *format, ...) { va_list ap; va_start(ap, format); vfprintf(stderr, format, ap); va_end(ap); exit(1); } int main(int argc, char **argv) { FILE *classfile; u_int16_t cp_count, i, this_class, classinfo_ptr; u_int8_t length; program = argv[0]; if(!argv[1]) error("%s: Missing input file\n", program); classfile = fopen(argv[1], "rb"); if(!classfile) error("%s: Error opening %s\n", program, argv[1]); if(fseek(classfile, 8, SEEK_SET)) /* skip magic and version numbers */ seek_error(); cp_count = read_16(classfile); pool = calloc(cp_count, sizeof(long)); if(!pool) error("%s: Out of memory for constant pool\n", program); for(i = 1; i < cp_count; ++i) skip_constant(classfile, &i); if(fseek(classfile, 2, SEEK_CUR)) /* skip access flags */ seek_error(); this_class = read_16(classfile); if(this_class < 1 || this_class >= cp_count) corrupt_error(); if(!pool[this_class] || pool[this_class] == -1) corrupt_error(); if(fseek(classfile, pool[this_class] + 1, SEEK_SET)) seek_error(); classinfo_ptr = read_16(classfile); if(classinfo_ptr < 1 || classinfo_ptr >= cp_count) corrupt_error(); if(!pool[classinfo_ptr] || pool[classinfo_ptr] == -1) corrupt_error(); if(fseek(classfile, pool[classinfo_ptr] + 1, SEEK_SET)) seek_error(); length = read_16(classfile); for(i = 0; i < length; ++i) { u_int8_t x = read_8(classfile); if((x & 0x80) || !x) { if((x & 0xE0) == 0xC0) { u_int8_t y = read_8(classfile); if((y & 0xC0) == 0x80) { int c = ((x & 0x1f) << 6) + (y & 0x3f); if(c) putchar(c); else utf8_error(); } else utf8_error(); } else utf8_error(); } else if(x == '/') putchar('.'); else putchar(x); } putchar('\n'); free(pool); fclose(classfile); return 0; } ``` [Category](../../Special:Categories.html "Special:Categories"): * [System administration](../../en/Category:System_administration.html "Category:System administration") - Retrieved from "<https://wiki.archlinux.org/index.php?title=Binfmt_misc_for_Java/Wrapper_examples&oldid=806243>" - This page was last edited on 17 April 2024, at 09:07. - Content is available under [GNU Free Documentation License 1.3 or later](https://www.gnu.org/copyleft/fdl.html) unless otherwise noted. * [Privacy policy](https://terms.archlinux.org/docs/privacy-policy/) * [About ArchWiki](../../en/ArchWiki:About.html) * [Disclaimers](../../en/ArchWiki:General_disclaimer.html) * [Code of conduct](https://terms.archlinux.org/docs/code-of-conduct/ "archlinux-service-agreements:code-of-conduct") * [Terms of service](https://terms.archlinux.org/docs/terms-of-service/ "archlinux-service-agreements:terms-of-service") - [![GNU Free Documentation License 1.3 or later](/resources/assets/licenses/gnu-fdl.png)](https://www.gnu.org/copyleft/fdl.html) - ![](/resources/assets/poweredby_mediawiki_88x31.png) * Toggle limited content width
Bubblewrap/Examples
Intro
# Bubblewrap/Examples \[ ] 1 language * [日本語](https://wiki.archlinux.jp/index.php/Bubblewrap/%E4%BE%8B "Bubblewrap/例 – 日本語") From ArchWiki < [Bubblewrap](../../en/Bubblewrap.html "Bubblewrap")
Bubblewrap/Examples
dhcpcd
## dhcpcd Create a simple [dhcpcd](../../en/Dhcpcd.html "Dhcpcd") sandbox: * Determine available kernel namespaces ``` $ ls /proc/self/ns cgroup ipc mnt net pid uts ``` **Note:** The absence of `user` indicates that the kernel has been built with `CONFIG_USER_NS=n` or is user namespace restricted. * Bind as read-write the entire host `/` directory to `/` in the sandbox * Mount a new devtmpfs filesystem to `/dev` in the sandbox * Create new [IPC](https://en.wikipedia.org/wiki/Inter-process_communication "wikipedia:Inter-process communication") and [control group](../../en/Cgroups.html "Control group") namespaces * Create a new UTS namespace and set `dhcpcd` as the hostname ``` # /usr/bin/bwrap --bind / / --dev /dev --unshare-ipc --unshare-cgroup --unshare-uts --hostname dhcpcd /usr/bin/dhcpcd -q -b ```
Bubblewrap/Examples
Unbound
## Unbound Create a more granular and complex [Unbound](../../en/Unbound.html "Unbound") sandbox: * Bind as read-only the system `/usr` directory to `/usr` in the sandbox * Create a symbolic link from the system `/usr/lib` directory to `/lib64` in the sandbox * Bind as read-only the system `/etc` directory to `/etc` in the sandbox * Create empty `/var` and `/run` directories within the sandbox * Mount a new devtmpfs filesystem to `/dev` in the sandbox * Create new IPC and [PID](https://en.wikipedia.org/wiki/Process_identifier "wikipedia:Process identifier") and control group namespaces * Create a new UTS namespace and set `unbound` as the hostname ``` # /usr/bin/bwrap --ro-bind /usr /usr --symlink usr/lib /lib64 --ro-bind /etc /etc --dir /var --dir /run --dev /dev --unshare-ipc --unshare-pid --unshare-cgroup --unshare-uts --hostname unbound /usr/bin/unbound -d ``` **Tip:** See [systemd#Editing provided units](../../en/Systemd.html#Editing_provided_units "Systemd") to enable the bubblewrapping of systemd unit files including `unbound.service`
Bubblewrap/Examples
MuPDF
## MuPDF ![](../../File:Inaccurate.svg)**The factual accuracy of this article or section is disputed.** **Reason:** Forwarding the X11 socket may lead to a sandbox escape (Discuss in [Talk:Bubblewrap/Examples](../../en/Talk:Bubblewrap/Examples.html)) The power and flexibility of *bwrap* is best revealed when used to create an environment within a shell wrapper: * Bind as read-only the host `/usr/bin` directory to `/usr/bin` in the sandbox * Bind as read-only the host `/usr/lib` directory to `/usr/lib` in the sandbox * Create a symbolic link from the system `/usr/lib` directory to `/lib64` in the sandbox * Create a [tmpfs](../../en/Tmpfs.html "Tmpfs") filesystem overlaying `/usr/lib/gcc` in the sandbox * This effectively [blacklists](https://en.wikipedia.org/wiki/Blacklist_\(computing\) "wikipedia:Blacklist (computing)") the contents of `/usr/lib/gcc` from appearing in the sandbox * Create a new tmpfs filesystem as the `$HOME` directory in the sandbox * Bind as read-only an `.Xauthority` file and *Documents* directory into the sandbox * This effectively whitelists the `.Xauthority` file and *Documents* directory with recursion * Create a new tmpfs filesystem as the `/tmp` directory in the sandbox * Whitelist the [X11](https://en.wikipedia.org/wiki/X_Window_System "wikipedia:X Window System") socket by binding it into the sandbox as read-only * Clone and create private containers for all namespaces supported by the running kernel * If the kernel does not support non-privileged user namespaces, skip its creation and continue * Do not place network components into a private namespace * This allows for network access to follow URI hyperlinks ``` #!/bin/sh #~/bwrap/mupdf.sh (exec bwrap \ --ro-bind /usr/bin /usr/bin \ --ro-bind /usr/lib /usr/lib \ --symlink usr/lib /lib64 \ --tmpfs /usr/lib/gcc \ --tmpfs $HOME \ --ro-bind $HOME/.Xauthority $HOME/.Xauthority \ --ro-bind $HOME/Documents $HOME/Documents \ --tmpfs /tmp \ --ro-bind /tmp/.X11-unix/X0 /tmp/.X11-unix/X0 \ --unshare-all \ --share-net \ /usr/bin/mupdf "$@") ``` **Tip:** Execute a shell wrapper substituting the existing executable with */usr/bin/sh* to debug and verify the contents and filesystem structure of the sandbox. ``` $ bwrap \ --ro-bind /usr/bin /usr/bin \ --ro-bind /usr/lib /usr/lib \ --symlink usr/lib /lib64 \ --tmpfs /usr/lib/gcc \ --tmpfs $HOME \ --ro-bind $HOME/.Xauthority $HOME/.Xauthority \ --ro-bind $HOME/Desktop $HOME/Desktop \ --tmpfs /tmp \ --ro-bind /tmp/.X11-unix/X0 /tmp/.X11-unix/X0 \ --unshare-all \ --share-net \ /usr/bin/sh bash-4.4$ ls -AF .Xauthority Documents/ ``` Perhaps the most important rule to consider when building a bubblewrapped filesystem is that *commands are executed in the order they appear*. From the [MuPDF](https://mupdf.com/) example above: * A tmpfs system is created followed by the bind mounting of an `.Xauthority` file and a *Documents* directory: ``` --tmpfs $HOME \ --ro-bind $HOME/.Xauthority $HOME/.Xauthority \ --ro-bind $HOME/Documents $HOME/Documents \ ``` ``` bash-4.4$ ls -a . .. .Xauthority Desktop ``` * A tmpfs filesystem is created after the bind mounting of `.Xauthority` and overlays it so that only the *Documents* directory is visible within the sandbox: ``` --ro-bind $HOME/.Xauthority $HOME/.Xauthority \ --tmpfs $HOME \ --ro-bind $HOME/Desktop $HOME/Desktop \ ``` ``` bash-4.4$ ls -a . .. Desktop ```
Bubblewrap/Examples
p7zip
## p7zip Applications which have not yet been patched against [known vulnerabilities](https://web.nvd.nist.gov/view/vuln/detail?vulnId=CVE-2016-9296) constitute prime candidates for bubblewrapping: * Bind as read-only the host `/usr/bin/7za` executable path to the sandbox * Create a symbolic link from the system `/usr/lib` directory to `/lib64` in the sandbox * Blacklist the sandboxed contents of `/usr/lib/modules` and `/usr/lib/systemd` with tmpfs overlays * Mount a new devtmpfs filesystem to `/dev` in the sandbox * Bind as read-write the host `/sandbox` directory to the `/sandbox` directory in the sandbox * *7za* will only run in the host `/sandbox` directory and/or its subdirectories when called from the shell wrapper * Create new cgroup/IPC/network/PID/UTS namespaces for the application and its processes * If the kernel does not support non-privileged user namespaces, skip its creation and continue * Creation of a new network namespace prevents the sandbox from obtaining network access * Add a custom or an arbitrary [hostname](../../en/Network_configuration.html#Set_the_hostname "Hostname") to the sandbox such as `p7zip` * Unset the `XAUTHORITY` [environment variable](../../en/Environment_variables.html "Environment variable") to hide the location of the X11 connection cookie * *7za* does not need to connect to an X11 display server to function properly * Start a new terminal session to prevent keyboard input from escaping the sandbox ``` #!/bin/sh #~/bwrap/pz7ip.sh (exec bwrap \ --ro-bind /usr/bin/7za /usr/bin/7za \ --symlink usr/lib /lib64 \ --tmpfs /usr/lib/modules \ --tmpfs /usr/lib/systemd \ --dev /dev \ --bind /sandbox /sandbox \ --unshare-all \ --hostname p7zip \ --unsetenv XAUTHORITY \ --new-session \ /usr/bin/7za "$@") ``` **Note:** */usr/bin/sh* and */usr/bin/ls* must reside in the executable path in order to traverse and verify the sandbox filesystem. ``` bwrap \ --ro-bind /usr/bin/7za /usr/bin/7za \ --ro-bind /usr/bin/ls /usr/bin/ls \ --ro-bind /usr/bin/sh /usr/bin/sh \ --symlink usr/lib /lib64 \ --tmpfs /usr/lib/modules \ --tmpfs /usr/lib/systemd \ --dev /dev \ --bind /sandbox /sandbox \ --unshare-all \ --hostname p7zip \ --unsetenv XAUTHORITY \ --new-session \ /usr/bin/sh bash: no job control in this shell bash-4.4$ ls -AF dev/ lib64@ usr/ bash-4.4$ ls -l /usr/lib/modules total 0 bash-4.4$ ls -l /usr/lib/systemd total 0 bash-4.4$ ls -AF /dev console full null ptmx@ pts/ random shm/ stderr@ stdin@ stdout@ tty urandom zero bash-4.4$ ls -A /usr/bin 7za ls sh ```
Bubblewrap/Examples
Firefox
## Firefox Network facing applications with large surface attack areas are also ideal candidates to be bubblewrapped: * [Transmission](../../en/Transmission.html "Transmission") included in the sandbox to launch with magnet and torrent links * Example wrap supports audio ([PulseAudio](../../en/PulseAudio.html "PulseAudio")) and printing ([CUPS](../../en/CUPS.html "CUPS")/[Avahi](../../en/Avahi.html "Avahi")) under [GNOME](../../en/GNOME.html "GNOME") ([Wayland](../../en/Wayland.html "Wayland")) * Paths in `~/.config/transmission/settings.json` should reflect the `--setenv HOME` variable * Full paths are used to allow for keyboard bindings in environments which do not support variable expansion. * [WebRenderer](../../en/Firefox.html#Hardware_video_acceleration "Firefox") and hardware (accelerated) compositing support included ``` bwrap \ --symlink usr/lib /lib \ --symlink usr/lib64 /lib64 \ --symlink usr/bin /bin \ --symlink usr/bin /sbin \ --ro-bind /usr/lib /usr/lib \ --ro-bind /usr/lib64 /usr/lib64 \ --ro-bind /usr/bin /usr/bin \ --ro-bind /usr/lib/firefox /usr/lib/firefox \ --ro-bind /usr/share/applications /usr/share/applications \ --ro-bind /usr/share/gtk-3.0 /usr/share/gtk-3.0 \ --ro-bind /usr/share/fontconfig /usr/share/fontconfig \ --ro-bind /usr/share/icu /usr/share/icu \ --ro-bind /usr/share/drirc.d /usr/share/drirc.d \ --ro-bind /usr/share/fonts /usr/share/fonts \ --ro-bind /usr/share/glib-2.0 /usr/share/glib-2.0 \ --ro-bind /usr/share/glvnd /usr/share/glvnd \ --ro-bind /usr/share/icons /usr/share/icons \ --ro-bind /usr/share/libdrm /usr/share/libdrm \ --ro-bind /usr/share/mime /usr/share/mime \ --ro-bind /usr/share/X11/xkb /usr/share/X11/xkb \ --ro-bind /usr/share/icons /usr/share/icons \ --ro-bind /usr/share/mime /usr/share/mime \ --ro-bind /etc/fonts /etc/fonts \ --ro-bind /etc/resolv.conf /etc/resolv.conf \ --ro-bind /usr/share/ca-certificates /usr/share/ca-certificates \ --ro-bind /etc/ssl /etc/ssl \ --ro-bind /etc/ca-certificates /etc/ca-certificates \ --dir "$XDG_RUNTIME_DIR" \ --ro-bind "$XDG_RUNTIME_DIR/pulse" "$XDG_RUNTIME_DIR/pulse" \ --ro-bind "$XDG_RUNTIME_DIR/wayland-1" "$XDG_RUNTIME_DIR/wayland-1" \ --dev /dev \ --dev-bind /dev/dri /dev/dri \ --ro-bind /sys/dev/char /sys/dev/char \ --ro-bind /sys/devices/pci0000:00 /sys/devices/pci0000:00 \ --proc /proc \ --tmpfs /tmp \ --bind /home/example/.mozilla /home/example/.mozilla \ --bind /home/example/.config/transmission /home/example/.config/transmission \ --bind /home/example/Downloads /home/example/Downloads \ --setenv HOME /home/example \ --setenv GTK_THEME Adwaita:dark \ --setenv MOZ_ENABLE_WAYLAND 1 \ --setenv PATH /usr/bin \ --hostname RESTRICTED \ --unshare-all \ --share-net \ --die-with-parent \ --new-session \ /usr/bin/firefox ``` ### Enhancing privacy * Further restrictions can be made by removing specific entries * Remove the following entry to remove audio support: ``` --ro-bind "$XDG_RUNTIME_DIR/pulse" "$XDG_RUNTIME_DIR/pulse" \ ``` * `/sandbox` represents an arbitrary location defined by the user to hold desired profile information * This allows for the use of a [sanitized profile](../../en/Firefox/Privacy.html#Sanitized_profiles "Firefox/Privacy") copied into `/sandbox` via a script/cron job or manually e.g. ``` $ cp -pR ~/.mozilla /sandbox/ ``` The location can be a network share, a USB mount, or a local filesystem or [ramfs/tmpfs location](../../en/Firefox/Profile_on_RAM.html "Firefox/Profile on RAM") * Set `/home/r` to obscure the actual `/home/example` * Set new user ID and group ID values **Note:** Ensure that the selected UID and GID does not conflict with existing values listed in `/etc/passwd` and `/etc/groups`. ``` bwrap \ .... --bind /sandbox/.mozilla /home/r/.mozilla \ --bind /sandbox/Downloads /home/r/Downloads \ ... --setenv HOME /home/r \ ... --uid 200 --gid 400 \ ... /usr/bin/firefox --no-remote --private-window ```
Bubblewrap/Examples
Chromium
## Chromium A simple chromium sandbox on wayland and with pipewire: ``` bwrap \ --symlink usr/lib /lib \ --symlink usr/lib64 /lib64 \ --symlink usr/bin /bin \ --symlink usr/bin /sbin \ --ro-bind /usr/lib /usr/lib \ --ro-bind /usr/lib64 /usr/lib64 \ --ro-bind /usr/bin /usr/bin \ --ro-bind /etc /etc \ --ro-bind /usr/lib/chromium /usr/lib/chromium \ --ro-bind /usr/share /usr/share \ --dev /dev \ --dev-bind /dev/dri /dev/dri \ --proc /proc \ --ro-bind /sys/dev/char /sys/dev/char \ --ro-bind /sys/devices /sys/devices \ --ro-bind /run/dbus /run/dbus \ --dir "$XDG_RUNTIME_DIR" \ --ro-bind "$XDG_RUNTIME_DIR/wayland-1" "$XDG_RUNTIME_DIR/wayland-1" \ --ro-bind "$XDG_RUNTIME_DIR/pipewire-0" "$XDG_RUNTIME_DIR/pipewire-0" \ --ro-bind "$XDG_RUNTIME_DIR/pulse" "$XDG_RUNTIME_DIR/pulse" \ --tmpfs /tmp \ --dir $HOME/.cache \ --bind $HOME/.config/chromium $HOME/.config/chromium \ --bind $HOME/Downloads $HOME/Downloads \ /usr/bin/chromium --enable-features=UseOzonePlatform --ozone-platform=wayland ``` **Warning:** If you are using the [linux-hardened](https://archlinux.org/packages/?name=linux-hardened) kernel, you will not be able to use bubblewrap to sandbox chromium due to the `kernel.unprivileged_userns_clone` [sysctl](../../en/Sysctl.html "Sysctl") being set to 0. You can set it to 1, however, this is not recommended [FS#36969](https://bugs.archlinux.org/task/36969). One alternative solution is to have chromium use the namespace created by bubblewrap. This can be achieved through [zypak](https://aur.archlinux.org/packages/zypak/)AUR which is also used by flatpak to run electron based apps inside an additional namespace. Example code that demonstrates how to use zypak with chromium/electron can be found [here](https://github.com/valoq/bwscripts/blob/master/profiles/signal-desktop) * [PipeWire](../../en/PipeWire.html "PipeWire"): `--ro-bind "$XDG_RUNTIME_DIR/pipewire-0" "$XDG_RUNTIME_DIR/pipewire-0" \` * If you are not using pipewire, feel free to remove this line * `--bind $HOME/.config/chromium $HOME/.config/chromium \` mounts your chromium configuration directory in the sandbox as readable and writable * `--bind $HOME/Downloads $HOME/Downloads \` mounts your \~/Downloads directory in the sandbox as readable and writable * This example can be further improved for more isolation.
Bubblewrap/Examples
Skype for Linux
## Skype for Linux ![](../../File:Inaccurate.svg)**The factual accuracy of this article or section is disputed.** **Reason:** Forwarding the X11 and/or DBus sockets may lead to a sandbox escape (Discuss in [Talk:Bubblewrap/Examples](../../en/Talk:Bubblewrap/Examples.html)) The following example provides these features: * `env -i` ensures that all environment variables are unset. * Network is shared with the host (`--share-net`), `/etc/resolv.conf` is bind-mounted. * [Xorg](../../en/Xorg.html "Xorg") access: bind the `/tmp/.X11-unix/X0` socket, set `$DISPLAY`. * [D-Bus](../../en/D-Bus.html "D-Bus"): bind the `$XDG_RUNTIME_DIR/bus` socket, set `$DBUS_SESSION_BUS_ADDRESS`. * Audio: bind the [PulseAudio](../../en/PulseAudio.html "PulseAudio") socket. * Video: dev-bind the `/dev/video0` device. The directory on the host where you want to keep the Skype profile can be configured with `$HOST_PROFILE_PATH`. ``` env -i bwrap \ --ro-bind /usr /usr \ --dir /home/r \ --dir /tmp \ --dir /var \ --dir "$XDG_RUNTIME_DIR" \ --proc /proc \ --dev /dev \ --symlink usr/lib /lib \ --symlink usr/lib64 /lib64 \ --symlink usr/bin /bin \ --symlink usr/sbin /sbin \ --symlink ../tmp /var/tmp \ --bind "$HOST_PROFILE_PATH" /home/r/.config/skypeforlinux \ --ro-bind /etc/resolv.conf /etc/resolv.conf \ --ro-bind /tmp/.X11-unix/X0 /tmp/.X11-unix/X0 \ --ro-bind "$XDG_RUNTIME_DIR/bus" "$XDG_RUNTIME_DIR/bus" \ --ro-bind "$XDG_RUNTIME_DIR/pulse" "$XDG_RUNTIME_DIR/pulse" \ --dev-bind /dev/video0 /dev/video0 \ --chdir / \ --unshare-all \ --share-net \ --hostname RESTRICTED \ --die-with-parent \ --new-session \ --setenv PATH /usr/bin \ --setenv HOME /home/r \ --setenv XDG_RUNTIME_DIR "$XDG_RUNTIME_DIR" \ --setenv DISPLAY "$DISPLAY" \ --setenv DBUS_SESSION_BUS_ADDRESS "unix:path=$XDG_RUNTIME_DIR/bus" \ /usr/bin/skypeforlinux ```
Bubblewrap/Examples
Steam
## Steam ![](../../File:Inaccurate.svg)**The factual accuracy of this article or section is disputed.** **Reason:** Forwarding the X11 and/or DBus sockets may lead to a sandbox escape (Discuss in [Talk:Bubblewrap/Examples](../../en/Talk:Bubblewrap/Examples.html)) A simple Steam sandbox ``` #!/usr/bin/bash set -e STEAM_HOME="$HOME/.local/share/steam_sandbox" RUN_USER="$XDG_RUNTIME_DIR" mkdir -p "$STEAM_HOME" _bind() { _bind_arg=$1 shift for _path in "$@"; do args+=("$_bind_arg" "$_path" "$_path") done } bind() { _bind --bind-try "$@" } robind() { _bind --ro-bind-try "$@" } devbind() { _bind --dev-bind-try "$@" } args=( --tmpfs /tmp --proc /proc --dev /dev --dir /etc --dir /var --dir "$RUN_USER" --bind "$STEAM_HOME" "$HOME" --dir "$HOME" --dir "$XDG_CONFIG_HOME" --dir "$XDG_CACHE_HOME" --dir "$XDG_DATA_HOME" --dir "$XDG_STATE_HOME" --symlink /usr/lib /lib --symlink /usr/lib /lib64 --symlink /usr/bin /bin --symlink /usr/bin /sbin --symlink /run /var/run --setenv XAUTHORITY "$XAUTHORITY" ) robind \ /usr \ /etc \ /opt \ /sys \ /var/empty \ /var/lib/alsa \ /var/lib/dbus \ "$RUN_USER/systemd/resolve" devbind \ /dev/dri \ /dev/nvidia* \ /dev/input \ /dev/uinput # steam bind \ "$XAUTHORITY" \ "$HOME/.local/bin/proton" \ "$HOME/.pki" \ "$HOME/.steam" \ "$HOME/.steampath" \ "$HOME/.steampid" \ "$HOME/Downloads" \ "$RUN_USER"/.mutter-X* \ "$RUN_USER"/ICE* \ "$RUN_USER"/dbus* \ "$RUN_USER"/gnome* \ "$RUN_USER"/pipewire* \ "$RUN_USER"/pulse* \ "$RUN_USER"/wayland* \ "$RUN_USER/at-spi" \ "$RUN_USER/bus" \ "$RUN_USER/dconf" \ "$RUN_USER/systemd" \ "$XDG_CACHE_HOME/mesa_shader_cache" \ "$XDG_CACHE_HOME/nv" \ "$XDG_CACHE_HOME/nvidia" \ "$XDG_CACHE_HOME/radv_builtin_shaders64" \ "$XDG_CONFIG_HOME/Epic" \ "$XDG_CONFIG_HOME/Loop_Hero" \ "$XDG_CONFIG_HOME/MangoHud" \ "$XDG_CONFIG_HOME/ModTheSpire" \ "$XDG_CONFIG_HOME/RogueLegacy" \ "$XDG_CONFIG_HOME/RogueLegacyStorageContainer" \ "$XDG_CONFIG_HOME/cef_user_data" \ "$XDG_CONFIG_HOME/proton" \ "$XDG_CONFIG_HOME/pulse" \ "$XDG_CONFIG_HOME/unity3d" \ "$XDG_DATA_HOME/3909/PapersPlease" \ "$XDG_DATA_HOME/Colossal Order" \ "$XDG_DATA_HOME/Dredmor" \ "$XDG_DATA_HOME/FasterThanLight" \ "$XDG_DATA_HOME/HotlineMiami" \ "$XDG_DATA_HOME/IntoTheBreach" \ "$XDG_DATA_HOME/Paradox Interactive" \ "$XDG_DATA_HOME/PillarsOfEternity" \ "$XDG_DATA_HOME/RogueLegacy" \ "$XDG_DATA_HOME/RogueLegacyStorageContainer" \ "$XDG_DATA_HOME/Steam" \ "$XDG_DATA_HOME/SuperHexagon" \ "$XDG_DATA_HOME/Terraria" \ "$XDG_DATA_HOME/applications" \ "$XDG_DATA_HOME/aspyr-media" \ "$XDG_DATA_HOME/bohemiainteractive" \ "$XDG_DATA_HOME/cdprojektred" \ "$XDG_DATA_HOME/feral-interactive" \ "$XDG_DATA_HOME/frictionalgames" \ "$XDG_DATA_HOME/icons" \ "$XDG_DATA_HOME/proton" \ "$XDG_DATA_HOME/vpltd" \ "$XDG_DATA_HOME/vulkan" \ "/var/lib/bluetooth" \ /run/systemd \ /tmp/.ICE-unix \ /tmp/.X11-unix exec bwrap "${args[@]}" /usr/lib/steam/steam "$@" ```
Bubblewrap/Examples
NPM, Node Version Manager (NVM), Maven Java
## NPM, Node Version Manager (NVM), Maven Java In order to be able to run *npm* in a project root you can use the following command. It works in combination with Angular, Cypress and Maven Java. X11 and wayland are on top included because Cypress starts a GUI based on electron. It allows full file access to the current directory where it is run from. Assuming you execute `npm install` in the current project root where *npm* needs to write to `node_modules`, `package.json`, etc. Also access to global *npm* install directory and *nvm* is allowed (`npm -g install ...`). Furthermore X11 with cypress is also able to run and even wayland apps. **Note:** The bindings to the directories zsh, maven, etc might differ from your setup. ``` bwrap_arguments=( # no zombies --die-with-parent # network required for dependencies --unshare-all --share-net # create environment for a properly running shell --tmpfs / --tmpfs /run --dir /tmp --dev /dev --proc /proc --ro-bind /bin /bin --ro-bind /sbin /sbin --ro-bind /usr /usr --ro-bind /etc /etc --ro-bind /lib /lib --ro-bind /lib64 /lib64 --ro-bind /sys /sys --ro-bind /var /var # systemd-resolve for dns --ro-bind /run/systemd/resolve /run/systemd/resolve # git is used by npm to init repos, config necessary for email username --ro-bind $XDG_CONFIG_HOME/git/config $XDG_CONFIG_HOME/git/config # zsh has to look everywhere cool --ro-bind $XDG_CONFIG_HOME/zsh/.zshrc $XDG_CONFIG_HOME/zsh/.zshrc --ro-bind $XDG_CONFIG_HOME/zsh/.zshenv $XDG_CONFIG_HOME/zsh/.zshenv --ro-bind $HOME/.zshenv $HOME/.zshenv # Maven --ro-bind /opt/maven /opt/maven --ro-bind $HOME/.m2 $HOME/.m2 # NPM --bind "$XDG_DATA_HOME/npm" "$XDG_DATA_HOME/npm" # cache is needed by many programs like npm, cypress, nvm, maven --bind "$XDG_CACHE_HOME" "$XDG_CACHE_HOME" # x11, needed for cypress --ro-bind "$XAUTHORITY" "$XAUTHORITY" # wayland, might be useful --ro-bind "$XDG_RUNTIME_DIR/$WAYLAND_DISPLAY" "$XDG_RUNTIME_DIR/$WAYLAND_DISPLAY" # current dir is assumed to be project dir and full access is allowed --bind "$(pwd)" "$(pwd)" ) # run bwrap with the arguments specified above and with the command provided by the user: zsh, npm install, etc $ bwrap "${bwrap_arguments[@]}" "$@" ``` [Categories](../../Special:Categories.html "Special:Categories"): * [Sandboxing](../../en/Category:Sandboxing.html "Category:Sandboxing") * [Kernel](../../en/Category:Kernel.html "Category:Kernel") Hidden category: * [Pages or sections flagged with Template:Accuracy](../../en/Category:Pages_or_sections_flagged_with_Template:Accuracy.html "Category:Pages or sections flagged with Template:Accuracy") - Retrieved from "<https://wiki.archlinux.org/index.php?title=Bubblewrap/Examples&oldid=805314>" - This page was last edited on 5 April 2024, at 00:32. - Content is available under [GNU Free Documentation License 1.3 or later](https://www.gnu.org/copyleft/fdl.html) unless otherwise noted. * [Privacy policy](https://terms.archlinux.org/docs/privacy-policy/) * [About ArchWiki](../../en/ArchWiki:About.html) * [Disclaimers](../../en/ArchWiki:General_disclaimer.html) * [Code of conduct](https://terms.archlinux.org/docs/code-of-conduct/ "archlinux-service-agreements:code-of-conduct") * [Terms of service](https://terms.archlinux.org/docs/terms-of-service/ "archlinux-service-agreements:terms-of-service") - [![GNU Free Documentation License 1.3 or later](/resources/assets/licenses/gnu-fdl.png)](https://www.gnu.org/copyleft/fdl.html) - ![](/resources/assets/poweredby_mediawiki_88x31.png) * Toggle limited content width
CUPS/Printer-specific problems
Intro
# CUPS/Printer-specific problems \[ ] 2 languages * [日本語](https://wiki.archlinux.jp/index.php/CUPS/%E3%83%97%E3%83%AA%E3%83%B3%E3%82%BF%E3%83%BC%E5%88%A5%E3%81%AE%E5%95%8F%E9%A1%8C "CUPS/プリンター別の問題 – 日本語") * [Русский](../../ru/CUPS/Printer-specific_problems.html "CUPS (Русский)/Printer-specific problems – русский") From ArchWiki < [CUPS](../../en/CUPS.html "CUPS") Related articles * [CUPS](../../en/CUPS.html "CUPS") * [CUPS/Troubleshooting](../../en/CUPS/Troubleshooting.html "CUPS/Troubleshooting") This article contains printer or manufacturer-specific instructions for [CUPS](../../en/CUPS.html "CUPS"). See [OpenPrinting](https://www.openprinting.org/printers) if your printer is not already listed here, or if none of the listed drivers work. **Note:** If you add a printer to this list, consider contributing your entry to [OpenPrinting](https://wiki.linuxfoundation.org/openprinting/database/databaseintro) - that way users of other distributions will also benefit!
YAML Metadata Warning: empty or missing yaml metadata in repo card (https://huggingface.co/docs/hub/datasets-cards)

This dataset is an export of the Arch Linux wiki as of the 7th of June 2024. The articles are split by subsection.

Downloads last month
4
Edit dataset card