Advertisement

Linux notes

This post is a collection of useful notes for myself. I will update it with quick commands that I can't keep in memory but occasionally use.

Create ISO from CD or DVD on Linux

# dd if=/dev/{cdrom|sr0|whatever} of=file.iso

Set partition or drive label

View current label

# blkid -f

or

# blkid /dev/sda1

Change label

  • ext4: e2label /dev/sda1 my_label
  • fat: fatlabel /dev/sda1 my_label
  • ntfs: ntfslabel /dev/sda1 my_label
  • any fs: tune2fs -L "my_lable" /dev/sda1
  • any fs with gparted (the partition must be unmounted)Linux Gparted Change Drive Label

Combine multiple images into one with ImageMagick

montage *.jpg -tile 5x3 -geometry +0+0 out.png

5 - columns

3 - rows

Change the terminal title from a bash script

Add this to the script: echo -ne "\033]2;Your title goes here\007"

For example:

#!/bin/bash
echo -ne "\033]2;Music\007"
mpg123 -qZ $HOME/Music/*

Convert SVG to PDF

Chrome browser method (supports embedded fonts)

#!/bin/bash
for i in {001..157}
do
google-chrome --headless --disable-gpu --print-to-pdf-no-header --no-pdf-header-footer --print-to-pdf="file${i}.pdf" "file${i}.svg"
done
pdfunite file*.pdf merged.pdf

Method 2 (doesn't support embedded fonts)

  1. Install librsvg2-bin:sudo apt install librsvg2-bin
  2. Multiple svg to a single pdf: rsvg-convert -f pdf -o out.pdf *.svg
  3. A single file: rsvg-convert -f pdf -o out.pdf in.svg

Pad left the loop variable in bash

Just specify the desired width in the loop range:

#!/bin/bash

for i in {001..157}

Change the date of the file

  • To change the file date to some specific value:
    touch -a -m -t 202301280130.09 filename
  • To set the date of the file from another file but on 3 hours earlier:
    touch -d "$(date -R -r sourcefile) - 3 hours" destinationfile

Support us

Winaero greatly relies on your support. You can help the site keep bringing you interesting and useful content and software by using these options:

If you like this article, please share it using the buttons below. It won't take a lot from you, but it will help us grow. Thanks for your support!

Advertisеment

Author: Sergey Tkachenko

Sergey Tkachenko is a software developer who started Winaero back in 2011. On this blog, Sergey is writing about everything connected to Microsoft, Windows and popular software. Follow him on Telegram, Twitter, and YouTube.

2 thoughts on “Linux notes”

  1. I like Linux! Hope you start writing a little bit about it. I know that the site is mostly about Windows, but a little Linux can slip in I think! ;)

Leave a Reply

Your email address will not be published.

css.php
Using Telegram? Subscribe to the blog channel!
Hello. Add your message here.