failed to execute ‘/lib/udev/socket:@/org/freedesktop/hal/udev_event’ ‘socket:@/org/freedesktop/hal/udev_event’

Problem

Looking at your /var/log/syslog you see entries every few seconds like the following:

Mar  1 15:44:52 L530 systemd-udevd[11464]: failed to execute '/lib/udev/socket:@/org/freedesktop/hal/udev_event' 'socket:@/org/freedesktop/hal/udev_event': No such file or directory
Mar  1 15:44:52 L530 systemd-udevd[11451]: Process 'socket:@/org/freedesktop/hal/udev_event' failed with exit code 2.
Mar  1 15:44:54 L530 systemd-udevd[11479]: failed to execute '/lib/udev/socket:@/org/freedesktop/hal/udev_event' 'socket:@/org/freedesktop/hal/udev_event': No such file or directory
Mar  1 15:44:54 L530 systemd-udevd[11466]: Process 'socket:@/org/freedesktop/hal/udev_event' failed with exit code 2.

Solution

Seems that hal is not used in newer Ubuntu versions, so you can remove it:

sudo apt-get purge hal

Taken from the answer here

Remove line from bash history

Problem

You want to remove a certain line from your server’s bash history, if for example you pasted a password in the wrong place.

Solution

Use the two steps:

1. history -d line_number to remove from memory
2. history -w to write in-memory history to the history file ~/.bash_history

as described here

When the shell is not bash (sh) you can remove them from ~/.ash_history and then source the file.

Changing default editor for crontab from nano to vim

Problem

You would like to change the default editor for crontab from nano to vim.

Solution

Add the following to the ~/.selected_editor:

SELECTED_EDITOR="/usr/bin/vim"

or run the select-editor and choose vim-basic (4)

server# select-editor 

Select an editor.  To change later, run 'select-editor'.
  1. /bin/ed
  2. /bin/nano        <---- easiest
  3. /usr/bin/mcedit
  4. /usr/bin/vim.basic
  5. /usr/bin/vim.tiny

Choose 1-5 [2]: 4

Converting number from any base system to decimal in linux shell

Problem

You would like to quickly convert a number from a different base system (i.e. binary, octal, hexadecimal), to decimal.

Solution

Use the echo $(()) shell command to convert it passing it the current base system and the number, as in $((2#101010)) or using the O for octal or 0x for hexadecimal notations.
Examples:

echo $(( 16#FF ))
255
echo $(( 0xFF ))
255
echo $(( 8#21 ))
17
echo $(( 021 ))
17

Taken from Linux Journal’s Work the Shell column (March 2016)

Combine multiple zip files (from windows) and unzip them in linux

Problem

You have received multiple zip files that were originally one big zip file, possibly from windows, and you want to put them back together and unzip them in linux.

Solution

So if your file names are for example called: file1.zip file2.zip etc, you can do the following:

cat file* > one_file.zip
unzip one_file.zip

git apply name_of_file.patch does not work

Problem

You are given a patch file to apply to your git repository but using git apply does not work. No errors reported but no changes applied neither.

Solution

Try to use the patch command command possibly with the -p1 parameter like:

patch -p1 < path_to_the_patch_file.patch

NOTE: Make sure that you are in the right folder relative to the file path in the patch file

rvm single user installation fails with: curl: (35) error:140770FC:SSL routines:SSL23_GET_SERVER_HELLO:unknown protocol

Problem

You want to install rvm as a single user in a new linux but when trying to install it with the normal installation instruction:

curl -sSL https://get.rvm.io | bash -s stable --ruby

it fails with the following error:

curl: (35) error:140770FC:SSL routines:SSL23_GET_SERVER_HELLO:unknown protocol

Solution

You are behind a proxy server and you need to setup your environment variables for the server in your .profile file like the following (and make sure you source the file afterwards with . ~/.profile):

export http_proxy=http://xxx.xxx.xxx.xxx:port_no/
export https_proxy=https://xxx.xxx.xxx.xxx:port_no/

Replacing spaces with underscores in linux busybox

Problem

You want to replace the spaces in filenames (ie in Brennan’s B2 system), that uses busybox and you do not have all the linux commands available.

Solution

Use the following in the directory with the files (ie flac files). At the moment this command only works in the directory that is being run.

# find . -type f -name "*.flac" -exec ash -c 'mv "$0" "${0// /_}"' '{}' ';'