RSA (Rivest–Shamir–Adleman) is a widely used public-key cryptosystem that is used for secure communication over the internet. In this post, we will explore how to generate a pair of RSA private and public keys in Linux using the OpenSSL library. Generating a pair of RSA private and public keys in Linux using OpenSSL is a
Read more
Author: Q A
How to encrypt a file using openssl on Linux non-interactively?
Posted onHow to encrypt a file using openssl on Linux non-interactively? The passphrase shall be provied to openssl in a programmatic way instead of requesting the user to input it, so that the command may work in a regular cron job or some batch jobs. To encrypt file file.tgz and store it to file.tgz using aes-256-ebc
Read more
How to generate a pair of SSH private key and public key pairs?
Posted onHow to generate a pair of SSH private key and public key pairs? On Linux, you can generate one first by $ ssh-keygen -t rsa By default on Linux, the key pair is stored in `~/.ssh` named `id_rsa` and `id_rsa.pub` for the private and public key.
How to cat a text file out from a tar archive without having to extracting it?
Posted onHow to cat a text file out from a compressed tar archive package without having to extracting the whole package? For example, I have a pkg.tar.gz which contains a text file pkg/readme.txt in it. How to cat the pkg/readme.txt file content out? You may use this command to cat out the file content: tar -O
Read more
How to mirror a website using wget on Linux?
Posted onHow to mirror a website using wget on Linux? If the command can filter only specific file extensions, such as pdf and docx, it will be much better too. To download all PDF files from https://example.org/path/ as an example, you may use this command: wget –mirror \ –convert-links –no-parent –quiet \ –adjust-extension -A pdf \
Read more
How to write file content with sudo in Vim?
Posted onVim opens file even if the user does bot have write permission to the file. But after revision, how to write file content with sudo in Vim if Vim reports no permission to write the file. Use this command inside of vim to write to the file with sudo: :w !sudo tee % Here, !
Read more
How to rename a branch name in the remote git server?
Posted onHow to rename a branch name in the remote git server? For example, I made a mistake to push a branch named ood-name to the git server while I intended to name it old-name. How to rename the branch name ood-name on the remote git server? You may change the remote git server’s branch name
Read more
How to get date and time from another timezone in Python?
Posted onHow to get the date and time from another timezone in Python? You may use the pytz library. Example usage as follows. $ python3 Python 3.8.2 (default, Jul 16 2020, 14:00:26) >>> from datetime import datetime >>> import pytz >>> >>> print(datetime.now(pytz.timezone(‘Europe/Amsterdam’)).strftime(‘%Y-%m-%d %H:%M:%S %Z%z’)) 2020-08-09 15:50:00 CEST+0200 >>>
How to enable user themes in Ubuntu 18.04?
Posted onThe way for Ubuntu 17 to installing the gnome-shell-extensions package does not work any more for Ubuntu 18.04. How to enable user themes in Ubuntu 18.04? The updated gnome-shell-extensions package actually adds the User Theme extension back. You can use that. First, install the package sudo apt install gnome-shell-extensions Second, log out and login again
Read more
How to get date and time using date command from another timezone in Linux?
Posted ondate command on Linux gets the date and time in the system timezone. But how to get date and time using date command from another timezone in Linux? You can make date print the time of another timezone by setting the TZ environment variable. For example, export TZ=Hongkong; date Sat Dec 1 09:39:13 HKT 2018
Read more
How to detach a docker container to be a running daemon?
Posted onIf I quite a docker instanced (invoking /bin/bash) by Ctrl+d, the docker container is closed. How to detach a docker container to be a running daemon without closing it? Docker has a detach sequence, which, by default, is Ctrl-p + Ctrl-q. If the docker detach sequence is overridden by the –detach-keys=”<sequence>” flag, you need to
Read more
Fixing the huge emoji icons in Unbuntu 18.04 for Thunderbird
Posted onIn Ubuntu 18.04, Thunderbird shows huge emoji icons in the email list. The emoji covers other text and is several lines higher and wider than other charactors. How to solve it? This is likely caused by the fonts. Find out the *emoji* fonts installed in your system by sudo apt list *emoji* and remove those
Read more
How to change the logo shown during booting in Ubuntu?
Posted onHow to change the logo shown during booting in Ubuntu? I originally installed Ubuntu MATE 18.04. But I am using GNOME 3 now by replacing the DE. But the log shown during booting is still Ubuntu MATE’s. How to change it to another one? It is plymouth the application that manages the “splash” screen during
Read more
GNOME 3 "Natural scrolling" mouse option does not work
Posted onIn GNOME 3 “Settings” -> “Devices” -> “Mouse & Touchpad”, after setting “Natural scrolling” to On, the scrolling is still as the same before (non-natural). How to fix this? This is likely related to the X11 driver. Remove the xorg-x11-drv-synaptics driver if it is installed. And install the xorg-x11-drv-libinput driver if it is not installed.
Read more
How to add Chinese input method to Unbuntu 18.04?
Posted onHow to add Chinese input method, such as Pinyin, to Unbuntu 18.04? To input Chinese, first install an input method framework. Here, we use fcitx. Then you need to input the Pinyin input method. You may use fcitx-sunpinyin. Put them all together $ sudo apt-get install fcitx fcitx-sunpinyin After that, set the default input method
Read more
Port forwarding on local host
Posted onI am trying to forward UDP port 500 to 2500 on local host, but can’t get this to work – I have run: iptables -t nat -A PREROUTING -p udp -d 192.168.1.10 –dport 500 -j DNAT –to-destination 192.168.1.10:2500 iptables -A FORWARD -p udp -d 192.168.1.10 –dport 2500 -j ACCEPT where 192.168.1.10 is the IP of
Read more
How to convert a string to lower case in Python?
Posted onHow to convert a string to lower case in Python? For example: “Abc” -> “abc” “BBB” -> “bbb” “abc” -> “abc” You can use the string.lower() method of Python: string.lower(s) Return a copy of s, but with upper case letters converted to lower case. Example: $ python Python 2.7.5 (default, Apr 11 2018, 07:36:10) [GCC
Read more
System Call Tracking without ptrace,strace,etc.
Posted onHow could I log system calls made by another process without using current built in functions like ptrace, strace, audit etc. I think two options are intercepting the system call table, and another is modifying the entry_64.s file. I want to output these system calls to a file. Can’t find any suggestions on this anywhere.
Read more
How to filter bbpress content in WordPress
Posted onIn WordPress, we can filter the post content by adding a filter to the_content: add_filter('the_content', 'inline_markdown_pre_process_shortcode2', 7); But how to filter the content for bbpress contents? bbpress topic and reply (they are separated) content have their own filters: bbp_get_topic_content and bbp_get_reply_content. For example, add_filter(‘bbp_get_topic_content’, ‘my_plugin_custom_bbp_function’); add_filter(‘bbp_get_reply_content’, ‘my_plugin_custom_bbp_function’); function my_plugin_custom_bbp_function($content) { return ‘my_plugin_custom_bbp_function processed: ‘.$content; }
Call a Function by Its Name as a String in PHP
Posted onIn PHP, it is possible to call a function by its name as a string. This can be useful when the name of the function is not known until runtime, or when the name of the function is stored in a variable or retrieved from a database or other external source. To call a function
Read more