#!/usr/bin/env bash BASE_DIR=$1 if [ ! -d "${BASE_DIR}" ] ; then echo "$BASE_DIR is not a directory"; fi ## Find those files that are older than a month find "$BASE_DIR" -maxdepth 1 -mtime +30 -type f -name '*.jpg' | while IFS= read -r file; do ## Get the file's modification year year="$(date -d "$(stat -c %y "$file")" +%Y)" ## Get the file's modification month month="$(date -d "$(stat -c %y "$file")" +%b)" ## Create the directories if they don't exist. The -p flag ## makes 'mkdir' create the parent directories as needed so ## you don't need to create $year explicitly. [[ ! -d "$BASE_DIR/$year/$month" ]] && mkdir -p "$BASE_DIR/$year/$month"; ## Move the file mv "$file" "$BASE_DIR/$year/$month" done
Tag Archives: Linux
Docker fails to fetch http://deb.debian.org/debian/dists/buster/InRelease
I found a network issue when trying to build my docker image: the command `apt update` fails with the following error:
W: Failed to fetch http://deb.debian.org/debian/dists/buster/InRelease
W: Failed to fetch http://deb.debian.org/debian/dists/buster-updates/InRelease
W: Failed to fetch http://security.debian.org/dists/buster/updates/InRelease
W: Failed to fetch http://deb.debian.org/debian/dists/buster/Release.gpg Temporary failure resolving ‘deb.debian.org’
W: Failed to fetch http://security.debian.org/dists/buster/updates/Release.gpg Temporary failure resolving ‘security.debian.org’
W: Failed to fetch http://deb.debian.org/debian/dists/buster-updates/Release.gpg Temporary failure resolving ‘deb.debian.org’
W: Some index files failed to download. They have been ignored, or old ones used instead.
This happens because your ISP DNS servers are not reachable from this network. The easiest workaround is to directly instruct Docker to rely on some public DNS servers proven to be stable and reliable (Google, Cloudflare).
Add them to a new configuration file called daemon.json
:
$ sudo pico /etc/docker/daemon.json
Insert the following:
{ "dns": ["1.1.1.1", "8.8.8.8", "8.8.4.4"] }
Then restart the service:
$ sudo service docker restart
GSConnect doesn’t mount my phone on Manjaro Gnome, this is the solution
Hi there! I am using the Gnome shell extension GSConnect on Manjaro Gnome to share files from my phone to my laptop. There is an option called “Mount” that initially didn’t work on Manjaro but I found a solution and it now works like a charm!
All you need to do is to edit the file /etc/ssh/ssh_config
sudo vim /etc/ssh/ssh_config
and add to the end of the file the following:
Host 192.168.*.* HostKeyAlgorithms +ssh-rsa
Accessing Samba on Manjaro: failed to retrieve share list from server
A few days ago I got my shiny new StarBook Mk V and installed Manjaro on it for the very first time. I have no prior experience neither with Arch-based distros not rolling releases. Anyway, soon after I installed it I realized that I can’t access my homemade NAS server over Samba. I have a samba network at home with a mix of Linux (Linux Mint, Manjaro) and Windows 10 (don’t judge me) computers. Samba has always worked well to connect to each other. But now, when opening smb://192.168.1.6 in Gnome file manager I get this error: Failed to retrieve share list from server: Invalid argument
After quick duckling I found the solution: everything you need to do is to add these two lines in the global section of /etc/samba/smb.conf file on the server
client min protocol = CORE server min protocol = CORE
and then restart it:
sudo service smbd restart
Voila!
P.S. The solution is based on the original post on the Manjaro forums here.
Install the latest versions of Vagrant and VirtualBox on Linux Mint 19.2
I use Linux Mint 19.2 as daily driver on my ThinkPad L480. This step by step tutorial will guide you through the process of getting the latest versions of VirtualBox and Vagrant instead of the outdated versions available in the official Ubuntu repositories.
VirtualBox and Vagrant receive updates on Linux much often than the repositories update. If you want to consistently get these updates when they become available, you’ll want to add VirtualBox and Vagrant repository to your system. This will allow you to get notified for new versions and update trough Linux Mint Update Manager and apt.
Batch rename files with Cyrillic filenames to Latin ones (transliterate file names)
If you have a bunch of files with Cyrillic file names, there is a chance that some old devices such as TV embedded players, car audio systems, mp3 players may not recognize them or fail to read. The quick and dirty solution is to rename these files to Latin only characters. In order to save some time I use this handy bash script. It works flawlessly on both Windows (Git Bash) and native Linux systems. Continue reading
This machine ID is already enabled with a different key or is non-unique
I have purchased new VPS and I wanted to enable Ubuntu live patch service for it. Unfortunately, the command canonical-livepatch enable [TOKEN] failed with this ugly error message:
This machine ID is already enabled with a different key or is non-unique.
Either “sudo canonical-livepatch disable” on the other machine, or regenerate a
unique /etc/machine-id on this machine with
“sudo rm /etc/machine-id /var/lib/dbus/machine-id && sudo systemd-machine-id-setup” :
{“error”: “Conflicting machine-id”}
I thought to myself “Ok, let’s try the suggested solution”. What I did was to backup the file /etc/machine-id, than delete it and run suggested systemd command. I was surprised to see the newly generated UUID was the same! Consulting with man page of systemd-machine-id-setup command revealed that “If run inside a KVM virtual machine and a UUID is configured (via the -uuid option), this UUID is used to initialize the machine ID. The caller must ensure that the UUID passed is sufficiently unique and is different for every booted instance of the VM.”. Obviously, my new VPS provider did not ensure that and somebody else has the same machine ID on his/her VPS and enabled Ubuntu live patch for it.
Vagrant: Authentication failure. Retrying…
I recently bought a newer laptop. It had Windows 8 preinstalled which I wiped immediately in order to install Linux Mint 19.1 and started to migrate data from my old machine. I packaged my vagrant box and transferred it to the new machine. Once imported the box back and issued vagrant up command I was surprised by the following errors:
Add GIT branch information to Bash prompt
I’ve seen such as fancy Bash prompts on various tutorials and Linux examples over the Internet and I’ve always wondered how is achieved. I never really had a enough free time to learn more about it and explore the options. But being jobless for a month gave me opportunity to play with the thinks I like 🙂
My solution is pretty simple: when you navigate to git controlled folder, the bash prompt will show “@ branch” after the directory name. Nothing fancy.
Just open your ~/.bashrc configuration file with your favorite editor and add the following:
get_git_branch () { git name-rev HEAD 2> /dev/null | sed "s/[a-zA-Z0-9]\+\ \(.*\)/ @ \1/" }
than put this into your PS1 string:
$(get_git_branch)
so it become something like that
PS1='${debian_chroot:+($debian_chroot)}\[\033[01;32m\]\u@\h\[\033[00m\]:\[\033[01;34m\]\w$(parse_git_branch) \n\$\[\033[00m\] '
Restart your terminal or type bash to start new bash session. Navigate to git controlled folder to test. It should look like this:
How to create user without useradd command in OpenWRT
There is no useradd command in OpenWRT. Instead, shadow user package is available but I found it overkill. Anyway, if you are interested in using it – check out this tutorial,
Follow these steps to create a user without using useradd command in OpenWRT. Continue reading