Skip to content

Rage Against the Shell

Linux tips and other things…

  • Home
  • Contact
  • Privacy Policy

Category: Command line

Using qrencode

Posted on January 16, 2022 by Mr. Reboot

Tested on Ubuntu 20

With qrencode you can encode text, strings or urls into a QR image, easily.

Install package:

~ $ sudo apt-get install qrencode

Generate a QR image from a URL in PNG format:

~ $ qrencode -o thebestwebsite.png -t PNG "https://rageagainstshell.com"

Generate a QR image from a URL in PNG format, with size 10 (default is 3):

~ $ qrencode -s 10 -o thebestwebsite.png -t PNG "https://rageagainstshell.com"

Print a QR image by stdout from a text:

qrencode -t ansiutf8 "This is a string" -o -

If you feel green, you may change the default background color:

~ $ qrencode --background=457834 -s 5 -o thebestwebsite.png -t PNG "https://rageagainstshell.com"

Or the foreground:

~ $ qrencode --foreground=457823 -s 5 -o thebestwebsite.png -t PNG "https://rageagainstshell.com"
Posted in Command lineLeave a comment

Getting the parent process pid

Posted on October 12, 2018 by Mr. Reboot

Tested in debian 8

Sometimes can be useful to know the parent pid of a process for getting info or to kill it. You can use ps with ppid option:

Scenario:

root      1208  0.0 11.0 312388 113172 ?       Ss   Oct10   0:06 /usr/sbin/apache2 -k start
www-data  3915  0.0 11.1 1363796 113332 ?      Sl   06:25   0:05  \_ /usr/sbin/apache2 -k start
www-data  3916  0.0 10.9 1362304 112000 ?      Sl   06:25   0:03  \_ /usr/sbin/apache2 -k start

Getting de ppid knowing the child pid:

~ $ ps -O ppid= -p 3916
  PID       S TTY          TIME COMMAND
 3916  1208 S ?        00:00:03 /usr/sbin/apache2 -k start

Or short format with only pid:

~ $ ps -o ppid= -p 3916
 1208

Or knowing the child name:

~ $ ps -O ppid= -p $(pgrep apache2)
  PID       S TTY          TIME COMMAND
 1208     1 S ?        00:00:06 /usr/sbin/apache2 -k start
 3915  1208 S ?        00:00:05 /usr/sbin/apache2 -k start
 3916  1208 S ?        00:00:04 /usr/sbin/apache2 -k start

And viceversa, knowing the parent pid get pid from all childs:

~ $ ps --ppid=1208 -f
UID        PID  PPID  C STIME TTY          TIME CMD
www-data  3915  1208  0 06:25 ?        00:00:05 /usr/sbin/apache2 -k start
www-data  3916  1208  0 06:25 ?        00:00:04 /usr/sbin/apache2 -k start
Posted in Command lineLeave a comment

Snow in your shell

Posted on January 15, 2018 - January 15, 2018 by Mr. Reboot

Command to generate snow on your shell console, it’s cool:

~ $ clear;while :;do echo $LINES $COLUMNS $(($RANDOM%$COLUMNS)) $(printf "\u2744\n");sleep 0.1;done|gawk '{a[$3]=0;for(x in a) {o=a[x];a[x]=a[x]+1;printf "\033[%s;%sH ",o,x;printf "\033[%s;%sH%s \033[0;0H",a[x],x,$4;}}'

You will need gawk installed.

Source: http://climagic.org/coolstuff/let-it-snow.html (@climagic)

Posted in Command lineLeave a comment

Search

Calendar

March 2023
M T W T F S S
 12345
6789101112
13141516171819
20212223242526
2728293031  
« Jan    

Categories

  • Apache
  • Cisco
  • Command line
  • Distros
  • Dovecot
  • File systems
  • Gadgets
  • GlusterFS
  • MySQL
  • Nginx
  • NTP
  • Opendkim
  • Pacemaker + Corosync
  • Postfix
  • Raspberrypi
  • SSH
  • SSL
  • Varnish

RSS RSS

  • Using qrencode January 16, 2022
  • Compile varnish module vmod_vsthrottle April 22, 2020
  • SSH vpn with sshuttle April 9, 2020
  • Disable swap in systemd December 16, 2019
  • Getting the parent process pid October 12, 2018
Proudly powered by WordPress | Theme: micro, developed by DevriX.