Ron and Ella Wiki Page

Extremely Serious

Page 21 of 33

Basic Postfix Management

CommandDescription
postqueue -pDisplay the queue
postcat -vq <QUEUE_ID>View the content of the email
postsuper -d ALLRemove all emails
postsuper -d <QUEUE_ID>Remove a particular email
postqueue -i <QUEUE_ID>Attempt to send one particular email
Token Description
QUEUE_ID Can be identified by displaying the queue.

Using Rsync to Sync a Local Directory to Another Local Directory

Syntax

To sync some of your local directories to another local directory, you can use the following syntax:

rsync -av -L --delete <DIR1>[[ <DIR2>] <DIRn>] <DESTINATION_DIR>
Token Description
DIR1, DIR2, DIRn These are the local directories you've wanted to be synced. Only DIR1 is required and the rest are optional.
DESTINATION_DIR The destination directory on the remote machine.

Example

rsync -av -L --delete /var/log/ /data/log/

Useful Environment Variable for Git Troubleshooting

VariableDescriptionPossible Values
GIT_CURL_VERBOSETells Git to emit all the messages generated by that library. This is similar to doing curl -v on the command line.1
GIT_SSL_NO_VERIFYTells Git not to verify SSL certificates.true
GIT_TRACEControls general traces1, 2 or true
GIT_TRACE_PACKETEnables packet-level tracing for network operations.true

Generating SSH Key Pair

  1. Execute the following command:
    ssh-keygen -t ed25519
  2. Distribute the public key using the following syntax:
    ssh-copy-id -i ~/.ssh/id_ed25519.pub <USER>@<HOST>
    Token Description
    USER A valid user on the host computer.
    HOST The host that has an active ssh service.

    If ssh-copy-id command doesn't work, you can directly append the content of the id_ed25519.pub file to the ~/.ssh/authorized_keys file (i.e. create this file if it doesn't exists) of the target <USER> on the target <HOST>.

Creating an Email Alias

Create a new alias for postfix service by updating the following file:

/etc/aliases

Each entry in the file must have the following syntax:

<ALIAS>: <USER1>[[, <USER2>], <USERn>]
Token Description
ALIAS The desired email alias.
USER1, USER2, USERn USER1 is required and the rest are optional. Each user must be delimited by a comma.

The target user of the alias must be a valid user of the system with a home directory.

Example:

postmaster: root

After updating the file, you must execute the following command:

sudo newaliases

Using Embedded Derby in Java 9 with Gradle

  1. Add the following dependencies to your build.gradle file:
    compile group: 'org.apache.derby', name: 'derby', version: '10.15.1.3'
    compile group: 'org.apache.derby', name: 'derbyshared', version: '10.15.1.3'
  2. Add the following entries to your module-info.java file:
    requires org.apache.derby.engine;
    requires org.apache.derby.commons;
    requires java.sql;
    
  3. In your Java class, you can create a connection like the following:
    final String DATABASE_NAME = "sample_table";
    String connectionURL = String.format("jdbc:derby:%s;create=true", DATABASE_NAME);
    connection = DriverManager.getConnection(connectionURL);
    
  4. Do your needed database operations with the connection (e.g. create table, execute a query, or call a stored procedure.).
  5. When your done using the connection, close the connection and shutdown the Derby engine like the following:
    connection.close();
    
    boolean gotSQLExc = false;
    try {
        //shutdown all databases and the Derby engine
        DriverManager.getConnection("jdbc:derby:;shutdown=true");
    } catch (SQLException se)  {
        if ( se.getSQLState().equals("XJ015") ) {
            gotSQLExc = true;
        }
    }
    if (!gotSQLExc) {
        System.out.println("Database did not shut down normally");
    }

    A clean shutdown always throws SQL exception XJ015, which can be ignored.

Using Values as the Record Source for Select Statement

Values can become a valid record source for select statement if the values has table alias and column names as follows:

SELECT dummy_table.* 
FROM (VALUES ('record1'),
	 ('record2'),
	 ('record3'),
	 ('record4'),
	 ('record5'),
	 ('record6'),
	 ('record7'),
	 ('record8'),
	 ('record9')) dummy_table (column1)

From the preceding select statement, the dummy_table is the table alias and the column name is column1.

« Older posts Newer posts »