Posts

Display Date and Time for each Command in Bash History in Linux

Image
In this tutorial, How to list command display date and time command previously typed in Bash History. The Bash shell provides the command history. Display Date and Time for each Command in Bash History. The default history command $ history The output terminal as below Set time stamps in bash history Define the environment variable name $ HISTTIMEFORMAT="%d/%m/%y %T " The output as below   Or your add ~/.bash_profile file $ echo 'export HISTTIMEFORMAT="%d/%m/%y %T "' >> ~/.bash_profile $ cd $ source ~/.bash_profile The output terminal as below   To retrieve Linux bash command line history $ history  The output terminal as below   Conclusion Displaying the date and time for each command in Linux Linux can be invaluable for monitoring and debugging purposes. By using the HISTTIMEFORMAT variable, you can easily prepend timestamps to your command history, providing a clear record of when each command was executed. This simple yet powerful feature enhances

Setup a Raspberry Pi Static IP Address

 In this tutorial, I use Raspbian operating system. How to setup a Raspberry Pi Static IP Address. Recommended Raspberry Pi Micro SD Card Power Supply Ethernet Cord or WiFi dongle (The Pi 3 and 4 has WiFi inbuilt) Step 1: we will first need to retrieve some information about your network ip r | grep default Step 2 : Retrieve the current DNS server and opening up the “resolv.conf” configuration file sudo nano /etc/resolv.conf Setting nameserver alternative DNS – such as 8.8.8.8 for Google, or 1.1.1.1 for Cloudflare. Step 3: modify the way the Raspberry Pi handles the network. sudo nano /etc/dhcpcd.conf Add lines as below: interface <NETWORK> static ip_address=<STATICIP>/24 static routers=<ROUTERIP> static domain_name_servers=<DNSIP> • NETWORK – your network connection type: eth0 (Ethernet) or wlan0 (wireless). • STATIC_IP – the static IP address you want to set for the Raspberry Pi. • ROUTER_IP – the gateway IP address for your router on the local network. • D

Fixed Wordpress plugin install Could not create directory

Image
In this tutorial, you'll learn how to fix the "Could not create directory" error during WordPress WordPress plugin installation. The setup involves using Nginx, PHP 7.4, and WordPress on Ubuntu 21.04. The error usually arises due to incorrect directory permissions.  To resolve it, you need to adjust the ownership and permissions of the wp-content directory to ensure the web server can write to it. By following the provided steps, you can ensure seamless plugin installation and a smooth WordPress experience. After install and configure wordpress completed. I have update plugin and could not create directory. I installed into a wordpress directory in /var/www . Nginx does not have permissions to write to the wp-content directory. Wordpress plugin SEO Error Installing Plugin: SEO 17.0 Downloading install package from https://downloads.wordpress.org/plugin/seo.17.0.zip… Unpacking the package… Could not create directory. How to do it Fixed Step 1: Getting the connection info

Rclone backup all VPS to microsoft onedrive

In this tutorial, How to use Rclone backup all VPS to microsoft onedrive. It's very simple, free to backup all to Cloud with Rclone. Rclone supports a lot of Cloud services Google Drive Amazon S3 Openstack Swift / Rackspace cloud files / Memset Memstore Dropbox Google Cloud Storage Amazon Drive Microsoft OneDrive Hubic Backblaze B2 Yandex Disk SFTP The local filesystem Install Rclone on VPS Link direct download here : I use Ubuntu server on VPS. cd /root/ wget https://downloads.rclone.org/rclone-current-linux-amd64.zip unzip rclone-current-linux-amd64.zip cp rclone-v*-linux-amd64/rclone /usr/sbin/ rm -rf rclone-* Rclone command basic rclone config – Configure the connection to the cloud service. rclone copy – Copy files from server to cloud, skip if data already exists. rclone sync – Synchronize between server and cloud, only update data on cloud. rclone move – Move files from server to cloud. rclone delete – Delete the data of the folder. rclone purge – Deletes the data of the fol

Issue Let's Encrypt certificates for multiple websites Nginx

In this tutorial, you'll learn how to issue Let's Encrypt certificates for multiple websites using Nginx . Let's Encrypt is a free and open-source certificate authority that provides SSL/TLS certificates to encrypt your website's traffic.  This guide covers the steps to install Certbot, configure Nginx for SSL, and automate the certificate renewal process. By following these instructions, you can ensure that all your websites are secure and up-to-date with the latest certificates. Prerequisites Ubuntu instance with a LEMP stack installed. Two valid domain name. My example, devopsroles.com and huuphan.com You have access shell login VPS. You neeed install package certbot python3-certbot-nginx on your system. Let's Encrypt Certificates and Nginx Configure Certbot Let's Encrypt certificates for the first website Let's Encrypt free SSL for website. you run command the following certbot --nginx -d huuphan.com you see the following output: root@localhost:~# certbo

How to Install Caddy on Ubuntu

 In this tutorial, How to install Caddy on Ubuntu. The Caddy web server is an open-source web server written in Go. It is designed around simplicity and security that comes with a number of features that are useful for hosting websites. Caddy is both a flexible, efficient static file server and a powerful, scalable reverse proxy. Prerequisites A Ubuntu OS. A root user access or normal user with administrative privileges.  1. Update your system # apt update -y && apt upgrade -y 2. Install Caddy # curl -1sLf 'https://dl.cloudsmith.io/public/caddy/stable/gpg.key' | sudo apt-key add - # curl -1sLf 'https://dl.cloudsmith.io/public/caddy/stable/debian.deb.txt' | sudo tee -a /etc/apt/sources.list.d/caddy-stable.list # apt update After install Caddy on Ubuntu server. # apt install caddy 3. Open your browser and enter your server IP or domain name: http://Server-IP OR http://yourdomain.com 4. Configure Domain with Caddy Create a directory for your website files # mkdir -

How to installing Docker in Raspberry Pi 4

  In this tutorial. How to installing Docker in Raspberry Pi 4 1. Setup OS in the Raspberry Pi I used Ubuntu OS. 2. Update your system $ sudo apt update && sudo apt upgrade 3. Install basic packages $ sudo apt install net-tools git openssh-server Setting up Docker $ sudo apt-get -y install apt-transport-https ca-certificates curl software-properties-common $ curl -fsSL https://download.docker.com/linux/ubuntu/gpg | sudo apt-key add - $ sudo add-apt-repository "deb [arch=arm64] https://download.docker.com/linux/ubuntu $(lsb_release -cs) stable" $ sudo apt-get update $ apt-cache policy docker-ce $ sudo apt-get -y install docker-ce $ sudo usermod -aG docker ${USER} Installing Docker Compose $ sudo apt install python3-pip $ sudo pip3 install docker-compose The basic command docker compose Then deploy the application: $ docker-compose up -d Find what docker-compose is running with the following command: $ docker-compose ps To remove the application $ docker-compose down  

curl command cheat sheet

In this tutorial, I have compiled a comprehensive curl command cheat sheet. Curl is a powerful command-line tool for making HTTP requests and working with various protocols. The cheat sheet is designed to serve as a quick reference guide, providing concise and organized information on the essential curl commands. Whether you're a beginner or an experienced user, this resource aims to simplify the usage of curl commands, helping you navigate and leverage its capabilities efficiently. Feel free to explore the cheat sheet and enhance your proficiency in utilizing curl for various web-related tasks. curl command cheat sheet Option -o <file>       # --output: write to file -u user:pass  # --user: Authentication -v                  # --verbose -s                  # --silent -I                  # --head: headers only -i                  # --include: Include the HTTP-header in the output Request -X POST          # --request -L                     # follow link if page redirects -F  

How to enable SSH 2FA on AlmaLinux

Image
 In this tutorial, How to enable two-factor authentication (2FA) for SSH logins.  Install the Google Authenticator on AlmaLinux sudo dnf install epel-release -y sudo dnf install google-authenticator qrencode qrencode-libs -y After install completes, I will create a new secret key in ~/.ssh directory Run command as follows google-authenticator -s ~/.ssh/google_authenticator The output terminal as below [root@DevopsRoles ~]# google-authenticator -s ~/.ssh/google_authenticator Do you want authentication tokens to be time-based (y/n) y Warning: pasting the following URL into your browser exposes the OTP secret to Google:   https://www.google.com/chart?chs=200x200&chld=M|0&cht=qr&chl=otpauth://totp/[email protected]%3Fsecret%3DDXFSMCJ42VQ7FPMS2VAJ3CIJIE%26issuer%3DDevopsRoles.com Your new secret key is: DXFSMCJ42VQ7FPMS2VAJ3CIJIE Your verification code is 222214 Your emergency scratch codes are:   36072722   12212187   31577834   31344084   92578576 Do you want me to update y

speed test command line linux

Image
 In this tutorial, How to  run a Speedtest from your command line. The requirement Nodejs version > 8+.    Install speed test command line [vagrant@localhost ~]$ wget https://nodejs.org/dist/v14.15.4/node-v14.15.4.tar.gz [vagrant@localhost ~]$ tar xvf node-v14.15.4.tar.gz [vagrant@localhost ~]$ cd node-v14.15.4/ [vagrant@localhost node-v14.15.4]$ sudo ./configure [vagrant@localhost node-v14.15.4]$ sudo make [vagrant@localhost node-v14.15.4]$ sudo make install Use NPM install speed test [vagrant@localhost ~]$ sudo npm install --global speed-test  The result, Install speed-test [vagrant@localhost node-v14.15.4]$ sudo npm install --global speed-test /usr/local/bin/speed-test -> /usr/local/lib/node_modules/speed-test/cli.js + [email protected] updated 2 packages in 10.4s [vagrant@localhost node-v14.15.4]$ Usage speed-test [vagrant@localhost node-v14.15.4]$ speed-test --help   Test your internet connection speed and ping using speedtest.net from the CLI   Usage     $ speed-test   Optio