Useful Linux CLI Commands

crontab -u www-data -e - Edit crontab of user where www-data is the user.

rsync -a /dir1/ /dir2/ - Sync two directories. This overwrites files with the same names.

stat file.txt - Show information about a file or directory

du -sh directory/ - show file or directory size

zip -r directory/ - zip up a directory

unzip - unzip file to current directory

zipinfo - list files and directories in a zip file

grep -i “whatever” file.txt - search for “whatever” in file.txt

!! - run last command

sudo !! - run last command as root

One of the easiest tools to use if you don't know the syntax of a command is TLDR. On Ubuntu you can simply install it using apt, apt install tldr. Simply use tldr zip where zip is the command you wish to know more about.

· 2021/03/26 02:47 · 2021/04/08 21:34

Install Gogs on Ubuntu 20.04 with MariaDB

These instructions will install Gogs on an Ubuntu 20.04 server using the MariaDB back-end. Gogs is a self-hosted front-end to Git. Gogs is extremely lightweight and comes in a single binary file. It also supports multiple back-end databases including PostgreSQL, MySQL, or SQLite3.

These commands assume you are running as root or sudo. All scripts also rely on the install directory being /home/git. Remember to set your own password wherever a password is needed.

Install MariaDB

apt install mariadb-server

Download and extract the latest/desired version of Gogs from

tar xzvf gogs_0.12.3_linux_amd64.tar.gz

Create a systemd service file in /lib/systemd/system/gogs.service

ExecStart=/home/git/gogs/gogs web
Environment=USER=git HOME=/home/git GOGS_WORK_DIR=/home/git

Enable Gogs service

systemctl enable gogs

Start Gogs service

systemctl start gogs

Install nginx

apt install nginx

Log in to MariaDB to create a user and database

mysql -u root -p

Create database


Create user and grant privileges

CREATE USER 'gogs'@'localhost' IDENTIFIED BY 'password';
GRANT ALL PRIVILEGES ON gogs.* TO 'gogs'@'localhost';

Create nginx proxy file. Note that I am using an SSL certificate here. If you do not have your own certificate, you can use certbot.

server {
    listen 80;
    return 301 https://$server_name$request_uri;
server {
    listen 443 ssl;
    ssl_certificate /etc/nginx/ssl/cert.pem;
    ssl_certificate_key /etc/nginx/ssl/key.key;
    location / {
        proxy_set_header X-Real-IP $remote_addr;

Test your nginx configuration file

nginx -t

Restart nginx

systemctl restart nginx

Set the external URL by editing /home/git/custom/conf/app.ini.

Continue the installation using the web interface

· 2021/03/01 05:41 · 2021/04/10 18:34

Useful Commands for Windows Subsystem for Linux

wsl -l -v - check current WSL version in use

wsl -–set-default-version 1 - set default WSL version. Currently 1 or 2.

wsl -–set-version Ubuntu-20.04 2 - convert WSL version to version 2 where Ubuntu-20.04 is the name of the distribution.

· 2020/08/22 01:10 · 2021/03/11 13:36

Upgrade/Install PHP 7.4 in CentOS 8

The good news is this whole process is relatively painless, so here we go.

As always, all the commands assume you have root permissions.

Install the EPEL and remi repositories.

dnf install
dnf install

List the PHP versions you have available

dnf module list php

This should list versions of PHP both in the main repositorys as well as the remi repository. We want to enable remi-7.4.

Reset the php module (if you already have an existing PHP version installed)

dnf module reset php

Install PHP 7.4

dnf module enable php:remi-7.4

Update using dnf

dnf update

PHP 7.4 should now be installed.

Verify PHP version

php -v

· 2020/07/31 14:54 · 2021/03/01 05:13

Set up unattended-upgrades on Ubuntu 20.04

Package upgrades can be set up to install updates on Ubuntu without user intervention.

Install unattended-upgrades

apt install unattended-upgrades

Install mailx

apt install bsd-mailx

This will install also install Postfix. mailx is what unattended upgrades uses to send external mail.

Configure unattended-upgrades

Edit /etc/apt/apt.conf.d/50unattended-upgrades. This file is mostly self explanatory. The options can be enabled by deleting un-commenting the line. At the very least, configure the following:

  • Unattended-Upgrade::Mail “”; to allow sending notifications to your e-mail address.
  • Unattended-Upgrade::Automatic-Reboot “true”; to enable auto-reboots
  • Unattended-Upgrade::Remove-Unused-Kernel-Packages “true”; to remove kernel-related packages. This is usually done using apt autoremove.
  • Unattended-Upgrade::Remove-New-Unused-Dependencies “true”; - remove unneeded dependancies. Also manually done with apt autoremove.
  • Unattended-Upgrade::Remove-Unused-Dependencies “false”; - remove unused packages, also, apt autoremove.

Restart unattended-upgrades

systemctl restart unattended-upgrades

Configure Postfix

Edit /etc/postfix/ Configuration of postfix is outside the scope of this article. For my purposes, I use a relay, so I edit and uncomment relayhost = to point to my relay.

Test mail

mailx -vvv -s "Subject"

Press CTRL D to send the email.

Test your set up

unattended-upgrades --dry-run -–debug
· 2020/07/29 16:38 · 2020/07/30 13:11

<< Newer entries | Older entries >>