ranger – try terminal file manager

ranger is a terminal file manager, just install and run and have some fun.

Tip: You might want to try it on uxrvt terminal and in Photos folder once.

 

Name : ranger
Version : 1.7.2
Release : 8.fc28
Arch : noarch
Size : 1.2 M
Source : ranger-1.7.2-8.fc28.src.rpm
Repo : @System
From repo : fedora
Summary : A flexible console file manager
URL : http://savannah.nongnu.org/projects/ranger/
License : GPLv3+
Description : Ranger is a free console file manager that gives you greater flexibility and a
: good overview of your files without having to leave your *nix console. It
: visualizes the directory tree in two dimensions: the directory hierarchy on
: one, lists of files on the other, with a preview to the right so you know where
: you’ll be going.

Display IP address in console login screen

Here is one liner that will add the current IP address in the console login screen (if you are not running X as is case for servers):

 (ip -o -4 a| awk '$2 !="lo" {print "\nIP Address ::"$4}' |tr '\n' ',';echo)>>/etc/issue

Just execute the above command as root. It will add the required code in “/etc/issue” to display the IP address. BTW, you can also use “\4” or “\6” instead of that command to get the IP but that will not work with some old versions of Linux.

Port php mysql scripts to php 7.0 from 5.x version

Recently I got a script or series of scripts that were written for PHP 5.6x and hence used mysql_connect which as you know by now does not work with PHP 7.0. Since there were number of scripts, I thought it would be waste of time to change them manually and wrote a script to fix them. If you have similar situation then probably this few lines could help you.

Since my scripts did not use all the functions so I did not put the sed commands for all of them but you get the idea 🙂

#!/bin/bash - 
#===============================================================================
#
#          FILE: fix_mysql.sh
# 
#         USAGE: ./fix_mysql.sh 
# 
#   DESCRIPTION: 
# 
#       OPTIONS: ---
#  REQUIREMENTS: ---
#          BUGS: ---
#         NOTES: ---
#        AUTHOR: Amit Agarwal (aka), 
#  ORGANIZATION: 
#       CREATED: 03/23/2018 16:35
# Last modified: Fri Mar 23, 2018  04:36PM
#      REVISION:  ---
#===============================================================================

set -o nounset                              # Treat unset variables as an error


### Run as 
#### find . -type f -name \*php -exec ~/fixmysql.sh {} \;

####

# mysql_affected_rows -> mysqli_affected_rows($link)
# mysql_close -> mysqli_close($link)
# mysql_data_seek -> mysqli_data_seek( $result, $offset)
# mysql_errno -> mysqli_errno( $link)
# mysql_error -> mysqli_error( $link)
# mysql_fetch_array -> mysqli_fetch_array( $result, $type)
# mysql_fetch_assoc -> mysqli_fetch_assoc( $result)
# mysql_fetch_lengths -> mysqli_fetch_lengths( $result )
# mysql_fetch_object -> mysqli_fetch_object( $result, $class, $params)
# mysql_fetch_row -> mysqli_fetch_row( $result)
# mysql_field_seek -> mysqli_field_seek( $result, $number)
# mysql_free_result -> mysqli_free_result(result)
# mysql_get_client_info -> mysqli_get_client_info( $link)
# mysql_get_host_info -> mysqli_get_host_info( $link)
# mysql_get_proto_info -> mysqli_get_proto_info( $link)
# mysql_get_server_info -> mysqli_get_server_info( $link)
# mysql_info -> mysqli_info( $link)
# mysql_insert_id -> mysqli_insert_id( $link)
# mysql_num_rows ->  mysqli_num_rows( $result)
# mysql_ping -> mysqli_ping( $link)
# mysql_query -> mysqli_query( $link, $query)
# mysql_real_escape_string -> mysqli_real_escape_string( $link)
# mysql_select_db - > mysqli_select_db( $link, $database)
# mysql_set_charset -> mysqli_set_charset( $link, $charset)
# mysql_stat -> mysqli_stat( $link)
# mysql_thread_id -> mysqli_thread_id( $link)
######


file=$1
sed -i 's/mysql_connect/mysqli_connect/g' $file
sed -i 's/mysql_query(/mysqli_query($con,/g' $file
sed -i 's/mysql_error/mysqli_error/g' $file
sed -i 's/mysql_select_db(/mysqli_select_db($con,/g' $file
sed -i 's/mysql_affected_rows/mysqli_affected_rows($con,/' $file
sed -i 's/mysql_escape_string(/mysqli_escape_string($con/' $file 
sed -i 's/mysql_real_escape_string(/mysqli_real_escape_string($con/' $file 
sed -i 's/mysql_fetch_array/mysqli_fetch_array/g' $file
sed -i 's/mysql_fetch_assoc/mysqli_fetch_assoc/g' $file
sed -i 's/mysql_fetch_row/mysqli_fetch_row/g' $file
sed -i 's/mysql_select_db/mysqli_select_db/g' $file