Monday, August 31, 2020

Convert JPG to compressed PDF using ImageMagick

Resize and lower the quality of the JPG images while converting to PDF using

 convert -quality 25 -resize 50% input.JPG output.pdf

Saturday, May 4, 2019

Enable SSH on a MacBook Pro

Check if SSH is enabled from terminal

$ sudo systemsetup -getremotelogin

Enable SSH from terminal

$ sudo systemsetup -setremotelogin on

Saturday, May 12, 2018

Network Bandwidth

Network speed is measured in bits per second(bps)
File sizes are specified in Bytes


Network speed of 1Mbps  -> 125,000Bps(Byes per second) can transfer a 1 MB file in 8 seconds
Network speed of 10Mbps  -> 1,250,000Bps(Byes per second) can transfer a 1 MB file in 0.8 seconds
Network speed of 100Mbps  -> 12,500,000Bps(Byes per second) can transfer a 1 MB file in 0.08 seconds

Converting Megabits per second(Mbps) to Bytes per second(Bps)

(Mbps * 1,000,000) / 8 = Bps

Saturday, May 20, 2017

Python : Using end=' ' to prevent new line after print

print("Tell me your name : ",  end=' ')
name = input()

Putting an end=' ' tells print not to end the line with a newline character

The output will be like

Tell me your name : <name>

Monday, May 15, 2017

Linux 7 Boot Process


  1. As soon as the machine is powered on, the system firmware(either UEFI or BIOS) runs a Power On Self Test (POST) and starts initialising some hardware.
  2. The system firmware then searches for a bootable device, which is either configured in UEFI boot firmware or by searching for Master Boot Record(MBR) on all disks in the order configured in BIOS.
  3. The system firmware reads a boot loader from disk and passes control to the boot loader(grub2)
  4. The boot loader loads it's configuration from disk and presents user with a menu of possible configurations to boot.
  5. The boot loader then loads the kernel and initramfs from disk and place them in memory. An initramfs is a gziped cpio archive containing kernel modules for all hardware necessary at boot, init scripts and more. The initramfs containes an entire usable system by itself.
  6. The bootloader hands control of the system to the kernel.
  7. The kernel initializes all hardware for which it can find driver in the initramfs, then executes /sbin/init from initramfs as PID 1. The initramfs contains a working copy of systemd as /sbin/init, as well as udev daemon in RHEL 7.
  8. The systemd instance from initramfs executes all units for initrd.target. This includes mounting the actual root file system on /sysroot
  9. The kernel root file system is switched from the initramfs root file system to system root file system that was previously mounted on sysroot. systemd then re-executes itself using copy of systemd installed on the system.
  10. systemd then looks for a default target, then starts(and stops) units to comply with the configuration for that target, solving dependancies between units automatically.

Knowing a rpm package

List Binaries

rpm -ql <package_name> | grep bin

Eg: # rpm -ql httpd | grep bin
/usr/sbin/apachectl
/usr/sbin/fcgistarter
/usr/sbin/htcacheclean
/usr/sbin/httpd
/usr/sbin/rotatelogs
/usr/sbin/suexec
/usr/share/httpd/icons/binary.gif
/usr/share/httpd/icons/binary.png
/usr/share/httpd/icons/binhex.gif
/usr/share/httpd/icons/binhex.png
/usr/share/httpd/icons/small/binary.gif
/usr/share/httpd/icons/small/binary.png
/usr/share/httpd/icons/small/binhex.gif
/usr/share/httpd/icons/small/binhex.png
/var/www/cgi-bin

List configuration files

rpm -qc <package_name>

Eg: # rpm -qc httpd
/etc/httpd/conf.d/autoindex.conf
/etc/httpd/conf.d/userdir.conf
/etc/httpd/conf.d/welcome.conf
/etc/httpd/conf.modules.d/00-base.conf
/etc/httpd/conf.modules.d/00-dav.conf
/etc/httpd/conf.modules.d/00-lua.conf
/etc/httpd/conf.modules.d/00-mpm.conf
/etc/httpd/conf.modules.d/00-proxy.conf
/etc/httpd/conf.modules.d/00-systemd.conf
/etc/httpd/conf.modules.d/01-cgi.conf
/etc/httpd/conf/httpd.conf
/etc/httpd/conf/magic
/etc/logrotate.d/httpd
/etc/sysconfig/htcacheclean
/etc/sysconfig/httpd


Tips for configuration files

man 5 <filename.conf>

List documentation

rpm -qd <package_name>