Watch, Read, Listen
-
Create multiple symlink by changing name with command find
Let’s imagine that we have the following directory listing: $ ls -ls /data/db1/ total 4778688 1488 -rw-r–r– 1 dbmaster 760264 Feb 14 00:20 database_2016_file1 496 -rw-r–r– 1 dbmaster 251529 Dec 29 12:45 database_2016_file2 808960 -rw-r–r– 1 dbmaster 414187520 Jan 30 10:20 database_2016_file3 344 -rw-r–r– 1 dbmaster 172544 Mar 18 00:42 database_2016_file4 958528 -rw-r–r– 1 dbmaster…
-
Use wget/curl behind a proxy
If your machine is behind a proxy, you probably configured your browser for going through the proxy to reach Internet. But what about command line with curl and wget? If you want to add the proxy temporarily for some few installations for example, just type (by replacing URL and port with yours): export http_proxy=http://MyProxyURL:3128 export…
-
Reset root password on Linux
Who never forgot a root password on a running machine that you can’t reinstall totally? Most of the linux distributions do have a recovery partition that you can use for that on startup (I won’t detail this here). But if you don’t have this partition, you can still reset it using generic commands thanks to…
-
Some Apache servers do activate the DirectoryIndex so you can easily go through the directories listing over HTTP and download some files. It’ s often used for giving possibility to people to download multiple releases for a package/software. But in some cases, it can be useful to download the content of a full tree view.…
-
iTerm – Automatic mutliple panes with AppleScript
It’s often very useful to automate opening of multi panes with iTerm to execute many commands or getting access to many servers at the same time. This can be done through AppleScript. You can copy this script and save it as multi-panes.scpt #! /usr/bin/osascript — List actions to perform set actions to {¬ {action:”echo ‘I am…
-
Nagios plugin – Error “No such file or directory”
When trying to execute a nagios plugin, you’re getting this error: # /usr/lib/nagios/plugins/check_procs bash: /usr/lib/nagios/plugins/check_procs: No such file or directory But when checking further, the file does exist: # ls -l /usr/lib/nagios/plugins/check_procs -rwxr-xr-x 1 root root 124929 Jan 19 2016 /usr/lib/nagios/plugins/check_procs This can be due to some 32 bit libc libraries missing. To fix that,…
-
NRPE – Enable command args (Jessie, …)
With recent versions of NRPE server, the possibility to enable command args has been disabled. For example, on a Debian Jessie, you can get this kind of error on console: CHECK_NRPE: Received 0 bytes from daemon and in logs: Error: Request contained command arguments! !WARNING! This change can lead to security issue, this is why…
-
Apache – mod_auth compatibility for 2.2 and 2.4
Since Apache 2.4, mod_auth changed and some directive like Order allow,deny Allow from all that have been replaced with Require all granted If you want to automatically handle same configuration for multiple servers where different versions of Apache are installed, you can use this trick: <IfModule mod_version.c> <IfVersion < 2.4> Order allow,deny Allow from all…
-
PostgreSQL – Check value is in array
With PostgreSQL, if you have a field containing an Array and you want to get all the results containing this value in the array, you can use the following command. Here, we are looking for all the results in the table my_table containing my_value in the field my_array. SELECT * FROM my_table WHERE ‘my_value’=ANY(my_array) ORDER…
-
Add a confirmation dialog with bash
If you have a bash script doing some critical actions, it can be useful to add a confirmation dialog to double check with the user that he really wants to perform the action. Here is a very simple script allowing this kind of checking: #!/bin/bash echo “Welcome to your favourite script!” read -r -p “Are…