Let’s say you have a given directory with possible configurations and you want to create a environment file for your laravel app. Within this directory are several .php files containing things like this:


return [

    | Application Name
    | This value is the name of your application. This value is used when the
    | framework needs to place the application's name in a notification or
    | any other location as required by the application or its packages.

    'name' => env('APP_NAME', 'Laravel app'),

    | Application Environment
    | This value determines the "environment" your application is currently
    | running in. This may determine how you prefer to configure various
    | services your application utilizes. Set this in your ".env" file.

    'env' => env('APP_ENV', 'production'),

A proper environment file would look like this:

APP_NAME=Laravel App

We have to grep through all .php files, search for only UPPER_CASE strings and write them into a new file called ‘environment’:

% grep -oP '\b[A-Z_]*[A-Z]+[A-Z_]*\b' *.php

Which is fine if you want to start from scratch or want to build a example file with a lot of comments. As you can see, every line contains the source file. Turn this off with ‘-h’

% grep -h -oP '\b[A-Z_]*[A-Z]+[A-Z_]*\b' *.php

We are going to to move the entire MariaDB or Mysql Server – inclusive all users and databases – to a new Server. We don’t have to struggle with mysqldump, we just need tar and ssh.

At first make sure on both machines is installed the same Server version:

server # mysql --version
mysql  Ver 15.1 Distrib 10.3.10-MariaDB, for Linux (x86_64) using readline 5.1

Stop MariaDB/Mysql on both servers:

systemctl stop mariadb

Tar, compress and copy the mysql directory to the server. Copy as a regular user, because root login ist hopefully disabled:

old-server# tar -zcvf database.tar.gz /var/lib/mysql
old-server# scp database.tar.gz user@new-server/tmp

Extract archive on new server and make sure, owner of the new files is the database user:

new-server# tar -xzf /tmp/database.tar.gz -C /
new-server# chown -R mysql:mysql /var/lib/mysql/

The last thing you have to do, is to delete the old log files:

new-server# rm /var/lib/mysql/ib_logfile*

Thats it. Now restart the database server and you are done.

Install packet kernel-tools witch provide cpupower:

dnf install kernel-tools

Read your current CPU governor:

cat /sys/devices/system/cpu/cpu0/cpufreq/scaling_governor

List available CPU governors:

cpupower frequency-info --governors

Read current CPU frequency:

cpupower frequency-info

Set CPU gorvenor:

cpupower frequency-set --governor powersave

Get random numbers or random words in Linux command line with shuf.

Get a random port number with shuf command:

shuf -n 1 -i 1024-65535

Write it directly into a new variable:

RANDOM_PORT=`shuf -i 1024-65535 -n 1`

Get random word from a word list:

shuf -n 1 /usr/share/dict/words