Pi-Hole – Set the Database Max Days

I keep running out space on my Pi-Hole device. To limit this I invoked the MAXDBDAYS argument in the Pi-Hole FTL configuration.

  • Login into your Pi-Hole device via SSH.
  • At the prompt type or paste the following code to stop the FTL service:
sudo service pihole-FTL stop
  • Next type or paste the following line of code to edit the FTL configuration file
sudo nano /etc/pihole/pihole-FTL.conf
  • In the editor scroll down to the last lime of the document

#; Pi-hole FTL config file
#; Comments should start with #; to avoid issues with PHP and bash reading this file
PRIVACYLEVEL=0
RATE_LIMIT=1000/60
  • Add the following line of code. In this example I have set the number of days to 14. You can updated it to be longer or shorter
MAXDBDAYS=14
  • Save the file and exit the editor.
  • Type or paste the following code to start the FTL service:
sudo service pihole-FTL start

Installing Samba on Ubuntu

Samba is a Local Area Network (LAN) file sharing service for Linux and Unix.

To download the Samba pages need run the following line.

sudo apt-get install libcups2 samba samba-common

After the packages are loaded we need to edit the Samba configuration file. To do that we will use the text editor nano.

nano /etc/samba/smb.conf

In the global section, remove the “#” at the beginning of the line security = user so that it looks like this:

[...]
# "security = user" is always a good idea. This will require a Unix account
# in this server for every user accessing the server. See
# /usr/share/doc/samba-doc/htmldocs/Samba3-HOWTO/ServerType.html
# in the samba-doc package for details.
   security = user
[...]

This enables Linux system users to log in to the Samba server.

Close the file and restart Samba.

Adding Samba Shares

If you have not already determines a share directory you may wish to create generic share for system user accounts.

mkdir -p /home/shares/allusers

Next adjust the owner of directory and all the files and subfolders for the directory share

chown -R root:users /home/shares/allusers/

Now you can set the user permissions for all the files and subfolders for the directory share

chmod -R ug+rwx,o+rx-w /home/shares/allusers/

Now we can edit the Samba configuration file to set up the share.

vi /etc/samba/smb.conf

Add the following lines of code to the end of the smb.conf file

[allusers]
  comment = All Users
  path = /home/shares/allusers
  valid users = @users
  force group = users
  create mask = 0660
  directory mask = 0771
  writable = yes

You may want to also add a line to the configuration to limit which users have permission to write to file

write list = userX

Next restart the Samba service to load you changes.

Managing Users

Setting the user account up

Before adding users to Samba you must add them to the system. Do this by running the useradd command. Then the user name. Followed by -m -G. Lastly the name of the group. In this case users

useradd userX -m -G users

Set the user account password

Now that we have created a user account we need to set a password for said account.

passwd userX userY

Adding the User Account to the Samba User Database

Now we can add the user to the Samba database. You will be prompted to create a password for the Samba account. In most cases you want the system user account password and Samba password to be the same.

smbpasswd -a userX

Connection to a Samba Share

Windows

To connect to a Samba share you will need to open the Windows Explorer program. In the address bar type \\ and the IP address of the machine you are trying to connect to.

\\10.0.0.11

How to save DOS and shell output to a file

This is an old trick that does not get much use these day. But, from time to time I need to run something in DOS or in shell (terminal) and save the output.

For example, say that I need to list a directory out and write into a Word document. I could fight with the the DOS screen copy function in Window. Or with a simple use of “>” I can save the information to a file.

dir > c:\root_directory_list.txt

This should work with just about everything that you can write to the terminal window. And, comes in handy with logging ping, traceroute, nslookups, and netstat.

htop

I was looking for a tool that would allow me to SSH into a server and see what services are running and the performance output. Top does provide good general stats on memory usage and what is running on a Linux server. But, I wanted some real-time visualization on CPU usage. So, I found htop.

htop gives me a way to actively see CPU, RAM, and swap memory in a visual context. Other features allow me to tree out services and programs that are running. Function keys allow me to toggle layout and to quickly exit the program. I can even scroll the complete list of running items.

Installation notes:

sudo apt-get install htop

For more information on htop see https://en.wikipedia.org/wiki/Htop