Backing up and restoring home directory configuration files

vcsh Initialise repository REPO, creating a file in ~/.config/vcsh/repo.d/REPO.git: vcsh init REPO Copy the template gitignore and replace expample keyword by REPO: cp ~/.gitignore.d/{template,REPO} && sed -i "s|example|REPO|g" ~/.gitignore.d/REPO Add the gitignore first, and then all the non-ignored files in gitignore REPO vcsh REPO add -f .gitignore.d/REPO && vcsh REPO add -A Check that every REPO config file is tracked vcsh list-tracked-by REPO Commit the changes vcsh REPO commit -av ...

January 16, 2025 · Alberto Casado

Keyboard control

The keyboard configuration file is located at /etc/default/keyboard (in Debian). The next lines are an example of settings which can be set there: # Consult the keyboard(5) manual page. XKBMODEL="thinkpadx220" # XKBLAYOUT="us" XKBLAYOUT="us,es,fi" XKBVARIANT="euro" # XKBOPTIONS="lv3:ralt_switch,compose:lwin,terminate:ctrl_alt_bksp" XKBOPTIONS="grp:alt_shift_toggle,lv3:ralt_switch,terminate:ctrl_alt_bksp,ctrl:swapcaps,altwin:left_meta_win" BACKSPACE="guess" Alternatively, one can use: setxkbmap -layout us,es,fi -option grp:ctrl_shift_toggle -option ctrl:swapcaps -option terminate:ctrl_alt_bk sp-option altwin:left_meta_win

August 8, 2020 · Alberto Casado

Sytemd networkd

From Arch forums. Aslo follow this great instructions Okay, so I’ll walk you through this since there is really not a whole lot of documentation on the subject. This assumes that your NIC is wlan0, your SSID is MyNetwork, and the password is SuperSecretPassphrase. You need to create a wpa_supplicant-wlan0.conf. So use wpa_passphrase to generate one: wpa_passphrase MyNetwork SuperSecretPassphrase > /etc/wpa_supplicant/wpa_supplicant-wlan0.conf Enable it so that it runs on boot: systemctl enable wpa_supplicant@wlan0.service Get the IP Wired and wireless adapters on the same machine This setup will enable a DHCP IP for both a wired and wireless connection making use of the metric directive to allow the kernel to decide on-the-fly which one to use. This way, no connection downtime is observed when the wired connection is unplugged. ...

August 6, 2020 · Alberto Casado

How to fix a corrupted HDD

When it looks like your / partition can’t be mounted, it could be due to a corruption or a failing hard drive. Boot from a UNIX live CD or live USB and see if you can even mount the main root partition on your hard drive. If you can unmount it. (More below.) Now install GSmartControl on the live CD/live USB. Start up GSmartControl after install and look at the S.M.A.R.T. attributes of your hard drive. Anything highlighted in pink? If so - what? ...

August 4, 2020 · Alberto Casado

How to move the root partition

You’ll need to boot from a live cd. Add partitions for them to disk 1, copy all the contents over (with rsync, see rsync clone partition), and then use sudo blkid to get the UUID of each partition. On disk 1’s new /, edit the /etc/fstab to use the new UUIDs you just looked up. Updating GRUB depends on whether it’s GRUB1 or GRUB2. If GRUB1, you need to edit /boot/grub/device.map ...

August 4, 2020 · Alberto Casado

GPG

Create a file echo -e "password\n" | gpg --encrypt -o .file.gpg`` Create an encrypted file (containing e.g. a password) Edit vim mypw; gpg -e mypw; rm mypw Read gpg2 -q --for-your-eyes-only --no-tty -d mypw.gpg Backup keys gpg --output mygpgkey_pub-71CB6801.gpg --export 08352695F97D0952469752239A2E09E771CB6801 gpg --output mygpgkey_sec-71CB6801.gpg --export-secret-keys 08352695F97D0952469752239A2E09E771CB6801 Import keys gpg --import mygpgkey_sec-71CB6801.gpg Remote import and export Export the GPG key First list the gpg keys available in the system: ...

July 25, 2020 · Alberto Casado

Mount devices

Mount an ssh location in local tree sshfs user@domain.com:/path mountpoint -o reconnect,password_stdin,idmap=user,ServerAliveInterval=15,umask=0002,sftp_server="/usr/lib/openssh/sftp-server -u 0002" -o reconnect: reconnect after disconnection -o ServerAliveInterval=15: keep the connection alive even if there is no activity -o idmap=user: set permissions for local user emulating remote user -o password_stdin: get password from stdin -o umask=0002,sftp_server="/usr/lib/openssh/sftp-server -u 0002": mask for existing or newly created files E.g.: sshfs casadoa1@amor.org.aalto.fi:/m/nbe/project/quantum-data/ /m/nbe/project/quantum-data/ -o reconnect,password_stdin,idmap=user,ServerAliveInterval=15,umask=0002,sftp_server="/usr/lib/openssh/sftp-server -u 0002" Unmount fusermount -u mountpoint

July 25, 2020 · Alberto Casado

USB devices

USB format (part 1) Source Well, one could try zero’ing the raw block device to see if that can work. If you can write to that then you may be able to create a clean partition table, create a new partition and format that. Suppose the USB stick is on /dev/sdc, first make sure /dev/sdc1 is unmounted: umount /dev/sdc1 See if you can then clear the partition table, say by copying a bunch of zeros over the first few K ...

July 25, 2020 · Alberto Casado

Useful shell commands

Replace commas with tabs sed "s/,/\\t/g" in.dat >> out.dat List directories recursively ls -RAlph Remove files with and extension from multiple directories rm -Rvf /some/dir*/*.ext Move files only if they are newer, and backup if they already exist mv -vubi -v: verbose -u: update only -b: backup -i: interactive, ask for confirmation to overwrite From here: Quickly Find a PID with pgrep pgrep ssh Execute The Last Executed Command !! The !! command is very useful when you forget to start a command with sudo : ...

July 25, 2020 · Alberto Casado

Change X11 defaults

sudo update-alternatives --config x-www-browser

July 24, 2020 · Alberto Casado