Don't parse the output of "ls".
Instead:
for file in *
do
...
done
(source)
A piggy bank of commands, fixes, succinct reviews, some mini articles and technical opinions from a (mostly) Perl developer.
Windows has AutoHotkey (AHK), and Linux has xdotool.
But xdotool 3.20160805.1 doesn't work on Wayland at all. It silently fails. Turns out xdotool only works on X11, which is no longer the default for Ubuntu.
In 2024, using Ubuntu 22, this version of xdotool is the latest one available by running `apt install xdotool`.
To find out if you're using Wayland:
$ loginctl show-session 2 -p Type
Type=wayland
$ echo $XDG_SESSION_TYPE
wayland
To switch to X11, edit/etc/gdm3/custom.conf
, uncomment the line WaylandEnable=false
, and reboot.
Now xdotool will work perfectly.
xdotool README does mention some alternatives:
For username "foo":
$ adduser foo
$ passwd foo
$ sudo usermod -aG sudo foo
$ mkdir -p /home/foo/.ssh
$ cat the_public_key.pem >> /home/foo/.ssh/authorized_keys
$ chown -R foo:foo /home/foo/.ssh
$ chmod 700 /home/foo/.ssh
$ chmod 600 /home/foo/.ssh/authorized_keys
Disable default account:
$ usermod -s /usr/sbin/nologin default_username
Notes:
- Not useradd.
- Even when logging in with just SSH key, user must have a password. It will only be used for sudo commands.