Random Tips And Tricks

In this post I will share you some random tips and tricks I use in my daily life, and I will update this post frequently.
Some of them will be commented, but not all.

Generate random strings

tr -cd '[:alnum:]' < /dev/./urandom | fold -w12 | head -n4
You can use these string for example as random generated passwords.

Run simple python http server

nohup python -m SimpleHTTPServer 8888 >>../access.log &
This will create a very simple http server on port 8888.
Useful for shearing files quickly and easily over http protocol.

Poor man's VPN with sshuttle

sshuttle -r [USER]@[HOSTNAME] --dns -v

Split MP3 into equal time length slices

Install required package: apt-get install poc-streamer
Split into 3mins slices:
mp3splt -t 3.00 [MP3 FILE] -o @n
Output will be: 01.mp3, 02.mp3, 04.mp3 . . . .

Convert Video to 1280X (lower quality)

It us useful when you want to convert your video files to lower quality.
avconv -y -i $MOVIE -vf "scale=1280:trunc(ow/a/2)*2" -vcodec libx264 -acodec libmp3lame $NEWNAME
* -y overwrite output files * -i input files * -vf scale=1280:trunc(ow/a/2)*2" --> Keep original ratio, and avoid "height not divisible by 2" error message. * -vcodec libx264 --> video codec * -acodec libmp3lame --> audio codec You can replace "1280" to any other values which is divisible by 2. (640,480,etc...)

LUA - delay function

Sometimes you have to use delay before the next function, and in this situation can be useful this little function.

function sleepAndContinueWithCommand(command)  
    print("sleepAndContinueWithCommand Function")
    tmr.alarm(6,2000,tmr.ALARM_SINGLE, function()

How to call it?

Modify Post Width of Ghost Blog

Change max-width in this section

/* Every post, on every page, gets this style on its <article> tag */
.post {
    position: relative;
    width: 80%;
    max-width: 1000px;
    margin: 4rem auto;
    padding-bottom: 4rem;
    border-bottom: #EBF2F6 1px solid;
    word-wrap: break-word;

Limit OprengePI CPU cores (enable/disable cores)

echo 1 >/sys/devices/system/cpu/cpu0/online  
echo 0 >/sys/devices/system/cpu/cpu1/online  
echo 0 >/sys/devices/system/cpu/cpu2/online  
echo 0 >/sys/devices/system/cpu/cpu3/online  

Check CPU temperature:


tar from/to remote machine

tar from remote machine:
ssh root@ "tar cfz - /etc /opt" >output.tar.gz
tar to remote machine:
tar cvf - *.sh | ssh vinyo@ "cat >~/test.tar.gz"

untar from remote machine
ssh vinyo@ "cat ~/test.tar.gz" | tar xv OR
ssh vinyo@ "cat ~/test.tar.gz" | tar xvf -
untar to remote machine
cat test.tar.gz | ssh "cd /home/vinyo/temp ; tar xv" OR
cat test.tar.gz | ssh "cd /home/vinyo/temp ; tar xvf -"

Raspberry - prevent to sleep Wifi

Find your Wifi chip module:
ls -la /sys/module/
Mine is:
Check power management status:
cat /sys/module/8189es/parameters/rtw_power_mgnt If it is equal to 0 then you are OK.
If not, create a file something like this:

cat /etc/modprobe.d/8189es.conf  
options 8189es rtw_power_mgnt=0 rtw_enusbss=0  


Rename OpenVZ container

vzctl set [CTID] --hostname [NEW HOSTNAME] --save

Unzip Each .zip File To Separate Directory

You have to be in the directory which contains the .zip files.
for Z in $( find . -type f -name '*.zip') ; do B=$( basename $Z ) ; F=${B%.*} ; mkdir $F ; unzip $Z -d $F ; done

Read Parameter File In Linux Shell (bash)

while IFS='=' read -r key value  
    echo "... $key='$value'"
    eval "$key='$value'"
done < $PARAM_FILE  


  • $PARAM_FILE --> File which contains the paramter and values.
  • IFS='=' Internal Field Separator. Parameter names and Values are separated by = sign. Example: appname=weblogic
  • eval "$key='$value'" --> This will create system environment.

Some Linux Console Fun

Try them out, if you are brave enough. :)

apt-get moo  
apt-get install sl  
apt-get install furtune  
apt-get install cowsay  
apt-get install figlet  

fortune | cowsay
figlet "Hello"

Run command without X display

This method can be useful when you want to run a command (which needs X11 display), but X11 display isn't running on your system.
Typical error message: failed to commit changes to dconf: Cannot autolaunch D-Bus without X11 $DISPLAY
The solution is: xvfb-run

xvfb-run - run specified X client or command in a virtual X server environment


apt-cache search xvfb-run  
xvfb - Virtual Framebuffer 'fake' X server

apt-get install xvfb  

How to use it?
xvfb-run --server-args="-screen 0, 1024x768x24" /usr/bin/ssconvert --export-type=Gnumeric_Excel:excel_dsf 20161105_090001.html 20161105_090001.xls
Or from a shell script:
xvfb-run --server-args="-screen 0, 1024x768x24" /usr/bin/wkhtmltopdf $*

There are 2 typical command I'm using with xvfb-run: ssconvert and wkhtmltopdf

Simple Image Viewer For Linux

feh -- image viewer and cataloguer

Failed To Install Cisco AnyConnect on Xubuntu 16.04

Error message: Failed to start vpnagentd.service: Unit vpnagentd.service not found.


apt install network-manager-openconnect  
systemctl daemon-reload  

Then restart the install.

-- NEXT PAGE (2) -->

Vincze Janos Istvan

Read more posts by this author.


Subscribe to Blog

Get the latest posts delivered right to your inbox.

or subscribe via RSS with Feedly!