https://wiki.archlinux.org/api.php?action=feedcontributions&user=Max-k&feedformat=atomArchWiki - User contributions [en]2024-03-29T01:59:30ZUser contributionsMediaWiki 1.41.0https://wiki.archlinux.org/index.php?title=DisplayLink&diff=548433DisplayLink2018-10-19T12:04:47Z<p>Max-k: /* Workaround 2: Temporarily disable PageFlip for modesetting */</p>
<hr />
<div>[[Category:Displays]]<br />
[[ja:DisplayLink]]<br />
DisplayLink devices on Linux still only have experimental support. While some people have had success in using them, it is generally not an easy process and not guaranteed to work. The steps on this page describe the generally most successful methods of using external monitors with DisplayLink.<br />
<br />
Also be warned that even over USB 3.0, a DisplayLink monitor may exhibit noticeably more lag than e.g. a DisplayPort monitor, especially when large portions of the screen are being redrawn.<br />
<br />
==Installation==<br />
<br />
=== USB 2.0 DL-1x5, DL-1x0 Devices ===<br />
<br />
The kernel [[Wikipedia: Direct_Rendering_Manager|DRM]] driver for DisplayLink is {{ic|udl}}, a rewrite of the original [https://www.kernel.org/doc/Documentation/fb/udlfb.txt udlfb] driver. It allows configuring DisplayLink monitors using [[Xrandr]].<br />
<br />
This should work without any configuration changes on {{pkg|linux}} 4.14.9-1 and later. If you're using an earlier version of that package or have {{ic|1=CONFIG_FB_UDL=m}} set in your kernel config, you need to [[blacklist]] the old kernel module, {{ic|udlfb}}, which may attempt to load itself first.<br />
<br />
=== USB 3.0 DL-6xxx, DL-5xxx, DL-41xx, DL-3xxx Devices ===<br />
<br />
{{Warning|The current version of {{AUR|evdi}}, which {{AUR|displaylink}} depends on, doesn't work on the latest version of {{Pkg|xorg-server}}. You should [[downgrade]] your {{Pkg|xorg-server}} and some relevant packages including but not limited to {{Pkg|xf86-video-fbdev}} and {{Pkg|xf86-video-intel}} to version {{ic|1.19.6}} in order to make {{AUR|displaylink}} work. Please check the following [https://github.com/DisplayLink/evdi/issues/133 github issue] for the latest update of this issue.}}<br />
<br />
# Install the {{AUR|displaylink}} driver. It allows configuring DisplayLink monitors using [[Xrandr]] in the same manner as the {{ic|udl}} driver.<br />
# Enable {{ic|displaylink.service}}.<br />
<br />
=== Setting up X Displays ===<br />
<br />
After that, run:<br />
<br />
{{hc|$ xrandr --listproviders|<nowiki><br />
Providers: number : 2<br />
Provider 0: id: 0x49 cap: 0xb, Source Output, Sink Output, Sink Offload crtcs: 2 outputs: 8 associated providers: 0 name:Intel<br />
Provider 1: id: 0x13c cap: 0x2, Sink Output crtcs: 1 outputs: 1 associated providers: 0 name:modesetting<br />
</nowiki>}}<br />
<br />
In the above output, we can see that provider 0 is the system's regular graphics provider (Intel), and provider 1 (modesetting) is the DisplayLink provider. To use the DisplayLink device, connect provider 1 to provider 0:<br />
<br />
$ xrandr --setprovideroutputsource 1 0<br />
<br />
and xrandr will add a DVI output you can [[Xrandr#Configuration|use as normal with xrandr]]. This is still experimental but supports hotplugging and when works, it is by far the simplest setup. If it works then everything below is unnecessary.<br />
<br />
==Configuration==<br />
<br />
These instructions assume that you already have an up and running X server and are simply adding a monitor to your existing setup.<br />
<br />
===Load the framebuffer device===<br />
<br />
Before your system will recognize your DisplayLink device, the {{ic|udl}} kernel module must be loaded. To do this, run<br />
<br />
# modprobe udl<br />
<br />
If your DisplayLink device is connected, it should show some visual indication of this. Although a green screen is the standard indicator of this, other variations have been spotted and are perfectly normal. Most importantly, the output of {{ic|dmesg}} should show something like the following, indicating a new DisplayLink device was found:<br />
<br />
{{bc|<nowiki>usb 2-1.1: new high-speed USB device number 7 using ehci-pci<br />
usb 2-1.1: New USB device found, idVendor=17e9, idProduct=03e0<br />
usb 2-1.1: New USB device strings: Mfr=1, Product=2, SerialNumber=3<br />
usb 2-1.1: Product: Lenovo LT1421 wide<br />
usb 2-1.1: Manufacturer: DisplayLink<br />
usb 2-1.1: SerialNumber: 6V9BBRM1<br />
[drm] vendor descriptor length:17 data:17 5f 01 00 15 05 00 01 03 00 04<br />
udl 2-1.1:1.0: fb1: udldrmfb frame buffer device<br />
[drm] Initialized udl 0.0.1 20120220 on minor 1<br />
</nowiki>}}<br />
<br />
Furthermore, {{ic|/dev}} should contain a new {{ic|fb}} device, likely {{ic|/dev/fb1}} if you already had a framebuffer for your primary display.<br />
<br />
To automatically load {{ic|udl}} at boot, create the file {{ic|udl.conf}} in {{ic|/etc/modules-load.d/}} with the following contents:<br />
<br />
{{hc|/etc/modules-load.d/udl.conf|udl}}<br />
<br />
For more information on loading kernel modules, see [[Kernel modules#Automatic module handling]].<br />
<br />
===Configuring X Server===<br />
Use {{ic|xrandr}} or your Desktop Environment's display setup UI to configure your USB monitors running either the {{ic|udl}} or {{ic|displaylink}} driver.<br />
<br />
====xrandr====<br />
<br />
Once the driver is loaded, the DisplayLink monitor is listed as an output provider:<br />
<br />
{{hc|$ xrandr --listproviders|<nowiki><br />
Providers: number : 2<br />
Provider 0: id: 0x43 cap: 0xb, Source Output, Sink Output, Sink Offload crtcs: 2 outputs: 2 associated providers: 1 name:Intel<br />
Provider 1: id: 0xcb cap: 0x2, Sink Output crtcs: 1 outputs: 1 associated providers: 1 name:modesetting<br />
</nowiki>}}<br />
In the above example, provider 1 is the DisplayLink device, and provider 0 is the default display. Running {{ic|xrandr --current}} gives a list of available screens:<br />
<br />
{{hc|$ xrandr --current|<nowiki><br />
Screen 0: minimum 320 x 200, current 1600 x 900, maximum 8192 x 8192<br />
LVDS1 connected 1600x900+0+0 (normal left inverted right x axis y axis) 309mm x 174mm<br />
1600x900 60.0*+ 40.0 <br />
1440x900 59.9 <br />
1360x768 59.8 60.0 <br />
1152x864 60.0 <br />
1024x768 60.0 <br />
800x600 60.3 56.2 <br />
640x480 59.9 <br />
VGA1 disconnected (normal left inverted right x axis y axis)<br />
DVI-1-0 connected (normal left inverted right x axis y axis)<br />
1366x768 60.0 +<br />
1368x768_59.90 59.9 <br />
1368x768_59.90 (0xd0) 85.7MHz<br />
h: width 1368 start 1440 end 1584 total 1800 skew 0 clock 47.6KHz<br />
v: height 768 start 769 end 772 total 795 clock 59.9Hz<br />
</nowiki>}}<br />
<br />
If the above does not list the DisplayLink screen, then you will need to offload DisplayLink to the main GPU:<br />
<br />
{{bc|xrandr --setprovideroutputsource 1 0}}<br />
<br />
Once the screen is available, refer to [[Xrandr]] for info on setting it up. For automating the configuration process, see [https://github.com/nathantypanski/displaylink.sh displaylink.sh].<br />
<br />
====Enabling DVI output on startup====<br />
The DisplayLink provider will not be automatically connected to the main provider in most cases, therefore the DVI output device will not be available. It can be helpful to automatically do this when X starts to facilitate automatic display configuration by the window manager.<br />
<br />
Edit your desktop manager's startup configuration and add commands similar to:<br />
{{bc|<nowiki><br />
$(xrandr --listproviders | grep -q "modesetting") && xrandr --setprovideroutputsource 1 0<br />
</nowiki>}}<br />
<br />
For example, the appropriate startup configuration file for [[SDDM]] is {{ic|/usr/share/sddm/scripts/Xsetup}}.<br />
<br />
Avoid placing these commands in {{ic|~/.xprofile}} as this breaks the display configuration of some window managers. Instead these commands should be run prior to any display output or setup.<br />
<br />
{{Note|If you have additional providers, specify the name of the provider instead of using indexes. The name of the DisplayLink device will be {{ic|modesetting}}}}<br />
<br />
==== Switching between displaylink and nvidia/nouveau driver ====<br />
<br />
Currently (displaylink version 1.3.54-1) it is not possible to use displaylink device and nvidia/nouveau driver simultaniously on optimus based laptops.<br />
Currently to be able to use displaylink device on intel GPU, you should create config file (see troubleshooting section below). However, with that config file it is not possible to use primusrun. Bumblebee service is running, but it cannot work. Also, laptop's fans are becoming very noisy and laptop's temperature becomes very high. When you want to switch back to activate nvidia driver, comment everything in that file and reboot.<br />
<br />
To simplify process of switching, you can [[install]] {{aur|dl-switch}} and add an additional menu entry to your bootloader using the [[kernel parameter]] {{ic|1=systemd.unit=displaylink.target}}, thus activating displaylink workaround.<br />
<br />
To check which driver is used for your discrete video card, run {{ic|lspci -nnk -s xx:xx.x}} (replace xx:xx.x with your nvidia gpu pci id).<br />
<br />
== Troubleshooting ==<br />
<br />
=== Not working configuration ===<br />
<br />
These are tested on [[Xfce]] using Display settings (included in XFCE4 package) and external tool - {{pkg|arandr}}. XFCE4 Display settings are likely to crash, so ARandR might help.<br />
<br />
When you connect display link device via USB to your computer, the computer should show monitors in Display settings. There are few troubleshooting steps that you should try:<br />
<br />
* Check [[#Setting up X Displays]]. If you can find any external monitors recognized, you should try to make them visible by the following commands:<br />
{{bc|<nowiki>xrandr --setprovideroutputsource 1 0<br />
xrandr --setprovideroutputsource 2 0<br />
xrandr --setprovideroutputsource 3 0<br />
...<br />
</nowiki>}}<br />
This will make them visible and recognized in Display settings.<br />
* Restart {{ic|displaylink.service}}.<br />
* Re-connecte USB cable.<br />
* Check if {{ic|udl}} driver is loaded and monitors are connected.<br />
<br />
=== Screen redraw is broken ===<br />
If you are using {{ic|udl}} as your kernel driver and the monitor appears to work, but is only updating where you move the mouse or when windows change in certain places, then you probably have the wrong modeline for your screen. Getting a proper modeline for your screen with a command like<br />
<br />
{{bc|<br />
gtf 1366 768 59.9<br />
}}<br />
<br />
where {{ic|1366}} and {{ic|768}} are the horizontal and vertical resolutions for your monitor, and {{ic|59.9}} is the refresh rate from its specs. To use this, create a new mode with {{ic|xrandr}} like follows:<br />
<br />
{{bc|<br />
xrandr --newmode "1368x768_59.90" 85.72 1368 1440 1584 1800 768 769 772 795 -HSync +Vsync<br />
}}<br />
<br />
and add it to [[Xrandr]]:<br />
<br />
{{bc|<br />
xrandr --addmode DVI-0 1368x768_59.90<br />
}}<br />
<br />
Then tell the monitor to use that mode for the DisplayLink monitor, and this should fix the redraw issues. Check the [[Xrandr]] page for information on using a different mode.<br />
<br />
If this does not solve the problem (or if the correct modeline was already in place because of correct DDC data), it can help to run a compositor. E.g. when using plain i3, running {{Pkg|xcompmgr}} or {{Pkg|compton}} can mitigate the problem.<br />
<br />
=== DisplayLink refresh rate is extremely slow with gnome 3 ===<br />
If once you set up your DisplayLink your entire desktop becomes slow, try setting a "simpler" background image, such as complete black.<br />
<br />
=== Slow redraw/Unresponsiveness in Google Chrome and Webkit2-based Applications ===<br />
This is to be associated with bugs in hardware acceleration, which can be tested by running glxgears in the displaylink screen resulting in 1fps. There is currently no complete fix available, but turning off Hardware-Acceleration in affected applications can work as a temporary fix.<br />
<br />
This can be done in applications without a hardware-acceleration option by prepending the {{ic|1=LIBGL_ALWAYS_SOFTWARE=1}} environment variable.<br />
<br />
=== Impossible to activate displaylink's screen ===<br />
In case you are able to see attached monitor via DisplayLink device in your screen settings, but after you turn it on and apply settings, it becomes deactivated, then try blacklist nouveau module and reboot:<br />
{{hc|/etc/modprobe.d/nouveau.conf|<nowiki><br />
blacklist nouveau<br />
options nouveau modeset=0<br />
</nowiki>}}<br />
<br />
=== Suspend problem ===<br />
<br />
Displaylink is not working after suspend. Unplug and then plug again displaylink's usb cable to your computer. Monitor that is connected via DisplayLink will remain black. If you have lock screen, login to the system and then picture will appear at that monitor and you will be able to use displaylink as normal.<br />
<br />
=== DisplayLink is not working when usb hot plugged ===<br />
To be able to use DisplayLink monitors, its usb cable should be attached to laptop during boot time. Otherwise it can behave like they are available and mouse can be moved there, but its picture is frozen, even with correct configuration (see workaround 1). If it was not attached at boot time, attach it and reboot.<br />
<br />
=== DisplayLink driver does not work with Intel GPUs after recent X upgrades ===<br />
As [http://support.displaylink.com/knowledgebase/articles/1181623 this support] page says, upgrading the X Window Server to a version newer than 1.18.3 will make the system not compatible with DisplayLink by default. This applies to systems using an integrated Intel GPU, or a combination of integrated Intel GPU and a discrete GPU.<br />
Until fixes in X Windows System will be released, there are two workarounds:<br />
<br />
==== Workaround 1: Use older intel driver as a fallback ====<br />
<br />
Use the "intel" driver for the integrated GPU instead of "modesetting", which is now the default.<br />
<br />
Create a file with the following content:<br />
{{hc|/usr/share/X11/xorg.conf.d/20-displaylink.conf|<br />
Section "Device" <br />
Identifier "Intel Graphics"<br />
Driver "intel"<br />
EndSection<br />
}}<br />
A reboot is required for the setting to be effective.<br />
<br />
You may need the {{aur|evdi-git}} package.<br />
<br />
==== Workaround 2: Temporarily disable PageFlip for modesetting ====<br />
<br />
For users that prefer to keep using "modesetting" driver, disabling page flipping should also help.<br />
Create a file with the following content:<br />
{{hc|/usr/share/X11/xorg.conf.d/20-displaylink.conf|<br />
Section "Device"<br />
Identifier "DisplayLink"<br />
Driver "modesetting"<br />
Option "PageFlip" "false"<br />
EndSection <br />
}}<br />
<br />
=== Displays disconnect at random intervals when using the Dell D6000 docking station ===<br />
<br />
User's have [https://www.displaylink.org/forum/showthread.php?t=65476 reported] that when using the Dell D6000 docking station, their display(s) may disconnect at random intervals during usage. This will require physically reconnecting the dock in order to reinitialise the displays.<br />
<br />
This issue appears to be caused by [[PulseAudio]]'s {{ic|module-suspend-on-idle}} module, which automatically suspends sinks/sources on idle.<br />
<br />
To disable loading of the {{ic|module-suspend-on-idle}} module, comment out the following line in the configuration file in use ({{ic|~/.config/pulse/default.pa}} or {{ic|/etc/pulse/default.pa}}):<br />
<br />
{{hc|/etc/pulse/default.pa|<br />
### Automatically suspend sinks/sources that become idle for too long<br />
# load-module module-suspend-on-idle<br />
}}<br />
<br />
== See Also ==<br />
<br />
* [http://displaylink.org/forum/forumdisplay.php?f=29 DisplayLink Open Source]: Official DisplayLink open source support forum<br />
* [http://plugable.com/platforms/linux Plugable]: Vendor blog chronicling Linux support for DisplayLink.<br />
* [http://www.displaylink.com/downloads/ubuntu.php Ubuntu Driver Download]: DisplayLink Ubuntu Driver Download and Information<br />
* [http://downloads.displaylink.com/releasenotes/DisplayLink_Ubuntu_1.0.68_release-note.txt Release Notes]: Latest release notes for DisplayLink Ubuntu Software</div>Max-khttps://wiki.archlinux.org/index.php?title=LDAP_authentication&diff=501240LDAP authentication2017-12-06T12:28:15Z<p>Max-k: /* 2. Detail NSCD Configuration to show how to disable passwd an group caching in nscd.conf */</p>
<hr />
<div>[[Category:Networking]]<br />
[[Category:Security]]<br />
[[ja:LDAP 認証]]<br />
{{Related articles start}}<br />
{{Related|OpenLDAP}}<br />
{{Related|LDAP Hosts}}<br />
{{Related articles end}}<br />
<br />
== Introduction and Concepts ==<br />
<br />
This is a guide on how to configure an Arch Linux installation to authenticate against an LDAP directory. This LDAP directory can be either local (installed on the same computer) or network (e.g. in a lab environment where central authentication is desired).<br />
<br />
The guide is divided into two parts. The first part deals with how to setup an [[OpenLDAP]] server that hosts the authentication directory. The second part deals with how to setup the NSS and PAM modules that are required for the authentication scheme to work on the client computers. If you just want to configure Arch to authenticate against an already existing LDAP server, you can skip to the [[#Client_Setup|second part]].<br />
<br />
=== NSS and PAM ===<br />
NSS (which stands for Name Service Switch) is a system mechanism to configure different sources for common configuration databases. For example, {{ic|/etc/passwd}} is a {{ic|file}} type source for the {{ic|passwd}} database.<br />
<br />
[[PAM]] (which stands for Pluggable Authentication Modules) is a mechanism used by Linux (and most *nixes) to extend its authentication schemes based on different plugins.<br />
<br />
So to summarize, we need to configure NSS to use the OpenLDAP server as a source for the {{ic|passwd}}, {{ic|shadow}} and other configuration databases and then configure PAM to use these sources to authenticate its users.<br />
<br />
== LDAP Server Setup ==<br />
<br />
=== Installation ===<br />
<br />
You can read about installation and basic configuration in the [[OpenLDAP]] article. After you have completed that, return here.<br />
<br />
=== Set up access controls ===<br />
<br />
To make sure that no-one can read the (encrypted) passwords from the LDAP server, but still allowing users to edit some of their own select attributes (such as own password and photo), add the following to {{ic|/etc/openldap/slapd.conf}} and restart {{ic|slapd.service}} afterwards:<br />
{{note|If you have a different domain name then alter "example" and "org" to your needs}}<br />
<br />
{{hc|slapd.conf|2=<br />
access to attrs=userPassword,givenName,sn,photo<br />
by self write<br />
by anonymous auth<br />
by dn.base="cn=Manager,dc=example,dc=org" write<br />
by * none<br />
<br />
access to *<br />
by self read <br />
by dn.base="cn=Manager,dc=example,dc=org" write<br />
by * read<br />
<br />
}}<br />
<br />
=== Populate LDAP Tree with Base Data ===<br />
<br />
Create a temporarily file called {{ic|base.ldif}} with the following text.<br />
<br />
{{hc|base.ldif|<nowiki><br />
# example.org<br />
dn: dc=example,dc=org<br />
dc: example<br />
o: Example Organization<br />
objectClass: dcObject<br />
objectClass: organization<br />
<br />
# Manager, example.org<br />
dn: cn=Manager,dc=example,dc=org<br />
cn: Manager<br />
description: LDAP administrator<br />
objectClass: organizationalRole<br />
objectClass: top<br />
roleOccupant: dc=example,dc=org<br />
<br />
# People, example.org<br />
dn: ou=People,dc=example,dc=org<br />
ou: People<br />
objectClass: top<br />
objectClass: organizationalUnit<br />
<br />
# Groups, example.org<br />
dn: ou=Group,dc=example,dc=org<br />
ou: Group<br />
objectClass: top<br />
objectClass: organizationalUnit<br />
</nowiki>}}<br />
<br />
Add it to your OpenLDAP Tree:<br />
<br />
$ ldapadd -D "cn=Manager,dc=example,dc=org" -W -f base.ldif<br />
<br />
Test to make sure the data was imported:<br />
<br />
$ ldapsearch -x -b 'dc=example,dc=org' '(objectclass=*)'<br />
<br />
=== Adding users ===<br />
To manually add a user, create an {{ic|.ldif}} file like this:<br />
{{hc|user_joe.ldif|<nowiki><br />
dn: uid=johndoe,ou=People,dc=example,dc=org<br />
objectClass: top<br />
objectClass: person<br />
objectClass: organizationalPerson<br />
objectClass: inetOrgPerson<br />
objectClass: posixAccount<br />
objectClass: shadowAccount<br />
uid: johndoe<br />
cn: John Doe<br />
sn: Doe<br />
givenName: John<br />
title: Guinea Pig<br />
telephoneNumber: +0 000 000 0000<br />
mobile: +0 000 000 0000<br />
postalAddress: AddressLine1$AddressLine2$AddressLine3<br />
userPassword: {CRYPT}xxxxxxxxxx<br />
labeledURI: https://archlinux.org/<br />
loginShell: /bin/bash<br />
uidNumber: 9999<br />
gidNumber: 9999<br />
homeDirectory: /home/johndoe/<br />
description: This is an example user<br />
</nowiki>}}<br />
<br />
The {{ic|xxxxxxxxxx}} in the {{ic|userPassword}} entry should be replaced with the value in {{ic|/etc/shadow}} or use the {{ic|slappasswd}} command. Now add the user:<br />
<br />
$ ldapadd -D "cn=Manager,dc=example,dc=org" -W -f user_joe.ldif<br />
<br />
{{Note|You can automatically migrate all of your local accounts (and groups, etc.) to the LDAP directory using PADL Software's [http://www.padl.com/OSS/MigrationTools.html Migration Tools].}}<br />
<br />
== Client Setup ==<br />
<br />
Install the OpenLDAP client as described in [[OpenLDAP]]. Make sure you can query the server with {{ic|ldapsearch}}.<br />
<br />
Next, [[install]] the {{pkg|nss-pam-ldapd}} package.<br />
<br />
=== NSS Configuration ===<br />
NSS is a system facility which manages different sources as configuration databases. For example, {{ic|/etc/passwd}} is a {{ic|file}} type source for the {{ic|passwd}} database, which stores the user accounts.<br />
<br />
Edit {{ic|/etc/nsswitch.conf}} which is the central configuration file for NSS. It tells NSS which sources to use for which system databases. We need to add the {{ic|ldap}} directive to the {{ic|passwd}}, {{ic|group}} and {{ic|shadow}} databases, so be sure your file looks like this:<br />
<br />
passwd: files ldap<br />
group: files ldap<br />
shadow: files ldap<br />
<br />
Edit {{ic|/etc/nslcd.conf}} and change the {{ic|base}} and {{ic|uri}} lines to fit your ldap server setup.<br />
<br />
Start {{ic|nslcd.service}} using systemd.<br />
<br />
You now should see your LDAP users when running {{ic|getent passwd}} on the client.<br />
<br />
=== PAM Configuration ===<br />
The basic rule of thumb for PAM configuration is to include {{ic|pam_ldap.so}} wherever {{ic|pam_unix.so}} is included. Arch moving to {{pkg|pambase}} has helped decrease the amount of edits required. For more details about configuring pam, the [https://access.redhat.com/site/documentation/en-US/Red_Hat_Enterprise_Linux/6/html/Managing_Smart_Cards/PAM_Configuration_Files.html RedHat Documentation] is quite good. You might also want the upstream documentation for [http://arthurdejong.org/nss-pam-ldapd nss-pam-ldapd].<br />
<br />
{{Tip|If you want to prevent UID clashes with local users on your system, you might want to include {{ic|minimum_uid&#61;10000}} or similar on the end of the {{ic|pam_ldap.so}} lines. You will have to make sure the LDAP server returns uidNumber fields that match the restriction.}}<br />
<br />
{{Note|Each facility (auth, session, password, account) forms a separate chain and the order matters. Sufficient lines will sometimes "short circuit" and skip the rest of the section, so the rule of thumb for ''auth'', ''password'', and ''account'' is ''sufficient'' lines before ''required'', but after required lines for the ''session'' section; ''optional'' can almost always go at the end. When adding your {{ic|pam_ldap.so}} lines, do not change the relative order of the other lines without good reason! Simply insert LDAP within the chain.}}<br />
<br />
First edit {{ic|/etc/pam.d/system-auth}}. This file is included in most of the other files in {{ic|pam.d}}, so changes here propagate nicely. Updates to {{pkg|pambase}} may change this file.<br />
<br />
Make {{ic|pam_ldap.so}} sufficient at the top of each section, except in the ''session'' section, where we make it optional.<br />
{{hc|/etc/pam.d/system-auth|<br />
'''auth sufficient pam_ldap.so'''<br />
auth required pam_unix.so try_first_pass nullok<br />
auth optional pam_permit.so<br />
auth required pam_env.so<br />
<br />
'''account sufficient pam_ldap.so'''<br />
account required pam_unix.so<br />
account optional pam_permit.so<br />
account required pam_time.so<br />
<br />
'''password sufficient pam_ldap.so'''<br />
password required pam_unix.so try_first_pass nullok sha512 shadow<br />
password optional pam_permit.so<br />
<br />
session required pam_limits.so<br />
session required pam_unix.so<br />
'''session optional pam_ldap.so'''<br />
session optional pam_permit.so<br />
}}<br />
<br />
Then edit both {{ic|/etc/pam.d/su}} and {{ic|/etc/pam.d/su-l}} identically. The {{ic|su-l}} file is used when the user runs {{ic|su --login}}.<br />
<br />
Make {{ic|pam_ldap.so}} sufficient at the top of each section, and add {{ic|use_first_pass}} to {{ic|pam_unix}} in the ''auth'' section.<br />
{{hc|/etc/pam.d/su|<br />
#%PAM-1.0<br />
'''auth sufficient pam_ldap.so'''<br />
auth sufficient pam_rootok.so<br />
# Uncomment the following line to implicitly trust users in the "wheel" group.<br />
#auth sufficient pam_wheel.so trust use_uid<br />
# Uncomment the following line to require a user to be in the "wheel" group.<br />
#auth required pam_wheel.so use_uid<br />
auth required pam_unix.so '''use_first_pass'''<br />
'''account sufficient pam_ldap.so'''<br />
account required pam_unix.so<br />
'''session sufficient pam_ldap.so'''<br />
session required pam_unix.so<br />
}}<br />
<br />
To enable users to edit their password, edit {{ic|/etc/pam.d/passwd}}:<br />
<br />
{{hc|/etc/pam.d/passwd|2=<br />
#%PAM-1.0<br />
'''password sufficient pam_ldap.so'''<br />
#password required pam_cracklib.so difok=2 minlen=8 dcredit=2 ocredit=2 retry=3<br />
#password required pam_unix.so sha512 shadow use_authtok<br />
password required pam_unix.so sha512 shadow nullok<br />
}}<br />
<br />
==== Create home folders at login ====<br />
<br />
If you want home folders to be created at login (eg: if you are not using NFS to store home folders), edit {{ic|/etc/pam.d/system-login}} and add {{ic|pam_mkhomedir.so}} to the ''session'' section above any "sufficient" items. This will cause home folder creation when logging in at a tty, from ssh, xdm, kdm, gdm, etc. You might choose to edit additional files in the same way, such as {{ic|/etc/pam.d/su}} and {{ic|/etc/pam.d/su-l}} to enable it for {{ic|su}} and {{ic|su --login}}. If you do not want to do this for ssh logins, edit {{ic|system-local-login}} instead of {{ic|system-login}}, etc.<br />
<br />
{{hc|/etc/pam.d/system-login|<br />
...top of file not shown...<br />
session optional pam_loginuid.so<br />
session include system-auth<br />
session optional pam_motd.so motd&#61;/etc/motd<br />
session optional pam_mail.so dir&#61;/var/spool/mail standard quiet<br />
-session optional pam_systemd.so<br />
session required pam_env.so<br />
'''session required pam_mkhomedir.so skel&#61;/etc/skel umask&#61;0022'''<br />
}}<br />
<br />
{{hc|/etc/pam.d/su-l|<br />
...top of file not shown...<br />
'''session required pam_mkhomedir.so skel&#61;/etc/skel umask&#61;0022'''<br />
session sufficient pam_ldap.so<br />
session required pam_unix.so<br />
}}<br />
<br />
==== Enable sudo ====<br />
<br />
To enable sudo from an LDAP user, edit {{ic|/etc/pam.d/sudo}}. You will also need to modify sudoers accordingly.<br />
{{hc|/etc/pam.d/sudo|<br />
#%PAM-1.0<br />
'''auth sufficient pam_ldap.so'''<br />
auth required pam_unix.so '''try_first_pass'''<br />
auth required pam_nologin.so<br />
}}<br />
<br />
You will also need to add in {{ic|/etc/openldap/ldap.conf}} the following.<br />
{{hc|/etc/openldap/ldap.conf|2=<br />
sudoers_base ou=sudoers,dc=AFOLA<br />
}}<br />
<br />
== Online and Offline Authentication with SSSD ==<br />
<br />
SSSD is a system daemon. Its primary function is to provide access to identity and authentication remote resource through a common framework that can provide caching and offline support to the system. It provides PAM and NSS modules, and in the future will D-BUS based interfaces for extended user information. It provides also a better database to store local users as well as extended user data.<br />
<br />
=== General Package Details ===<br />
<br />
[[Install]] the {{pkg|sssd}} package.<br />
<br />
=== How to enable SSSD for basic Authentication ===<br />
<br />
==== 1. SSSD Configuration ====<br />
<br />
If it does not exist create {{ic|/etc/sssd/sssd.conf}}.<br />
{{hc|/etc/sssd/sssd.conf|2=<br />
[sssd]<br />
config_file_version = 2<br />
services = nss, pam<br />
domains = LDAP<br />
<br />
[domain/LDAP]<br />
cache_credentials = true<br />
enumerate = true<br />
<br />
id_provider = ldap<br />
auth_provider = ldap<br />
<br />
ldap_uri = ldap://server1.example.org, ldap://server2.example.org<br />
ldap_search_base = dc=example,dc=org<br />
ldap_id_use_start_tls = true<br />
ldap_tls_reqcert = demand<br />
ldap_tls_cacert = /etc/openldap/certs/cacerts.pem<br />
chpass_provider = ldap<br />
ldap_chpass_uri = ldap://server1.example.org<br />
entry_cache_timeout = 600<br />
ldap_network_timeout = 2<br />
ldap_group_member = uniquemember<br />
}}<br />
<br />
The above is an example only. See {{man|5|sssd.conf}} for the full details.<br />
<br />
Finally set the file permissions {{ic|chmod 600 /etc/sssd/sssd.conf}} otherwise sssd will fail to start.<br />
<br />
==== 2. NSCD Configuration ====<br />
<br />
Disable caching for passwd, group and netgroup entries in {{ic|/etc/nscd.conf}} as it will interfere with sssd caching.<br />
<br />
Keep caching enabled for hosts entries otherwise some services may fail to start.<br />
{{hc|/etc/nscd.conf|<br />
# Begin /etc/nscd.conf<br />
''[...]''<br />
enable-cache passwd '''no'''<br />
''[...]''<br />
enable-cache group '''no'''<br />
''[...]''<br />
enable-cache hosts yes<br />
''[...]''<br />
enable-cache netgroup '''no'''<br />
''[...]''<br />
# End /etc/nscd.conf<br />
}}<br />
<br />
==== 3. NSS Configuration ====<br />
<br />
Edit {{ic|/etc/nsswitch.conf}} as follows.<br />
{{hc|/etc/nsswitch.conf|<br />
# Begin /etc/nsswitch.conf<br />
<br />
passwd: files '''sss'''<br />
group: files '''sss'''<br />
shadow: files '''sss'''<br />
'''sudoers: files sss'''<br />
<br />
publickey: files<br />
<br />
hosts: files dns myhostname<br />
networks: files<br />
<br />
protocols: files<br />
services: files<br />
ethers: files<br />
rpc: files<br />
<br />
netgroup: files<br />
<br />
# End /etc/nsswitch.conf<br />
}}<br />
<br />
==== 4. PAM Configuration ====<br />
<br />
The first step is to edit {{ic|/etc/pam.d/system-auth}} as follows.<br />
{{hc|/etc/pam.d/system-auth|2=<br />
#%PAM-1.0<br />
<br />
'''auth sufficient pam_sss.so forward_pass'''<br />
auth required pam_unix.so try_first_pass nullok<br />
auth optional pam_permit.so<br />
auth required pam_env.so<br />
<br />
'''account [default=bad success=ok user_unknown=ignore authinfo_unavail=ignore] pam_sss.so'''<br />
account required pam_unix.so<br />
account optional pam_permit.so<br />
account required pam_time.so<br />
<br />
'''password sufficient pam_sss.so use_authtok'''<br />
password required pam_unix.so try_first_pass nullok sha512 shadow<br />
password optional pam_permit.so<br />
<br />
'''session required pam_mkhomedir.so skel=/etc/skel/ umask=0077'''<br />
session required pam_limits.so<br />
session required pam_unix.so<br />
'''session optional pam_sss.so'''<br />
session optional pam_permit.so<br />
}}<br />
<br />
===== 1. SUDO Configuration =====<br />
<br />
Edit {{ic|/etc/pam.d/sudo}} as follows.<br />
{{hc|/etc/pam.d/sudo|<br />
#%PAM-1.0<br />
'''auth sufficient pam_sss.so'''<br />
auth required pam_unix.so try_first_pass<br />
auth required pam_nologin.so<br />
}}<br />
<br />
===== 2. Password Management =====<br />
<br />
In order to enable users to change their passwords using {{ic|passwd}} edit {{ic|/etc/pam.d/passwd}} as follows.<br />
{{hc|/etc/pam.d/passwd|2=<br />
#%PAM-1.0<br />
'''password sufficient pam_sss.so'''<br />
#password required pam_cracklib.so difok=2 minlen=8 dcredit=2 ocredit=2 retry=3<br />
#password required pam_unix.so sha512 shadow use_authtok<br />
password required pam_unix.so sha512 shadow nullok<br />
}}<br />
<br />
[[Start/enable]] the {{ic|sssd.service}} systemd unit.<br />
<br />
You should now be able to see details of your ldap users with {{ic|getent passwd <username>}} or {{ic|id <username>}}.<br />
<br />
Once you have logged in with a user the credentials will be cached and you will be able to login using the cached credentials when the ldap server is offline or unavailable.<br />
<br />
== Resources ==<br />
* [http://arthurdejong.org/nss-pam-ldapd/setup The official page of the nss-pam-ldapd packet]<br />
* [[debian:LDAP/NSS|Debian Wiki - LDAP/NSS]]<br />
* [[debian:LDAP/PAM|Debian Wiki - LDAP/PAM]]<br />
* [https://www.fatofthelan.com/technical/using-ldap-for-single-authentication/ Using LDAP for single authentication]<br />
* [http://www.cs.dixie.edu/ldap/ Heterogeneous Network Authentication Introduction]<br />
* [http://readlist.com/lists/suse.com/suse-linux-e/36/182642.html Discussion on suse's mailing lists about nss-pam-ldapd]<br />
* [https://docs.fedoraproject.org/en-US/Fedora/15/html/Deployment_Guide/chap-SSSD_User_Guide-Introduction.html Fedora's SSSD User Guide]</div>Max-khttps://wiki.archlinux.org/index.php?title=Cgroups&diff=439192Cgroups2016-06-28T01:12:51Z<p>Max-k: /* Ad-hoc groups */</p>
<hr />
<div>[[Category:Kernel]]<br />
[[Category:Virtualization]]<br />
[[ja:Cgroups]]<br />
{{Related articles start}}<br />
{{Related|Linux Containers}}<br />
{{Related|systemd-nspawn}}<br />
{{Related|Docker}}<br />
{{Related articles end}}<br />
<br />
'''cgroups''' (aka '''control groups''') is a Linux kernel feature to limit, police and account the resource usage for a set of processes. Compared to other approaches like the 'nice' command or {{ic|/etc/security/limits.conf}}, cgroups are more flexible as they can operate on (sub)sets of processes (possibly with different system users).<br />
<br />
Control groups can be used in multiple ways:<br />
* By accessing the {{ic|cgroup}} filesystem directly.<br />
* Using the {{ic|cgm}} client (part of the {{Pkg|cgmanager}} package).<br />
* Via tools like {{ic|cgcreate}}, {{ic|cgexec}} and {{ic|cgclassify}} (part of the {{AUR|libcgroup}} package).<br />
* the "rules engine daemon", to automatically move certain users/groups/commands to groups ({{ic|/etc/cgrules.conf}} and {{ic|/usr/lib/systemd/system/cgconfig.service}}) (part of the {{AUR|libcgroup}} package).<br />
* through other software such as [[Linux Containers]] (LXC) virtualization, tools like {{Pkg|playpen}} or systemd.<br />
<br />
== Installing ==<br />
[[Install]] any of:<br />
* {{AUR|libcgroup}} - set of standalone tools ({{ic|cgcreate}}, {{ic|cgclassify}}, persistence via {{ic|cgconfig.conf}}).<br />
* {{Pkg|cgmanager}} - simple client ({{ic|cgm}}) that communicates with its daemon ({{ic|cgmanager}}) to manage cgroups.<br />
* {{Pkg|systemd}} - for controlling resources of a systemd service.<br />
<br />
After installation of the {{Pkg|cgmanager}} package, you need to [[Start]] {{ic|cgmanager.service}} before its {{ic|cgm}} client can be used.<br />
<br />
== Managing Resource Groups with Systemd ==<br />
<br />
You can [[enable]] the {{ic|cgconfig}} service with systemd. This gives you the capability to track more easily any errors in {{ic|cgconfig.conf}}.<br />
<br />
== Simple usage ==<br />
<br />
=== Ad-hoc groups ===<br />
<br />
One of the powers of cgroups is that you can create "ad-hoc" groups on the fly. You can even grant the privileges to create custom groups to regular users. {{ic|groupname}} is the cgroup name:<br />
<br />
# cgcreate -a ''user'' -g memory,cpu:''groupname''<br />
<br />
Alternatively, using {{ic|cgmanager}} with user ID `1000` and system group ''root'' (GID 0):<br />
<br />
# cgm create memory ''groupname''<br />
# cgm chown memory ''groupname'' ''1000'' 0<br />
# cgm create cpu ''groupname''<br />
# cgm chown cpu ''groupname'' ''1000'' 0<br />
# # the above only makes 'cgroup.procs' and 'tasks' writable<br />
# chown ''user'' /sys/fs/cgroup/{memory,cpu}/''groupname''/*<br />
<br />
Now all the tunables in the group {{ic|groupname}} are writable by your user:<br />
<br />
$ ls -l /sys/fs/cgroup/memory/''groupname''<br />
total 0<br />
-rwxrwxr-x 1 user root 0 Sep 25 00:39 cgroup.event_control<br />
-rwxrwxr-x 1 user root 0 Sep 25 00:39 cgroup.procs<br />
-rwxrwxr-x 1 user root 0 Sep 25 00:39 cpu.rt_period_us<br />
-rwxrwxr-x 1 user root 0 Sep 25 00:39 cpu.rt_runtime_us<br />
-rwxrwxr-x 1 user root 0 Sep 25 00:39 cpu.shares<br />
-rwxrwxr-x 1 user root 0 Sep 25 00:39 notify_on_release<br />
-rwxrwxr-x 1 user root 0 Sep 25 00:39 tasks<br />
<br />
Cgroups are hierarchical, so you can create as many subgroups as you like. If a normal user wants to run a {{ic|bash}} shell under a new subgroup called {{ic|foo}}:<br />
<br />
$ cgcreate -g memory,cpu:'''groupname/foo'''<br />
$ '''cgexec''' -g memory,cpu:groupname/foo '''bash'''<br />
<br />
Likewise, for {{ic|cgmanager}}:<br />
<br />
$ cgm create memory '''groupname/foo'''<br />
$ cgm create cpu '''groupname/foo'''<br />
$ bash<br />
$ cgm movepid memory groupname/foo $pid_of_bash<br />
$ cgm movepid cpu groupname/foo $pid_of_bash<br />
<br />
To make sure (only meaningful for legacy (v1) cgroups):<br />
<br />
$ cat /proc/self/cgroup<br />
11:memory:/groupname/foo<br />
6:cpu:/groupname/foo<br />
<br />
A new subdirectory was created for this group. To limit the memory usage of all processes in this group to 10 MB, run the following:<br />
<br />
$ echo 10000000 > /sys/fs/cgroup/memory/groupname/foo/memory.limit_in_bytes<br />
<br />
Alternative invocation with {{ic|cgmanager}}:<br />
<br />
$ cgm setvalue memory groupname/foo memory.limit_in_bytes 10000000<br />
<br />
Note that the memory limit applies to RAM use only -- once tasks hit this limit, they will begin to swap. But it won't affect the performance of other processes significantly.<br />
<br />
Similarly you can change the CPU priority ("shares") of this group. By default all groups have 1024 shares. A group with 100 shares will get a ~10% portion of the CPU time:<br />
<br />
$ echo 100 > /sys/fs/cgroup/cpu/groupname/foo/cpu.shares<br />
<br />
You can find more tunables or statistics by listing the cgroup directory.<br />
<br />
You can also change the cgroup of already running processes. To move all 'bash' commands to this group:<br />
<br />
$ pidof bash<br />
13244 13266<br />
$ '''cgclassify''' -g memory,cpu:groupname/foo `pidof bash`<br />
$ cat /proc/13244/cgroup<br />
11:memory:/groupname/foo<br />
6:cpu:/groupname/foo<br />
<br />
=== Persistent group configuration ===<br />
<br />
{{Note|when using [[Systemd]] > &#61; 205 to manage cgroups, you can ignore this file entirely.<br />
}}<br />
<br />
If you want your cgroups to be created at boot, you can define them in {{ic|/etc/cgconfig.conf}} instead. For example, the "groupname" has a permission for {{ic|$USER}} and ''users'' of group {{ic|$GROUP}} to manage limits and add tasks. A ''subgroup'' "groupname/foo" group definitions would look like this: <br />
<br />
{{hc|/etc/cgconfig.conf |2=<br />
group '''groupname''' {<br />
perm {<br />
# who can manage limits<br />
admin {<br />
uid = '''$USER''';<br />
gid = '''$GROUP''';<br />
}<br />
# who can add tasks to this group<br />
task {<br />
uid = '''$USER''';<br />
gid = '''$GROUP''';<br />
}<br />
}<br />
# create this group in cpu and memory controllers<br />
cpu { }<br />
memory { }<br />
}<br />
<br />
group '''groupname/foo''' {<br />
cpu {<br />
'''cpu.shares''' = 100;<br />
}<br />
memory {<br />
'''memory.limit_in_bytes''' = 10000000;<br />
}<br />
}<br />
}}<br />
<br />
{{Note|<br />
*Comments should begin at the start of a line! The '''#''' character for comments must appear as the first character of a line. Else, ''cgconfigparser'' will have problem parsing it but will only report {{ic|cgroup change of group failed}} as the error, unless you started ''cgconfig'' with [[Systemd]]<br />
*The permissions section is optional.<br />
*The {{ic|/sys/fs/cgroup/}} hierarchy directory containing all ''controllers'' sub-directories is already created and mounted at boot as a virtual file system. This gives the ability to create a new group entry with the {{ic|''$CONTROLLER-NAME { }''}} command. If for any reason you want to create and mount hierachies in another place, you will then need to write a second entry in {{ic|/etc/cgconfig.conf}} following this way :<br />
<br />
mount { <br />
cpuset &#61; /your/path/''groupname'';<br />
}<br />
<br />
This is equivalent to these shell commands:<br />
{{ic| <br />
# mkdir /your/path/''groupname''<br />
# mount -t /your/path -o cpuset ''groupname'' /your/path/''groupname''}}<br />
<br />
}}<br />
<br />
== Useful examples ==<br />
<br />
=== Matlab ===<br />
<br />
Matlab does not have any protection against taking all your machine's memory or CPU. Launching a large calculation can thus trash your system. You could put the following in {{ic|/etc/cgconfig.conf}} to protect from this (where {{ic|$USER}} is your username):<br />
<br />
{{hc|/etc/cgconfig.conf |2=<br />
# Prevent Matlab from taking all memory<br />
group matlab {<br />
perm {<br />
admin {<br />
uid = ''$USER'';<br />
}<br />
task {<br />
uid = ''$USER'';<br />
}<br />
}<br />
<br />
cpuset {<br />
cpuset.mems="0";<br />
cpuset.cpus="0-5";<br />
}<br />
memory {<br />
# 5 GiB limit<br />
memory.limit_in_bytes = 5368709120;<br />
}<br />
}<br />
}}<br />
<br />
{{Note|Do not forget to change $USER to the actual username Matlab will be run by.}}<br />
<br />
This cgroup will bind Matlab to cores 0 to 5 (e.g., if you have have 8, Matlab will only see 6) and cap its memory usage to 5 GiB. The "cpu" resource constraint can also be defined to prevent CPU usage, but you may find the "cpuset" constrain to be sufficient.<br />
<br />
Launch matlab like this:<br />
<br />
$ cgexec -g memory,cpuset:matlab /opt/MATLAB/2012b/bin/matlab -desktop<br />
<br />
Make sure to use the right path to the executable.<br />
<br />
== Documentation ==<br />
<br />
* For information on controllers and what certain switches and tunables mean, refer to [https://www.kernel.org/doc/Documentation/cgroups/ kernel's Documentation/cgroup] (or install linux-docs and see {{ic|/usr/src/linux/Documentation/cgroup}}<br />
* A detailed and complete Resource Management Guide can be found in the [http://docs.fedoraproject.org/en-US/Fedora/17/html-single/Resource_Management_Guide/index.html#sec-How_Control_Groups_Are_Organized fedora project documentation].<br />
For commands and configuration files, see relevant man pages, e.g. {{ic|man cgcreate}} or {{ic|man cgrules.conf}}</div>Max-khttps://wiki.archlinux.org/index.php?title=GnuPG&diff=438872GnuPG2016-06-24T08:34:57Z<p>Max-k: /* SSH agent */</p>
<hr />
<div>[[Category:Encryption]]<br />
[[es:GnuPG]]<br />
[[ja:GnuPG]]<br />
[[ru:GnuPG]]<br />
[[zh-cn:GnuPG]]<br />
{{Related articles start}}<br />
{{Related|pacman/Package signing}}<br />
{{Related|Disk encryption}}<br />
{{Related|List of applications/Security#Encryption, signing, steganography}}<br />
{{Related articles end}}<br />
<br />
According to the [http://www.gnupg.org official website]:<br />
<br />
:GnuPG is a complete and free implementation of the OpenPGP standard as defined by RFC4880 (also known as PGP). GnuPG allows to encrypt and sign your data and communication, features a versatile key management system as well as access modules for all kinds of public key directories. GnuPG, also known as GPG, is a command line tool with features for easy integration with other applications. A wealth of frontend applications and libraries are available. Version 2 of GnuPG also provides support for S/MIME and Secure Shell (ssh).<br />
<br />
== Installation ==<br />
<br />
[[Install]] the {{Pkg|gnupg}} package.<br />
<br />
This will also install {{Pkg|pinentry}}, a collection of simple PIN or passphrase entry dialogs which GnuPG uses for passphrase entry. Which ''pinentry'' dialog is used is determined by the symbolic link {{ic|/usr/bin/pinentry}}, which by default points to {{ic|/usr/bin/pinentry-gtk-2}}.<br />
<br />
If you want to use a graphical frontend or program that integrates with GnuPG, see [[List of applications/Security#Encryption, signing, steganography]].<br />
<br />
== Configuration ==<br />
<br />
=== Directory location ===<br />
{{ic|$GNUPGHOME}} is used by GnuPG to point to the directory where its configuration files are stored. By default {{ic|$GNUPGHOME}} is not set and your {{ic|$HOME}} is used instead; thus, you will find a {{ic|~/.gnupg}} directory right after installation. <br />
<br />
To change the default location, either run gpg this way {{ic|$ gpg --homedir ''path/to/file''}} or set {{ic|GNUPGHOME}} in one of your regular [[startup files]].<br />
<br />
=== Configuration files ===<br />
<br />
The default configuration files are {{ic|~/.gnupg/gpg.conf}} and {{ic|~/.gnupg/dirmngr.conf}}. <br />
<br />
By default, the gnupg directory has its [[permissions]] set to {{ic|700}} and the files it contains have their permissions set to {{ic|600}}. Only the owner of the directory has permission to read, write, and access the files. This is for security purposes and should not be changed. In case this directory or any file inside it does not follow this security measure, you will get warnings about unsafe file and home directory permissions.<br />
<br />
Append to these files any long options you want. Do not write the two dashes, but simply the name of the option and required arguments. You will find skeleton files in {{ic|/usr/share/gnupg}}. These files are copied to {{ic|~/.gnupg}} the first time gpg is run if they do not exist there. Other examples are found in [[#See also]].<br />
<br />
Additionally, [[pacman]] uses a different set of configuration files for package signature verification. See [[Pacman/Package signing]] for details.<br />
<br />
=== Default options for new users ===<br />
<br />
If you want to setup some default options for new users, put configuration files in {{ic|/etc/skel/.gnupg/}}. When the new user is added in system, files from here will be copied to its GnuPG home directory. There is also a simple script called ''addgnupghome'' which you can use to create new GnuPG home directories for existing users:<br />
<br />
# addgnupghome user1 user2<br />
<br />
This will add the respective {{ic|/home/user1/.gnupg}} and {{ic|/home/user2/.gnupg}} and copy the files from the skeleton directory to it. Users with existing GnuPG home directory are simply skipped.<br />
<br />
== Usage ==<br />
<br />
{{Note|Whenever a ''{{ic|<user-id>}}'' is required in a command, it can be specified with your key ID, fingerprint, a part of your name or email address, etc. GnuPG is flexible on this.<br />
}}<br />
<br />
=== Create key pair ===<br />
<br />
Generate a key pair by typing in a terminal:<br />
<br />
$ gpg --full-gen-key<br />
<br />
{{Tip|Use the {{ic|--expert}} option for getting alternative ciphers like [[wikipedia:Elliptic_curve_cryptography|ECC]].}}<br />
<br />
The command will prompt for answers to several questions. For general use most people will want: <br />
<br />
* the RSA (sign only) and a RSA (encrypt only) key.<br />
* a keysize of the default value (2048). A larger keysize of 4096 "gives us almost nothing, while costing us quite a lot"[https://www.gnupg.org/faq/gnupg-faq.html#no_default_of_rsa4096].<br />
* an expiration date. A period of a year is good enough for the average user. This way even if access is lost to the keyring, it will allow others to know that it is no longer valid. Later, if necessary, the expiration date can be extended without having to re-issue a new key.<br />
* your name and email address. You can add multiple identities to the same key later (''e.g.'', if you have multiple email addresses you want to associate with this key).<br />
* ''no'' optional comment. Since the semantics of the comment field are [https://lists.gnupg.org/pipermail/gnupg-devel/2015-July/030150.html not well-defined], it has limited value for identification.<br />
* [[Security#Choosing_secure_passwords|a secure passphrase]].<br />
<br />
{{Note|The name and email address you enter here will be seen by anybody who imports your key.}}<br />
<br />
=== List keys ===<br />
<br />
To list keys in your public key ring:<br />
<br />
$ gpg --list-keys<br />
<br />
To list keys in your secret key ring:<br />
<br />
$ gpg --list-secret-keys<br />
<br />
=== Export your public key ===<br />
<br />
gpg's main usage is to ensure confidentiality of exchanged messages via public-key cryptography. With it each user distributes the public key of their keyring, which can be be used by others to encrypt messages to the user. The private key must ''always'' be kept private, otherwise confidentiality is broken. See [[w:Public-key cryptography]] for examples about the message exchange. <br />
<br />
So, in order for others to send encrypted messages to you, they need your public key. <br />
<br />
To generate an ASCII version of your public key (''e.g.'' to distribute it by e-mail):<br />
<br />
$ gpg --output ''public.key'' --armor --export ''<user-id>'' <br />
<br />
Alternatively, or in addition, you can [[#Use a keyserver]] to share your key. <br />
<br />
{{Tip|Add {{ic|--no-emit-version}} to avoid printing the version number, or add the corresponding setting to your configuration file.}}<br />
<br />
=== Import a public key ===<br />
<br />
In order to encrypt messages to others, as well as verify their signatures, you need their public key. To import a public key with file name {{ic|''public.key''}} to your public key ring:<br />
<br />
$ gpg --import ''public.key''<br />
<br />
Alternatively, [[#Use a keyserver]] to find a public key.<br />
<br />
=== Use a keyserver ===<br />
<br />
You can register your key with a public PGP key server, so that others can retrieve your key without having to contact you directly:<br />
<br />
$ gpg --send-keys ''<key-id>''<br />
<br />
To find out details of a key on the keyserver, without importing it, do:<br />
<br />
$ gpg --search-keys ''<key-id>''<br />
<br />
To import a key from a key server:<br />
<br />
$ gpg --recv-keys ''<key-id>''<br />
<br />
{{Warning|Anyone can send keys to a keyserver, so you should not trust that the key you download actually belongs to the individual listed. You should verify the authenticity of the retrieved public key by comparing its fingerprint with one that the owner published on an independent source, such as their own blog or website, or contacting them by email, over the phone or in person. Using multiple authentication sources will increase the level of trust you can give to the downloaded key. See [[Wikipedia:Public key fingerprint]] for more information.}}<br />
<br />
{{Tip|<br />
* Adding {{ic|keyserver-options auto-key-retrieve}} to {{ic|gpg.conf}} will automatically fetch keys from the key server as needed.<br />
* An alternative key server is {{ic|pool.sks-keyservers.net}} and can be specified with {{ic|keyserver}} in {{ic|dirmngr.conf}}.; see also [[wikipedia:Key server (cryptographic)#Keyserver examples]].<br />
* You can connect to the keyserver over [[Tor]] using {{ic|--use-tor}}. {{ic|hkp://jijrk5u4osbsr34t5.onion}} is the onion address for the sks-keyservers pool. [https://gnupg.org/blog/20151224-gnupg-in-november-and-december.html See this GnuPG blog post] for more information.<br />
* You can connect to a keyserver using a proxy by setting the {{ic|http_proxy}} environment variable and setting {{ic|honor-http-proxy}} in {{ic|dirmngr.conf}}. Alternatively, set {{ic|http-proxy ''host[:port]''}} in {{ic|dirmngr.conf}}, overriding the {{ic|http_proxy}} environment variable.}}<br />
<br />
=== Encrypt and decrypt ===<br />
<br />
You need to [[#Import a public key]] of a user before encrypting (options {{ic|--encrypt}} or {{ic|-e}}) a file or message to that recipient (options {{ic|--recipient}} or {{ic|-r}}).<br />
<br />
To encrypt a file with the name ''doc'', use:<br />
<br />
$ gpg --recipient ''<user-id>'' --encrypt ''doc''<br />
<br />
To decrypt (option {{ic|--decrypt}} or {{ic|-d}}) a file with the name ''doc.gpg'' encrypted with your public key, use:<br />
<br />
$ gpg --output ''doc'' --decrypt ''doc.gpg''<br />
<br />
''gpg'' will prompt you for your passphrase and then decrypt and write the data from ''doc.gpg'' to ''doc''. If you omit the {{ic|-o}} ({{ic|--output}}) option, ''gpg'' will write the decrypted data to stdout.<br />
<br />
{{Tip|<br />
* Add {{ic|--armor}} to encrypt a file using ASCII armor (suitable for copying and pasting a message in text format)<br />
* Use {{ic|-R ''<user-id>''}} or {{ic|--hidden-recipient ''<user-id>''}} instead of {{ic|-r}} to not put the recipient key IDs in the encrypted message. This helps to hide the receivers of the message and is a limited countermeasure against traffic analysis.<br />
* Add {{ic|--no-emit-version}} to avoid printing the version number, or add the corresponding setting to your configuration file.<br />
* You can use gnupg to encrypt your sensitive documents by using your own user-id as recipient, but only individual files at a time, though you can always tarball various files and then encrypt the tarball. See also [[Disk encryption#Available methods]] if you want to encrypt directories or a whole file-system.}}<br />
<br />
== Key maintenance ==<br />
<br />
=== Backup your private key ===<br />
<br />
To backup your private key do the following:<br />
<br />
$ gpg --export-secret-keys --armor ''<user-id>'' > ''privkey.asc''<br />
<br />
Note that ''gpg'' release 2.1 changed default behaviour so that the above command enforces a passphrase protection, even if you deliberately chose not to use one on key creation. This is because otherwise anyone who gains access to the above exported file would be able to encrypt and sign documents as if they were you ''without'' needing to know your passphrase. <br />
<br />
{{Warning|The passphrase is usually the weakest link in protecting your secret key. Place the private key in a safe place on a different system/device, such as a locked container or encrypted drive. It is the only safety you have to regain control to your keyring in case of, for example, a drive failure, theft or worse.}}<br />
<br />
To import the backup of your private key:<br />
$ gpg --allow-secret-key-import --import ''privkey.asc''<br />
<br />
=== Edit your key ===<br />
<br />
Running the {{ic|gpg --edit-key ''<user-id>''}} command will present a menu which enables you to do most of your key management related tasks.<br />
<br />
Some useful commands in the edit key sub menu:<br />
> passwd # change the passphrase<br />
> clean # compact any user ID that is no longer usable (e.g revoked or expired)<br />
> revkey # revoke a key<br />
> addkey # add a subkey to this key<br />
> expire # change the key expiration time<br />
<br />
Type {{ic|help}} in the edit key sub menu for more commands.<br />
<br />
{{Tip|If you have multiple email accounts you can add each one of them as an identity, using {{ic|adduid}} command. You can then set your favourite one as {{ic|primary}}.}}<br />
<br />
=== Exporting subkey ===<br />
<br />
If you plan to use the same key across multiple devices, you may want to strip out your master key and only keep the bare minimum encryption subkey on less secure systems.<br />
<br />
First, find out which subkey you want to export.<br />
<br />
$ gpg -K<br />
<br />
Select only that subkey to export.<br />
<br />
$ gpg -a --export-secret-subkeys [subkey id]! > /tmp/subkey.gpg<br />
<br />
{{Warning|If you forget to add the !, all of your subkeys will be exported.}}<br />
<br />
At this point you could stop, but it is most likely a good idea to change the passphrase as well. Import the key into a temporary folder. <br />
<br />
$ gpg --homedir /tmp/gpg --import /tmp/subkey.gpg<br />
$ gpg --homedir /tmp/gpg --edit-key ''<user-id>''<br />
> passwd<br />
> save<br />
$ gpg --homedir /tmp/gpg -a --export-secret-subkeys [subkey id]! > /tmp/subkey.altpass.gpg<br />
<br />
{{Note|You will get a warning that the master key was not available and the password was not changed, but that can safely be ignored as the subkey password was.}}<br />
<br />
At this point, you can now use {{ic|/tmp/subkey.altpass.gpg}} on your other devices.<br />
<br />
=== Rotating subkeys ===<br />
<br />
{{Warning|'''Never''' delete your expired or revoked subkeys unless you have a good reason. Doing so will cause you to lose the ability to decrypt files encrypted with the old subkey. Please '''only''' delete expired or revoked keys from other users to clean your keyring.}}<br />
<br />
If you have set your subkeys to expire after a set time, you can create new ones. Do this a few weeks in advance to allow others to update their keyring.<br />
<br />
{{Note|You do not need to create a new key simply because it is expired. You can extend the expiration date.}}<br />
<br />
Create new subkey (repeat for both signing and encrypting key)<br />
<br />
$ gpg --edit-key ''<user-id>''<br />
> addkey<br />
<br />
And answer the following questions it asks (see previous section for suggested settings).<br />
<br />
Save changes<br />
<br />
> save<br />
<br />
Update it to a keyserver.<br />
<br />
$ gpg --keyserver pgp.mit.edu --send-keys ''<user-id>''<br />
<br />
{{Note|Revoking expired subkeys is unnecessary and arguably bad form. If you are constantly revoking keys, it may cause others to lack confidence in you.}}<br />
<br />
== Signatures ==<br />
<br />
Signatures certify and timestamp documents. If the document is modified, verification of the signature will fail. Unlike encryption which uses public keys to encrypt a document, signatures are created with the user's private key. The recipient of a signed document then verifies the signature using the sender's public key.<br />
<br />
=== Sign a file ===<br />
<br />
To sign a file use the {{ic|--sign}} or {{ic|-s}} flag:<br />
<br />
$ gpg --output ''doc.sig'' --sign ''doc''<br />
<br />
The above also encrypts the file and stores it in binary format.<br />
<br />
=== Clearsign a file or message ===<br />
<br />
To sign a file without compressing it into binary format use:<br />
<br />
$ gpg --clearsign ''doc''<br />
<br />
This wraps the document into an ASCII-armored signature, but does not modify the document.<br />
<br />
=== Make a detached signature ===<br />
<br />
To create a separate signature file to be distributed separately from the document or file itself, use the {{ic|--detach-sig}} flag:<br />
<br />
$ gpg --output ''doc.sig'' --detach-sig ''doc''<br />
<br />
This method is often used in distributing software projects to allow users to verify that the program has not been modified by a third party.<br />
<br />
=== Verify a signature ===<br />
<br />
To verify a signature use the {{ic|--verify}} flag:<br />
<br />
$ gpg --verify ''doc.sig''<br />
<br />
where {{ic|''doc.sig''}} is the signature you wish to verify.<br />
<br />
To verify and decrypt a file at the same time, use the {{ic|--decrypt}} flag as you normally would in decrypting a file.<br />
<br />
If you are verifying a detached signature, both the file and the signature must be present when verifying. For example, to verify Arch Linux's latest iso you would do:<br />
<br />
$ gpg --verify ''archlinux-<version>-dual.iso.sig''<br />
<br />
where {{ic|''archlinux-<version>-dual.iso''}} must be located in the same directory.<br />
<br />
== gpg-agent ==<br />
<br />
''gpg-agent'' is mostly used as daemon to request and cache the password for the keychain. This is useful if GnuPG is used from an external program like a mail client.<br />
<br />
Starting with GnuPG 2.1.0 the use of ''gpg-agent'' is required. ''gpg-agent'' is started on-demand by the GnuPG tools, so there is usually no reason to start it manually.<br />
<br />
=== Configuration ===<br />
<br />
gpg-agent can be configured via {{ic|~/.gnupg/gpg-agent.conf}} file. The configuration options are listed in {{ic|man gpg-agent}}. For example you can change cache ttl for unused keys:<br />
<br />
{{hc|~/.gnupg/gpg-agent.conf|<br />
default-cache-ttl 3600<br />
}}<br />
<br />
{{Tip|To cache your passphrase for the whole session, please run the following command:<br />
$ /usr/lib/gnupg/gpg-preset-passphrase --preset XXXXXX<br />
<br />
where XXXX is the keygrip. You can get its value when running {{ic|gpg --with-keygrip -K}}. Passphrase will be stored until {{ic|gpg-agent}} is restarted. If you set up {{ic|default-cache-ttl}} value, it will take precedence.<br />
}}<br />
<br />
=== Reload the agent ===<br />
<br />
After changing the configuration, reload the agent using ''gpg-connect-agent'':<br />
<br />
$ gpg-connect-agent reloadagent /bye<br />
<br />
The command should print {{ic|OK}}.<br />
<br />
=== pinentry ===<br />
<br />
Finally, the agent needs to know how to ask the user for the password. This can be set in the gpg-agent configuration file.<br />
<br />
The default uses a gtk dialog. There are other options - see {{ic|info pinentry}}. To change the dialog implementation set {{ic|pinentry-program}} configuration option:<br />
{{hc|~/.gnupg/gpg-agent.conf|<br />
<br />
# PIN entry program<br />
# pinentry-program /usr/bin/pinentry-curses<br />
# pinentry-program /usr/bin/pinentry-qt<br />
# pinentry-program /usr/bin/pinentry-kwallet<br />
<br />
pinentry-program /usr/bin/pinentry-gtk-2<br />
}}<br />
<br />
{{Tip|For using {{ic|/usr/bin/pinentry-kwallet}} you have to install the {{Pkg|kwalletcli}} package.}}<br />
<br />
After making this change, reload the gpg-agent.<br />
<br />
=== Start gpg-agent with systemd user ===<br />
<br />
It is possible to use the [[Systemd/User]] facilities to start the agent.<br />
<br />
Create a systemd unit file:<br />
<br />
{{hc|~/.config/systemd/user/gpg-agent.service|2=<br />
[Unit]<br />
Description=GnuPG private key agent<br />
IgnoreOnIsolate=true<br />
<br />
[Service]<br />
Type=forking<br />
ExecStart=/usr/bin/gpg-agent --daemon<br />
Restart=on-abort<br />
<br />
[Install]<br />
WantedBy=default.target<br />
}}<br />
<br />
{{Note|If you use non-default value for the [[#Directory location|GNUPGHOME]] environment variable, you need to pass it to the service. See [[systemd/User#Environment variables]] for details.}}<br />
<br />
=== Unattended passphrase ===<br />
<br />
Starting with GnuPG 2.1.0 the use of gpg-agent and pinentry is required, which may break backwards compatibility for passphrases piped in from STDIN using the {{ic|--passphrase-fd 0}} commandline option. In order to have the same type of functionality as the older releases two things must be done:<br />
<br />
First, edit the gpg-agent configuration to allow ''loopback'' pinentry mode:<br />
<br />
{{hc|1=~/.gnupg/gpg-agent.conf|2=<br />
allow-loopback-pinentry<br />
}}<br />
<br />
Restart the gpg-agent process if it is running to let the change take effect.<br />
<br />
Second, either the application needs to be updated to include a commandline parameter to use loopback mode like so:<br />
<br />
$ gpg --pinentry-mode loopback ...<br />
<br />
...or if this is not possible, add the option to the configuration:<br />
<br />
{{hc|1=~/.gnupg/gpg.conf|2=<br />
pinentry-mode loopback<br />
}}<br />
<br />
{{Note|The upstream author indicates setting {{ic|pinentry-mode loopback}} in {{ic|gpg.conf}} may break other usage, using the commandline option should be preferred if at all possible. [https://bugs.g10code.com/gnupg/issue1772]}}<br />
<br />
=== SSH agent ===<br />
<br />
''gpg-agent'' has OpenSSH agent emulation. If you already use the GnuPG suite, you might consider using its agent to also cache your SSH keys. Additionally, some users may prefer the PIN entry dialog GnuPG agent provides as part of its passphrase management.<br />
<br />
To start using GnuPG agent for your SSH keys, enable SSH support in the {{ic|~/.gnupg/gpg-agent.conf}} file:<br />
<br />
{{hc|~/.gnupg/gpg-agent.conf|<br />
enable-ssh-support<br />
}}<br />
<br />
Next, make sure that ''gpg-agent'' is always started. Use either the [[#Start gpg-agent with systemd user|systemd user service]] or add the following to your {{ic|.bashrc}} file:<br />
<br />
{{hc|~/.bashrc|<nowiki><br />
# Start the gpg-agent if not already running<br />
if ! pgrep -x -u "${USER}" gpg-agent >/dev/null 2>&1; then<br />
gpg-connect-agent /bye >/dev/null 2>&1<br />
fi<br />
</nowiki>}}<br />
<br />
Then set {{ic|SSH_AUTH_SOCK}} so that SSH will use ''gpg-agent'' instead of ''ssh-agent'':<br />
<br />
{{hc|~/.bashrc|<nowiki><br />
# Set SSH to use gpg-agent<br />
unset SSH_AGENT_PID<br />
if [ "${gnupg_SSH_AUTH_SOCK_by:-0}" -ne $$ ]; then<br />
export SSH_AUTH_SOCK="/run/user/$UID/gnupg/S.gpg-agent.ssh"<br />
fi<br />
</nowiki>}}<br />
<br />
{{Note|If you use non-default [[#Directory location|GnuPG home directory]], run {{ic|gpgconf --create-socketdir}} to create a socket directory under {{ic|/run/user/$UID/gnupg/}}. Otherwise the socket will be placed in the GnuPG home directory.}}<br />
<br />
Also set the GPG TTY and refresh the TTY in case user has switched into an X session. Example:<br />
<br />
{{Expansion|Not clear why this is necessary (even tha man page does not explain it).}}<br />
<br />
{{hc|~/.bashrc|<nowiki><br />
# Set GPG TTY<br />
export GPG_TTY=$(tty)<br />
<br />
# Refresh gpg-agent tty in case user switches into an X session<br />
gpg-connect-agent updatestartuptty /bye >/dev/null<br />
</nowiki>}}<br />
<br />
Here is simpler but working ~/.bashrc configuration:<br />
<br />
{{hc|~/.bashrc|<nowiki><br />
# Update TTY of running gpg-agent or start it if needed<br />
gpg-connect-agent updatestartuptty /bye >/dev/null 2>&1<br />
# Export socket path for ssh-agent emulation<br />
export SSH_AUTH_SOCK="/run/user/$UID/gnupg/S.gpg-agent.ssh"<br />
</nowiki>}}<br />
<br />
Once ''gpg-agent'' is running you can use ''ssh-add'' to approve keys, following the same steps as for [[SSH keys#ssh-agent|ssh-agent]]. The list of approved keys is stored in the {{ic|~/.gnupg/sshcontrol}} file. Once your key is approved, you will get a ''pinentry'' dialog every time your passphrase is needed. You can control passphrase caching in the {{ic|~/.gnupg/gpg-agent.conf}} file. The following example would have ''gpg-agent'' cache your keys for 3 hours:<br />
<br />
{{hc|~/.gnupg/gpg-agent.conf|<br />
default-cache-ttl-ssh 10800<br />
}}<br />
<br />
== Smartcards ==<br />
<br />
GnuPG uses ''scdaemon'' as an interface to your smartcard reader, please refer to the [[man page]] for details.<br />
<br />
=== GnuPG only setups ===<br />
<br />
{{Note| To allow scdaemon direct access to USB smarcard readers the optional dependency {{Pkg|libusb-compat}} have to be installed}}<br />
<br />
If you do not plan to use other cards but those based on GnuPG, you should check the {{Ic|reader-port}} parameter in {{ic|~/.gnupg/scdaemon.conf}}. The value '0' refers to the first available serial port reader and a value of '32768' (default) refers to the first USB reader.<br />
<br />
=== GnuPG with PSCD-Lite ===<br />
<br />
{{Note|{{Pkg|pcsclite}} and {{Pkg|ccid}} have to be installed, and the contained [[systemd#Using units|systemd]] service {{ic|pcscd.service}} has to be running, or the socket {{ic|pscd.socket}} has to be listening.}}<br />
<br />
PSCD-Lite is a daemon which handles access to smartcard (SCard API). If GnuPG's scdaemon fails to connect the smartcard directly (e.g. by using its integrated CCID support), it will fallback and try to find a smartcard using the PSCD-Lite driver.<br />
<br />
==== Always use PSCD-Light ====<br />
<br />
If you are using any smartcard with an opensc driver (e.g.: ID cards from some countries) you should pay some attention to GnuPG configuration. Out of the box you might receive a message like this when using {{Ic|gpg --card-status}}<br />
<br />
gpg: selecting openpgp failed: ec=6.108<br />
<br />
By default, scdaemon will try to connect directly to the device. This connection will fail if the reader is being used by another process. For example: the pcscd daemon used by OpenSC. To cope with this situation we should use the same underlying driver as opensc so they can work well together. In order to point scdaemon to use pcscd you should remove {{Ic|reader-port}} from {{ic|~/.gnupg/scdaemon.conf}}, specify the location to {{ic|libpcsclite.so}} library and disable ccid so we make sure that we use pcscd:<br />
<br />
{{hc|~/.gnupg/scdaemon.conf|<nowiki><br />
pcsc-driver /usr/lib/libpcsclite.so<br />
card-timeout 5<br />
disable-ccid<br />
</nowiki>}}<br />
<br />
Please check {{Ic|man scdaemon}} if you do not use OpenSC.<br />
<br />
== Tips and tricks ==<br />
<br />
=== Different algorithm ===<br />
<br />
You may want to use stronger algorithms:<br />
<br />
{{hc|~/.gnupg/gpg.conf|<br />
...<br />
<br />
personal-digest-preferences SHA512<br />
cert-digest-algo SHA512<br />
default-preference-list SHA512 SHA384 SHA256 SHA224 AES256 AES192 AES CAST5 ZLIB BZIP2 ZIP Uncompressed<br />
personal-cipher-preferences TWOFISH CAMELLIA256 AES 3DES<br />
}}<br />
<br />
In the latest version of GnuPG, the default algorithms used are SHA256 and AES, both of which are secure enough for most people. However, if you are using a version of GnuPG older than 2.1, or if you want an even higher level of security, then you should follow the above step.<br />
<br />
=== Encrypt a password ===<br />
<br />
It can be useful to encrypt some password, so it will not be written in clear on a configuration file. A good example is your email password.<br />
<br />
First create a file with your password. You '''need''' to leave '''one''' empty line after the password, otherwise gpg will return an error message when evaluating the file.<br />
<br />
Then run:<br />
<br />
$ gpg -e -a -r ''<user-id>'' ''your_password_file''<br />
<br />
{{ic|-e}} is for encrypt, {{ic|-a}} for armor (ASCII output), {{ic|-r}} for recipient user ID.<br />
<br />
You will be left with a new {{ic|''your_password_file''.asc}} file.<br />
<br />
=== Revoking a key ===<br />
<br />
{{Warning|<br />
*Anybody having access to your revocation certificate can revoke your key, rendering it useless.<br />
*Key revocation should only be performed if your key is compromised or lost, or you forget your passphrase.}}<br />
<br />
Revocation certificates are automatically generated for newly generated keys, although one can be generated manually by the user later. These are located at {{ic|~/.gnupg/openpgp-revocs.d/}}. The filename of the certificate is the fingerprint of the key it will revoke.<br />
<br />
To revoke your key, simply import the revocation certificate:<br />
<br />
$ gpg --import ''<fingerprint>''.rev<br />
<br />
Now update the keyserver:<br />
<br />
$ gpg --keyserver subkeys.pgp.net --send ''<userid>''<br />
<br />
=== Change trust model ===<br />
<br />
By default GnuPG uses the [[Wikipedia::Web of Trust|Web of Trust]] as the trust model. You can change this to [[Wikipedia::Trust on First|Trust on First]] Use by adding {{ic|1=--trust-model=tofu}} when adding a key or adding this option to your GnuPG configuration file. More details are in [https://lists.gnupg.org/pipermail/gnupg-devel/2015-October/030341.html this email to the GnuPG list].<br />
<br />
=== Hide all recipient id's ===<br />
<br />
By default the recipient's key ID is in the encrypted message. This can be removed at encryption time for a recipient by using {{ic|hidden-recipient ''<user-id>''}}. To remove it for all recipients add {{ic|throw-keyids}} to your configuration file. This helps to hide the receivers of the message and is a limited countermeasure against traffic analysis. (Using a little social engineering anyone who is able to decrypt the message can check whether one of the other recipients is the one he suspects.) On the receiving side, it may slow down the decryption process because all available secret keys must be tried (''e.g.'' with {{ic|--try-secret-key ''<user-id>''}}).<br />
<br />
=== Using caff for keysigning parties ===<br />
<br />
To allow users to validate keys on the keyservers and in their keyrings (i.e. make sure they are from whom they claim to be), PGP/GPG uses he [[Wikipedia::Web of Trust|Web of Trust]]. Keysigning parties allow users to get together in physical location to validate keys. The [[Wikipedia:Zimmermann–Sassaman key-signing protocol|Zimmermann-Sassaman]] key-signing protocol is a way of making these very effective. [http://www.cryptnet.net/fdp/crypto/keysigning_party/en/keysigning_party.html Here] you will find a how-to article.<br />
<br />
For an easier process of signing keys and sending signatures to the owners after a keysigning party, you can use the tool ''caff''. It can be installed from the AUR with the package {{AUR|caff-svn}} or bundled together with other useful tools in the package {{AUR|signing-party-svn}}{{Broken package link|{{aur-mirror|signing-party-svn}}}}.<br />
Either way, there will be a lot of dependencies installing from the AUR. Alternatively you can install them from CPAN with<br />
cpanm Any::Moose<br />
cpanm GnuPG::Interface<br />
<br />
To send the signatures to their owners you need a working [[Wikipedia:Message transfer agent|MTA]]. If you do not have already one, install [[msmtp]].<br />
<br />
== Troubleshooting ==<br />
<br />
=== Not enough random bytes available ===<br />
When generating a key, gpg can run into this error:<br />
Not enough random bytes available. Please do some other work to give the OS a chance to collect more entropy!<br />
To check the available entropy, check the kernel parameters:<br />
cat /proc/sys/kernel/random/entropy_avail<br />
A healthy Linux system with a lot of entropy available will have return close to the full 4,096 bits of entropy. If the value returned is less than 200, the system is running low on entropy. <br />
<br />
To solve it, remember you do not often need to create keys and best just do what the message suggests (e.g. create disk activity, move the mouse, edit the wiki - all will create entropy). If that does not help, check which service is using up the entropy and consider stopping it for the time. If that is no alternative, see [[Random number generation#Faster alternatives]].<br />
<br />
=== su ===<br />
<br />
When using {{Ic|pinentry}}, you must have the proper permissions of the terminal device (e.g. {{Ic|/dev/tty1}}) in use. However, with ''su'' (or ''sudo''), the ownership stays with the original user, not the new one. This means that pinentry will fail, even as root. The fix is to change the permissions of the device at some point before the use of pinentry (i.e. using gpg with an agent). If doing gpg as root, simply change the ownership to root right before using gpg:<br />
<br />
chown root /dev/ttyN # where N is the current tty<br />
<br />
and then change it back after using gpg the first time. The equivalent is likely to be true with {{Ic|/dev/pts/}}.<br />
<br />
{{Note|The owner of tty ''must'' match with the user for which pinentry is running. Being part of the group {{Ic|tty}} '''is not''' enough.}}<br />
<br />
=== Agent complains end of file ===<br />
<br />
The default pinentry program is pinentry-gtk-2, which needs a DBus session bus to run properly. See [[General troubleshooting#Session permissions]] for details.<br />
<br />
Alternatively, you can use {{ic|pinentry-qt}}. See [[#pinentry]].<br />
<br />
=== KGpg configuration permissions ===<br />
<br />
There have been issues with {{Pkg|kdeutils-kgpg}} being able to access the {{ic|~/.gnupg/}} options. One issue might be a result of a deprecated ''options'' file, see the [https://bugs.kde.org/show_bug.cgi?id=290221 bug] report.<br />
<br />
Another user reported that ''KGpg'' failed to start until the {{ic|~/.gnupg}} folder is set to {{ic|drwxr-xr-x}} permissions. If you require this work-around, ensure that the directory contents retain {{ic|-rw-------}} permissions! Further, report it as a bug to the [https://bugs.kde.org/buglist.cgi?quicksearch=kgpg developers].<br />
<br />
=== Conflicts between gnome-keyring and gpg-agent ===<br />
<br />
{{Accuracy|See [[#GPG_AGENT_INFO]]}}<br />
<br />
While the Gnome keyring implements a GPG agent component, as of GnuPG version 2.1, GnuPG ignores the {{ic|GPG_AGENT_INFO}} environment variable, so that Gnome keyring can no longer be used as a GPG agent.<br />
<br />
However, since version 0.9.6 the package {{Pkg|pinentry}} provides the {{Ic|pinentry-gnome3}} program. You may set the following option in your {{Ic|gpg-agent.conf}} file<br />
pinentry-program /usr/bin/pinentry-gnome3<br />
in order to make use of that pinentry program.<br />
<br />
Since version 0.9.2 all pinentry programs can be configured to optionally save a passphrase with libsecret. For example, when the user is asked for a passphrase via {{Ic|pinentry-gnome3}}, a checkbox is shown whether to save the passphrase using a password manager. Unfortunately, the package {{Pkg|pinentry}} does not have this feature enabled (see {{Bug|46059}} for the reasons). You may use {{AUR|pinentry-libsecret}} as a replacement for it, which has support for libsecret enabled.<br />
<br />
=== mutt and gpg ===<br />
<br />
To be asked for your GnuPG password only once per session as of GnuPG 2.1, see [https://bbs.archlinux.org/viewtopic.php?pid=1490821#p1490821 this forum thread].<br />
<br />
=== "Lost" keys, upgrading to gnupg version 2.1 ===<br />
<br />
When {{ic|gpg --list-keys}} fails to show keys that used to be there, and applications complain about missing or invalid keys, some keys may not have been migrated to the new format.<br />
<br />
Please read [http://jo-ke.name/wp/?p=111 GnuPG invalid packet workaround]. Basically, it says that there is a bug with keys in the old {{ic|pubring.gpg}} and {{ic|secring.gpg}} files, which have now been superseded by the new {{ic|pubring.kbx}} file and the {{ic|private-keys-v1.d/}} subdirectory and files. Your missing keys can be recovered with the following commnads:<br />
<br />
$ cd<br />
$ cp -r .gnupg gnupgOLD<br />
$ gpg --export-ownertrust > otrust.txt<br />
$ gpg --import .gnupg/pubring.gpg<br />
$ gpg --import-ownertrust otrust.txt<br />
$ gpg --list-keys<br />
<br />
=== gpg hanged for all keyservers (when trying to receive keys) ===<br />
<br />
If gpg hanged with a certain keyserver when trying to receive keys, you might need to kill dirmngr in order to get access to other keyservers which are actually working, otherwise it might keeping hanging for all of them.<br />
<br />
=== Smartcard not detected ===<br />
<br />
Your user might not have the permission to access the smartcard which results in a {{ic|card error}} to be thrown, even though the card is correctly set up and inserted.<br />
<br />
One possible solution is to add a new group {{ic|scard}} including the users who need access to the smartcard.<br />
<br />
Then use an [[Udev#Writing_udev_rules|udev]] rule, similar to the following:<br />
{{hc|/etc/udev/rules.d/71-gnupg-ccid.rules|<nowiki><br />
ACTION=="add", SUBSYSTEM=="usb", ENV{ID_VENDOR_ID}=="1050", ENV{ID_MODEL_ID}=="0116|0111", MODE="660", GROUP="scard"<br />
</nowiki>}}<br />
One needs to adapt VENDOR and MODEL according to the {{ic|lsusb}} output, the above example is for a YubikeyNEO.<br />
<br />
== See also ==<br />
<br />
* [https://gnupg.org/ GNU Privacy Guard Homepage]<br />
* [https://fedoraproject.org/wiki/Creating_GPG_Keys Creating GPG Keys (Fedora)]<br />
* [https://wiki.debian.org/Subkeys OpenPGP subkeys in Debian]<br />
* [http://blog.sanctum.geek.nz/series/linux-crypto/ A more comprehensive gpg Tutorial]<br />
* [https://help.riseup.net/en/security/message-security/openpgp/gpg-best-practices gpg.conf recommendations and best practices]<br />
* [https://github.com/ioerror/torbirdy/blob/master/gpg.conf Torbirdy gpg.conf]<br />
* [https://www.reddit.com/r/GPGpractice/ /r/GPGpractice - a subreddit to practice using GnuPG.]</div>Max-khttps://wiki.archlinux.org/index.php?title=GnuPG&diff=438720GnuPG2016-06-22T08:57:21Z<p>Max-k: /* SSH agent */</p>
<hr />
<div>[[Category:Encryption]]<br />
[[es:GnuPG]]<br />
[[ja:GnuPG]]<br />
[[ru:GnuPG]]<br />
[[zh-cn:GnuPG]]<br />
{{Related articles start}}<br />
{{Related|pacman/Package signing}}<br />
{{Related|Disk encryption}}<br />
{{Related|List of applications/Security#Encryption, signing, steganography}}<br />
{{Related articles end}}<br />
<br />
According to the [http://www.gnupg.org official website]:<br />
<br />
:GnuPG is a complete and free implementation of the OpenPGP standard as defined by RFC4880 (also known as PGP). GnuPG allows to encrypt and sign your data and communication, features a versatile key management system as well as access modules for all kinds of public key directories. GnuPG, also known as GPG, is a command line tool with features for easy integration with other applications. A wealth of frontend applications and libraries are available. Version 2 of GnuPG also provides support for S/MIME and Secure Shell (ssh).<br />
<br />
== Installation ==<br />
<br />
[[Install]] the {{Pkg|gnupg}} package.<br />
<br />
This will also install {{Pkg|pinentry}}, a collection of simple PIN or passphrase entry dialogs which GnuPG uses for passphrase entry. Which ''pinentry'' dialog is used is determined by the symbolic link {{ic|/usr/bin/pinentry}}, which by default points to {{ic|/usr/bin/pinentry-gtk-2}}.<br />
<br />
If you want to use a graphical frontend or program that integrates with GnuPG, see [[List of applications/Security#Encryption, signing, steganography]].<br />
<br />
== Configuration ==<br />
<br />
=== Directory location ===<br />
{{ic|$GNUPGHOME}} is used by GnuPG to point to the directory where its configuration files are stored. By default {{ic|$GNUPGHOME}} is not set and your {{ic|$HOME}} is used instead; thus, you will find a {{ic|~/.gnupg}} directory right after installation. <br />
<br />
To change the default location, either run gpg this way {{ic|$ gpg --homedir ''path/to/file''}} or set {{ic|GNUPGHOME}} in one of your regular [[startup files]].<br />
<br />
=== Configuration files ===<br />
<br />
The default configuration files are {{ic|~/.gnupg/gpg.conf}} and {{ic|~/.gnupg/dirmngr.conf}}. <br />
<br />
By default, the gnupg directory has its [[permissions]] set to {{ic|700}} and the files it contains have their permissions set to {{ic|600}}. Only the owner of the directory has permission to read, write, and access the files. This is for security purposes and should not be changed. In case this directory or any file inside it does not follow this security measure, you will get warnings about unsafe file and home directory permissions.<br />
<br />
Append to these files any long options you want. Do not write the two dashes, but simply the name of the option and required arguments. You will find skeleton files in {{ic|/usr/share/gnupg}}. These files are copied to {{ic|~/.gnupg}} the first time gpg is run if they do not exist there. Other examples are found in [[#See also]].<br />
<br />
Additionally, [[pacman]] uses a different set of configuration files for package signature verification. See [[Pacman/Package signing]] for details.<br />
<br />
=== Default options for new users ===<br />
<br />
If you want to setup some default options for new users, put configuration files in {{ic|/etc/skel/.gnupg/}}. When the new user is added in system, files from here will be copied to its GnuPG home directory. There is also a simple script called ''addgnupghome'' which you can use to create new GnuPG home directories for existing users:<br />
<br />
# addgnupghome user1 user2<br />
<br />
This will add the respective {{ic|/home/user1/.gnupg}} and {{ic|/home/user2/.gnupg}} and copy the files from the skeleton directory to it. Users with existing GnuPG home directory are simply skipped.<br />
<br />
== Usage ==<br />
<br />
{{Note|Whenever a ''{{ic|<user-id>}}'' is required in a command, it can be specified with your key ID, fingerprint, a part of your name or email address, etc. GnuPG is flexible on this.<br />
}}<br />
<br />
=== Create key pair ===<br />
<br />
Generate a key pair by typing in a terminal:<br />
<br />
$ gpg --full-gen-key<br />
<br />
{{Tip|Use the {{ic|--expert}} option for getting alternative ciphers like [[wikipedia:Elliptic_curve_cryptography|ECC]].}}<br />
<br />
The command will prompt for answers to several questions. For general use most people will want: <br />
<br />
* the RSA (sign only) and a RSA (encrypt only) key.<br />
* a keysize of the default value (2048). A larger keysize of 4096 "gives us almost nothing, while costing us quite a lot"[https://www.gnupg.org/faq/gnupg-faq.html#no_default_of_rsa4096].<br />
* an expiration date. A period of a year is good enough for the average user. This way even if access is lost to the keyring, it will allow others to know that it is no longer valid. Later, if necessary, the expiration date can be extended without having to re-issue a new key.<br />
* your name and email address. You can add multiple identities to the same key later (''e.g.'', if you have multiple email addresses you want to associate with this key).<br />
* ''no'' optional comment. Since the semantics of the comment field are [https://lists.gnupg.org/pipermail/gnupg-devel/2015-July/030150.html not well-defined], it has limited value for identification.<br />
* [[Security#Choosing_secure_passwords|a secure passphrase]].<br />
<br />
{{Note|The name and email address you enter here will be seen by anybody who imports your key.}}<br />
<br />
=== List keys ===<br />
<br />
To list keys in your public key ring:<br />
<br />
$ gpg --list-keys<br />
<br />
To list keys in your secret key ring:<br />
<br />
$ gpg --list-secret-keys<br />
<br />
=== Export your public key ===<br />
<br />
gpg's main usage is to ensure confidentiality of exchanged messages via public-key cryptography. With it each user distributes the public key of their keyring, which can be be used by others to encrypt messages to the user. The private key must ''always'' be kept private, otherwise confidentiality is broken. See [[w:Public-key cryptography]] for examples about the message exchange. <br />
<br />
So, in order for others to send encrypted messages to you, they need your public key. <br />
<br />
To generate an ASCII version of your public key (''e.g.'' to distribute it by e-mail):<br />
<br />
$ gpg --output ''public.key'' --armor --export ''<user-id>'' <br />
<br />
Alternatively, or in addition, you can [[#Use a keyserver]] to share your key. <br />
<br />
{{Tip|Add {{ic|--no-emit-version}} to avoid printing the version number, or add the corresponding setting to your configuration file.}}<br />
<br />
=== Import a public key ===<br />
<br />
In order to encrypt messages to others, as well as verify their signatures, you need their public key. To import a public key with file name {{ic|''public.key''}} to your public key ring:<br />
<br />
$ gpg --import ''public.key''<br />
<br />
Alternatively, [[#Use a keyserver]] to find a public key.<br />
<br />
=== Use a keyserver ===<br />
<br />
You can register your key with a public PGP key server, so that others can retrieve your key without having to contact you directly:<br />
<br />
$ gpg --send-keys ''<key-id>''<br />
<br />
To find out details of a key on the keyserver, without importing it, do:<br />
<br />
$ gpg --search-keys ''<key-id>''<br />
<br />
To import a key from a key server:<br />
<br />
$ gpg --recv-keys ''<key-id>''<br />
<br />
{{Warning|Anyone can send keys to a keyserver, so you should not trust that the key you download actually belongs to the individual listed. You should verify the authenticity of the retrieved public key by comparing its fingerprint with one that the owner published on an independent source, such as their own blog or website, or contacting them by email, over the phone or in person. Using multiple authentication sources will increase the level of trust you can give to the downloaded key. See [[Wikipedia:Public key fingerprint]] for more information.}}<br />
<br />
{{Tip|<br />
* Adding {{ic|keyserver-options auto-key-retrieve}} to {{ic|gpg.conf}} will automatically fetch keys from the key server as needed.<br />
* An alternative key server is {{ic|pool.sks-keyservers.net}} and can be specified with {{ic|keyserver}} in {{ic|dirmngr.conf}}.; see also [[wikipedia:Key server (cryptographic)#Keyserver examples]].<br />
* You can connect to the keyserver over [[Tor]] using {{ic|--use-tor}}. {{ic|hkp://jijrk5u4osbsr34t5.onion}} is the onion address for the sks-keyservers pool. [https://gnupg.org/blog/20151224-gnupg-in-november-and-december.html See this GnuPG blog post] for more information.<br />
* You can connect to a keyserver using a proxy by setting the {{ic|http_proxy}} environment variable and setting {{ic|honor-http-proxy}} in {{ic|dirmngr.conf}}. Alternatively, set {{ic|http-proxy ''host[:port]''}} in {{ic|dirmngr.conf}}, overriding the {{ic|http_proxy}} environment variable.}}<br />
<br />
=== Encrypt and decrypt ===<br />
<br />
You need to [[#Import a public key]] of a user before encrypting (options {{ic|--encrypt}} or {{ic|-e}}) a file or message to that recipient (options {{ic|--recipient}} or {{ic|-r}}).<br />
<br />
To encrypt a file with the name ''doc'', use:<br />
<br />
$ gpg --recipient ''<user-id>'' --encrypt ''doc''<br />
<br />
To decrypt (option {{ic|--decrypt}} or {{ic|-d}}) a file with the name ''doc.gpg'' encrypted with your public key, use:<br />
<br />
$ gpg --output ''doc'' --decrypt ''doc.gpg''<br />
<br />
''gpg'' will prompt you for your passphrase and then decrypt and write the data from ''doc.gpg'' to ''doc''. If you omit the {{ic|-o}} ({{ic|--output}}) option, ''gpg'' will write the decrypted data to stdout.<br />
<br />
{{Tip|<br />
* Add {{ic|--armor}} to encrypt a file using ASCII armor (suitable for copying and pasting a message in text format)<br />
* Use {{ic|-R ''<user-id>''}} or {{ic|--hidden-recipient ''<user-id>''}} instead of {{ic|-r}} to not put the recipient key IDs in the encrypted message. This helps to hide the receivers of the message and is a limited countermeasure against traffic analysis.<br />
* Add {{ic|--no-emit-version}} to avoid printing the version number, or add the corresponding setting to your configuration file.<br />
* You can use gnupg to encrypt your sensitive documents by using your own user-id as recipient, but only individual files at a time, though you can always tarball various files and then encrypt the tarball. See also [[Disk encryption#Available methods]] if you want to encrypt directories or a whole file-system.}}<br />
<br />
== Key maintenance ==<br />
<br />
=== Backup your private key ===<br />
<br />
To backup your private key do the following:<br />
<br />
$ gpg --export-secret-keys --armor ''<user-id>'' > ''privkey.asc''<br />
<br />
Note that ''gpg'' release 2.1 changed default behaviour so that the above command enforces a passphrase protection, even if you deliberately chose not to use one on key creation. This is because otherwise anyone who gains access to the above exported file would be able to encrypt and sign documents as if they were you ''without'' needing to know your passphrase. <br />
<br />
{{Warning|The passphrase is usually the weakest link in protecting your secret key. Place the private key in a safe place on a different system/device, such as a locked container or encrypted drive. It is the only safety you have to regain control to your keyring in case of, for example, a drive failure, theft or worse.}}<br />
<br />
To import the backup of your private key:<br />
$ gpg --allow-secret-key-import --import ''privkey.asc''<br />
<br />
=== Edit your key ===<br />
<br />
Running the {{ic|gpg --edit-key ''<user-id>''}} command will present a menu which enables you to do most of your key management related tasks.<br />
<br />
Some useful commands in the edit key sub menu:<br />
> passwd # change the passphrase<br />
> clean # compact any user ID that is no longer usable (e.g revoked or expired)<br />
> revkey # revoke a key<br />
> addkey # add a subkey to this key<br />
> expire # change the key expiration time<br />
<br />
Type {{ic|help}} in the edit key sub menu for more commands.<br />
<br />
{{Tip|If you have multiple email accounts you can add each one of them as an identity, using {{ic|adduid}} command. You can then set your favourite one as {{ic|primary}}.}}<br />
<br />
=== Exporting subkey ===<br />
<br />
If you plan to use the same key across multiple devices, you may want to strip out your master key and only keep the bare minimum encryption subkey on less secure systems.<br />
<br />
First, find out which subkey you want to export.<br />
<br />
$ gpg -K<br />
<br />
Select only that subkey to export.<br />
<br />
$ gpg -a --export-secret-subkeys [subkey id]! > /tmp/subkey.gpg<br />
<br />
{{Warning|If you forget to add the !, all of your subkeys will be exported.}}<br />
<br />
At this point you could stop, but it is most likely a good idea to change the passphrase as well. Import the key into a temporary folder. <br />
<br />
$ gpg --homedir /tmp/gpg --import /tmp/subkey.gpg<br />
$ gpg --homedir /tmp/gpg --edit-key ''<user-id>''<br />
> passwd<br />
> save<br />
$ gpg --homedir /tmp/gpg -a --export-secret-subkeys [subkey id]! > /tmp/subkey.altpass.gpg<br />
<br />
{{Note|You will get a warning that the master key was not available and the password was not changed, but that can safely be ignored as the subkey password was.}}<br />
<br />
At this point, you can now use {{ic|/tmp/subkey.altpass.gpg}} on your other devices.<br />
<br />
=== Rotating subkeys ===<br />
<br />
{{Warning|'''Never''' delete your expired or revoked subkeys unless you have a good reason. Doing so will cause you to lose the ability to decrypt files encrypted with the old subkey. Please '''only''' delete expired or revoked keys from other users to clean your keyring.}}<br />
<br />
If you have set your subkeys to expire after a set time, you can create new ones. Do this a few weeks in advance to allow others to update their keyring.<br />
<br />
{{Note|You do not need to create a new key simply because it is expired. You can extend the expiration date.}}<br />
<br />
Create new subkey (repeat for both signing and encrypting key)<br />
<br />
$ gpg --edit-key ''<user-id>''<br />
> addkey<br />
<br />
And answer the following questions it asks (see previous section for suggested settings).<br />
<br />
Save changes<br />
<br />
> save<br />
<br />
Update it to a keyserver.<br />
<br />
$ gpg --keyserver pgp.mit.edu --send-keys ''<user-id>''<br />
<br />
{{Note|Revoking expired subkeys is unnecessary and arguably bad form. If you are constantly revoking keys, it may cause others to lack confidence in you.}}<br />
<br />
== Signatures ==<br />
<br />
Signatures certify and timestamp documents. If the document is modified, verification of the signature will fail. Unlike encryption which uses public keys to encrypt a document, signatures are created with the user's private key. The recipient of a signed document then verifies the signature using the sender's public key.<br />
<br />
=== Sign a file ===<br />
<br />
To sign a file use the {{ic|--sign}} or {{ic|-s}} flag:<br />
<br />
$ gpg --output ''doc.sig'' --sign ''doc''<br />
<br />
The above also encrypts the file and stores it in binary format.<br />
<br />
=== Clearsign a file or message ===<br />
<br />
To sign a file without compressing it into binary format use:<br />
<br />
$ gpg --clearsign ''doc''<br />
<br />
This wraps the document into an ASCII-armored signature, but does not modify the document.<br />
<br />
=== Make a detached signature ===<br />
<br />
To create a separate signature file to be distributed separately from the document or file itself, use the {{ic|--detach-sig}} flag:<br />
<br />
$ gpg --output ''doc.sig'' --detach-sig ''doc''<br />
<br />
This method is often used in distributing software projects to allow users to verify that the program has not been modified by a third party.<br />
<br />
=== Verify a signature ===<br />
<br />
To verify a signature use the {{ic|--verify}} flag:<br />
<br />
$ gpg --verify ''doc.sig''<br />
<br />
where {{ic|''doc.sig''}} is the signature you wish to verify.<br />
<br />
To verify and decrypt a file at the same time, use the {{ic|--decrypt}} flag as you normally would in decrypting a file.<br />
<br />
If you are verifying a detached signature, both the file and the signature must be present when verifying. For example, to verify Arch Linux's latest iso you would do:<br />
<br />
$ gpg --verify ''archlinux-<version>-dual.iso.sig''<br />
<br />
where {{ic|''archlinux-<version>-dual.iso''}} must be located in the same directory.<br />
<br />
== gpg-agent ==<br />
<br />
''gpg-agent'' is mostly used as daemon to request and cache the password for the keychain. This is useful if GnuPG is used from an external program like a mail client.<br />
<br />
Starting with GnuPG 2.1.0 the use of ''gpg-agent'' is required. ''gpg-agent'' is started on-demand by the GnuPG tools, so there is usually no reason to start it manually.<br />
<br />
=== Configuration ===<br />
<br />
gpg-agent can be configured via {{ic|~/.gnupg/gpg-agent.conf}} file. The configuration options are listed in {{ic|man gpg-agent}}. For example you can change cache ttl for unused keys:<br />
<br />
{{hc|~/.gnupg/gpg-agent.conf|<br />
default-cache-ttl 3600<br />
}}<br />
<br />
{{Tip|To cache your passphrase for the whole session, please run the following command:<br />
$ /usr/lib/gnupg/gpg-preset-passphrase --preset XXXXXX<br />
<br />
where XXXX is the keygrip. You can get its value when running {{ic|gpg --with-keygrip -K}}. Passphrase will be stored until {{ic|gpg-agent}} is restarted. If you set up {{ic|default-cache-ttl}} value, it will take precedence.<br />
}}<br />
<br />
=== Reload the agent ===<br />
<br />
After changing the configuration, reload the agent using ''gpg-connect-agent'':<br />
<br />
$ gpg-connect-agent reloadagent /bye<br />
<br />
The command should print {{ic|OK}}.<br />
<br />
=== pinentry ===<br />
<br />
Finally, the agent needs to know how to ask the user for the password. This can be set in the gpg-agent configuration file.<br />
<br />
The default uses a gtk dialog. There are other options - see {{ic|info pinentry}}. To change the dialog implementation set {{ic|pinentry-program}} configuration option:<br />
{{hc|~/.gnupg/gpg-agent.conf|<br />
<br />
# PIN entry program<br />
# pinentry-program /usr/bin/pinentry-curses<br />
# pinentry-program /usr/bin/pinentry-qt<br />
# pinentry-program /usr/bin/pinentry-kwallet<br />
<br />
pinentry-program /usr/bin/pinentry-gtk-2<br />
}}<br />
<br />
{{Tip|For using {{ic|/usr/bin/pinentry-kwallet}} you have to install the {{Pkg|kwalletcli}} package.}}<br />
<br />
After making this change, reload the gpg-agent.<br />
<br />
=== Start gpg-agent with systemd user ===<br />
<br />
It is possible to use the [[Systemd/User]] facilities to start the agent.<br />
<br />
Create a systemd unit file:<br />
<br />
{{hc|~/.config/systemd/user/gpg-agent.service|2=<br />
[Unit]<br />
Description=GnuPG private key agent<br />
IgnoreOnIsolate=true<br />
<br />
[Service]<br />
Type=forking<br />
ExecStart=/usr/bin/gpg-agent --daemon<br />
Restart=on-abort<br />
<br />
[Install]<br />
WantedBy=default.target<br />
}}<br />
<br />
{{Note|If you use non-default value for the [[#GNUPGHOME]] environment variable, you need to pass it to the service. See [[systemd/User#Environment variables]] for details.}}<br />
<br />
=== Unattended passphrase ===<br />
<br />
Starting with GnuPG 2.1.0 the use of gpg-agent and pinentry is required, which may break backwards compatibility for passphrases piped in from STDIN using the {{ic|--passphrase-fd 0}} commandline option. In order to have the same type of functionality as the older releases two things must be done:<br />
<br />
First, edit the gpg-agent configuration to allow ''loopback'' pinentry mode:<br />
<br />
{{hc|1=~/.gnupg/gpg-agent.conf|2=<br />
allow-loopback-pinentry<br />
}}<br />
<br />
Restart the gpg-agent process if it is running to let the change take effect.<br />
<br />
Second, either the application needs to be updated to include a commandline parameter to use loopback mode like so:<br />
<br />
$ gpg --pinentry-mode loopback ...<br />
<br />
...or if this is not possible, add the option to the configuration:<br />
<br />
{{hc|1=~/.gnupg/gpg.conf|2=<br />
pinentry-mode loopback<br />
}}<br />
<br />
{{Note|The upstream author indicates setting {{ic|pinentry-mode loopback}} in {{ic|gpg.conf}} may break other usage, using the commandline option should be preferred if at all possible. [https://bugs.g10code.com/gnupg/issue1772]}}<br />
<br />
=== SSH agent ===<br />
<br />
''gpg-agent'' has OpenSSH agent emulation. If you already use the GnuPG suite, you might consider using its agent to also cache your SSH keys. Additionally, some users may prefer the PIN entry dialog GnuPG agent provides as part of its passphrase management.<br />
<br />
To start using GnuPG agent for your SSH keys, enable SSH support in the {{ic|~/.gnupg/gpg-agent.conf}} file:<br />
<br />
{{hc|~/.gnupg/gpg-agent.conf|<br />
enable-ssh-support<br />
}}<br />
<br />
Next, make sure that ''gpg-agent'' is always started. Use either the [[#Start gpg-agent with systemd user|systemd user service]] or add the following to your {{ic|.bashrc}} file:<br />
<br />
{{hc|~/.bashrc|<nowiki><br />
# Start the gpg-agent if not already running<br />
if ! pgrep -x -u "${USER}" gpg-agent >/dev/null 2>&1; then<br />
gpg-connect-agent /bye >/dev/null 2>&1<br />
fi<br />
</nowiki>}}<br />
<br />
Then set {{ic|SSH_AUTH_SOCK}} so that SSH will use ''gpg-agent'' instead of ''ssh-agent'':<br />
<br />
{{hc|~/.bashrc|<nowiki><br />
# Set SSH to use gpg-agent<br />
unset SSH_AGENT_PID<br />
if [ "${gnupg_SSH_AUTH_SOCK_by:-0}" -ne $$ ]; then<br />
export SSH_AUTH_SOCK="/run/user/$(id -u)/gnupg/S.gpg-agent.ssh"<br />
fi<br />
</nowiki>}}<br />
<br />
Also set the GPG TTY and refresh the TTY in case user has switched into an X session. Example:<br />
<br />
{{Expansion|Not clear why this is necessary (even tha man page does not explain it).}}<br />
<br />
{{hc|~/.bashrc|<nowiki><br />
# Set GPG TTY<br />
export GPG_TTY=$(tty)<br />
<br />
# Refresh gpg-agent tty in case user switches into an X session<br />
gpg-connect-agent updatestartuptty /bye >/dev/null<br />
</nowiki>}}<br />
<br />
Once ''gpg-agent'' is running you can use ''ssh-add'' to approve keys, following the same steps as for [[SSH keys#ssh-agent|ssh-agent]]. The list of approved keys is stored in the {{ic|~/.gnupg/sshcontrol}} file. Once your key is approved, you will get a ''pinentry'' dialog every time your passphrase is needed. You can control passphrase caching in the {{ic|~/.gnupg/gpg-agent.conf}} file. The following example would have ''gpg-agent'' cache your keys for 3 hours:<br />
<br />
{{hc|~/.gnupg/gpg-agent.conf|<br />
default-cache-ttl-ssh 10800<br />
}}<br />
<br />
== Smartcards ==<br />
<br />
GnuPG uses ''scdaemon'' as an interface to your smartcard reader, please refer to the [[man page]] for details.<br />
<br />
=== GnuPG only setups ===<br />
<br />
{{Note| To allow scdaemon direct access to USB smarcard readers the optional dependency {{Pkg|libusb-compat}} have to be installed}}<br />
<br />
If you do not plan to use other cards but those based on GnuPG, you should check the {{Ic|reader-port}} parameter in {{ic|~/.gnupg/scdaemon.conf}}. The value '0' refers to the first available serial port reader and a value of '32768' (default) refers to the first USB reader.<br />
<br />
=== GnuPG with PSCD-Lite ===<br />
<br />
{{Note|{{Pkg|pcsclite}} and {{Pkg|ccid}} have to be installed, and the contained [[systemd#Using units|systemd]] service {{ic|pcscd.service}} has to be running, or the socket {{ic|pscd.socket}} has to be listening.}}<br />
<br />
PSCD-Lite is a daemon which handles access to smartcard (SCard API). If GnuPG's scdaemon fails to connect the smartcard directly (e.g. by using its integrated CCID support), it will fallback and try to find a smartcard using the PSCD-Lite driver.<br />
<br />
==== Always use PSCD-Light ====<br />
<br />
If you are using any smartcard with an opensc driver (e.g.: ID cards from some countries) you should pay some attention to GnuPG configuration. Out of the box you might receive a message like this when using {{Ic|gpg --card-status}}<br />
<br />
gpg: selecting openpgp failed: ec=6.108<br />
<br />
By default, scdaemon will try to connect directly to the device. This connection will fail if the reader is being used by another process. For example: the pcscd daemon used by OpenSC. To cope with this situation we should use the same underlying driver as opensc so they can work well together. In order to point scdaemon to use pcscd you should remove {{Ic|reader-port}} from {{ic|~/.gnupg/scdaemon.conf}}, specify the location to {{ic|libpcsclite.so}} library and disable ccid so we make sure that we use pcscd:<br />
<br />
{{hc|~/.gnupg/scdaemon.conf|<nowiki><br />
pcsc-driver /usr/lib/libpcsclite.so<br />
card-timeout 5<br />
disable-ccid<br />
</nowiki>}}<br />
<br />
Please check {{Ic|man scdaemon}} if you do not use OpenSC.<br />
<br />
== Tips and tricks ==<br />
<br />
=== Different algorithm ===<br />
<br />
You may want to use stronger algorithms:<br />
<br />
{{hc|~/.gnupg/gpg.conf|<br />
...<br />
<br />
personal-digest-preferences SHA512<br />
cert-digest-algo SHA512<br />
default-preference-list SHA512 SHA384 SHA256 SHA224 AES256 AES192 AES CAST5 ZLIB BZIP2 ZIP Uncompressed<br />
personal-cipher-preferences TWOFISH CAMELLIA256 AES 3DES<br />
}}<br />
<br />
In the latest version of GnuPG, the default algorithms used are SHA256 and AES, both of which are secure enough for most people. However, if you are using a version of GnuPG older than 2.1, or if you want an even higher level of security, then you should follow the above step.<br />
<br />
=== Encrypt a password ===<br />
<br />
It can be useful to encrypt some password, so it will not be written in clear on a configuration file. A good example is your email password.<br />
<br />
First create a file with your password. You '''need''' to leave '''one''' empty line after the password, otherwise gpg will return an error message when evaluating the file.<br />
<br />
Then run:<br />
<br />
$ gpg -e -a -r ''<user-id>'' ''your_password_file''<br />
<br />
{{ic|-e}} is for encrypt, {{ic|-a}} for armor (ASCII output), {{ic|-r}} for recipient user ID.<br />
<br />
You will be left with a new {{ic|''your_password_file''.asc}} file.<br />
<br />
=== Revoking a key ===<br />
<br />
{{Warning|<br />
*Anybody having access to your revocation certificate can revoke your key, rendering it useless.<br />
*Key revocation should only be performed if your key is compromised or lost, or you forget your passphrase.}}<br />
<br />
Revocation certificates are automatically generated for newly generated keys, although one can be generated manually by the user later. These are located at {{ic|~/.gnupg/openpgp-revocs.d/}}. The filename of the certificate is the fingerprint of the key it will revoke.<br />
<br />
To revoke your key, simply import the revocation certificate:<br />
<br />
$ gpg --import ''<fingerprint>''.rev<br />
<br />
Now update the keyserver:<br />
<br />
$ gpg --keyserver subkeys.pgp.net --send ''<userid>''<br />
<br />
=== Change trust model ===<br />
<br />
By default GnuPG uses the [[Wikipedia::Web of Trust|Web of Trust]] as the trust model. You can change this to [[Wikipedia::Trust on First|Trust on First]] Use by adding {{ic|1=--trust-model=tofu}} when adding a key or adding this option to your GnuPG configuration file. More details are in [https://lists.gnupg.org/pipermail/gnupg-devel/2015-October/030341.html this email to the GnuPG list].<br />
<br />
=== Hide all recipient id's ===<br />
<br />
By default the recipient's key ID is in the encrypted message. This can be removed at encryption time for a recipient by using {{ic|hidden-recipient ''<user-id>''}}. To remove it for all recipients add {{ic|throw-keyids}} to your configuration file. This helps to hide the receivers of the message and is a limited countermeasure against traffic analysis. (Using a little social engineering anyone who is able to decrypt the message can check whether one of the other recipients is the one he suspects.) On the receiving side, it may slow down the decryption process because all available secret keys must be tried (''e.g.'' with {{ic|--try-secret-key ''<user-id>''}}).<br />
<br />
=== Using caff for keysigning parties ===<br />
<br />
To allow users to validate keys on the keyservers and in their keyrings (i.e. make sure they are from whom they claim to be), PGP/GPG uses he [[Wikipedia::Web of Trust|Web of Trust]]. Keysigning parties allow users to get together in physical location to validate keys. The [[Wikipedia:Zimmermann–Sassaman key-signing protocol|Zimmermann-Sassaman]] key-signing protocol is a way of making these very effective. [http://www.cryptnet.net/fdp/crypto/keysigning_party/en/keysigning_party.html Here] you will find a how-to article.<br />
<br />
For an easier process of signing keys and sending signatures to the owners after a keysigning party, you can use the tool ''caff''. It can be installed from the AUR with the package {{AUR|caff-svn}} or bundled together with other useful tools in the package {{AUR|signing-party-svn}}{{Broken package link|{{aur-mirror|signing-party-svn}}}}.<br />
Either way, there will be a lot of dependencies installing from the AUR. Alternatively you can install them from CPAN with<br />
cpanm Any::Moose<br />
cpanm GnuPG::Interface<br />
<br />
To send the signatures to their owners you need a working [[Wikipedia:Message transfer agent|MTA]]. If you do not have already one, install [[msmtp]].<br />
<br />
== Troubleshooting ==<br />
<br />
=== Not enough random bytes available ===<br />
When generating a key, gpg can run into this error:<br />
Not enough random bytes available. Please do some other work to give the OS a chance to collect more entropy!<br />
To check the available entropy, check the kernel parameters:<br />
cat /proc/sys/kernel/random/entropy_avail<br />
A healthy Linux system with a lot of entropy available will have return close to the full 4,096 bits of entropy. If the value returned is less than 200, the system is running low on entropy. <br />
<br />
To solve it, remember you do not often need to create keys and best just do what the message suggests (e.g. create disk activity, move the mouse, edit the wiki - all will create entropy). If that does not help, check which service is using up the entropy and consider stopping it for the time. If that is no alternative, see [[Random number generation#Faster alternatives]].<br />
<br />
=== su ===<br />
<br />
When using {{Ic|pinentry}}, you must have the proper permissions of the terminal device (e.g. {{Ic|/dev/tty1}}) in use. However, with ''su'' (or ''sudo''), the ownership stays with the original user, not the new one. This means that pinentry will fail, even as root. The fix is to change the permissions of the device at some point before the use of pinentry (i.e. using gpg with an agent). If doing gpg as root, simply change the ownership to root right before using gpg:<br />
<br />
chown root /dev/ttyN # where N is the current tty<br />
<br />
and then change it back after using gpg the first time. The equivalent is likely to be true with {{Ic|/dev/pts/}}.<br />
<br />
{{Note|The owner of tty ''must'' match with the user for which pinentry is running. Being part of the group {{Ic|tty}} '''is not''' enough.}}<br />
<br />
=== Agent complains end of file ===<br />
<br />
The default pinentry program is pinentry-gtk-2, which needs a DBus session bus to run properly. See [[General troubleshooting#Session permissions]] for details.<br />
<br />
Alternatively, you can use {{ic|pinentry-qt}}. See [[#pinentry]].<br />
<br />
=== KGpg configuration permissions ===<br />
<br />
There have been issues with {{Pkg|kdeutils-kgpg}} being able to access the {{ic|~/.gnupg/}} options. One issue might be a result of a deprecated ''options'' file, see the [https://bugs.kde.org/show_bug.cgi?id=290221 bug] report.<br />
<br />
Another user reported that ''KGpg'' failed to start until the {{ic|~/.gnupg}} folder is set to {{ic|drwxr-xr-x}} permissions. If you require this work-around, ensure that the directory contents retain {{ic|-rw-------}} permissions! Further, report it as a bug to the [https://bugs.kde.org/buglist.cgi?quicksearch=kgpg developers].<br />
<br />
=== Conflicts between gnome-keyring and gpg-agent ===<br />
<br />
{{Accuracy|See [[#GPG_AGENT_INFO]]}}<br />
<br />
While the Gnome keyring implements a GPG agent component, as of GnuPG version 2.1, GnuPG ignores the {{ic|GPG_AGENT_INFO}} environment variable, so that Gnome keyring can no longer be used as a GPG agent.<br />
<br />
However, since version 0.9.6 the package {{Pkg|pinentry}} provides the {{Ic|pinentry-gnome3}} program. You may set the following option in your {{Ic|gpg-agent.conf}} file<br />
pinentry-program /usr/bin/pinentry-gnome3<br />
in order to make use of that pinentry program.<br />
<br />
Since version 0.9.2 all pinentry programs can be configured to optionally save a passphrase with libsecret. For example, when the user is asked for a passphrase via {{Ic|pinentry-gnome3}}, a checkbox is shown whether to save the passphrase using a password manager. Unfortunately, the package {{Pkg|pinentry}} does not have this feature enabled (see {{Bug|46059}} for the reasons). You may use {{AUR|pinentry-libsecret}} as a replacement for it, which has support for libsecret enabled.<br />
<br />
=== mutt and gpg ===<br />
<br />
To be asked for your GnuPG password only once per session as of GnuPG 2.1, see [https://bbs.archlinux.org/viewtopic.php?pid=1490821#p1490821 this forum thread].<br />
<br />
=== "Lost" keys, upgrading to gnupg version 2.1 ===<br />
<br />
When {{ic|gpg --list-keys}} fails to show keys that used to be there, and applications complain about missing or invalid keys, some keys may not have been migrated to the new format.<br />
<br />
Please read [http://jo-ke.name/wp/?p=111 GnuPG invalid packet workaround]. Basically, it says that there is a bug with keys in the old {{ic|pubring.gpg}} and {{ic|secring.gpg}} files, which have now been superseded by the new {{ic|pubring.kbx}} file and the {{ic|private-keys-v1.d/}} subdirectory and files. Your missing keys can be recovered with the following commnads:<br />
<br />
$ cd<br />
$ cp -r .gnupg gnupgOLD<br />
$ gpg --export-ownertrust > otrust.txt<br />
$ gpg --import .gnupg/pubring.gpg<br />
$ gpg --import-ownertrust otrust.txt<br />
$ gpg --list-keys<br />
<br />
=== gpg hanged for all keyservers (when trying to receive keys) ===<br />
<br />
If gpg hanged with a certain keyserver when trying to receive keys, you might need to kill dirmngr in order to get access to other keyservers which are actually working, otherwise it might keeping hanging for all of them.<br />
<br />
=== Smartcard not detected ===<br />
<br />
Your user might not have the permission to access the smartcard which results in a {{ic|card error}} to be thrown, even though the card is correctly set up and inserted.<br />
<br />
One possible solution is to add a new group {{ic|scard}} including the users who need access to the smartcard.<br />
<br />
Then use an [[Udev#Writing_udev_rules|udev]] rule, similar to the following:<br />
{{hc|/etc/udev/rules.d/71-gnupg-ccid.rules|<nowiki><br />
ACTION=="add", SUBSYSTEM=="usb", ENV{ID_VENDOR_ID}=="1050", ENV{ID_MODEL_ID}=="0116|0111", MODE="660", GROUP="scard"<br />
</nowiki>}}<br />
One needs to adapt VENDOR and MODEL according to the {{ic|lsusb}} output, the above example is for a YubikeyNEO.<br />
<br />
== See also ==<br />
<br />
* [https://gnupg.org/ GNU Privacy Guard Homepage]<br />
* [https://fedoraproject.org/wiki/Creating_GPG_Keys Creating GPG Keys (Fedora)]<br />
* [https://wiki.debian.org/Subkeys OpenPGP subkeys in Debian]<br />
* [http://blog.sanctum.geek.nz/series/linux-crypto/ A more comprehensive gpg Tutorial]<br />
* [https://help.riseup.net/en/security/message-security/openpgp/gpg-best-practices gpg.conf recommendations and best practices]<br />
* [https://github.com/ioerror/torbirdy/blob/master/gpg.conf Torbirdy gpg.conf]<br />
* [https://www.reddit.com/r/GPGpractice/ /r/GPGpractice - a subreddit to practice using GnuPG.]</div>Max-khttps://wiki.archlinux.org/index.php?title=Ampache&diff=379322Ampache2015-06-18T12:28:24Z<p>Max-k: </p>
<hr />
<div>[[Category:Web Server]]<br />
{{Warning|Be careful. This article can be outdated '''since 3.8 release'''.}}<br />
This document describes how to set up Ampache on an Arch Linux LAMP server. Ampache is a Web-based Audio file manager. It is implemented with MySQL, and PHP. It allows you to view, edit, and play your audio files via the web. It has support for playlists, artist and album views, album art, random play, playback via Http/On the Fly Transcoding and Downsampling, Ampache is excellent if you want to be able to listen to your music collection anywhere. <br />
<br />
== Installation ==<br />
<br />
You need three things to run Ampache. A webserver, [[PHP]] and [[MySQL]]. Please refere to the [[LAMP]] article for more information.<br />
<br />
[[pacman|Install]] one Ampache package:<br />
<br />
* {{AUR|ampache}} - Stable release<br />
<br />
* {{AUR|ampache-git}} - Development version<br />
<br />
== Configuration ==<br />
<br />
PHP is installed as a dependency of Ampache. You need to edit the PHP configuration file {{ic|/etc/php/php.ini}} in order to enable iconv support for ampache.<br />
<br />
Uncomment (remove the initial semi-colon from) the following line in the {{ic|php.ini}} file:<br />
<br />
;extension=iconv.so<br />
<br />
When Ampache is installed, point your browser to [http://localhost/ampache http://localhost/ampache] (substitute the address of your Ampache server for localhost if you did not install it locally).<br />
<br />
If you encounter any problems here, use http://localhost/ampache/test.php to double check your configuration. <br />
<br />
* On the first page choose your the installation language.<br />
<br />
* On the second page enter the following:<br />
** Desired Database Name - Choose a unique name then you will recognize when you edit your MySQL databases.<br />
** MySQL Hostname - localhost is fine.<br />
** MySQL Administrative Username - root is the default<br />
** MySQL Administrative Password - root's password.<br />
** Create Database User for New Database? - Yes.<br />
** Ampache Database Username - Same thing here, unique and recognizable.<br />
** Ampache Database User Password - Please note that this is only MySQL info, this is not your Ampache user account<br />
** Overwrite Existing <br />
** Use Existing Database<br />
<br />
* On the third page you are going to edit the {{ic|ampache.cfg.php}} file<br />
** Web Path - Your path to ampache.<br />
** Desired Database Name - Same as on the second page.<br />
** MySQL Hostname - localhost.<br />
** MySQL Username - Same as Ampache Database Username, or root if you did not create a database user.<br />
** MySQL Password - MySQL Username's password.<br />
* Press write config<br />
* Move the {{ic|ampache.cfg.php}} to the {{ic|ampache/config}} directory.<br />
* Press check for config.<br />
<br />
* On the fourth page you are going to create an admin account. This step is self explanatory.<br />
** Username<br />
** Password<br />
** Confirm Password<br />
<br />
== Troubleshooting ==<br />
<br />
If you are having problems adding catalogs, please check your permission settings. More catalog toubleshooting [http://ampache.org/wiki/install:catalog#permissions here].<br />
<br />
If you are still having problems check your Open basedir setting in php.ini. You can either comment out the open_basedir all together or add the directory in which your files reside. The second option is preferred. To comment out a line all you need to do is add a semicolon at the beginning of the line.<br />
<br />
;open_basedir = /srv/http/:/home/:/tmp/:/usr/share/pear/<br />
<br />
== Tips and tricks ==<br />
<br />
=== Logging ===<br />
<br />
Is something not working as intended? Let's get some logging going!<br />
<br />
There are five levels of logging in Ampache, 5 being the highest.<br />
<br />
To enable logging you just need to set the debug value to true and set debug_level to your desired level.<br />
<br />
{{bc|1=<br />
; Debug<br />
; If this is enabled Ampache will get really chatty<br />
; warning this can crash browser during catalog builds due to <br />
; the amount of text that is dumped out this will also cause <br />
; ampache to write to the log file<br />
; DEFAULT: false<br />
debug = "true"<br />
<br />
; Debug Level<br />
; This should always be set in conjunction with the<br />
; debug option, it defines how prolific you want the<br />
; debugging in ampache to be. values are 1-5. <br />
; 1 == Errors only<br />
; 2 == Error + Failures (login attempts etc.)<br />
; 3 == ??<br />
; 4 == ?? (Profit!)<br />
; 5 == Information (cataloging progress etc.)<br />
; DEFAULT: 5<br />
debug_level = 5<br />
}}<br />
<br />
Last thing you have to do is specify where you want the log to reside. Remember that the {{ic|http}} user needs write permissons to the file.<br />
<br />
{{bc|1=<br />
; Path to Log File<br />
; This defines where you want ampache to log events to<br />
; this will only happen if debug is turned on. Do not<br />
; include trailing slash. You will need to make sure that<br />
; your HTTP server has write access to the specified directory<br />
; DEFAULT: NULL<br />
log_path = "/var/log/ampache"<br />
}}<br />
<br />
=== Transcoding ===<br />
<br />
If you want to use Ampache's on the fly transcoding you need the packages specified in {{ic|config/ampache.cfg}}, the packages needed for transcoding the most common audio file formats are listed in Ampache stable's ''.install'' file. You also need to configure the specific lines in {{ic|ampache.cfg}}.<br />
<br />
The following example enables M4A transcoding to MP3.<br />
<br />
Please note that you need both lame, used for all audio file formats, and faad, m4a specific, installed.<br />
<br />
{{bc|1=<br />
; List of filetypes to transcode<br />
transcode_m4a = true<br />
transcode_m4a_target = mp3 <br />
<br />
; These are the commands that will be run to transcode the file<br />
transcode_cmd_m4a = "faad -f 2 -w %FILE% | lame -r -b %SAMPLE% -S - -"<br />
}}<br />
<br />
=== Downsampling ===<br />
<br />
Downsampling requires the same packages as transcoding so follow the steps above for each audio file format you need. The example above enables downsampling of m4a files.<br />
<br />
You also need to uncomment and specify the minimum and maximum bitrate you prefer.<br />
<br />
{{bc|1=<br />
max_bit_rate = 576<br />
<br />
min_bit_rate = 48<br />
}}<br />
<br />
== Using with Amarok==<br />
<br />
* [http://ampache.org/wiki/config:amarok Amarok and Ampache] <br />
<br />
Using the Ampache web interface, we need to allow API access to Ampache from our local network. To do this go to the Admin tab and then click on Show Acls. Find Add API / RPC Host and click on it. <br />
Name your ACL Entry, ("My Network" for ex). If you want API + Streaming + Web Interface access pick RPC + All under type. <br />
<br />
In Amarok, go to ''Settings > Services''. Make sure the Ampache Service is enabled and then click ''Settings'' button on Ampache plugin. <br />
* Name : This is an internal name for Amarok, up to you.<br />
* Server : This is the fully qualified address for your Ampache server including the http://.<br />
* Username : This is your username to the Ampache web interface.<br />
* Password : This is your password to the Ampache web interface<br />
<br />
== See also ==<br />
<br />
https://github.com/ampache/ampache/ - Official site</div>Max-khttps://wiki.archlinux.org/index.php?title=Nginx&diff=309485Nginx2014-04-09T18:08:58Z<p>Max-k: /* Step 3: Nginx configuration */</p>
<hr />
<div>[[Category:Web Server]]<br />
[[de:Nginx]]<br />
[[ja:Nginx]]<br />
[[ru:Nginx]]<br />
[[zh-CN:Nginx]]<br />
'''Nginx''' (pronounced "engine X"), is a free, open-source, high-performance HTTP server and reverse proxy, as well as an IMAP/POP3 proxy server, written by Igor Sysoev in 2005. According to Netcraft's [http://news.netcraft.com/archives/2014/01/03/january-2014-web-server-survey.html January 2014 Web Server Survey], Nginx now hosts 14.4% of all domains worldwide, while [[Apache]] hosts about 41.64%. Nginx is now well known for its stability, rich feature set, simple configuration, and low resource consumption.<br />
<br />
== Installation ==<br />
<br />
[[Pacman|Install]] package {{Pkg|nginx}} in the [[official repositories]].<br />
<br />
For a ''Ruby on Rails'' oriented installation, see [[Ruby on Rails#The Perfect Rails Setup]].<br />
<br />
For a chroot-based installation for additional security, see [[#Installation_in_a_chroot]]<br />
<br />
== Running ==<br />
<br />
To enable the Nginx service by default at start-up, run:<br />
# systemctl enable nginx<br />
<br />
To start the Nginx service, run:<br />
# systemctl start nginx<br />
<br />
The default served page at http://127.0.0.1 is: <br />
/usr/share/nginx/html/index.html<br />
<br />
== Configuring ==<br />
<br />
You can modify the configuration by editing the files in {{ic|/etc/nginx/}}. The main configuration file is located at {{ic|/etc/nginx/nginx.conf}}. <br />
<br />
More details can be found here: [http://wiki.nginx.org/NginxConfiguration Nginx Configuration Examples].<br />
<br />
The examples below cover the most common use cases. It is assumed that you use the default location for documents ({{ic|/usr/share/nginx/html}}). If that is not the case, substitute your path instead.<br />
<br />
=== General Configuration ===<br />
<br />
You should choose a fitting value for {{ic|worker_processes}}. This settings ultimately defines how many connection nginx will accept and how many processors it will be able to make use of. Generally, making it the number of hardware threads in your system is a good start. As such, with modern servers, set something like<br />
<br />
worker_processes 8;<br />
<br />
The maximum connections nginx will accept is given by {{ic|1=max_clients = worker_processes * worker_connections}}.<br />
<br />
=== FastCGI ===<br />
<br />
FastCGI, also FCGI, is a protocol for interfacing interactive programs with a web server. FastCGI is a variation on the earlier Common Gateway Interface (CGI); FastCGI's main aim is to reduce the overhead associated with interfacing the web server and CGI programs, allowing a server to handle more web page requests at once.<br />
<br />
FastCGI technology is introduced into Nginx to work with many external tools, i.e.: Perl, [[PHP]] and [[Python]].<br />
<br />
==== PHP implementation ====<br />
<br />
There are different ways to run a FastCGI server for PHP. We cover '''php-fpm''', a recommended solution.<br />
<br />
===== Step 1: PHP configuration =====<br />
<br />
The {{Ic|open_basedir}} in {{ic|/etc/php/php.ini}} has to list base directories which contain PHP files, like {{ic|/usr/share/nginx/html/}} and {{ic|/usr/share/webapps/}}:<br />
open_basedir = /usr/share/webapps/:/srv/http/:/usr/share/nginx/html/:/home/:/tmp/:/usr/share/pear/<br />
<br />
After that let's configure modules you need. For example to use sqlite3 you should install {{ic|php-sqlite}}. Then enable it in {{ic|/etc/php/php.ini}} by uncommenting following line:<br />
extension=sqlite3.so<br />
<br />
If you run nginx in chrooted environment (chroot is {{ic|/srv/nginx-jail}}, web pages are served at {{ic|/srv/nginx-jail/www}}), the directive refers to the chroot only (i.e. {{ic|1=open_basedir = /www}}) only.<br />
<br />
===== Step 2: php-fpm =====<br />
<br />
* http://php-fpm.org<br />
<br />
Install {{Pkg|php-fpm}}.<br />
The configuration file is {{ic|/etc/php/php-fpm.conf}}.<br />
Enable and start the [[systemd]] ''php-fpm.service''.<br />
<br />
If you run nginx in chrooted environment (chroot is {{ic|/srv/nginx-jail}}, web pages are served at {{ic|/srv/nginx-jail/www}}), you must modify the file {{ic|/etc/php/php-fpm.conf}} to include the {{ic|chroot /srv/nginx-jail}} and {{ic|1=listen = /srv/nginx-jail/run/php-fpm/php-fpm.sock}} directives within the pool name section (a default one is {{ic|[www]}}). (Create the directory for the socket file, if missing.)<br />
<br />
===== Step 3: Nginx configuration =====<br />
<br />
Inside each {{Ic|server}} block serving a PHP web application should appear a {{Ic|location}} block similar to:<br />
location ~ \.php$ {<br />
try_files $uri = 404; <br />
fastcgi_pass unix:/run/php-fpm/php-fpm.sock;<br />
fastcgi_index index.php;<br />
include fastcgi_params;<br />
}<br />
<br />
If the {{Ic|root}} path in specified only inside a {{Ic|location}} (as it is in the default config), then either add<br />
root /srv/http<br />
to the {{Ic|location ~ \.php$}}, or move it directly somewhere under {{Ic|server}}.<br />
<br />
A complete working configuration could look like this:<br />
<br />
server {<br />
listen 80;<br />
server_name localhost;<br />
root /usr/share/nginx/html;<br />
location / {<br />
index index.html index.htm index.php;<br />
}<br />
<br />
location ~ \.php$ {<br />
#fastcgi_pass 127.0.0.1:9000; (depending on your php-fpm socket configuration)<br />
fastcgi_pass unix:/run/php-fpm/php-fpm.sock;<br />
fastcgi_index index.php;<br />
include fastcgi_params;<br />
}<br />
}<br />
<br />
You could create {{Ic|/etc/nginx/php.conf}} and save the php bit of the configuration there, then when needed just include this file into the {{Ic|server}} block.<br />
server = {<br />
...<br />
include php.conf;<br />
...<br />
}<br />
<br />
If you are going to process .html and .htm files with PHP, you should have something like this:<br />
location ~ \.(php|html|htm)$ {<br />
fastcgi_pass unix:/run/php-fpm/php-fpm.sock;<br />
fastcgi_index index.php;<br />
include fastcgi_params;<br />
}<br />
<br />
Non .php files processing in php-fpm should be explicitly enabled in<br />
{{Ic|/etc/php/php-fpm.conf}}:<br />
security.limit_extensions = .php .html .htm<br />
<br />
You need to restart the php-fpm daemon if you changed the configuration.<br />
# systemctl restart php-fpm<br />
<br />
'''Pay attention''' to the {{Ic|fastcgi_pass}} argument, as it must be the TCP or Unix socket defined by the chosen FastCGI server in its config file. The '''default''' (Unix) socket for {{Ic|php-fpm}} is<br />
fastcgi_pass unix:/run/php-fpm/php-fpm.sock;<br />
You might use the common TCP socket, '''not default''',<br />
fastcgi_pass 127.0.0.1:9000;<br />
Unix domain sockets are however faster.<br />
<br />
{{Ic|fastcgi.conf}} or {{Ic|fastcgi_params}} are usually included because they hold FastCGI settings for Nginx; the use of the latter is deprecated, though. They come within the Nginx installation.<br />
<br />
Finally, if Nginx has been working, run:<br />
# systemctl restart nginx<br />
<br />
If you would like to test the FastCGI implementation, create {{ic|/usr/share/nginx/html/index.php}} with content<br />
<?php<br />
phpinfo();<br />
?> <br />
and visit the URL http://127.0.0.1/index.php with your browser after checking that {{ic|/usr/share/nginx/html}} is included in {{ic|open_basedir}}.<br />
<br />
==== CGI implementation ====<br />
<br />
This implementation is needed for CGI applications.<br />
<br />
===== Step 1: fcgiwrap =====<br />
<br />
Install {{Pkg|fcgiwrap}}.<br />
The configuration file is {{ic|/usr/lib/systemd/system/fcgiwrap.socket}}.<br />
Enable and start the [[systemd]] ''fcgiwrap.socket''.<br />
<br />
The systemd unit file is currently being discussed on [https://bugs.archlinux.org/task/31696 this ArchLinux task page]. You may want to examine the unit file yourself to ensure it will work the way you want.<br />
<br />
====== Multiple worker threads ======<br />
<br />
If you want to spawn multiple worker threads, it's recommended that you use {{AUR|multiwatch}}, which will take care of restarting crashed children. You will need to use {{ic|spawn-fcgi}} to create the unix socket, as multiwatch seems unable to handle the systemd-created socket, even though fcgiwrap itself does not have any trouble if invoked directly in the unit file.<br />
<br />
Copy the unit file from {{ic|/usr/lib/systemd/system/fcgiwrap.service}} to {{ic|/etc/systemd/system/fcgiwrap.service}} (and the {{ic|fcgiwrap.socket}} unit, if present), and modify the {{ic|ExecStart}} line to suit your needs. Here is a unit file that uses {{AUR|multiwatch}}. Make sure {{ic|fcgiwrap.socket}} is not started or enabled, because it will conflict with this unit:<br />
<br />
{{hc|/etc/systemd/system/fcgiwrap.service|2=<br />
[Unit]<br />
Description=Simple CGI Server<br />
After=nss-user-lookup.target<br />
<br />
[Service]<br />
ExecStart=/usr/bin/spawn-fcgi -u http -g http -s /run/fcgiwrap.sock -n -- /usr/bin/multiwatch -f 10 -- /usr/sbin/fcgiwrap<br />
ExecStartPost=/usr/bin/chmod 660 /run/fcgiwrap.sock<br />
PrivateTmp=true<br />
Restart=on-failure<br />
<br />
[Install]<br />
WantedBy=multi-user.target<br />
}}<br />
<br />
Tweak {{ic|-f 10}} to change the number of children that are spawned.<br />
<br />
{{Warning|The ExecStartPost line is required because of strange behaviour I'm seeing when I use the {{ic|-M 660}} option for {{ic|spawn-fcgi}}. The wrong mode is set. This may be a bug?}}<br />
<br />
===== Step 2: Nginx configuration =====<br />
<br />
Inside each {{Ic|server}} block serving a CGI web application should appear a {{Ic|location}} block similar to:<br />
<br />
location ~ \.cgi$ {<br />
fastcgi_pass unix:/run/fcgiwrap.sock;<br />
include fastcgi.conf;<br />
}<br />
<br />
The '''default''' (Unix) socket for {{Ic|fcgiwrap}} is ''/run/fcgiwrap.sock''.<br />
<br />
== Installation in a chroot ==<br />
<br />
Installing Nginx in a chroot adds an additional layer of security. For<br />
maximum security the chroot should include only the files needed to run<br />
the Nginx server and all files should have the most restrictive<br />
permissions possible, e.g., as much as possible should be owned by root,<br />
directories such as {{ic|/usr/bin}} should be unreadable and unwriteable,<br />
etc. <br />
<br />
Arch comes with an {{ic|http}} user and group by default which will run the<br />
server. The chroot will be in {{ic|/srv/http}}.<br />
<br />
A perl script to create this jail is available at<br />
[https://gist.github.com/4365696 jail.pl gist]. You can either use that or follow the instructions in this article. It expects to be run<br />
as root. You will need to uncomment a line before it makes any changes.<br />
<br />
=== Create Necessary Devices ===<br />
<br />
Nginx needs {{ic|/dev/null}}, {{ic|/dev/random}}, and<br />
{{ic|/dev/urandom}}. To install these in the chroot we create the<br />
{{ic|/dev/}} folder and add the devices with mknod. We avoid mounting<br />
all of {{ic|/dev/}} to ensure that, even if the chroot is compromised, an<br />
attacker must break out of the chroot to access important devices like<br />
{{ic|/dev/sda1}}.<br />
<br />
{{Tip|See {{ic|man mknod}} and {{ic|<nowiki>ls -l<br />
/dev/{null,random,urandom}</nowiki>}} to better<br />
understand the argument to mknod.}}<br />
<br />
# export JAIL=/srv/http<br />
# mkdir $JAIL/dev<br />
# mknod -m 0666 $JAIL/dev/null c 1 3<br />
# mknod -m 0666 $JAIL/dev/random c 1 8<br />
# mknod -m 0444 $JAIL/dev/urandom c 1 9<br />
<br />
=== Create Necessary Folders ===<br />
<br />
Nginx requires a bunch of files to run properly. Before copying them<br />
over, create the folders to store them. This assumes your Nginx document<br />
root will be {{ic|/srv/http/www}}.<br />
<br />
# mkdir -p $JAIL/etc/nginx/logs<br />
# mkdir -p $JAIL/usr/{lib,bin}<br />
# mkdir -p $JAIL/usr/share/nginx<br />
# mkdir -p $JAIL/var/{log,lib}/nginx<br />
# mkdir -p $JAIL/www/cgi-bin<br />
# mkdir -p $JAIL/{run,tmp}<br />
# cd $JAIL; ln -s usr/lib lib <br />
<br />
{{Note| If using a 64 bit kernel you will need to create symbolic links {{ic|lib64}} and {{ic|usr/lib64}} to {{ic|usr/lib}}: {{ic|cd $JAIL; ln -s usr/lib lib64}} and {{ic|cd $JAIL/usr; ln -s lib lib64}}<br />
}}<br />
Then mount {{ic|$JAIL/tmp}} and {{ic|$JAIL/run}} as tmpfs's. The size<br />
should be limited to ensure an attacker cannot eat all the RAM.<br />
<br />
# mount -t tmpfs none $JAIL/run -o 'noexec,size=1M'<br />
# mount -t tmpfs none $JAIL/tmp -o 'noexec,size=100M'<br />
<br />
In order to preserve the mounts across reboots, the following entries should be added to /etc/fstab:<br />
<br />
{{hc|/etc/fstab|<nowiki><br />
tmpfs /srv/http/run tmpfs rw,noexec,relatime,size=1024k 0 0<br />
tmpfs /srv/http/tmp tmpfs rw,noexec,relatime,size=102400k 0 0<br />
</nowiki>}}<br />
<br />
=== Populate the chroot ===<br />
<br />
First copy over the easy files.<br />
<br />
# cp -r /usr/share/nginx/* $JAIL/usr/share/nginx<br />
# cp -r /usr/share/nginx/html/* $JAIL/www<br />
# cp /usr/bin/nginx $JAIL/usr/bin/<br />
# cp -r /var/lib/nginx $JAIL/var/lib/nginx<br />
<br />
Now copy over required libraries. Use ldd to list them and then copy<br />
them all to the correct location. Copying is preferred over hardlinks to<br />
ensure that even if an attacker gains write access to the files they<br />
cannot destroy or alter the true system files.<br />
<br />
{{hc|$ ldd /usr/bin/nginx|<nowiki><br />
linux-vdso.so.1 (0x00007fffc41fe000)<br />
libpthread.so.0 => /usr/lib/libpthread.so.0 (0x00007f57ec3e8000)<br />
libcrypt.so.1 => /usr/lib/libcrypt.so.1 (0x00007f57ec1b1000)<br />
libstdc++.so.6 => /usr/lib/libstdc++.so.6 (0x00007f57ebead000)<br />
libm.so.6 => /usr/lib/libm.so.6 (0x00007f57ebbaf000)<br />
libpcre.so.1 => /usr/lib/libpcre.so.1 (0x00007f57eb94c000)<br />
libssl.so.1.0.0 => /usr/lib/libssl.so.1.0.0 (0x00007f57eb6e0000)<br />
libcrypto.so.1.0.0 => /usr/lib/libcrypto.so.1.0.0 (0x00007f57eb2d6000)<br />
libdl.so.2 => /usr/lib/libdl.so.2 (0x00007f57eb0d2000)<br />
libz.so.1 => /usr/lib/libz.so.1 (0x00007f57eaebc000)<br />
libGeoIP.so.1 => /usr/lib/libGeoIP.so.1 (0x00007f57eac8d000)<br />
libgcc_s.so.1 => /usr/lib/libgcc_s.so.1 (0x00007f57eaa77000)<br />
libc.so.6 => /usr/lib/libc.so.6 (0x00007f57ea6ca000)<br />
/lib64/ld-linux-x86-64.so.2 (0x00007f57ec604000)</nowiki>}}<br />
<br />
# cp /lib64/ld-linux-x86-64.so.2 $JAIL/lib<br />
<br />
For files residing in {{ic|/usr/lib}} you may try the following one-liner:<br />
{{bc|<nowiki># cp $(ldd /usr/bin/nginx | grep /usr/lib | sed -sre 's/(.+)(\/usr\/lib\/\S+).+/\2/g') $JAIL/usr/lib</nowiki>}}<br />
<br />
{{Note|Do not try to copy linux-vdso.so – it is not a real library and does not exist in /usr/lib. Also ld-linux-x86-64.so will likely be listed in /lib64 for a 64 bit system.}}<br />
<br />
Copy over some misc. but necessary libraries and system files.<br />
<br />
{{bc|# cp /usr/lib/libnss_* $JAIL/usr/lib<br />
# cp -rfvL /etc/{services,localtime,nsswitch.conf,nscd.conf,protocols,hosts,ld.so.cache,ld.so.conf,resolv.conf,host.conf,nginx} $JAIL/etc}}<br />
<br />
Create restricted user/group files for the chroot. This way only the<br />
users needed for the chroot to function exist as far as the chroot<br />
knows, and none of the system users/groups are leaked to attackers<br />
should they gain access to the chroot.<br />
<br />
{{hc|$JAIL/etc/group|<br />
http:x:33:<br />
nobody:x:99:<br />
}}<br />
<br />
{{hc|$JAIL/etc/passwd|<br />
http:x:33:33:http:/:/bin/false<br />
nobody:x:99:99:nobody:/:/bin/false<br />
}}<br />
<br />
{{hc|$JAIL/etc/shadow|<br />
http:x:14871::::::<br />
nobody:x:14871::::::<br />
}}<br />
<br />
{{hc|$JAIL/etc/gshadow|<br />
http:::<br />
nobody:::<br />
}}<br />
<br />
# touch $JAIL/etc/shells<br />
# touch $JAIL/run/nginx.pid<br />
<br />
Finally make set very restrictive permissions. As much as possible<br />
should be owned by root and set unwritable.<br />
<br />
# chown -R root:root $JAIL/<br />
<br />
# chown -R http:http $JAIL/www<br />
# chown -R http:http $JAIL/etc/nginx<br />
# chown -R http:http $JAIL/var/{log,lib}/nginx<br />
# chown http:http $JAIL/run/nginx.pid<br />
<br />
# find $JAIL/ -gid 0 -uid 0 -type d -print | xargs sudo chmod -rw<br />
# find $JAIL/ -gid 0 -uid 0 -type d -print | xargs sudo chmod +x<br />
# find $JAIL/etc -gid 0 -uid 0 -type f -print | xargs sudo chmod -x<br />
# find $JAIL/usr/bin -type f -print | xargs sudo chmod ug+rx<br />
# find $JAIL/ -group http -user http -print | xargs sudo chmod o-rwx<br />
# chmod +rw $JAIL/tmp<br />
# chmod +rw $JAIL/run<br />
<br />
If your server will bind port 80 (or any port 0-1024), give the<br />
chrooted executable permission to bind these ports without root.<br />
<br />
# setcap 'cap_net_bind_service=+ep' $JAIL/usr/bin/nginx<br />
<br />
=== Modify nginx.service to start chroot ===<br />
<br />
Before modifying the nginx.service unit file, it may be a good idea to copy it to<br />
{{ic|/etc/systemd/system/}} since the unit files there take priority over those in {{ic|/usr/lib/systemd/system/}}. <br />
This means upgrading nginx would not modify your custom .service file. <br />
# cp /usr/lib/systemd/system/nginx.service /etc/systemd/system/nginx.service<br />
<br />
The systemd unit must be changed to start up Nginx in the chroot, as<br />
the http user, and store the pid file in the chroot <br />
{{Note|I'm not sure if the pid file needs to be stored in the chroot jail.}}<br />
<br />
{{hc|/etc/systemd/system/nginx.service|<nowiki><br />
[Unit]<br />
Description=A high performance web server and a reverse proxy server<br />
After=syslog.target network.target<br />
<br />
[Service]<br />
Type=forking<br />
PIDFile=/srv/http/run/nginx.pid<br />
ExecStartPre=/usr/bin/chroot --userspec=http:http /srv/http /usr/bin/nginx -t -q -g 'pid /run/nginx.pid; daemon on; master_process on;'<br />
ExecStart=/usr/bin/chroot --userspec=http:http /srv/http /usr/bin/nginx -g 'pid /run/nginx.pid; daemon on; master_process on;'<br />
ExecReload=/usr/bin/chroot --userspec=http:http /srv/http /usr/bin/nginx -g 'pid /run/nginx.pid; daemon on; master_process on;' -s reload<br />
ExecStop=/usr/bin/chroot --userspec=http:http /srv/http /usr/bin/nginx -g 'pid /run/nginx.pid;' -s quit<br />
<br />
[Install]<br />
WantedBy=multi-user.target</nowiki>}}<br />
<br />
{{Note|Upgrading nginx with pacman will not upgrade the chrooted nginx installation. You have to take care of the updates manually by repeating some of the steps above. Do not forget to also update the libraries it links against. }}<br />
<br />
You can now safely get rid of the non-chrooted nginx installation. <br />
# pacman -Rsc nginx<br />
<br />
If you do not remove the non-chrooted nginx installation, you may want to make sure that the running nginx process is in fact the chrooted one. You can do so by checking where {{ic|/proc/{PID}/root}} symmlinks to. If should link to {{ic|/srv/http}} instead of {{ic|/}}. <br />
# ps -C nginx | awk '{print $1}' | sed 1d | while read -r PID; do ls -l /proc/$PID/root; done<br />
<br />
== Troubleshooting ==<br />
<br />
=== Accessing local IP redirects to localhost ===<br />
<br />
Solution from the Arch Linux [https://bbs.archlinux.org/viewtopic.php?pid=780561#p780561 forum].<br />
<br />
Edit {{ic|/etc/nginx/nginx.conf}} and locate the "server_name localhost" line without a # infront of it, and add below:<br />
server_name_in_redirect off;<br />
<br />
Default behavior is that nginx redirects any requests to the value given as server_name in the config.<br />
<br />
=== Error: 403 (Permission error) ===<br />
<br />
This is most likely a permission error. Are you sure whatever user configured in the Nginx configuration is able to read the correct files?<br />
<br />
If the files are located within a home directory, (e.g. {{ic|/home/arch/public/webapp}}) and you are sure the user running Nginx has the right permissions (you can temporarily chmod all the files to 777 in order to determine this), {{ic|/home/arch}} might be '''chmod 750''', simply {{Ic|chmod}} it to ''751'', and it should work.<br />
<br />
'''If you have changed your document root'''<br />
<br />
If you are sure that permissions are as they should be, make sure that your document root directory is not empty. Try creating index.html in there.<br />
<br />
=== Error: 404 (Pathinfo error) ===<br />
<br />
In some framework (like thinkphp, cakephp) or CMS, they need the pathinfo function. <br />
<br />
1. Edit the file {{ic|/etc/php/php.ini}}, make sure<br />
cgi.fix_pathinfo=1<br />
2. Edit {{ic|/etc/nginx/conf/nginx.conf}}, comment<br />
<br />
location ~ \.php$ {<br />
...<br />
}<br />
<br />
to <br />
<br />
#location ~ \.php$ {<br />
#...<br />
#}<br />
<br />
Then add the follows,<br />
location ~ ^(.+\.php)(.*)$ {<br />
root /srv/http/nginx;<br />
fastcgi_pass unix:/var/run/php-fpm/php-fpm.sock; <br />
#fastcgi_pass 127.0.0.1:9000; #Un-comment this and comment "fastcgi_pass unix:/var/run/php-fpm/php-fpm.sock;" if you are not using php-fpm.<br />
fastcgi_index index.php;<br />
set $document_root2 $document_root;<br />
if ($document_root2 ~ "^(.*\\\\).*?[\\\\|\/]\.\.\/(.*)$") { set $document_root2 $1$2; }<br />
if ($document_root2 ~ "^(.*\\\\).*?[\\\\|\/]\.\.\/(.*)$") { set $document_root2 $1$2; }<br />
if ($document_root2 ~ "^(.*\\\\).*?[\\\\|\/]\.\.\/(.*)$") { set $document_root2 $1$2; }<br />
if ($document_root2 ~ "^(.*\\\\).*?[\\\\|\/]\.\.\/(.*)$") { set $document_root2 $1$2; }<br />
if ($document_root2 ~ "^(.*\\\\).*?[\\\\|\/]\.\.\/(.*)$") { set $document_root2 $1$2; }<br />
fastcgi_split_path_info ^(.+\.php)(.*)$;<br />
fastcgi_param SCRIPT_FILENAME $document_root2$fastcgi_script_name;<br />
fastcgi_param PATH_INFO $fastcgi_path_info;<br />
fastcgi_param PATH_TRANSLATED $document_root2$fastcgi_path_info;<br />
include fastcgi_params;<br />
fastcgi_param DOCUMENT_ROOT $document_root2;<br />
}<br />
<br />
=== Error: The page you are looking for is temporarily unavailable. Please try again later. ===<br />
<br />
This is because the FastCGI server has not been started, or the socket used has wrong permissions.<br />
<br />
=== Error: No input file specified ===<br />
<br />
1. Most Likely you do not have the SCRIPT_FILENAME containing the full path to your scripts.<br />
If the configuration of nginx (fastcgi_param SCRIPT_FILENAME) is correct, this kind of error means php failed to load the requested script. Usually it is simply a permissions issue, you can just run php-cgi as root<br />
# spawn-fcgi -a 127.0.0.1 -p 9000 -f /usr/bin/php-cgi<br />
or you should create a group and user to start the php-cgi. For example:<br />
# groupadd www<br />
# useradd -g www www<br />
# chmod +w /srv/www/nginx/html<br />
# chown -R www:www /srv/www/nginx/html<br />
# spawn-fcgi -a 127.0.0.1 -p 9000 -u www -g www -f /usr/bin/php-cgi<br />
<br />
2. Another occasion is that, wrong "root" argument in the "location ~ \.php$" section in {{ic|nginx.conf}}, make sure the "root" points to the same directory as it in "location /" in the same server. Or you may just set root as global, do not define it in any location section.<br />
<br />
3. Verify that variable "open_basedir" in {{ic|/etc/php/php.ini}} also contains path you specified in "root" argument in {{ic|nginx.conf}}<br />
<br />
4. Also notice that not only php script should have read permission, but also the entire directory structure should have execute permission so that PHP user can traverse the path.<br />
<br />
=== Error: "File not found" in browser or "Primary script unknown" in log file ===<br />
<br />
Ensure you've specified a '''root''' and '''index''' in your '''server''' or '''location''' directive:<br />
location ~ \.php$ {<br />
root /srv/http/root_dir;<br />
index index.php;<br />
fastcgi_pass unix:/run/php-fpm/php-fpm.sock;<br />
include fastcgi.conf;<br />
}<br />
<br />
=== Error: chroot: '/usr/sbin/nginx' No such file or directory ===<br />
<br />
If you encounter this error when running the daemon of nginx using chroot, this is likely due to missing 64 bit libraries in the jailed environment.<br />
<br />
If you are running chroot in {{ic|/srv/http}} you need to add the required 64 bit libraries. <br />
<br />
First, set up the directories (these commands will need to be run as root)<br />
<br />
# mkdir /srv/http/usr/lib64 <br />
# cd /srv/http; ln -s usr/lib64 lib64<br />
<br />
Then copy the required 64 bit libraries found using {{ic|ldd /usr/sbin/nginx}} to {{ic|/srv/http/usr/lib64}}<br />
<br />
if run as root, permissions for the libraries should be read and executable for all users, so no modification is required.<br />
<br />
=== Alternative Script for Systemd ===<br />
<br />
On pure Systemd you can get advantages of chroot + Systemd -> [http://0pointer.de/blog/projects/changing-roots.html Systemd for Administrators, Part VI ]<br />
Based on set [http://wiki.nginx.org/CoreModule#user user group] an pid on:<br />
{{hc|/etc/nginx/nginx.conf|2=<br />
user http;<br />
pid /run/nginx.pid;<br />
}}<br />
the absolute path of file is {{ic|/srv/http/etc/nginx/nginx.conf}}<br />
{{hc|/etc/systemd/system/nginx.service|2=<br />
[Unit]<br />
Description=Nginx (Chroot)<br />
After=syslog.target network.target<br />
<br />
[Service]<br />
Type=forking<br />
PIDFile=/srv/http/run/nginx.pid<br />
RootDirectory=/srv/http<br />
ExecStartPre=/usr/sbin/nginx -t -c /etc/nginx/nginx.conf<br />
ExecStart=/usr/sbin/nginx -c /etc/nginx/nginx.conf<br />
ExecReload=/usr/sbin/nginx -c /etc/nginx/nginx.conf -s reload<br />
ExecStop=/usr/sbin/nginx -c /etc/nginx/nginx.conf -s stop<br />
<br />
[Install]<br />
WantedBy=multi-user.target<br />
}}<br />
Is not necesary set the default location, nginx loads at default {{ic| -c /etc/nginx/nginx.conf}}, but is a good idea set it. <br />
<br />
Alternatively can run '''only''' ExecStart as chroot whit parameter {{ic|RootDirectoryStartOnly}} set as yes [[http://www.freedesktop.org/software/systemd/man/systemd.service.html man systemd service]] or start it before mount point as efective or a [http://www.freedesktop.org/software/systemd/man/systemd.path.html systemd path] is available.<br />
<br />
{{hc|/etc/systemd/system/nginx.path|2=<br />
[Unit]<br />
Description=Nginx (Chroot) path<br />
[Path]<br />
PathExists=/srv/http/site/Public_html<br />
[Install]<br />
WantedBy=default.target<br />
}}<br />
to activate it<br />
{{ic|systemctl enable nginx.path }} <br />
and change on {{ic|/etc/systemd/system/nginx.service}} '''WantedBy=default.target''' to '''WantedBy=nginx.path'''<br />
Practicality may be that the mount point delay unless the folder to be accessible, each time the point is accessible, systemd start the server. In my case, I prefer to mount, and before Bind to existing Dir. <br />
<br />
The {{ic| PIDFile}} on .service file allows Systemd to monitor process(absolute Path), If not the desired behavior, you can change to default one-shoot Type, and delete the reference on .service file.<br />
<br />
<br />
== See Also ==<br />
* [https://calomel.org/nginx.html Very good in-depth 2014 look at Nginx security and Reverse Proxying]<br />
* [[Nginx/Init_script|Init script for Nginx]]<br />
* [http://nginx.org/ Nginx Official Site]<br />
* [http://calomel.org/nginx.html Nginx HowTo]<br />
* [http://blog.gotux.net/tutorial/custom-nginx-indexer/ Custom Nginx Indexer]</div>Max-khttps://wiki.archlinux.org/index.php?title=Burning_Xbox_360_games&diff=290480Burning Xbox 360 games2013-12-26T10:59:10Z<p>Max-k: /* Burning ISO Files */</p>
<hr />
<div>[[Category:Gaming]]<br />
{{Warning|The legality of this process may be questionable. Refer to the copyright laws in your country for clarification. Playing backup games online may result in your Xbox360 console being banned from Xbox Live. Follow this guide at your own risk!}}<br />
{{Tip|Backups may only be played on an Xbox360 with a flashed firmware.}}<br />
<br />
==Overview==<br />
Xbox 360 games come in two image formats: .iso and .000. They are burned on dual layer DVD+R discs. This requires a dual-layer DVD burner. No specific brand or burner is needed. In order to maximize the success of your burn, you should burn at the slowest speed your burner and media allow.<br />
<br />
Please note that games must be burned onto DVD+R DL (Dual Layered), as DVD-R DL would not work. <br />
<br />
==Stealth Patching==<br />
<br />
Stealth patching patches a game image to make it ignore the security check done by the Xbox360 console upon boot. If you use a stealth firmware, you will need to patch your backup. You can do this with a tool called [https://aur.archlinux.org/packages.php?ID=24813 abgx360], which can be found in the [[AUR]].<br />
<br />
abgx360 works on .iso ''and'' .000 images. In order to patch these images, use the {{Ic|--af3}} flag, as such:<br />
<br />
abgx360 --af3 /path/to/game.iso<br />
<br />
Using this tool should patch the file with no issues. It will also output metadata about the game.<br />
<br />
==Burning ISO Files==<br />
{{Note| You can use [https://wiki.archlinux.org/index.php/Wine#Burning_optical_media Imgburn + Wine] to burn ISO (yes, XGD3 burns work with burnermax drives and since Imgburn 2.5.8 the builtin "BurnerMax Payload" feature works as well).}}<br />
<br />
Burning an iso is best done through the command line with growisofs. This is found in the {{pkg|dvd+rw-tools}} package found in the [[Official Repositories]].<br />
<br />
There are other applications you can use to burn the image ({{pkg|k3b}}, {{AUR|gnomebaker}}, etc) but you may miss some configuration options and end up with a dud burn. Use the following command to burn the image to disc.<br />
<br />
XGD1/XGD2:<br />
<br />
growisofs -use-the-force-luke=dao -use-the-force-luke=break:1913760 -dvd-compat -speed=2 -Z /dev/sr0=/path/to/game.iso<br />
<br />
XGD3(iXtreme Burner Max Firmware):<br />
<br />
growisofs -use-the-force-luke=dao -use-the-force-luke=break:2133520 -dvd-compat -speed=2 -Z /dev/sr0=/path/to/game.iso<br />
<br />
Replace {{Ic|/dev/sr0}} with the path to your dual layer drive. For most systems it will be {{Ic|/dev/sr0}}. Since May 2011, the {{ic|/dev/dvd}} symlink has been removed in [[udev]]. See [https://bbs.archlinux.org/viewtopic.php?id=120010] for more details.<br />
<br />
If everything has been set up correctly you should see a messages like this:<br />
<br />
Executing 'builtin_dd if=TalesOfVesperia.iso of=/dev/sr0 obs=32k seek=0'<br />
/dev/sr0: splitting layers at 1913760 blocks<br />
/dev/sr0: "Current Write Speed" is 2.5x1352KBps.<br />
3538944/7835492352 ( 0.0%) @0.8x, remaining 45:39 RBU 89.7% UBU 7.1%<br />
<br />
The burn should take around approximately 40 minutes at 2.4x write speed, depending on the size of the iso.<br />
<br />
==Burning .000 Files==<br />
<br />
To burn a .000 image you must first patch it with a Java application called imagebpatch.jar. You can get it [http://www.megaupload.com/?d=2JOIHFU3 here].<br />
You will need to have java installed to use this.<br />
<br />
pacman -S jre<br />
<br />
Logout and login again (or {{Ic|source /etc/profile}}) in order to update your $PATH.<br />
<br />
After you've installed Java and downloaded the application, just run it in the console:<br />
<br />
java -jar imgbpatch.jar /path/to/image.000<br />
<br />
Now it can be burned like an iso, using the following. <br />
<br />
XGD1/XGD2:<br />
<br />
growisofs -use-the-force-luke=dao -use-the-force-luke=break:1913760 -dvd-compat -speed=2 -Z /dev/sr0=/path/to/game.000<br />
<br />
XGD3(iXtreme Burner Max Firmware):<br />
<br />
growisofs -use-the-force-luke=dao -use-the-force-luke=break:2133520 -dvd-compat -speed=2 -Z /dev/sr0=/path/to/game.000<br />
<br />
Replace {{Ic|/dev/sr0}} with the path to your dual layer drive. For most systems it will be {{Ic|/dev/sr0}}. Since May 2011, the /dev/dvd symlink has been removed in udev. See [https://bbs.archlinux.org/viewtopic.php?id=120010] for more details.<br />
<br />
==xbox360_burn==<br />
It's obviously possible to create an executable file containing the command to burn DVD, as such, someone has created a bash script to allow for a more user-friendly interface, you can get it from the AUR here: {{aur|xbox360_burn 0.7-1}}.<br />
<br />
To burn, you then only have to use this command:<br />
<br />
xbox360_burn -ib /dev/sr0 rom.iso<br />
<br />
Replace {{Ic|/dev/sr0}} with the path to your dual layer drive. For most systems it will be {{Ic|/dev/sr0}}. Since May 2011, the /dev/dvd symlink has been removed in udev. See [https://bbs.archlinux.org/viewtopic.php?id=120010] for more details.<br />
<br />
==Notes==<br />
{{Warning|It seems that removing these parameters from the command line for XGD1/2 burning will set a wrong layer break and make your backup broken.}}<br />
To fix error '''"...INVALID FIELD IN PARAMETER LIST..."''' you need to omit these options from the command line:<br />
<br />
-use-the-force-luke=dao -dvd-compat<br />
<br />
So for example command becomes:<br />
<br />
growisofs -use-the-force-luke=break:layer_break_size -speed=2 -Z /dev/sr0=/path/to/game.iso</div>Max-khttps://wiki.archlinux.org/index.php?title=Burning_Xbox_360_games&diff=290479Burning Xbox 360 games2013-12-26T10:58:39Z<p>Max-k: /* Notes */</p>
<hr />
<div>[[Category:Gaming]]<br />
{{Warning|The legality of this process may be questionable. Refer to the copyright laws in your country for clarification. Playing backup games online may result in your Xbox360 console being banned from Xbox Live. Follow this guide at your own risk!}}<br />
{{Tip|Backups may only be played on an Xbox360 with a flashed firmware.}}<br />
<br />
==Overview==<br />
Xbox 360 games come in two image formats: .iso and .000. They are burned on dual layer DVD+R discs. This requires a dual-layer DVD burner. No specific brand or burner is needed. In order to maximize the success of your burn, you should burn at the slowest speed your burner and media allow.<br />
<br />
Please note that games must be burned onto DVD+R DL (Dual Layered), as DVD-R DL would not work. <br />
<br />
==Stealth Patching==<br />
<br />
Stealth patching patches a game image to make it ignore the security check done by the Xbox360 console upon boot. If you use a stealth firmware, you will need to patch your backup. You can do this with a tool called [https://aur.archlinux.org/packages.php?ID=24813 abgx360], which can be found in the [[AUR]].<br />
<br />
abgx360 works on .iso ''and'' .000 images. In order to patch these images, use the {{Ic|--af3}} flag, as such:<br />
<br />
abgx360 --af3 /path/to/game.iso<br />
<br />
Using this tool should patch the file with no issues. It will also output metadata about the game.<br />
<br />
==Burning ISO Files==<br />
{{Note| You can use [https://wiki.archlinux.org/index.php/Wine#Burning_optical_media Imgburn + Wine] to burn ISO (yes, XGD3 burns work with burnermax drives and since Imgburn 2.5.8 the builtin "BurnerMax Payload" feature works as well).}}<br />
<br />
Burning an iso is best done through the command line with growisofs. This is found in the {{pkg|dvd+rw-tools}} package found in the [[Official Repositories]].<br />
<br />
There are other applications you can use to burn the image ({{pkg|k3b}}, {{AUR|gnomebaker}}, etc) but you may miss some configuration options and end up with a dud burn. Use the following command to burn the image to disc.<br />
<br />
XGD1/XGD2:<br />
<br />
growisofs -use-the-force-luke=dao -use-the-force-luke=break:1913760 -dvd-compat -speed=2 -Z /dev/sr0=/path/to/game.iso<br />
<br />
XGD3(iXtreme Burner Max Firmware):<br />
<br />
growisofs -use-the-force-luke=break:2133520 -speed=2 -Z /dev/sr0=/path/to/game.iso<br />
<br />
Replace {{Ic|/dev/sr0}} with the path to your dual layer drive. For most systems it will be {{Ic|/dev/sr0}}. Since May 2011, the {{ic|/dev/dvd}} symlink has been removed in [[udev]]. See [https://bbs.archlinux.org/viewtopic.php?id=120010] for more details.<br />
<br />
If everything has been set up correctly you should see a messages like this:<br />
<br />
Executing 'builtin_dd if=TalesOfVesperia.iso of=/dev/sr0 obs=32k seek=0'<br />
/dev/sr0: splitting layers at 1913760 blocks<br />
/dev/sr0: "Current Write Speed" is 2.5x1352KBps.<br />
3538944/7835492352 ( 0.0%) @0.8x, remaining 45:39 RBU 89.7% UBU 7.1%<br />
<br />
The burn should take around approximately 40 minutes at 2.4x write speed, depending on the size of the iso.<br />
<br />
==Burning .000 Files==<br />
<br />
To burn a .000 image you must first patch it with a Java application called imagebpatch.jar. You can get it [http://www.megaupload.com/?d=2JOIHFU3 here].<br />
You will need to have java installed to use this.<br />
<br />
pacman -S jre<br />
<br />
Logout and login again (or {{Ic|source /etc/profile}}) in order to update your $PATH.<br />
<br />
After you've installed Java and downloaded the application, just run it in the console:<br />
<br />
java -jar imgbpatch.jar /path/to/image.000<br />
<br />
Now it can be burned like an iso, using the following. <br />
<br />
XGD1/XGD2:<br />
<br />
growisofs -use-the-force-luke=dao -use-the-force-luke=break:1913760 -dvd-compat -speed=2 -Z /dev/sr0=/path/to/game.000<br />
<br />
XGD3(iXtreme Burner Max Firmware):<br />
<br />
growisofs -use-the-force-luke=dao -use-the-force-luke=break:2133520 -dvd-compat -speed=2 -Z /dev/sr0=/path/to/game.000<br />
<br />
Replace {{Ic|/dev/sr0}} with the path to your dual layer drive. For most systems it will be {{Ic|/dev/sr0}}. Since May 2011, the /dev/dvd symlink has been removed in udev. See [https://bbs.archlinux.org/viewtopic.php?id=120010] for more details.<br />
<br />
==xbox360_burn==<br />
It's obviously possible to create an executable file containing the command to burn DVD, as such, someone has created a bash script to allow for a more user-friendly interface, you can get it from the AUR here: {{aur|xbox360_burn 0.7-1}}.<br />
<br />
To burn, you then only have to use this command:<br />
<br />
xbox360_burn -ib /dev/sr0 rom.iso<br />
<br />
Replace {{Ic|/dev/sr0}} with the path to your dual layer drive. For most systems it will be {{Ic|/dev/sr0}}. Since May 2011, the /dev/dvd symlink has been removed in udev. See [https://bbs.archlinux.org/viewtopic.php?id=120010] for more details.<br />
<br />
==Notes==<br />
{{Warning|It seems that removing these parameters from the command line for XGD1/2 burning will set a wrong layer break and make your backup broken.}}<br />
To fix error '''"...INVALID FIELD IN PARAMETER LIST..."''' you need to omit these options from the command line:<br />
<br />
-use-the-force-luke=dao -dvd-compat<br />
<br />
So for example command becomes:<br />
<br />
growisofs -use-the-force-luke=break:layer_break_size -speed=2 -Z /dev/sr0=/path/to/game.iso</div>Max-khttps://wiki.archlinux.org/index.php?title=Burning_Xbox_360_games&diff=290475Burning Xbox 360 games2013-12-26T10:56:25Z<p>Max-k: /* Notes */</p>
<hr />
<div>[[Category:Gaming]]<br />
{{Warning|The legality of this process may be questionable. Refer to the copyright laws in your country for clarification. Playing backup games online may result in your Xbox360 console being banned from Xbox Live. Follow this guide at your own risk!}}<br />
{{Tip|Backups may only be played on an Xbox360 with a flashed firmware.}}<br />
<br />
==Overview==<br />
Xbox 360 games come in two image formats: .iso and .000. They are burned on dual layer DVD+R discs. This requires a dual-layer DVD burner. No specific brand or burner is needed. In order to maximize the success of your burn, you should burn at the slowest speed your burner and media allow.<br />
<br />
Please note that games must be burned onto DVD+R DL (Dual Layered), as DVD-R DL would not work. <br />
<br />
==Stealth Patching==<br />
<br />
Stealth patching patches a game image to make it ignore the security check done by the Xbox360 console upon boot. If you use a stealth firmware, you will need to patch your backup. You can do this with a tool called [https://aur.archlinux.org/packages.php?ID=24813 abgx360], which can be found in the [[AUR]].<br />
<br />
abgx360 works on .iso ''and'' .000 images. In order to patch these images, use the {{Ic|--af3}} flag, as such:<br />
<br />
abgx360 --af3 /path/to/game.iso<br />
<br />
Using this tool should patch the file with no issues. It will also output metadata about the game.<br />
<br />
==Burning ISO Files==<br />
{{Note| You can use [https://wiki.archlinux.org/index.php/Wine#Burning_optical_media Imgburn + Wine] to burn ISO (yes, XGD3 burns work with burnermax drives and since Imgburn 2.5.8 the builtin "BurnerMax Payload" feature works as well).}}<br />
<br />
Burning an iso is best done through the command line with growisofs. This is found in the {{pkg|dvd+rw-tools}} package found in the [[Official Repositories]].<br />
<br />
There are other applications you can use to burn the image ({{pkg|k3b}}, {{AUR|gnomebaker}}, etc) but you may miss some configuration options and end up with a dud burn. Use the following command to burn the image to disc.<br />
<br />
XGD1/XGD2:<br />
<br />
growisofs -use-the-force-luke=dao -use-the-force-luke=break:1913760 -dvd-compat -speed=2 -Z /dev/sr0=/path/to/game.iso<br />
<br />
XGD3(iXtreme Burner Max Firmware):<br />
<br />
growisofs -use-the-force-luke=break:2133520 -speed=2 -Z /dev/sr0=/path/to/game.iso<br />
<br />
Replace {{Ic|/dev/sr0}} with the path to your dual layer drive. For most systems it will be {{Ic|/dev/sr0}}. Since May 2011, the {{ic|/dev/dvd}} symlink has been removed in [[udev]]. See [https://bbs.archlinux.org/viewtopic.php?id=120010] for more details.<br />
<br />
If everything has been set up correctly you should see a messages like this:<br />
<br />
Executing 'builtin_dd if=TalesOfVesperia.iso of=/dev/sr0 obs=32k seek=0'<br />
/dev/sr0: splitting layers at 1913760 blocks<br />
/dev/sr0: "Current Write Speed" is 2.5x1352KBps.<br />
3538944/7835492352 ( 0.0%) @0.8x, remaining 45:39 RBU 89.7% UBU 7.1%<br />
<br />
The burn should take around approximately 40 minutes at 2.4x write speed, depending on the size of the iso.<br />
<br />
==Burning .000 Files==<br />
<br />
To burn a .000 image you must first patch it with a Java application called imagebpatch.jar. You can get it [http://www.megaupload.com/?d=2JOIHFU3 here].<br />
You will need to have java installed to use this.<br />
<br />
pacman -S jre<br />
<br />
Logout and login again (or {{Ic|source /etc/profile}}) in order to update your $PATH.<br />
<br />
After you've installed Java and downloaded the application, just run it in the console:<br />
<br />
java -jar imgbpatch.jar /path/to/image.000<br />
<br />
Now it can be burned like an iso, using the following. <br />
<br />
XGD1/XGD2:<br />
<br />
growisofs -use-the-force-luke=dao -use-the-force-luke=break:1913760 -dvd-compat -speed=2 -Z /dev/sr0=/path/to/game.000<br />
<br />
XGD3(iXtreme Burner Max Firmware):<br />
<br />
growisofs -use-the-force-luke=dao -use-the-force-luke=break:2133520 -dvd-compat -speed=2 -Z /dev/sr0=/path/to/game.000<br />
<br />
Replace {{Ic|/dev/sr0}} with the path to your dual layer drive. For most systems it will be {{Ic|/dev/sr0}}. Since May 2011, the /dev/dvd symlink has been removed in udev. See [https://bbs.archlinux.org/viewtopic.php?id=120010] for more details.<br />
<br />
==xbox360_burn==<br />
It's obviously possible to create an executable file containing the command to burn DVD, as such, someone has created a bash script to allow for a more user-friendly interface, you can get it from the AUR here: {{aur|xbox360_burn 0.7-1}}.<br />
<br />
To burn, you then only have to use this command:<br />
<br />
xbox360_burn -ib /dev/sr0 rom.iso<br />
<br />
Replace {{Ic|/dev/sr0}} with the path to your dual layer drive. For most systems it will be {{Ic|/dev/sr0}}. Since May 2011, the /dev/dvd symlink has been removed in udev. See [https://bbs.archlinux.org/viewtopic.php?id=120010] for more details.<br />
<br />
==Notes==<br />
{{Warning|It seems that removing these parameters from the command line for XGD1/2 burning will set a wrong layer break and your backup will not work.}}<br />
To fix error '''"...INVALID FIELD IN PARAMETER LIST..."''' you need to omit these options from the command line:<br />
<br />
-use-the-force-luke=dao -dvd-compat<br />
<br />
So for example command becomes:<br />
<br />
growisofs -use-the-force-luke=break:layer_break_size -speed=2 -Z /dev/sr0=/path/to/game.iso</div>Max-khttps://wiki.archlinux.org/index.php?title=Burning_Xbox_360_games&diff=290474Burning Xbox 360 games2013-12-26T10:50:43Z<p>Max-k: /* Burning ISO Files */</p>
<hr />
<div>[[Category:Gaming]]<br />
{{Warning|The legality of this process may be questionable. Refer to the copyright laws in your country for clarification. Playing backup games online may result in your Xbox360 console being banned from Xbox Live. Follow this guide at your own risk!}}<br />
{{Tip|Backups may only be played on an Xbox360 with a flashed firmware.}}<br />
<br />
==Overview==<br />
Xbox 360 games come in two image formats: .iso and .000. They are burned on dual layer DVD+R discs. This requires a dual-layer DVD burner. No specific brand or burner is needed. In order to maximize the success of your burn, you should burn at the slowest speed your burner and media allow.<br />
<br />
Please note that games must be burned onto DVD+R DL (Dual Layered), as DVD-R DL would not work. <br />
<br />
==Stealth Patching==<br />
<br />
Stealth patching patches a game image to make it ignore the security check done by the Xbox360 console upon boot. If you use a stealth firmware, you will need to patch your backup. You can do this with a tool called [https://aur.archlinux.org/packages.php?ID=24813 abgx360], which can be found in the [[AUR]].<br />
<br />
abgx360 works on .iso ''and'' .000 images. In order to patch these images, use the {{Ic|--af3}} flag, as such:<br />
<br />
abgx360 --af3 /path/to/game.iso<br />
<br />
Using this tool should patch the file with no issues. It will also output metadata about the game.<br />
<br />
==Burning ISO Files==<br />
{{Note| You can use [https://wiki.archlinux.org/index.php/Wine#Burning_optical_media Imgburn + Wine] to burn ISO (yes, XGD3 burns work with burnermax drives and since Imgburn 2.5.8 the builtin "BurnerMax Payload" feature works as well).}}<br />
<br />
Burning an iso is best done through the command line with growisofs. This is found in the {{pkg|dvd+rw-tools}} package found in the [[Official Repositories]].<br />
<br />
There are other applications you can use to burn the image ({{pkg|k3b}}, {{AUR|gnomebaker}}, etc) but you may miss some configuration options and end up with a dud burn. Use the following command to burn the image to disc.<br />
<br />
XGD1/XGD2:<br />
<br />
growisofs -use-the-force-luke=dao -use-the-force-luke=break:1913760 -dvd-compat -speed=2 -Z /dev/sr0=/path/to/game.iso<br />
<br />
XGD3(iXtreme Burner Max Firmware):<br />
<br />
growisofs -use-the-force-luke=break:2133520 -speed=2 -Z /dev/sr0=/path/to/game.iso<br />
<br />
Replace {{Ic|/dev/sr0}} with the path to your dual layer drive. For most systems it will be {{Ic|/dev/sr0}}. Since May 2011, the {{ic|/dev/dvd}} symlink has been removed in [[udev]]. See [https://bbs.archlinux.org/viewtopic.php?id=120010] for more details.<br />
<br />
If everything has been set up correctly you should see a messages like this:<br />
<br />
Executing 'builtin_dd if=TalesOfVesperia.iso of=/dev/sr0 obs=32k seek=0'<br />
/dev/sr0: splitting layers at 1913760 blocks<br />
/dev/sr0: "Current Write Speed" is 2.5x1352KBps.<br />
3538944/7835492352 ( 0.0%) @0.8x, remaining 45:39 RBU 89.7% UBU 7.1%<br />
<br />
The burn should take around approximately 40 minutes at 2.4x write speed, depending on the size of the iso.<br />
<br />
==Burning .000 Files==<br />
<br />
To burn a .000 image you must first patch it with a Java application called imagebpatch.jar. You can get it [http://www.megaupload.com/?d=2JOIHFU3 here].<br />
You will need to have java installed to use this.<br />
<br />
pacman -S jre<br />
<br />
Logout and login again (or {{Ic|source /etc/profile}}) in order to update your $PATH.<br />
<br />
After you've installed Java and downloaded the application, just run it in the console:<br />
<br />
java -jar imgbpatch.jar /path/to/image.000<br />
<br />
Now it can be burned like an iso, using the following. <br />
<br />
XGD1/XGD2:<br />
<br />
growisofs -use-the-force-luke=dao -use-the-force-luke=break:1913760 -dvd-compat -speed=2 -Z /dev/sr0=/path/to/game.000<br />
<br />
XGD3(iXtreme Burner Max Firmware):<br />
<br />
growisofs -use-the-force-luke=dao -use-the-force-luke=break:2133520 -dvd-compat -speed=2 -Z /dev/sr0=/path/to/game.000<br />
<br />
Replace {{Ic|/dev/sr0}} with the path to your dual layer drive. For most systems it will be {{Ic|/dev/sr0}}. Since May 2011, the /dev/dvd symlink has been removed in udev. See [https://bbs.archlinux.org/viewtopic.php?id=120010] for more details.<br />
<br />
==xbox360_burn==<br />
It's obviously possible to create an executable file containing the command to burn DVD, as such, someone has created a bash script to allow for a more user-friendly interface, you can get it from the AUR here: {{aur|xbox360_burn 0.7-1}}.<br />
<br />
To burn, you then only have to use this command:<br />
<br />
xbox360_burn -ib /dev/sr0 rom.iso<br />
<br />
Replace {{Ic|/dev/sr0}} with the path to your dual layer drive. For most systems it will be {{Ic|/dev/sr0}}. Since May 2011, the /dev/dvd symlink has been removed in udev. See [https://bbs.archlinux.org/viewtopic.php?id=120010] for more details.<br />
<br />
==Notes==<br />
<br />
To fix error '''"...INVALID FIELD IN PARAMETER LIST..."''' you need to omit these options from the command line:<br />
<br />
-use-the-force-luke=dao -dvd-compat<br />
<br />
So for example command becomes:<br />
<br />
growisofs -use-the-force-luke=break:layer_break_size -speed=2 -Z /dev/sr0=/path/to/game.iso</div>Max-khttps://wiki.archlinux.org/index.php?title=Bash/Prompt_customization&diff=288051Bash/Prompt customization2013-12-15T11:38:39Z<p>Max-k: /* Version #1: with numerical error */</p>
<hr />
<div>[[Category:Eye candy]]<br />
[[Category:Command shells]]<br />
[[de:Bash-Prompt anpassen]]<br />
[[es:Color Bash Prompt]]<br />
[[it:Color Bash Prompt]]<br />
[[ru:Color Bash Prompt]]<br />
[[zh-CN:Color Bash Prompt]]<br />
{{Article summary start}}<br />
{{Article summary text|Discussing and improving Bash graphical customisations.}}<br />
{{Article summary heading|Related}}<br />
{{Article summary wiki|Environment Variables}}<br />
{{Article summary wiki|Bash}}<br />
{{Article summary end}}<br />
There are a variety of possibilities for [[Bash]]'s prompt (PS1), and customizing it can help you be more productive at the command line. You can add additional information to your prompt, or you can simply add color to it to make the prompt stand out. See [https://bbs.archlinux.org/viewtopic.php?id=50885 this Forum thread] for more informations and examples.<br />
<br />
=A well-established Bash color prompt=<br />
<br />
What follows is a well-proven way to color the Bash prompt. It is the most widespread Bash color scheme in the GNU/Linux world. Here is a preview of how it will appear:<br />
<br />
<div style="font-family: monospace; margin: 1em 3em; padding: 1em; border: 3px solid #bcd; background-color: black; color: #fff;">I am two with nature.<br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;-- Woody Allen<br /><span style="color: #0a0; font-weight: bold;">andy@alba</span> <span style="color: #55f; font-weight: bold;">~ $</span> ls<br /><span style="color: #55f; font-weight: bold;">Desktop Documents Music</span> public.desktop<br /><span style="color: #0a0; font-weight: bold;">andy@alba</span> <span style="color: #55f; font-weight: bold;">~ $</span> I\ will\ try\ to\ type\ a\ wrong\ command...<br />bash: I will try to type a wrong command...: command not found<br /><span style="color: #0a0; font-weight: bold;">andy@alba</span> <span style="color: #55f; font-weight: bold;">~</span> <span style="color: #a00; font-weight: bold;">:(</span> <span style="color: #55f; font-weight: bold;">$</span> echo 'Hello world!'<br />Hello world!<br /><span style="color: #0a0; font-weight: bold;">andy@alba</span> su<br />Password:<br />Two can Live as Cheaply as One for Half as Long.<br /> &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;-- Howard Kandel<br /><span style="color: #a00; font-weight: bold;">alba</span> <span style="color: #55f; font-weight: bold;">~ $</span> <span style="text-decoration: blink;">_</span></div><br />
<br />
==Installation==<br />
{{Warning|You should back up any system-wide bash files you modify in {{ic|/etc}} as simple syntax mistakes may break your shell.}}<br />
<br />
It's a '''generalized scheme for all users''', so you should start renaming your {{ic|~/.bashrc}} file and then copy the {{ic|/etc/bash.bashrc}} file to {{ic|/etc/bash.bashrc.back}} and create a {{ic|/etc/DIR_COLORS}} file ({{ic|~/.bashrc}} and {{ic|/etc/bash.bashrc}} [[Color_Bash_Prompt#Example_of_cohabitation_of_.2Fetc.2Fbash.bashrc_and_.7E.2F.bashrc|can also cohabitate]]). Here is our possible version of this scheme for Arch (originally this scheme was created for Gentoo, but here are some important additions).<br />
<br />
===/etc/bash.bashrc===<br />
<br />
<pre style="max-height: 400px; overflow:auto;"># /etc/bash.bashrc<br />
#<br />
# https://wiki.archlinux.org/index.php/Color_Bash_Prompt<br />
#<br />
# This file is sourced by all *interactive* bash shells on startup,<br />
# including some apparently interactive shells such as scp and rcp<br />
# that can't tolerate any output. So make sure this doesn't display<br />
# anything or bad things will happen !<br />
<br />
# Test for an interactive shell. There is no need to set anything<br />
# past this point for scp and rcp, and it's important to refrain from<br />
# outputting anything in those cases.<br />
<br />
# If not running interactively, don't do anything!<br />
[[ $- != *i* ]] &amp;&amp; return<br />
<br />
# Bash won't get SIGWINCH if another process is in the foreground.<br />
# Enable checkwinsize so that bash will check the terminal size when<br />
# it regains control.<br />
# http://cnswww.cns.cwru.edu/~chet/bash/FAQ (E11)<br />
shopt -s checkwinsize<br />
<br />
# Enable history appending instead of overwriting.<br />
shopt -s histappend<br />
<br />
case ${TERM} in<br />
xterm*|rxvt*|Eterm|aterm|kterm|gnome*)<br />
PROMPT_COMMAND=${PROMPT_COMMAND:+$PROMPT_COMMAND; }'printf "\033]0;%s@%s:%s\007" "${USER}" "${HOSTNAME%%.*}" "${PWD/#$HOME/~}"'<br />
;;<br />
screen)<br />
PROMPT_COMMAND=${PROMPT_COMMAND:+$PROMPT_COMMAND; }'printf "\033_%s@%s:%s\033\\" "${USER}" "${HOSTNAME%%.*}" "${PWD/#$HOME/~}"'<br />
;;<br />
esac<br />
<br />
# fortune is a simple program that displays a pseudorandom message<br />
# from a database of quotations at logon and/or logout.<br />
# If you wish to use it, please install "fortune-mod" from the<br />
# official repositories, then uncomment the following line:<br />
<br />
# [[ "$PS1" ]] &amp;&amp; /usr/bin/fortune<br />
<br />
# Set colorful PS1 only on colorful terminals.<br />
# dircolors --print-database uses its own built-in database<br />
# instead of using /etc/DIR_COLORS. Try to use the external file<br />
# first to take advantage of user additions. Use internal bash<br />
# globbing instead of external grep binary.<br />
<br />
# sanitize TERM:<br />
safe_term=${TERM//[^[:alnum:]]/?}<br />
match_lhs=""<br />
<br />
[[ -f ~/.dir_colors ]] &amp;&amp; match_lhs="${match_lhs}$(&lt;~/.dir_colors)"<br />
[[ -f /etc/DIR_COLORS ]] &amp;&amp; match_lhs="${match_lhs}$(&lt;/etc/DIR_COLORS)"<br />
[[ -z ${match_lhs} ]] \<br />
&amp;&amp; type -P dircolors &gt;/dev/null \<br />
&amp;&amp; match_lhs=$(dircolors --print-database)<br />
<br />
if [[ $'\n'${match_lhs} == *$'\n'"TERM "${safe_term}* ]] ; then<br />
<br />
# we have colors :-)<br />
<br />
# Enable colors for ls, etc. Prefer ~/.dir_colors<br />
if type -P dircolors &gt;/dev/null ; then<br />
if [[ -f ~/.dir_colors ]] ; then<br />
eval $(dircolors -b ~/.dir_colors)<br />
elif [[ -f /etc/DIR_COLORS ]] ; then<br />
eval $(dircolors -b /etc/DIR_COLORS)<br />
fi<br />
fi<br />
<br />
PS1="$(if [[ ${EUID} == 0 ]]; then echo '\[\033[01;31m\]\h'; else echo '\[\033[01;32m\]\u@\h'; fi)\[\033[01;34m\] \w \$([[ \$? != 0 ]] &amp;&amp; echo \"\[\033[01;31m\]:(\[\033[01;34m\] \")\\$\[\033[00m\] "<br />
<br />
# Use this other PS1 string if you want \W for root and \w for all other users:<br />
# PS1="$(if [[ ${EUID} == 0 ]]; then echo '\[\033[01;31m\]\h\[\033[01;34m\] \W'; else echo '\[\033[01;32m\]\u@\h\[\033[01;34m\] \w'; fi) \$([[ \$? != 0 ]] &amp;&amp; echo \"\[\033[01;31m\]:(\[\033[01;34m\] \")\\$\[\033[00m\] "<br />
<br />
alias ls="ls --color=auto"<br />
alias dir="dir --color=auto"<br />
alias grep="grep --color=auto"<br />
alias dmesg='dmesg --color'<br />
<br />
# Uncomment the "Color" line in /etc/pacman.conf instead of uncommenting the following line...!<br />
<br />
# alias pacman="pacman --color=auto"<br />
<br />
else<br />
<br />
# show root@ when we do not have colors<br />
<br />
PS1="\u@\h \w \$([[ \$? != 0 ]] &amp;&amp; echo \":( \")\$ "<br />
<br />
# Use this other PS1 string if you want \W for root and \w for all other users:<br />
# PS1="\u@\h $(if [[ ${EUID} == 0 ]]; then echo '\W'; else echo '\w'; fi) \$([[ \$? != 0 ]] &amp;&amp; echo \":( \")\$ "<br />
<br />
fi<br />
<br />
PS2="&gt; "<br />
PS3="&gt; "<br />
PS4="+ "<br />
<br />
# Try to keep environment pollution down, EPA loves us.<br />
unset safe_term match_lhs<br />
<br />
# Try to enable the auto-completion (type: "pacman -S bash-completion" to install it).<br />
[ -r /usr/share/bash-completion/bash_completion ] &amp;&amp; . /usr/share/bash-completion/bash_completion<br />
<br />
# Try to enable the "Command not found" hook ("pacman -S pkgfile" to install it).<br />
# See also: https://wiki.archlinux.org/index.php/Bash#The_.22command_not_found.22_hook<br />
[ -r /usr/share/doc/pkgfile/command-not-found.bash ] &amp;&amp; . /usr/share/doc/pkgfile/command-not-found.bash</pre><br />
<br />
====Environment variables====<br />
<br />
There are also other programs which, to be colorized, require the setting of some [[Environment Variables|environment variables]]. This is the case of [[Man Page|man]], for example:<br />
<br />
{{bc|<nowiki>export LESS_TERMCAP_mb=$'\E[01;31m' \<br />
LESS_TERMCAP_md=$'\E[01;38;5;74m' \<br />
LESS_TERMCAP_me=$'\E[0m' \<br />
LESS_TERMCAP_se=$'\E[0m' \<br />
LESS_TERMCAP_so=$'\E[38;5;246m' \<br />
LESS_TERMCAP_ue=$'\E[0m' \<br />
LESS_TERMCAP_us=$'\E[04;38;5;146m' \</nowiki>}}<br />
<br />
For more info, see: [[Environment Variables]].<br />
<br />
===/etc/DIR_COLORS===<br />
<br />
<pre style="max-height: 300px; overflow:auto;"># Configuration file for the color ls utility<br />
# This file goes in the /etc directory, and must be world readable.<br />
# You can copy this file to .dir_colors in your $HOME directory to override<br />
# the system defaults.<br />
<br />
# COLOR needs one of these arguments: 'tty' colorizes output to ttys, but not<br />
# pipes. 'all' adds color characters to all output. 'none' shuts colorization<br />
# off.<br />
COLOR all<br />
<br />
# Extra command line options for ls go here.<br />
# Basically these ones are:<br />
# -F = show '/' for dirs, '*' for executables, etc.<br />
# -T 0 = don't trust tab spacing when formatting ls output.<br />
OPTIONS -F -T 0<br />
<br />
# Below, there should be one TERM entry for each termtype that is colorizable<br />
TERM linux<br />
TERM console<br />
TERM con132x25<br />
TERM con132x30<br />
TERM con132x43<br />
TERM con132x60<br />
TERM con80x25<br />
TERM con80x28<br />
TERM con80x30<br />
TERM con80x43<br />
TERM con80x50<br />
TERM con80x60<br />
TERM xterm<br />
TERM xterm-color<br />
TERM vt100<br />
TERM rxvt<br />
TERM rxvt-256color<br />
TERM rxvt-cygwin<br />
TERM rxvt-cygwin-native<br />
TERM rxvt-unicode<br />
TERM rxvt-unicode-256color<br />
TERM rxvt-unicode256<br />
TERM screen<br />
<br />
# EIGHTBIT, followed by '1' for on, '0' for off. (8-bit output)<br />
EIGHTBIT 1<br />
<br />
# Below are the color init strings for the basic file types. A color init<br />
# string consists of one or more of the following numeric codes:<br />
# Attribute codes: <br />
# 00=none 01=bold 04=underscore 05=blink 07=reverse 08=concealed<br />
# Text color codes:<br />
# 30=black 31=red 32=green 33=yellow 34=blue 35=magenta 36=cyan 37=white<br />
# Background color codes:<br />
# 40=black 41=red 42=green 43=yellow 44=blue 45=magenta 46=cyan 47=white<br />
NORMAL 00 # global default, although everything should be something.<br />
FILE 00 # normal file<br />
DIR 01;34 # directory<br />
LINK 01;36 # symbolic link<br />
FIFO 40;33 # pipe<br />
SOCK 01;35 # socket<br />
BLK 40;33;01 # block device driver<br />
CHR 40;33;01 # character device driver<br />
<br />
# This is for files with execute permission:<br />
EXEC 01;32 <br />
<br />
# List any file extensions like '.gz' or '.tar' that you would like ls<br />
# to colorize below. Put the extension, a space, and the color init string.<br />
# (and any comments you want to add after a '#')<br />
.cmd 01;32 # executables (bright green)<br />
.exe 01;32<br />
.com 01;32<br />
.btm 01;32<br />
.bat 01;32<br />
.tar 01;31 # archives or compressed (bright red)<br />
.tgz 01;31<br />
.arj 01;31<br />
.taz 01;31<br />
.lzh 01;31<br />
.zip 01;31<br />
.z 01;31<br />
.Z 01;31<br />
.gz 01;31<br />
.jpg 01;35 # image formats<br />
.gif 01;35<br />
.bmp 01;35<br />
.xbm 01;35<br />
.xpm 01;35<br />
.tif 01;35</pre><br />
<br />
===/etc/pacman.conf===<br />
<br />
As of version 4.1, Pacman has a '''color''' option. In order to activate it, please, uncomment the {{ic|#Color}} line in {{ic|/etc/pacman.conf}}.<br />
<br />
===/etc/skel/===<br />
<br />
This tip shows you how to use {{ic|/etc/skel/}} directory to ensure that all new users on your system get the same initial settings.<br />
<br />
The {{ic|/etc/skel/}} directory is the directory used by {{ic|useradd}} to create the default settings in a new user's home directory.<br />
<br />
To change the location of {{ic|/etc/skel/}}, edit {{ic|/etc/default/useradd}}.<br />
<br />
{{bc|<nowiki># useradd defaults file <br />
GROUP=100 <br />
HOME=/home <br />
INACTIVE=-1 <br />
EXPIRE= <br />
SHELL=/bin/bash <br />
SKEL=/etc/skel</nowiki>}}<br />
<br />
Typically files included in {{ic|/etc/skel/}} are {{ic|.rc}} files for shell initialization, but you could also include a {{ic|public_html}} directory, a custom {{ic|.dir_colors}} file, or anything else.<br />
<br />
<div style="font-family: monospace; margin: 1em 3em; padding: 1em; border: 3px solid #bcd; background-color: black; color: #fff;"><span style="color: #0a0; font-weight: bold;">andy@alba</span> <span style="color: #55f; font-weight: bold;">/etc/skel $</span> ls -A<br />.bash_logout .bash_profile .bashrc .xinitrc .xsession<br /><span style="color: #0a0; font-weight: bold;">andy@alba</span> <span style="color: #55f; font-weight: bold;">/etc/skel $</span> <span style="text-decoration: blink;">_</span></div><br />
<br />
For more information on customizing the {{ic|/etc/skel/}} directory, type: {{ic|$ man useradd}}. See also: [http://www.gentoo.org/news/en/gwn/20031222-newsletter.xml http://www.gentoo.org/news/en/gwn/20031222-newsletter.xml].<br />
<br />
Now, the {{ic|/etc/skel/.bashrc}} file is the {{ic|.bashrc}} file copyied into the home directory of each ''new'' user. It will look something like this:<br />
<br />
{{bc|<nowiki>#<br />
# ~/.bashrc<br />
#<br />
<br />
# If not running interactively, don't do anything<br />
[[ $- != *i* ]] &amp;&amp; return<br />
<br />
alias ls='ls --color=auto'<br />
PS1='[\u@\h \W]\$ '</nowiki>}}<br />
<br />
As you can see, a {{ic|PS1}} variable (i.e.: the prompt) is exported. So, if you had previously created a color prompt through the {{ic|/etc/bash.bashrc}} file, each user newly created, to see it, should delete the line<br />
<br />
{{bc|<nowiki>PS1='[\u@\h \W]\$ '</nowiki>}}<br />
<br />
from his own {{ic|~/.bashrc}}. Accordingly, if you want to grant to newly created users to have the same colorfull {{ic|PS1}}, you should delete that line from {{ic|/etc/skel/.bashrc}}.<br />
<br />
==Example of cohabitation of /etc/bash.bashrc and ~/.bashrc==<br />
<br />
{{ic|~/.bashrc}} and {{ic|/etc/bash.bashrc}} can also cohabitate. Here is a possible example of a typical Arch user's {{ic|~/.bashrc}} file which can cohabit with the {{ic|/etc/bash.bashrc}} file proposed here, valid for all users. The output will remain coloured.<br />
<br />
{{bc|<nowiki>#<br />
# ~/.bashrc<br />
#<br />
<br />
# If not running interactively, don't do anything<br />
[[ $- != *i* ]] &amp;&amp; return<br />
<br />
# environment variables<br />
export EDITOR="$(if [[ -n $DISPLAY ]]; then echo 'gedit'; else echo 'nano'; fi)" # gedit, nano<br />
<br />
# pacman aliases (if desired, adapt for your favourite AUR helper)<br />
alias pac="sudo /usr/bin/pacman -S" # default action - install one or more packages<br />
alias pacu="sudo /usr/bin/pacman -Syu" # '[u]pdate' - upgrade all packages to their newest version<br />
alias pacr="sudo /usr/bin/pacman -Rns" # '[r]emove' - uninstall one or more packages<br />
alias pacs="/usr/bin/pacman -Ss" # '[s]earch' - search for a package using one or more keywords<br />
alias paci="/usr/bin/pacman -Si" # '[i]nfo' - show information about a package<br />
alias paclo="/usr/bin/pacman -Qdt" # '[l]ist [o]rphans' - list all packages which are orphaned<br />
alias pacc="sudo /usr/bin/pacman -Scc" # '[c]lean cache' - delete all not currently installed package files<br />
alias paclf="/usr/bin/pacman -Ql" # '[l]ist [f]iles' - list all files installed by a given package<br />
alias pacexpl="sudo /usr/bin/pacman -D --asexp" # 'mark as [expl]icit' - mark one or more packages as explicitly installed <br />
alias pacimpl="sudo /usr/bin/pacman -D --asdep" # 'mark as [impl]icit' - mark one or more packages as non explicitly installed<br />
<br />
# '[r]emove [o]rphans' - recursively remove ALL orphaned packages<br />
alias pacro="/usr/bin/pacman -Qtdq > /dev/null && sudo /usr/bin/pacman -Rns \$(/usr/bin/pacman -Qtdq | sed -e ':a;N;$!ba;s/\n/ /g')"</nowiki>}}<br />
<br />
== Random quotations at logon ==<br />
<br />
If you want a random quotation at logon (like Slackware) you must install {{Pkg|fortune-mod}}. fortune is a simple program that displays a pseudorandom message from a database of quotations at logon and/or logout. Uncomment the following line from [[Color_Bash_Prompt#.2Fetc.2Fbash.bashrc|our]] {{ic|/etc/bash.bashrc}} file:<br />
{{bc|<nowiki># [[ "$PS1" ]] &amp;&amp; /usr/bin/fortune</nowiki>}}<br />
<br />
If you want to colorize (brown in this example) the random message from fortune, replace the previous commented text with:<br />
{{bc|<nowiki>[[ "$PS1" ]] &amp;&amp; echo -e "\e[00;33m$(/usr/bin/fortune)\e[00m"</nowiki>}}<br />
<br />
== Colorized Arch latest news at logon ==<br />
<br />
If you want to read the latest news from the [https://www.archlinux.org/news/ Arch official website], instead of a random quotation from fortune, replace the following lines from [[Color_Bash_Prompt#.2Fetc.2Fbash.bashrc|our]] {{ic|/etc/bash.bashrc}} file:<br />
{{bc|<nowiki># fortune is a simple program that displays a pseudorandom message<br />
# from a database of quotations at logon and/or logout.<br />
# If you wish to use it, uncomment the following line:<br />
<br />
# [[ "$PS1" ]] &amp;&amp; /usr/bin/fortune</nowiki>}}<br />
with:<br />
{{bc|<nowiki># Arch latest news<br />
<br />
if [ "$PS1" ]; then<br />
# The characters "&pound;, &sect;" are used as metacharacters. They should not be encountered in a feed...<br />
echo -e "$(echo $(curl --silent https://www.archlinux.org/feeds/news/ | sed -e ':a;N;$!ba;s/\n/ /g') | \<br />
sed -e 's/&amp;amp;/\&amp;/g<br />
s/&amp;lt;\|&amp;#60;/&lt;/g<br />
s/&amp;gt;\|&amp;#62;/&gt;/g<br />
s/&lt;\/a&gt;/&pound;/g<br />
s/href\=\"/&sect;/g<br />
s/&lt;title&gt;/\\n\\n\\n :: \\e[01;31m/g; s/&lt;\/title&gt;/\\e[00m ::\\n/g<br />
s/&lt;link&gt;/ [ \\e[01;36m/g; s/&lt;\/link&gt;/\\e[00m ]/g<br />
s/&lt;description&gt;/\\n\\n\\e[00;37m/g; s/&lt;\/description&gt;/\\e[00m\\n\\n/g<br />
s/&lt;p\( [^&gt;]*\)\?&gt;\|&lt;br\s*\/\?&gt;/\n/g<br />
s/&lt;b\( [^&gt;]*\)\?&gt;\|&lt;strong\( [^&gt;]*\)\?&gt;/\\e[01;30m/g; s/&lt;\/b&gt;\|&lt;\/strong&gt;/\\e[00;37m/g<br />
s/&lt;i\( [^&gt;]*\)\?&gt;\|&lt;em\( [^&gt;]*\)\?&gt;/\\e[41;37m/g; s/&lt;\/i&gt;\|&lt;\/em&gt;/\\e[00;37m/g<br />
s/&lt;u\( [^&gt;]*\)\?&gt;/\\e[4;37m/g; s/&lt;\/u&gt;/\\e[00;37m/g<br />
s/&lt;code\( [^&gt;]*\)\?&gt;/\\e[00m/g; s/&lt;\/code&gt;/\\e[00;37m/g<br />
s/&lt;a[^&sect;|t]*&sect;\([^\"]*\)\"[^&gt;]*&gt;\([^&pound;]*\)[^&pound;]*&pound;/\\e[01;31m\2\\e[00;37m \\e[01;34m[\\e[00;37m \\e[04m\1\\e[00;37m\\e[01;34m ]\\e[00;37m/g<br />
s/&lt;li\( [^&gt;]*\)\?&gt;/\n \\e[01;34m*\\e[00;37m /g<br />
s/&lt;!\[CDATA\[\|\]\]&gt;//g<br />
s/\|&gt;\s*&lt;//g<br />
s/ *&lt;[^&gt;]\+&gt; */ /g<br />
s/[&lt;&gt;&pound;&sect;]//g')\n\n";<br />
fi</nowiki>}}<br />
that is a small and coloured RSS escaping script written by the user [https://aur.archlinux.org/account.php?Action=AccountInfo&ID=33208 grufo] which will display an output like this:<br />
<br />
<div style="height: 350px; overflow: auto; font-family: monospace; margin: 1em 3em; padding: 1em; border: 3px solid #bbccdd; background-color: black; color: #aaaaaa;">&nbsp;&nbsp; <span style="color: #ffffff; font-weight: bold;">::</span> <span style="color: #aa0000; font-weight: bold;">Arch Linux: Recent news updates</span> <span style="color: #ffffff; font-weight: bold;">::</span><br />&nbsp;<span style="color: #ffffff;">[</span> <span style="color: #55ccff; font-weight: bold;"><nowiki>https://www.archlinux.org/news/</nowiki></span> <span style="color: #ffffff;">]</span><br /><br />The latest and greatest news from the Arch Linux distribution.<br /><br />&nbsp;<span style="color: #aa0000; font-weight: bold;">en-us Sun, 04 Nov 2012 16:09:46 +0000</span><br /><br /><br />&nbsp;&nbsp; <span style="color: #ffffff; font-weight: bold;">::</span> <span style="color: #aa0000; font-weight: bold;">End of initscripts support</span> <span style="color: #ffffff; font-weight: bold;">::</span><br />&nbsp;<span style="color: #ffffff;">[</span> <span style="color: #55ccff; font-weight: bold;"><nowiki>https://www.archlinux.org/news/end-of-initscripts-support/</nowiki></span> <span style="color: #ffffff;">]</span><br /><br /><br />Tom Gundersen wrote:<br />As <span style="color: #ffffff;">systemd</span> is now the default init system, Arch Linux is receiving minimal testing on initscripts systems. Due to a lack of resources and interest, we are unlikely to work on fixing <span style="color: #ffffff;">initscripts</span>-specific bugs, and may close them as WONTFIX.<br />We therefore strongly encourage all users to migrate to <span style="color: #ffffff;">systemd</span> as soon as possible. See the <span style="color: #ffffff;">systemd</span> migration guide <span style="color: #5555ff;">[</span> <span style="text-decoration: underline;"><nowiki>https://wiki.archlinux.org/index.php/Systemd</nowiki></span> <span style="color: #5555ff;">]</span>.<br />To ease the transition, <span style="color: #ffffff;">initscripts</span> support will remain in the official repositories for the time being, unless otherwise stated. As of January 2013, we will start removing <span style="color: #ffffff;">initscripts</span> support (e.g., <span style="color: #ffffff;">rc</span> scripts) from individual packages without further notice.<br /><br />&nbsp;<span style="color: #ffffff;">Tom Gundersen Sun, 04 Nov 2012 16:09:46 +0000 tag:www.archlinux.org,2012-11-04:/news/end-of-initscripts-support/</span><br /><br /><br />&nbsp;&nbsp; <span style="color: #ffffff; font-weight: bold;">::</span> <span style="color: #aa0000; font-weight: bold;">November release of install media available</span> <span style="color: #ffffff; font-weight: bold;">::</span><br />&nbsp;<span style="color: #ffffff;">[</span> <span style="color: #55ccff; font-weight: bold;"><nowiki>https://www.archlinux.org/news/november-release-of-install-media-available/</nowiki></span> <span style="color: #ffffff;">]</span><br /><br /><br />Pierre Schmitz wrote:<br />The latest snapshot of our install and rescue media can be found on our <span style="color: #aa0000; font-weight: bold;">Download</span> <span style="color: #5555ff;">[</span> <span style="text-decoration: underline;"><nowiki>https://www.archlinux.org/download/</nowiki></span> <span style="color: #5555ff;">]</span> page. The 2012.11.01 ISO image mainly contains minor bug fixes, cleanups and new packages compared to the previous one:<br />&nbsp;<span style="color: #5555ff;">*</span> First media with Linux 3.6<br />&nbsp;<span style="color: #5555ff;">*</span> <span style="background-color: #aa0000;">copytoram=n</span> can be used to not copy the image to RAM on network boot. This is probably unreliable but an option for systems with very low memory.<br />&nbsp;<span style="color: #5555ff;">*</span> <span style="background-color: #aa0000;">cowfile_size</span> boot parameter mainly for persistent COW on VFAT. See the <span style="color: #aa0000; font-weight: bold;">README</span> <span style="color: #5555ff;">[</span> <span style="text-decoration: underline;"><nowiki>https://projects.archlinux.org/archiso.git/plain/docs/README.bootparams?id=v4</nowiki></span> <span style="color: #5555ff;">]</span> file for details.<br /><br />&nbsp;<span style="color: #ffffff;">Pierre Schmitz Fri, 02 Nov 2012 17:54:15 +0000 tag:www.archlinux.org,2012-11-02:/news/november-release-of-install-media-available/</span><br /><br /><br />&nbsp;&nbsp; <span style="color: #ffffff; font-weight: bold;">::</span> <span style="color: #aa0000; font-weight: bold;">Bug Squashing Day: Saturday 17th November</span> <span style="color: #ffffff; font-weight: bold;">::</span><br />&nbsp;<span style="color: #ffffff;">[</span> <span style="color: #55ccff; font-weight: bold;"><nowiki>https://www.archlinux.org/news/bug-squashing-day-saturday-17th-november/</nowiki></span> <span style="color: #ffffff;">]</span><br /><br /><br />Allan McRae wrote:<br />The number of bugs in the Arch Linux bug tracker is creeping up so it is time for some extermination.<br />This is a great way for the community to get involved and help the Arch Linux team. The process is simple. First look at a bug for your favorite piece of software in the bug tracker and check if it still occurs. If it does, check the upstream project for a fix and test it to confirm it works. If there is no fix available, make sure the bug has been filed in the upstream tracker.<br />Join us on the #archlinux-bugs IRC channel. We are spread across timezones, so people should be around all day.<br /><br />&nbsp;<span style="color: #ffffff;">Allan McRae Thu, 01 Nov 2012 12:28:51 +0000 tag:www.archlinux.org,2012-11-01:/news/bug-squashing-day-saturday-17th-november/</span><br /><br /><br />&nbsp;&nbsp; <span style="color: #ffffff; font-weight: bold;">::</span> <span style="color: #aa0000; font-weight: bold;">ConsoleKit replaced by logind</span> <span style="color: #ffffff; font-weight: bold;">::</span><br />&nbsp;<span style="color: #ffffff;">[</span> <span style="color: #55ccff; font-weight: bold;"><nowiki>https://www.archlinux.org/news/consolekit-replaced-by-logind/</nowiki></span> <span style="color: #ffffff;">]</span><br /><br /><br />Allan McRae wrote:<br />With GNOME 3.6, polkit and networkmanager moving to [extra], ConsoleKit has now been removed from the repositories. Any package that previously depended on it now relies on systemd-logind instead. That means that the system must be booted with systemd to be fully functional.<br />In addition to GNOME, both KDE and XFCE are also affected by this change.<br /><br />&nbsp;<span style="color: #ffffff;">Allan McRae Tue, 30 Oct 2012 22:17:39 +0000 tag:www.archlinux.org,2012-10-30:/news/consolekit-replaced-by-logind/</span><br /><br /><br />&nbsp;&nbsp; <span style="color: #ffffff; font-weight: bold;">::</span> <span style="color: #aa0000; font-weight: bold;">systemd is now the default on new installations</span> <span style="color: #ffffff; font-weight: bold;">::</span><br />&nbsp;<span style="color: #ffffff;">[</span> <span style="color: #55ccff; font-weight: bold;"><nowiki>https://www.archlinux.org/news/systemd-is-now-the-default-on-new-installations/</nowiki></span> <span style="color: #ffffff;">]</span><br /><br /><br />Thomas B&auml;chler wrote:<br />The base group now contains the <span style="color: #ffffff;">systemd-sysvcompat</span> package. This means that all new installations will boot with systemd by default.<br />As some packages still lack native systemd units, users can install the <span style="color: #ffffff;">initscripts</span> package and use the <span style="color: #ffffff;">DAEMONS</span> array in <span style="color: #ffffff;">/etc/rc.conf</span> to start services using the legacy rc.d scripts.<br />This change does not affect existing installations. For the time being, the <span style="color: #ffffff;">initscripts</span> and <span style="color: #ffffff;">sysvinit</span> packages remain available from our repositories. However, individual packages may now start relying on the system being booted with systemd.<br />Please refer to <span style="color: #aa0000; font-weight: bold;">the wiki</span> <span style="color: #5555ff;">[</span> <span style="text-decoration: underline;"><nowiki>https://wiki.archlinux.org/index.php/Systemd</nowiki></span> <span style="color: #5555ff;">]</span> for how to transition an existing installation to systemd.<br /><br />&nbsp;<span style="color: #ffffff;">Thomas B&auml;chler Sat, 13 Oct 2012 09:29:38 +0000 tag:www.archlinux.org,2012-10-13:/news/systemd-is-now-the-default-on-new-installations/</span><br /><br /><br />&nbsp;&nbsp; <span style="color: #ffffff; font-weight: bold;">::</span> <span style="color: #aa0000; font-weight: bold;">Install medium 2012.10.06 introduces systemd</span> <span style="color: #ffffff; font-weight: bold;">::</span><br />&nbsp;<span style="color: #ffffff;">[</span> <span style="color: #55ccff; font-weight: bold;"><nowiki>https://www.archlinux.org/news/install-medium-20121006-introduces-systemd/</nowiki></span> <span style="color: #ffffff;">]</span><br /><br /><br />Pierre Schmitz wrote:<br />The October release of the Arch Linux install medium is available for <span style="color: #aa0000; font-weight: bold;">Download</span> <span style="color: #5555ff;">[</span> <span style="text-decoration: underline;"><nowiki>https://www.archlinux.org/download/</nowiki></span> <span style="color: #5555ff;">]</span> and can be used for new installs or as a rescue system. It contains a set of updated packages and the following notable changes:<br />&nbsp;<span style="color: #5555ff;">*</span> systemd is used to boot up the live system.<br />&nbsp;<span style="color: #5555ff;">*</span> initscripts are no longer available on the live system but are still installed by default on the target system. This is likely to change in the near future.<br />&nbsp;<span style="color: #5555ff;">*</span> EFI boot and setup has been simplified.<br />&nbsp;<span style="color: #5555ff;">*</span> gummiboot is used to display a menu on EFI systems.<br />&nbsp;<span style="color: #5555ff;">*</span> The following new packages are available on the live system: ethtool, fsarchiver, gummiboot-efi, mc, partclone, partimage, refind-efi, rfkill, sudo, testdisk, wget, xl2tpd<br /><br />&nbsp;<span style="color: #ffffff;">Pierre Schmitz Sun, 07 Oct 2012 16:58:03 +0000 tag:www.archlinux.org,2012-10-07:/news/install-medium-20121006-introduces-systemd/</span><br /><br /><br />&nbsp;&nbsp; <span style="color: #ffffff; font-weight: bold;">::</span> <span style="color: #aa0000; font-weight: bold;">New install medium 2012.09.07</span> <span style="color: #ffffff; font-weight: bold;">::</span><br />&nbsp;<span style="color: #ffffff;">[</span> <span style="color: #55ccff; font-weight: bold;"><nowiki>https://www.archlinux.org/news/new-install-medium-20120907/</nowiki></span> <span style="color: #ffffff;">]</span><br /><br /><br />Pierre Schmitz wrote:<br />As is customary by now there is a new install medium available at the beginning of this month. The live system can be downloaded from <span style="color: #aa0000; font-weight: bold;">Download</span> <span style="color: #5555ff;">[</span> <span style="text-decoration: underline;"><nowiki>https://www.archlinux.org/download/</nowiki></span> <span style="color: #5555ff;">]</span> and be used for new installs or as a rescue system.<br />In addition to a couple of updated packages and bug fixes the following changes stand out:<br />&nbsp;<span style="color: #5555ff;">*</span> First medium with Linux 3.5 (3.5.3)<br />&nbsp;<span style="color: #5555ff;">*</span> The <span style="background-color: #aa0000;">script</span> boot parameter works again (<span style="color: #aa0000; font-weight: bold;">FS#31022</span> <span style="color: #5555ff;">[</span> <span style="text-decoration: underline;"><nowiki>https://bugs.archlinux.org/task/31022</nowiki></span> <span style="color: #5555ff;">]</span>)<br />&nbsp;<span style="color: #5555ff;">*</span> When booting via PXE and NFS or NBD the ISO will be copied to RAM to ensure a more stable usage.<br />&nbsp;<span style="color: #5555ff;">*</span> The live medium contains <span style="background-color: #aa0000;">usb_modeswitch</span> and <span style="background-color: #aa0000;">wvdial</span> which e.g. allows to establish a network connection using an UMTS USB dongle<br />&nbsp;<span style="color: #5555ff;">*</span> Furthermore the newest versions of <span style="background-color: #aa0000;">initscripts</span>, <span style="background-color: #aa0000;">systemd</span> and <span style="background-color: #aa0000;">netcfg</span> are included.<br /><br />&nbsp;<span style="color: #ffffff;">Pierre Schmitz Sat, 08 Sep 2012 09:48:52 +0000 tag:www.archlinux.org,2012-09-08:/news/new-install-medium-20120907/</span><br /><br /><br />&nbsp;&nbsp; <span style="color: #ffffff; font-weight: bold;">::</span> <span style="color: #aa0000; font-weight: bold;">Fontconfig 2.10.1 update - manual intervention required</span> <span style="color: #ffffff; font-weight: bold;">::</span><br />&nbsp;<span style="color: #ffffff;">[</span> <span style="color: #55ccff; font-weight: bold;"><nowiki>https://www.archlinux.org/news/fontconfig-2101-update-manual-intervention-required/</nowiki></span> <span style="color: #ffffff;">]</span><br /><br /><br />Andreas Radke wrote:<br />The fontconfig 2.10.1 update overwrites symlinks created by the former package version. These symlinks need to be removed before the update:<br /><br /><span style="color: #ffffff;">rm /etc/fonts/conf.d/20-unhint-small-vera.conf</span><br /><span style="color: #ffffff;">rm /etc/fonts/conf.d/20-fix-globaladvance.conf</span><br /><span style="color: #ffffff;">rm /etc/fonts/conf.d/29-replace-bitmap-fonts.conf</span><br /><span style="color: #ffffff;">rm /etc/fonts/conf.d/30-metric-aliases.conf</span><br /><span style="color: #ffffff;">rm /etc/fonts/conf.d/30-urw-aliases.conf</span><br /><span style="color: #ffffff;">rm /etc/fonts/conf.d/40-nonlatin.conf</span><br /><span style="color: #ffffff;">rm /etc/fonts/conf.d/45-latin.conf</span><br /><span style="color: #ffffff;">rm /etc/fonts/conf.d/49-sansserif.conf</span><br /><span style="color: #ffffff;">rm /etc/fonts/conf.d/50-user.conf</span><br /><span style="color: #ffffff;">rm /etc/fonts/conf.d/51-local.conf</span><br /><span style="color: #ffffff;">rm /etc/fonts/conf.d/60-latin.conf</span><br /><span style="color: #ffffff;">rm /etc/fonts/conf.d/65-fonts-persian.conf</span><br /><span style="color: #ffffff;">rm /etc/fonts/conf.d/65-nonlatin.conf</span><br /><span style="color: #ffffff;">rm /etc/fonts/conf.d/69-unifont.conf</span><br /><span style="color: #ffffff;">rm /etc/fonts/conf.d/80-delicious.conf</span><br /><span style="color: #ffffff;">rm /etc/fonts/conf.d/90-synthetic.conf</span><br /><span style="color: #ffffff;">pacman -Syu fontconfig</span><br /><br />Main systemwide configuration should be done by symlinks (especially for autohinting, sub-pixel and lcdfilter):<br /><br /><span style="color: #ffffff;">cd /etc/fonts/conf.d</span><br /><span style="color: #ffffff;">ln -s ../conf.avail/XX-foo.conf</span><br /><br />Also check <span style="color: #aa0000; font-weight: bold;">Font Configuration</span> <span style="color: #5555ff;">[</span> <span style="text-decoration: underline;"><nowiki>https://wiki.archlinux.org/index.php/Font_Configuration</nowiki></span> <span style="color: #5555ff;">]</span> and <span style="color: #aa0000; font-weight: bold;">Fonts</span> <span style="color: #5555ff;">[</span> <span style="text-decoration: underline;"><nowiki>https://wiki.archlinux.org/index.php/Fonts</nowiki></span> <span style="color: #5555ff;">]</span>.<br /><br />&nbsp;<span style="color: #ffffff;">Andreas Radke Thu, 06 Sep 2012 13:54:23 +0000 tag:www.archlinux.org,2012-09-06:/news/fontconfig-2101-update-manual-intervention-required/</span><br /><br /><br />&nbsp;&nbsp; <span style="color: #ffffff; font-weight: bold;">::</span> <span style="color: #aa0000; font-weight: bold;">netcfg-2.8.9 drops deprecated rc.conf compatibility</span> <span style="color: #ffffff; font-weight: bold;">::</span><br />&nbsp;<span style="color: #ffffff;">[</span> <span style="color: #55ccff; font-weight: bold;"><nowiki>https://www.archlinux.org/news/netcfg-289-drops-initscripts-compatibility/</nowiki></span> <span style="color: #ffffff;">]</span><br /><br /><br />Florian Pritz wrote:<br />Users of <span style="color: #ffffff;">netcfg</span> should configure all interfaces in <span style="color: #ffffff;">/etc/conf.d/netcfg</span> rather than <span style="color: #ffffff;">/etc/rc.conf</span>.<br /><br />&nbsp;Florian Pritz Sat, 11 Aug 2012 20:00:02 +0000 tag:www.archlinux.org,2012-08-11:/news/netcfg-289-drops-initscripts-compatibility/<br /><br /><br />&nbsp;&nbsp; <span style="color: #ffffff; font-weight: bold;">::</span> <span style="color: #aa0000; font-weight: bold;">Install media 2012.08.04 available</span> <span style="color: #ffffff; font-weight: bold;">::</span><br />&nbsp;<span style="color: #ffffff;">[</span> <span style="color: #55ccff; font-weight: bold;"><nowiki>https://www.archlinux.org/news/install-media-20120804-available/</nowiki></span> <span style="color: #ffffff;">]</span><br /><br /><br />Pierre Schmitz wrote:<br />The August snapshot of our live and install media comes with updated packages and the following changes on top of the <span style="color: #aa0000; font-weight: bold;">previous ISO image</span> <span style="color: #5555ff;">[</span> <span style="text-decoration: underline;">/news/install-media-20120715-released/</span> <span style="color: #5555ff;">]</span>:<br />&nbsp;<span style="color: #5555ff;">*</span> GRUB 2.0 instead of the legacy 0.9 version is available.<br />&nbsp;<span style="color: #5555ff;">*</span> The <span style="color: #aa0000; font-weight: bold;">Installation Guide</span> <span style="color: #5555ff;">[</span> <span style="text-decoration: underline;"><nowiki>https://wiki.archlinux.org/index.php/Installation_Guide</nowiki></span> <span style="color: #5555ff;">]</span> can be found at <span style="background-color: #aa0000;">/root/install.txt</span>.<br />&nbsp;<span style="color: #5555ff;">*</span> ZSH with <span style="color: #aa0000; font-weight: bold;">Grml's configuration</span> <span style="color: #5555ff;">[</span> <span style="text-decoration: underline;"><nowiki>http://grml.org/zsh/</nowiki></span> <span style="color: #5555ff;">]</span> is used as interactive shell to provide a user friendly and more convenient environment. This includes completion support for pacstrap, arch-chroot, pacman and most other tools.<br />&nbsp;<span style="color: #5555ff;">*</span> The network daemon is started by default which will automatically setup your network if DHCP is available.<br />Note that all these changes only affect the live system and not the base system you install using pacstrap. The ISO image can be downloaded from our <span style="color: #aa0000; font-weight: bold;">download page</span> <span style="color: #5555ff;">[</span> <span style="text-decoration: underline;">/download/</span> <span style="color: #5555ff;">]</span>. The next snapshot is scheduled for September.<br /><br />&nbsp;<span style="color: #ffffff;">Pierre Schmitz Sat, 04 Aug 2012 17:24:30 +0000 tag:www.archlinux.org,2012-08-04:/news/install-media-20120804-available/</span><br /><br /><br /><span style="color: #0a0; font-weight: bold;">andy@alba</span> <span style="text-decoration: blink;">_</span></div><br />
<br />
If you don't want to see months worth of updates but only the latest item, you can use this::<br />
{{bc|<nowiki># Arch latest news<br />
<br />
if [ "$PS1" ]; then<br />
# The characters "&pound;, &sect;" are used as metacharacters. They should not be encountered in a feed...<br />
echo -e "$(echo $(curl --silent https://www.archlinux.org/feeds/news/ | awk ' NR == 1 {while ($0 !~ /<\/item>/) {print;getline} sub(/<\/item>.*/,"</item>") ;print}' | sed -e ':a;N;$!ba;s/\n/ /g') | \<br />
sed -e 's/&amp;amp;/\&amp;/g<br />
s/&amp;lt;\|&amp;#60;/&lt;/g<br />
s/&amp;gt;\|&amp;#62;/&gt;/g<br />
s/&lt;\/a&gt;/&pound;/g<br />
s/href\=\"/&sect;/g<br />
s/&lt;title&gt;/\\n\\n\\n :: \\e[01;31m/g; s/&lt;\/title&gt;/\\e[00m ::\\n/g<br />
s/&lt;link&gt;/ [ \\e[01;36m/g; s/&lt;\/link&gt;/\\e[00m ]/g<br />
s/&lt;description&gt;/\\n\\n\\e[00;37m/g; s/&lt;\/description&gt;/\\e[00m\\n\\n/g<br />
s/&lt;p\( [^&gt;]*\)\?&gt;\|&lt;br\s*\/\?&gt;/\n/g<br />
s/&lt;b\( [^&gt;]*\)\?&gt;\|&lt;strong\( [^&gt;]*\)\?&gt;/\\e[01;30m/g; s/&lt;\/b&gt;\|&lt;\/strong&gt;/\\e[00;37m/g<br />
s/&lt;i\( [^&gt;]*\)\?&gt;\|&lt;em\( [^&gt;]*\)\?&gt;/\\e[41;37m/g; s/&lt;\/i&gt;\|&lt;\/em&gt;/\\e[00;37m/g<br />
s/&lt;u\( [^&gt;]*\)\?&gt;/\\e[4;37m/g; s/&lt;\/u&gt;/\\e[00;37m/g<br />
s/&lt;code\( [^&gt;]*\)\?&gt;/\\e[00m/g; s/&lt;\/code&gt;/\\e[00;37m/g<br />
s/&lt;a[^&sect;|t]*&sect;\([^\"]*\)\"[^&gt;]*&gt;\([^&pound;]*\)[^&pound;]*&pound;/\\e[01;31m\2\\e[00;37m \\e[01;34m[\\e[00;37m \\e[04m\1\\e[00;37m\\e[01;34m ]\\e[00;37m/g<br />
s/&lt;li\( [^&gt;]*\)\?&gt;/\n \\e[01;34m*\\e[00;37m /g<br />
s/&lt;!\[CDATA\[\|\]\]&gt;//g<br />
s/\|&gt;\s*&lt;//g<br />
s/ *&lt;[^&gt;]\+&gt; */ /g<br />
s/[&lt;&gt;&pound;&sect;]//g')\n\n";<br />
fi</nowiki>}}<br />
<br />
See [https://bbs.archlinux.org/viewtopic.php?id=146850 this thread] for details.<br />
<br />
==Variations on a theme==<br />
<br />
Here are some {{ic|PS1}} variables (i.e.: prompts) with different layout to be applyied to [[Color_Bash_Prompt#.2Fetc.2Fbash.bashrc|our]] {{ic|/etc/bash.bashrc}} file. When you choose a layout you must replace the following lines from [[Color_Bash_Prompt#.2Fetc.2Fbash.bashrc|our]] {{ic|/etc/bash.bashrc}} file:<br />
<br />
{{bc|<nowiki> PS1="$(if [[ ${EUID} == 0 ]]; then echo '\[\033[01;31m\]\h'; else echo '\[\033[01;32m\]\u@\h'; fi)\[\033[01;34m\] \w \$([[ \$? != 0 ]] &amp;&amp; echo \"\[\033[01;31m\]:(\[\033[01;34m\] \")\$\[\033[00m\] "<br />
<br />
# Use this other PS1 string if you want \W for root and \w for all other users:<br />
# PS1="$(if [[ ${EUID} == 0 ]]; then echo '\[\033[01;31m\]\h\[\033[01;34m\] \W'; else echo '\[\033[01;32m\]\u@\h\[\033[01;34m\] \w'; fi) \$([[ \$? != 0 ]] &amp;&amp; echo \"\[\033[01;31m\]:(\[\033[01;34m\] \")\$\[\033[00m\] "</nowiki>}}<br />
<br />
with the {{ic|PS1}} variable (and possibly other code lines) given by the choosen layout.<br />
<br />
===From Arch Forum #1===<br />
<br />
Here is an unicode variation of [[Color_Bash_Prompt#.2Fetc.2Fbash.bashrc|our]] {{ic|/etc/bash.bashrc}} file freely based on [https://bbs.archlinux.org/viewtopic.php?pid=1068202#p1068202 what wrote the user JeSuisNerd and others in the Arch Forum]. Here is a preview of how it will appear:<br />
<br />
<div style="font-family: monospace; margin: 1em 3em; padding: 1em; border: 3px solid #bcd; background-color: black; color: #fff; font-size: 14px; line-height: 17px;">I am two with nature.<br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;-- Woody Allen<br /><span style="color: #aaa;">&#9484;&#9472;[</span><span style="color: #f90;">andy</span>@<span style="color: #5fc;">alba</span><span style="color: #aaa;">]&#9472;[</span><span style="color: #0c0;">~</span><span style="color: #aaa;">]</span><br /><span style="color: #aaa;">&#9492;&#9472;&#9472;&#9596;</span> ls<br /><span style="color: #55f; font-weight: bold;">Desktop Documents Music</span> public.desktop<br /><span style="color: #aaa;">&#9484;&#9472;[</span><span style="color: #f90;">andy</span>@<span style="color: #5fc;">alba</span><span style="color: #aaa;">]&#9472;[</span><span style="color: #0c0;">~</span><span style="color: #aaa;">]</span><br /><span style="color: #aaa;">&#9492;&#9472;&#9472;&#9596;</span>&nbsp;I\ will\ try\ to\ type\ a\ wrong\ command...<br />bash: I will try to type a wrong command...: command not found<br /><span style="color: #aaa;">&#9484;&#9472;[<span style="color: #a00;">&#10007;</span>]&#9472;[</span><span style="color: #f90;">andy</span>@<span style="color: #5fc;">alba</span><span style="color: #aaa;">]&#9472;[</span><span style="color: #0c0;">~</span><span style="color: #aaa;">]</span><br /><span style="color: #aaa;">&#9492;&#9472;&#9472;&#9596;</span> echo 'Hello world!' Hello world!<br /><span style="color: #aaa;">&#9484;&#9472;[</span><span style="color: #f90;">andy</span>@<span style="color: #5fc;">alba</span><span style="color: #aaa;">]&#9472;[</span><span style="color: #0c0;">~</span><span style="color: #aaa;">]</span><br /><span style="color: #aaa;">&#9492;&#9472;&#9472;&#9596;</span>&nbsp;su<br />Password:<br />Two can Live as Cheaply as One for Half as Long.<br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;-- Howard Kandel<br /><span style="color: #aaa;">&#9484;&#9472;[<span style="color: #a00;">alba</span>]</span><span style="color: #aaa;">&#9472;[</span><span style="color: #0c0;">~</span><span style="color: #aaa;">]</span><br /><span style="color: #aaa;">&#9492;&#9472;&#9472;&#9596;</span>&nbsp;<span style="text-decoration: blink;">_</span></div><br />
<br />
'''Note:''' '''Some unicode symbols (like <span style="color: #a00;">✗</span> and ╼) are not well supported in some terminals''' (in linux console, for example), so this prompt will appear a bit different depending on where is displayed. If you want to know the unicode representation of a plain text, [http://0xcc.net/jsescape/ here] you have a little plain text converter.<br />
<br />
And finally here is the {{ic|PS1}} variable for this effect to be applyied to [[Color_Bash_Prompt#.2Fetc.2Fbash.bashrc|our]] {{ic|/etc/bash.bashrc}} file (see [[Color_Bash_Prompt#Variations_on_a_theme|above]]):<br />
<br />
{{bc|<nowiki> # https://bbs.archlinux.org/viewtopic.php?pid=1068202#p1068202<br />
PS1="\[\033[0;37m\]\342\224\214\342\224\200\$([[ \$? != 0 ]] &amp;&amp; echo \"[\[\033[0;31m\]\342\234\227\[\033[0;37m\]]\342\224\200\")[$(if [[ ${EUID} == 0 ]]; then echo '\[\033[0;31m\]\h'; else echo '\[\033[0;33m\]\u\[\033[0;37m\]@\[\033[0;96m\]\h'; fi)\[\033[0;37m\]]\342\224\200[\[\033[0;32m\]\w\[\033[0;37m\]]\n\[\033[0;37m\]\342\224\224\342\224\200\342\224\200\342\225\274 \[\033[0m\]"</nowiki>}}<br />
<br />
===From an italian blog&hellip;===<br />
<br />
Here is an unicode variation of [[Color_Bash_Prompt#.2Fetc.2Fbash.bashrc|our]] {{ic|/etc/bash.bashrc}} file freely based on [http://dark-linux.net/personalizzare-bashrc-eo-bash-bashrc/ an italian blog]. Here is a preview of how it will appear:<br />
<br />
<div style="font-family: monospace; margin: 1em 3em; padding: 1em; border: 3px solid #bcd; background-color: black; color: #fff; font-size: 14px; line-height: 17px;">I am two with nature.<br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;-- Woody Allen<br /><span style="color: #55f;">&#9484;&#9472;[</span>12:03:20<span style="color: #55f;">]&#9472;[</span>andy@alba<span style="color: #55f;">]<br /></span><span style="color: #55f;">&#9492;&#9472;&#9472;&gt;</span> ~ <span style="color: #55f;">$</span> ls<br /><span style="color: #55f; font-weight: bold;">Desktop Documents Music</span> public.desktop<br /><span style="color: #55f;">&#9484;&#9472;[</span>12:03:31<span style="color: #55f;">]&#9472;[</span>andy@alba<span style="color: #55f;">]</span><br /><span style="color: #55f;">&#9492;&#9472;&#9472;&gt;</span> ~ <span style="color: #55f;">$</span> I\ will\ try\ to\ type\ a\ wrong\ command...<br />bash: I will try to type a wrong command...: command not found<br /><span style="color: #55f;">&#9484;&#9472;[</span>&#10007;<span style="color: #55f;">]&#9472;[</span>12:04:01<span style="color: #55f;">]&#9472;[</span>andy@alba<span style="color: #55f;">]<br /></span><span style="color: #55f;">&#9492;&#9472;&#9472;&gt;</span> ~ <span style="color: #55f;">$</span> echo 'Hello world!'<br />Hello world!<br /><span style="color: #55f;">&#9484;&#9472;[</span>12:04:13<span style="color: #55f;">]&#9472;[</span>andy@alba<span style="color: #55f;">]<br /></span><span style="color: #55f;">&#9492;&#9472;&#9472;&gt;</span> ~ <span style="color: #55f;">$</span> su<br />Password:<br />Two can Live as Cheaply as One for Half as Long.<br /> &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;-- Howard Kandel<br /><span style="color: #a00;">&#9484;&#9472;[</span>12:04:21<span style="color: #a00;">]&#9472;[</span>root@alba<span style="color: #a00;">]<br /></span><span style="color: #a00;">&#9492;&#9472;&#9472;&gt;</span> ~ <span style="color: #a00;">$</span> <span style="text-decoration: blink;">_</span></div><br />
<br />
'''Note:''' '''Some unicode symbols (like ✗) are not well supported in some terminals''' (in linux console, for example), so this prompt will appear a bit different depending on where is displayed. If you want to know the unicode representation of a plain text, [http://0xcc.net/jsescape/ here] you have a little plain text converter.<br />
<br />
And finally here is the {{ic|PS1}} variable for this effect to be applyied to [[Color_Bash_Prompt#.2Fetc.2Fbash.bashrc|our]] {{ic|/etc/bash.bashrc}} file (see [[Color_Bash_Prompt#Variations_on_a_theme|above]]):<br />
<br />
{{bc|<nowiki> if [[ ${EUID} == 0 ]] ; then<br />
sq_color="\[\033[0;31m\]"<br />
else <br />
sq_color="\[\033[0;34m\]"<br />
fi<br />
<br />
PS1="$sq_color\342\224\214\342\224\200\$([[ \$? != 0 ]] &amp;&amp; echo \"[\[\033[01;37m\]\342\234\227$sq_color]\342\224\200\")[\[\033[01;37m\]\t$sq_color]\342\224\200[\[\033[01;37m\]\u@\h$sq_color]\n\342\224\224\342\224\200\342\224\200&gt; \[\033[01;37m\]\W$sq_color $ \[\033[01;37m\]&gt;&gt;\\[\\033[0m\\] "<br />
<br />
unset sq_color</nowiki>}}<br />
<br />
===From Arch Forum #2===<br />
<br />
Here is another variation of [[Color_Bash_Prompt#.2Fetc.2Fbash.bashrc|our]] {{ic|/etc/bash.bashrc}} file freely based on [https://bbs.archlinux.org/viewtopic.php?pid=1156660#p1156660 what wrote the user shumer1213 and others in the Arch Forum]. Here is a preview of how it will appear:<br />
<br />
<div style="font-family: monospace; margin: 1em 3em; padding: 1em; border: 3px solid #bcd; background-color: black; color: #fff; font-size: 14px; line-height: 17px;">I am two with nature.<br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;-- Woody Allen<br /><br /><span style="color: #5555ff;">&#9608;&#9608; [ ~ ] [ 18:05:58 ]</span><br />&#9608;&#9608; ls<br /><span style="color: #55f; font-weight: bold;">Desktop Documents Music</span> public.desktop<br /><br /><span style="color: #5555ff;">&#9608;&#9608; [ ~ ] [ 18:06:02 ]</span><br />&#9608;&#9608; I\ will\ try\ to\ type\ a\ wrong\ command...<br />bash: I will try to type a wrong command...: command not found<br /><br /><span style="color: #aa0000;">&#9608;&#9608; [ ~ ] [ 18:06:12 ]</span><br />&#9608;&#9608; echo 'Hello world!'<br />Hello world!<br /><br /><span style="color: #5555ff;">&#9608;&#9608; [ ~ ] [ 18:06:17 ]</span><br />&#9608;&#9608; su<br />Password: <br />Two can Live as Cheaply as One for Half as Long.<br /> &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;-- Howard Kandel<br /><br /><span style="color: #5555ff;">&#9608;&#9608; [ andy ] [ 18:06:26 ]</span><br />&#9608;&#9608; <span style="text-decoration: blink;">_</span></div><br />
<br />
Here is the {{ic|PS1}} variable for this effect to be applyied to [[Color_Bash_Prompt#.2Fetc.2Fbash.bashrc|our]] {{ic|/etc/bash.bashrc}} file (see [[Color_Bash_Prompt#Variations_on_a_theme|above]]):<br />
<br />
{{bc|<nowiki> # https://bbs.archlinux.org/viewtopic.php?pid=1156660#p1156660<br />
PS1="\n\$(if [[ \$? == 0 ]]; then echo \"\[\033[0;34m\]\"; else echo \"\[\033[0;31m\]\"; fi)\342\226\210\342\226\210 [ \W ] [ \t ]\n\[\033[0m\]\342\226\210\342\226\210 "</nowiki>}}<br />
<br />
===With directory information===<br />
<br />
Here are other three variations of [[Color_Bash_Prompt#.2Fetc.2Fbash.bashrc|our]] {{ic|/etc/bash.bashrc}} file freely based on the article [http://maketecheasier.com/8-useful-and-interesting-bash-prompts/2009/09/04 8 Useful and Interesting Bash Prompts]. Here is a preview of how they will appear:<br />
<br />
====Version #1: with numerical error====<br />
<br />
<div style="font-family: monospace; margin: 1em 3em; padding: 1em; border: 3px solid #bcd; background-color: black; color: #fff; font-size: 14px; line-height: 17px;">I am two with nature.<br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;-- Woody Allen<br /><br /><span style="font-weight: bold;">&#9484;(</span><span style="font-weight: bold; color: #5555ff;">andy@alba</span><span style="font-weight: bold;">)&#9472;(</span><span style="font-weight: bold; color: #5555ff;">0</span><span style="font-weight: bold;">)&#9472;(</span><span style="font-weight: bold; color: #5555ff;">02:38 PM Sat Aug 29</span><span style="font-weight: bold;">)</span><br /><span style="font-weight: bold;">&#9492;&#9472;(</span><span style="font-weight: bold; color: #00cc00;">~</span><span style="font-weight: bold;">)&#9472;(</span><span style="font-weight: bold; color: #00cc00;">4 files, 332Kb</span><span style="font-weight: bold;">)&#9472;&gt;</span> ls<br /><span style="color: #55f; font-weight: bold;">Desktop Documents Music</span> myScript.js<br /><br /><span style="font-weight: bold;">&#9484;(</span><span style="font-weight: bold; color: #5555ff;">andy@alba</span><span style="font-weight: bold;">)&#9472;(</span><span style="font-weight: bold; color: #5555ff;">0</span><span style="font-weight: bold;">)&#9472;(</span><span style="font-weight: bold; color: #5555ff;">02:38 PM Sat Aug 29</span><span style="font-weight: bold;">)</span><br /><span style="font-weight: bold;">&#9492;&#9472;(</span><span style="font-weight: bold; color: #00cc00;">~</span><span style="font-weight: bold;">)&#9472;(</span><span style="font-weight: bold; color: #00cc00;">4 files, 332Kb</span><span style="font-weight: bold;">)&#9472;&gt;</span> I\ will\ try\ to\ type\ a\ wrong\ command...<br />bash: I will try to type a wrong command...: command not found<br /><br /><span style="font-weight: bold;">&#9484;(</span><span style="font-weight: bold; color: #5555ff;">andy@alba</span><span style="font-weight: bold;">)&#9472;(</span><span style="font-weight: bold; color: #5555ff;">127</span><span style="font-weight: bold;">)&#9472;(</span><span style="font-weight: bold; color: #5555ff;">02:39 PM Sat Aug 29</span><span style="font-weight: bold;">)</span><br /><span style="font-weight: bold;">&#9492;&#9472;(</span><span style="font-weight: bold; color: #00cc00;">~</span><span style="font-weight: bold;">)&#9472;(</span><span style="font-weight: bold; color: #00cc00;">4 files, 332Kb</span><span style="font-weight: bold;">)&#9472;&gt;</span> echo 'Hello world!'<br />Hello world!<br /><br /><span style="font-weight: bold;">&#9484;(</span><span style="font-weight: bold; color: #5555ff;">andy@alba</span><span style="font-weight: bold;">)&#9472;(</span><span style="font-weight: bold; color: #5555ff;">0</span><span style="font-weight: bold;">)&#9472;(</span><span style="font-weight: bold; color: #5555ff;">02:39 PM Sat Aug 29</span><span style="font-weight: bold;">)</span><br /><span style="font-weight: bold;">&#9492;&#9472;(</span><span style="font-weight: bold; color: #00cc00;">~</span><span style="font-weight: bold;">)&#9472;(</span><span style="font-weight: bold; color: #00cc00;">4 files, 332Kb</span><span style="font-weight: bold;">)&#9472;&gt;</span> false<br /><br /><span style="font-weight: bold;">&#9484;(</span><span style="font-weight: bold; color: #5555ff;">andy@alba</span><span style="font-weight: bold;">)&#9472;(</span><span style="font-weight: bold; color: #5555ff;">1</span><span style="font-weight: bold;">)&#9472;(</span><span style="font-weight: bold; color: #5555ff;">02:39 PM Sat Aug 29</span><span style="font-weight: bold;">)</span><br /><span style="font-weight: bold;">&#9492;&#9472;(</span><span style="font-weight: bold; color: #00cc00;">~</span><span style="font-weight: bold;">)&#9472;(</span><span style="font-weight: bold; color: #00cc00;">4 files, 332Kb</span><span style="font-weight: bold;">)&#9472;&gt;</span> su<br />Password: <br />Two can Live as Cheaply as One for Half as Long.<br /> &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;-- Howard Kandel<br /><br /><span style="font-weight: bold;">&#9484;(</span><span style="font-weight: bold; color: #aa0000;">alba</span><span style="font-weight: bold;">)&#9472;(</span><span style="font-weight: bold; color: #5555ff;">0</span><span style="font-weight: bold;">)&#9472;(</span><span style="font-weight: bold; color: #5555ff;">02:39 PM Sat Aug 29</span><span style="font-weight: bold;">)</span><br /><span style="font-weight: bold;">&#9492;&#9472;(</span><span style="font-weight: bold; color: #00cc00;">/home/andy</span><span style="font-weight: bold;">)&#9472;(</span><span style="font-weight: bold; color: #00cc00;">4 files, 332Kb</span><span style="font-weight: bold;">)&#9472;&gt;</span> <span style="text-decoration: blink;">_</span></div><br />
<br />
Here is the {{ic|PS1}} variable for this effect to be applyied to [[Color_Bash_Prompt#.2Fetc.2Fbash.bashrc|our]] {{ic|/etc/bash.bashrc}} file (see [[Color_Bash_Prompt#Variations_on_a_theme|above]]):<br />
<br />
{{bc|<nowiki> # http://maketecheasier.com/8-useful-and-interesting-bash-prompts/2009/09/04<br />
PS1="\n\[\033[1;37m\]\342\224\214($(if [[ ${EUID} == 0 ]]; then echo '\[\033[01;31m\]\h'; else echo '\[\033[01;34m\]\u@\h'; fi)\[\033[1;37m\])\342\224\200(\[\033[1;34m\]\$?\[\033[1;37m\])\342\224\200(\[\033[1;34m\]\@ \d\[\033[1;37m\])\[\033[1;37m\]\n\342\224\224\342\224\200(\[\033[1;32m\]\w\[\033[1;37m\])\342\224\200(\[\033[1;32m\]\$(ls -1 | wc -l | sed 's: ::g') files, \$(ls -sh | head -n1 | sed 's/total //')b\[\033[1;37m\])\342\224\200&gt; \[\033[0m\]"</nowiki>}}<br />
<br />
====Version #2: with unicode error status symbols====<br />
<br />
<div style="font-family: monospace; margin: 1em 3em; padding: 1em; border: 3px solid #bcd; background-color: black; color: #fff; font-size: 14px; line-height: 17px;">I am two with nature.<br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;-- Woody Allen<br /><br /><span style="font-weight: bold;">&#9484;(</span><span style="font-weight: bold; color: #5555ff;">andy@alba</span><span style="font-weight: bold;">)&#9472;(</span><span style="color: #0a0; font-weight: bold;">&#10003;</span><span style="font-weight: bold;">)&#9472;(</span><span style="font-weight: bold; color: #5555ff;">02:38 PM Sat Aug 29</span><span style="font-weight: bold;">)</span><br /><span style="font-weight: bold;">&#9492;&#9472;(</span><span style="font-weight: bold; color: #00cc00;">~</span><span style="font-weight: bold;">)&#9472;(</span><span style="font-weight: bold; color: #00cc00;">4 files, 332Kb</span><span style="font-weight: bold;">)&#9472;&gt;</span> ls<br /><span style="color: #55f; font-weight: bold;">Desktop Documents Music</span> myScript.js<br /><br /><span style="font-weight: bold;">&#9484;(</span><span style="font-weight: bold; color: #5555ff;">andy@alba</span><span style="font-weight: bold;">)&#9472;(</span><span style="color: #0a0; font-weight: bold;">&#10003;</span><span style="font-weight: bold;">)&#9472;(</span><span style="font-weight: bold; color: #5555ff;">02:38 PM Sat Aug 29</span><span style="font-weight: bold;">)</span><br /><span style="font-weight: bold;">&#9492;&#9472;(</span><span style="font-weight: bold; color: #00cc00;">~</span><span style="font-weight: bold;">)&#9472;(</span><span style="font-weight: bold; color: #00cc00;">4 files, 332Kb</span><span style="font-weight: bold;">)&#9472;&gt;</span> I\ will\ try\ to\ type\ a\ wrong\ command...<br />bash: I will try to type a wrong command...: command not found<br /><br /><span style="font-weight: bold;">&#9484;(</span><span style="font-weight: bold; color: #5555ff;">andy@alba</span><span style="font-weight: bold;">)&#9472;(</span><span style="color: #a00; font-weight: bold;">&#10007;</span><span style="font-weight: bold;">)&#9472;(</span><span style="font-weight: bold; color: #5555ff;">02:39 PM Sat Aug 29</span><span style="font-weight: bold;">)</span><br /><span style="font-weight: bold;">&#9492;&#9472;(</span><span style="font-weight: bold; color: #00cc00;">~</span><span style="font-weight: bold;">)&#9472;(</span><span style="font-weight: bold; color: #00cc00;">4 files, 332Kb</span><span style="font-weight: bold;">)&#9472;&gt;</span> echo 'Hello world!'<br />Hello world!<br /><br /><span style="font-weight: bold;">&#9484;(</span><span style="font-weight: bold; color: #5555ff;">andy@alba</span><span style="font-weight: bold;">)&#9472;(</span><span style="color: #0a0; font-weight: bold;">&#10003;</span><span style="font-weight: bold;">)&#9472;(</span><span style="font-weight: bold; color: #5555ff;">02:39 PM Sat Aug 29</span><span style="font-weight: bold;">)</span><br /><span style="font-weight: bold;">&#9492;&#9472;(</span><span style="font-weight: bold; color: #00cc00;">~</span><span style="font-weight: bold;">)&#9472;(</span><span style="font-weight: bold; color: #00cc00;">4 files, 332Kb</span><span style="font-weight: bold;">)&#9472;&gt;</span> false<br /><br /><span style="font-weight: bold;">&#9484;(</span><span style="font-weight: bold; color: #5555ff;">andy@alba</span><span style="font-weight: bold;">)&#9472;(</span><span style="color: #a00; font-weight: bold;">&#10007;</span><span style="font-weight: bold;">)&#9472;(</span><span style="font-weight: bold; color: #5555ff;">02:39 PM Sat Aug 29</span><span style="font-weight: bold;">)</span><br /><span style="font-weight: bold;">&#9492;&#9472;(</span><span style="font-weight: bold; color: #00cc00;">~</span><span style="font-weight: bold;">)&#9472;(</span><span style="font-weight: bold; color: #00cc00;">4 files, 332Kb</span><span style="font-weight: bold;">)&#9472;&gt;</span> su<br />Password: <br />Two can Live as Cheaply as One for Half as Long.<br /> &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;-- Howard Kandel<br /><br /><span style="font-weight: bold;">&#9484;(</span><span style="font-weight: bold; color: #aa0000;">alba</span><span style="font-weight: bold;">)&#9472;(</span><span style="color: #0a0; font-weight: bold;">&#10003;</span><span style="font-weight: bold;">)&#9472;(</span><span style="font-weight: bold; color: #5555ff;">02:39 PM Sat Aug 29</span><span style="font-weight: bold;">)</span><br /><span style="font-weight: bold;">&#9492;&#9472;(</span><span style="font-weight: bold; color: #00cc00;">/home/andy</span><span style="font-weight: bold;">)&#9472;(</span><span style="font-weight: bold; color: #00cc00;">4 files, 332Kb</span><span style="font-weight: bold;">)&#9472;&gt;</span> <span style="text-decoration: blink;">_</span></div><br />
<br />
Here is the {{ic|PS1}} variable for this effect to be applyied to [[Color_Bash_Prompt#.2Fetc.2Fbash.bashrc|our]] {{ic|/etc/bash.bashrc}} file (see [[Color_Bash_Prompt#Variations_on_a_theme|above]]):<br />
<br />
{{bc|<nowiki> # http://maketecheasier.com/8-useful-and-interesting-bash-prompts/2009/09/04<br />
PS1="\n\[\033[1;37m\]\342\224\214($(if [[ ${EUID} == 0 ]]; then echo '\[\033[01;31m\]\h'; else echo '\[\033[01;34m\]\u@\h'; fi)\[\033[1;37m\])\342\224\200(\$(if [[ \$? == 0 ]]; then echo \"\[\033[01;32m\]\342\234\223\"; else echo \"\[\033[01;31m\]\342\234\227\"; fi)\[\033[1;37m\])\342\224\200(\[\033[1;34m\]\@ \d\[\033[1;37m\])\[\033[1;37m\]\n\342\224\224\342\224\200(\[\033[1;32m\]\w\[\033[1;37m\])\342\224\200(\[\033[1;32m\]\$(ls -1 | wc -l | sed 's: ::g') files, \$(ls -sh | head -n1 | sed 's/total //')b\[\033[1;37m\])\342\224\200&gt; \[\033[0m\]"</nowiki>}}<br />
<br />
====Version #3: with unicode error status symbol (non-zero only)====<br />
<br />
<div style="font-family: monospace; margin: 1em 3em; padding: 1em; border: 3px solid #bcd; background-color: black; color: #fff; font-size: 14px; line-height: 17px;">I am two with nature.<br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;-- Woody Allen<br /><br /><span style="font-weight: bold;">&#9484;(</span><span style="font-weight: bold; color: #5555ff;">andy@alba</span><span style="font-weight: bold;">)&#9472;(</span><span style="font-weight: bold; color: #5555ff;">02:38 PM Sat Aug 29</span><span style="font-weight: bold;">)</span><br /><span style="font-weight: bold;">&#9492;&#9472;(</span><span style="font-weight: bold; color: #00cc00;">~</span><span style="font-weight: bold;">)&#9472;(</span><span style="font-weight: bold; color: #00cc00;">4 files, 332Kb</span><span style="font-weight: bold;">)&#9472;&gt;</span> ls<br /><span style="color: #55f; font-weight: bold;">Desktop Documents Music</span> myScript.js<br /><br /><span style="font-weight: bold;">&#9484;(</span><span style="font-weight: bold; color: #5555ff;">andy@alba</span><span style="font-weight: bold;">)&#9472;(</span><span style="font-weight: bold; color: #5555ff;">02:38 PM Sat Aug 29</span><span style="font-weight: bold;">)</span><br /><span style="font-weight: bold;">&#9492;&#9472;(</span><span style="font-weight: bold; color: #00cc00;">~</span><span style="font-weight: bold;">)&#9472;(</span><span style="font-weight: bold; color: #00cc00;">4 files, 332Kb</span><span style="font-weight: bold;">)&#9472;&gt;</span> I\ will\ try\ to\ type\ a\ wrong\ command...<br />bash: I will try to type a wrong command...: command not found<br /><br /><span style="font-weight: bold;">&#9484;(</span><span style="font-weight: bold; color: #5555ff;">andy@alba</span><span style="font-weight: bold;">)&#9472;(</span><span style="color: #a00; font-weight: bold;">&#10007;</span><span style="font-weight: bold;">)&#9472;(</span><span style="font-weight: bold; color: #5555ff;">02:39 PM Sat Aug 29</span><span style="font-weight: bold;">)</span><br /><span style="font-weight: bold;">&#9492;&#9472;(</span><span style="font-weight: bold; color: #00cc00;">~</span><span style="font-weight: bold;">)&#9472;(</span><span style="font-weight: bold; color: #00cc00;">4 files, 332Kb</span><span style="font-weight: bold;">)&#9472;&gt;</span> echo 'Hello world!'<br />Hello world!<br /><br /><span style="font-weight: bold;">&#9484;(</span><span style="font-weight: bold; color: #5555ff;">andy@alba</span><span style="font-weight: bold;">)&#9472;(</span><span style="font-weight: bold; color: #5555ff;">02:39 PM Sat Aug 29</span><span style="font-weight: bold;">)</span><br /><span style="font-weight: bold;">&#9492;&#9472;(</span><span style="font-weight: bold; color: #00cc00;">~</span><span style="font-weight: bold;">)&#9472;(</span><span style="font-weight: bold; color: #00cc00;">4 files, 332Kb</span><span style="font-weight: bold;">)&#9472;&gt;</span> false<br /><br /><span style="font-weight: bold;">&#9484;(</span><span style="font-weight: bold; color: #5555ff;">andy@alba</span><span style="font-weight: bold;">)&#9472;(</span><span style="color: #a00; font-weight: bold;">&#10007;</span><span style="font-weight: bold;">)&#9472;(</span><span style="font-weight: bold; color: #5555ff;">02:39 PM Sat Aug 29</span><span style="font-weight: bold;">)</span><br /><span style="font-weight: bold;">&#9492;&#9472;(</span><span style="font-weight: bold; color: #00cc00;">~</span><span style="font-weight: bold;">)&#9472;(</span><span style="font-weight: bold; color: #00cc00;">4 files, 332Kb</span><span style="font-weight: bold;">)&#9472;&gt;</span> su<br />Password: <br />Two can Live as Cheaply as One for Half as Long.<br /> &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;-- Howard Kandel<br /><br /><span style="font-weight: bold;">&#9484;(</span><span style="font-weight: bold; color: #aa0000;">alba</span><span style="font-weight: bold;">)&#9472;(</span><span style="font-weight: bold; color: #5555ff;">02:39 PM Sat Aug 29</span><span style="font-weight: bold;">)</span><br /><span style="font-weight: bold;">&#9492;&#9472;(</span><span style="font-weight: bold; color: #00cc00;">/home/andy</span><span style="font-weight: bold;">)&#9472;(</span><span style="font-weight: bold; color: #00cc00;">4 files, 332Kb</span><span style="font-weight: bold;">)&#9472;&gt;</span> <span style="text-decoration: blink;">_</span></div><br />
<br />
Here is the {{ic|PS1}} variable for this effect to be applyied to [[Color_Bash_Prompt#.2Fetc.2Fbash.bashrc|our]] {{ic|/etc/bash.bashrc}} file (see [[Color_Bash_Prompt#Variations_on_a_theme|above]]):<br />
<br />
{{bc|<nowiki> # http://maketecheasier.com/8-useful-and-interesting-bash-prompts/2009/09/04<br />
PS1="\n\[\033[1;37m\]\342\224\214($(if [[ ${EUID} == 0 ]]; then echo '\[\033[01;31m\]\h'; else echo '\[\033[01;34m\]\u@\h'; fi)\[\033[1;37m\])\$([[ \$? != 0 ]] &amp;&amp; echo \"\342\224\200(\[\033[0;31m\]\342\234\227\[\033[1;37m\])\")\342\224\200(\[\033[1;34m\]\@ \d\[\033[1;37m\])\[\033[1;37m\]\n\342\224\224\342\224\200(\[\033[1;32m\]\w\[\033[1;37m\])\342\224\200(\[\033[1;32m\]\$(ls -1 | wc -l | sed 's: ::g') files, \$(ls -sh | head -n1 | sed 's/total //')b\[\033[1;37m\])\342\224\200&gt; \[\033[0m\]"</nowiki>}}<br />
<br />
==Restoring the original /etc/bash.bashrc file==<br />
<br />
If you repent having modified the {{ic|/etc/bash.bashrc}} file, you can always restore the original Arch {{ic|/etc/bash.bashrc}} file from the [[ bash ]] package and remove the {{ic|/etc/DIR_COLORS}} file. Note that there is not an "official" bash.bashrc: each distribution has its own.<br />
<br />
==Original /etc/bash.bashrc from Gentoo==<br />
<br />
The original ''not modified'' Gentoo's {{ic|/etc/bash.bashrc}} file can be found [http://www.jeremysands.com/archlinux/gentoo-bashrc-2008.0 here].<br />
<br />
=Colors overview=<br />
The page at http://ascii-table.com/ansi-escape-sequences.php describes the various available color escapes. The following Bash function (put it in your .bashrc!) displays a table with ready-to-copy escape codes.<br />
<br />
{{bc|<nowiki><br />
colors() {<br />
local fgc bgc vals seq0<br />
<br />
printf "Color escapes are %s\n" '\e[${value};...;${value}m'<br />
printf "Values 30..37 are \e[33mforeground colors\e[m\n"<br />
printf "Values 40..47 are \e[43mbackground colors\e[m\n"<br />
printf "Value 1 gives a \e[1mbold-faced look\e[m\n\n"<br />
<br />
# foreground colors<br />
for fgc in {30..37}; do<br />
# background colors<br />
for bgc in {40..47}; do<br />
fgc=${fgc#37} # white<br />
bgc=${bgc#40} # black<br />
<br />
vals="${fgc:+$fgc;}${bgc}"<br />
vals=${vals%%;}<br />
<br />
seq0="${vals:+\e[${vals}m}"<br />
printf " %-9s" "${seq0:-(default)}"<br />
printf " ${seq0}TEXT\e[m"<br />
printf " \e[${vals:+${vals+$vals;}}1mBOLD\e[m"<br />
done<br />
echo; echo<br />
done<br />
}<br />
</nowiki>}}<br />
<br />
=Step by step=<br />
<br />
If you want to create a style all your own, you can take a look at these tips. [https://bbs.archlinux.org/viewtopic.php?id=50885 This Forum thread] could give you more informations and examples.<br />
<br />
==Basic prompts==<br />
<br />
The following settings are useful for distinguishing the root prompt from non-root users.<br />
<br />
*Edit Bash's personal configuration file:<br />
{{bc|<nowiki>$ nano ~/.bashrc</nowiki>}}<br />
<br />
*Comment out the default prompt:<br />
{{bc|<nowiki># PS1='[\u@\h \W]\$ '</nowiki>}}<br />
<br />
*Add the following green prompt for regular users:<br />
<div style="font-family: monospace; white-space: pre; margin: 1em 3em; padding: 1em; border: 3px solid #bcd; background-color: black; color: #aaa;"><span style="color: #0f0">[chiri@zetsubou ~]$</span> <span style="text-decoration: blink;">_</span></div><br />
{{bc|<nowiki>PS1='\[\e[1;32m\][\u@\h \W]\$\[\e[0m\] '</nowiki>}}<br />
<br />
*Edit root's .bashrc file; copy it from /etc/skel if the file is not present:<br />
{{bc|<nowiki>$ nano /root/.bashrc</nowiki>}}<br />
*Assign a red prompt for root:<br />
<br />
<div style="font-family: monospace; white-space: pre; margin: 1em 3em; padding: 1em; border: 3px solid #bcd; background-color: black; color: #aaa;"><span style="color: #f00">[root@zetsubou ~]#</span> <span style="text-decoration: blink;">_</span></div><br />
{{bc|<nowiki>PS1='\[\e[1;31m\][\u@\h \W]\$\[\e[0m\] '</nowiki>}}<br />
<br />
===Slightly fancier prompts===<br />
<br />
*A green and blue prompt for regular users:<br />
<div style="font-family: monospace; white-space: pre; margin: 1em 3em; padding: 1em; border: 3px solid #bcd; background-color: black; color: #aaa;"><span style="color: #0a0">chiri</span> <span style="color: #00f">~/docs</span> <span style="color: #0f0">$</span> echo "sample output text"<br />sample output text<br /><span style="color: #0a0">chiri</span> <span style="color: #00f">~/docs</span> <span style="color: #0f0">$</span> <span style="text-decoration: blink;">_</span></div><br />
{{bc|<nowiki>PS1='\[\e[0;32m\]\u\[\e[m\] \[\e[1;34m\]\w\[\e[m\] \[\e[1;32m\]\$\[\e[m\] \[\e[1;37m\]'</nowiki>}}<br />
<br />
This will give a very pleasing, colorful prompt and theme for the console with bright white text.<br />
<br />
The string above contains color-set escape sequences (start coloring: \[\e[color\], end coloring: \[\e[m\]) and information placeholders:<br />
<br />
* \u - Username. The original prompt also has \h, which prints the host name.<br />
* \w - Current absolute path. Use \W for current relative path.<br />
* \$ - The prompt character (eg. '#' for root, '$' for regular users). <br />
<br />
The last color-set sequence, "\[\e[1;37m\]", is not closed, so the remaining text (everything typed into the terminal, program output and so on) will be in that (bright white) color. It may be desirable to change this color, or to delete the last escape sequence in order to leave the actual output in unaltered color. <br />
<br />
*A red and blue prompt for root:<br />
<div style="font-family: monospace; white-space: pre; margin: 1em 3em; padding: 1em; border: 3px solid #bcd; background-color: black; color: #aaa;"><span style="color: #a00">root</span> <span style="color: #00f">~/docs</span> <span style="color: #a00">#</span> <span style="color: #0a0">echo "sample output text"<br />sample output text<br /></span><span style="color: #a00">root</span> <span style="color: #00f">~/docs</span> <span style="color: #a00">#</span> <span style="color: #0a0"><span style="text-decoration: blink;">_</span></span></div><br />
{{bc|<nowiki>PS1='\[\e[0;31m\]\u\[\e[m\] \[\e[1;34m\]\w\[\e[m\] \[\e[0;31m\]\$ \[\e[m\]\[\e[0;32m\]'</nowiki>}}<br />
<br />
This will give you a red designation and green console text.<br />
<br />
Once you have made your changes to .bashrc, to execute your changes:<br />
<br />
{{bc|<nowiki>$ source ~/.bashrc</nowiki>}}<br />
<br />
==Advanced prompts==<br />
<br />
===Load/Mem Status for 256colors===<br />
This is not even pushing the limits. Other than using 'sed' to parse the memory and load average (using the ''-u'' option for non-buffering), and the builtin ''history'' to save your history to your ''HISTFILE'' after every command, which you may find incredibly useful when dealing with crashing shells or subshells, this is essentially just making BASH print variables it already knows, making this extremely fast compared to prompts with non-builtin commands.<br />
<br />
This prompt is from AskApache.com's [http://www.askapache.com/linux-unix/bash-power-prompt.html BASH Power Prompt article], which goes into greater detail. It is especially helpful for those wanting to understand 256 color terminals, ncurses, termcap, and terminfo.<br />
<br />
This is for '''256 color terminals''', which is where the '''\033[38;5;22m''' terminal escapes come from. <br />
{{bc|1=<br />
<span style="color:#0b0">802</span><span style="color:#005f00">/1024MB</span> <span style="color:#5f00af">1.28 1.20 1.13 3/94 18563</span><br />
<span style="color:#555">[5416:17880 0:70]</span> <span style="color:0bb">05:35:50 Wed Apr 21</span> <span style="color:#555">[</span><span style="color:#2b47ff">srot@host.sqpt.net</span><span style="color:#555">:</span><span style="color:#bbb">/dev/pts/0</span> <span style="color:#00bb00">+1</span><span style="color:#555">]</span> <span style="color:#000">~<br /><br />
(1:70)$ <span style="text-decoration: blink;">_</span></span><br />
}}<br />
<br />
{{bc|<nowiki>PROMPT_COMMAND='history -a;echo -en "\033[m\033[38;5;2m"$(( $(sed -nu "s/MemFree:[\t ]\+\([0-9]\+\) kB/\1/p" /proc/meminfo)/1024))"\033[38;5;22m/"$(($(sed -nu "s/MemTotal:[\t ]\+\([0-9]\+\) kB/\1/Ip" /proc/meminfo)/1024 ))MB"\t\033[m\033[38;5;55m$(&lt; /proc/loadavg)\033[m"'<br />
PS1='\[\e[m\n\e[1;30m\][$$:$PPID \j:\!\[\e[1;30m\]]\[\e[0;36m\] \T \d \[\e[1;30m\][\[\e[1;34m\]\u@\H\[\e[1;30m\]:\[\e[0;37m\]${SSH_TTY} \[\e[0;32m\]+${SHLVL}\[\e[1;30m\]] \[\e[1;37m\]\w\[\e[0;37m\] \n($SHLVL:\!)\$ '</nowiki>}}<br />
<br />
===List of colors for prompt and Bash===<br />
<br />
Add this to your Bash file(s) to define colors for prompt and commands:<br />
{{bc|<nowiki>txtblk='\e[0;30m' # Black - Regular<br />
txtred='\e[0;31m' # Red<br />
txtgrn='\e[0;32m' # Green<br />
txtylw='\e[0;33m' # Yellow<br />
txtblu='\e[0;34m' # Blue<br />
txtpur='\e[0;35m' # Purple<br />
txtcyn='\e[0;36m' # Cyan<br />
txtwht='\e[0;37m' # White<br />
bldblk='\e[1;30m' # Black - Bold<br />
bldred='\e[1;31m' # Red<br />
bldgrn='\e[1;32m' # Green<br />
bldylw='\e[1;33m' # Yellow<br />
bldblu='\e[1;34m' # Blue<br />
bldpur='\e[1;35m' # Purple<br />
bldcyn='\e[1;36m' # Cyan<br />
bldwht='\e[1;37m' # White<br />
unkblk='\e[4;30m' # Black - Underline<br />
undred='\e[4;31m' # Red<br />
undgrn='\e[4;32m' # Green<br />
undylw='\e[4;33m' # Yellow<br />
undblu='\e[4;34m' # Blue<br />
undpur='\e[4;35m' # Purple<br />
undcyn='\e[4;36m' # Cyan<br />
undwht='\e[4;37m' # White<br />
bakblk='\e[40m' # Black - Background<br />
bakred='\e[41m' # Red<br />
bakgrn='\e[42m' # Green<br />
bakylw='\e[43m' # Yellow<br />
bakblu='\e[44m' # Blue<br />
bakpur='\e[45m' # Purple<br />
bakcyn='\e[46m' # Cyan<br />
bakwht='\e[47m' # White<br />
txtrst='\e[0m' # Text Reset</nowiki>}}<br />
<br />
Or if you prefer color names you will know how to spell without a special decoder ring and want high intensity colors:<br />
{{bc|<nowiki># Reset<br />
Color_Off='\e[0m' # Text Reset<br />
<br />
# Regular Colors<br />
Black='\e[0;30m' # Black<br />
Red='\e[0;31m' # Red<br />
Green='\e[0;32m' # Green<br />
Yellow='\e[0;33m' # Yellow<br />
Blue='\e[0;34m' # Blue<br />
Purple='\e[0;35m' # Purple<br />
Cyan='\e[0;36m' # Cyan<br />
White='\e[0;37m' # White<br />
<br />
# Bold<br />
BBlack='\e[1;30m' # Black<br />
BRed='\e[1;31m' # Red<br />
BGreen='\e[1;32m' # Green<br />
BYellow='\e[1;33m' # Yellow<br />
BBlue='\e[1;34m' # Blue<br />
BPurple='\e[1;35m' # Purple<br />
BCyan='\e[1;36m' # Cyan<br />
BWhite='\e[1;37m' # White<br />
<br />
# Underline<br />
UBlack='\e[4;30m' # Black<br />
URed='\e[4;31m' # Red<br />
UGreen='\e[4;32m' # Green<br />
UYellow='\e[4;33m' # Yellow<br />
UBlue='\e[4;34m' # Blue<br />
UPurple='\e[4;35m' # Purple<br />
UCyan='\e[4;36m' # Cyan<br />
UWhite='\e[4;37m' # White<br />
<br />
# Background<br />
On_Black='\e[40m' # Black<br />
On_Red='\e[41m' # Red<br />
On_Green='\e[42m' # Green<br />
On_Yellow='\e[43m' # Yellow<br />
On_Blue='\e[44m' # Blue<br />
On_Purple='\e[45m' # Purple<br />
On_Cyan='\e[46m' # Cyan<br />
On_White='\e[47m' # White<br />
<br />
# High Intensity<br />
IBlack='\e[0;90m' # Black<br />
IRed='\e[0;91m' # Red<br />
IGreen='\e[0;92m' # Green<br />
IYellow='\e[0;93m' # Yellow<br />
IBlue='\e[0;94m' # Blue<br />
IPurple='\e[0;95m' # Purple<br />
ICyan='\e[0;96m' # Cyan<br />
IWhite='\e[0;97m' # White<br />
<br />
# Bold High Intensity<br />
BIBlack='\e[1;90m' # Black<br />
BIRed='\e[1;91m' # Red<br />
BIGreen='\e[1;92m' # Green<br />
BIYellow='\e[1;93m' # Yellow<br />
BIBlue='\e[1;94m' # Blue<br />
BIPurple='\e[1;95m' # Purple<br />
BICyan='\e[1;96m' # Cyan<br />
BIWhite='\e[1;97m' # White<br />
<br />
# High Intensity backgrounds<br />
On_IBlack='\e[0;100m' # Black<br />
On_IRed='\e[0;101m' # Red<br />
On_IGreen='\e[0;102m' # Green<br />
On_IYellow='\e[0;103m' # Yellow<br />
On_IBlue='\e[0;104m' # Blue<br />
On_IPurple='\e[0;105m' # Purple<br />
On_ICyan='\e[0;106m' # Cyan<br />
On_IWhite='\e[0;107m' # White<br />
</nowiki>}}<br />
<br />
To use in commands from your shell environment:<br />
<br />
<div style="font-family: monospace; margin: 1em 3em; padding: 1em; border: 3px solid #bcd; background-color: black; color: #fff;">$ echo -e "${txtblu}test"<br /><span style="color: blue;">test</span><br />$ echo -e "${bldblu}test"<br /><span style="color: lightblue;"><strong>test</strong></span><br />$ echo -e "${undblu}test"<br /><span style="color: lightblue;"><strong><span style="text-decoration: underline;">test</span></strong></span><br />$ echo -e "${bakblu}test"<br /><span style="color: white; background-color: lightblue;"><strong>test</strong></span><br />$ <span style="text-decoration: blink;">_</span></div><br />
<br />
To use in a prompt (note double quotes to enable $color variable expansion and <nowiki>\[ \]</nowiki> escapes around them so they are not counted as character positions and the cursor position is not wrong):<br />
<br />
{{bc|<nowiki>PS1="\[$txtblu\]foo\[$txtred\] bar\[$txtrst\] baz : "</nowiki>}}<br />
<br />
If you experience premature line wrapping when entering commands at the prompt then missing escapes is most likely to be the reason.<br />
<br />
=== Prompt escapes ===<br />
<br />
The various Bash prompt escapes listed in the manpage:<br />
<br />
{{bc|1=Bash allows these prompt strings to be customized by inserting a<br />
number of ''backslash-escaped special characters'' that are<br />
decoded as follows:<br />
<br />
\a an ASCII bell character (07)<br />
\d the date in "Weekday Month Date" format (e.g., "Tue May 26")<br />
\D{format} the format is passed to strftime(3) and the result<br />
is inserted into the prompt string an empty format<br />
results in a locale-specific time representation.<br />
The braces are required<br />
\e an ASCII escape character (033)<br />
\h the hostname up to the first `.'<br />
\H the hostname<br />
\j the number of jobs currently managed by the shell<br />
\l the basename of the shell's terminal device name<br />
\n newline<br />
\r carriage return<br />
\s the name of the shell, the basename of $0 (the portion following<br />
the final slash)<br />
\t the current time in 24-hour HH:MM:SS format<br />
\T the current time in 12-hour HH:MM:SS format<br />
\@ the current time in 12-hour am/pm format<br />
\A the current time in 24-hour HH:MM format<br />
\u the username of the current user<br />
\v the version of bash (e.g., 2.00)<br />
\V the release of bash, version + patch level (e.g., 2.00.0)<br />
\w the current working directory, with $HOME abbreviated with a tilde<br />
\W the basename of the current working directory, with $HOME<br />
abbreviated with a tilde<br />
\! the history number of this command<br />
\# the command number of this command<br />
\$ if the effective UID is 0, a #, otherwise a $<br />
\nnn the character corresponding to the octal number nnn<br />
\\ a backslash<br />
\[ begin a sequence of non-printing characters, which could be used<br />
to embed a terminal control sequence into the prompt<br />
\] end a sequence of non-printing characters<br />
<br />
The command number and the history number are usually different:<br />
the history number of a command is its position in the history<br />
list, which may include commands restored from the history file<br />
(see HISTORY below), while the command number is the position in<br />
the sequence of commands executed during the current shell session.<br />
After the string is decoded, it is expanded via parameter<br />
expansion, command substitution, arithmetic expansion, and quote<br />
removal, subject to the value of the promptvars shell option (see<br />
the description of the shopt command under SHELL BUILTIN COMMANDS<br />
below).<br />
}}<br />
<br />
=== Positioning the cursor ===<br />
<br />
{{Accuracy|The last example don't work (at least on Bash). Seems to have a problem in '''\[\033[1;\$((COLUMNS-4))f\]'''}}<br />
<br />
The following sequence sets the cursor position:<br />
<br />
{{bc|<nowiki>\[\033[<row>;<column>f\]</nowiki>}}<br />
<br />
The current cursor position can be saved using:<br />
<br />
{{bc|<nowiki>\[\033[s\]</nowiki>}}<br />
<br />
To restore a position, use the following sequence: <br />
<br />
{{bc|<nowiki>\[\033[u\]</nowiki>}}<br />
<br />
The following example uses these sequences to display the time in the upper right corner:<br />
<br />
{{bc|<nowiki>PS1="&gt;\[\033[s\]\[\033[1;\$((COLUMNS-4))f\]\$(date +%H:%M)\[\033[u\]"</nowiki>}}<br />
<br />
The environment variable ''COLUMNS'' contains the number of columns of the terminal. The above example substracts 4 from its value in order to justify the five character wide output of ''date'' at the right border.<br />
<br />
===Return value visualisation===<br />
<br />
Use this prompt if you want to see the return value of the last executed command.<br />
<br />
{{bc|<nowiki>#return value visualisation<br />
PS1="\$? \$(if [[ \$? == 0 ]]; then echo \"\[\033[0;32m\];)\"; else echo \"\[\033[0;31m\];(\"; fi)\[\033[00m\] : "</nowiki>}}<br />
<br />
This will give you basic prompt:<br />
<div style="font-family: monospace; margin: 1em 3em; padding: 1em; border: 3px solid #bcd; background-color: black; color: #fff;">0 <span style="color: green;">;)</span>&nbsp;: true<br />0 <span style="color: green;">;)</span>&nbsp;: false<br />1 <span style="color: red;">;(</span>&nbsp;:</div><br />
<br />
Zero is a green smiley (replace it with anything you want) and non-zero is a red one. So your prompt will smile if the last operation was successful.<br />
<br />
But you will probably want to use the return value in your own prompt, like this:<br />
<br />
<div style="font-family: monospace; margin: 1em 3em; padding: 1em; border: 3px solid #bcd; background-color: black; color: #fff;"><span style="font-weight: bold;">0</span> <span style="color: #0a0; font-weight: bold;">;) andy@alba</span> <span style="color: #55f; font-weight: bold;">~ $</span> true<br /><span style="font-weight: bold;">0</span> <span style="color: #0a0; font-weight: bold;">;) andy@alba</span> <span style="color: #55f; font-weight: bold;">~ $</span> false<br /><span style="font-weight: bold;">1</span> <span style="color: #a00; font-weight: bold;">;(</span> <span style="color: #0a0; font-weight: bold;">andy@alba</span> <span style="color: #55f; font-weight: bold;">~ $</span> <span style="text-decoration: blink;">_</span></div><br />
<br />
with a code like this one:<br />
<br />
{{bc|<nowiki>#return value visualisation<br />
PS1="\[\033[01;37m\]\$? \$(if [[ \$? == 0 ]]; then echo \"\[\033[01;32m\];)\"; else echo \"\[\033[01;31m\];(\"; fi) $(if [[ ${EUID} == 0 ]]; then echo '\[\033[01;31m\]\h'; else echo '\[\033[01;32m\]\u@\h'; fi)\[\033[01;34m\] \w \$\[\033[00m\] "</nowiki>}}<br />
<br />
Or, if you want, you can build your prompt using the <span style="color: #0a0; font-weight: bold;">&#10003;</span> unicode symbol for a ''zero'' status and the <span style="color: #a00; font-weight: bold;">&#10007;</span> unicode symbol for a ''nonzero'' status:<br />
<br />
<div style="font-family: monospace; margin: 1em 3em; padding: 1em; border: 3px solid #bcd; background-color: black; color: #fff;"><span style="font-weight: bold;">0</span> <span style="color: #0a0; font-weight: bold;">&#10003; andy@alba</span> <span style="color: #55f; font-weight: bold;">~ $</span> true<br /><span style="font-weight: bold;">0</span> <span style="color: #0a0; font-weight: bold;">&#10003; andy@alba</span> <span style="color: #55f; font-weight: bold;">~ $</span> false<br /><span style="font-weight: bold;">1</span> <span style="color: #a00; font-weight: bold;">&#10007;</span> <span style="color: #0a0; font-weight: bold;">andy@alba</span> <span style="color: #55f; font-weight: bold;">~ $</span> I\ will\ try\ to\ type\ a\ wrong\ command...<br />bash: I will try to type a wrong command...: command not found<br /><span style="font-weight: bold;">127</span> <span style="color: #a00; font-weight: bold;">&#10007;</span> <span style="color: #0a0; font-weight: bold;">andy@alba</span> <span style="color: #55f; font-weight: bold;">~ $</span> <span style="text-decoration: blink;">_</span></div><br />
<br />
starting from a code like this other one:<br />
<br />
{{bc|<nowiki>#return value visualisation<br />
PS1="\[\033[01;37m\]\$? \$(if [[ \$? == 0 ]]; then echo \"\[\033[01;32m\]\342\234\223\"; else echo \"\[\033[01;31m\]\342\234\227\"; fi) $(if [[ ${EUID} == 0 ]]; then echo '\[\033[01;31m\]\h'; else echo '\[\033[01;32m\]\u@\h'; fi)\[\033[01;34m\] \w \$\[\033[00m\] "</nowiki>}}<br />
<br />
Here's an alternative that only include the error status if it is nonzero:<br />
{{bc|<nowiki><br />
PROMPT_COMMAND='es=$?; [[ $es -eq 0 ]] &amp;&amp; unset error || error=$(echo -e "\e[1;41m $es \e[40m")'<br />
PS1="${error} ${PS1}"</nowiki>}}<br />
<br />
===Wolfman's===<br />
<br />
After reading through most of the [http://www.tldp.org/HOWTO/Bash-Prompt-HOWTO/index.html Bash Prompt Howto], the author developed a color bash prompt that displays the last 25 characters of the current working directory. This prompt should work well on terminals with a black background. The following code goes in file {{ic|~/.bashrc}}.<br />
<br />
*Add the bash_prompt_command function. If you have a couple directories with long names or start entering a lot of subdirectories, this function will keep the command prompt from wrapping around the screen by displaying at most the last pwdmaxlen characters from the PWD. This code was taken from the ''Bash Prompt Howto''<nowiki>'s</nowiki> section on [http://www.tldp.org/HOWTO/Bash-Prompt-HOWTO/x783.html Controlling the Size and Appearance of $PWD] and modified to replace the user's home directory with a tilde.<br />
<br />
{{bc|<nowiki>##################################################<br />
# Fancy PWD display function<br />
##################################################<br />
# The home directory (HOME) is replaced with a ~<br />
# The last pwdmaxlen characters of the PWD are displayed<br />
# Leading partial directory names are striped off<br />
# /home/me/stuff -&gt; ~/stuff if USER=me<br />
# /usr/share/big_dir_name -&gt; ../share/big_dir_name if pwdmaxlen=20<br />
##################################################<br />
<br />
bash_prompt_command() {<br />
# How many characters of the $PWD should be kept<br />
local pwdmaxlen=25<br />
# Indicate that there has been dir truncation<br />
local trunc_symbol=".."<br />
local dir=${PWD##*/}<br />
pwdmaxlen=$(( ( pwdmaxlen &lt; ${#dir} ) ? ${#dir} : pwdmaxlen ))<br />
NEW_PWD=${PWD/#$HOME/\~}<br />
local pwdoffset=$(( ${#NEW_PWD} - pwdmaxlen ))<br />
if [ ${pwdoffset} -gt "0" ]<br />
then<br />
NEW_PWD=${NEW_PWD:$pwdoffset:$pwdmaxlen}<br />
NEW_PWD=${trunc_symbol}/${NEW_PWD#*/}<br />
fi<br />
}</nowiki>}}<br />
<br />
*The next fragment generates the command prompt and various colors are defined. The user's color for the username, hostname, and prompt ($ or #) is set to cyan, and if the user is root (root's UID is always 0), set the color to red. The command prompt is set to a colored version of Arch's default with the NEW_PWD from the last function.<br />
<br />
:Also, make sure that your color variables are enclosed in double and not single quote marks. Using single quote marks seems to give Bash problems with line wrapping correctly.<br />
<br />
{{bc|<nowiki>bash_prompt() {<br />
case $TERM in<br />
xterm*|rxvt*)<br />
local TITLEBAR='\[\033]0;\u:${NEW_PWD}\007\]'<br />
;;<br />
*)<br />
local TITLEBAR=""<br />
;;<br />
esac<br />
local NONE="\[\033[0m\]" # unsets color to term's fg color<br />
<br />
# regular colors<br />
local K="\[\033[0;30m\]" # black<br />
local R="\[\033[0;31m\]" # red<br />
local G="\[\033[0;32m\]" # green<br />
local Y="\[\033[0;33m\]" # yellow<br />
local B="\[\033[0;34m\]" # blue<br />
local M="\[\033[0;35m\]" # magenta<br />
local C="\[\033[0;36m\]" # cyan<br />
local W="\[\033[0;37m\]" # white<br />
<br />
# emphasized (bolded) colors<br />
local EMK="\[\033[1;30m\]"<br />
local EMR="\[\033[1;31m\]"<br />
local EMG="\[\033[1;32m\]"<br />
local EMY="\[\033[1;33m\]"<br />
local EMB="\[\033[1;34m\]"<br />
local EMM="\[\033[1;35m\]"<br />
local EMC="\[\033[1;36m\]"<br />
local EMW="\[\033[1;37m\]"<br />
<br />
# background colors<br />
local BGK="\[\033[40m\]"<br />
local BGR="\[\033[41m\]"<br />
local BGG="\[\033[42m\]"<br />
local BGY="\[\033[43m\]"<br />
local BGB="\[\033[44m\]"<br />
local BGM="\[\033[45m\]"<br />
local BGC="\[\033[46m\]"<br />
local BGW="\[\033[47m\]"<br />
<br />
local UC=$W # user's color<br />
[ $UID -eq "0" ] &amp;&amp; UC=$R # root's color<br />
<br />
PS1="$TITLEBAR ${EMK}[${UC}\u${EMK}@${UC}\h ${EMB}\${NEW_PWD}${EMK}]${UC}\\$ ${NONE}"<br />
# without colors: PS1="[\u@\h \${NEW_PWD}]\\$ "<br />
# extra backslash in front of \$ to make bash colorize the prompt<br />
}</nowiki>}}<br />
<br />
*Finally, append this code. This ensures that the NEW_PWD variable will be updated when you cd somewhere else, and it sets the PS1 variable, which contains the command prompt.<br />
<br />
{{bc|<nowiki>PROMPT_COMMAND=bash_prompt_command<br />
bash_prompt<br />
unset bash_prompt</nowiki>}}<br />
<br />
===KitchM's===<br />
These prompts offer a little more flash and visual clarity. Note that the use of red in the root user's prompt should provide ample warning. That is not to say someone could not use flashing text or arrow to do even more, but these will give you a good starting point.<br />
<br />
'''First''', change the default background in your terminal preferences (this example uses Xfce's Terminal program) to #D2D2D2, and the text color to #000000. The font is listed as DejaVu Sans Mono Book 12. The cursor color is #00AA00, and the tab activity color is #AF0000.<br />
<br />
'''Second''', in ~/.bashrc and right after the PS1= line, enter a new line with the following:<br />
{{bc|<nowiki>PS1='\e[1;33;47m\u \e[1;32;47mon \h \e[1;35;47m\d \@\e[0;0m\n\e[1;34m[dir.= \w] \# &gt; \e[0;0m'</nowiki>}}<br />
And then place a # in front of the first PS1 line to remark it out.<br />
<br />
'''Third''', for root user, edit /root/.bashrc in the same manner to include:<br />
{{bc|<nowiki>PS1='\e[1;31;47m\u \e[1;32;47mon \h \e[1;35;47m\d \@\e[0;0m\n\e[1;31m[dir.= \w] \# &gt; \e[0;0m'</nowiki>}}<br />
Do not forget to comment out the old line.<br />
<br />
These are double-line prompts, and they should look something like these:<br />
<br />
:'''user'''<br />
<br />
<div style="font-family: monospace; margin: 1em 3em; padding: 1em; border: 3px solid #bbccdd; font-weight: bold; color: #0000ff; background-color: #d2d2d2;"><span style="color: #ff0000; background: #A9A9A9;">Root</span><span style="color: #00ff00; background: #A9A9A9;"> on myhost</span><span style="color: #ff00ff; background: #A9A9A9;"> Sun Jan 15 12:30 PM</span><br />[dir.= /etc/rc.d] 1 &gt;</div><br />
<br />
:'''root'''<br />
<br />
<div style="font-family: monospace; margin: 1em 3em; padding: 1em; border: 3px solid #bbccdd; font-weight: bold; color: #ff0000; background-color: #d2d2d2;"><span style="color: #ff0000; background: #A9A9A9;">Root</span><span style="color: #00ff00; background: #A9A9A9;"> on myhost</span><span style="color: #ff00ff; background: #A9A9A9;"> Sun Jan 15 12:30 PM</span><br />[dir.= /etc/rc.d] 1 &gt;</div><br />
<br />
You will note that the background colors make them easier to read, and the text colors just keep things interesting. There is a lot of leeway to make them personalized, just with the use of colors. Enjoy!<br />
<br />
==Set window title==<br />
<br />
[[Xterm]] and many other terminal emulators (including PuTTY) allow you to set the window title using special escape sequences. You can define the {{ic|<nowiki>${XTERM_TITLE}</nowiki>}} variable as follows, then insert it at the beginning of the prompt to set [[xterm]] title (if available) to directory@user@hostname:<br />
<br />
{{bc|<nowiki>#set xterm title<br />
case "$TERM" in<br />
xterm | xterm-color)<br />
XTERM_TITLE='\[\e]0;\W@\u@\H\a\]'<br />
;;<br />
esac</nowiki>}}<br />
<br />
The text between {{ic|0;}} and {{ic|\a}} can be set to anything you like, for example:<br />
<br />
{{bc|<nowiki>export PS1="\[\e]0;Welcome to ArchLinux\a\]\$&gt;&gt; "</nowiki>}}<br />
<br />
sets the window title to "Welcome to ArchLinux" and displays this simple prompt: <br />
<br />
<div style="font-family: monospace; margin: 1em 3em; padding: 1em; border: 3px solid #bcd; background-color: black; color: #fff;">$&gt;&gt; <span style="text-decoration: blink;">_</span></div><br />
<br />
==Different colors for text entry and console output==<br />
<br />
If you do not reset the text color at the end of your prompt, both the text you enter and the console text will simply stay in that color. If you want to edit text in a special color but still use the default color for command output, you will need to reset the color after you press enter, but still before any commands get run. You can do this by installing a DEBUG trap in your ~/.bashrc, like this:<br />
<br />
{{bc|<nowiki>trap 'echo -ne "\e[0m"' DEBUG</nowiki>}}<br />
<br />
==Laptop battery status on prompt==<br />
<br />
Read [http://www.basicallytech.com/blog/index.php?/archives/110-Colour-coded-battery-charge-level-and-status-in-your-bash-prompt.html this article] and [https://bbs.archlinux.org/viewtopic.php?pid=1156660#p1156660 this post] for details.<br />
<br />
==See also==<br />
<br />
* {{AUR|gentoo-bashrc}} from [[AUR]]<br />
* tput(1)<br />
* [http://tldp.org/HOWTO/Bash-Prompt-HOWTO/x405.html Colours and Cursor Movement With tput]<br />
<br />
==External links==<br />
<br />
* Forum Discussions:<br />
** [https://bbs.archlinux.org/viewtopic.php?id=1817 BASH prompt]<br />
** [https://bbs.archlinux.org/viewtopic.php?id=50885 What's your PS1?]<br />
* [http://xcolors.net/ Nice Xresources color schemes collection]<br />
* [http://www.tldp.org/HOWTO/Bash-Prompt-HOWTO/x329.html Bash Prompt HOWTO]<br />
* [http://gilesorr.com/bashprompt/prompts/index.html Giles Orr's collection of sample prompts]<br />
* [http://misc.flogisoft.com/bash/tip_colors_and_formatting Bash tips: Colors and formatting]</div>Max-khttps://wiki.archlinux.org/index.php?title=Bash/Prompt_customization&diff=288050Bash/Prompt customization2013-12-15T11:38:15Z<p>Max-k: /* Version #2: with unicode error status symbols */</p>
<hr />
<div>[[Category:Eye candy]]<br />
[[Category:Command shells]]<br />
[[de:Bash-Prompt anpassen]]<br />
[[es:Color Bash Prompt]]<br />
[[it:Color Bash Prompt]]<br />
[[ru:Color Bash Prompt]]<br />
[[zh-CN:Color Bash Prompt]]<br />
{{Article summary start}}<br />
{{Article summary text|Discussing and improving Bash graphical customisations.}}<br />
{{Article summary heading|Related}}<br />
{{Article summary wiki|Environment Variables}}<br />
{{Article summary wiki|Bash}}<br />
{{Article summary end}}<br />
There are a variety of possibilities for [[Bash]]'s prompt (PS1), and customizing it can help you be more productive at the command line. You can add additional information to your prompt, or you can simply add color to it to make the prompt stand out. See [https://bbs.archlinux.org/viewtopic.php?id=50885 this Forum thread] for more informations and examples.<br />
<br />
=A well-established Bash color prompt=<br />
<br />
What follows is a well-proven way to color the Bash prompt. It is the most widespread Bash color scheme in the GNU/Linux world. Here is a preview of how it will appear:<br />
<br />
<div style="font-family: monospace; margin: 1em 3em; padding: 1em; border: 3px solid #bcd; background-color: black; color: #fff;">I am two with nature.<br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;-- Woody Allen<br /><span style="color: #0a0; font-weight: bold;">andy@alba</span> <span style="color: #55f; font-weight: bold;">~ $</span> ls<br /><span style="color: #55f; font-weight: bold;">Desktop Documents Music</span> public.desktop<br /><span style="color: #0a0; font-weight: bold;">andy@alba</span> <span style="color: #55f; font-weight: bold;">~ $</span> I\ will\ try\ to\ type\ a\ wrong\ command...<br />bash: I will try to type a wrong command...: command not found<br /><span style="color: #0a0; font-weight: bold;">andy@alba</span> <span style="color: #55f; font-weight: bold;">~</span> <span style="color: #a00; font-weight: bold;">:(</span> <span style="color: #55f; font-weight: bold;">$</span> echo 'Hello world!'<br />Hello world!<br /><span style="color: #0a0; font-weight: bold;">andy@alba</span> su<br />Password:<br />Two can Live as Cheaply as One for Half as Long.<br /> &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;-- Howard Kandel<br /><span style="color: #a00; font-weight: bold;">alba</span> <span style="color: #55f; font-weight: bold;">~ $</span> <span style="text-decoration: blink;">_</span></div><br />
<br />
==Installation==<br />
{{Warning|You should back up any system-wide bash files you modify in {{ic|/etc}} as simple syntax mistakes may break your shell.}}<br />
<br />
It's a '''generalized scheme for all users''', so you should start renaming your {{ic|~/.bashrc}} file and then copy the {{ic|/etc/bash.bashrc}} file to {{ic|/etc/bash.bashrc.back}} and create a {{ic|/etc/DIR_COLORS}} file ({{ic|~/.bashrc}} and {{ic|/etc/bash.bashrc}} [[Color_Bash_Prompt#Example_of_cohabitation_of_.2Fetc.2Fbash.bashrc_and_.7E.2F.bashrc|can also cohabitate]]). Here is our possible version of this scheme for Arch (originally this scheme was created for Gentoo, but here are some important additions).<br />
<br />
===/etc/bash.bashrc===<br />
<br />
<pre style="max-height: 400px; overflow:auto;"># /etc/bash.bashrc<br />
#<br />
# https://wiki.archlinux.org/index.php/Color_Bash_Prompt<br />
#<br />
# This file is sourced by all *interactive* bash shells on startup,<br />
# including some apparently interactive shells such as scp and rcp<br />
# that can't tolerate any output. So make sure this doesn't display<br />
# anything or bad things will happen !<br />
<br />
# Test for an interactive shell. There is no need to set anything<br />
# past this point for scp and rcp, and it's important to refrain from<br />
# outputting anything in those cases.<br />
<br />
# If not running interactively, don't do anything!<br />
[[ $- != *i* ]] &amp;&amp; return<br />
<br />
# Bash won't get SIGWINCH if another process is in the foreground.<br />
# Enable checkwinsize so that bash will check the terminal size when<br />
# it regains control.<br />
# http://cnswww.cns.cwru.edu/~chet/bash/FAQ (E11)<br />
shopt -s checkwinsize<br />
<br />
# Enable history appending instead of overwriting.<br />
shopt -s histappend<br />
<br />
case ${TERM} in<br />
xterm*|rxvt*|Eterm|aterm|kterm|gnome*)<br />
PROMPT_COMMAND=${PROMPT_COMMAND:+$PROMPT_COMMAND; }'printf "\033]0;%s@%s:%s\007" "${USER}" "${HOSTNAME%%.*}" "${PWD/#$HOME/~}"'<br />
;;<br />
screen)<br />
PROMPT_COMMAND=${PROMPT_COMMAND:+$PROMPT_COMMAND; }'printf "\033_%s@%s:%s\033\\" "${USER}" "${HOSTNAME%%.*}" "${PWD/#$HOME/~}"'<br />
;;<br />
esac<br />
<br />
# fortune is a simple program that displays a pseudorandom message<br />
# from a database of quotations at logon and/or logout.<br />
# If you wish to use it, please install "fortune-mod" from the<br />
# official repositories, then uncomment the following line:<br />
<br />
# [[ "$PS1" ]] &amp;&amp; /usr/bin/fortune<br />
<br />
# Set colorful PS1 only on colorful terminals.<br />
# dircolors --print-database uses its own built-in database<br />
# instead of using /etc/DIR_COLORS. Try to use the external file<br />
# first to take advantage of user additions. Use internal bash<br />
# globbing instead of external grep binary.<br />
<br />
# sanitize TERM:<br />
safe_term=${TERM//[^[:alnum:]]/?}<br />
match_lhs=""<br />
<br />
[[ -f ~/.dir_colors ]] &amp;&amp; match_lhs="${match_lhs}$(&lt;~/.dir_colors)"<br />
[[ -f /etc/DIR_COLORS ]] &amp;&amp; match_lhs="${match_lhs}$(&lt;/etc/DIR_COLORS)"<br />
[[ -z ${match_lhs} ]] \<br />
&amp;&amp; type -P dircolors &gt;/dev/null \<br />
&amp;&amp; match_lhs=$(dircolors --print-database)<br />
<br />
if [[ $'\n'${match_lhs} == *$'\n'"TERM "${safe_term}* ]] ; then<br />
<br />
# we have colors :-)<br />
<br />
# Enable colors for ls, etc. Prefer ~/.dir_colors<br />
if type -P dircolors &gt;/dev/null ; then<br />
if [[ -f ~/.dir_colors ]] ; then<br />
eval $(dircolors -b ~/.dir_colors)<br />
elif [[ -f /etc/DIR_COLORS ]] ; then<br />
eval $(dircolors -b /etc/DIR_COLORS)<br />
fi<br />
fi<br />
<br />
PS1="$(if [[ ${EUID} == 0 ]]; then echo '\[\033[01;31m\]\h'; else echo '\[\033[01;32m\]\u@\h'; fi)\[\033[01;34m\] \w \$([[ \$? != 0 ]] &amp;&amp; echo \"\[\033[01;31m\]:(\[\033[01;34m\] \")\\$\[\033[00m\] "<br />
<br />
# Use this other PS1 string if you want \W for root and \w for all other users:<br />
# PS1="$(if [[ ${EUID} == 0 ]]; then echo '\[\033[01;31m\]\h\[\033[01;34m\] \W'; else echo '\[\033[01;32m\]\u@\h\[\033[01;34m\] \w'; fi) \$([[ \$? != 0 ]] &amp;&amp; echo \"\[\033[01;31m\]:(\[\033[01;34m\] \")\\$\[\033[00m\] "<br />
<br />
alias ls="ls --color=auto"<br />
alias dir="dir --color=auto"<br />
alias grep="grep --color=auto"<br />
alias dmesg='dmesg --color'<br />
<br />
# Uncomment the "Color" line in /etc/pacman.conf instead of uncommenting the following line...!<br />
<br />
# alias pacman="pacman --color=auto"<br />
<br />
else<br />
<br />
# show root@ when we do not have colors<br />
<br />
PS1="\u@\h \w \$([[ \$? != 0 ]] &amp;&amp; echo \":( \")\$ "<br />
<br />
# Use this other PS1 string if you want \W for root and \w for all other users:<br />
# PS1="\u@\h $(if [[ ${EUID} == 0 ]]; then echo '\W'; else echo '\w'; fi) \$([[ \$? != 0 ]] &amp;&amp; echo \":( \")\$ "<br />
<br />
fi<br />
<br />
PS2="&gt; "<br />
PS3="&gt; "<br />
PS4="+ "<br />
<br />
# Try to keep environment pollution down, EPA loves us.<br />
unset safe_term match_lhs<br />
<br />
# Try to enable the auto-completion (type: "pacman -S bash-completion" to install it).<br />
[ -r /usr/share/bash-completion/bash_completion ] &amp;&amp; . /usr/share/bash-completion/bash_completion<br />
<br />
# Try to enable the "Command not found" hook ("pacman -S pkgfile" to install it).<br />
# See also: https://wiki.archlinux.org/index.php/Bash#The_.22command_not_found.22_hook<br />
[ -r /usr/share/doc/pkgfile/command-not-found.bash ] &amp;&amp; . /usr/share/doc/pkgfile/command-not-found.bash</pre><br />
<br />
====Environment variables====<br />
<br />
There are also other programs which, to be colorized, require the setting of some [[Environment Variables|environment variables]]. This is the case of [[Man Page|man]], for example:<br />
<br />
{{bc|<nowiki>export LESS_TERMCAP_mb=$'\E[01;31m' \<br />
LESS_TERMCAP_md=$'\E[01;38;5;74m' \<br />
LESS_TERMCAP_me=$'\E[0m' \<br />
LESS_TERMCAP_se=$'\E[0m' \<br />
LESS_TERMCAP_so=$'\E[38;5;246m' \<br />
LESS_TERMCAP_ue=$'\E[0m' \<br />
LESS_TERMCAP_us=$'\E[04;38;5;146m' \</nowiki>}}<br />
<br />
For more info, see: [[Environment Variables]].<br />
<br />
===/etc/DIR_COLORS===<br />
<br />
<pre style="max-height: 300px; overflow:auto;"># Configuration file for the color ls utility<br />
# This file goes in the /etc directory, and must be world readable.<br />
# You can copy this file to .dir_colors in your $HOME directory to override<br />
# the system defaults.<br />
<br />
# COLOR needs one of these arguments: 'tty' colorizes output to ttys, but not<br />
# pipes. 'all' adds color characters to all output. 'none' shuts colorization<br />
# off.<br />
COLOR all<br />
<br />
# Extra command line options for ls go here.<br />
# Basically these ones are:<br />
# -F = show '/' for dirs, '*' for executables, etc.<br />
# -T 0 = don't trust tab spacing when formatting ls output.<br />
OPTIONS -F -T 0<br />
<br />
# Below, there should be one TERM entry for each termtype that is colorizable<br />
TERM linux<br />
TERM console<br />
TERM con132x25<br />
TERM con132x30<br />
TERM con132x43<br />
TERM con132x60<br />
TERM con80x25<br />
TERM con80x28<br />
TERM con80x30<br />
TERM con80x43<br />
TERM con80x50<br />
TERM con80x60<br />
TERM xterm<br />
TERM xterm-color<br />
TERM vt100<br />
TERM rxvt<br />
TERM rxvt-256color<br />
TERM rxvt-cygwin<br />
TERM rxvt-cygwin-native<br />
TERM rxvt-unicode<br />
TERM rxvt-unicode-256color<br />
TERM rxvt-unicode256<br />
TERM screen<br />
<br />
# EIGHTBIT, followed by '1' for on, '0' for off. (8-bit output)<br />
EIGHTBIT 1<br />
<br />
# Below are the color init strings for the basic file types. A color init<br />
# string consists of one or more of the following numeric codes:<br />
# Attribute codes: <br />
# 00=none 01=bold 04=underscore 05=blink 07=reverse 08=concealed<br />
# Text color codes:<br />
# 30=black 31=red 32=green 33=yellow 34=blue 35=magenta 36=cyan 37=white<br />
# Background color codes:<br />
# 40=black 41=red 42=green 43=yellow 44=blue 45=magenta 46=cyan 47=white<br />
NORMAL 00 # global default, although everything should be something.<br />
FILE 00 # normal file<br />
DIR 01;34 # directory<br />
LINK 01;36 # symbolic link<br />
FIFO 40;33 # pipe<br />
SOCK 01;35 # socket<br />
BLK 40;33;01 # block device driver<br />
CHR 40;33;01 # character device driver<br />
<br />
# This is for files with execute permission:<br />
EXEC 01;32 <br />
<br />
# List any file extensions like '.gz' or '.tar' that you would like ls<br />
# to colorize below. Put the extension, a space, and the color init string.<br />
# (and any comments you want to add after a '#')<br />
.cmd 01;32 # executables (bright green)<br />
.exe 01;32<br />
.com 01;32<br />
.btm 01;32<br />
.bat 01;32<br />
.tar 01;31 # archives or compressed (bright red)<br />
.tgz 01;31<br />
.arj 01;31<br />
.taz 01;31<br />
.lzh 01;31<br />
.zip 01;31<br />
.z 01;31<br />
.Z 01;31<br />
.gz 01;31<br />
.jpg 01;35 # image formats<br />
.gif 01;35<br />
.bmp 01;35<br />
.xbm 01;35<br />
.xpm 01;35<br />
.tif 01;35</pre><br />
<br />
===/etc/pacman.conf===<br />
<br />
As of version 4.1, Pacman has a '''color''' option. In order to activate it, please, uncomment the {{ic|#Color}} line in {{ic|/etc/pacman.conf}}.<br />
<br />
===/etc/skel/===<br />
<br />
This tip shows you how to use {{ic|/etc/skel/}} directory to ensure that all new users on your system get the same initial settings.<br />
<br />
The {{ic|/etc/skel/}} directory is the directory used by {{ic|useradd}} to create the default settings in a new user's home directory.<br />
<br />
To change the location of {{ic|/etc/skel/}}, edit {{ic|/etc/default/useradd}}.<br />
<br />
{{bc|<nowiki># useradd defaults file <br />
GROUP=100 <br />
HOME=/home <br />
INACTIVE=-1 <br />
EXPIRE= <br />
SHELL=/bin/bash <br />
SKEL=/etc/skel</nowiki>}}<br />
<br />
Typically files included in {{ic|/etc/skel/}} are {{ic|.rc}} files for shell initialization, but you could also include a {{ic|public_html}} directory, a custom {{ic|.dir_colors}} file, or anything else.<br />
<br />
<div style="font-family: monospace; margin: 1em 3em; padding: 1em; border: 3px solid #bcd; background-color: black; color: #fff;"><span style="color: #0a0; font-weight: bold;">andy@alba</span> <span style="color: #55f; font-weight: bold;">/etc/skel $</span> ls -A<br />.bash_logout .bash_profile .bashrc .xinitrc .xsession<br /><span style="color: #0a0; font-weight: bold;">andy@alba</span> <span style="color: #55f; font-weight: bold;">/etc/skel $</span> <span style="text-decoration: blink;">_</span></div><br />
<br />
For more information on customizing the {{ic|/etc/skel/}} directory, type: {{ic|$ man useradd}}. See also: [http://www.gentoo.org/news/en/gwn/20031222-newsletter.xml http://www.gentoo.org/news/en/gwn/20031222-newsletter.xml].<br />
<br />
Now, the {{ic|/etc/skel/.bashrc}} file is the {{ic|.bashrc}} file copyied into the home directory of each ''new'' user. It will look something like this:<br />
<br />
{{bc|<nowiki>#<br />
# ~/.bashrc<br />
#<br />
<br />
# If not running interactively, don't do anything<br />
[[ $- != *i* ]] &amp;&amp; return<br />
<br />
alias ls='ls --color=auto'<br />
PS1='[\u@\h \W]\$ '</nowiki>}}<br />
<br />
As you can see, a {{ic|PS1}} variable (i.e.: the prompt) is exported. So, if you had previously created a color prompt through the {{ic|/etc/bash.bashrc}} file, each user newly created, to see it, should delete the line<br />
<br />
{{bc|<nowiki>PS1='[\u@\h \W]\$ '</nowiki>}}<br />
<br />
from his own {{ic|~/.bashrc}}. Accordingly, if you want to grant to newly created users to have the same colorfull {{ic|PS1}}, you should delete that line from {{ic|/etc/skel/.bashrc}}.<br />
<br />
==Example of cohabitation of /etc/bash.bashrc and ~/.bashrc==<br />
<br />
{{ic|~/.bashrc}} and {{ic|/etc/bash.bashrc}} can also cohabitate. Here is a possible example of a typical Arch user's {{ic|~/.bashrc}} file which can cohabit with the {{ic|/etc/bash.bashrc}} file proposed here, valid for all users. The output will remain coloured.<br />
<br />
{{bc|<nowiki>#<br />
# ~/.bashrc<br />
#<br />
<br />
# If not running interactively, don't do anything<br />
[[ $- != *i* ]] &amp;&amp; return<br />
<br />
# environment variables<br />
export EDITOR="$(if [[ -n $DISPLAY ]]; then echo 'gedit'; else echo 'nano'; fi)" # gedit, nano<br />
<br />
# pacman aliases (if desired, adapt for your favourite AUR helper)<br />
alias pac="sudo /usr/bin/pacman -S" # default action - install one or more packages<br />
alias pacu="sudo /usr/bin/pacman -Syu" # '[u]pdate' - upgrade all packages to their newest version<br />
alias pacr="sudo /usr/bin/pacman -Rns" # '[r]emove' - uninstall one or more packages<br />
alias pacs="/usr/bin/pacman -Ss" # '[s]earch' - search for a package using one or more keywords<br />
alias paci="/usr/bin/pacman -Si" # '[i]nfo' - show information about a package<br />
alias paclo="/usr/bin/pacman -Qdt" # '[l]ist [o]rphans' - list all packages which are orphaned<br />
alias pacc="sudo /usr/bin/pacman -Scc" # '[c]lean cache' - delete all not currently installed package files<br />
alias paclf="/usr/bin/pacman -Ql" # '[l]ist [f]iles' - list all files installed by a given package<br />
alias pacexpl="sudo /usr/bin/pacman -D --asexp" # 'mark as [expl]icit' - mark one or more packages as explicitly installed <br />
alias pacimpl="sudo /usr/bin/pacman -D --asdep" # 'mark as [impl]icit' - mark one or more packages as non explicitly installed<br />
<br />
# '[r]emove [o]rphans' - recursively remove ALL orphaned packages<br />
alias pacro="/usr/bin/pacman -Qtdq > /dev/null && sudo /usr/bin/pacman -Rns \$(/usr/bin/pacman -Qtdq | sed -e ':a;N;$!ba;s/\n/ /g')"</nowiki>}}<br />
<br />
== Random quotations at logon ==<br />
<br />
If you want a random quotation at logon (like Slackware) you must install {{Pkg|fortune-mod}}. fortune is a simple program that displays a pseudorandom message from a database of quotations at logon and/or logout. Uncomment the following line from [[Color_Bash_Prompt#.2Fetc.2Fbash.bashrc|our]] {{ic|/etc/bash.bashrc}} file:<br />
{{bc|<nowiki># [[ "$PS1" ]] &amp;&amp; /usr/bin/fortune</nowiki>}}<br />
<br />
If you want to colorize (brown in this example) the random message from fortune, replace the previous commented text with:<br />
{{bc|<nowiki>[[ "$PS1" ]] &amp;&amp; echo -e "\e[00;33m$(/usr/bin/fortune)\e[00m"</nowiki>}}<br />
<br />
== Colorized Arch latest news at logon ==<br />
<br />
If you want to read the latest news from the [https://www.archlinux.org/news/ Arch official website], instead of a random quotation from fortune, replace the following lines from [[Color_Bash_Prompt#.2Fetc.2Fbash.bashrc|our]] {{ic|/etc/bash.bashrc}} file:<br />
{{bc|<nowiki># fortune is a simple program that displays a pseudorandom message<br />
# from a database of quotations at logon and/or logout.<br />
# If you wish to use it, uncomment the following line:<br />
<br />
# [[ "$PS1" ]] &amp;&amp; /usr/bin/fortune</nowiki>}}<br />
with:<br />
{{bc|<nowiki># Arch latest news<br />
<br />
if [ "$PS1" ]; then<br />
# The characters "&pound;, &sect;" are used as metacharacters. They should not be encountered in a feed...<br />
echo -e "$(echo $(curl --silent https://www.archlinux.org/feeds/news/ | sed -e ':a;N;$!ba;s/\n/ /g') | \<br />
sed -e 's/&amp;amp;/\&amp;/g<br />
s/&amp;lt;\|&amp;#60;/&lt;/g<br />
s/&amp;gt;\|&amp;#62;/&gt;/g<br />
s/&lt;\/a&gt;/&pound;/g<br />
s/href\=\"/&sect;/g<br />
s/&lt;title&gt;/\\n\\n\\n :: \\e[01;31m/g; s/&lt;\/title&gt;/\\e[00m ::\\n/g<br />
s/&lt;link&gt;/ [ \\e[01;36m/g; s/&lt;\/link&gt;/\\e[00m ]/g<br />
s/&lt;description&gt;/\\n\\n\\e[00;37m/g; s/&lt;\/description&gt;/\\e[00m\\n\\n/g<br />
s/&lt;p\( [^&gt;]*\)\?&gt;\|&lt;br\s*\/\?&gt;/\n/g<br />
s/&lt;b\( [^&gt;]*\)\?&gt;\|&lt;strong\( [^&gt;]*\)\?&gt;/\\e[01;30m/g; s/&lt;\/b&gt;\|&lt;\/strong&gt;/\\e[00;37m/g<br />
s/&lt;i\( [^&gt;]*\)\?&gt;\|&lt;em\( [^&gt;]*\)\?&gt;/\\e[41;37m/g; s/&lt;\/i&gt;\|&lt;\/em&gt;/\\e[00;37m/g<br />
s/&lt;u\( [^&gt;]*\)\?&gt;/\\e[4;37m/g; s/&lt;\/u&gt;/\\e[00;37m/g<br />
s/&lt;code\( [^&gt;]*\)\?&gt;/\\e[00m/g; s/&lt;\/code&gt;/\\e[00;37m/g<br />
s/&lt;a[^&sect;|t]*&sect;\([^\"]*\)\"[^&gt;]*&gt;\([^&pound;]*\)[^&pound;]*&pound;/\\e[01;31m\2\\e[00;37m \\e[01;34m[\\e[00;37m \\e[04m\1\\e[00;37m\\e[01;34m ]\\e[00;37m/g<br />
s/&lt;li\( [^&gt;]*\)\?&gt;/\n \\e[01;34m*\\e[00;37m /g<br />
s/&lt;!\[CDATA\[\|\]\]&gt;//g<br />
s/\|&gt;\s*&lt;//g<br />
s/ *&lt;[^&gt;]\+&gt; */ /g<br />
s/[&lt;&gt;&pound;&sect;]//g')\n\n";<br />
fi</nowiki>}}<br />
that is a small and coloured RSS escaping script written by the user [https://aur.archlinux.org/account.php?Action=AccountInfo&ID=33208 grufo] which will display an output like this:<br />
<br />
<div style="height: 350px; overflow: auto; font-family: monospace; margin: 1em 3em; padding: 1em; border: 3px solid #bbccdd; background-color: black; color: #aaaaaa;">&nbsp;&nbsp; <span style="color: #ffffff; font-weight: bold;">::</span> <span style="color: #aa0000; font-weight: bold;">Arch Linux: Recent news updates</span> <span style="color: #ffffff; font-weight: bold;">::</span><br />&nbsp;<span style="color: #ffffff;">[</span> <span style="color: #55ccff; font-weight: bold;"><nowiki>https://www.archlinux.org/news/</nowiki></span> <span style="color: #ffffff;">]</span><br /><br />The latest and greatest news from the Arch Linux distribution.<br /><br />&nbsp;<span style="color: #aa0000; font-weight: bold;">en-us Sun, 04 Nov 2012 16:09:46 +0000</span><br /><br /><br />&nbsp;&nbsp; <span style="color: #ffffff; font-weight: bold;">::</span> <span style="color: #aa0000; font-weight: bold;">End of initscripts support</span> <span style="color: #ffffff; font-weight: bold;">::</span><br />&nbsp;<span style="color: #ffffff;">[</span> <span style="color: #55ccff; font-weight: bold;"><nowiki>https://www.archlinux.org/news/end-of-initscripts-support/</nowiki></span> <span style="color: #ffffff;">]</span><br /><br /><br />Tom Gundersen wrote:<br />As <span style="color: #ffffff;">systemd</span> is now the default init system, Arch Linux is receiving minimal testing on initscripts systems. Due to a lack of resources and interest, we are unlikely to work on fixing <span style="color: #ffffff;">initscripts</span>-specific bugs, and may close them as WONTFIX.<br />We therefore strongly encourage all users to migrate to <span style="color: #ffffff;">systemd</span> as soon as possible. See the <span style="color: #ffffff;">systemd</span> migration guide <span style="color: #5555ff;">[</span> <span style="text-decoration: underline;"><nowiki>https://wiki.archlinux.org/index.php/Systemd</nowiki></span> <span style="color: #5555ff;">]</span>.<br />To ease the transition, <span style="color: #ffffff;">initscripts</span> support will remain in the official repositories for the time being, unless otherwise stated. As of January 2013, we will start removing <span style="color: #ffffff;">initscripts</span> support (e.g., <span style="color: #ffffff;">rc</span> scripts) from individual packages without further notice.<br /><br />&nbsp;<span style="color: #ffffff;">Tom Gundersen Sun, 04 Nov 2012 16:09:46 +0000 tag:www.archlinux.org,2012-11-04:/news/end-of-initscripts-support/</span><br /><br /><br />&nbsp;&nbsp; <span style="color: #ffffff; font-weight: bold;">::</span> <span style="color: #aa0000; font-weight: bold;">November release of install media available</span> <span style="color: #ffffff; font-weight: bold;">::</span><br />&nbsp;<span style="color: #ffffff;">[</span> <span style="color: #55ccff; font-weight: bold;"><nowiki>https://www.archlinux.org/news/november-release-of-install-media-available/</nowiki></span> <span style="color: #ffffff;">]</span><br /><br /><br />Pierre Schmitz wrote:<br />The latest snapshot of our install and rescue media can be found on our <span style="color: #aa0000; font-weight: bold;">Download</span> <span style="color: #5555ff;">[</span> <span style="text-decoration: underline;"><nowiki>https://www.archlinux.org/download/</nowiki></span> <span style="color: #5555ff;">]</span> page. The 2012.11.01 ISO image mainly contains minor bug fixes, cleanups and new packages compared to the previous one:<br />&nbsp;<span style="color: #5555ff;">*</span> First media with Linux 3.6<br />&nbsp;<span style="color: #5555ff;">*</span> <span style="background-color: #aa0000;">copytoram=n</span> can be used to not copy the image to RAM on network boot. This is probably unreliable but an option for systems with very low memory.<br />&nbsp;<span style="color: #5555ff;">*</span> <span style="background-color: #aa0000;">cowfile_size</span> boot parameter mainly for persistent COW on VFAT. See the <span style="color: #aa0000; font-weight: bold;">README</span> <span style="color: #5555ff;">[</span> <span style="text-decoration: underline;"><nowiki>https://projects.archlinux.org/archiso.git/plain/docs/README.bootparams?id=v4</nowiki></span> <span style="color: #5555ff;">]</span> file for details.<br /><br />&nbsp;<span style="color: #ffffff;">Pierre Schmitz Fri, 02 Nov 2012 17:54:15 +0000 tag:www.archlinux.org,2012-11-02:/news/november-release-of-install-media-available/</span><br /><br /><br />&nbsp;&nbsp; <span style="color: #ffffff; font-weight: bold;">::</span> <span style="color: #aa0000; font-weight: bold;">Bug Squashing Day: Saturday 17th November</span> <span style="color: #ffffff; font-weight: bold;">::</span><br />&nbsp;<span style="color: #ffffff;">[</span> <span style="color: #55ccff; font-weight: bold;"><nowiki>https://www.archlinux.org/news/bug-squashing-day-saturday-17th-november/</nowiki></span> <span style="color: #ffffff;">]</span><br /><br /><br />Allan McRae wrote:<br />The number of bugs in the Arch Linux bug tracker is creeping up so it is time for some extermination.<br />This is a great way for the community to get involved and help the Arch Linux team. The process is simple. First look at a bug for your favorite piece of software in the bug tracker and check if it still occurs. If it does, check the upstream project for a fix and test it to confirm it works. If there is no fix available, make sure the bug has been filed in the upstream tracker.<br />Join us on the #archlinux-bugs IRC channel. We are spread across timezones, so people should be around all day.<br /><br />&nbsp;<span style="color: #ffffff;">Allan McRae Thu, 01 Nov 2012 12:28:51 +0000 tag:www.archlinux.org,2012-11-01:/news/bug-squashing-day-saturday-17th-november/</span><br /><br /><br />&nbsp;&nbsp; <span style="color: #ffffff; font-weight: bold;">::</span> <span style="color: #aa0000; font-weight: bold;">ConsoleKit replaced by logind</span> <span style="color: #ffffff; font-weight: bold;">::</span><br />&nbsp;<span style="color: #ffffff;">[</span> <span style="color: #55ccff; font-weight: bold;"><nowiki>https://www.archlinux.org/news/consolekit-replaced-by-logind/</nowiki></span> <span style="color: #ffffff;">]</span><br /><br /><br />Allan McRae wrote:<br />With GNOME 3.6, polkit and networkmanager moving to [extra], ConsoleKit has now been removed from the repositories. Any package that previously depended on it now relies on systemd-logind instead. That means that the system must be booted with systemd to be fully functional.<br />In addition to GNOME, both KDE and XFCE are also affected by this change.<br /><br />&nbsp;<span style="color: #ffffff;">Allan McRae Tue, 30 Oct 2012 22:17:39 +0000 tag:www.archlinux.org,2012-10-30:/news/consolekit-replaced-by-logind/</span><br /><br /><br />&nbsp;&nbsp; <span style="color: #ffffff; font-weight: bold;">::</span> <span style="color: #aa0000; font-weight: bold;">systemd is now the default on new installations</span> <span style="color: #ffffff; font-weight: bold;">::</span><br />&nbsp;<span style="color: #ffffff;">[</span> <span style="color: #55ccff; font-weight: bold;"><nowiki>https://www.archlinux.org/news/systemd-is-now-the-default-on-new-installations/</nowiki></span> <span style="color: #ffffff;">]</span><br /><br /><br />Thomas B&auml;chler wrote:<br />The base group now contains the <span style="color: #ffffff;">systemd-sysvcompat</span> package. This means that all new installations will boot with systemd by default.<br />As some packages still lack native systemd units, users can install the <span style="color: #ffffff;">initscripts</span> package and use the <span style="color: #ffffff;">DAEMONS</span> array in <span style="color: #ffffff;">/etc/rc.conf</span> to start services using the legacy rc.d scripts.<br />This change does not affect existing installations. For the time being, the <span style="color: #ffffff;">initscripts</span> and <span style="color: #ffffff;">sysvinit</span> packages remain available from our repositories. However, individual packages may now start relying on the system being booted with systemd.<br />Please refer to <span style="color: #aa0000; font-weight: bold;">the wiki</span> <span style="color: #5555ff;">[</span> <span style="text-decoration: underline;"><nowiki>https://wiki.archlinux.org/index.php/Systemd</nowiki></span> <span style="color: #5555ff;">]</span> for how to transition an existing installation to systemd.<br /><br />&nbsp;<span style="color: #ffffff;">Thomas B&auml;chler Sat, 13 Oct 2012 09:29:38 +0000 tag:www.archlinux.org,2012-10-13:/news/systemd-is-now-the-default-on-new-installations/</span><br /><br /><br />&nbsp;&nbsp; <span style="color: #ffffff; font-weight: bold;">::</span> <span style="color: #aa0000; font-weight: bold;">Install medium 2012.10.06 introduces systemd</span> <span style="color: #ffffff; font-weight: bold;">::</span><br />&nbsp;<span style="color: #ffffff;">[</span> <span style="color: #55ccff; font-weight: bold;"><nowiki>https://www.archlinux.org/news/install-medium-20121006-introduces-systemd/</nowiki></span> <span style="color: #ffffff;">]</span><br /><br /><br />Pierre Schmitz wrote:<br />The October release of the Arch Linux install medium is available for <span style="color: #aa0000; font-weight: bold;">Download</span> <span style="color: #5555ff;">[</span> <span style="text-decoration: underline;"><nowiki>https://www.archlinux.org/download/</nowiki></span> <span style="color: #5555ff;">]</span> and can be used for new installs or as a rescue system. It contains a set of updated packages and the following notable changes:<br />&nbsp;<span style="color: #5555ff;">*</span> systemd is used to boot up the live system.<br />&nbsp;<span style="color: #5555ff;">*</span> initscripts are no longer available on the live system but are still installed by default on the target system. This is likely to change in the near future.<br />&nbsp;<span style="color: #5555ff;">*</span> EFI boot and setup has been simplified.<br />&nbsp;<span style="color: #5555ff;">*</span> gummiboot is used to display a menu on EFI systems.<br />&nbsp;<span style="color: #5555ff;">*</span> The following new packages are available on the live system: ethtool, fsarchiver, gummiboot-efi, mc, partclone, partimage, refind-efi, rfkill, sudo, testdisk, wget, xl2tpd<br /><br />&nbsp;<span style="color: #ffffff;">Pierre Schmitz Sun, 07 Oct 2012 16:58:03 +0000 tag:www.archlinux.org,2012-10-07:/news/install-medium-20121006-introduces-systemd/</span><br /><br /><br />&nbsp;&nbsp; <span style="color: #ffffff; font-weight: bold;">::</span> <span style="color: #aa0000; font-weight: bold;">New install medium 2012.09.07</span> <span style="color: #ffffff; font-weight: bold;">::</span><br />&nbsp;<span style="color: #ffffff;">[</span> <span style="color: #55ccff; font-weight: bold;"><nowiki>https://www.archlinux.org/news/new-install-medium-20120907/</nowiki></span> <span style="color: #ffffff;">]</span><br /><br /><br />Pierre Schmitz wrote:<br />As is customary by now there is a new install medium available at the beginning of this month. The live system can be downloaded from <span style="color: #aa0000; font-weight: bold;">Download</span> <span style="color: #5555ff;">[</span> <span style="text-decoration: underline;"><nowiki>https://www.archlinux.org/download/</nowiki></span> <span style="color: #5555ff;">]</span> and be used for new installs or as a rescue system.<br />In addition to a couple of updated packages and bug fixes the following changes stand out:<br />&nbsp;<span style="color: #5555ff;">*</span> First medium with Linux 3.5 (3.5.3)<br />&nbsp;<span style="color: #5555ff;">*</span> The <span style="background-color: #aa0000;">script</span> boot parameter works again (<span style="color: #aa0000; font-weight: bold;">FS#31022</span> <span style="color: #5555ff;">[</span> <span style="text-decoration: underline;"><nowiki>https://bugs.archlinux.org/task/31022</nowiki></span> <span style="color: #5555ff;">]</span>)<br />&nbsp;<span style="color: #5555ff;">*</span> When booting via PXE and NFS or NBD the ISO will be copied to RAM to ensure a more stable usage.<br />&nbsp;<span style="color: #5555ff;">*</span> The live medium contains <span style="background-color: #aa0000;">usb_modeswitch</span> and <span style="background-color: #aa0000;">wvdial</span> which e.g. allows to establish a network connection using an UMTS USB dongle<br />&nbsp;<span style="color: #5555ff;">*</span> Furthermore the newest versions of <span style="background-color: #aa0000;">initscripts</span>, <span style="background-color: #aa0000;">systemd</span> and <span style="background-color: #aa0000;">netcfg</span> are included.<br /><br />&nbsp;<span style="color: #ffffff;">Pierre Schmitz Sat, 08 Sep 2012 09:48:52 +0000 tag:www.archlinux.org,2012-09-08:/news/new-install-medium-20120907/</span><br /><br /><br />&nbsp;&nbsp; <span style="color: #ffffff; font-weight: bold;">::</span> <span style="color: #aa0000; font-weight: bold;">Fontconfig 2.10.1 update - manual intervention required</span> <span style="color: #ffffff; font-weight: bold;">::</span><br />&nbsp;<span style="color: #ffffff;">[</span> <span style="color: #55ccff; font-weight: bold;"><nowiki>https://www.archlinux.org/news/fontconfig-2101-update-manual-intervention-required/</nowiki></span> <span style="color: #ffffff;">]</span><br /><br /><br />Andreas Radke wrote:<br />The fontconfig 2.10.1 update overwrites symlinks created by the former package version. These symlinks need to be removed before the update:<br /><br /><span style="color: #ffffff;">rm /etc/fonts/conf.d/20-unhint-small-vera.conf</span><br /><span style="color: #ffffff;">rm /etc/fonts/conf.d/20-fix-globaladvance.conf</span><br /><span style="color: #ffffff;">rm /etc/fonts/conf.d/29-replace-bitmap-fonts.conf</span><br /><span style="color: #ffffff;">rm /etc/fonts/conf.d/30-metric-aliases.conf</span><br /><span style="color: #ffffff;">rm /etc/fonts/conf.d/30-urw-aliases.conf</span><br /><span style="color: #ffffff;">rm /etc/fonts/conf.d/40-nonlatin.conf</span><br /><span style="color: #ffffff;">rm /etc/fonts/conf.d/45-latin.conf</span><br /><span style="color: #ffffff;">rm /etc/fonts/conf.d/49-sansserif.conf</span><br /><span style="color: #ffffff;">rm /etc/fonts/conf.d/50-user.conf</span><br /><span style="color: #ffffff;">rm /etc/fonts/conf.d/51-local.conf</span><br /><span style="color: #ffffff;">rm /etc/fonts/conf.d/60-latin.conf</span><br /><span style="color: #ffffff;">rm /etc/fonts/conf.d/65-fonts-persian.conf</span><br /><span style="color: #ffffff;">rm /etc/fonts/conf.d/65-nonlatin.conf</span><br /><span style="color: #ffffff;">rm /etc/fonts/conf.d/69-unifont.conf</span><br /><span style="color: #ffffff;">rm /etc/fonts/conf.d/80-delicious.conf</span><br /><span style="color: #ffffff;">rm /etc/fonts/conf.d/90-synthetic.conf</span><br /><span style="color: #ffffff;">pacman -Syu fontconfig</span><br /><br />Main systemwide configuration should be done by symlinks (especially for autohinting, sub-pixel and lcdfilter):<br /><br /><span style="color: #ffffff;">cd /etc/fonts/conf.d</span><br /><span style="color: #ffffff;">ln -s ../conf.avail/XX-foo.conf</span><br /><br />Also check <span style="color: #aa0000; font-weight: bold;">Font Configuration</span> <span style="color: #5555ff;">[</span> <span style="text-decoration: underline;"><nowiki>https://wiki.archlinux.org/index.php/Font_Configuration</nowiki></span> <span style="color: #5555ff;">]</span> and <span style="color: #aa0000; font-weight: bold;">Fonts</span> <span style="color: #5555ff;">[</span> <span style="text-decoration: underline;"><nowiki>https://wiki.archlinux.org/index.php/Fonts</nowiki></span> <span style="color: #5555ff;">]</span>.<br /><br />&nbsp;<span style="color: #ffffff;">Andreas Radke Thu, 06 Sep 2012 13:54:23 +0000 tag:www.archlinux.org,2012-09-06:/news/fontconfig-2101-update-manual-intervention-required/</span><br /><br /><br />&nbsp;&nbsp; <span style="color: #ffffff; font-weight: bold;">::</span> <span style="color: #aa0000; font-weight: bold;">netcfg-2.8.9 drops deprecated rc.conf compatibility</span> <span style="color: #ffffff; font-weight: bold;">::</span><br />&nbsp;<span style="color: #ffffff;">[</span> <span style="color: #55ccff; font-weight: bold;"><nowiki>https://www.archlinux.org/news/netcfg-289-drops-initscripts-compatibility/</nowiki></span> <span style="color: #ffffff;">]</span><br /><br /><br />Florian Pritz wrote:<br />Users of <span style="color: #ffffff;">netcfg</span> should configure all interfaces in <span style="color: #ffffff;">/etc/conf.d/netcfg</span> rather than <span style="color: #ffffff;">/etc/rc.conf</span>.<br /><br />&nbsp;Florian Pritz Sat, 11 Aug 2012 20:00:02 +0000 tag:www.archlinux.org,2012-08-11:/news/netcfg-289-drops-initscripts-compatibility/<br /><br /><br />&nbsp;&nbsp; <span style="color: #ffffff; font-weight: bold;">::</span> <span style="color: #aa0000; font-weight: bold;">Install media 2012.08.04 available</span> <span style="color: #ffffff; font-weight: bold;">::</span><br />&nbsp;<span style="color: #ffffff;">[</span> <span style="color: #55ccff; font-weight: bold;"><nowiki>https://www.archlinux.org/news/install-media-20120804-available/</nowiki></span> <span style="color: #ffffff;">]</span><br /><br /><br />Pierre Schmitz wrote:<br />The August snapshot of our live and install media comes with updated packages and the following changes on top of the <span style="color: #aa0000; font-weight: bold;">previous ISO image</span> <span style="color: #5555ff;">[</span> <span style="text-decoration: underline;">/news/install-media-20120715-released/</span> <span style="color: #5555ff;">]</span>:<br />&nbsp;<span style="color: #5555ff;">*</span> GRUB 2.0 instead of the legacy 0.9 version is available.<br />&nbsp;<span style="color: #5555ff;">*</span> The <span style="color: #aa0000; font-weight: bold;">Installation Guide</span> <span style="color: #5555ff;">[</span> <span style="text-decoration: underline;"><nowiki>https://wiki.archlinux.org/index.php/Installation_Guide</nowiki></span> <span style="color: #5555ff;">]</span> can be found at <span style="background-color: #aa0000;">/root/install.txt</span>.<br />&nbsp;<span style="color: #5555ff;">*</span> ZSH with <span style="color: #aa0000; font-weight: bold;">Grml's configuration</span> <span style="color: #5555ff;">[</span> <span style="text-decoration: underline;"><nowiki>http://grml.org/zsh/</nowiki></span> <span style="color: #5555ff;">]</span> is used as interactive shell to provide a user friendly and more convenient environment. This includes completion support for pacstrap, arch-chroot, pacman and most other tools.<br />&nbsp;<span style="color: #5555ff;">*</span> The network daemon is started by default which will automatically setup your network if DHCP is available.<br />Note that all these changes only affect the live system and not the base system you install using pacstrap. The ISO image can be downloaded from our <span style="color: #aa0000; font-weight: bold;">download page</span> <span style="color: #5555ff;">[</span> <span style="text-decoration: underline;">/download/</span> <span style="color: #5555ff;">]</span>. The next snapshot is scheduled for September.<br /><br />&nbsp;<span style="color: #ffffff;">Pierre Schmitz Sat, 04 Aug 2012 17:24:30 +0000 tag:www.archlinux.org,2012-08-04:/news/install-media-20120804-available/</span><br /><br /><br /><span style="color: #0a0; font-weight: bold;">andy@alba</span> <span style="text-decoration: blink;">_</span></div><br />
<br />
If you don't want to see months worth of updates but only the latest item, you can use this::<br />
{{bc|<nowiki># Arch latest news<br />
<br />
if [ "$PS1" ]; then<br />
# The characters "&pound;, &sect;" are used as metacharacters. They should not be encountered in a feed...<br />
echo -e "$(echo $(curl --silent https://www.archlinux.org/feeds/news/ | awk ' NR == 1 {while ($0 !~ /<\/item>/) {print;getline} sub(/<\/item>.*/,"</item>") ;print}' | sed -e ':a;N;$!ba;s/\n/ /g') | \<br />
sed -e 's/&amp;amp;/\&amp;/g<br />
s/&amp;lt;\|&amp;#60;/&lt;/g<br />
s/&amp;gt;\|&amp;#62;/&gt;/g<br />
s/&lt;\/a&gt;/&pound;/g<br />
s/href\=\"/&sect;/g<br />
s/&lt;title&gt;/\\n\\n\\n :: \\e[01;31m/g; s/&lt;\/title&gt;/\\e[00m ::\\n/g<br />
s/&lt;link&gt;/ [ \\e[01;36m/g; s/&lt;\/link&gt;/\\e[00m ]/g<br />
s/&lt;description&gt;/\\n\\n\\e[00;37m/g; s/&lt;\/description&gt;/\\e[00m\\n\\n/g<br />
s/&lt;p\( [^&gt;]*\)\?&gt;\|&lt;br\s*\/\?&gt;/\n/g<br />
s/&lt;b\( [^&gt;]*\)\?&gt;\|&lt;strong\( [^&gt;]*\)\?&gt;/\\e[01;30m/g; s/&lt;\/b&gt;\|&lt;\/strong&gt;/\\e[00;37m/g<br />
s/&lt;i\( [^&gt;]*\)\?&gt;\|&lt;em\( [^&gt;]*\)\?&gt;/\\e[41;37m/g; s/&lt;\/i&gt;\|&lt;\/em&gt;/\\e[00;37m/g<br />
s/&lt;u\( [^&gt;]*\)\?&gt;/\\e[4;37m/g; s/&lt;\/u&gt;/\\e[00;37m/g<br />
s/&lt;code\( [^&gt;]*\)\?&gt;/\\e[00m/g; s/&lt;\/code&gt;/\\e[00;37m/g<br />
s/&lt;a[^&sect;|t]*&sect;\([^\"]*\)\"[^&gt;]*&gt;\([^&pound;]*\)[^&pound;]*&pound;/\\e[01;31m\2\\e[00;37m \\e[01;34m[\\e[00;37m \\e[04m\1\\e[00;37m\\e[01;34m ]\\e[00;37m/g<br />
s/&lt;li\( [^&gt;]*\)\?&gt;/\n \\e[01;34m*\\e[00;37m /g<br />
s/&lt;!\[CDATA\[\|\]\]&gt;//g<br />
s/\|&gt;\s*&lt;//g<br />
s/ *&lt;[^&gt;]\+&gt; */ /g<br />
s/[&lt;&gt;&pound;&sect;]//g')\n\n";<br />
fi</nowiki>}}<br />
<br />
See [https://bbs.archlinux.org/viewtopic.php?id=146850 this thread] for details.<br />
<br />
==Variations on a theme==<br />
<br />
Here are some {{ic|PS1}} variables (i.e.: prompts) with different layout to be applyied to [[Color_Bash_Prompt#.2Fetc.2Fbash.bashrc|our]] {{ic|/etc/bash.bashrc}} file. When you choose a layout you must replace the following lines from [[Color_Bash_Prompt#.2Fetc.2Fbash.bashrc|our]] {{ic|/etc/bash.bashrc}} file:<br />
<br />
{{bc|<nowiki> PS1="$(if [[ ${EUID} == 0 ]]; then echo '\[\033[01;31m\]\h'; else echo '\[\033[01;32m\]\u@\h'; fi)\[\033[01;34m\] \w \$([[ \$? != 0 ]] &amp;&amp; echo \"\[\033[01;31m\]:(\[\033[01;34m\] \")\$\[\033[00m\] "<br />
<br />
# Use this other PS1 string if you want \W for root and \w for all other users:<br />
# PS1="$(if [[ ${EUID} == 0 ]]; then echo '\[\033[01;31m\]\h\[\033[01;34m\] \W'; else echo '\[\033[01;32m\]\u@\h\[\033[01;34m\] \w'; fi) \$([[ \$? != 0 ]] &amp;&amp; echo \"\[\033[01;31m\]:(\[\033[01;34m\] \")\$\[\033[00m\] "</nowiki>}}<br />
<br />
with the {{ic|PS1}} variable (and possibly other code lines) given by the choosen layout.<br />
<br />
===From Arch Forum #1===<br />
<br />
Here is an unicode variation of [[Color_Bash_Prompt#.2Fetc.2Fbash.bashrc|our]] {{ic|/etc/bash.bashrc}} file freely based on [https://bbs.archlinux.org/viewtopic.php?pid=1068202#p1068202 what wrote the user JeSuisNerd and others in the Arch Forum]. Here is a preview of how it will appear:<br />
<br />
<div style="font-family: monospace; margin: 1em 3em; padding: 1em; border: 3px solid #bcd; background-color: black; color: #fff; font-size: 14px; line-height: 17px;">I am two with nature.<br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;-- Woody Allen<br /><span style="color: #aaa;">&#9484;&#9472;[</span><span style="color: #f90;">andy</span>@<span style="color: #5fc;">alba</span><span style="color: #aaa;">]&#9472;[</span><span style="color: #0c0;">~</span><span style="color: #aaa;">]</span><br /><span style="color: #aaa;">&#9492;&#9472;&#9472;&#9596;</span> ls<br /><span style="color: #55f; font-weight: bold;">Desktop Documents Music</span> public.desktop<br /><span style="color: #aaa;">&#9484;&#9472;[</span><span style="color: #f90;">andy</span>@<span style="color: #5fc;">alba</span><span style="color: #aaa;">]&#9472;[</span><span style="color: #0c0;">~</span><span style="color: #aaa;">]</span><br /><span style="color: #aaa;">&#9492;&#9472;&#9472;&#9596;</span>&nbsp;I\ will\ try\ to\ type\ a\ wrong\ command...<br />bash: I will try to type a wrong command...: command not found<br /><span style="color: #aaa;">&#9484;&#9472;[<span style="color: #a00;">&#10007;</span>]&#9472;[</span><span style="color: #f90;">andy</span>@<span style="color: #5fc;">alba</span><span style="color: #aaa;">]&#9472;[</span><span style="color: #0c0;">~</span><span style="color: #aaa;">]</span><br /><span style="color: #aaa;">&#9492;&#9472;&#9472;&#9596;</span> echo 'Hello world!' Hello world!<br /><span style="color: #aaa;">&#9484;&#9472;[</span><span style="color: #f90;">andy</span>@<span style="color: #5fc;">alba</span><span style="color: #aaa;">]&#9472;[</span><span style="color: #0c0;">~</span><span style="color: #aaa;">]</span><br /><span style="color: #aaa;">&#9492;&#9472;&#9472;&#9596;</span>&nbsp;su<br />Password:<br />Two can Live as Cheaply as One for Half as Long.<br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;-- Howard Kandel<br /><span style="color: #aaa;">&#9484;&#9472;[<span style="color: #a00;">alba</span>]</span><span style="color: #aaa;">&#9472;[</span><span style="color: #0c0;">~</span><span style="color: #aaa;">]</span><br /><span style="color: #aaa;">&#9492;&#9472;&#9472;&#9596;</span>&nbsp;<span style="text-decoration: blink;">_</span></div><br />
<br />
'''Note:''' '''Some unicode symbols (like <span style="color: #a00;">✗</span> and ╼) are not well supported in some terminals''' (in linux console, for example), so this prompt will appear a bit different depending on where is displayed. If you want to know the unicode representation of a plain text, [http://0xcc.net/jsescape/ here] you have a little plain text converter.<br />
<br />
And finally here is the {{ic|PS1}} variable for this effect to be applyied to [[Color_Bash_Prompt#.2Fetc.2Fbash.bashrc|our]] {{ic|/etc/bash.bashrc}} file (see [[Color_Bash_Prompt#Variations_on_a_theme|above]]):<br />
<br />
{{bc|<nowiki> # https://bbs.archlinux.org/viewtopic.php?pid=1068202#p1068202<br />
PS1="\[\033[0;37m\]\342\224\214\342\224\200\$([[ \$? != 0 ]] &amp;&amp; echo \"[\[\033[0;31m\]\342\234\227\[\033[0;37m\]]\342\224\200\")[$(if [[ ${EUID} == 0 ]]; then echo '\[\033[0;31m\]\h'; else echo '\[\033[0;33m\]\u\[\033[0;37m\]@\[\033[0;96m\]\h'; fi)\[\033[0;37m\]]\342\224\200[\[\033[0;32m\]\w\[\033[0;37m\]]\n\[\033[0;37m\]\342\224\224\342\224\200\342\224\200\342\225\274 \[\033[0m\]"</nowiki>}}<br />
<br />
===From an italian blog&hellip;===<br />
<br />
Here is an unicode variation of [[Color_Bash_Prompt#.2Fetc.2Fbash.bashrc|our]] {{ic|/etc/bash.bashrc}} file freely based on [http://dark-linux.net/personalizzare-bashrc-eo-bash-bashrc/ an italian blog]. Here is a preview of how it will appear:<br />
<br />
<div style="font-family: monospace; margin: 1em 3em; padding: 1em; border: 3px solid #bcd; background-color: black; color: #fff; font-size: 14px; line-height: 17px;">I am two with nature.<br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;-- Woody Allen<br /><span style="color: #55f;">&#9484;&#9472;[</span>12:03:20<span style="color: #55f;">]&#9472;[</span>andy@alba<span style="color: #55f;">]<br /></span><span style="color: #55f;">&#9492;&#9472;&#9472;&gt;</span> ~ <span style="color: #55f;">$</span> ls<br /><span style="color: #55f; font-weight: bold;">Desktop Documents Music</span> public.desktop<br /><span style="color: #55f;">&#9484;&#9472;[</span>12:03:31<span style="color: #55f;">]&#9472;[</span>andy@alba<span style="color: #55f;">]</span><br /><span style="color: #55f;">&#9492;&#9472;&#9472;&gt;</span> ~ <span style="color: #55f;">$</span> I\ will\ try\ to\ type\ a\ wrong\ command...<br />bash: I will try to type a wrong command...: command not found<br /><span style="color: #55f;">&#9484;&#9472;[</span>&#10007;<span style="color: #55f;">]&#9472;[</span>12:04:01<span style="color: #55f;">]&#9472;[</span>andy@alba<span style="color: #55f;">]<br /></span><span style="color: #55f;">&#9492;&#9472;&#9472;&gt;</span> ~ <span style="color: #55f;">$</span> echo 'Hello world!'<br />Hello world!<br /><span style="color: #55f;">&#9484;&#9472;[</span>12:04:13<span style="color: #55f;">]&#9472;[</span>andy@alba<span style="color: #55f;">]<br /></span><span style="color: #55f;">&#9492;&#9472;&#9472;&gt;</span> ~ <span style="color: #55f;">$</span> su<br />Password:<br />Two can Live as Cheaply as One for Half as Long.<br /> &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;-- Howard Kandel<br /><span style="color: #a00;">&#9484;&#9472;[</span>12:04:21<span style="color: #a00;">]&#9472;[</span>root@alba<span style="color: #a00;">]<br /></span><span style="color: #a00;">&#9492;&#9472;&#9472;&gt;</span> ~ <span style="color: #a00;">$</span> <span style="text-decoration: blink;">_</span></div><br />
<br />
'''Note:''' '''Some unicode symbols (like ✗) are not well supported in some terminals''' (in linux console, for example), so this prompt will appear a bit different depending on where is displayed. If you want to know the unicode representation of a plain text, [http://0xcc.net/jsescape/ here] you have a little plain text converter.<br />
<br />
And finally here is the {{ic|PS1}} variable for this effect to be applyied to [[Color_Bash_Prompt#.2Fetc.2Fbash.bashrc|our]] {{ic|/etc/bash.bashrc}} file (see [[Color_Bash_Prompt#Variations_on_a_theme|above]]):<br />
<br />
{{bc|<nowiki> if [[ ${EUID} == 0 ]] ; then<br />
sq_color="\[\033[0;31m\]"<br />
else <br />
sq_color="\[\033[0;34m\]"<br />
fi<br />
<br />
PS1="$sq_color\342\224\214\342\224\200\$([[ \$? != 0 ]] &amp;&amp; echo \"[\[\033[01;37m\]\342\234\227$sq_color]\342\224\200\")[\[\033[01;37m\]\t$sq_color]\342\224\200[\[\033[01;37m\]\u@\h$sq_color]\n\342\224\224\342\224\200\342\224\200&gt; \[\033[01;37m\]\W$sq_color $ \[\033[01;37m\]&gt;&gt;\\[\\033[0m\\] "<br />
<br />
unset sq_color</nowiki>}}<br />
<br />
===From Arch Forum #2===<br />
<br />
Here is another variation of [[Color_Bash_Prompt#.2Fetc.2Fbash.bashrc|our]] {{ic|/etc/bash.bashrc}} file freely based on [https://bbs.archlinux.org/viewtopic.php?pid=1156660#p1156660 what wrote the user shumer1213 and others in the Arch Forum]. Here is a preview of how it will appear:<br />
<br />
<div style="font-family: monospace; margin: 1em 3em; padding: 1em; border: 3px solid #bcd; background-color: black; color: #fff; font-size: 14px; line-height: 17px;">I am two with nature.<br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;-- Woody Allen<br /><br /><span style="color: #5555ff;">&#9608;&#9608; [ ~ ] [ 18:05:58 ]</span><br />&#9608;&#9608; ls<br /><span style="color: #55f; font-weight: bold;">Desktop Documents Music</span> public.desktop<br /><br /><span style="color: #5555ff;">&#9608;&#9608; [ ~ ] [ 18:06:02 ]</span><br />&#9608;&#9608; I\ will\ try\ to\ type\ a\ wrong\ command...<br />bash: I will try to type a wrong command...: command not found<br /><br /><span style="color: #aa0000;">&#9608;&#9608; [ ~ ] [ 18:06:12 ]</span><br />&#9608;&#9608; echo 'Hello world!'<br />Hello world!<br /><br /><span style="color: #5555ff;">&#9608;&#9608; [ ~ ] [ 18:06:17 ]</span><br />&#9608;&#9608; su<br />Password: <br />Two can Live as Cheaply as One for Half as Long.<br /> &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;-- Howard Kandel<br /><br /><span style="color: #5555ff;">&#9608;&#9608; [ andy ] [ 18:06:26 ]</span><br />&#9608;&#9608; <span style="text-decoration: blink;">_</span></div><br />
<br />
Here is the {{ic|PS1}} variable for this effect to be applyied to [[Color_Bash_Prompt#.2Fetc.2Fbash.bashrc|our]] {{ic|/etc/bash.bashrc}} file (see [[Color_Bash_Prompt#Variations_on_a_theme|above]]):<br />
<br />
{{bc|<nowiki> # https://bbs.archlinux.org/viewtopic.php?pid=1156660#p1156660<br />
PS1="\n\$(if [[ \$? == 0 ]]; then echo \"\[\033[0;34m\]\"; else echo \"\[\033[0;31m\]\"; fi)\342\226\210\342\226\210 [ \W ] [ \t ]\n\[\033[0m\]\342\226\210\342\226\210 "</nowiki>}}<br />
<br />
===With directory information===<br />
<br />
Here are other three variations of [[Color_Bash_Prompt#.2Fetc.2Fbash.bashrc|our]] {{ic|/etc/bash.bashrc}} file freely based on the article [http://maketecheasier.com/8-useful-and-interesting-bash-prompts/2009/09/04 8 Useful and Interesting Bash Prompts]. Here is a preview of how they will appear:<br />
<br />
====Version #1: with numerical error====<br />
<br />
<div style="font-family: monospace; margin: 1em 3em; padding: 1em; border: 3px solid #bcd; background-color: black; color: #fff; font-size: 14px; line-height: 17px;">I am two with nature.<br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;-- Woody Allen<br /><br /><span style="font-weight: bold;">&#9484;(</span><span style="font-weight: bold; color: #5555ff;">andy@alba</span><span style="font-weight: bold;">)&#9472;(</span><span style="font-weight: bold; color: #5555ff;">0</span><span style="font-weight: bold;">)&#9472;(</span><span style="font-weight: bold; color: #5555ff;">02:38 PM Sat Aug 29</span><span style="font-weight: bold;">)</span><br /><span style="font-weight: bold;">&#9492;&#9472;(</span><span style="font-weight: bold; color: #00cc00;">~</span><span style="font-weight: bold;">)&#9472;(</span><span style="font-weight: bold; color: #00cc00;">4 files, 332Kb</span><span style="font-weight: bold;">)&#9472;&gt;</span> ls<br /><span style="color: #55f; font-weight: bold;">Desktop Documents Music</span> myScript.js<br /><br /><span style="font-weight: bold;">&#9484;(</span><span style="font-weight: bold; color: #5555ff;">andy@alba</span><span style="font-weight: bold;">)&#9472;(</span><span style="font-weight: bold; color: #5555ff;">0</span><span style="font-weight: bold;">)&#9472;(</span><span style="font-weight: bold; color: #5555ff;">02:38 PM Sat Aug 29</span><span style="font-weight: bold;">)</span><br /><span style="font-weight: bold;">&#9492;&#9472;(</span><span style="font-weight: bold; color: #00cc00;">~</span><span style="font-weight: bold;">)&#9472;(</span><span style="font-weight: bold; color: #00cc00;">4 files, 332Kb</span><span style="font-weight: bold;">)&#9472;&gt;</span> I\ will\ try\ to\ type\ a\ wrong\ command...<br />bash: I will try to type a wrong command...: command not found<br /><br /><span style="font-weight: bold;">&#9484;(</span><span style="font-weight: bold; color: #5555ff;">andy@alba</span><span style="font-weight: bold;">)&#9472;(</span><span style="font-weight: bold; color: #5555ff;">127</span><span style="font-weight: bold;">)&#9472;(</span><span style="font-weight: bold; color: #5555ff;">02:39 PM Sat Aug 29</span><span style="font-weight: bold;">)</span><br /><span style="font-weight: bold;">&#9492;&#9472;(</span><span style="font-weight: bold; color: #00cc00;">~</span><span style="font-weight: bold;">)&#9472;(</span><span style="font-weight: bold; color: #00cc00;">4 files, 332Kb</span><span style="font-weight: bold;">)&#9472;&gt;</span> echo 'Hello world!'<br />Hello world!<br /><br /><span style="font-weight: bold;">&#9484;(</span><span style="font-weight: bold; color: #5555ff;">andy@alba</span><span style="font-weight: bold;">)&#9472;(</span><span style="font-weight: bold; color: #5555ff;">0</span><span style="font-weight: bold;">)&#9472;(</span><span style="font-weight: bold; color: #5555ff;">02:39 PM Sat Aug 29</span><span style="font-weight: bold;">)</span><br /><span style="font-weight: bold;">&#9492;&#9472;(</span><span style="font-weight: bold; color: #00cc00;">~</span><span style="font-weight: bold;">)&#9472;(</span><span style="font-weight: bold; color: #00cc00;">4 files, 332Kb</span><span style="font-weight: bold;">)&#9472;&gt;</span> false<br /><br /><span style="font-weight: bold;">&#9484;(</span><span style="font-weight: bold; color: #5555ff;">andy@alba</span><span style="font-weight: bold;">)&#9472;(</span><span style="font-weight: bold; color: #5555ff;">1</span><span style="font-weight: bold;">)&#9472;(</span><span style="font-weight: bold; color: #5555ff;">02:39 PM Sat Aug 29</span><span style="font-weight: bold;">)</span><br /><span style="font-weight: bold;">&#9492;&#9472;(</span><span style="font-weight: bold; color: #00cc00;">~</span><span style="font-weight: bold;">)&#9472;(</span><span style="font-weight: bold; color: #00cc00;">4 files, 332Kb</span><span style="font-weight: bold;">)&#9472;&gt;</span> su<br />Password: <br />Two can Live as Cheaply as One for Half as Long.<br /> &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;-- Howard Kandel<br /><br /><span style="font-weight: bold;">&#9484;(</span><span style="font-weight: bold; color: #aa0000;">alba</span><span style="font-weight: bold;">)&#9472;(</span><span style="font-weight: bold; color: #5555ff;">0</span><span style="font-weight: bold;">)&#9472;(</span><span style="font-weight: bold; color: #5555ff;">02:39 PM Sat Aug 29</span><span style="font-weight: bold;">)</span><br /><span style="font-weight: bold;">&#9492;&#9472;(</span><span style="font-weight: bold; color: #00cc00;">/home/andy</span><span style="font-weight: bold;">)&#9472;(</span><span style="font-weight: bold; color: #00cc00;">4 files, 332Kb</span><span style="font-weight: bold;">)&#9472;&gt;</span> <span style="text-decoration: blink;">_</span></div><br />
<br />
Here is the {{ic|PS1}} variable for this effect to be applyied to [[Color_Bash_Prompt#.2Fetc.2Fbash.bashrc|our]] {{ic|/etc/bash.bashrc}} file (see [[Color_Bash_Prompt#Variations_on_a_theme|above]]):<br />
<br />
{{bc|<nowiki> # http://maketecheasier.com/8-useful-and-interesting-bash-prompts/2009/09/04<br />
PS1="\n\[\033[1;37m\]\342\224\214($(if [[ ${EUID} == 0 ]]; then echo '\[\033[01;31m\]\h'; else echo '\[\033[01;34m\]\u@\h'; fi)\[\033[1;37m\])\342\224\200(\[\033[1;34m\]\$?\[\033[1;37m\])\342\224\200(\[\033[1;34m\]\@ \d\[\033[1;37m\])\[\033[1;37m\]\n\342\224\224\342\224\200(\[\033[1;32m\]\w\[\033[1;37m\])\342\224\200(\[\033[1;32m\]\$(ls -1 | wc -l | sed 's: ::g') files, \$(ls -lah | grep -m 1 total | sed 's/total //')b\[\033[1;37m\])\342\224\200&gt; \[\033[0m\]"</nowiki>}}<br />
<br />
<br />
====Version #2: with unicode error status symbols====<br />
<br />
<div style="font-family: monospace; margin: 1em 3em; padding: 1em; border: 3px solid #bcd; background-color: black; color: #fff; font-size: 14px; line-height: 17px;">I am two with nature.<br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;-- Woody Allen<br /><br /><span style="font-weight: bold;">&#9484;(</span><span style="font-weight: bold; color: #5555ff;">andy@alba</span><span style="font-weight: bold;">)&#9472;(</span><span style="color: #0a0; font-weight: bold;">&#10003;</span><span style="font-weight: bold;">)&#9472;(</span><span style="font-weight: bold; color: #5555ff;">02:38 PM Sat Aug 29</span><span style="font-weight: bold;">)</span><br /><span style="font-weight: bold;">&#9492;&#9472;(</span><span style="font-weight: bold; color: #00cc00;">~</span><span style="font-weight: bold;">)&#9472;(</span><span style="font-weight: bold; color: #00cc00;">4 files, 332Kb</span><span style="font-weight: bold;">)&#9472;&gt;</span> ls<br /><span style="color: #55f; font-weight: bold;">Desktop Documents Music</span> myScript.js<br /><br /><span style="font-weight: bold;">&#9484;(</span><span style="font-weight: bold; color: #5555ff;">andy@alba</span><span style="font-weight: bold;">)&#9472;(</span><span style="color: #0a0; font-weight: bold;">&#10003;</span><span style="font-weight: bold;">)&#9472;(</span><span style="font-weight: bold; color: #5555ff;">02:38 PM Sat Aug 29</span><span style="font-weight: bold;">)</span><br /><span style="font-weight: bold;">&#9492;&#9472;(</span><span style="font-weight: bold; color: #00cc00;">~</span><span style="font-weight: bold;">)&#9472;(</span><span style="font-weight: bold; color: #00cc00;">4 files, 332Kb</span><span style="font-weight: bold;">)&#9472;&gt;</span> I\ will\ try\ to\ type\ a\ wrong\ command...<br />bash: I will try to type a wrong command...: command not found<br /><br /><span style="font-weight: bold;">&#9484;(</span><span style="font-weight: bold; color: #5555ff;">andy@alba</span><span style="font-weight: bold;">)&#9472;(</span><span style="color: #a00; font-weight: bold;">&#10007;</span><span style="font-weight: bold;">)&#9472;(</span><span style="font-weight: bold; color: #5555ff;">02:39 PM Sat Aug 29</span><span style="font-weight: bold;">)</span><br /><span style="font-weight: bold;">&#9492;&#9472;(</span><span style="font-weight: bold; color: #00cc00;">~</span><span style="font-weight: bold;">)&#9472;(</span><span style="font-weight: bold; color: #00cc00;">4 files, 332Kb</span><span style="font-weight: bold;">)&#9472;&gt;</span> echo 'Hello world!'<br />Hello world!<br /><br /><span style="font-weight: bold;">&#9484;(</span><span style="font-weight: bold; color: #5555ff;">andy@alba</span><span style="font-weight: bold;">)&#9472;(</span><span style="color: #0a0; font-weight: bold;">&#10003;</span><span style="font-weight: bold;">)&#9472;(</span><span style="font-weight: bold; color: #5555ff;">02:39 PM Sat Aug 29</span><span style="font-weight: bold;">)</span><br /><span style="font-weight: bold;">&#9492;&#9472;(</span><span style="font-weight: bold; color: #00cc00;">~</span><span style="font-weight: bold;">)&#9472;(</span><span style="font-weight: bold; color: #00cc00;">4 files, 332Kb</span><span style="font-weight: bold;">)&#9472;&gt;</span> false<br /><br /><span style="font-weight: bold;">&#9484;(</span><span style="font-weight: bold; color: #5555ff;">andy@alba</span><span style="font-weight: bold;">)&#9472;(</span><span style="color: #a00; font-weight: bold;">&#10007;</span><span style="font-weight: bold;">)&#9472;(</span><span style="font-weight: bold; color: #5555ff;">02:39 PM Sat Aug 29</span><span style="font-weight: bold;">)</span><br /><span style="font-weight: bold;">&#9492;&#9472;(</span><span style="font-weight: bold; color: #00cc00;">~</span><span style="font-weight: bold;">)&#9472;(</span><span style="font-weight: bold; color: #00cc00;">4 files, 332Kb</span><span style="font-weight: bold;">)&#9472;&gt;</span> su<br />Password: <br />Two can Live as Cheaply as One for Half as Long.<br /> &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;-- Howard Kandel<br /><br /><span style="font-weight: bold;">&#9484;(</span><span style="font-weight: bold; color: #aa0000;">alba</span><span style="font-weight: bold;">)&#9472;(</span><span style="color: #0a0; font-weight: bold;">&#10003;</span><span style="font-weight: bold;">)&#9472;(</span><span style="font-weight: bold; color: #5555ff;">02:39 PM Sat Aug 29</span><span style="font-weight: bold;">)</span><br /><span style="font-weight: bold;">&#9492;&#9472;(</span><span style="font-weight: bold; color: #00cc00;">/home/andy</span><span style="font-weight: bold;">)&#9472;(</span><span style="font-weight: bold; color: #00cc00;">4 files, 332Kb</span><span style="font-weight: bold;">)&#9472;&gt;</span> <span style="text-decoration: blink;">_</span></div><br />
<br />
Here is the {{ic|PS1}} variable for this effect to be applyied to [[Color_Bash_Prompt#.2Fetc.2Fbash.bashrc|our]] {{ic|/etc/bash.bashrc}} file (see [[Color_Bash_Prompt#Variations_on_a_theme|above]]):<br />
<br />
{{bc|<nowiki> # http://maketecheasier.com/8-useful-and-interesting-bash-prompts/2009/09/04<br />
PS1="\n\[\033[1;37m\]\342\224\214($(if [[ ${EUID} == 0 ]]; then echo '\[\033[01;31m\]\h'; else echo '\[\033[01;34m\]\u@\h'; fi)\[\033[1;37m\])\342\224\200(\$(if [[ \$? == 0 ]]; then echo \"\[\033[01;32m\]\342\234\223\"; else echo \"\[\033[01;31m\]\342\234\227\"; fi)\[\033[1;37m\])\342\224\200(\[\033[1;34m\]\@ \d\[\033[1;37m\])\[\033[1;37m\]\n\342\224\224\342\224\200(\[\033[1;32m\]\w\[\033[1;37m\])\342\224\200(\[\033[1;32m\]\$(ls -1 | wc -l | sed 's: ::g') files, \$(ls -sh | head -n1 | sed 's/total //')b\[\033[1;37m\])\342\224\200&gt; \[\033[0m\]"</nowiki>}}<br />
<br />
====Version #3: with unicode error status symbol (non-zero only)====<br />
<br />
<div style="font-family: monospace; margin: 1em 3em; padding: 1em; border: 3px solid #bcd; background-color: black; color: #fff; font-size: 14px; line-height: 17px;">I am two with nature.<br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;-- Woody Allen<br /><br /><span style="font-weight: bold;">&#9484;(</span><span style="font-weight: bold; color: #5555ff;">andy@alba</span><span style="font-weight: bold;">)&#9472;(</span><span style="font-weight: bold; color: #5555ff;">02:38 PM Sat Aug 29</span><span style="font-weight: bold;">)</span><br /><span style="font-weight: bold;">&#9492;&#9472;(</span><span style="font-weight: bold; color: #00cc00;">~</span><span style="font-weight: bold;">)&#9472;(</span><span style="font-weight: bold; color: #00cc00;">4 files, 332Kb</span><span style="font-weight: bold;">)&#9472;&gt;</span> ls<br /><span style="color: #55f; font-weight: bold;">Desktop Documents Music</span> myScript.js<br /><br /><span style="font-weight: bold;">&#9484;(</span><span style="font-weight: bold; color: #5555ff;">andy@alba</span><span style="font-weight: bold;">)&#9472;(</span><span style="font-weight: bold; color: #5555ff;">02:38 PM Sat Aug 29</span><span style="font-weight: bold;">)</span><br /><span style="font-weight: bold;">&#9492;&#9472;(</span><span style="font-weight: bold; color: #00cc00;">~</span><span style="font-weight: bold;">)&#9472;(</span><span style="font-weight: bold; color: #00cc00;">4 files, 332Kb</span><span style="font-weight: bold;">)&#9472;&gt;</span> I\ will\ try\ to\ type\ a\ wrong\ command...<br />bash: I will try to type a wrong command...: command not found<br /><br /><span style="font-weight: bold;">&#9484;(</span><span style="font-weight: bold; color: #5555ff;">andy@alba</span><span style="font-weight: bold;">)&#9472;(</span><span style="color: #a00; font-weight: bold;">&#10007;</span><span style="font-weight: bold;">)&#9472;(</span><span style="font-weight: bold; color: #5555ff;">02:39 PM Sat Aug 29</span><span style="font-weight: bold;">)</span><br /><span style="font-weight: bold;">&#9492;&#9472;(</span><span style="font-weight: bold; color: #00cc00;">~</span><span style="font-weight: bold;">)&#9472;(</span><span style="font-weight: bold; color: #00cc00;">4 files, 332Kb</span><span style="font-weight: bold;">)&#9472;&gt;</span> echo 'Hello world!'<br />Hello world!<br /><br /><span style="font-weight: bold;">&#9484;(</span><span style="font-weight: bold; color: #5555ff;">andy@alba</span><span style="font-weight: bold;">)&#9472;(</span><span style="font-weight: bold; color: #5555ff;">02:39 PM Sat Aug 29</span><span style="font-weight: bold;">)</span><br /><span style="font-weight: bold;">&#9492;&#9472;(</span><span style="font-weight: bold; color: #00cc00;">~</span><span style="font-weight: bold;">)&#9472;(</span><span style="font-weight: bold; color: #00cc00;">4 files, 332Kb</span><span style="font-weight: bold;">)&#9472;&gt;</span> false<br /><br /><span style="font-weight: bold;">&#9484;(</span><span style="font-weight: bold; color: #5555ff;">andy@alba</span><span style="font-weight: bold;">)&#9472;(</span><span style="color: #a00; font-weight: bold;">&#10007;</span><span style="font-weight: bold;">)&#9472;(</span><span style="font-weight: bold; color: #5555ff;">02:39 PM Sat Aug 29</span><span style="font-weight: bold;">)</span><br /><span style="font-weight: bold;">&#9492;&#9472;(</span><span style="font-weight: bold; color: #00cc00;">~</span><span style="font-weight: bold;">)&#9472;(</span><span style="font-weight: bold; color: #00cc00;">4 files, 332Kb</span><span style="font-weight: bold;">)&#9472;&gt;</span> su<br />Password: <br />Two can Live as Cheaply as One for Half as Long.<br /> &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;-- Howard Kandel<br /><br /><span style="font-weight: bold;">&#9484;(</span><span style="font-weight: bold; color: #aa0000;">alba</span><span style="font-weight: bold;">)&#9472;(</span><span style="font-weight: bold; color: #5555ff;">02:39 PM Sat Aug 29</span><span style="font-weight: bold;">)</span><br /><span style="font-weight: bold;">&#9492;&#9472;(</span><span style="font-weight: bold; color: #00cc00;">/home/andy</span><span style="font-weight: bold;">)&#9472;(</span><span style="font-weight: bold; color: #00cc00;">4 files, 332Kb</span><span style="font-weight: bold;">)&#9472;&gt;</span> <span style="text-decoration: blink;">_</span></div><br />
<br />
Here is the {{ic|PS1}} variable for this effect to be applyied to [[Color_Bash_Prompt#.2Fetc.2Fbash.bashrc|our]] {{ic|/etc/bash.bashrc}} file (see [[Color_Bash_Prompt#Variations_on_a_theme|above]]):<br />
<br />
{{bc|<nowiki> # http://maketecheasier.com/8-useful-and-interesting-bash-prompts/2009/09/04<br />
PS1="\n\[\033[1;37m\]\342\224\214($(if [[ ${EUID} == 0 ]]; then echo '\[\033[01;31m\]\h'; else echo '\[\033[01;34m\]\u@\h'; fi)\[\033[1;37m\])\$([[ \$? != 0 ]] &amp;&amp; echo \"\342\224\200(\[\033[0;31m\]\342\234\227\[\033[1;37m\])\")\342\224\200(\[\033[1;34m\]\@ \d\[\033[1;37m\])\[\033[1;37m\]\n\342\224\224\342\224\200(\[\033[1;32m\]\w\[\033[1;37m\])\342\224\200(\[\033[1;32m\]\$(ls -1 | wc -l | sed 's: ::g') files, \$(ls -sh | head -n1 | sed 's/total //')b\[\033[1;37m\])\342\224\200&gt; \[\033[0m\]"</nowiki>}}<br />
<br />
==Restoring the original /etc/bash.bashrc file==<br />
<br />
If you repent having modified the {{ic|/etc/bash.bashrc}} file, you can always restore the original Arch {{ic|/etc/bash.bashrc}} file from the [[ bash ]] package and remove the {{ic|/etc/DIR_COLORS}} file. Note that there is not an "official" bash.bashrc: each distribution has its own.<br />
<br />
==Original /etc/bash.bashrc from Gentoo==<br />
<br />
The original ''not modified'' Gentoo's {{ic|/etc/bash.bashrc}} file can be found [http://www.jeremysands.com/archlinux/gentoo-bashrc-2008.0 here].<br />
<br />
=Colors overview=<br />
The page at http://ascii-table.com/ansi-escape-sequences.php describes the various available color escapes. The following Bash function (put it in your .bashrc!) displays a table with ready-to-copy escape codes.<br />
<br />
{{bc|<nowiki><br />
colors() {<br />
local fgc bgc vals seq0<br />
<br />
printf "Color escapes are %s\n" '\e[${value};...;${value}m'<br />
printf "Values 30..37 are \e[33mforeground colors\e[m\n"<br />
printf "Values 40..47 are \e[43mbackground colors\e[m\n"<br />
printf "Value 1 gives a \e[1mbold-faced look\e[m\n\n"<br />
<br />
# foreground colors<br />
for fgc in {30..37}; do<br />
# background colors<br />
for bgc in {40..47}; do<br />
fgc=${fgc#37} # white<br />
bgc=${bgc#40} # black<br />
<br />
vals="${fgc:+$fgc;}${bgc}"<br />
vals=${vals%%;}<br />
<br />
seq0="${vals:+\e[${vals}m}"<br />
printf " %-9s" "${seq0:-(default)}"<br />
printf " ${seq0}TEXT\e[m"<br />
printf " \e[${vals:+${vals+$vals;}}1mBOLD\e[m"<br />
done<br />
echo; echo<br />
done<br />
}<br />
</nowiki>}}<br />
<br />
=Step by step=<br />
<br />
If you want to create a style all your own, you can take a look at these tips. [https://bbs.archlinux.org/viewtopic.php?id=50885 This Forum thread] could give you more informations and examples.<br />
<br />
==Basic prompts==<br />
<br />
The following settings are useful for distinguishing the root prompt from non-root users.<br />
<br />
*Edit Bash's personal configuration file:<br />
{{bc|<nowiki>$ nano ~/.bashrc</nowiki>}}<br />
<br />
*Comment out the default prompt:<br />
{{bc|<nowiki># PS1='[\u@\h \W]\$ '</nowiki>}}<br />
<br />
*Add the following green prompt for regular users:<br />
<div style="font-family: monospace; white-space: pre; margin: 1em 3em; padding: 1em; border: 3px solid #bcd; background-color: black; color: #aaa;"><span style="color: #0f0">[chiri@zetsubou ~]$</span> <span style="text-decoration: blink;">_</span></div><br />
{{bc|<nowiki>PS1='\[\e[1;32m\][\u@\h \W]\$\[\e[0m\] '</nowiki>}}<br />
<br />
*Edit root's .bashrc file; copy it from /etc/skel if the file is not present:<br />
{{bc|<nowiki>$ nano /root/.bashrc</nowiki>}}<br />
*Assign a red prompt for root:<br />
<br />
<div style="font-family: monospace; white-space: pre; margin: 1em 3em; padding: 1em; border: 3px solid #bcd; background-color: black; color: #aaa;"><span style="color: #f00">[root@zetsubou ~]#</span> <span style="text-decoration: blink;">_</span></div><br />
{{bc|<nowiki>PS1='\[\e[1;31m\][\u@\h \W]\$\[\e[0m\] '</nowiki>}}<br />
<br />
===Slightly fancier prompts===<br />
<br />
*A green and blue prompt for regular users:<br />
<div style="font-family: monospace; white-space: pre; margin: 1em 3em; padding: 1em; border: 3px solid #bcd; background-color: black; color: #aaa;"><span style="color: #0a0">chiri</span> <span style="color: #00f">~/docs</span> <span style="color: #0f0">$</span> echo "sample output text"<br />sample output text<br /><span style="color: #0a0">chiri</span> <span style="color: #00f">~/docs</span> <span style="color: #0f0">$</span> <span style="text-decoration: blink;">_</span></div><br />
{{bc|<nowiki>PS1='\[\e[0;32m\]\u\[\e[m\] \[\e[1;34m\]\w\[\e[m\] \[\e[1;32m\]\$\[\e[m\] \[\e[1;37m\]'</nowiki>}}<br />
<br />
This will give a very pleasing, colorful prompt and theme for the console with bright white text.<br />
<br />
The string above contains color-set escape sequences (start coloring: \[\e[color\], end coloring: \[\e[m\]) and information placeholders:<br />
<br />
* \u - Username. The original prompt also has \h, which prints the host name.<br />
* \w - Current absolute path. Use \W for current relative path.<br />
* \$ - The prompt character (eg. '#' for root, '$' for regular users). <br />
<br />
The last color-set sequence, "\[\e[1;37m\]", is not closed, so the remaining text (everything typed into the terminal, program output and so on) will be in that (bright white) color. It may be desirable to change this color, or to delete the last escape sequence in order to leave the actual output in unaltered color. <br />
<br />
*A red and blue prompt for root:<br />
<div style="font-family: monospace; white-space: pre; margin: 1em 3em; padding: 1em; border: 3px solid #bcd; background-color: black; color: #aaa;"><span style="color: #a00">root</span> <span style="color: #00f">~/docs</span> <span style="color: #a00">#</span> <span style="color: #0a0">echo "sample output text"<br />sample output text<br /></span><span style="color: #a00">root</span> <span style="color: #00f">~/docs</span> <span style="color: #a00">#</span> <span style="color: #0a0"><span style="text-decoration: blink;">_</span></span></div><br />
{{bc|<nowiki>PS1='\[\e[0;31m\]\u\[\e[m\] \[\e[1;34m\]\w\[\e[m\] \[\e[0;31m\]\$ \[\e[m\]\[\e[0;32m\]'</nowiki>}}<br />
<br />
This will give you a red designation and green console text.<br />
<br />
Once you have made your changes to .bashrc, to execute your changes:<br />
<br />
{{bc|<nowiki>$ source ~/.bashrc</nowiki>}}<br />
<br />
==Advanced prompts==<br />
<br />
===Load/Mem Status for 256colors===<br />
This is not even pushing the limits. Other than using 'sed' to parse the memory and load average (using the ''-u'' option for non-buffering), and the builtin ''history'' to save your history to your ''HISTFILE'' after every command, which you may find incredibly useful when dealing with crashing shells or subshells, this is essentially just making BASH print variables it already knows, making this extremely fast compared to prompts with non-builtin commands.<br />
<br />
This prompt is from AskApache.com's [http://www.askapache.com/linux-unix/bash-power-prompt.html BASH Power Prompt article], which goes into greater detail. It is especially helpful for those wanting to understand 256 color terminals, ncurses, termcap, and terminfo.<br />
<br />
This is for '''256 color terminals''', which is where the '''\033[38;5;22m''' terminal escapes come from. <br />
{{bc|1=<br />
<span style="color:#0b0">802</span><span style="color:#005f00">/1024MB</span> <span style="color:#5f00af">1.28 1.20 1.13 3/94 18563</span><br />
<span style="color:#555">[5416:17880 0:70]</span> <span style="color:0bb">05:35:50 Wed Apr 21</span> <span style="color:#555">[</span><span style="color:#2b47ff">srot@host.sqpt.net</span><span style="color:#555">:</span><span style="color:#bbb">/dev/pts/0</span> <span style="color:#00bb00">+1</span><span style="color:#555">]</span> <span style="color:#000">~<br /><br />
(1:70)$ <span style="text-decoration: blink;">_</span></span><br />
}}<br />
<br />
{{bc|<nowiki>PROMPT_COMMAND='history -a;echo -en "\033[m\033[38;5;2m"$(( $(sed -nu "s/MemFree:[\t ]\+\([0-9]\+\) kB/\1/p" /proc/meminfo)/1024))"\033[38;5;22m/"$(($(sed -nu "s/MemTotal:[\t ]\+\([0-9]\+\) kB/\1/Ip" /proc/meminfo)/1024 ))MB"\t\033[m\033[38;5;55m$(&lt; /proc/loadavg)\033[m"'<br />
PS1='\[\e[m\n\e[1;30m\][$$:$PPID \j:\!\[\e[1;30m\]]\[\e[0;36m\] \T \d \[\e[1;30m\][\[\e[1;34m\]\u@\H\[\e[1;30m\]:\[\e[0;37m\]${SSH_TTY} \[\e[0;32m\]+${SHLVL}\[\e[1;30m\]] \[\e[1;37m\]\w\[\e[0;37m\] \n($SHLVL:\!)\$ '</nowiki>}}<br />
<br />
===List of colors for prompt and Bash===<br />
<br />
Add this to your Bash file(s) to define colors for prompt and commands:<br />
{{bc|<nowiki>txtblk='\e[0;30m' # Black - Regular<br />
txtred='\e[0;31m' # Red<br />
txtgrn='\e[0;32m' # Green<br />
txtylw='\e[0;33m' # Yellow<br />
txtblu='\e[0;34m' # Blue<br />
txtpur='\e[0;35m' # Purple<br />
txtcyn='\e[0;36m' # Cyan<br />
txtwht='\e[0;37m' # White<br />
bldblk='\e[1;30m' # Black - Bold<br />
bldred='\e[1;31m' # Red<br />
bldgrn='\e[1;32m' # Green<br />
bldylw='\e[1;33m' # Yellow<br />
bldblu='\e[1;34m' # Blue<br />
bldpur='\e[1;35m' # Purple<br />
bldcyn='\e[1;36m' # Cyan<br />
bldwht='\e[1;37m' # White<br />
unkblk='\e[4;30m' # Black - Underline<br />
undred='\e[4;31m' # Red<br />
undgrn='\e[4;32m' # Green<br />
undylw='\e[4;33m' # Yellow<br />
undblu='\e[4;34m' # Blue<br />
undpur='\e[4;35m' # Purple<br />
undcyn='\e[4;36m' # Cyan<br />
undwht='\e[4;37m' # White<br />
bakblk='\e[40m' # Black - Background<br />
bakred='\e[41m' # Red<br />
bakgrn='\e[42m' # Green<br />
bakylw='\e[43m' # Yellow<br />
bakblu='\e[44m' # Blue<br />
bakpur='\e[45m' # Purple<br />
bakcyn='\e[46m' # Cyan<br />
bakwht='\e[47m' # White<br />
txtrst='\e[0m' # Text Reset</nowiki>}}<br />
<br />
Or if you prefer color names you will know how to spell without a special decoder ring and want high intensity colors:<br />
{{bc|<nowiki># Reset<br />
Color_Off='\e[0m' # Text Reset<br />
<br />
# Regular Colors<br />
Black='\e[0;30m' # Black<br />
Red='\e[0;31m' # Red<br />
Green='\e[0;32m' # Green<br />
Yellow='\e[0;33m' # Yellow<br />
Blue='\e[0;34m' # Blue<br />
Purple='\e[0;35m' # Purple<br />
Cyan='\e[0;36m' # Cyan<br />
White='\e[0;37m' # White<br />
<br />
# Bold<br />
BBlack='\e[1;30m' # Black<br />
BRed='\e[1;31m' # Red<br />
BGreen='\e[1;32m' # Green<br />
BYellow='\e[1;33m' # Yellow<br />
BBlue='\e[1;34m' # Blue<br />
BPurple='\e[1;35m' # Purple<br />
BCyan='\e[1;36m' # Cyan<br />
BWhite='\e[1;37m' # White<br />
<br />
# Underline<br />
UBlack='\e[4;30m' # Black<br />
URed='\e[4;31m' # Red<br />
UGreen='\e[4;32m' # Green<br />
UYellow='\e[4;33m' # Yellow<br />
UBlue='\e[4;34m' # Blue<br />
UPurple='\e[4;35m' # Purple<br />
UCyan='\e[4;36m' # Cyan<br />
UWhite='\e[4;37m' # White<br />
<br />
# Background<br />
On_Black='\e[40m' # Black<br />
On_Red='\e[41m' # Red<br />
On_Green='\e[42m' # Green<br />
On_Yellow='\e[43m' # Yellow<br />
On_Blue='\e[44m' # Blue<br />
On_Purple='\e[45m' # Purple<br />
On_Cyan='\e[46m' # Cyan<br />
On_White='\e[47m' # White<br />
<br />
# High Intensity<br />
IBlack='\e[0;90m' # Black<br />
IRed='\e[0;91m' # Red<br />
IGreen='\e[0;92m' # Green<br />
IYellow='\e[0;93m' # Yellow<br />
IBlue='\e[0;94m' # Blue<br />
IPurple='\e[0;95m' # Purple<br />
ICyan='\e[0;96m' # Cyan<br />
IWhite='\e[0;97m' # White<br />
<br />
# Bold High Intensity<br />
BIBlack='\e[1;90m' # Black<br />
BIRed='\e[1;91m' # Red<br />
BIGreen='\e[1;92m' # Green<br />
BIYellow='\e[1;93m' # Yellow<br />
BIBlue='\e[1;94m' # Blue<br />
BIPurple='\e[1;95m' # Purple<br />
BICyan='\e[1;96m' # Cyan<br />
BIWhite='\e[1;97m' # White<br />
<br />
# High Intensity backgrounds<br />
On_IBlack='\e[0;100m' # Black<br />
On_IRed='\e[0;101m' # Red<br />
On_IGreen='\e[0;102m' # Green<br />
On_IYellow='\e[0;103m' # Yellow<br />
On_IBlue='\e[0;104m' # Blue<br />
On_IPurple='\e[0;105m' # Purple<br />
On_ICyan='\e[0;106m' # Cyan<br />
On_IWhite='\e[0;107m' # White<br />
</nowiki>}}<br />
<br />
To use in commands from your shell environment:<br />
<br />
<div style="font-family: monospace; margin: 1em 3em; padding: 1em; border: 3px solid #bcd; background-color: black; color: #fff;">$ echo -e "${txtblu}test"<br /><span style="color: blue;">test</span><br />$ echo -e "${bldblu}test"<br /><span style="color: lightblue;"><strong>test</strong></span><br />$ echo -e "${undblu}test"<br /><span style="color: lightblue;"><strong><span style="text-decoration: underline;">test</span></strong></span><br />$ echo -e "${bakblu}test"<br /><span style="color: white; background-color: lightblue;"><strong>test</strong></span><br />$ <span style="text-decoration: blink;">_</span></div><br />
<br />
To use in a prompt (note double quotes to enable $color variable expansion and <nowiki>\[ \]</nowiki> escapes around them so they are not counted as character positions and the cursor position is not wrong):<br />
<br />
{{bc|<nowiki>PS1="\[$txtblu\]foo\[$txtred\] bar\[$txtrst\] baz : "</nowiki>}}<br />
<br />
If you experience premature line wrapping when entering commands at the prompt then missing escapes is most likely to be the reason.<br />
<br />
=== Prompt escapes ===<br />
<br />
The various Bash prompt escapes listed in the manpage:<br />
<br />
{{bc|1=Bash allows these prompt strings to be customized by inserting a<br />
number of ''backslash-escaped special characters'' that are<br />
decoded as follows:<br />
<br />
\a an ASCII bell character (07)<br />
\d the date in "Weekday Month Date" format (e.g., "Tue May 26")<br />
\D{format} the format is passed to strftime(3) and the result<br />
is inserted into the prompt string an empty format<br />
results in a locale-specific time representation.<br />
The braces are required<br />
\e an ASCII escape character (033)<br />
\h the hostname up to the first `.'<br />
\H the hostname<br />
\j the number of jobs currently managed by the shell<br />
\l the basename of the shell's terminal device name<br />
\n newline<br />
\r carriage return<br />
\s the name of the shell, the basename of $0 (the portion following<br />
the final slash)<br />
\t the current time in 24-hour HH:MM:SS format<br />
\T the current time in 12-hour HH:MM:SS format<br />
\@ the current time in 12-hour am/pm format<br />
\A the current time in 24-hour HH:MM format<br />
\u the username of the current user<br />
\v the version of bash (e.g., 2.00)<br />
\V the release of bash, version + patch level (e.g., 2.00.0)<br />
\w the current working directory, with $HOME abbreviated with a tilde<br />
\W the basename of the current working directory, with $HOME<br />
abbreviated with a tilde<br />
\! the history number of this command<br />
\# the command number of this command<br />
\$ if the effective UID is 0, a #, otherwise a $<br />
\nnn the character corresponding to the octal number nnn<br />
\\ a backslash<br />
\[ begin a sequence of non-printing characters, which could be used<br />
to embed a terminal control sequence into the prompt<br />
\] end a sequence of non-printing characters<br />
<br />
The command number and the history number are usually different:<br />
the history number of a command is its position in the history<br />
list, which may include commands restored from the history file<br />
(see HISTORY below), while the command number is the position in<br />
the sequence of commands executed during the current shell session.<br />
After the string is decoded, it is expanded via parameter<br />
expansion, command substitution, arithmetic expansion, and quote<br />
removal, subject to the value of the promptvars shell option (see<br />
the description of the shopt command under SHELL BUILTIN COMMANDS<br />
below).<br />
}}<br />
<br />
=== Positioning the cursor ===<br />
<br />
{{Accuracy|The last example don't work (at least on Bash). Seems to have a problem in '''\[\033[1;\$((COLUMNS-4))f\]'''}}<br />
<br />
The following sequence sets the cursor position:<br />
<br />
{{bc|<nowiki>\[\033[<row>;<column>f\]</nowiki>}}<br />
<br />
The current cursor position can be saved using:<br />
<br />
{{bc|<nowiki>\[\033[s\]</nowiki>}}<br />
<br />
To restore a position, use the following sequence: <br />
<br />
{{bc|<nowiki>\[\033[u\]</nowiki>}}<br />
<br />
The following example uses these sequences to display the time in the upper right corner:<br />
<br />
{{bc|<nowiki>PS1="&gt;\[\033[s\]\[\033[1;\$((COLUMNS-4))f\]\$(date +%H:%M)\[\033[u\]"</nowiki>}}<br />
<br />
The environment variable ''COLUMNS'' contains the number of columns of the terminal. The above example substracts 4 from its value in order to justify the five character wide output of ''date'' at the right border.<br />
<br />
===Return value visualisation===<br />
<br />
Use this prompt if you want to see the return value of the last executed command.<br />
<br />
{{bc|<nowiki>#return value visualisation<br />
PS1="\$? \$(if [[ \$? == 0 ]]; then echo \"\[\033[0;32m\];)\"; else echo \"\[\033[0;31m\];(\"; fi)\[\033[00m\] : "</nowiki>}}<br />
<br />
This will give you basic prompt:<br />
<div style="font-family: monospace; margin: 1em 3em; padding: 1em; border: 3px solid #bcd; background-color: black; color: #fff;">0 <span style="color: green;">;)</span>&nbsp;: true<br />0 <span style="color: green;">;)</span>&nbsp;: false<br />1 <span style="color: red;">;(</span>&nbsp;:</div><br />
<br />
Zero is a green smiley (replace it with anything you want) and non-zero is a red one. So your prompt will smile if the last operation was successful.<br />
<br />
But you will probably want to use the return value in your own prompt, like this:<br />
<br />
<div style="font-family: monospace; margin: 1em 3em; padding: 1em; border: 3px solid #bcd; background-color: black; color: #fff;"><span style="font-weight: bold;">0</span> <span style="color: #0a0; font-weight: bold;">;) andy@alba</span> <span style="color: #55f; font-weight: bold;">~ $</span> true<br /><span style="font-weight: bold;">0</span> <span style="color: #0a0; font-weight: bold;">;) andy@alba</span> <span style="color: #55f; font-weight: bold;">~ $</span> false<br /><span style="font-weight: bold;">1</span> <span style="color: #a00; font-weight: bold;">;(</span> <span style="color: #0a0; font-weight: bold;">andy@alba</span> <span style="color: #55f; font-weight: bold;">~ $</span> <span style="text-decoration: blink;">_</span></div><br />
<br />
with a code like this one:<br />
<br />
{{bc|<nowiki>#return value visualisation<br />
PS1="\[\033[01;37m\]\$? \$(if [[ \$? == 0 ]]; then echo \"\[\033[01;32m\];)\"; else echo \"\[\033[01;31m\];(\"; fi) $(if [[ ${EUID} == 0 ]]; then echo '\[\033[01;31m\]\h'; else echo '\[\033[01;32m\]\u@\h'; fi)\[\033[01;34m\] \w \$\[\033[00m\] "</nowiki>}}<br />
<br />
Or, if you want, you can build your prompt using the <span style="color: #0a0; font-weight: bold;">&#10003;</span> unicode symbol for a ''zero'' status and the <span style="color: #a00; font-weight: bold;">&#10007;</span> unicode symbol for a ''nonzero'' status:<br />
<br />
<div style="font-family: monospace; margin: 1em 3em; padding: 1em; border: 3px solid #bcd; background-color: black; color: #fff;"><span style="font-weight: bold;">0</span> <span style="color: #0a0; font-weight: bold;">&#10003; andy@alba</span> <span style="color: #55f; font-weight: bold;">~ $</span> true<br /><span style="font-weight: bold;">0</span> <span style="color: #0a0; font-weight: bold;">&#10003; andy@alba</span> <span style="color: #55f; font-weight: bold;">~ $</span> false<br /><span style="font-weight: bold;">1</span> <span style="color: #a00; font-weight: bold;">&#10007;</span> <span style="color: #0a0; font-weight: bold;">andy@alba</span> <span style="color: #55f; font-weight: bold;">~ $</span> I\ will\ try\ to\ type\ a\ wrong\ command...<br />bash: I will try to type a wrong command...: command not found<br /><span style="font-weight: bold;">127</span> <span style="color: #a00; font-weight: bold;">&#10007;</span> <span style="color: #0a0; font-weight: bold;">andy@alba</span> <span style="color: #55f; font-weight: bold;">~ $</span> <span style="text-decoration: blink;">_</span></div><br />
<br />
starting from a code like this other one:<br />
<br />
{{bc|<nowiki>#return value visualisation<br />
PS1="\[\033[01;37m\]\$? \$(if [[ \$? == 0 ]]; then echo \"\[\033[01;32m\]\342\234\223\"; else echo \"\[\033[01;31m\]\342\234\227\"; fi) $(if [[ ${EUID} == 0 ]]; then echo '\[\033[01;31m\]\h'; else echo '\[\033[01;32m\]\u@\h'; fi)\[\033[01;34m\] \w \$\[\033[00m\] "</nowiki>}}<br />
<br />
Here's an alternative that only include the error status if it is nonzero:<br />
{{bc|<nowiki><br />
PROMPT_COMMAND='es=$?; [[ $es -eq 0 ]] &amp;&amp; unset error || error=$(echo -e "\e[1;41m $es \e[40m")'<br />
PS1="${error} ${PS1}"</nowiki>}}<br />
<br />
===Wolfman's===<br />
<br />
After reading through most of the [http://www.tldp.org/HOWTO/Bash-Prompt-HOWTO/index.html Bash Prompt Howto], the author developed a color bash prompt that displays the last 25 characters of the current working directory. This prompt should work well on terminals with a black background. The following code goes in file {{ic|~/.bashrc}}.<br />
<br />
*Add the bash_prompt_command function. If you have a couple directories with long names or start entering a lot of subdirectories, this function will keep the command prompt from wrapping around the screen by displaying at most the last pwdmaxlen characters from the PWD. This code was taken from the ''Bash Prompt Howto''<nowiki>'s</nowiki> section on [http://www.tldp.org/HOWTO/Bash-Prompt-HOWTO/x783.html Controlling the Size and Appearance of $PWD] and modified to replace the user's home directory with a tilde.<br />
<br />
{{bc|<nowiki>##################################################<br />
# Fancy PWD display function<br />
##################################################<br />
# The home directory (HOME) is replaced with a ~<br />
# The last pwdmaxlen characters of the PWD are displayed<br />
# Leading partial directory names are striped off<br />
# /home/me/stuff -&gt; ~/stuff if USER=me<br />
# /usr/share/big_dir_name -&gt; ../share/big_dir_name if pwdmaxlen=20<br />
##################################################<br />
<br />
bash_prompt_command() {<br />
# How many characters of the $PWD should be kept<br />
local pwdmaxlen=25<br />
# Indicate that there has been dir truncation<br />
local trunc_symbol=".."<br />
local dir=${PWD##*/}<br />
pwdmaxlen=$(( ( pwdmaxlen &lt; ${#dir} ) ? ${#dir} : pwdmaxlen ))<br />
NEW_PWD=${PWD/#$HOME/\~}<br />
local pwdoffset=$(( ${#NEW_PWD} - pwdmaxlen ))<br />
if [ ${pwdoffset} -gt "0" ]<br />
then<br />
NEW_PWD=${NEW_PWD:$pwdoffset:$pwdmaxlen}<br />
NEW_PWD=${trunc_symbol}/${NEW_PWD#*/}<br />
fi<br />
}</nowiki>}}<br />
<br />
*The next fragment generates the command prompt and various colors are defined. The user's color for the username, hostname, and prompt ($ or #) is set to cyan, and if the user is root (root's UID is always 0), set the color to red. The command prompt is set to a colored version of Arch's default with the NEW_PWD from the last function.<br />
<br />
:Also, make sure that your color variables are enclosed in double and not single quote marks. Using single quote marks seems to give Bash problems with line wrapping correctly.<br />
<br />
{{bc|<nowiki>bash_prompt() {<br />
case $TERM in<br />
xterm*|rxvt*)<br />
local TITLEBAR='\[\033]0;\u:${NEW_PWD}\007\]'<br />
;;<br />
*)<br />
local TITLEBAR=""<br />
;;<br />
esac<br />
local NONE="\[\033[0m\]" # unsets color to term's fg color<br />
<br />
# regular colors<br />
local K="\[\033[0;30m\]" # black<br />
local R="\[\033[0;31m\]" # red<br />
local G="\[\033[0;32m\]" # green<br />
local Y="\[\033[0;33m\]" # yellow<br />
local B="\[\033[0;34m\]" # blue<br />
local M="\[\033[0;35m\]" # magenta<br />
local C="\[\033[0;36m\]" # cyan<br />
local W="\[\033[0;37m\]" # white<br />
<br />
# emphasized (bolded) colors<br />
local EMK="\[\033[1;30m\]"<br />
local EMR="\[\033[1;31m\]"<br />
local EMG="\[\033[1;32m\]"<br />
local EMY="\[\033[1;33m\]"<br />
local EMB="\[\033[1;34m\]"<br />
local EMM="\[\033[1;35m\]"<br />
local EMC="\[\033[1;36m\]"<br />
local EMW="\[\033[1;37m\]"<br />
<br />
# background colors<br />
local BGK="\[\033[40m\]"<br />
local BGR="\[\033[41m\]"<br />
local BGG="\[\033[42m\]"<br />
local BGY="\[\033[43m\]"<br />
local BGB="\[\033[44m\]"<br />
local BGM="\[\033[45m\]"<br />
local BGC="\[\033[46m\]"<br />
local BGW="\[\033[47m\]"<br />
<br />
local UC=$W # user's color<br />
[ $UID -eq "0" ] &amp;&amp; UC=$R # root's color<br />
<br />
PS1="$TITLEBAR ${EMK}[${UC}\u${EMK}@${UC}\h ${EMB}\${NEW_PWD}${EMK}]${UC}\\$ ${NONE}"<br />
# without colors: PS1="[\u@\h \${NEW_PWD}]\\$ "<br />
# extra backslash in front of \$ to make bash colorize the prompt<br />
}</nowiki>}}<br />
<br />
*Finally, append this code. This ensures that the NEW_PWD variable will be updated when you cd somewhere else, and it sets the PS1 variable, which contains the command prompt.<br />
<br />
{{bc|<nowiki>PROMPT_COMMAND=bash_prompt_command<br />
bash_prompt<br />
unset bash_prompt</nowiki>}}<br />
<br />
===KitchM's===<br />
These prompts offer a little more flash and visual clarity. Note that the use of red in the root user's prompt should provide ample warning. That is not to say someone could not use flashing text or arrow to do even more, but these will give you a good starting point.<br />
<br />
'''First''', change the default background in your terminal preferences (this example uses Xfce's Terminal program) to #D2D2D2, and the text color to #000000. The font is listed as DejaVu Sans Mono Book 12. The cursor color is #00AA00, and the tab activity color is #AF0000.<br />
<br />
'''Second''', in ~/.bashrc and right after the PS1= line, enter a new line with the following:<br />
{{bc|<nowiki>PS1='\e[1;33;47m\u \e[1;32;47mon \h \e[1;35;47m\d \@\e[0;0m\n\e[1;34m[dir.= \w] \# &gt; \e[0;0m'</nowiki>}}<br />
And then place a # in front of the first PS1 line to remark it out.<br />
<br />
'''Third''', for root user, edit /root/.bashrc in the same manner to include:<br />
{{bc|<nowiki>PS1='\e[1;31;47m\u \e[1;32;47mon \h \e[1;35;47m\d \@\e[0;0m\n\e[1;31m[dir.= \w] \# &gt; \e[0;0m'</nowiki>}}<br />
Do not forget to comment out the old line.<br />
<br />
These are double-line prompts, and they should look something like these:<br />
<br />
:'''user'''<br />
<br />
<div style="font-family: monospace; margin: 1em 3em; padding: 1em; border: 3px solid #bbccdd; font-weight: bold; color: #0000ff; background-color: #d2d2d2;"><span style="color: #ff0000; background: #A9A9A9;">Root</span><span style="color: #00ff00; background: #A9A9A9;"> on myhost</span><span style="color: #ff00ff; background: #A9A9A9;"> Sun Jan 15 12:30 PM</span><br />[dir.= /etc/rc.d] 1 &gt;</div><br />
<br />
:'''root'''<br />
<br />
<div style="font-family: monospace; margin: 1em 3em; padding: 1em; border: 3px solid #bbccdd; font-weight: bold; color: #ff0000; background-color: #d2d2d2;"><span style="color: #ff0000; background: #A9A9A9;">Root</span><span style="color: #00ff00; background: #A9A9A9;"> on myhost</span><span style="color: #ff00ff; background: #A9A9A9;"> Sun Jan 15 12:30 PM</span><br />[dir.= /etc/rc.d] 1 &gt;</div><br />
<br />
You will note that the background colors make them easier to read, and the text colors just keep things interesting. There is a lot of leeway to make them personalized, just with the use of colors. Enjoy!<br />
<br />
==Set window title==<br />
<br />
[[Xterm]] and many other terminal emulators (including PuTTY) allow you to set the window title using special escape sequences. You can define the {{ic|<nowiki>${XTERM_TITLE}</nowiki>}} variable as follows, then insert it at the beginning of the prompt to set [[xterm]] title (if available) to directory@user@hostname:<br />
<br />
{{bc|<nowiki>#set xterm title<br />
case "$TERM" in<br />
xterm | xterm-color)<br />
XTERM_TITLE='\[\e]0;\W@\u@\H\a\]'<br />
;;<br />
esac</nowiki>}}<br />
<br />
The text between {{ic|0;}} and {{ic|\a}} can be set to anything you like, for example:<br />
<br />
{{bc|<nowiki>export PS1="\[\e]0;Welcome to ArchLinux\a\]\$&gt;&gt; "</nowiki>}}<br />
<br />
sets the window title to "Welcome to ArchLinux" and displays this simple prompt: <br />
<br />
<div style="font-family: monospace; margin: 1em 3em; padding: 1em; border: 3px solid #bcd; background-color: black; color: #fff;">$&gt;&gt; <span style="text-decoration: blink;">_</span></div><br />
<br />
==Different colors for text entry and console output==<br />
<br />
If you do not reset the text color at the end of your prompt, both the text you enter and the console text will simply stay in that color. If you want to edit text in a special color but still use the default color for command output, you will need to reset the color after you press enter, but still before any commands get run. You can do this by installing a DEBUG trap in your ~/.bashrc, like this:<br />
<br />
{{bc|<nowiki>trap 'echo -ne "\e[0m"' DEBUG</nowiki>}}<br />
<br />
==Laptop battery status on prompt==<br />
<br />
Read [http://www.basicallytech.com/blog/index.php?/archives/110-Colour-coded-battery-charge-level-and-status-in-your-bash-prompt.html this article] and [https://bbs.archlinux.org/viewtopic.php?pid=1156660#p1156660 this post] for details.<br />
<br />
==See also==<br />
<br />
* {{AUR|gentoo-bashrc}} from [[AUR]]<br />
* tput(1)<br />
* [http://tldp.org/HOWTO/Bash-Prompt-HOWTO/x405.html Colours and Cursor Movement With tput]<br />
<br />
==External links==<br />
<br />
* Forum Discussions:<br />
** [https://bbs.archlinux.org/viewtopic.php?id=1817 BASH prompt]<br />
** [https://bbs.archlinux.org/viewtopic.php?id=50885 What's your PS1?]<br />
* [http://xcolors.net/ Nice Xresources color schemes collection]<br />
* [http://www.tldp.org/HOWTO/Bash-Prompt-HOWTO/x329.html Bash Prompt HOWTO]<br />
* [http://gilesorr.com/bashprompt/prompts/index.html Giles Orr's collection of sample prompts]<br />
* [http://misc.flogisoft.com/bash/tip_colors_and_formatting Bash tips: Colors and formatting]</div>Max-khttps://wiki.archlinux.org/index.php?title=Bash/Prompt_customization&diff=288049Bash/Prompt customization2013-12-15T11:37:37Z<p>Max-k: /* Version #3: with unicode error status symbol (non-zero only) */</p>
<hr />
<div>[[Category:Eye candy]]<br />
[[Category:Command shells]]<br />
[[de:Bash-Prompt anpassen]]<br />
[[es:Color Bash Prompt]]<br />
[[it:Color Bash Prompt]]<br />
[[ru:Color Bash Prompt]]<br />
[[zh-CN:Color Bash Prompt]]<br />
{{Article summary start}}<br />
{{Article summary text|Discussing and improving Bash graphical customisations.}}<br />
{{Article summary heading|Related}}<br />
{{Article summary wiki|Environment Variables}}<br />
{{Article summary wiki|Bash}}<br />
{{Article summary end}}<br />
There are a variety of possibilities for [[Bash]]'s prompt (PS1), and customizing it can help you be more productive at the command line. You can add additional information to your prompt, or you can simply add color to it to make the prompt stand out. See [https://bbs.archlinux.org/viewtopic.php?id=50885 this Forum thread] for more informations and examples.<br />
<br />
=A well-established Bash color prompt=<br />
<br />
What follows is a well-proven way to color the Bash prompt. It is the most widespread Bash color scheme in the GNU/Linux world. Here is a preview of how it will appear:<br />
<br />
<div style="font-family: monospace; margin: 1em 3em; padding: 1em; border: 3px solid #bcd; background-color: black; color: #fff;">I am two with nature.<br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;-- Woody Allen<br /><span style="color: #0a0; font-weight: bold;">andy@alba</span> <span style="color: #55f; font-weight: bold;">~ $</span> ls<br /><span style="color: #55f; font-weight: bold;">Desktop Documents Music</span> public.desktop<br /><span style="color: #0a0; font-weight: bold;">andy@alba</span> <span style="color: #55f; font-weight: bold;">~ $</span> I\ will\ try\ to\ type\ a\ wrong\ command...<br />bash: I will try to type a wrong command...: command not found<br /><span style="color: #0a0; font-weight: bold;">andy@alba</span> <span style="color: #55f; font-weight: bold;">~</span> <span style="color: #a00; font-weight: bold;">:(</span> <span style="color: #55f; font-weight: bold;">$</span> echo 'Hello world!'<br />Hello world!<br /><span style="color: #0a0; font-weight: bold;">andy@alba</span> su<br />Password:<br />Two can Live as Cheaply as One for Half as Long.<br /> &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;-- Howard Kandel<br /><span style="color: #a00; font-weight: bold;">alba</span> <span style="color: #55f; font-weight: bold;">~ $</span> <span style="text-decoration: blink;">_</span></div><br />
<br />
==Installation==<br />
{{Warning|You should back up any system-wide bash files you modify in {{ic|/etc}} as simple syntax mistakes may break your shell.}}<br />
<br />
It's a '''generalized scheme for all users''', so you should start renaming your {{ic|~/.bashrc}} file and then copy the {{ic|/etc/bash.bashrc}} file to {{ic|/etc/bash.bashrc.back}} and create a {{ic|/etc/DIR_COLORS}} file ({{ic|~/.bashrc}} and {{ic|/etc/bash.bashrc}} [[Color_Bash_Prompt#Example_of_cohabitation_of_.2Fetc.2Fbash.bashrc_and_.7E.2F.bashrc|can also cohabitate]]). Here is our possible version of this scheme for Arch (originally this scheme was created for Gentoo, but here are some important additions).<br />
<br />
===/etc/bash.bashrc===<br />
<br />
<pre style="max-height: 400px; overflow:auto;"># /etc/bash.bashrc<br />
#<br />
# https://wiki.archlinux.org/index.php/Color_Bash_Prompt<br />
#<br />
# This file is sourced by all *interactive* bash shells on startup,<br />
# including some apparently interactive shells such as scp and rcp<br />
# that can't tolerate any output. So make sure this doesn't display<br />
# anything or bad things will happen !<br />
<br />
# Test for an interactive shell. There is no need to set anything<br />
# past this point for scp and rcp, and it's important to refrain from<br />
# outputting anything in those cases.<br />
<br />
# If not running interactively, don't do anything!<br />
[[ $- != *i* ]] &amp;&amp; return<br />
<br />
# Bash won't get SIGWINCH if another process is in the foreground.<br />
# Enable checkwinsize so that bash will check the terminal size when<br />
# it regains control.<br />
# http://cnswww.cns.cwru.edu/~chet/bash/FAQ (E11)<br />
shopt -s checkwinsize<br />
<br />
# Enable history appending instead of overwriting.<br />
shopt -s histappend<br />
<br />
case ${TERM} in<br />
xterm*|rxvt*|Eterm|aterm|kterm|gnome*)<br />
PROMPT_COMMAND=${PROMPT_COMMAND:+$PROMPT_COMMAND; }'printf "\033]0;%s@%s:%s\007" "${USER}" "${HOSTNAME%%.*}" "${PWD/#$HOME/~}"'<br />
;;<br />
screen)<br />
PROMPT_COMMAND=${PROMPT_COMMAND:+$PROMPT_COMMAND; }'printf "\033_%s@%s:%s\033\\" "${USER}" "${HOSTNAME%%.*}" "${PWD/#$HOME/~}"'<br />
;;<br />
esac<br />
<br />
# fortune is a simple program that displays a pseudorandom message<br />
# from a database of quotations at logon and/or logout.<br />
# If you wish to use it, please install "fortune-mod" from the<br />
# official repositories, then uncomment the following line:<br />
<br />
# [[ "$PS1" ]] &amp;&amp; /usr/bin/fortune<br />
<br />
# Set colorful PS1 only on colorful terminals.<br />
# dircolors --print-database uses its own built-in database<br />
# instead of using /etc/DIR_COLORS. Try to use the external file<br />
# first to take advantage of user additions. Use internal bash<br />
# globbing instead of external grep binary.<br />
<br />
# sanitize TERM:<br />
safe_term=${TERM//[^[:alnum:]]/?}<br />
match_lhs=""<br />
<br />
[[ -f ~/.dir_colors ]] &amp;&amp; match_lhs="${match_lhs}$(&lt;~/.dir_colors)"<br />
[[ -f /etc/DIR_COLORS ]] &amp;&amp; match_lhs="${match_lhs}$(&lt;/etc/DIR_COLORS)"<br />
[[ -z ${match_lhs} ]] \<br />
&amp;&amp; type -P dircolors &gt;/dev/null \<br />
&amp;&amp; match_lhs=$(dircolors --print-database)<br />
<br />
if [[ $'\n'${match_lhs} == *$'\n'"TERM "${safe_term}* ]] ; then<br />
<br />
# we have colors :-)<br />
<br />
# Enable colors for ls, etc. Prefer ~/.dir_colors<br />
if type -P dircolors &gt;/dev/null ; then<br />
if [[ -f ~/.dir_colors ]] ; then<br />
eval $(dircolors -b ~/.dir_colors)<br />
elif [[ -f /etc/DIR_COLORS ]] ; then<br />
eval $(dircolors -b /etc/DIR_COLORS)<br />
fi<br />
fi<br />
<br />
PS1="$(if [[ ${EUID} == 0 ]]; then echo '\[\033[01;31m\]\h'; else echo '\[\033[01;32m\]\u@\h'; fi)\[\033[01;34m\] \w \$([[ \$? != 0 ]] &amp;&amp; echo \"\[\033[01;31m\]:(\[\033[01;34m\] \")\\$\[\033[00m\] "<br />
<br />
# Use this other PS1 string if you want \W for root and \w for all other users:<br />
# PS1="$(if [[ ${EUID} == 0 ]]; then echo '\[\033[01;31m\]\h\[\033[01;34m\] \W'; else echo '\[\033[01;32m\]\u@\h\[\033[01;34m\] \w'; fi) \$([[ \$? != 0 ]] &amp;&amp; echo \"\[\033[01;31m\]:(\[\033[01;34m\] \")\\$\[\033[00m\] "<br />
<br />
alias ls="ls --color=auto"<br />
alias dir="dir --color=auto"<br />
alias grep="grep --color=auto"<br />
alias dmesg='dmesg --color'<br />
<br />
# Uncomment the "Color" line in /etc/pacman.conf instead of uncommenting the following line...!<br />
<br />
# alias pacman="pacman --color=auto"<br />
<br />
else<br />
<br />
# show root@ when we do not have colors<br />
<br />
PS1="\u@\h \w \$([[ \$? != 0 ]] &amp;&amp; echo \":( \")\$ "<br />
<br />
# Use this other PS1 string if you want \W for root and \w for all other users:<br />
# PS1="\u@\h $(if [[ ${EUID} == 0 ]]; then echo '\W'; else echo '\w'; fi) \$([[ \$? != 0 ]] &amp;&amp; echo \":( \")\$ "<br />
<br />
fi<br />
<br />
PS2="&gt; "<br />
PS3="&gt; "<br />
PS4="+ "<br />
<br />
# Try to keep environment pollution down, EPA loves us.<br />
unset safe_term match_lhs<br />
<br />
# Try to enable the auto-completion (type: "pacman -S bash-completion" to install it).<br />
[ -r /usr/share/bash-completion/bash_completion ] &amp;&amp; . /usr/share/bash-completion/bash_completion<br />
<br />
# Try to enable the "Command not found" hook ("pacman -S pkgfile" to install it).<br />
# See also: https://wiki.archlinux.org/index.php/Bash#The_.22command_not_found.22_hook<br />
[ -r /usr/share/doc/pkgfile/command-not-found.bash ] &amp;&amp; . /usr/share/doc/pkgfile/command-not-found.bash</pre><br />
<br />
====Environment variables====<br />
<br />
There are also other programs which, to be colorized, require the setting of some [[Environment Variables|environment variables]]. This is the case of [[Man Page|man]], for example:<br />
<br />
{{bc|<nowiki>export LESS_TERMCAP_mb=$'\E[01;31m' \<br />
LESS_TERMCAP_md=$'\E[01;38;5;74m' \<br />
LESS_TERMCAP_me=$'\E[0m' \<br />
LESS_TERMCAP_se=$'\E[0m' \<br />
LESS_TERMCAP_so=$'\E[38;5;246m' \<br />
LESS_TERMCAP_ue=$'\E[0m' \<br />
LESS_TERMCAP_us=$'\E[04;38;5;146m' \</nowiki>}}<br />
<br />
For more info, see: [[Environment Variables]].<br />
<br />
===/etc/DIR_COLORS===<br />
<br />
<pre style="max-height: 300px; overflow:auto;"># Configuration file for the color ls utility<br />
# This file goes in the /etc directory, and must be world readable.<br />
# You can copy this file to .dir_colors in your $HOME directory to override<br />
# the system defaults.<br />
<br />
# COLOR needs one of these arguments: 'tty' colorizes output to ttys, but not<br />
# pipes. 'all' adds color characters to all output. 'none' shuts colorization<br />
# off.<br />
COLOR all<br />
<br />
# Extra command line options for ls go here.<br />
# Basically these ones are:<br />
# -F = show '/' for dirs, '*' for executables, etc.<br />
# -T 0 = don't trust tab spacing when formatting ls output.<br />
OPTIONS -F -T 0<br />
<br />
# Below, there should be one TERM entry for each termtype that is colorizable<br />
TERM linux<br />
TERM console<br />
TERM con132x25<br />
TERM con132x30<br />
TERM con132x43<br />
TERM con132x60<br />
TERM con80x25<br />
TERM con80x28<br />
TERM con80x30<br />
TERM con80x43<br />
TERM con80x50<br />
TERM con80x60<br />
TERM xterm<br />
TERM xterm-color<br />
TERM vt100<br />
TERM rxvt<br />
TERM rxvt-256color<br />
TERM rxvt-cygwin<br />
TERM rxvt-cygwin-native<br />
TERM rxvt-unicode<br />
TERM rxvt-unicode-256color<br />
TERM rxvt-unicode256<br />
TERM screen<br />
<br />
# EIGHTBIT, followed by '1' for on, '0' for off. (8-bit output)<br />
EIGHTBIT 1<br />
<br />
# Below are the color init strings for the basic file types. A color init<br />
# string consists of one or more of the following numeric codes:<br />
# Attribute codes: <br />
# 00=none 01=bold 04=underscore 05=blink 07=reverse 08=concealed<br />
# Text color codes:<br />
# 30=black 31=red 32=green 33=yellow 34=blue 35=magenta 36=cyan 37=white<br />
# Background color codes:<br />
# 40=black 41=red 42=green 43=yellow 44=blue 45=magenta 46=cyan 47=white<br />
NORMAL 00 # global default, although everything should be something.<br />
FILE 00 # normal file<br />
DIR 01;34 # directory<br />
LINK 01;36 # symbolic link<br />
FIFO 40;33 # pipe<br />
SOCK 01;35 # socket<br />
BLK 40;33;01 # block device driver<br />
CHR 40;33;01 # character device driver<br />
<br />
# This is for files with execute permission:<br />
EXEC 01;32 <br />
<br />
# List any file extensions like '.gz' or '.tar' that you would like ls<br />
# to colorize below. Put the extension, a space, and the color init string.<br />
# (and any comments you want to add after a '#')<br />
.cmd 01;32 # executables (bright green)<br />
.exe 01;32<br />
.com 01;32<br />
.btm 01;32<br />
.bat 01;32<br />
.tar 01;31 # archives or compressed (bright red)<br />
.tgz 01;31<br />
.arj 01;31<br />
.taz 01;31<br />
.lzh 01;31<br />
.zip 01;31<br />
.z 01;31<br />
.Z 01;31<br />
.gz 01;31<br />
.jpg 01;35 # image formats<br />
.gif 01;35<br />
.bmp 01;35<br />
.xbm 01;35<br />
.xpm 01;35<br />
.tif 01;35</pre><br />
<br />
===/etc/pacman.conf===<br />
<br />
As of version 4.1, Pacman has a '''color''' option. In order to activate it, please, uncomment the {{ic|#Color}} line in {{ic|/etc/pacman.conf}}.<br />
<br />
===/etc/skel/===<br />
<br />
This tip shows you how to use {{ic|/etc/skel/}} directory to ensure that all new users on your system get the same initial settings.<br />
<br />
The {{ic|/etc/skel/}} directory is the directory used by {{ic|useradd}} to create the default settings in a new user's home directory.<br />
<br />
To change the location of {{ic|/etc/skel/}}, edit {{ic|/etc/default/useradd}}.<br />
<br />
{{bc|<nowiki># useradd defaults file <br />
GROUP=100 <br />
HOME=/home <br />
INACTIVE=-1 <br />
EXPIRE= <br />
SHELL=/bin/bash <br />
SKEL=/etc/skel</nowiki>}}<br />
<br />
Typically files included in {{ic|/etc/skel/}} are {{ic|.rc}} files for shell initialization, but you could also include a {{ic|public_html}} directory, a custom {{ic|.dir_colors}} file, or anything else.<br />
<br />
<div style="font-family: monospace; margin: 1em 3em; padding: 1em; border: 3px solid #bcd; background-color: black; color: #fff;"><span style="color: #0a0; font-weight: bold;">andy@alba</span> <span style="color: #55f; font-weight: bold;">/etc/skel $</span> ls -A<br />.bash_logout .bash_profile .bashrc .xinitrc .xsession<br /><span style="color: #0a0; font-weight: bold;">andy@alba</span> <span style="color: #55f; font-weight: bold;">/etc/skel $</span> <span style="text-decoration: blink;">_</span></div><br />
<br />
For more information on customizing the {{ic|/etc/skel/}} directory, type: {{ic|$ man useradd}}. See also: [http://www.gentoo.org/news/en/gwn/20031222-newsletter.xml http://www.gentoo.org/news/en/gwn/20031222-newsletter.xml].<br />
<br />
Now, the {{ic|/etc/skel/.bashrc}} file is the {{ic|.bashrc}} file copyied into the home directory of each ''new'' user. It will look something like this:<br />
<br />
{{bc|<nowiki>#<br />
# ~/.bashrc<br />
#<br />
<br />
# If not running interactively, don't do anything<br />
[[ $- != *i* ]] &amp;&amp; return<br />
<br />
alias ls='ls --color=auto'<br />
PS1='[\u@\h \W]\$ '</nowiki>}}<br />
<br />
As you can see, a {{ic|PS1}} variable (i.e.: the prompt) is exported. So, if you had previously created a color prompt through the {{ic|/etc/bash.bashrc}} file, each user newly created, to see it, should delete the line<br />
<br />
{{bc|<nowiki>PS1='[\u@\h \W]\$ '</nowiki>}}<br />
<br />
from his own {{ic|~/.bashrc}}. Accordingly, if you want to grant to newly created users to have the same colorfull {{ic|PS1}}, you should delete that line from {{ic|/etc/skel/.bashrc}}.<br />
<br />
==Example of cohabitation of /etc/bash.bashrc and ~/.bashrc==<br />
<br />
{{ic|~/.bashrc}} and {{ic|/etc/bash.bashrc}} can also cohabitate. Here is a possible example of a typical Arch user's {{ic|~/.bashrc}} file which can cohabit with the {{ic|/etc/bash.bashrc}} file proposed here, valid for all users. The output will remain coloured.<br />
<br />
{{bc|<nowiki>#<br />
# ~/.bashrc<br />
#<br />
<br />
# If not running interactively, don't do anything<br />
[[ $- != *i* ]] &amp;&amp; return<br />
<br />
# environment variables<br />
export EDITOR="$(if [[ -n $DISPLAY ]]; then echo 'gedit'; else echo 'nano'; fi)" # gedit, nano<br />
<br />
# pacman aliases (if desired, adapt for your favourite AUR helper)<br />
alias pac="sudo /usr/bin/pacman -S" # default action - install one or more packages<br />
alias pacu="sudo /usr/bin/pacman -Syu" # '[u]pdate' - upgrade all packages to their newest version<br />
alias pacr="sudo /usr/bin/pacman -Rns" # '[r]emove' - uninstall one or more packages<br />
alias pacs="/usr/bin/pacman -Ss" # '[s]earch' - search for a package using one or more keywords<br />
alias paci="/usr/bin/pacman -Si" # '[i]nfo' - show information about a package<br />
alias paclo="/usr/bin/pacman -Qdt" # '[l]ist [o]rphans' - list all packages which are orphaned<br />
alias pacc="sudo /usr/bin/pacman -Scc" # '[c]lean cache' - delete all not currently installed package files<br />
alias paclf="/usr/bin/pacman -Ql" # '[l]ist [f]iles' - list all files installed by a given package<br />
alias pacexpl="sudo /usr/bin/pacman -D --asexp" # 'mark as [expl]icit' - mark one or more packages as explicitly installed <br />
alias pacimpl="sudo /usr/bin/pacman -D --asdep" # 'mark as [impl]icit' - mark one or more packages as non explicitly installed<br />
<br />
# '[r]emove [o]rphans' - recursively remove ALL orphaned packages<br />
alias pacro="/usr/bin/pacman -Qtdq > /dev/null && sudo /usr/bin/pacman -Rns \$(/usr/bin/pacman -Qtdq | sed -e ':a;N;$!ba;s/\n/ /g')"</nowiki>}}<br />
<br />
== Random quotations at logon ==<br />
<br />
If you want a random quotation at logon (like Slackware) you must install {{Pkg|fortune-mod}}. fortune is a simple program that displays a pseudorandom message from a database of quotations at logon and/or logout. Uncomment the following line from [[Color_Bash_Prompt#.2Fetc.2Fbash.bashrc|our]] {{ic|/etc/bash.bashrc}} file:<br />
{{bc|<nowiki># [[ "$PS1" ]] &amp;&amp; /usr/bin/fortune</nowiki>}}<br />
<br />
If you want to colorize (brown in this example) the random message from fortune, replace the previous commented text with:<br />
{{bc|<nowiki>[[ "$PS1" ]] &amp;&amp; echo -e "\e[00;33m$(/usr/bin/fortune)\e[00m"</nowiki>}}<br />
<br />
== Colorized Arch latest news at logon ==<br />
<br />
If you want to read the latest news from the [https://www.archlinux.org/news/ Arch official website], instead of a random quotation from fortune, replace the following lines from [[Color_Bash_Prompt#.2Fetc.2Fbash.bashrc|our]] {{ic|/etc/bash.bashrc}} file:<br />
{{bc|<nowiki># fortune is a simple program that displays a pseudorandom message<br />
# from a database of quotations at logon and/or logout.<br />
# If you wish to use it, uncomment the following line:<br />
<br />
# [[ "$PS1" ]] &amp;&amp; /usr/bin/fortune</nowiki>}}<br />
with:<br />
{{bc|<nowiki># Arch latest news<br />
<br />
if [ "$PS1" ]; then<br />
# The characters "&pound;, &sect;" are used as metacharacters. They should not be encountered in a feed...<br />
echo -e "$(echo $(curl --silent https://www.archlinux.org/feeds/news/ | sed -e ':a;N;$!ba;s/\n/ /g') | \<br />
sed -e 's/&amp;amp;/\&amp;/g<br />
s/&amp;lt;\|&amp;#60;/&lt;/g<br />
s/&amp;gt;\|&amp;#62;/&gt;/g<br />
s/&lt;\/a&gt;/&pound;/g<br />
s/href\=\"/&sect;/g<br />
s/&lt;title&gt;/\\n\\n\\n :: \\e[01;31m/g; s/&lt;\/title&gt;/\\e[00m ::\\n/g<br />
s/&lt;link&gt;/ [ \\e[01;36m/g; s/&lt;\/link&gt;/\\e[00m ]/g<br />
s/&lt;description&gt;/\\n\\n\\e[00;37m/g; s/&lt;\/description&gt;/\\e[00m\\n\\n/g<br />
s/&lt;p\( [^&gt;]*\)\?&gt;\|&lt;br\s*\/\?&gt;/\n/g<br />
s/&lt;b\( [^&gt;]*\)\?&gt;\|&lt;strong\( [^&gt;]*\)\?&gt;/\\e[01;30m/g; s/&lt;\/b&gt;\|&lt;\/strong&gt;/\\e[00;37m/g<br />
s/&lt;i\( [^&gt;]*\)\?&gt;\|&lt;em\( [^&gt;]*\)\?&gt;/\\e[41;37m/g; s/&lt;\/i&gt;\|&lt;\/em&gt;/\\e[00;37m/g<br />
s/&lt;u\( [^&gt;]*\)\?&gt;/\\e[4;37m/g; s/&lt;\/u&gt;/\\e[00;37m/g<br />
s/&lt;code\( [^&gt;]*\)\?&gt;/\\e[00m/g; s/&lt;\/code&gt;/\\e[00;37m/g<br />
s/&lt;a[^&sect;|t]*&sect;\([^\"]*\)\"[^&gt;]*&gt;\([^&pound;]*\)[^&pound;]*&pound;/\\e[01;31m\2\\e[00;37m \\e[01;34m[\\e[00;37m \\e[04m\1\\e[00;37m\\e[01;34m ]\\e[00;37m/g<br />
s/&lt;li\( [^&gt;]*\)\?&gt;/\n \\e[01;34m*\\e[00;37m /g<br />
s/&lt;!\[CDATA\[\|\]\]&gt;//g<br />
s/\|&gt;\s*&lt;//g<br />
s/ *&lt;[^&gt;]\+&gt; */ /g<br />
s/[&lt;&gt;&pound;&sect;]//g')\n\n";<br />
fi</nowiki>}}<br />
that is a small and coloured RSS escaping script written by the user [https://aur.archlinux.org/account.php?Action=AccountInfo&ID=33208 grufo] which will display an output like this:<br />
<br />
<div style="height: 350px; overflow: auto; font-family: monospace; margin: 1em 3em; padding: 1em; border: 3px solid #bbccdd; background-color: black; color: #aaaaaa;">&nbsp;&nbsp; <span style="color: #ffffff; font-weight: bold;">::</span> <span style="color: #aa0000; font-weight: bold;">Arch Linux: Recent news updates</span> <span style="color: #ffffff; font-weight: bold;">::</span><br />&nbsp;<span style="color: #ffffff;">[</span> <span style="color: #55ccff; font-weight: bold;"><nowiki>https://www.archlinux.org/news/</nowiki></span> <span style="color: #ffffff;">]</span><br /><br />The latest and greatest news from the Arch Linux distribution.<br /><br />&nbsp;<span style="color: #aa0000; font-weight: bold;">en-us Sun, 04 Nov 2012 16:09:46 +0000</span><br /><br /><br />&nbsp;&nbsp; <span style="color: #ffffff; font-weight: bold;">::</span> <span style="color: #aa0000; font-weight: bold;">End of initscripts support</span> <span style="color: #ffffff; font-weight: bold;">::</span><br />&nbsp;<span style="color: #ffffff;">[</span> <span style="color: #55ccff; font-weight: bold;"><nowiki>https://www.archlinux.org/news/end-of-initscripts-support/</nowiki></span> <span style="color: #ffffff;">]</span><br /><br /><br />Tom Gundersen wrote:<br />As <span style="color: #ffffff;">systemd</span> is now the default init system, Arch Linux is receiving minimal testing on initscripts systems. Due to a lack of resources and interest, we are unlikely to work on fixing <span style="color: #ffffff;">initscripts</span>-specific bugs, and may close them as WONTFIX.<br />We therefore strongly encourage all users to migrate to <span style="color: #ffffff;">systemd</span> as soon as possible. See the <span style="color: #ffffff;">systemd</span> migration guide <span style="color: #5555ff;">[</span> <span style="text-decoration: underline;"><nowiki>https://wiki.archlinux.org/index.php/Systemd</nowiki></span> <span style="color: #5555ff;">]</span>.<br />To ease the transition, <span style="color: #ffffff;">initscripts</span> support will remain in the official repositories for the time being, unless otherwise stated. As of January 2013, we will start removing <span style="color: #ffffff;">initscripts</span> support (e.g., <span style="color: #ffffff;">rc</span> scripts) from individual packages without further notice.<br /><br />&nbsp;<span style="color: #ffffff;">Tom Gundersen Sun, 04 Nov 2012 16:09:46 +0000 tag:www.archlinux.org,2012-11-04:/news/end-of-initscripts-support/</span><br /><br /><br />&nbsp;&nbsp; <span style="color: #ffffff; font-weight: bold;">::</span> <span style="color: #aa0000; font-weight: bold;">November release of install media available</span> <span style="color: #ffffff; font-weight: bold;">::</span><br />&nbsp;<span style="color: #ffffff;">[</span> <span style="color: #55ccff; font-weight: bold;"><nowiki>https://www.archlinux.org/news/november-release-of-install-media-available/</nowiki></span> <span style="color: #ffffff;">]</span><br /><br /><br />Pierre Schmitz wrote:<br />The latest snapshot of our install and rescue media can be found on our <span style="color: #aa0000; font-weight: bold;">Download</span> <span style="color: #5555ff;">[</span> <span style="text-decoration: underline;"><nowiki>https://www.archlinux.org/download/</nowiki></span> <span style="color: #5555ff;">]</span> page. The 2012.11.01 ISO image mainly contains minor bug fixes, cleanups and new packages compared to the previous one:<br />&nbsp;<span style="color: #5555ff;">*</span> First media with Linux 3.6<br />&nbsp;<span style="color: #5555ff;">*</span> <span style="background-color: #aa0000;">copytoram=n</span> can be used to not copy the image to RAM on network boot. This is probably unreliable but an option for systems with very low memory.<br />&nbsp;<span style="color: #5555ff;">*</span> <span style="background-color: #aa0000;">cowfile_size</span> boot parameter mainly for persistent COW on VFAT. See the <span style="color: #aa0000; font-weight: bold;">README</span> <span style="color: #5555ff;">[</span> <span style="text-decoration: underline;"><nowiki>https://projects.archlinux.org/archiso.git/plain/docs/README.bootparams?id=v4</nowiki></span> <span style="color: #5555ff;">]</span> file for details.<br /><br />&nbsp;<span style="color: #ffffff;">Pierre Schmitz Fri, 02 Nov 2012 17:54:15 +0000 tag:www.archlinux.org,2012-11-02:/news/november-release-of-install-media-available/</span><br /><br /><br />&nbsp;&nbsp; <span style="color: #ffffff; font-weight: bold;">::</span> <span style="color: #aa0000; font-weight: bold;">Bug Squashing Day: Saturday 17th November</span> <span style="color: #ffffff; font-weight: bold;">::</span><br />&nbsp;<span style="color: #ffffff;">[</span> <span style="color: #55ccff; font-weight: bold;"><nowiki>https://www.archlinux.org/news/bug-squashing-day-saturday-17th-november/</nowiki></span> <span style="color: #ffffff;">]</span><br /><br /><br />Allan McRae wrote:<br />The number of bugs in the Arch Linux bug tracker is creeping up so it is time for some extermination.<br />This is a great way for the community to get involved and help the Arch Linux team. The process is simple. First look at a bug for your favorite piece of software in the bug tracker and check if it still occurs. If it does, check the upstream project for a fix and test it to confirm it works. If there is no fix available, make sure the bug has been filed in the upstream tracker.<br />Join us on the #archlinux-bugs IRC channel. We are spread across timezones, so people should be around all day.<br /><br />&nbsp;<span style="color: #ffffff;">Allan McRae Thu, 01 Nov 2012 12:28:51 +0000 tag:www.archlinux.org,2012-11-01:/news/bug-squashing-day-saturday-17th-november/</span><br /><br /><br />&nbsp;&nbsp; <span style="color: #ffffff; font-weight: bold;">::</span> <span style="color: #aa0000; font-weight: bold;">ConsoleKit replaced by logind</span> <span style="color: #ffffff; font-weight: bold;">::</span><br />&nbsp;<span style="color: #ffffff;">[</span> <span style="color: #55ccff; font-weight: bold;"><nowiki>https://www.archlinux.org/news/consolekit-replaced-by-logind/</nowiki></span> <span style="color: #ffffff;">]</span><br /><br /><br />Allan McRae wrote:<br />With GNOME 3.6, polkit and networkmanager moving to [extra], ConsoleKit has now been removed from the repositories. Any package that previously depended on it now relies on systemd-logind instead. That means that the system must be booted with systemd to be fully functional.<br />In addition to GNOME, both KDE and XFCE are also affected by this change.<br /><br />&nbsp;<span style="color: #ffffff;">Allan McRae Tue, 30 Oct 2012 22:17:39 +0000 tag:www.archlinux.org,2012-10-30:/news/consolekit-replaced-by-logind/</span><br /><br /><br />&nbsp;&nbsp; <span style="color: #ffffff; font-weight: bold;">::</span> <span style="color: #aa0000; font-weight: bold;">systemd is now the default on new installations</span> <span style="color: #ffffff; font-weight: bold;">::</span><br />&nbsp;<span style="color: #ffffff;">[</span> <span style="color: #55ccff; font-weight: bold;"><nowiki>https://www.archlinux.org/news/systemd-is-now-the-default-on-new-installations/</nowiki></span> <span style="color: #ffffff;">]</span><br /><br /><br />Thomas B&auml;chler wrote:<br />The base group now contains the <span style="color: #ffffff;">systemd-sysvcompat</span> package. This means that all new installations will boot with systemd by default.<br />As some packages still lack native systemd units, users can install the <span style="color: #ffffff;">initscripts</span> package and use the <span style="color: #ffffff;">DAEMONS</span> array in <span style="color: #ffffff;">/etc/rc.conf</span> to start services using the legacy rc.d scripts.<br />This change does not affect existing installations. For the time being, the <span style="color: #ffffff;">initscripts</span> and <span style="color: #ffffff;">sysvinit</span> packages remain available from our repositories. However, individual packages may now start relying on the system being booted with systemd.<br />Please refer to <span style="color: #aa0000; font-weight: bold;">the wiki</span> <span style="color: #5555ff;">[</span> <span style="text-decoration: underline;"><nowiki>https://wiki.archlinux.org/index.php/Systemd</nowiki></span> <span style="color: #5555ff;">]</span> for how to transition an existing installation to systemd.<br /><br />&nbsp;<span style="color: #ffffff;">Thomas B&auml;chler Sat, 13 Oct 2012 09:29:38 +0000 tag:www.archlinux.org,2012-10-13:/news/systemd-is-now-the-default-on-new-installations/</span><br /><br /><br />&nbsp;&nbsp; <span style="color: #ffffff; font-weight: bold;">::</span> <span style="color: #aa0000; font-weight: bold;">Install medium 2012.10.06 introduces systemd</span> <span style="color: #ffffff; font-weight: bold;">::</span><br />&nbsp;<span style="color: #ffffff;">[</span> <span style="color: #55ccff; font-weight: bold;"><nowiki>https://www.archlinux.org/news/install-medium-20121006-introduces-systemd/</nowiki></span> <span style="color: #ffffff;">]</span><br /><br /><br />Pierre Schmitz wrote:<br />The October release of the Arch Linux install medium is available for <span style="color: #aa0000; font-weight: bold;">Download</span> <span style="color: #5555ff;">[</span> <span style="text-decoration: underline;"><nowiki>https://www.archlinux.org/download/</nowiki></span> <span style="color: #5555ff;">]</span> and can be used for new installs or as a rescue system. It contains a set of updated packages and the following notable changes:<br />&nbsp;<span style="color: #5555ff;">*</span> systemd is used to boot up the live system.<br />&nbsp;<span style="color: #5555ff;">*</span> initscripts are no longer available on the live system but are still installed by default on the target system. This is likely to change in the near future.<br />&nbsp;<span style="color: #5555ff;">*</span> EFI boot and setup has been simplified.<br />&nbsp;<span style="color: #5555ff;">*</span> gummiboot is used to display a menu on EFI systems.<br />&nbsp;<span style="color: #5555ff;">*</span> The following new packages are available on the live system: ethtool, fsarchiver, gummiboot-efi, mc, partclone, partimage, refind-efi, rfkill, sudo, testdisk, wget, xl2tpd<br /><br />&nbsp;<span style="color: #ffffff;">Pierre Schmitz Sun, 07 Oct 2012 16:58:03 +0000 tag:www.archlinux.org,2012-10-07:/news/install-medium-20121006-introduces-systemd/</span><br /><br /><br />&nbsp;&nbsp; <span style="color: #ffffff; font-weight: bold;">::</span> <span style="color: #aa0000; font-weight: bold;">New install medium 2012.09.07</span> <span style="color: #ffffff; font-weight: bold;">::</span><br />&nbsp;<span style="color: #ffffff;">[</span> <span style="color: #55ccff; font-weight: bold;"><nowiki>https://www.archlinux.org/news/new-install-medium-20120907/</nowiki></span> <span style="color: #ffffff;">]</span><br /><br /><br />Pierre Schmitz wrote:<br />As is customary by now there is a new install medium available at the beginning of this month. The live system can be downloaded from <span style="color: #aa0000; font-weight: bold;">Download</span> <span style="color: #5555ff;">[</span> <span style="text-decoration: underline;"><nowiki>https://www.archlinux.org/download/</nowiki></span> <span style="color: #5555ff;">]</span> and be used for new installs or as a rescue system.<br />In addition to a couple of updated packages and bug fixes the following changes stand out:<br />&nbsp;<span style="color: #5555ff;">*</span> First medium with Linux 3.5 (3.5.3)<br />&nbsp;<span style="color: #5555ff;">*</span> The <span style="background-color: #aa0000;">script</span> boot parameter works again (<span style="color: #aa0000; font-weight: bold;">FS#31022</span> <span style="color: #5555ff;">[</span> <span style="text-decoration: underline;"><nowiki>https://bugs.archlinux.org/task/31022</nowiki></span> <span style="color: #5555ff;">]</span>)<br />&nbsp;<span style="color: #5555ff;">*</span> When booting via PXE and NFS or NBD the ISO will be copied to RAM to ensure a more stable usage.<br />&nbsp;<span style="color: #5555ff;">*</span> The live medium contains <span style="background-color: #aa0000;">usb_modeswitch</span> and <span style="background-color: #aa0000;">wvdial</span> which e.g. allows to establish a network connection using an UMTS USB dongle<br />&nbsp;<span style="color: #5555ff;">*</span> Furthermore the newest versions of <span style="background-color: #aa0000;">initscripts</span>, <span style="background-color: #aa0000;">systemd</span> and <span style="background-color: #aa0000;">netcfg</span> are included.<br /><br />&nbsp;<span style="color: #ffffff;">Pierre Schmitz Sat, 08 Sep 2012 09:48:52 +0000 tag:www.archlinux.org,2012-09-08:/news/new-install-medium-20120907/</span><br /><br /><br />&nbsp;&nbsp; <span style="color: #ffffff; font-weight: bold;">::</span> <span style="color: #aa0000; font-weight: bold;">Fontconfig 2.10.1 update - manual intervention required</span> <span style="color: #ffffff; font-weight: bold;">::</span><br />&nbsp;<span style="color: #ffffff;">[</span> <span style="color: #55ccff; font-weight: bold;"><nowiki>https://www.archlinux.org/news/fontconfig-2101-update-manual-intervention-required/</nowiki></span> <span style="color: #ffffff;">]</span><br /><br /><br />Andreas Radke wrote:<br />The fontconfig 2.10.1 update overwrites symlinks created by the former package version. These symlinks need to be removed before the update:<br /><br /><span style="color: #ffffff;">rm /etc/fonts/conf.d/20-unhint-small-vera.conf</span><br /><span style="color: #ffffff;">rm /etc/fonts/conf.d/20-fix-globaladvance.conf</span><br /><span style="color: #ffffff;">rm /etc/fonts/conf.d/29-replace-bitmap-fonts.conf</span><br /><span style="color: #ffffff;">rm /etc/fonts/conf.d/30-metric-aliases.conf</span><br /><span style="color: #ffffff;">rm /etc/fonts/conf.d/30-urw-aliases.conf</span><br /><span style="color: #ffffff;">rm /etc/fonts/conf.d/40-nonlatin.conf</span><br /><span style="color: #ffffff;">rm /etc/fonts/conf.d/45-latin.conf</span><br /><span style="color: #ffffff;">rm /etc/fonts/conf.d/49-sansserif.conf</span><br /><span style="color: #ffffff;">rm /etc/fonts/conf.d/50-user.conf</span><br /><span style="color: #ffffff;">rm /etc/fonts/conf.d/51-local.conf</span><br /><span style="color: #ffffff;">rm /etc/fonts/conf.d/60-latin.conf</span><br /><span style="color: #ffffff;">rm /etc/fonts/conf.d/65-fonts-persian.conf</span><br /><span style="color: #ffffff;">rm /etc/fonts/conf.d/65-nonlatin.conf</span><br /><span style="color: #ffffff;">rm /etc/fonts/conf.d/69-unifont.conf</span><br /><span style="color: #ffffff;">rm /etc/fonts/conf.d/80-delicious.conf</span><br /><span style="color: #ffffff;">rm /etc/fonts/conf.d/90-synthetic.conf</span><br /><span style="color: #ffffff;">pacman -Syu fontconfig</span><br /><br />Main systemwide configuration should be done by symlinks (especially for autohinting, sub-pixel and lcdfilter):<br /><br /><span style="color: #ffffff;">cd /etc/fonts/conf.d</span><br /><span style="color: #ffffff;">ln -s ../conf.avail/XX-foo.conf</span><br /><br />Also check <span style="color: #aa0000; font-weight: bold;">Font Configuration</span> <span style="color: #5555ff;">[</span> <span style="text-decoration: underline;"><nowiki>https://wiki.archlinux.org/index.php/Font_Configuration</nowiki></span> <span style="color: #5555ff;">]</span> and <span style="color: #aa0000; font-weight: bold;">Fonts</span> <span style="color: #5555ff;">[</span> <span style="text-decoration: underline;"><nowiki>https://wiki.archlinux.org/index.php/Fonts</nowiki></span> <span style="color: #5555ff;">]</span>.<br /><br />&nbsp;<span style="color: #ffffff;">Andreas Radke Thu, 06 Sep 2012 13:54:23 +0000 tag:www.archlinux.org,2012-09-06:/news/fontconfig-2101-update-manual-intervention-required/</span><br /><br /><br />&nbsp;&nbsp; <span style="color: #ffffff; font-weight: bold;">::</span> <span style="color: #aa0000; font-weight: bold;">netcfg-2.8.9 drops deprecated rc.conf compatibility</span> <span style="color: #ffffff; font-weight: bold;">::</span><br />&nbsp;<span style="color: #ffffff;">[</span> <span style="color: #55ccff; font-weight: bold;"><nowiki>https://www.archlinux.org/news/netcfg-289-drops-initscripts-compatibility/</nowiki></span> <span style="color: #ffffff;">]</span><br /><br /><br />Florian Pritz wrote:<br />Users of <span style="color: #ffffff;">netcfg</span> should configure all interfaces in <span style="color: #ffffff;">/etc/conf.d/netcfg</span> rather than <span style="color: #ffffff;">/etc/rc.conf</span>.<br /><br />&nbsp;Florian Pritz Sat, 11 Aug 2012 20:00:02 +0000 tag:www.archlinux.org,2012-08-11:/news/netcfg-289-drops-initscripts-compatibility/<br /><br /><br />&nbsp;&nbsp; <span style="color: #ffffff; font-weight: bold;">::</span> <span style="color: #aa0000; font-weight: bold;">Install media 2012.08.04 available</span> <span style="color: #ffffff; font-weight: bold;">::</span><br />&nbsp;<span style="color: #ffffff;">[</span> <span style="color: #55ccff; font-weight: bold;"><nowiki>https://www.archlinux.org/news/install-media-20120804-available/</nowiki></span> <span style="color: #ffffff;">]</span><br /><br /><br />Pierre Schmitz wrote:<br />The August snapshot of our live and install media comes with updated packages and the following changes on top of the <span style="color: #aa0000; font-weight: bold;">previous ISO image</span> <span style="color: #5555ff;">[</span> <span style="text-decoration: underline;">/news/install-media-20120715-released/</span> <span style="color: #5555ff;">]</span>:<br />&nbsp;<span style="color: #5555ff;">*</span> GRUB 2.0 instead of the legacy 0.9 version is available.<br />&nbsp;<span style="color: #5555ff;">*</span> The <span style="color: #aa0000; font-weight: bold;">Installation Guide</span> <span style="color: #5555ff;">[</span> <span style="text-decoration: underline;"><nowiki>https://wiki.archlinux.org/index.php/Installation_Guide</nowiki></span> <span style="color: #5555ff;">]</span> can be found at <span style="background-color: #aa0000;">/root/install.txt</span>.<br />&nbsp;<span style="color: #5555ff;">*</span> ZSH with <span style="color: #aa0000; font-weight: bold;">Grml's configuration</span> <span style="color: #5555ff;">[</span> <span style="text-decoration: underline;"><nowiki>http://grml.org/zsh/</nowiki></span> <span style="color: #5555ff;">]</span> is used as interactive shell to provide a user friendly and more convenient environment. This includes completion support for pacstrap, arch-chroot, pacman and most other tools.<br />&nbsp;<span style="color: #5555ff;">*</span> The network daemon is started by default which will automatically setup your network if DHCP is available.<br />Note that all these changes only affect the live system and not the base system you install using pacstrap. The ISO image can be downloaded from our <span style="color: #aa0000; font-weight: bold;">download page</span> <span style="color: #5555ff;">[</span> <span style="text-decoration: underline;">/download/</span> <span style="color: #5555ff;">]</span>. The next snapshot is scheduled for September.<br /><br />&nbsp;<span style="color: #ffffff;">Pierre Schmitz Sat, 04 Aug 2012 17:24:30 +0000 tag:www.archlinux.org,2012-08-04:/news/install-media-20120804-available/</span><br /><br /><br /><span style="color: #0a0; font-weight: bold;">andy@alba</span> <span style="text-decoration: blink;">_</span></div><br />
<br />
If you don't want to see months worth of updates but only the latest item, you can use this::<br />
{{bc|<nowiki># Arch latest news<br />
<br />
if [ "$PS1" ]; then<br />
# The characters "&pound;, &sect;" are used as metacharacters. They should not be encountered in a feed...<br />
echo -e "$(echo $(curl --silent https://www.archlinux.org/feeds/news/ | awk ' NR == 1 {while ($0 !~ /<\/item>/) {print;getline} sub(/<\/item>.*/,"</item>") ;print}' | sed -e ':a;N;$!ba;s/\n/ /g') | \<br />
sed -e 's/&amp;amp;/\&amp;/g<br />
s/&amp;lt;\|&amp;#60;/&lt;/g<br />
s/&amp;gt;\|&amp;#62;/&gt;/g<br />
s/&lt;\/a&gt;/&pound;/g<br />
s/href\=\"/&sect;/g<br />
s/&lt;title&gt;/\\n\\n\\n :: \\e[01;31m/g; s/&lt;\/title&gt;/\\e[00m ::\\n/g<br />
s/&lt;link&gt;/ [ \\e[01;36m/g; s/&lt;\/link&gt;/\\e[00m ]/g<br />
s/&lt;description&gt;/\\n\\n\\e[00;37m/g; s/&lt;\/description&gt;/\\e[00m\\n\\n/g<br />
s/&lt;p\( [^&gt;]*\)\?&gt;\|&lt;br\s*\/\?&gt;/\n/g<br />
s/&lt;b\( [^&gt;]*\)\?&gt;\|&lt;strong\( [^&gt;]*\)\?&gt;/\\e[01;30m/g; s/&lt;\/b&gt;\|&lt;\/strong&gt;/\\e[00;37m/g<br />
s/&lt;i\( [^&gt;]*\)\?&gt;\|&lt;em\( [^&gt;]*\)\?&gt;/\\e[41;37m/g; s/&lt;\/i&gt;\|&lt;\/em&gt;/\\e[00;37m/g<br />
s/&lt;u\( [^&gt;]*\)\?&gt;/\\e[4;37m/g; s/&lt;\/u&gt;/\\e[00;37m/g<br />
s/&lt;code\( [^&gt;]*\)\?&gt;/\\e[00m/g; s/&lt;\/code&gt;/\\e[00;37m/g<br />
s/&lt;a[^&sect;|t]*&sect;\([^\"]*\)\"[^&gt;]*&gt;\([^&pound;]*\)[^&pound;]*&pound;/\\e[01;31m\2\\e[00;37m \\e[01;34m[\\e[00;37m \\e[04m\1\\e[00;37m\\e[01;34m ]\\e[00;37m/g<br />
s/&lt;li\( [^&gt;]*\)\?&gt;/\n \\e[01;34m*\\e[00;37m /g<br />
s/&lt;!\[CDATA\[\|\]\]&gt;//g<br />
s/\|&gt;\s*&lt;//g<br />
s/ *&lt;[^&gt;]\+&gt; */ /g<br />
s/[&lt;&gt;&pound;&sect;]//g')\n\n";<br />
fi</nowiki>}}<br />
<br />
See [https://bbs.archlinux.org/viewtopic.php?id=146850 this thread] for details.<br />
<br />
==Variations on a theme==<br />
<br />
Here are some {{ic|PS1}} variables (i.e.: prompts) with different layout to be applyied to [[Color_Bash_Prompt#.2Fetc.2Fbash.bashrc|our]] {{ic|/etc/bash.bashrc}} file. When you choose a layout you must replace the following lines from [[Color_Bash_Prompt#.2Fetc.2Fbash.bashrc|our]] {{ic|/etc/bash.bashrc}} file:<br />
<br />
{{bc|<nowiki> PS1="$(if [[ ${EUID} == 0 ]]; then echo '\[\033[01;31m\]\h'; else echo '\[\033[01;32m\]\u@\h'; fi)\[\033[01;34m\] \w \$([[ \$? != 0 ]] &amp;&amp; echo \"\[\033[01;31m\]:(\[\033[01;34m\] \")\$\[\033[00m\] "<br />
<br />
# Use this other PS1 string if you want \W for root and \w for all other users:<br />
# PS1="$(if [[ ${EUID} == 0 ]]; then echo '\[\033[01;31m\]\h\[\033[01;34m\] \W'; else echo '\[\033[01;32m\]\u@\h\[\033[01;34m\] \w'; fi) \$([[ \$? != 0 ]] &amp;&amp; echo \"\[\033[01;31m\]:(\[\033[01;34m\] \")\$\[\033[00m\] "</nowiki>}}<br />
<br />
with the {{ic|PS1}} variable (and possibly other code lines) given by the choosen layout.<br />
<br />
===From Arch Forum #1===<br />
<br />
Here is an unicode variation of [[Color_Bash_Prompt#.2Fetc.2Fbash.bashrc|our]] {{ic|/etc/bash.bashrc}} file freely based on [https://bbs.archlinux.org/viewtopic.php?pid=1068202#p1068202 what wrote the user JeSuisNerd and others in the Arch Forum]. Here is a preview of how it will appear:<br />
<br />
<div style="font-family: monospace; margin: 1em 3em; padding: 1em; border: 3px solid #bcd; background-color: black; color: #fff; font-size: 14px; line-height: 17px;">I am two with nature.<br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;-- Woody Allen<br /><span style="color: #aaa;">&#9484;&#9472;[</span><span style="color: #f90;">andy</span>@<span style="color: #5fc;">alba</span><span style="color: #aaa;">]&#9472;[</span><span style="color: #0c0;">~</span><span style="color: #aaa;">]</span><br /><span style="color: #aaa;">&#9492;&#9472;&#9472;&#9596;</span> ls<br /><span style="color: #55f; font-weight: bold;">Desktop Documents Music</span> public.desktop<br /><span style="color: #aaa;">&#9484;&#9472;[</span><span style="color: #f90;">andy</span>@<span style="color: #5fc;">alba</span><span style="color: #aaa;">]&#9472;[</span><span style="color: #0c0;">~</span><span style="color: #aaa;">]</span><br /><span style="color: #aaa;">&#9492;&#9472;&#9472;&#9596;</span>&nbsp;I\ will\ try\ to\ type\ a\ wrong\ command...<br />bash: I will try to type a wrong command...: command not found<br /><span style="color: #aaa;">&#9484;&#9472;[<span style="color: #a00;">&#10007;</span>]&#9472;[</span><span style="color: #f90;">andy</span>@<span style="color: #5fc;">alba</span><span style="color: #aaa;">]&#9472;[</span><span style="color: #0c0;">~</span><span style="color: #aaa;">]</span><br /><span style="color: #aaa;">&#9492;&#9472;&#9472;&#9596;</span> echo 'Hello world!' Hello world!<br /><span style="color: #aaa;">&#9484;&#9472;[</span><span style="color: #f90;">andy</span>@<span style="color: #5fc;">alba</span><span style="color: #aaa;">]&#9472;[</span><span style="color: #0c0;">~</span><span style="color: #aaa;">]</span><br /><span style="color: #aaa;">&#9492;&#9472;&#9472;&#9596;</span>&nbsp;su<br />Password:<br />Two can Live as Cheaply as One for Half as Long.<br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;-- Howard Kandel<br /><span style="color: #aaa;">&#9484;&#9472;[<span style="color: #a00;">alba</span>]</span><span style="color: #aaa;">&#9472;[</span><span style="color: #0c0;">~</span><span style="color: #aaa;">]</span><br /><span style="color: #aaa;">&#9492;&#9472;&#9472;&#9596;</span>&nbsp;<span style="text-decoration: blink;">_</span></div><br />
<br />
'''Note:''' '''Some unicode symbols (like <span style="color: #a00;">✗</span> and ╼) are not well supported in some terminals''' (in linux console, for example), so this prompt will appear a bit different depending on where is displayed. If you want to know the unicode representation of a plain text, [http://0xcc.net/jsescape/ here] you have a little plain text converter.<br />
<br />
And finally here is the {{ic|PS1}} variable for this effect to be applyied to [[Color_Bash_Prompt#.2Fetc.2Fbash.bashrc|our]] {{ic|/etc/bash.bashrc}} file (see [[Color_Bash_Prompt#Variations_on_a_theme|above]]):<br />
<br />
{{bc|<nowiki> # https://bbs.archlinux.org/viewtopic.php?pid=1068202#p1068202<br />
PS1="\[\033[0;37m\]\342\224\214\342\224\200\$([[ \$? != 0 ]] &amp;&amp; echo \"[\[\033[0;31m\]\342\234\227\[\033[0;37m\]]\342\224\200\")[$(if [[ ${EUID} == 0 ]]; then echo '\[\033[0;31m\]\h'; else echo '\[\033[0;33m\]\u\[\033[0;37m\]@\[\033[0;96m\]\h'; fi)\[\033[0;37m\]]\342\224\200[\[\033[0;32m\]\w\[\033[0;37m\]]\n\[\033[0;37m\]\342\224\224\342\224\200\342\224\200\342\225\274 \[\033[0m\]"</nowiki>}}<br />
<br />
===From an italian blog&hellip;===<br />
<br />
Here is an unicode variation of [[Color_Bash_Prompt#.2Fetc.2Fbash.bashrc|our]] {{ic|/etc/bash.bashrc}} file freely based on [http://dark-linux.net/personalizzare-bashrc-eo-bash-bashrc/ an italian blog]. Here is a preview of how it will appear:<br />
<br />
<div style="font-family: monospace; margin: 1em 3em; padding: 1em; border: 3px solid #bcd; background-color: black; color: #fff; font-size: 14px; line-height: 17px;">I am two with nature.<br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;-- Woody Allen<br /><span style="color: #55f;">&#9484;&#9472;[</span>12:03:20<span style="color: #55f;">]&#9472;[</span>andy@alba<span style="color: #55f;">]<br /></span><span style="color: #55f;">&#9492;&#9472;&#9472;&gt;</span> ~ <span style="color: #55f;">$</span> ls<br /><span style="color: #55f; font-weight: bold;">Desktop Documents Music</span> public.desktop<br /><span style="color: #55f;">&#9484;&#9472;[</span>12:03:31<span style="color: #55f;">]&#9472;[</span>andy@alba<span style="color: #55f;">]</span><br /><span style="color: #55f;">&#9492;&#9472;&#9472;&gt;</span> ~ <span style="color: #55f;">$</span> I\ will\ try\ to\ type\ a\ wrong\ command...<br />bash: I will try to type a wrong command...: command not found<br /><span style="color: #55f;">&#9484;&#9472;[</span>&#10007;<span style="color: #55f;">]&#9472;[</span>12:04:01<span style="color: #55f;">]&#9472;[</span>andy@alba<span style="color: #55f;">]<br /></span><span style="color: #55f;">&#9492;&#9472;&#9472;&gt;</span> ~ <span style="color: #55f;">$</span> echo 'Hello world!'<br />Hello world!<br /><span style="color: #55f;">&#9484;&#9472;[</span>12:04:13<span style="color: #55f;">]&#9472;[</span>andy@alba<span style="color: #55f;">]<br /></span><span style="color: #55f;">&#9492;&#9472;&#9472;&gt;</span> ~ <span style="color: #55f;">$</span> su<br />Password:<br />Two can Live as Cheaply as One for Half as Long.<br /> &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;-- Howard Kandel<br /><span style="color: #a00;">&#9484;&#9472;[</span>12:04:21<span style="color: #a00;">]&#9472;[</span>root@alba<span style="color: #a00;">]<br /></span><span style="color: #a00;">&#9492;&#9472;&#9472;&gt;</span> ~ <span style="color: #a00;">$</span> <span style="text-decoration: blink;">_</span></div><br />
<br />
'''Note:''' '''Some unicode symbols (like ✗) are not well supported in some terminals''' (in linux console, for example), so this prompt will appear a bit different depending on where is displayed. If you want to know the unicode representation of a plain text, [http://0xcc.net/jsescape/ here] you have a little plain text converter.<br />
<br />
And finally here is the {{ic|PS1}} variable for this effect to be applyied to [[Color_Bash_Prompt#.2Fetc.2Fbash.bashrc|our]] {{ic|/etc/bash.bashrc}} file (see [[Color_Bash_Prompt#Variations_on_a_theme|above]]):<br />
<br />
{{bc|<nowiki> if [[ ${EUID} == 0 ]] ; then<br />
sq_color="\[\033[0;31m\]"<br />
else <br />
sq_color="\[\033[0;34m\]"<br />
fi<br />
<br />
PS1="$sq_color\342\224\214\342\224\200\$([[ \$? != 0 ]] &amp;&amp; echo \"[\[\033[01;37m\]\342\234\227$sq_color]\342\224\200\")[\[\033[01;37m\]\t$sq_color]\342\224\200[\[\033[01;37m\]\u@\h$sq_color]\n\342\224\224\342\224\200\342\224\200&gt; \[\033[01;37m\]\W$sq_color $ \[\033[01;37m\]&gt;&gt;\\[\\033[0m\\] "<br />
<br />
unset sq_color</nowiki>}}<br />
<br />
===From Arch Forum #2===<br />
<br />
Here is another variation of [[Color_Bash_Prompt#.2Fetc.2Fbash.bashrc|our]] {{ic|/etc/bash.bashrc}} file freely based on [https://bbs.archlinux.org/viewtopic.php?pid=1156660#p1156660 what wrote the user shumer1213 and others in the Arch Forum]. Here is a preview of how it will appear:<br />
<br />
<div style="font-family: monospace; margin: 1em 3em; padding: 1em; border: 3px solid #bcd; background-color: black; color: #fff; font-size: 14px; line-height: 17px;">I am two with nature.<br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;-- Woody Allen<br /><br /><span style="color: #5555ff;">&#9608;&#9608; [ ~ ] [ 18:05:58 ]</span><br />&#9608;&#9608; ls<br /><span style="color: #55f; font-weight: bold;">Desktop Documents Music</span> public.desktop<br /><br /><span style="color: #5555ff;">&#9608;&#9608; [ ~ ] [ 18:06:02 ]</span><br />&#9608;&#9608; I\ will\ try\ to\ type\ a\ wrong\ command...<br />bash: I will try to type a wrong command...: command not found<br /><br /><span style="color: #aa0000;">&#9608;&#9608; [ ~ ] [ 18:06:12 ]</span><br />&#9608;&#9608; echo 'Hello world!'<br />Hello world!<br /><br /><span style="color: #5555ff;">&#9608;&#9608; [ ~ ] [ 18:06:17 ]</span><br />&#9608;&#9608; su<br />Password: <br />Two can Live as Cheaply as One for Half as Long.<br /> &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;-- Howard Kandel<br /><br /><span style="color: #5555ff;">&#9608;&#9608; [ andy ] [ 18:06:26 ]</span><br />&#9608;&#9608; <span style="text-decoration: blink;">_</span></div><br />
<br />
Here is the {{ic|PS1}} variable for this effect to be applyied to [[Color_Bash_Prompt#.2Fetc.2Fbash.bashrc|our]] {{ic|/etc/bash.bashrc}} file (see [[Color_Bash_Prompt#Variations_on_a_theme|above]]):<br />
<br />
{{bc|<nowiki> # https://bbs.archlinux.org/viewtopic.php?pid=1156660#p1156660<br />
PS1="\n\$(if [[ \$? == 0 ]]; then echo \"\[\033[0;34m\]\"; else echo \"\[\033[0;31m\]\"; fi)\342\226\210\342\226\210 [ \W ] [ \t ]\n\[\033[0m\]\342\226\210\342\226\210 "</nowiki>}}<br />
<br />
===With directory information===<br />
<br />
Here are other three variations of [[Color_Bash_Prompt#.2Fetc.2Fbash.bashrc|our]] {{ic|/etc/bash.bashrc}} file freely based on the article [http://maketecheasier.com/8-useful-and-interesting-bash-prompts/2009/09/04 8 Useful and Interesting Bash Prompts]. Here is a preview of how they will appear:<br />
<br />
====Version #1: with numerical error====<br />
<br />
<div style="font-family: monospace; margin: 1em 3em; padding: 1em; border: 3px solid #bcd; background-color: black; color: #fff; font-size: 14px; line-height: 17px;">I am two with nature.<br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;-- Woody Allen<br /><br /><span style="font-weight: bold;">&#9484;(</span><span style="font-weight: bold; color: #5555ff;">andy@alba</span><span style="font-weight: bold;">)&#9472;(</span><span style="font-weight: bold; color: #5555ff;">0</span><span style="font-weight: bold;">)&#9472;(</span><span style="font-weight: bold; color: #5555ff;">02:38 PM Sat Aug 29</span><span style="font-weight: bold;">)</span><br /><span style="font-weight: bold;">&#9492;&#9472;(</span><span style="font-weight: bold; color: #00cc00;">~</span><span style="font-weight: bold;">)&#9472;(</span><span style="font-weight: bold; color: #00cc00;">4 files, 332Kb</span><span style="font-weight: bold;">)&#9472;&gt;</span> ls<br /><span style="color: #55f; font-weight: bold;">Desktop Documents Music</span> myScript.js<br /><br /><span style="font-weight: bold;">&#9484;(</span><span style="font-weight: bold; color: #5555ff;">andy@alba</span><span style="font-weight: bold;">)&#9472;(</span><span style="font-weight: bold; color: #5555ff;">0</span><span style="font-weight: bold;">)&#9472;(</span><span style="font-weight: bold; color: #5555ff;">02:38 PM Sat Aug 29</span><span style="font-weight: bold;">)</span><br /><span style="font-weight: bold;">&#9492;&#9472;(</span><span style="font-weight: bold; color: #00cc00;">~</span><span style="font-weight: bold;">)&#9472;(</span><span style="font-weight: bold; color: #00cc00;">4 files, 332Kb</span><span style="font-weight: bold;">)&#9472;&gt;</span> I\ will\ try\ to\ type\ a\ wrong\ command...<br />bash: I will try to type a wrong command...: command not found<br /><br /><span style="font-weight: bold;">&#9484;(</span><span style="font-weight: bold; color: #5555ff;">andy@alba</span><span style="font-weight: bold;">)&#9472;(</span><span style="font-weight: bold; color: #5555ff;">127</span><span style="font-weight: bold;">)&#9472;(</span><span style="font-weight: bold; color: #5555ff;">02:39 PM Sat Aug 29</span><span style="font-weight: bold;">)</span><br /><span style="font-weight: bold;">&#9492;&#9472;(</span><span style="font-weight: bold; color: #00cc00;">~</span><span style="font-weight: bold;">)&#9472;(</span><span style="font-weight: bold; color: #00cc00;">4 files, 332Kb</span><span style="font-weight: bold;">)&#9472;&gt;</span> echo 'Hello world!'<br />Hello world!<br /><br /><span style="font-weight: bold;">&#9484;(</span><span style="font-weight: bold; color: #5555ff;">andy@alba</span><span style="font-weight: bold;">)&#9472;(</span><span style="font-weight: bold; color: #5555ff;">0</span><span style="font-weight: bold;">)&#9472;(</span><span style="font-weight: bold; color: #5555ff;">02:39 PM Sat Aug 29</span><span style="font-weight: bold;">)</span><br /><span style="font-weight: bold;">&#9492;&#9472;(</span><span style="font-weight: bold; color: #00cc00;">~</span><span style="font-weight: bold;">)&#9472;(</span><span style="font-weight: bold; color: #00cc00;">4 files, 332Kb</span><span style="font-weight: bold;">)&#9472;&gt;</span> false<br /><br /><span style="font-weight: bold;">&#9484;(</span><span style="font-weight: bold; color: #5555ff;">andy@alba</span><span style="font-weight: bold;">)&#9472;(</span><span style="font-weight: bold; color: #5555ff;">1</span><span style="font-weight: bold;">)&#9472;(</span><span style="font-weight: bold; color: #5555ff;">02:39 PM Sat Aug 29</span><span style="font-weight: bold;">)</span><br /><span style="font-weight: bold;">&#9492;&#9472;(</span><span style="font-weight: bold; color: #00cc00;">~</span><span style="font-weight: bold;">)&#9472;(</span><span style="font-weight: bold; color: #00cc00;">4 files, 332Kb</span><span style="font-weight: bold;">)&#9472;&gt;</span> su<br />Password: <br />Two can Live as Cheaply as One for Half as Long.<br /> &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;-- Howard Kandel<br /><br /><span style="font-weight: bold;">&#9484;(</span><span style="font-weight: bold; color: #aa0000;">alba</span><span style="font-weight: bold;">)&#9472;(</span><span style="font-weight: bold; color: #5555ff;">0</span><span style="font-weight: bold;">)&#9472;(</span><span style="font-weight: bold; color: #5555ff;">02:39 PM Sat Aug 29</span><span style="font-weight: bold;">)</span><br /><span style="font-weight: bold;">&#9492;&#9472;(</span><span style="font-weight: bold; color: #00cc00;">/home/andy</span><span style="font-weight: bold;">)&#9472;(</span><span style="font-weight: bold; color: #00cc00;">4 files, 332Kb</span><span style="font-weight: bold;">)&#9472;&gt;</span> <span style="text-decoration: blink;">_</span></div><br />
<br />
Here is the {{ic|PS1}} variable for this effect to be applyied to [[Color_Bash_Prompt#.2Fetc.2Fbash.bashrc|our]] {{ic|/etc/bash.bashrc}} file (see [[Color_Bash_Prompt#Variations_on_a_theme|above]]):<br />
<br />
{{bc|<nowiki> # http://maketecheasier.com/8-useful-and-interesting-bash-prompts/2009/09/04<br />
PS1="\n\[\033[1;37m\]\342\224\214($(if [[ ${EUID} == 0 ]]; then echo '\[\033[01;31m\]\h'; else echo '\[\033[01;34m\]\u@\h'; fi)\[\033[1;37m\])\342\224\200(\[\033[1;34m\]\$?\[\033[1;37m\])\342\224\200(\[\033[1;34m\]\@ \d\[\033[1;37m\])\[\033[1;37m\]\n\342\224\224\342\224\200(\[\033[1;32m\]\w\[\033[1;37m\])\342\224\200(\[\033[1;32m\]\$(ls -1 | wc -l | sed 's: ::g') files, \$(ls -lah | grep -m 1 total | sed 's/total //')b\[\033[1;37m\])\342\224\200&gt; \[\033[0m\]"</nowiki>}}<br />
<br />
<br />
====Version #2: with unicode error status symbols====<br />
<br />
<div style="font-family: monospace; margin: 1em 3em; padding: 1em; border: 3px solid #bcd; background-color: black; color: #fff; font-size: 14px; line-height: 17px;">I am two with nature.<br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;-- Woody Allen<br /><br /><span style="font-weight: bold;">&#9484;(</span><span style="font-weight: bold; color: #5555ff;">andy@alba</span><span style="font-weight: bold;">)&#9472;(</span><span style="color: #0a0; font-weight: bold;">&#10003;</span><span style="font-weight: bold;">)&#9472;(</span><span style="font-weight: bold; color: #5555ff;">02:38 PM Sat Aug 29</span><span style="font-weight: bold;">)</span><br /><span style="font-weight: bold;">&#9492;&#9472;(</span><span style="font-weight: bold; color: #00cc00;">~</span><span style="font-weight: bold;">)&#9472;(</span><span style="font-weight: bold; color: #00cc00;">4 files, 332Kb</span><span style="font-weight: bold;">)&#9472;&gt;</span> ls<br /><span style="color: #55f; font-weight: bold;">Desktop Documents Music</span> myScript.js<br /><br /><span style="font-weight: bold;">&#9484;(</span><span style="font-weight: bold; color: #5555ff;">andy@alba</span><span style="font-weight: bold;">)&#9472;(</span><span style="color: #0a0; font-weight: bold;">&#10003;</span><span style="font-weight: bold;">)&#9472;(</span><span style="font-weight: bold; color: #5555ff;">02:38 PM Sat Aug 29</span><span style="font-weight: bold;">)</span><br /><span style="font-weight: bold;">&#9492;&#9472;(</span><span style="font-weight: bold; color: #00cc00;">~</span><span style="font-weight: bold;">)&#9472;(</span><span style="font-weight: bold; color: #00cc00;">4 files, 332Kb</span><span style="font-weight: bold;">)&#9472;&gt;</span> I\ will\ try\ to\ type\ a\ wrong\ command...<br />bash: I will try to type a wrong command...: command not found<br /><br /><span style="font-weight: bold;">&#9484;(</span><span style="font-weight: bold; color: #5555ff;">andy@alba</span><span style="font-weight: bold;">)&#9472;(</span><span style="color: #a00; font-weight: bold;">&#10007;</span><span style="font-weight: bold;">)&#9472;(</span><span style="font-weight: bold; color: #5555ff;">02:39 PM Sat Aug 29</span><span style="font-weight: bold;">)</span><br /><span style="font-weight: bold;">&#9492;&#9472;(</span><span style="font-weight: bold; color: #00cc00;">~</span><span style="font-weight: bold;">)&#9472;(</span><span style="font-weight: bold; color: #00cc00;">4 files, 332Kb</span><span style="font-weight: bold;">)&#9472;&gt;</span> echo 'Hello world!'<br />Hello world!<br /><br /><span style="font-weight: bold;">&#9484;(</span><span style="font-weight: bold; color: #5555ff;">andy@alba</span><span style="font-weight: bold;">)&#9472;(</span><span style="color: #0a0; font-weight: bold;">&#10003;</span><span style="font-weight: bold;">)&#9472;(</span><span style="font-weight: bold; color: #5555ff;">02:39 PM Sat Aug 29</span><span style="font-weight: bold;">)</span><br /><span style="font-weight: bold;">&#9492;&#9472;(</span><span style="font-weight: bold; color: #00cc00;">~</span><span style="font-weight: bold;">)&#9472;(</span><span style="font-weight: bold; color: #00cc00;">4 files, 332Kb</span><span style="font-weight: bold;">)&#9472;&gt;</span> false<br /><br /><span style="font-weight: bold;">&#9484;(</span><span style="font-weight: bold; color: #5555ff;">andy@alba</span><span style="font-weight: bold;">)&#9472;(</span><span style="color: #a00; font-weight: bold;">&#10007;</span><span style="font-weight: bold;">)&#9472;(</span><span style="font-weight: bold; color: #5555ff;">02:39 PM Sat Aug 29</span><span style="font-weight: bold;">)</span><br /><span style="font-weight: bold;">&#9492;&#9472;(</span><span style="font-weight: bold; color: #00cc00;">~</span><span style="font-weight: bold;">)&#9472;(</span><span style="font-weight: bold; color: #00cc00;">4 files, 332Kb</span><span style="font-weight: bold;">)&#9472;&gt;</span> su<br />Password: <br />Two can Live as Cheaply as One for Half as Long.<br /> &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;-- Howard Kandel<br /><br /><span style="font-weight: bold;">&#9484;(</span><span style="font-weight: bold; color: #aa0000;">alba</span><span style="font-weight: bold;">)&#9472;(</span><span style="color: #0a0; font-weight: bold;">&#10003;</span><span style="font-weight: bold;">)&#9472;(</span><span style="font-weight: bold; color: #5555ff;">02:39 PM Sat Aug 29</span><span style="font-weight: bold;">)</span><br /><span style="font-weight: bold;">&#9492;&#9472;(</span><span style="font-weight: bold; color: #00cc00;">/home/andy</span><span style="font-weight: bold;">)&#9472;(</span><span style="font-weight: bold; color: #00cc00;">4 files, 332Kb</span><span style="font-weight: bold;">)&#9472;&gt;</span> <span style="text-decoration: blink;">_</span></div><br />
<br />
Here is the {{ic|PS1}} variable for this effect to be applyied to [[Color_Bash_Prompt#.2Fetc.2Fbash.bashrc|our]] {{ic|/etc/bash.bashrc}} file (see [[Color_Bash_Prompt#Variations_on_a_theme|above]]):<br />
<br />
{{bc|<nowiki> # http://maketecheasier.com/8-useful-and-interesting-bash-prompts/2009/09/04<br />
PS1="\n\[\033[1;37m\]\342\224\214($(if [[ ${EUID} == 0 ]]; then echo '\[\033[01;31m\]\h'; else echo '\[\033[01;34m\]\u@\h'; fi)\[\033[1;37m\])\342\224\200(\$(if [[ \$? == 0 ]]; then echo \"\[\033[01;32m\]\342\234\223\"; else echo \"\[\033[01;31m\]\342\234\227\"; fi)\[\033[1;37m\])\342\224\200(\[\033[1;34m\]\@ \d\[\033[1;37m\])\[\033[1;37m\]\n\342\224\224\342\224\200(\[\033[1;32m\]\w\[\033[1;37m\])\342\224\200(\[\033[1;32m\]\$(ls -1 | wc -l | sed 's: ::g') files, \$(ls -lah | grep -m 1 total | sed 's/total //')b\[\033[1;37m\])\342\224\200&gt; \[\033[0m\]"</nowiki>}}<br />
<br />
====Version #3: with unicode error status symbol (non-zero only)====<br />
<br />
<div style="font-family: monospace; margin: 1em 3em; padding: 1em; border: 3px solid #bcd; background-color: black; color: #fff; font-size: 14px; line-height: 17px;">I am two with nature.<br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;-- Woody Allen<br /><br /><span style="font-weight: bold;">&#9484;(</span><span style="font-weight: bold; color: #5555ff;">andy@alba</span><span style="font-weight: bold;">)&#9472;(</span><span style="font-weight: bold; color: #5555ff;">02:38 PM Sat Aug 29</span><span style="font-weight: bold;">)</span><br /><span style="font-weight: bold;">&#9492;&#9472;(</span><span style="font-weight: bold; color: #00cc00;">~</span><span style="font-weight: bold;">)&#9472;(</span><span style="font-weight: bold; color: #00cc00;">4 files, 332Kb</span><span style="font-weight: bold;">)&#9472;&gt;</span> ls<br /><span style="color: #55f; font-weight: bold;">Desktop Documents Music</span> myScript.js<br /><br /><span style="font-weight: bold;">&#9484;(</span><span style="font-weight: bold; color: #5555ff;">andy@alba</span><span style="font-weight: bold;">)&#9472;(</span><span style="font-weight: bold; color: #5555ff;">02:38 PM Sat Aug 29</span><span style="font-weight: bold;">)</span><br /><span style="font-weight: bold;">&#9492;&#9472;(</span><span style="font-weight: bold; color: #00cc00;">~</span><span style="font-weight: bold;">)&#9472;(</span><span style="font-weight: bold; color: #00cc00;">4 files, 332Kb</span><span style="font-weight: bold;">)&#9472;&gt;</span> I\ will\ try\ to\ type\ a\ wrong\ command...<br />bash: I will try to type a wrong command...: command not found<br /><br /><span style="font-weight: bold;">&#9484;(</span><span style="font-weight: bold; color: #5555ff;">andy@alba</span><span style="font-weight: bold;">)&#9472;(</span><span style="color: #a00; font-weight: bold;">&#10007;</span><span style="font-weight: bold;">)&#9472;(</span><span style="font-weight: bold; color: #5555ff;">02:39 PM Sat Aug 29</span><span style="font-weight: bold;">)</span><br /><span style="font-weight: bold;">&#9492;&#9472;(</span><span style="font-weight: bold; color: #00cc00;">~</span><span style="font-weight: bold;">)&#9472;(</span><span style="font-weight: bold; color: #00cc00;">4 files, 332Kb</span><span style="font-weight: bold;">)&#9472;&gt;</span> echo 'Hello world!'<br />Hello world!<br /><br /><span style="font-weight: bold;">&#9484;(</span><span style="font-weight: bold; color: #5555ff;">andy@alba</span><span style="font-weight: bold;">)&#9472;(</span><span style="font-weight: bold; color: #5555ff;">02:39 PM Sat Aug 29</span><span style="font-weight: bold;">)</span><br /><span style="font-weight: bold;">&#9492;&#9472;(</span><span style="font-weight: bold; color: #00cc00;">~</span><span style="font-weight: bold;">)&#9472;(</span><span style="font-weight: bold; color: #00cc00;">4 files, 332Kb</span><span style="font-weight: bold;">)&#9472;&gt;</span> false<br /><br /><span style="font-weight: bold;">&#9484;(</span><span style="font-weight: bold; color: #5555ff;">andy@alba</span><span style="font-weight: bold;">)&#9472;(</span><span style="color: #a00; font-weight: bold;">&#10007;</span><span style="font-weight: bold;">)&#9472;(</span><span style="font-weight: bold; color: #5555ff;">02:39 PM Sat Aug 29</span><span style="font-weight: bold;">)</span><br /><span style="font-weight: bold;">&#9492;&#9472;(</span><span style="font-weight: bold; color: #00cc00;">~</span><span style="font-weight: bold;">)&#9472;(</span><span style="font-weight: bold; color: #00cc00;">4 files, 332Kb</span><span style="font-weight: bold;">)&#9472;&gt;</span> su<br />Password: <br />Two can Live as Cheaply as One for Half as Long.<br /> &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;-- Howard Kandel<br /><br /><span style="font-weight: bold;">&#9484;(</span><span style="font-weight: bold; color: #aa0000;">alba</span><span style="font-weight: bold;">)&#9472;(</span><span style="font-weight: bold; color: #5555ff;">02:39 PM Sat Aug 29</span><span style="font-weight: bold;">)</span><br /><span style="font-weight: bold;">&#9492;&#9472;(</span><span style="font-weight: bold; color: #00cc00;">/home/andy</span><span style="font-weight: bold;">)&#9472;(</span><span style="font-weight: bold; color: #00cc00;">4 files, 332Kb</span><span style="font-weight: bold;">)&#9472;&gt;</span> <span style="text-decoration: blink;">_</span></div><br />
<br />
Here is the {{ic|PS1}} variable for this effect to be applyied to [[Color_Bash_Prompt#.2Fetc.2Fbash.bashrc|our]] {{ic|/etc/bash.bashrc}} file (see [[Color_Bash_Prompt#Variations_on_a_theme|above]]):<br />
<br />
{{bc|<nowiki> # http://maketecheasier.com/8-useful-and-interesting-bash-prompts/2009/09/04<br />
PS1="\n\[\033[1;37m\]\342\224\214($(if [[ ${EUID} == 0 ]]; then echo '\[\033[01;31m\]\h'; else echo '\[\033[01;34m\]\u@\h'; fi)\[\033[1;37m\])\$([[ \$? != 0 ]] &amp;&amp; echo \"\342\224\200(\[\033[0;31m\]\342\234\227\[\033[1;37m\])\")\342\224\200(\[\033[1;34m\]\@ \d\[\033[1;37m\])\[\033[1;37m\]\n\342\224\224\342\224\200(\[\033[1;32m\]\w\[\033[1;37m\])\342\224\200(\[\033[1;32m\]\$(ls -1 | wc -l | sed 's: ::g') files, \$(ls -sh | head -n1 | sed 's/total //')b\[\033[1;37m\])\342\224\200&gt; \[\033[0m\]"</nowiki>}}<br />
<br />
==Restoring the original /etc/bash.bashrc file==<br />
<br />
If you repent having modified the {{ic|/etc/bash.bashrc}} file, you can always restore the original Arch {{ic|/etc/bash.bashrc}} file from the [[ bash ]] package and remove the {{ic|/etc/DIR_COLORS}} file. Note that there is not an "official" bash.bashrc: each distribution has its own.<br />
<br />
==Original /etc/bash.bashrc from Gentoo==<br />
<br />
The original ''not modified'' Gentoo's {{ic|/etc/bash.bashrc}} file can be found [http://www.jeremysands.com/archlinux/gentoo-bashrc-2008.0 here].<br />
<br />
=Colors overview=<br />
The page at http://ascii-table.com/ansi-escape-sequences.php describes the various available color escapes. The following Bash function (put it in your .bashrc!) displays a table with ready-to-copy escape codes.<br />
<br />
{{bc|<nowiki><br />
colors() {<br />
local fgc bgc vals seq0<br />
<br />
printf "Color escapes are %s\n" '\e[${value};...;${value}m'<br />
printf "Values 30..37 are \e[33mforeground colors\e[m\n"<br />
printf "Values 40..47 are \e[43mbackground colors\e[m\n"<br />
printf "Value 1 gives a \e[1mbold-faced look\e[m\n\n"<br />
<br />
# foreground colors<br />
for fgc in {30..37}; do<br />
# background colors<br />
for bgc in {40..47}; do<br />
fgc=${fgc#37} # white<br />
bgc=${bgc#40} # black<br />
<br />
vals="${fgc:+$fgc;}${bgc}"<br />
vals=${vals%%;}<br />
<br />
seq0="${vals:+\e[${vals}m}"<br />
printf " %-9s" "${seq0:-(default)}"<br />
printf " ${seq0}TEXT\e[m"<br />
printf " \e[${vals:+${vals+$vals;}}1mBOLD\e[m"<br />
done<br />
echo; echo<br />
done<br />
}<br />
</nowiki>}}<br />
<br />
=Step by step=<br />
<br />
If you want to create a style all your own, you can take a look at these tips. [https://bbs.archlinux.org/viewtopic.php?id=50885 This Forum thread] could give you more informations and examples.<br />
<br />
==Basic prompts==<br />
<br />
The following settings are useful for distinguishing the root prompt from non-root users.<br />
<br />
*Edit Bash's personal configuration file:<br />
{{bc|<nowiki>$ nano ~/.bashrc</nowiki>}}<br />
<br />
*Comment out the default prompt:<br />
{{bc|<nowiki># PS1='[\u@\h \W]\$ '</nowiki>}}<br />
<br />
*Add the following green prompt for regular users:<br />
<div style="font-family: monospace; white-space: pre; margin: 1em 3em; padding: 1em; border: 3px solid #bcd; background-color: black; color: #aaa;"><span style="color: #0f0">[chiri@zetsubou ~]$</span> <span style="text-decoration: blink;">_</span></div><br />
{{bc|<nowiki>PS1='\[\e[1;32m\][\u@\h \W]\$\[\e[0m\] '</nowiki>}}<br />
<br />
*Edit root's .bashrc file; copy it from /etc/skel if the file is not present:<br />
{{bc|<nowiki>$ nano /root/.bashrc</nowiki>}}<br />
*Assign a red prompt for root:<br />
<br />
<div style="font-family: monospace; white-space: pre; margin: 1em 3em; padding: 1em; border: 3px solid #bcd; background-color: black; color: #aaa;"><span style="color: #f00">[root@zetsubou ~]#</span> <span style="text-decoration: blink;">_</span></div><br />
{{bc|<nowiki>PS1='\[\e[1;31m\][\u@\h \W]\$\[\e[0m\] '</nowiki>}}<br />
<br />
===Slightly fancier prompts===<br />
<br />
*A green and blue prompt for regular users:<br />
<div style="font-family: monospace; white-space: pre; margin: 1em 3em; padding: 1em; border: 3px solid #bcd; background-color: black; color: #aaa;"><span style="color: #0a0">chiri</span> <span style="color: #00f">~/docs</span> <span style="color: #0f0">$</span> echo "sample output text"<br />sample output text<br /><span style="color: #0a0">chiri</span> <span style="color: #00f">~/docs</span> <span style="color: #0f0">$</span> <span style="text-decoration: blink;">_</span></div><br />
{{bc|<nowiki>PS1='\[\e[0;32m\]\u\[\e[m\] \[\e[1;34m\]\w\[\e[m\] \[\e[1;32m\]\$\[\e[m\] \[\e[1;37m\]'</nowiki>}}<br />
<br />
This will give a very pleasing, colorful prompt and theme for the console with bright white text.<br />
<br />
The string above contains color-set escape sequences (start coloring: \[\e[color\], end coloring: \[\e[m\]) and information placeholders:<br />
<br />
* \u - Username. The original prompt also has \h, which prints the host name.<br />
* \w - Current absolute path. Use \W for current relative path.<br />
* \$ - The prompt character (eg. '#' for root, '$' for regular users). <br />
<br />
The last color-set sequence, "\[\e[1;37m\]", is not closed, so the remaining text (everything typed into the terminal, program output and so on) will be in that (bright white) color. It may be desirable to change this color, or to delete the last escape sequence in order to leave the actual output in unaltered color. <br />
<br />
*A red and blue prompt for root:<br />
<div style="font-family: monospace; white-space: pre; margin: 1em 3em; padding: 1em; border: 3px solid #bcd; background-color: black; color: #aaa;"><span style="color: #a00">root</span> <span style="color: #00f">~/docs</span> <span style="color: #a00">#</span> <span style="color: #0a0">echo "sample output text"<br />sample output text<br /></span><span style="color: #a00">root</span> <span style="color: #00f">~/docs</span> <span style="color: #a00">#</span> <span style="color: #0a0"><span style="text-decoration: blink;">_</span></span></div><br />
{{bc|<nowiki>PS1='\[\e[0;31m\]\u\[\e[m\] \[\e[1;34m\]\w\[\e[m\] \[\e[0;31m\]\$ \[\e[m\]\[\e[0;32m\]'</nowiki>}}<br />
<br />
This will give you a red designation and green console text.<br />
<br />
Once you have made your changes to .bashrc, to execute your changes:<br />
<br />
{{bc|<nowiki>$ source ~/.bashrc</nowiki>}}<br />
<br />
==Advanced prompts==<br />
<br />
===Load/Mem Status for 256colors===<br />
This is not even pushing the limits. Other than using 'sed' to parse the memory and load average (using the ''-u'' option for non-buffering), and the builtin ''history'' to save your history to your ''HISTFILE'' after every command, which you may find incredibly useful when dealing with crashing shells or subshells, this is essentially just making BASH print variables it already knows, making this extremely fast compared to prompts with non-builtin commands.<br />
<br />
This prompt is from AskApache.com's [http://www.askapache.com/linux-unix/bash-power-prompt.html BASH Power Prompt article], which goes into greater detail. It is especially helpful for those wanting to understand 256 color terminals, ncurses, termcap, and terminfo.<br />
<br />
This is for '''256 color terminals''', which is where the '''\033[38;5;22m''' terminal escapes come from. <br />
{{bc|1=<br />
<span style="color:#0b0">802</span><span style="color:#005f00">/1024MB</span> <span style="color:#5f00af">1.28 1.20 1.13 3/94 18563</span><br />
<span style="color:#555">[5416:17880 0:70]</span> <span style="color:0bb">05:35:50 Wed Apr 21</span> <span style="color:#555">[</span><span style="color:#2b47ff">srot@host.sqpt.net</span><span style="color:#555">:</span><span style="color:#bbb">/dev/pts/0</span> <span style="color:#00bb00">+1</span><span style="color:#555">]</span> <span style="color:#000">~<br /><br />
(1:70)$ <span style="text-decoration: blink;">_</span></span><br />
}}<br />
<br />
{{bc|<nowiki>PROMPT_COMMAND='history -a;echo -en "\033[m\033[38;5;2m"$(( $(sed -nu "s/MemFree:[\t ]\+\([0-9]\+\) kB/\1/p" /proc/meminfo)/1024))"\033[38;5;22m/"$(($(sed -nu "s/MemTotal:[\t ]\+\([0-9]\+\) kB/\1/Ip" /proc/meminfo)/1024 ))MB"\t\033[m\033[38;5;55m$(&lt; /proc/loadavg)\033[m"'<br />
PS1='\[\e[m\n\e[1;30m\][$$:$PPID \j:\!\[\e[1;30m\]]\[\e[0;36m\] \T \d \[\e[1;30m\][\[\e[1;34m\]\u@\H\[\e[1;30m\]:\[\e[0;37m\]${SSH_TTY} \[\e[0;32m\]+${SHLVL}\[\e[1;30m\]] \[\e[1;37m\]\w\[\e[0;37m\] \n($SHLVL:\!)\$ '</nowiki>}}<br />
<br />
===List of colors for prompt and Bash===<br />
<br />
Add this to your Bash file(s) to define colors for prompt and commands:<br />
{{bc|<nowiki>txtblk='\e[0;30m' # Black - Regular<br />
txtred='\e[0;31m' # Red<br />
txtgrn='\e[0;32m' # Green<br />
txtylw='\e[0;33m' # Yellow<br />
txtblu='\e[0;34m' # Blue<br />
txtpur='\e[0;35m' # Purple<br />
txtcyn='\e[0;36m' # Cyan<br />
txtwht='\e[0;37m' # White<br />
bldblk='\e[1;30m' # Black - Bold<br />
bldred='\e[1;31m' # Red<br />
bldgrn='\e[1;32m' # Green<br />
bldylw='\e[1;33m' # Yellow<br />
bldblu='\e[1;34m' # Blue<br />
bldpur='\e[1;35m' # Purple<br />
bldcyn='\e[1;36m' # Cyan<br />
bldwht='\e[1;37m' # White<br />
unkblk='\e[4;30m' # Black - Underline<br />
undred='\e[4;31m' # Red<br />
undgrn='\e[4;32m' # Green<br />
undylw='\e[4;33m' # Yellow<br />
undblu='\e[4;34m' # Blue<br />
undpur='\e[4;35m' # Purple<br />
undcyn='\e[4;36m' # Cyan<br />
undwht='\e[4;37m' # White<br />
bakblk='\e[40m' # Black - Background<br />
bakred='\e[41m' # Red<br />
bakgrn='\e[42m' # Green<br />
bakylw='\e[43m' # Yellow<br />
bakblu='\e[44m' # Blue<br />
bakpur='\e[45m' # Purple<br />
bakcyn='\e[46m' # Cyan<br />
bakwht='\e[47m' # White<br />
txtrst='\e[0m' # Text Reset</nowiki>}}<br />
<br />
Or if you prefer color names you will know how to spell without a special decoder ring and want high intensity colors:<br />
{{bc|<nowiki># Reset<br />
Color_Off='\e[0m' # Text Reset<br />
<br />
# Regular Colors<br />
Black='\e[0;30m' # Black<br />
Red='\e[0;31m' # Red<br />
Green='\e[0;32m' # Green<br />
Yellow='\e[0;33m' # Yellow<br />
Blue='\e[0;34m' # Blue<br />
Purple='\e[0;35m' # Purple<br />
Cyan='\e[0;36m' # Cyan<br />
White='\e[0;37m' # White<br />
<br />
# Bold<br />
BBlack='\e[1;30m' # Black<br />
BRed='\e[1;31m' # Red<br />
BGreen='\e[1;32m' # Green<br />
BYellow='\e[1;33m' # Yellow<br />
BBlue='\e[1;34m' # Blue<br />
BPurple='\e[1;35m' # Purple<br />
BCyan='\e[1;36m' # Cyan<br />
BWhite='\e[1;37m' # White<br />
<br />
# Underline<br />
UBlack='\e[4;30m' # Black<br />
URed='\e[4;31m' # Red<br />
UGreen='\e[4;32m' # Green<br />
UYellow='\e[4;33m' # Yellow<br />
UBlue='\e[4;34m' # Blue<br />
UPurple='\e[4;35m' # Purple<br />
UCyan='\e[4;36m' # Cyan<br />
UWhite='\e[4;37m' # White<br />
<br />
# Background<br />
On_Black='\e[40m' # Black<br />
On_Red='\e[41m' # Red<br />
On_Green='\e[42m' # Green<br />
On_Yellow='\e[43m' # Yellow<br />
On_Blue='\e[44m' # Blue<br />
On_Purple='\e[45m' # Purple<br />
On_Cyan='\e[46m' # Cyan<br />
On_White='\e[47m' # White<br />
<br />
# High Intensity<br />
IBlack='\e[0;90m' # Black<br />
IRed='\e[0;91m' # Red<br />
IGreen='\e[0;92m' # Green<br />
IYellow='\e[0;93m' # Yellow<br />
IBlue='\e[0;94m' # Blue<br />
IPurple='\e[0;95m' # Purple<br />
ICyan='\e[0;96m' # Cyan<br />
IWhite='\e[0;97m' # White<br />
<br />
# Bold High Intensity<br />
BIBlack='\e[1;90m' # Black<br />
BIRed='\e[1;91m' # Red<br />
BIGreen='\e[1;92m' # Green<br />
BIYellow='\e[1;93m' # Yellow<br />
BIBlue='\e[1;94m' # Blue<br />
BIPurple='\e[1;95m' # Purple<br />
BICyan='\e[1;96m' # Cyan<br />
BIWhite='\e[1;97m' # White<br />
<br />
# High Intensity backgrounds<br />
On_IBlack='\e[0;100m' # Black<br />
On_IRed='\e[0;101m' # Red<br />
On_IGreen='\e[0;102m' # Green<br />
On_IYellow='\e[0;103m' # Yellow<br />
On_IBlue='\e[0;104m' # Blue<br />
On_IPurple='\e[0;105m' # Purple<br />
On_ICyan='\e[0;106m' # Cyan<br />
On_IWhite='\e[0;107m' # White<br />
</nowiki>}}<br />
<br />
To use in commands from your shell environment:<br />
<br />
<div style="font-family: monospace; margin: 1em 3em; padding: 1em; border: 3px solid #bcd; background-color: black; color: #fff;">$ echo -e "${txtblu}test"<br /><span style="color: blue;">test</span><br />$ echo -e "${bldblu}test"<br /><span style="color: lightblue;"><strong>test</strong></span><br />$ echo -e "${undblu}test"<br /><span style="color: lightblue;"><strong><span style="text-decoration: underline;">test</span></strong></span><br />$ echo -e "${bakblu}test"<br /><span style="color: white; background-color: lightblue;"><strong>test</strong></span><br />$ <span style="text-decoration: blink;">_</span></div><br />
<br />
To use in a prompt (note double quotes to enable $color variable expansion and <nowiki>\[ \]</nowiki> escapes around them so they are not counted as character positions and the cursor position is not wrong):<br />
<br />
{{bc|<nowiki>PS1="\[$txtblu\]foo\[$txtred\] bar\[$txtrst\] baz : "</nowiki>}}<br />
<br />
If you experience premature line wrapping when entering commands at the prompt then missing escapes is most likely to be the reason.<br />
<br />
=== Prompt escapes ===<br />
<br />
The various Bash prompt escapes listed in the manpage:<br />
<br />
{{bc|1=Bash allows these prompt strings to be customized by inserting a<br />
number of ''backslash-escaped special characters'' that are<br />
decoded as follows:<br />
<br />
\a an ASCII bell character (07)<br />
\d the date in "Weekday Month Date" format (e.g., "Tue May 26")<br />
\D{format} the format is passed to strftime(3) and the result<br />
is inserted into the prompt string an empty format<br />
results in a locale-specific time representation.<br />
The braces are required<br />
\e an ASCII escape character (033)<br />
\h the hostname up to the first `.'<br />
\H the hostname<br />
\j the number of jobs currently managed by the shell<br />
\l the basename of the shell's terminal device name<br />
\n newline<br />
\r carriage return<br />
\s the name of the shell, the basename of $0 (the portion following<br />
the final slash)<br />
\t the current time in 24-hour HH:MM:SS format<br />
\T the current time in 12-hour HH:MM:SS format<br />
\@ the current time in 12-hour am/pm format<br />
\A the current time in 24-hour HH:MM format<br />
\u the username of the current user<br />
\v the version of bash (e.g., 2.00)<br />
\V the release of bash, version + patch level (e.g., 2.00.0)<br />
\w the current working directory, with $HOME abbreviated with a tilde<br />
\W the basename of the current working directory, with $HOME<br />
abbreviated with a tilde<br />
\! the history number of this command<br />
\# the command number of this command<br />
\$ if the effective UID is 0, a #, otherwise a $<br />
\nnn the character corresponding to the octal number nnn<br />
\\ a backslash<br />
\[ begin a sequence of non-printing characters, which could be used<br />
to embed a terminal control sequence into the prompt<br />
\] end a sequence of non-printing characters<br />
<br />
The command number and the history number are usually different:<br />
the history number of a command is its position in the history<br />
list, which may include commands restored from the history file<br />
(see HISTORY below), while the command number is the position in<br />
the sequence of commands executed during the current shell session.<br />
After the string is decoded, it is expanded via parameter<br />
expansion, command substitution, arithmetic expansion, and quote<br />
removal, subject to the value of the promptvars shell option (see<br />
the description of the shopt command under SHELL BUILTIN COMMANDS<br />
below).<br />
}}<br />
<br />
=== Positioning the cursor ===<br />
<br />
{{Accuracy|The last example don't work (at least on Bash). Seems to have a problem in '''\[\033[1;\$((COLUMNS-4))f\]'''}}<br />
<br />
The following sequence sets the cursor position:<br />
<br />
{{bc|<nowiki>\[\033[<row>;<column>f\]</nowiki>}}<br />
<br />
The current cursor position can be saved using:<br />
<br />
{{bc|<nowiki>\[\033[s\]</nowiki>}}<br />
<br />
To restore a position, use the following sequence: <br />
<br />
{{bc|<nowiki>\[\033[u\]</nowiki>}}<br />
<br />
The following example uses these sequences to display the time in the upper right corner:<br />
<br />
{{bc|<nowiki>PS1="&gt;\[\033[s\]\[\033[1;\$((COLUMNS-4))f\]\$(date +%H:%M)\[\033[u\]"</nowiki>}}<br />
<br />
The environment variable ''COLUMNS'' contains the number of columns of the terminal. The above example substracts 4 from its value in order to justify the five character wide output of ''date'' at the right border.<br />
<br />
===Return value visualisation===<br />
<br />
Use this prompt if you want to see the return value of the last executed command.<br />
<br />
{{bc|<nowiki>#return value visualisation<br />
PS1="\$? \$(if [[ \$? == 0 ]]; then echo \"\[\033[0;32m\];)\"; else echo \"\[\033[0;31m\];(\"; fi)\[\033[00m\] : "</nowiki>}}<br />
<br />
This will give you basic prompt:<br />
<div style="font-family: monospace; margin: 1em 3em; padding: 1em; border: 3px solid #bcd; background-color: black; color: #fff;">0 <span style="color: green;">;)</span>&nbsp;: true<br />0 <span style="color: green;">;)</span>&nbsp;: false<br />1 <span style="color: red;">;(</span>&nbsp;:</div><br />
<br />
Zero is a green smiley (replace it with anything you want) and non-zero is a red one. So your prompt will smile if the last operation was successful.<br />
<br />
But you will probably want to use the return value in your own prompt, like this:<br />
<br />
<div style="font-family: monospace; margin: 1em 3em; padding: 1em; border: 3px solid #bcd; background-color: black; color: #fff;"><span style="font-weight: bold;">0</span> <span style="color: #0a0; font-weight: bold;">;) andy@alba</span> <span style="color: #55f; font-weight: bold;">~ $</span> true<br /><span style="font-weight: bold;">0</span> <span style="color: #0a0; font-weight: bold;">;) andy@alba</span> <span style="color: #55f; font-weight: bold;">~ $</span> false<br /><span style="font-weight: bold;">1</span> <span style="color: #a00; font-weight: bold;">;(</span> <span style="color: #0a0; font-weight: bold;">andy@alba</span> <span style="color: #55f; font-weight: bold;">~ $</span> <span style="text-decoration: blink;">_</span></div><br />
<br />
with a code like this one:<br />
<br />
{{bc|<nowiki>#return value visualisation<br />
PS1="\[\033[01;37m\]\$? \$(if [[ \$? == 0 ]]; then echo \"\[\033[01;32m\];)\"; else echo \"\[\033[01;31m\];(\"; fi) $(if [[ ${EUID} == 0 ]]; then echo '\[\033[01;31m\]\h'; else echo '\[\033[01;32m\]\u@\h'; fi)\[\033[01;34m\] \w \$\[\033[00m\] "</nowiki>}}<br />
<br />
Or, if you want, you can build your prompt using the <span style="color: #0a0; font-weight: bold;">&#10003;</span> unicode symbol for a ''zero'' status and the <span style="color: #a00; font-weight: bold;">&#10007;</span> unicode symbol for a ''nonzero'' status:<br />
<br />
<div style="font-family: monospace; margin: 1em 3em; padding: 1em; border: 3px solid #bcd; background-color: black; color: #fff;"><span style="font-weight: bold;">0</span> <span style="color: #0a0; font-weight: bold;">&#10003; andy@alba</span> <span style="color: #55f; font-weight: bold;">~ $</span> true<br /><span style="font-weight: bold;">0</span> <span style="color: #0a0; font-weight: bold;">&#10003; andy@alba</span> <span style="color: #55f; font-weight: bold;">~ $</span> false<br /><span style="font-weight: bold;">1</span> <span style="color: #a00; font-weight: bold;">&#10007;</span> <span style="color: #0a0; font-weight: bold;">andy@alba</span> <span style="color: #55f; font-weight: bold;">~ $</span> I\ will\ try\ to\ type\ a\ wrong\ command...<br />bash: I will try to type a wrong command...: command not found<br /><span style="font-weight: bold;">127</span> <span style="color: #a00; font-weight: bold;">&#10007;</span> <span style="color: #0a0; font-weight: bold;">andy@alba</span> <span style="color: #55f; font-weight: bold;">~ $</span> <span style="text-decoration: blink;">_</span></div><br />
<br />
starting from a code like this other one:<br />
<br />
{{bc|<nowiki>#return value visualisation<br />
PS1="\[\033[01;37m\]\$? \$(if [[ \$? == 0 ]]; then echo \"\[\033[01;32m\]\342\234\223\"; else echo \"\[\033[01;31m\]\342\234\227\"; fi) $(if [[ ${EUID} == 0 ]]; then echo '\[\033[01;31m\]\h'; else echo '\[\033[01;32m\]\u@\h'; fi)\[\033[01;34m\] \w \$\[\033[00m\] "</nowiki>}}<br />
<br />
Here's an alternative that only include the error status if it is nonzero:<br />
{{bc|<nowiki><br />
PROMPT_COMMAND='es=$?; [[ $es -eq 0 ]] &amp;&amp; unset error || error=$(echo -e "\e[1;41m $es \e[40m")'<br />
PS1="${error} ${PS1}"</nowiki>}}<br />
<br />
===Wolfman's===<br />
<br />
After reading through most of the [http://www.tldp.org/HOWTO/Bash-Prompt-HOWTO/index.html Bash Prompt Howto], the author developed a color bash prompt that displays the last 25 characters of the current working directory. This prompt should work well on terminals with a black background. The following code goes in file {{ic|~/.bashrc}}.<br />
<br />
*Add the bash_prompt_command function. If you have a couple directories with long names or start entering a lot of subdirectories, this function will keep the command prompt from wrapping around the screen by displaying at most the last pwdmaxlen characters from the PWD. This code was taken from the ''Bash Prompt Howto''<nowiki>'s</nowiki> section on [http://www.tldp.org/HOWTO/Bash-Prompt-HOWTO/x783.html Controlling the Size and Appearance of $PWD] and modified to replace the user's home directory with a tilde.<br />
<br />
{{bc|<nowiki>##################################################<br />
# Fancy PWD display function<br />
##################################################<br />
# The home directory (HOME) is replaced with a ~<br />
# The last pwdmaxlen characters of the PWD are displayed<br />
# Leading partial directory names are striped off<br />
# /home/me/stuff -&gt; ~/stuff if USER=me<br />
# /usr/share/big_dir_name -&gt; ../share/big_dir_name if pwdmaxlen=20<br />
##################################################<br />
<br />
bash_prompt_command() {<br />
# How many characters of the $PWD should be kept<br />
local pwdmaxlen=25<br />
# Indicate that there has been dir truncation<br />
local trunc_symbol=".."<br />
local dir=${PWD##*/}<br />
pwdmaxlen=$(( ( pwdmaxlen &lt; ${#dir} ) ? ${#dir} : pwdmaxlen ))<br />
NEW_PWD=${PWD/#$HOME/\~}<br />
local pwdoffset=$(( ${#NEW_PWD} - pwdmaxlen ))<br />
if [ ${pwdoffset} -gt "0" ]<br />
then<br />
NEW_PWD=${NEW_PWD:$pwdoffset:$pwdmaxlen}<br />
NEW_PWD=${trunc_symbol}/${NEW_PWD#*/}<br />
fi<br />
}</nowiki>}}<br />
<br />
*The next fragment generates the command prompt and various colors are defined. The user's color for the username, hostname, and prompt ($ or #) is set to cyan, and if the user is root (root's UID is always 0), set the color to red. The command prompt is set to a colored version of Arch's default with the NEW_PWD from the last function.<br />
<br />
:Also, make sure that your color variables are enclosed in double and not single quote marks. Using single quote marks seems to give Bash problems with line wrapping correctly.<br />
<br />
{{bc|<nowiki>bash_prompt() {<br />
case $TERM in<br />
xterm*|rxvt*)<br />
local TITLEBAR='\[\033]0;\u:${NEW_PWD}\007\]'<br />
;;<br />
*)<br />
local TITLEBAR=""<br />
;;<br />
esac<br />
local NONE="\[\033[0m\]" # unsets color to term's fg color<br />
<br />
# regular colors<br />
local K="\[\033[0;30m\]" # black<br />
local R="\[\033[0;31m\]" # red<br />
local G="\[\033[0;32m\]" # green<br />
local Y="\[\033[0;33m\]" # yellow<br />
local B="\[\033[0;34m\]" # blue<br />
local M="\[\033[0;35m\]" # magenta<br />
local C="\[\033[0;36m\]" # cyan<br />
local W="\[\033[0;37m\]" # white<br />
<br />
# emphasized (bolded) colors<br />
local EMK="\[\033[1;30m\]"<br />
local EMR="\[\033[1;31m\]"<br />
local EMG="\[\033[1;32m\]"<br />
local EMY="\[\033[1;33m\]"<br />
local EMB="\[\033[1;34m\]"<br />
local EMM="\[\033[1;35m\]"<br />
local EMC="\[\033[1;36m\]"<br />
local EMW="\[\033[1;37m\]"<br />
<br />
# background colors<br />
local BGK="\[\033[40m\]"<br />
local BGR="\[\033[41m\]"<br />
local BGG="\[\033[42m\]"<br />
local BGY="\[\033[43m\]"<br />
local BGB="\[\033[44m\]"<br />
local BGM="\[\033[45m\]"<br />
local BGC="\[\033[46m\]"<br />
local BGW="\[\033[47m\]"<br />
<br />
local UC=$W # user's color<br />
[ $UID -eq "0" ] &amp;&amp; UC=$R # root's color<br />
<br />
PS1="$TITLEBAR ${EMK}[${UC}\u${EMK}@${UC}\h ${EMB}\${NEW_PWD}${EMK}]${UC}\\$ ${NONE}"<br />
# without colors: PS1="[\u@\h \${NEW_PWD}]\\$ "<br />
# extra backslash in front of \$ to make bash colorize the prompt<br />
}</nowiki>}}<br />
<br />
*Finally, append this code. This ensures that the NEW_PWD variable will be updated when you cd somewhere else, and it sets the PS1 variable, which contains the command prompt.<br />
<br />
{{bc|<nowiki>PROMPT_COMMAND=bash_prompt_command<br />
bash_prompt<br />
unset bash_prompt</nowiki>}}<br />
<br />
===KitchM's===<br />
These prompts offer a little more flash and visual clarity. Note that the use of red in the root user's prompt should provide ample warning. That is not to say someone could not use flashing text or arrow to do even more, but these will give you a good starting point.<br />
<br />
'''First''', change the default background in your terminal preferences (this example uses Xfce's Terminal program) to #D2D2D2, and the text color to #000000. The font is listed as DejaVu Sans Mono Book 12. The cursor color is #00AA00, and the tab activity color is #AF0000.<br />
<br />
'''Second''', in ~/.bashrc and right after the PS1= line, enter a new line with the following:<br />
{{bc|<nowiki>PS1='\e[1;33;47m\u \e[1;32;47mon \h \e[1;35;47m\d \@\e[0;0m\n\e[1;34m[dir.= \w] \# &gt; \e[0;0m'</nowiki>}}<br />
And then place a # in front of the first PS1 line to remark it out.<br />
<br />
'''Third''', for root user, edit /root/.bashrc in the same manner to include:<br />
{{bc|<nowiki>PS1='\e[1;31;47m\u \e[1;32;47mon \h \e[1;35;47m\d \@\e[0;0m\n\e[1;31m[dir.= \w] \# &gt; \e[0;0m'</nowiki>}}<br />
Do not forget to comment out the old line.<br />
<br />
These are double-line prompts, and they should look something like these:<br />
<br />
:'''user'''<br />
<br />
<div style="font-family: monospace; margin: 1em 3em; padding: 1em; border: 3px solid #bbccdd; font-weight: bold; color: #0000ff; background-color: #d2d2d2;"><span style="color: #ff0000; background: #A9A9A9;">Root</span><span style="color: #00ff00; background: #A9A9A9;"> on myhost</span><span style="color: #ff00ff; background: #A9A9A9;"> Sun Jan 15 12:30 PM</span><br />[dir.= /etc/rc.d] 1 &gt;</div><br />
<br />
:'''root'''<br />
<br />
<div style="font-family: monospace; margin: 1em 3em; padding: 1em; border: 3px solid #bbccdd; font-weight: bold; color: #ff0000; background-color: #d2d2d2;"><span style="color: #ff0000; background: #A9A9A9;">Root</span><span style="color: #00ff00; background: #A9A9A9;"> on myhost</span><span style="color: #ff00ff; background: #A9A9A9;"> Sun Jan 15 12:30 PM</span><br />[dir.= /etc/rc.d] 1 &gt;</div><br />
<br />
You will note that the background colors make them easier to read, and the text colors just keep things interesting. There is a lot of leeway to make them personalized, just with the use of colors. Enjoy!<br />
<br />
==Set window title==<br />
<br />
[[Xterm]] and many other terminal emulators (including PuTTY) allow you to set the window title using special escape sequences. You can define the {{ic|<nowiki>${XTERM_TITLE}</nowiki>}} variable as follows, then insert it at the beginning of the prompt to set [[xterm]] title (if available) to directory@user@hostname:<br />
<br />
{{bc|<nowiki>#set xterm title<br />
case "$TERM" in<br />
xterm | xterm-color)<br />
XTERM_TITLE='\[\e]0;\W@\u@\H\a\]'<br />
;;<br />
esac</nowiki>}}<br />
<br />
The text between {{ic|0;}} and {{ic|\a}} can be set to anything you like, for example:<br />
<br />
{{bc|<nowiki>export PS1="\[\e]0;Welcome to ArchLinux\a\]\$&gt;&gt; "</nowiki>}}<br />
<br />
sets the window title to "Welcome to ArchLinux" and displays this simple prompt: <br />
<br />
<div style="font-family: monospace; margin: 1em 3em; padding: 1em; border: 3px solid #bcd; background-color: black; color: #fff;">$&gt;&gt; <span style="text-decoration: blink;">_</span></div><br />
<br />
==Different colors for text entry and console output==<br />
<br />
If you do not reset the text color at the end of your prompt, both the text you enter and the console text will simply stay in that color. If you want to edit text in a special color but still use the default color for command output, you will need to reset the color after you press enter, but still before any commands get run. You can do this by installing a DEBUG trap in your ~/.bashrc, like this:<br />
<br />
{{bc|<nowiki>trap 'echo -ne "\e[0m"' DEBUG</nowiki>}}<br />
<br />
==Laptop battery status on prompt==<br />
<br />
Read [http://www.basicallytech.com/blog/index.php?/archives/110-Colour-coded-battery-charge-level-and-status-in-your-bash-prompt.html this article] and [https://bbs.archlinux.org/viewtopic.php?pid=1156660#p1156660 this post] for details.<br />
<br />
==See also==<br />
<br />
* {{AUR|gentoo-bashrc}} from [[AUR]]<br />
* tput(1)<br />
* [http://tldp.org/HOWTO/Bash-Prompt-HOWTO/x405.html Colours and Cursor Movement With tput]<br />
<br />
==External links==<br />
<br />
* Forum Discussions:<br />
** [https://bbs.archlinux.org/viewtopic.php?id=1817 BASH prompt]<br />
** [https://bbs.archlinux.org/viewtopic.php?id=50885 What's your PS1?]<br />
* [http://xcolors.net/ Nice Xresources color schemes collection]<br />
* [http://www.tldp.org/HOWTO/Bash-Prompt-HOWTO/x329.html Bash Prompt HOWTO]<br />
* [http://gilesorr.com/bashprompt/prompts/index.html Giles Orr's collection of sample prompts]<br />
* [http://misc.flogisoft.com/bash/tip_colors_and_formatting Bash tips: Colors and formatting]</div>Max-khttps://wiki.archlinux.org/index.php?title=GRUB&diff=92909GRUB2010-01-21T02:33:17Z<p>Max-k: /* Background image and bitmap fonts */</p>
<hr />
<div>[[Category:Boot process (English)]]<br />
[[Category:HOWTOs (English)]]<br />
{{Article summary start}}<br />
{{Article summary text|Covers various aspects of the next generation of the GRand Unified Bootloader (GRUB2).}}<br />
{{Article summary heading|Available in languages}}<br />
{{i18n_entry|English|GRUB2}}<br />
{{i18n_entry|Česky|GRUB2 (Česky)}}<br />
{{i18n_entry|Español|GRUB2 (Español)}}<br />
{{i18n_entry|Français|GRUB2 (Français)}}<br />
{{i18n_entry|Italiano|GRUB2 (Italiano)}}<br />
{{i18n_entry|Русский|GRUB2 (Русский)}}<br />
{{Article summary heading|Related articles}}<br />
{{Article summary wiki|GRUB}}<br />
{{Article summary heading|External links}}<br />
{{Article summary link|GNU GRUB -- GNU Project|http://www.gnu.org/software/grub/}}<br />
{{Article summary link|GNU GRUB Wiki|http://grub.enbug.org/}}<br />
{{Article summary end}}<br />
<br />
[http://www.gnu.org/software/grub/grub-2.en.html GRUB2] is the next generation of the GRand Uniform Bootloader (GRUB). GRUB2 is derived from [http://www.nongnu.org/pupa/ PUPA] which was a research project to investigate the next generation of GRUB. GRUB 2 has been rewritten from scratch to clean up everything and provide modularity and portability.<br />
<br />
Briefly, the ''bootloader'' is the first software program that runs when a computer starts. It is responsible for loading and transferring control to the Linux kernel. The kernel, in turn, initializes the rest of the operating system.<br />
<br />
Currently, [[GRUB]] (i.e. version 0.9x) is the de facto standard bootloader of Linux, and is expected to be superseded by GRUB2 in the near future. When this happens, "GRUB" will become "GRUB Legacy".<br />
<br />
== Preface ==<br />
<br />
GRUB2 is still under development and therefore caution should be observed. '''Consider yourself warned!''' GRUB2 may not behave as expected, features may be missing, and functionality may change. Without any specific reason to use GRUB2, users should consider installing the more stable [[GRUB]] instead.<br />
<br />
=== Notes for current GRUB users ===<br />
<br />
* There are differences in the commads of GRUB and GRUB2. Familiarize yourself with [http://grub.enbug.org/CommandList GRUB2 commands] before proceeding (e.g. "find" has been replaced with "search").<br />
<br />
* GRUB2 is now ''modular'' and no longer requires "stage 1.5". As a result, the bootloader itself is limited -- modules are loaded from the hard drive as needed to expand functionality (e.g. for [[LVM]] or RAID support).<br />
<br />
* Device naming has changed between GRUB and GRUB2. Partitions are numbered from 1 instead of 0 while drives are still numbered from 0. For example, {{Filename|/dev/sda1}} would be referred to as {{Codeline|(hd0,1)}} using GRUB2.<br />
<br />
== Installation ==<br />
<br />
The GRUB2 package can be installed with pacman (and will replace {{Package Official|grub}}, if it is installed):<br />
# pacman -S grub2<br />
<br />
Additionally, GRUB2 must be installed to the boot sector of a drive or partition to serve as a bootloader. This is covered in the [[#Bootloader installation]] section.<br />
<br />
=== Installing GRUB2 during Arch Linux installation ===<br />
<br />
* Ensure the network is properly configured.<br />
* Skip the '''Install Bootloader''' step and exit the installer. <br />
* From the installer's live shell, chroot to the installed system:<br />
# mount -o bind /dev /mnt/dev<br />
# chroot /mnt bash<br />
* Install the GRUB2 package:<br />
# pacman -S grub2<br />
<br />
=== Bootloader Installation ===<br />
<br />
GRUB2 may be installed from a live environment, or directly from a running Arch install.<br />
<br />
In most cases, installing GRUB2 would is as easy as running the '''grub-install''' command as root:<br />
# grub-install /dev/sda<br />
<br />
where {{Filename|/dev/sda}} is the destination of the installation (in this case the MBR of the first SATA disk). If you use [[LVM]] for your {{Filename|/boot}}, you can install GRUB2 on multiple physical disks.<br />
<br />
If this fails with the error:<br />
<br />
grub-probe: error: Cannot get the real path of '/dev/fd0'<br />
Auto-detection of a filesystem module failed.<br />
Please specify the module with the option '--modules' explicitly.<br />
<br />
Try adding {{Codeline|--recheck}} to the arguments as follows:<br />
# grub-install --recheck /dev/sda<br />
<br />
== Configuration ==<br />
<br />
The configuration file is located at {{Filename|/boot/grub/grub.cfg}}. Edit this file to suit your needs.<br />
<br />
=== grub-mkconfig ===<br />
<br />
The grub-mkconfig script can be used to generate a {{Filename|grub.cfg}} file. By default the script outputs to stdout. to generate a {{Filename|grub.cfg}} file run the command<br />
# grub-mkconfig -o /boot/grub/grub.cfg<br />
<br />
=== grub.cfg ===<br />
<br />
A basic grub file uses the following options<br />
* {{Codeline|(hdX,Y)}} is the partition {{Codeline|Y}} on disk {{Codeline|X}}, partition numbers starting at 1, disk numbers starting at 0<br />
* {{Codeline|1=set default=N}} is the default boot entry that is chosen after timeout for user action<br />
* {{Codeline|1=set timeout=M}} is the time {{Codeline|M}} to wait in seconds for a user selection before default is booted<br />
* {{Codeline|<nowiki>menuentry "title" {entry options}</nowiki>}} is a boot entry titled {{Codeline|title}}<br />
* {{Codeline|1=set root=(hdX,Y)}} sets the boot partition, where the kernel and GRUB modules are stored (boot need not be a separate partition, and may simply be a directory under the "root" partition ({{Filename|/}})<br />
<br />
An example configuration:<br />
<br />
{{File<br />
|name=/boot/grub/grub.cfg<br />
|content=<nowiki><br />
# Config file for GRUB2 - The GNU GRand Unified Bootloader<br />
# /boot/grub/grub.cfg<br />
<br />
# DEVICE NAME CONVERSIONS<br />
#<br />
# Linux Grub<br />
# -------------------------<br />
# /dev/fd0 (fd0)<br />
# /dev/sda (hd0)<br />
# /dev/sdb2 (hd1,2)<br />
# /dev/sda3 (hd0,3)<br />
#<br />
<br />
# Timeout for menu<br />
set timeout=5<br />
<br />
# Set default boot entry as Entry 0<br />
set default=0<br />
<br />
# (0) Arch Linux<br />
menuentry "Arch Linux" {<br />
set root=(hd0,1)<br />
linux /vmlinuz26 root=/dev/sda3 ro<br />
initrd /kernel26.img<br />
}<br />
<br />
## (1) Windows<br />
#menuentry "Windows" {<br />
#set root=(hd0,3)<br />
#chainloader +1<br />
#}<br />
</nowiki>}}<br />
<br />
If you do not have a separate boot partition, {{Codeline|/boot}} must prefix entries in {{Filename|grub.cfg}}. Example:<br />
<br />
# (0) Arch Linux<br />
menuentry "Arch Linux" {<br />
set root=(hd0,1)<br />
linux /boot/vmlinuz26 root=/dev/sda1 ro<br />
initrd /boot/kernel26.img<br />
}<br />
<br />
=== Dual-booting ===<br />
<br />
These are the two most common ways of configuring the {{Filename|grub.cfg}} file. For more complex uses, feel free to add descriptions here.<br />
<br />
==== With GNU/Linux ====<br />
<br />
Assuming that the other distro is on partition {{Filename|sda2}}:<br />
<br />
menuentry "Other Linux" {<br />
set root=(hd0,2)<br />
linux /boot/vmlinuz (add other options here as required)<br />
initrd /boot/initrd.img (if the other kernel uses/needs one)<br />
}<br />
<br />
==== With Windows ====<br />
<br />
Add this at the end of your {{Filename|/boot/grub/grub.cfg}}. This assumes that your Windows partition is {{Filename|sda3}}.<br />
<br />
# (2) Windows XP<br />
menuentry "Windows XP" {<br />
set root=(hd0,3)<br />
chainloader +1<br />
}<br />
<br />
==== With Windows via EasyBCD and NeoGRUB ====<br />
<br />
Since EasyBCD's NeoGRUB currently does not understand the GRUB2 menu format, chainload to it by replacing the contents of your {{Filename|C:\NST\menu.lst}} file with lines similar to the following:<br />
<br />
default 0<br />
timeout 1<br />
<br />
title Chainload into GRUB v2<br />
root (hd0,7)<br />
kernel /boot/grub/core.img<br />
<br />
===Visual Configuration===<br />
<br />
In GRUB2 it is possible, by default to change the look of the menu.<br />
<br />
====Background image and bitmap fonts====<br />
<br />
GRUB2 comes with support for background images and bitmap fonts in pf2 format. The unifont font is included in the grub2 package under the filename {{Filename|unicode.pf2}}, or, as only ascii characters under the name {{Filename|ascii.pf2}}. Image formats supported include tga, png and jpeg, providing the correct modules are loaded. The maximum supported resolution depends on your hardware. A configuration sample setting a tga file as background is shown below.<br />
<br />
if loadfont /usr/share/grub/unicode.pf2 ; then<br />
set gfxmode="1024x768x32"<br />
insmod gfxterm<br />
insmod vbe<br />
terminal_output gfxterm<br />
if terminal_output gfxterm; then true ; else<br />
terminal gfxterm<br />
fi<br />
fi<br />
insmod tga<br />
background_image /boot/grub/archlinux.tga<br />
<br />
{{Note|If this example doesn't work for you. Try to replace {{Codeline|1=gfxmode="1024x768x32"}} by {{Codeline|1=vbemode="0x105"}}.}}<br />
{{Note|To show all the modes you can use. Try the the {{Codeline|1=vbeinfo}} command at grub2 prompt (you need to load the vbe module before).}}<br />
<br />
====Menu colors====<br />
<br />
To change the colors in GRUB2 you would specify one option in {{Filename|/boot/grub/grub.cfg}}. An example showing the default colors for Arch's release of GRUB-legacy.<br />
<br />
set menu_color_normal=light-blue/black<br />
set menu_color_highlight=light-cyan/blue<br />
<br />
The available colors for GRUB2 are at http://www.gnu.org/software/grub/manual/html_node/color.html.<br />
<br />
====Hidden menu====<br />
<br />
For hiding menu put that code in grub.cfg after picture initialization but before ''menuentries'' (e.g. background_image /boot/grub/archlinux.tga).<br />
<br />
set timeout=5<br />
<br />
echo -n "Press ESC to see the menu... "<br />
if sleep --verbose --interruptible 5 ; then<br />
set timeout=0<br />
fi<br />
<br />
====Setting the framebuffer resolution====<br />
<br />
To change the framebuffer resolution in grub2, add a line similar to this to the ''linux'' line in grub.cfg:<br />
<br />
video=vesafb:mode=1024x768-32 vga=790<br />
<br />
In the preceeding statement, the format mode=<resolution>-<colordepth> vga=<fbresolution> is used where fbresolution follows the following scheme:<br />
<br />
+-------------------------------------------------+<br />
| 640x480 800x600 1024x768 1280x1024<br />
----+--------------------------------------------<br />
256 | 0x301=769 0x303=771 0x305=773 0x307=775<br />
32K | 0x310=784 0x313=787 0x316=790 0x319=793<br />
64K | 0x311=785 0x314=788 0x317=791 0x31A=794<br />
16M | 0x312=786 0x315=789 0x318=792 0x31B=795<br />
+-------------------------------------------------+<br />
<br />
Make sure you add the following somewhere, (insmod statements are usually found at the top of the grub.cfg file):<br />
<br />
insmod vbe<br />
<br />
=== Other Options ===<br />
<br />
==== LVM ====<br />
<br />
If you use [[LVM]] for your {{Filename|/boot}}, add the following before menuentry lines:<br />
<br />
insmod lvm<br />
<br />
and specify your root in the menuentry as:<br />
<br />
set root=(''lvm_group_name''-''lvm_logical_boot_partition_name'')<br />
<br />
Example:<br />
<br />
# (0) Arch Linux<br />
menuentry "Arch Linux" {<br />
insmod lvm<br />
set root=(VolumeGroup-lv_boot)<br />
linux /vmlinuz26 root=/dev/mapper/VolumeGroup-root ro<br />
initrd /kernel26.img<br />
}<br />
<br />
==== Persistent block device naming ====<br />
<br />
To list UUIDs, from a running system:<br />
$ blkid<br />
<br />
Replace the {{Codeline|root}} line with the following:<br />
<br />
linux /vmlinuz26 root=/dev/disk/by-uuid/<UUID> ro<br />
<br />
However, you still have to set Grub2's notion of a root partition. In order to do that, use the {{Codeline|search}} command:<br />
<br />
search --fs-uuid <UUID> --set root<br />
<br />
PAn example boot entry using Persistent block device naming would look like:<br />
<br />
menuentry "Arch Linux" {<br />
search --fs-uuid 355ccb5c-99e1-400d-b612-451f9247e35e --set root<br />
linux /boot/vmlinuz26 root=/dev/disk/by-uuid/355ccb5c-99e1-400d-b612-451f9247e35e ro<br />
initrd /boot/kernel26.img<br />
}<br />
<br />
==== Using Labels ====<br />
<br />
It is possible to use labels, human-readable strings attached to filesystems, by using the {{Codeline|--label}} option to {{Codeline|search}}. First of all, label your existing partition:<br />
<br />
# tune2fs -L a <LABEL> <PARTITION><br />
<br />
Then, add an entry using labels. An example of this:<br />
<br />
menuentry "Arch Linux, session texte" {<br />
search --label archroot --set root<br />
linux /boot/vmlinuz26 root=/dev/disk/by-label/archroot ro<br />
initrd /boot/kernel26.img<br />
}<br />
<br />
== Using the command shell ==<br />
<br />
Since the MBR is too small to store all GRUB2 modules, only the menu and a few basic commands reside there. The majority of GRUB2 functionality remains in modules in {{Filename|/boot/grub}}, which are inserted as needed. In error conditions (e.g. if the partition layout changes) GRUB2 may fail to boot. When this happens, a command shell may appear.<br />
<br />
GRUB2 offers multiple shells/prompts. If there is a problem reading the menu but the bootloader is able to find the disk, you will likely be dropped to the "normal" shell:<br />
<br />
sh:grub><br />
<br />
If there is a more serious problem (e.g. GRUB cannot find required files), you may instead be dropped to the "rescue" shell:<br />
<br />
grub rescue><br />
<br />
The rescue shell is a restricted subset of the normal shell, offering much less functionality. If dumped to the rescue shell, first try inserting the "normal" module, then starting the "normal" shell:<br />
<br />
grub rescue> set prefix=(hdX,Y)/boot/grub<br />
grub rescue> insmod (hdX,Y)/boot/grub/normal.mod<br />
rescue:grub> normal<br />
<br />
{{Box YELLOW|TODO:|Describe how one might use the command shell.}}<br />
<br />
== Using the rescue console ==<br />
<br />
See [[#Using the command shell]] first. If unable to activate the standard shell, one possible solution is to boot using a live CD or some other rescue disk to correct configuration errors and reinstall GRUB. However, such a boot disk is not always available (nor necessary); the rescue console is surprisingly robust.<br />
<br />
The available commands in GRUB rescue include "insmod", "ls", "set", and "unset". This example uses "set" and "insmod". "set" modifies variables and "insmod" inserts new modules to add functionality.<br />
<br />
Before starting, the user must know the location of their {{Filename|/boot}} partition (be it a separate partition, or a subdirectory under their root):<br />
<br />
grub rescue> set prefix=(hdX,Y)/boot/grub<br />
<br />
where X is the physical drive number and Y is the partition number.<br />
<br />
To expand console capabilities, insert the "linux" module:<br />
<br />
grub rescue> insmod (hdX,Y)/boot/grub/linux.mod<br />
<br />
{{Note|With a separate boot partition, omit {{Filename|/boot}} from the path, (i.e. type {{Codeline|1=set prefix=(hdX,Y)/grub}} and {{Codeline|insmod (hdX,Y)/grub/linux.mod}}).}}<br />
<br />
This introduces the "linux" and "initrd" commands, which should be familiar (see [[#Configuration]]).<br />
<br />
An example, booting Arch Linux:<br />
<br />
set root=(hd0,5)<br />
linux /boot/vmlinuz26 root=/dev/sda5<br />
initrd /boot/kernel26.img<br />
boot<br />
<br />
With a separate boot partition, again change the lines accordingly:<br />
<br />
set root=(hd0,5)<br />
linux /vmlinuz26 root=/dev/sda6<br />
initrd /kernel26.img<br />
boot<br />
<br />
After successfully booting the Arch Linux installation, users can correct {{Filename|grub.cfg}} as needed and then run:<br />
<br />
# grub-install /dev/sda<br />
<br />
to reinstall GRUB2 and fix the problem completely, changing {{Filename|/dev/sda}} if needed. See [[#Bootloader installation]] for details.<br />
<br />
== Troubleshooting ==<br />
<br />
Any troubleshooting should be added here.<br />
<br />
=== msdos-style error message ===<br />
<br />
grub-setup: warn: This msdos-style partition label has no post-MBR gap; embedding won't be possible!<br />
grub-setup: warn: Embedding is not possible. GRUB can only be installed in this setup by using blocklists.<br />
However, blocklists are UNRELIABLE and its use is discouraged.<br />
grub-setup: error: If you really want blocklists, use --force.<br />
<br />
This error may occur when you try installing GRUB2 in a VMware container. Read more about it [http://bbs.archlinux.org/viewtopic.php?pid=581760#p581760 here]. Hopefully a fix will be provided soon.<br />
<br />
It also happens when the first partition starts just after the MBR, without the usual space of 60-something block before the first partition.<br />
<br />
=== Grub-install hangs for grub2 / legacy grub ===<br />
Disable the floppy drive in the BIOS, which often shows up even if you don't have one and confuses grub. For good measure, you can also use --no-floppy and erase the fd0 entry from grub's /boot/grub/device.map, however that alone without disabling it in the BIOS may not work.<br />
<br />
=== Other ===<br />
I couldn't figure out how to uninstall grub1, and install grub2 to the MBR, as it isn't being booted by default. It is still booting grub1. So, an easy work-around, is rename {{Filename|menu.lst.pacsave}} or whatever, to {{Filename|menu.lst}} (in /boot/grub/) and for each menu entry that you would like to use grub2, at the end type {{Codeline|"chainloader +1"}}. This will tell grub1 to forward control to grub2. This is an ugly hack though, so I advise setting the {{Filename|menu.lst}}'s timout as 0, otherwise the total timeout would be grub1's time out + grub2's which, for me would equal more than 18 seconds, which is quite a bit.<br />
<br />
P.S. hopefully someone figures out how to pry grub1's dead fingers off of my MBR, and place grub2 on it :) .<br />
<br />
In my case it had to do with my boot partition. Say boot-partition is {{Codeline|(hd0,1)}} and your root is {{Codeline|(hd0,3)}} (grub2 naming). grub-setup searches for {{Filename|(hd0,3)/boot/grub/core.img}}. Just because it's on {{Filename|(hd0,1)/grub/core.img}}, it is unable to find it. So I copied the grub-folder to my root partition and everything worked fine:<br />
<br />
E.g. (as root:)<br />
# mount /boot<br />
# cp -a /boot/grub /<br />
# umount /boot<br />
# mv /grub /boot/<br />
# grub-install /dev/sda</div>Max-khttps://wiki.archlinux.org/index.php?title=GRUB&diff=92908GRUB2010-01-21T02:32:27Z<p>Max-k: /* Background image and bitmap fonts */</p>
<hr />
<div>[[Category:Boot process (English)]]<br />
[[Category:HOWTOs (English)]]<br />
{{Article summary start}}<br />
{{Article summary text|Covers various aspects of the next generation of the GRand Unified Bootloader (GRUB2).}}<br />
{{Article summary heading|Available in languages}}<br />
{{i18n_entry|English|GRUB2}}<br />
{{i18n_entry|Česky|GRUB2 (Česky)}}<br />
{{i18n_entry|Español|GRUB2 (Español)}}<br />
{{i18n_entry|Français|GRUB2 (Français)}}<br />
{{i18n_entry|Italiano|GRUB2 (Italiano)}}<br />
{{i18n_entry|Русский|GRUB2 (Русский)}}<br />
{{Article summary heading|Related articles}}<br />
{{Article summary wiki|GRUB}}<br />
{{Article summary heading|External links}}<br />
{{Article summary link|GNU GRUB -- GNU Project|http://www.gnu.org/software/grub/}}<br />
{{Article summary link|GNU GRUB Wiki|http://grub.enbug.org/}}<br />
{{Article summary end}}<br />
<br />
[http://www.gnu.org/software/grub/grub-2.en.html GRUB2] is the next generation of the GRand Uniform Bootloader (GRUB). GRUB2 is derived from [http://www.nongnu.org/pupa/ PUPA] which was a research project to investigate the next generation of GRUB. GRUB 2 has been rewritten from scratch to clean up everything and provide modularity and portability.<br />
<br />
Briefly, the ''bootloader'' is the first software program that runs when a computer starts. It is responsible for loading and transferring control to the Linux kernel. The kernel, in turn, initializes the rest of the operating system.<br />
<br />
Currently, [[GRUB]] (i.e. version 0.9x) is the de facto standard bootloader of Linux, and is expected to be superseded by GRUB2 in the near future. When this happens, "GRUB" will become "GRUB Legacy".<br />
<br />
== Preface ==<br />
<br />
GRUB2 is still under development and therefore caution should be observed. '''Consider yourself warned!''' GRUB2 may not behave as expected, features may be missing, and functionality may change. Without any specific reason to use GRUB2, users should consider installing the more stable [[GRUB]] instead.<br />
<br />
=== Notes for current GRUB users ===<br />
<br />
* There are differences in the commads of GRUB and GRUB2. Familiarize yourself with [http://grub.enbug.org/CommandList GRUB2 commands] before proceeding (e.g. "find" has been replaced with "search").<br />
<br />
* GRUB2 is now ''modular'' and no longer requires "stage 1.5". As a result, the bootloader itself is limited -- modules are loaded from the hard drive as needed to expand functionality (e.g. for [[LVM]] or RAID support).<br />
<br />
* Device naming has changed between GRUB and GRUB2. Partitions are numbered from 1 instead of 0 while drives are still numbered from 0. For example, {{Filename|/dev/sda1}} would be referred to as {{Codeline|(hd0,1)}} using GRUB2.<br />
<br />
== Installation ==<br />
<br />
The GRUB2 package can be installed with pacman (and will replace {{Package Official|grub}}, if it is installed):<br />
# pacman -S grub2<br />
<br />
Additionally, GRUB2 must be installed to the boot sector of a drive or partition to serve as a bootloader. This is covered in the [[#Bootloader installation]] section.<br />
<br />
=== Installing GRUB2 during Arch Linux installation ===<br />
<br />
* Ensure the network is properly configured.<br />
* Skip the '''Install Bootloader''' step and exit the installer. <br />
* From the installer's live shell, chroot to the installed system:<br />
# mount -o bind /dev /mnt/dev<br />
# chroot /mnt bash<br />
* Install the GRUB2 package:<br />
# pacman -S grub2<br />
<br />
=== Bootloader Installation ===<br />
<br />
GRUB2 may be installed from a live environment, or directly from a running Arch install.<br />
<br />
In most cases, installing GRUB2 would is as easy as running the '''grub-install''' command as root:<br />
# grub-install /dev/sda<br />
<br />
where {{Filename|/dev/sda}} is the destination of the installation (in this case the MBR of the first SATA disk). If you use [[LVM]] for your {{Filename|/boot}}, you can install GRUB2 on multiple physical disks.<br />
<br />
If this fails with the error:<br />
<br />
grub-probe: error: Cannot get the real path of '/dev/fd0'<br />
Auto-detection of a filesystem module failed.<br />
Please specify the module with the option '--modules' explicitly.<br />
<br />
Try adding {{Codeline|--recheck}} to the arguments as follows:<br />
# grub-install --recheck /dev/sda<br />
<br />
== Configuration ==<br />
<br />
The configuration file is located at {{Filename|/boot/grub/grub.cfg}}. Edit this file to suit your needs.<br />
<br />
=== grub-mkconfig ===<br />
<br />
The grub-mkconfig script can be used to generate a {{Filename|grub.cfg}} file. By default the script outputs to stdout. to generate a {{Filename|grub.cfg}} file run the command<br />
# grub-mkconfig -o /boot/grub/grub.cfg<br />
<br />
=== grub.cfg ===<br />
<br />
A basic grub file uses the following options<br />
* {{Codeline|(hdX,Y)}} is the partition {{Codeline|Y}} on disk {{Codeline|X}}, partition numbers starting at 1, disk numbers starting at 0<br />
* {{Codeline|1=set default=N}} is the default boot entry that is chosen after timeout for user action<br />
* {{Codeline|1=set timeout=M}} is the time {{Codeline|M}} to wait in seconds for a user selection before default is booted<br />
* {{Codeline|<nowiki>menuentry "title" {entry options}</nowiki>}} is a boot entry titled {{Codeline|title}}<br />
* {{Codeline|1=set root=(hdX,Y)}} sets the boot partition, where the kernel and GRUB modules are stored (boot need not be a separate partition, and may simply be a directory under the "root" partition ({{Filename|/}})<br />
<br />
An example configuration:<br />
<br />
{{File<br />
|name=/boot/grub/grub.cfg<br />
|content=<nowiki><br />
# Config file for GRUB2 - The GNU GRand Unified Bootloader<br />
# /boot/grub/grub.cfg<br />
<br />
# DEVICE NAME CONVERSIONS<br />
#<br />
# Linux Grub<br />
# -------------------------<br />
# /dev/fd0 (fd0)<br />
# /dev/sda (hd0)<br />
# /dev/sdb2 (hd1,2)<br />
# /dev/sda3 (hd0,3)<br />
#<br />
<br />
# Timeout for menu<br />
set timeout=5<br />
<br />
# Set default boot entry as Entry 0<br />
set default=0<br />
<br />
# (0) Arch Linux<br />
menuentry "Arch Linux" {<br />
set root=(hd0,1)<br />
linux /vmlinuz26 root=/dev/sda3 ro<br />
initrd /kernel26.img<br />
}<br />
<br />
## (1) Windows<br />
#menuentry "Windows" {<br />
#set root=(hd0,3)<br />
#chainloader +1<br />
#}<br />
</nowiki>}}<br />
<br />
If you do not have a separate boot partition, {{Codeline|/boot}} must prefix entries in {{Filename|grub.cfg}}. Example:<br />
<br />
# (0) Arch Linux<br />
menuentry "Arch Linux" {<br />
set root=(hd0,1)<br />
linux /boot/vmlinuz26 root=/dev/sda1 ro<br />
initrd /boot/kernel26.img<br />
}<br />
<br />
=== Dual-booting ===<br />
<br />
These are the two most common ways of configuring the {{Filename|grub.cfg}} file. For more complex uses, feel free to add descriptions here.<br />
<br />
==== With GNU/Linux ====<br />
<br />
Assuming that the other distro is on partition {{Filename|sda2}}:<br />
<br />
menuentry "Other Linux" {<br />
set root=(hd0,2)<br />
linux /boot/vmlinuz (add other options here as required)<br />
initrd /boot/initrd.img (if the other kernel uses/needs one)<br />
}<br />
<br />
==== With Windows ====<br />
<br />
Add this at the end of your {{Filename|/boot/grub/grub.cfg}}. This assumes that your Windows partition is {{Filename|sda3}}.<br />
<br />
# (2) Windows XP<br />
menuentry "Windows XP" {<br />
set root=(hd0,3)<br />
chainloader +1<br />
}<br />
<br />
==== With Windows via EasyBCD and NeoGRUB ====<br />
<br />
Since EasyBCD's NeoGRUB currently does not understand the GRUB2 menu format, chainload to it by replacing the contents of your {{Filename|C:\NST\menu.lst}} file with lines similar to the following:<br />
<br />
default 0<br />
timeout 1<br />
<br />
title Chainload into GRUB v2<br />
root (hd0,7)<br />
kernel /boot/grub/core.img<br />
<br />
===Visual Configuration===<br />
<br />
In GRUB2 it is possible, by default to change the look of the menu.<br />
<br />
====Background image and bitmap fonts====<br />
<br />
GRUB2 comes with support for background images and bitmap fonts in pf2 format. The unifont font is included in the grub2 package under the filename {{Filename|unicode.pf2}}, or, as only ascii characters under the name {{Filename|ascii.pf2}}. Image formats supported include tga, png and jpeg, providing the correct modules are loaded. The maximum supported resolution depends on your hardware. A configuration sample setting a tga file as background is shown below.<br />
<br />
if loadfont /usr/share/grub/unicode.pf2 ; then<br />
set gfxmode="1024x768x32"<br />
insmod gfxterm<br />
insmod vbe<br />
terminal_output gfxterm<br />
if terminal_output gfxterm; then true ; else<br />
terminal gfxterm<br />
fi<br />
fi<br />
insmod tga<br />
background_image /boot/grub/archlinux.tga<br />
<br />
{{Note|If this doesn't work for you. Try to replace {{Codeline|1=gfxmode="1024x768x32"}} by {{Codeline|1=vbemode="0x105"}}.}}<br />
{{Note|To show all the modes you can use. Try the the {{Codeline|1=vbeinfo}} command at grub2 prompt (you need to load the vbe module before).}}<br />
<br />
====Menu colors====<br />
<br />
To change the colors in GRUB2 you would specify one option in {{Filename|/boot/grub/grub.cfg}}. An example showing the default colors for Arch's release of GRUB-legacy.<br />
<br />
set menu_color_normal=light-blue/black<br />
set menu_color_highlight=light-cyan/blue<br />
<br />
The available colors for GRUB2 are at http://www.gnu.org/software/grub/manual/html_node/color.html.<br />
<br />
====Hidden menu====<br />
<br />
For hiding menu put that code in grub.cfg after picture initialization but before ''menuentries'' (e.g. background_image /boot/grub/archlinux.tga).<br />
<br />
set timeout=5<br />
<br />
echo -n "Press ESC to see the menu... "<br />
if sleep --verbose --interruptible 5 ; then<br />
set timeout=0<br />
fi<br />
<br />
====Setting the framebuffer resolution====<br />
<br />
To change the framebuffer resolution in grub2, add a line similar to this to the ''linux'' line in grub.cfg:<br />
<br />
video=vesafb:mode=1024x768-32 vga=790<br />
<br />
In the preceeding statement, the format mode=<resolution>-<colordepth> vga=<fbresolution> is used where fbresolution follows the following scheme:<br />
<br />
+-------------------------------------------------+<br />
| 640x480 800x600 1024x768 1280x1024<br />
----+--------------------------------------------<br />
256 | 0x301=769 0x303=771 0x305=773 0x307=775<br />
32K | 0x310=784 0x313=787 0x316=790 0x319=793<br />
64K | 0x311=785 0x314=788 0x317=791 0x31A=794<br />
16M | 0x312=786 0x315=789 0x318=792 0x31B=795<br />
+-------------------------------------------------+<br />
<br />
Make sure you add the following somewhere, (insmod statements are usually found at the top of the grub.cfg file):<br />
<br />
insmod vbe<br />
<br />
=== Other Options ===<br />
<br />
==== LVM ====<br />
<br />
If you use [[LVM]] for your {{Filename|/boot}}, add the following before menuentry lines:<br />
<br />
insmod lvm<br />
<br />
and specify your root in the menuentry as:<br />
<br />
set root=(''lvm_group_name''-''lvm_logical_boot_partition_name'')<br />
<br />
Example:<br />
<br />
# (0) Arch Linux<br />
menuentry "Arch Linux" {<br />
insmod lvm<br />
set root=(VolumeGroup-lv_boot)<br />
linux /vmlinuz26 root=/dev/mapper/VolumeGroup-root ro<br />
initrd /kernel26.img<br />
}<br />
<br />
==== Persistent block device naming ====<br />
<br />
To list UUIDs, from a running system:<br />
$ blkid<br />
<br />
Replace the {{Codeline|root}} line with the following:<br />
<br />
linux /vmlinuz26 root=/dev/disk/by-uuid/<UUID> ro<br />
<br />
However, you still have to set Grub2's notion of a root partition. In order to do that, use the {{Codeline|search}} command:<br />
<br />
search --fs-uuid <UUID> --set root<br />
<br />
PAn example boot entry using Persistent block device naming would look like:<br />
<br />
menuentry "Arch Linux" {<br />
search --fs-uuid 355ccb5c-99e1-400d-b612-451f9247e35e --set root<br />
linux /boot/vmlinuz26 root=/dev/disk/by-uuid/355ccb5c-99e1-400d-b612-451f9247e35e ro<br />
initrd /boot/kernel26.img<br />
}<br />
<br />
==== Using Labels ====<br />
<br />
It is possible to use labels, human-readable strings attached to filesystems, by using the {{Codeline|--label}} option to {{Codeline|search}}. First of all, label your existing partition:<br />
<br />
# tune2fs -L a <LABEL> <PARTITION><br />
<br />
Then, add an entry using labels. An example of this:<br />
<br />
menuentry "Arch Linux, session texte" {<br />
search --label archroot --set root<br />
linux /boot/vmlinuz26 root=/dev/disk/by-label/archroot ro<br />
initrd /boot/kernel26.img<br />
}<br />
<br />
== Using the command shell ==<br />
<br />
Since the MBR is too small to store all GRUB2 modules, only the menu and a few basic commands reside there. The majority of GRUB2 functionality remains in modules in {{Filename|/boot/grub}}, which are inserted as needed. In error conditions (e.g. if the partition layout changes) GRUB2 may fail to boot. When this happens, a command shell may appear.<br />
<br />
GRUB2 offers multiple shells/prompts. If there is a problem reading the menu but the bootloader is able to find the disk, you will likely be dropped to the "normal" shell:<br />
<br />
sh:grub><br />
<br />
If there is a more serious problem (e.g. GRUB cannot find required files), you may instead be dropped to the "rescue" shell:<br />
<br />
grub rescue><br />
<br />
The rescue shell is a restricted subset of the normal shell, offering much less functionality. If dumped to the rescue shell, first try inserting the "normal" module, then starting the "normal" shell:<br />
<br />
grub rescue> set prefix=(hdX,Y)/boot/grub<br />
grub rescue> insmod (hdX,Y)/boot/grub/normal.mod<br />
rescue:grub> normal<br />
<br />
{{Box YELLOW|TODO:|Describe how one might use the command shell.}}<br />
<br />
== Using the rescue console ==<br />
<br />
See [[#Using the command shell]] first. If unable to activate the standard shell, one possible solution is to boot using a live CD or some other rescue disk to correct configuration errors and reinstall GRUB. However, such a boot disk is not always available (nor necessary); the rescue console is surprisingly robust.<br />
<br />
The available commands in GRUB rescue include "insmod", "ls", "set", and "unset". This example uses "set" and "insmod". "set" modifies variables and "insmod" inserts new modules to add functionality.<br />
<br />
Before starting, the user must know the location of their {{Filename|/boot}} partition (be it a separate partition, or a subdirectory under their root):<br />
<br />
grub rescue> set prefix=(hdX,Y)/boot/grub<br />
<br />
where X is the physical drive number and Y is the partition number.<br />
<br />
To expand console capabilities, insert the "linux" module:<br />
<br />
grub rescue> insmod (hdX,Y)/boot/grub/linux.mod<br />
<br />
{{Note|With a separate boot partition, omit {{Filename|/boot}} from the path, (i.e. type {{Codeline|1=set prefix=(hdX,Y)/grub}} and {{Codeline|insmod (hdX,Y)/grub/linux.mod}}).}}<br />
<br />
This introduces the "linux" and "initrd" commands, which should be familiar (see [[#Configuration]]).<br />
<br />
An example, booting Arch Linux:<br />
<br />
set root=(hd0,5)<br />
linux /boot/vmlinuz26 root=/dev/sda5<br />
initrd /boot/kernel26.img<br />
boot<br />
<br />
With a separate boot partition, again change the lines accordingly:<br />
<br />
set root=(hd0,5)<br />
linux /vmlinuz26 root=/dev/sda6<br />
initrd /kernel26.img<br />
boot<br />
<br />
After successfully booting the Arch Linux installation, users can correct {{Filename|grub.cfg}} as needed and then run:<br />
<br />
# grub-install /dev/sda<br />
<br />
to reinstall GRUB2 and fix the problem completely, changing {{Filename|/dev/sda}} if needed. See [[#Bootloader installation]] for details.<br />
<br />
== Troubleshooting ==<br />
<br />
Any troubleshooting should be added here.<br />
<br />
=== msdos-style error message ===<br />
<br />
grub-setup: warn: This msdos-style partition label has no post-MBR gap; embedding won't be possible!<br />
grub-setup: warn: Embedding is not possible. GRUB can only be installed in this setup by using blocklists.<br />
However, blocklists are UNRELIABLE and its use is discouraged.<br />
grub-setup: error: If you really want blocklists, use --force.<br />
<br />
This error may occur when you try installing GRUB2 in a VMware container. Read more about it [http://bbs.archlinux.org/viewtopic.php?pid=581760#p581760 here]. Hopefully a fix will be provided soon.<br />
<br />
It also happens when the first partition starts just after the MBR, without the usual space of 60-something block before the first partition.<br />
<br />
=== Grub-install hangs for grub2 / legacy grub ===<br />
Disable the floppy drive in the BIOS, which often shows up even if you don't have one and confuses grub. For good measure, you can also use --no-floppy and erase the fd0 entry from grub's /boot/grub/device.map, however that alone without disabling it in the BIOS may not work.<br />
<br />
=== Other ===<br />
I couldn't figure out how to uninstall grub1, and install grub2 to the MBR, as it isn't being booted by default. It is still booting grub1. So, an easy work-around, is rename {{Filename|menu.lst.pacsave}} or whatever, to {{Filename|menu.lst}} (in /boot/grub/) and for each menu entry that you would like to use grub2, at the end type {{Codeline|"chainloader +1"}}. This will tell grub1 to forward control to grub2. This is an ugly hack though, so I advise setting the {{Filename|menu.lst}}'s timout as 0, otherwise the total timeout would be grub1's time out + grub2's which, for me would equal more than 18 seconds, which is quite a bit.<br />
<br />
P.S. hopefully someone figures out how to pry grub1's dead fingers off of my MBR, and place grub2 on it :) .<br />
<br />
In my case it had to do with my boot partition. Say boot-partition is {{Codeline|(hd0,1)}} and your root is {{Codeline|(hd0,3)}} (grub2 naming). grub-setup searches for {{Filename|(hd0,3)/boot/grub/core.img}}. Just because it's on {{Filename|(hd0,1)/grub/core.img}}, it is unable to find it. So I copied the grub-folder to my root partition and everything worked fine:<br />
<br />
E.g. (as root:)<br />
# mount /boot<br />
# cp -a /boot/grub /<br />
# umount /boot<br />
# mv /grub /boot/<br />
# grub-install /dev/sda</div>Max-k