The pihole command - Pi-hole documentation (2024)

Pi-hole makes use of many commands, and here we will break down those required to administer the program via the command-line Interface.

IndexInvocation
Core Scriptpihole
Web Scriptpihole -a

Pi-hole Core

FeatureInvocation
Corepihole
Whitelisting, Blacklisting and Regexpihole -w, pihole -b, pihole --regex, pihole --wild
Debuggerpihole debug
Log Flushpihole flush
Reconfigurepihole reconfigure
Tailpihole tail
Adminpihole -a
Gravitypihole updateGravity
Loggingpihole logging
Querypihole query
Updatepihole updatePihole
Versionpihole version
Uninstallpihole uninstall
Statuspihole status
pihole enable
Restart DNSpihole restartdns
Checkoutpihole checkout

Core Script

Help Commandpihole --help
Script Location/usr/local/bin/pihole
Example Usagepihole -b advertiser.example.com

The core script of Pi-hole provides the ability to tie many DNS related functions into a simple and user-friendly management system, so that one may easily block unwanted content such as advertisem*nts. For both the Command-line Interface (CLI) and Web Interface, we achieve this through the pihole command (this helps minimize code duplication, and allows users to read exactly what's happening using bash scripting). This "wrapper" elevates the current user (whether it be your own user account, or www-data) using sudo, but restricts the elevation to solely what can be called through the wrapper.

Whitelisting, Blacklisting and Regex

Help Commandpihole -w --help, pihole -b --help, pihole --regex --help, pihole --wild --help
Script Location/opt/pihole/list.sh
Example Usagepihole --regex '^example.com$' '.*\.example2.net'

Administrators need to be able to manually add and remove domains for various purposes, and these commands serve that purpose.

See Regex Blocking for more information about using Regex.

Basic Script Process:

  • Each domain is validated using regex (except when using --regex), to ensure invalid domains and IDNs are not added
  • A domain gets added to or removed from the domainlist table in /etc/pihole/gravity.db
  • The DNS server is then reloaded

Debugger

Help CommandN/A
Script Location/opt/pihole/piholeDebug.sh
Example Usagepihole debug

The Pi-hole debugger will attempt to diagnose any issues, and link to an FAQ with instructions as to how an admin can rectify the issue. Once the debugger has finished, the admin has the option to upload the generated log to the Pi-hole developers, who can help with diagnosing and rectifying persistent issues.

Log Flush

Help CommandN/A
Script Location/opt/pihole/piholeLogFlush.sh
Example Usagepihole flush

When invoked manually, this command will allow you to empty Pi-hole's log, which is located at /var/log/pihole/pihole.log. The command also serves to rotate the log daily, if the logrotate application is installed.

Reconfigure

Help CommandN/A
Script Location/etc/.pihole/automated install/basic-install.sh
Example Usagepihole reconfigure

There are times where the administrator will need to repair or reconfigure the Pi-hole installation, which is performed via this command.

Basic Script Process:

  • basic-install.sh will be run
    • Reconfigure will run through the first-time installation prompts, asking for upstream DNS provider, IP protocols, etc
    • Repair will retain your existing settings and will attempt to repair any scripts or dependencies as necessary
  • The rest of basic-install.sh will then run as appropriate

Tail

Help CommandN/A
Script Location/usr/local/bin/pihole
Example Usagepihole tail

Since Pi-hole will log DNS queries by default, using this command to watch the log in real-time can be useful for debugging a problematic site, or even just for sheer curiosities sake.

Admin

Help Commandpihole -a --help
Script Location/opt/pihole/webpage.sh
Example Usagepihole -a -p secretpassword

Detailed information on this is found here.

Chronometer

Help Commandpihole -c --help
Script Location/opt/pihole/chronometer.sh
Example Usagepihole -c -e

Chronometer is a console dashboard of real-time stats, which can be displayed via ssh or on an LCD screen attached directly to your hardware. The script is capable of detecting the size of your screen and adjusting output to try and best suit it.


Image courtesy of /u/super_nicktendo22

Gravity

Help CommandN/A
Script Location/opt/pihole/gravity.sh
Example Usagepihole -g

Gravity is one of the most important scripts of Pi-hole. Its main purpose is to retrieve blocklists, and then consolidate them into one unique list for the built-in DNS server to use, but it also serves to complete the process of manual whitelisting, blacklisting and wildcard update. It is run automatically each week, but it can be invoked manually at any time.

Basic Script Process:

  • It will determine Internet connectivity, and give time for pihole-FTL to be resolvable on low-end systems if has just been restarted
  • It extracts all URLs and domains from the adlists table in /etc/pihole/gravity.db
  • It runs through each URL, downloading it if necessary
    • curl checks the servers Last-Modified header to ensure it is getting a newer version
  • It will attempt to parse the file into a domains-only format if necessary
  • Lists are merged, comments removed, sorted uniquely and stored in the gravity table of /etc/pihole/gravity.db
  • Gravity cleans up temporary content and reloads the DNS server

Logging

Help Commandpihole logging --help
Script Location/usr/local/bin/pihole
Example Usagepihole logging off

This command specifies whether the Pi-hole log should be used, by commenting out log-queries within /etc/dnsmasq.d/01-pihole.conf and flushing the log.

Query

Help Commandpihole query --help
Script Location/usr/local/bin/pihole
Example Usagepihole -q -exact -adlist example.domain.com

This command will query your whitelist, blacklist, wildcards and adlists for a specified domain.

Basic Script Process:

  • User-specified options are handled
  • Using idn, it will convert Internationalized domain names into punycode
  • Database at /etc/pihole/gravity.db is queried to return a list of adlists in which the queried domain exists.

Update

Help Commandpihole updatePihole
Script Location/opt/pihole/update.sh
Example Usagepihole -up

Check Pi-hole Core, Web Interface and FTL repositories to determine what upgrades (if any) are required. It will then automatically update and reinstall if necessary.

Basic Script Process:

  • Script determines if updates are available by querying GitHub
  • Updated files are downloaded to the local filesystem using git
  • basic-install.sh is run

Version

Help Commandpihole version
Script Location/opt/pihole/version.sh
Example Usagepihole -v -c

Shows installed versions of Pi-hole, Web Interface & FTL. It also provides options to configure which details will be printed, such as the current version, latest version, hash and subsystem.

Uninstall

Help CommandN/A
Script Location/etc/.pihole/automated install/uninstall.sh
Example Usagepihole uninstall

Uninstall Pi-hole from your system, giving the option to remove each dependency individually.

Status

Help CommandN/A
Script Location/usr/local/bin/pihole
Example Usagepihole status

Display the running status of Pi-hole's DNS and blocking services.

Enable & Disable

Help Commandpihole disable --help
Script Location/usr/local/bin/pihole
Example Usagepihole disable 5m

Toggle Pi-hole's ability to block unwanted domains. The disable option has the option to set a specified time before blocking is automatically re-enabled.

Restart DNS

Help CommandN/A
Script Location/usr/local/bin/pihole
Example Usagepihole restartdns

Restart Pi-hole's DNS service.

Checkout

Help Commandpihole checkout --help
Script Location/opt/pihole/piholeCheckout.sh
Example Usagepihole checkout dev

Switch Pi-hole subsystems to a different GitHub branch. An admin can specify repositories as well as branches.

Pi-hole Web

FeatureInvocation
Web Scriptpihole -a
Passwordpihole -a password
Teleportpihole -a -t
Temperature Unitpihole -a celsius, pihole -a fahrenheit, pihole -a kelvin
Interfacepihole -a interface

Web Script

Help Commandpihole -a --help
Script Location/opt/pihole/webpage.sh
Example Usagepihole -a -p secretpassword

Set options for the Web Interface. This script is used to tie in all Web Interface features which are not already covered by the Core Script.

Password

Help CommandN/A
Script Location/opt/pihole/webpage.sh
Example Usagepihole -a -p secretpassword

Set the Web Interface password. Password can be entered as an option (e.g: pihole -a -p secretpassword), or separately as to not display on the screen (e.g: pihole -a -p).

Teleport

Help CommandN/A
Script LocationN/A
Example Usagepihole -a -t

Create a configuration backup. The backup will be created in the directory from which the command is run. The backup can be imported using the Settings > Teleport page.

Temperature Unit

Help CommandN/A
Script Location/opt/pihole/webpage.sh
Example Usagepihole -a -c

Set the specified temperature unit as the preferred type. This preference will affect the Web Interface, as well as Chronometer.

Interface

Help Commandpihole -a interface --help
Script Location/opt/pihole/webpage.sh
Example Usagepihole -a interface local

Specify interface listening behavior for pihole-FTL. When using pihole -a interface all, please ensure you use a firewall to prevent your Pi-hole from becoming an unwitting host to DNS amplification attackers. You may want to consider running Wireguard to grant your mobile devices access to the Pi-hole.

The pihole command - Pi-hole documentation (2024)

FAQs

How to access Pi-hole command line? ›

Pi-hole stats can be accessed via a standard Unix socket ( /run/pihole/FTL. sock ), a telnet-like connection ( TCP socket on port 4711 ) as well as indirectly via the Web API ( admin/api. php ), and the command line ( pihole -c -j ).

What is the Pi-hole diagnosis rate limit? ›

In your case, a client can query Pi-hole no more than a 1000 times per minute (60 seconds). The limitation is a protection to avoid exhausting system resources.

How do I disable Pi-hole rate limiting? ›

Rate-limiting may be disabled altogether by setting RATE_LIMIT=0/0 (this results in the same behavior as before FTL v5.

What is unbound for Pi-hole? ›

Unbound is a private recursive DNS resolver. It can do what Google and the others do, but it is running locally on your LAN (on the Pi-hole host platform in most setups). The only client for your local unbound instance is typically Pi-hole. If you run unbound, you no longer need to use the public recursive resolvers.

How do I connect my Pi-hole to my network? ›

You install Pi-hole on your server (in this case, we're using a Raspberry Pi) and assign it a static IP address. On your router, you set the DNS primary server to the Pi-hole IP address. When a device connects to your home network, it gets the Pi-hole IP address as its main DNS server from your router.

Does Pi-hole speed up internet? ›

Pi hole may make web pages load faster but it is because it is blocking some content from loading. It won't actually speed up you connection, but not allowing ads to load may make your experience feel faster. Yes, Pi Hole will speed up your web browsing by eliminating ads and tracking software.

What is the average percentage blocked on Pi-hole? ›

Expected Behaviour:

Your block rate is primarily dependent on the client using the Pi-hole and your internet habits. 30% is completely reasonable, and is likely to change hourly.

Does Pi-hole increase security? ›

Security: Pi-hole blocks access to known malicious domains, thereby protecting your network from potentially harmful content. Network Performance: With fewer ads and tracking requests, your network's performance can improve, especially if you have multiple devices connected.

What exactly does a Pi-hole do? ›

Pi-hole functions similarly to a network firewall, meaning that advertisem*nts and tracking domains are blocked for all devices behind it, whereas traditional advertisem*nt blockers only run in a user's browser, and remove advertisem*nts only on the same machine.

Can Pi-hole block IP addresses? ›

Neither Pi-hole nor the machine hosting Pi-hole will see any of the associated traffic. If you want to block traffic to a specific IP address, you'd have to configure your firewall accordingly, i.e. on your router or a dedicated firewall device in your network.

What does Pi-hole actually block? ›

Pi-hole blocks ads by acting as a DNS sinkhole. To understand what a DNS sinkhole is, you need to understand what DNS is. Here are a few key terms: Domain Name.

What is the best DNS service for Pi-hole? ›

CloudFlare DNS

CloudFlare will never log your IP address (the way other companies identify you). The independent DNS monitor DNSPerf ranks Cloudflare's DNS the fastest DNS service in the world. Cloudflare also provides 1.1. 1.1 for Families, a set of resolvers that can block malware only, or malware and adult content.

What does FTL stand for Pi-hole? ›

FTL (Faster Than Light)

Daily data are stored in RAM and are captured in real-time within /run/log/pihole/pihole. log.

How to access pi from command line? ›

  1. Open the Raspberry Pi Terminal.
  2. Enter the command: sudo raspi-config.
  3. Use the arrow keys to navigate to Interfacing Options. Press the Enter key.
  4. Go to SSH, and press enter.
  5. When prompted, select <Yes>.
  6. Select Enter to confirm, then click Finish to exit raspi-config.
  7. Close the terminal window.
Aug 1, 2023

How do I access Pi-hole from my computer? ›

There are several ways to access the dashboard: http://<IP_ADDRESS_OF_YOUR_PI_HOLE>/admin/ http://pi.hole/admin/ (when using Pi-hole as your DNS server) http://pi.hole/ (when using Pi-hole as your DNS server)

How do I open API terminal? ›

To open a terminal window, click on the Terminal icon at the top of the screen, or select Accessories and then Terminal in the menu. You should see the following prompt, although the exact prompt will show the username you have chosen.

How to boot pi to command line? ›

Select the first option in the list called “Desktop / CLI”. In the boot option, select the second option, which will force the Pi to boot in command line mode and automatically log in using the default user “pi”. When you select the boot option, you will return to the main menu. At this point, click “Finish”.

References

Top Articles
Latest Posts
Article information

Author: Ouida Strosin DO

Last Updated:

Views: 6322

Rating: 4.6 / 5 (76 voted)

Reviews: 91% of readers found this page helpful

Author information

Name: Ouida Strosin DO

Birthday: 1995-04-27

Address: Suite 927 930 Kilback Radial, Candidaville, TN 87795

Phone: +8561498978366

Job: Legacy Manufacturing Specialist

Hobby: Singing, Mountain biking, Water sports, Water sports, Taxidermy, Polo, Pet

Introduction: My name is Ouida Strosin DO, I am a precious, combative, spotless, modern, spotless, beautiful, precious person who loves writing and wants to share my knowledge and understanding with you.