Bash


How to Use Gmail to Send Email with Postfix on Ubuntu

Introduction

In today’s digital age, email has become integral to our personal and professional lives. While numerous email clients are available, Gmail remains a popular choice due to its user-friendly interface and powerful features. In this blog post, we will guide you through configuring Postfix, a famous mail transfer agent (MTA), to send emails using your Gmail account on an Ubuntu system. Let’s dive in!

Prerequisites:

Before we begin, make sure you have the following prerequisites in place:

  1. An Ubuntu system with administrative privileges.
  2. A Gmail account.
  3. A basic understanding of the Linux command line.

Step 1: Install Postfix

  1. Open the terminal on your Ubuntu system.
  2. Update the package lists by running the command:
sudo apt update;

Install Postfix by running the command:

sudo apt install postfix;

During the installation process, you will be prompted to configure Postfix. Select “Internet Site” and press Enter. Provide your system’s mail name when prompted.

Step 2: Configure Postfix to Use Gmail

Open the main Postfix configuration file using a text editor:

sudo nano /etc/postfix/main.cf;

Locate the following lines and modify them as shown below:

relayhost = [smtp.gmail.com]:587
smtp_use_tls = yes
smtp_sasl_auth_enable = yes
smtp_sasl_password_maps = hash:/etc/postfix/sasl_passwd
smtp_sasl_security_options = noanonymous

Save the changes and exit the text editor.

Step 3: Configure Gmail Account Credentials

Create a file to store your Gmail account credentials:

sudo nano /etc/postfix/sasl_passwd;

Add the following line to the file:

[smtp.gmail.com]:587 [email protected]:your_app_password

Note: Replace “[email protected]” with your actual Gmail address and “your_app_password” with the application-specific password you generated for Postfix in your Google Account settings. Save the file and exit the text editor. Secure the credentials file by running the command:

sudo chmod 600 /etc/postfix/sasl_passwd;

Update the Postfix lookup table for the credentials file by running the command:

sudo postmap /etc/postfix/sasl_passwd;

Step 4: Restart Postfix and Test

Restart the Postfix service to apply the changes:

sudo systemctl restart postfix;

Test the email configuration by sending a test email using the following command:

echo "This is a test email." | mail -s "Test Email" [email protected];

Note: Replace “[email protected]” with the email address where you want to send the test email.

Check the recipient’s mailbox to ensure the test email was delivered successfully.

Conclusion

By configuring Postfix to use Gmail on your Ubuntu system, you can harness the power of both platforms to send emails seamlessly. This integration allows you to leverage Gmail’s advanced features while benefiting from Postfix’s reliability and customization options. With the steps outlined in this blog post, you can easily set up the connection and streamline your email communication. Happy emailing!


Mastering Desktop Zoom: A Guide to Keyboard Shortcuts on GNOME

In today’s fast-paced digital world, accessibility features are vital in empowering users with different abilities. One such feature is desktop zoom, which allows users to magnify their screen content for better visibility. GNOME, a popular desktop environment for Linux, offers a convenient way to activate and utilize desktop zoom through keyboard shortcuts. This blog post will explore how to make the most of these shortcuts and enhance your GNOME experience.

Activating Desktop Zoom via the Settings:

To activate desktop zoom on GNOME, follow these steps:

Step 1: Open the GNOME Settings: Click on the “Activities” button in the screen’s top-left corner or press the “Super” key on your keyboard. Then type “Settings” and select the “Settings” application.

Step 2: Navigate to Accessibility Settings: In the GNOME Settings window, select the “Accessibility” category on the left sidebar.

Step 3: Enable Desktop Zoom: Within the Accessibility settings, locate the “Zoom” section. Toggle the switch to the “ON” position to activate desktop zoom.

Using Keyboard Shortcuts for Desktop Zoom:

You can use the following keyboard shortcuts to control and customize your zoom experience:

  1. Toggle Zoom On/Off: Super + Alt + 8 Pressing the Super (Windows) key, Alt key, and the number 8 simultaneously will toggle the zoom functionality on or off.
  2. Zoom In: Super + Alt + plus (+) Pressing the Super key, Alt key, and the plus (+) key simultaneously will zoom in, magnifying the content on your screen.
  3. Zoom Out: Super + Alt + minus (-) Pressing the Super key, Alt key, and the minus (-) key simultaneously will zoom out, reducing the magnification of the screen content.
  4. Zoom Reset: Super + Alt + 0 Pressing the Super key, Alt key, and the number 0 simultaneously will reset the zoom level to its default state.
  5. Pan Around the Screen: Super + Alt + left-click and drag While zoomed in, holding down the Super key, Alt key, and left-clicking the mouse button while dragging will allow you to pan around the zoomed-in screen area.

Customizing Desktop Zoom Options:

If you wish to customize your desktop zoom experience further, you can access additional settings through the GNOME Settings application. Here, you can modify options such as zoom factor, mouse wheel behavior, and more to suit your preferences.

Conclusion:

The keyboard shortcuts provided by GNOME for desktop zoom offer a convenient and efficient way to magnify your screen content. By activating and using these shortcuts, you can enhance your productivity and accessibility within the GNOME desktop environment. Explore additional customization options to tailor the desktop zoom feature to your needs. Embrace the power of keyboard shortcuts and take complete control of your GNOME experience.


Bulk convert PNG images to JPG / JPEG

for i in *.png ; do convert "$i" "${i%.*}.jpg" ; done

The command “for i in .png ; do convert “$i” “${i%.}.jpg” ; done” is a Bash script that converts all PNG files in the current directory to JPEG files.

Let’s break down this command:

  • “for i in *.png ;” is a loop that iterates over each PNG file in the current directory.
  • “$i” is the name of the current PNG file being processed.
  • “convert” is a command-line tool that is part of the ImageMagick software suite. It is used for image conversion, resizing, and manipulation.
  • “${i%.}.jpg” is the new filename that the PNG file will be converted to. The “${i%.}” syntax is used to remove the file extension from the original PNG file name, leaving just the base filename, which is then followed by “.jpg” to indicate that the new file should be a JPEG file.

In summary, this command converts each PNG file in the current directory to a JPEG file with the same base filename. For example, “example.png” would be converted to “example.jpg”. This command can be useful when you have a large number of PNG files that you need to convert to JPEG format quickly and easily.


How to monitor all outgoing requests/connections from your GNU/Linux machine

netstat -nputw;

The “netstat” command is a network utility tool used to display information about active network connections, including the protocol used (TCP or UDP), the local and remote addresses and port numbers, and the current state of the connection.

The options used in this command are as follows:

  • “n” displays addresses and port numbers in numerical form rather than converting them to hostnames and service names.
  • “p” shows the process ID (PID) and program name using the connection.
  • “u” displays UDP connections.
  • “t” displays TCP connections.
  • “w” displays raw sockets.
  • “;” separates the command from other commands that may follow.

Therefore, the command netstat -nputw; will display all current network connections on the machine, including the corresponding processes and raw socket connections, in a numerical format without resolving hostnames and service names.