All posts by Don Matteo

How to Zoom out Firefox bookmarks spacing

Firefox Update enlarges bookmark context menu spacing in the toolbar. Zoom out with userChrome.css

As we can easily see after the Mozilla Firefox Update 92, the bookmark context menu under the toolbar now appears much larger. A comparison to Chrome shows the spacing (padding) between the bookmark items now twice as large.

If you go to the Firefox settings by click the menu button, select under “More tools – Customize toolbar” at the button “Density – Normal” does not really shows a reduction. If you have many bookmarks in a folder, depending on the screen resolution, the menus can sometimes overlapping.

How it’s done

By creating the file userChrome.css the bookmark menu (menuitem) can be adjust using style sheets. Before that, however, Firefox 69 and later must set the default setting on the about:config-page from false to true to enable userChrome.css and userContent.css in the Chrome folder, to do it with past about:config in the firefox address bar and hit enter.

On the page Caution! Click the button accepting the risk.

In the search box in the page, type or paste into “Find setting name”.

toolkit.legacyUserProfileCustomizations.stylesheets

The option for Customize Style Sheets appears, click on the icon on the right to set it to true.

For the style sheet files create a folder “chrome” (if not already available), this under the Firefox profile folder, this profile folder is easy find by opening the Firefox menu button and click Help and select More Troubleshooting Information, then scroll down a bit and click on the Open Folder button at Profile Folder, the profile folder opens in File Explorer. Now create the chrome folder here.

Mozilla Firefox default pofile path to userChrome.css

userChrome.css is a style sheet with special importance to Firefox. The rules in userChrome.css under the profile folder are applied to the user interface, and can override nearly every built-in style rule.

menupopup > menuitem, menupopup > menu {
 padding-block: 2px !important; /*adjust: 0px-4px*/
 min-height: 22px !important; /*adjust: 21px-24px or unset*/
}

*|*:root {--arrowpanel-menuitem-padding: 2px 8px !important;}

Add the CSS code into Notepad Editor and save them with the file name userChrome.css. Copy the file under the Firefox profile folder to the chrome folder. The next time you open Firefox, the bookmarks under the toolbar appear smaller again.

Mozilla Firefox with using Customized userChrome.css

How to Search in Bash History

Using Bash History Reverse Search to find and re-execute command

Bourne-again shell is a free Unix shell under the GPL. Bash remembers the commands you enter and saves them to a history file. It is the default shell for terminal environments of most Linux distributions, on macOS the default shell can be set to Bash, the Bourne-again shell is also available for Windows 10 and can be installed with the WSL features.

BASH the Bourne-again terminal shell on Debian
Bash the Bourne-again shell on Debian

Most will know it, with the arrow up key you can scroll through the bash history to run a previously executed command again.

Reverse Search Bash History for a Command

What many do not know, it can be searched for a certain command in the history, so with Ctrl+R the reverse search can be called, here you enter the characters you remember.

Bash Reverse Search Ctrl+R

By repeatedly pressing Ctrl+R you scroll back step by step, to command lines that match to the search pattern in the history.

  • Ctrl+R: Search Bash History for a Command. Gets the last command that matches the characters you entered.
  • Ctrl+O: Run the found command, after Ctrl+R.
  • Ctrl+G: Exits history search mode without executing a command.

Bash History Common Scenario

A common scenario in which you find yourself is to enter part of a command and then find that you have run it before and could search the history for it.

The correct search method with what is already on the command line is to move the cursor to the beginning of the line with Ctrl+A to call the reverse history with Ctrl+R and to insert the current row into the search with Ctrl+Y and then search backwards again with Ctrl+R

Reviewing Previous Bash History

Each command is associated with a number for easy reference. The list of commands in the Bash history begins with an index number.

$ history

The command with the highest number is the last command executed.

495 vi /etc/bash.bashrc
496 cd /var/www/3w/dot/html/content
497 uname -promsvm
498 vi /etc/sysctl.conf
499 multitail -cS postfix /var/log/mail.log
500 multitail -cS apache /var/log/apache2/access.log
501 multitail -cS syslog /var/log/syslog
502 history

We can truncate the output by specifying a number after the command. For example, if we only want to see the last 5 commands entered, we can type the following.

$ history 5

Other possibilities are, for example, with forward to grep to filter the command history output.

$ history | grep hostname
365 hostname
369 hostnamectl status
484 hostnamectl set-hostname debian
486 cat /etc/hostname
516 history | grep hostname

Run Commands from Bash History

We can recall any of our previous command from history by its number preceded by an exclamation point (!). For instance, if the history looks like the above, we could run hostnamectl status quickly by typing !369.

$ !369
   Static hostname: debian
         Icon name: computer-vm
           Chassis: vm
        Machine ID: fc5cb9d7ace83e1c9c1fcbe4ec76d302
           Boot ID: 379bf41010125c63bbaa4f2b778ac54c
    Virtualization: vmware
  Operating System: Debian GNU/Linux 10 (buster)
            Kernel: Linux 4.19.0-17-amd64
      Architecture: x86-64

This will immediately recall and execute the command associated with the history number 369.

We can also execute commands relative to our current position. We can do this by using the !-n syntax, where n is replaced by the number of commands ago we want to recall.

For instance, if we want to recall and execute a command that we typed before our most recent one, we could type !-5. So we will run again, our session might look like this.

$ !-5
hostname
debian

To re-execute the previous command, bash provides a shortcut that we can use. The shortcut is !! will re-execute the last recent command.

Delete Bash History

The command cleans up the history of the current user session.

$ history -c

Completely clear the saved bash history from the current user.

$ cat /dev/null > ~/.bash_history

The cat command clear the the content in file .bash_history of the currently logged on user.

Conclusion

This should now give a good idea of how the available follow-up operations can be used. Some of these will probably be more useful than others, but it’s good to know that bash has these skills in case you’re in a position where it would be helpful to dig them up.

Last but not least, the history command, the reverse search, and the simple history extensions should help speed up the workflow.

How to Forward Mails to Gmail using Postfix

Send email using Postfix (MTA) Mail Transfer Agent via Gmail Relayhost

Emails sending with Postfix (MTA) Mail Transfer Agent via Gmail relay host. E-mails are delivered via Gmail account, the clients in the local network use Postfix as a local SMTP gateway. This tutorial shows how to do this.

In situations with these, for example, multifunctional devices, or apps that do not support authentication via Mail Submission and STARTTLS (port 587), e-mails can send via local Postfix MTA without the need to log on to a mail server.

If CentOS Linux is used, the required packages are installed as root.

yum update && yum install -y postfix mailx cyrus-sasl cyrus-sasl-plain

On a Debian and Ubuntu, the package installation is as follows.

apt-get update && apt-get install -y postfix mailutils

The Postfix configuration is to be edited by opening the file /etc/postfix/main.cf

mynetworks = 127.0.0.0/8 192.168.1.0/24
myhostname = 12.34.56.78.dynamic.yline.res.cust.isp.net
mydestination = $myhostname, localhost.$mydomain, localhost
inet_interfaces = all
inet_protocols = ipv4
relayhost = [smtp.gmail.com]:587
smtp_use_tls = yes
smtp_sasl_auth_enable = yes
smtp_sasl_security_options =
smtp_sasl_password_maps = hash:/etc/postfix/sasl_passwd
smtp_tls_CAfile = /etc/pki/tls/certs/ca-bundle.crt

Enter the local networks in mynetworks. As myhostname the PTR resource record that can be resolved on the Internet for determining the PTR entry, the following command can be executed in the terminal, as in the following example, or here.

$ curl -s ifconfig.co | xargs host
12.34.56.78.in-addr.arpa domain name pointer 12.34.56.78.dynamic.yline.res.cust.isp.net

Next, a /etc/postfix/sasl_passwd file is created with the following content.

[smtp.gmail.com]:587 mein@gmail.com:password

Instead of mein@gmail.com use your own Gmail account, with password the Google password.

Use postmap to create the file sasl_passwd as Berkeley DB.

postmap /etc/postfix/sasl_passwd

Hint. Run postmap after each change.

Now Postfix is restarted to activate the configuration.

systemctl restart postfix

Test the Postfix configuration with this line in the terminal.

echo "Here is a text." | mail -v -s "Test subject" -r mein@gmail.com andere@domain.com

The mein@gmail.com be the valid Gmail address, and if andere@domain.com, enter a valid recipient email.

Note. This Google Account requires disabled settings under Security – Sign in to Google – go to Security Verification and set two factor Off, and access to the Google Account when accessed by less secure apps must be On.

Postfix logging with syslog in the log file /var/log/maillog in which you can check whether the e-mail was sent and accepted by smtp.gmail.com.

tail -25 /var/log/maillog
mailq

Use mailq to check the queue for any rejected mails.

If you find authentication errors in maillog, the Google Account security settings must be checked.

status=deferred (SASL authentication failed; server smtp.gmail.com[108.177.126.108] said: 534-5.7.9 Application-specific password required. Learn more at?534 5.7.9

Hint. It can happen that after several sending attempts, then rejected (bounced) mails are in the queue, the command mailq gets them, with postsuper -d you remove mails from the queue.

postsuper -d ALL