gpg not working without X server

archlinux-logo-dark-200dpi.b42bd35d5916

If you are trying to use gpg command for encrypt or decrypt data on tty without X server (I use that in combination with yadm, you will probably get this error:

gpg: public key decryption failed: Inappropriate ioctl for device

If you don’t want to switch to X every time, there is a simple solution.Put this line in your ~/.bashrc:

export GPG_TTY=$(tty)

Happy hacking…

Advertisements

hstr – improved bash history completition

hh>

When working on command line most of the time, there is always a problem with long commands, for example:
find . -depth -name '* *' -execdir bash \-c 'a="{}";mv -f "$a" ${a// /.}' \;
(this command replace all spaces ‘ ‘ with dots ‘.’ recursively in directories and file names, see my post¬†for explanation)

There is option with ctrl-r or you can use clipboard manager like anamnesis or CopyQ or some other helper. A while ago I stumbled upon hstr on ArchLinux AUR repository (it’s called hh there) and I’m using it since then. The advantages are easier and more efficient browsing with managed history (removing sensitive commands) and option to bookmark favorite commands.
When installed just configure hh with:
hh --show-configuration >> ~/.bashrc
and with the same ctrl-r keyboard shortcut.

For quick introduction you can view video tutorial on Youtube or, when installed read man hh.

Happy hacking….

tfman – a different file manager

tfman tfman_vim

There are a plead different file managers out there, with or without GUI, with variable amount of panels, keyboard or mouse driven and so on, but this one is a little bit different. It is still in an early stage of development so it is not yet 100% ready, but it is already show potential to be useful terminal driven file manager.

It is named tfman  – “text file manager” and it performs file operations through textual representation of file system which is in the form of plain text, editable with any text editor and may contain multiple operations of every kind. Tfman can be used from command-line or from within Vim as multi-window file manager.

A quick start guide is here, tutorial here and manual page here.

For now it is only available as package at Arch AUR, for other Linux flavours you must compile and install tfman manually.

Happy hacking….

Recursive change of file permissions and attributes

ratpoison_logo-60

This is just quick sequel to previous post:
#changing directory permissions to 755
find . -depth -type d -name '*' -execdir bash \-c 'a="{}";chmod 755 -f "$a"' \;

#changing file permissions to 644
find . -depth -type f -name '*' -execdir bash \-c 'a="{}";chmod 644 -f "$a"' \;

…of course you must be root to do so…
Happy New Year!

Recursive Batch Rename in Console

ratpoison_logo-60

One quick one for the end of the year…
Recursive batch rename of directories and files in the same time:

#replace ” ” with “.”:
find . -depth -name '* *' -execdir bash \-c 'a="{}";mv -f "$a" ${a// /.}' \;

#replace “-” with “_”:
find . -depth -name '*-*' -execdir bash \-c 'a="{}";mv -f "$a" ${a//-/_}' \;

#replace “if” with “or”:
find . -depth -name '*if*' -execdir bash \-c 'a="{}";mv -f "$a" ${a//if/or}' \;

…if you want to rename just directories or files just add:

-type d #for directories
-type f #for files

…after…
-depth

Happy New Year….

The Shell Shock Vulnerability

The Shell Shock exploit or bash vulnerability is a serious bug in most versions of Bash dating back to at least 1994. It allows remote attackers to execute arbitrary code because it processes trailing strings after function definitions in the values of environment variables.
Simple check is executing command:
x="() { :; }; echo x" bash -c :
and if “x” is printed then your bash is vulnerable. Taken from commandlinefu by user malathion
More about vulnerability can be found at shellshockexploit.com where are also described more checking methods and more info about that.