Showing posts with label Ubuntu. Show all posts
Showing posts with label Ubuntu. Show all posts

Wednesday, 16 May 2018

Ubuntu 17.10 Netplan

Netplan

Ubuntu 17.10 networking completely changed with the introduction of netplan, below the basic configuration to configure networking.

The new configuration files can be located at:

/etc/netplan/*.yaml
and to set a static IP address:

network:
 version: 2
 renderer: networkd
 ethernets:
   ens33:
     dhcp4: no
     dhcp6: no
     addresses: [192.168.1.2/24]
     gateway4: 192.168.1.1
     nameservers:
       addresses: [8.8.8.8,8.8.4.4]

and then to apply the changes:

sudo netplan apply

Sunday, 3 September 2017

U/Kubuntu Network Monitoring from CLI

I had to do some traffic monitoring per process and found nethogs to be perfect for the job.
Another application that helped a lot was tcptrack


Monday, 13 March 2017

Terminal commands for hard- reboot & shutdown

So i had the unfortunate scenario where I could not reboot or shutdown a Ubuntu server via the command line and no "out of band" access methods were available.

Luckily the following saved me:

Terminal command for hard-shutdown
sudo sh -c "echo o > /proc/sysrq-trigger"
Terminal command for hard-restart
sudo sh -c "echo b > /proc/sysrq-trigger"





Sunday, 19 June 2016

Edit PDF files in Ubuntu / remove text from PDF

Recently I had to remove a footer from a pdf document, as the document is over
100 pages and I need to do this on a monthly basis manual editing was not an option (oh and I am waaaay to lazy to do it manually)

After some research the following command line options worked like a charm:

Install qpdf and pdftk:

sudo apt-get install qpdf pdftk

Uncompress the pdf document:

qpdf --qdf --object-streams=disable source.pdf uncompressed.pdf

Then remove the text (footer) with the following sed:
sed -e "s/string to be removed/ /g" <uncompressed.pdf >removed.pdf

And lastly repair the pdf and compress it again.
pdftk removed.pdf output target.pdf compress

remember to clean up and remove all the interim files.


Monday, 6 June 2016

Easy way to determine missing file on Ubuntu

If you experience something like the following:

libXi.so.6: cannot open shared object file: No such file or directory 
apt-file can come in very handy,


sudo apt-get install apt-file 
then the following commands to identify and install the correct object containing the missing file.

sudo apt-get install apt-file 
apt-file update
apt-file search libXi.so.6 
libxi6: /usr/lib/x86_64-linux-gnu/libXi.so.6
sudo apt-get install libxi6  

Wednesday, 25 May 2016

Splitting FLAC files based on CUE

image from https://en.wikipedia.org/wiki/FLAC
Install the following packages
  • cuetools
  • shntool
  • flac

sudo apt-get install cuetools shntool flac

Now the FLAC file can be split as follows:

cuebreakpoints inputfile.cue | shnsplit -o flac inputfile.flac

The result will be as follows: 
split-track01.flac
split-track02.flac
....



Saturday, 2 April 2016

Ubuntu - merge Video files

The following applications can be used to concatenate video files.

Some ways to determine details of the media files :
ffprobe file.mp4
ffmpeg -i file.mp4

Extracting AC3 audio with FFMpeg

ffmpeg -i video.avi -acodec copy audio.ac3
or if there are multiple audio streams use the map to select the correct stream to extract

ffmpeg -i my_input_file.m4v -map 0:2 -c:a copy output_file.ac3 

MP4

sudo apt-get install gpac 
 MP4Box -add file1.mp4 -cat file2.mp4 NameofCombinedFile.mp4

Update:

And a way with ffmpeg (if all files are the same format):
ffmpeg -f concat -i <(for f in ./*.mp4; do echo "file '$PWD/$f'"; done) -c copy ../destination.mp4

Update2:

And to compress the mp4 afterwards for something like Youtube:
ffmpeg -i source.mp4 -codec:v libx264 -crf 21 -bf 2 -flags +cgop -pix_fmt yuv420p -codec:a aac -strict -2 -b:a 384k -r:a 48000 -movflags faststart target.mp4
Update 3: 

to add a audio channel to a video file:
MP4Box -new -add OriginalMovie.mp4 -add Track2.mp3#audio:delay=300 Output.mp4

MKV

sudo apt-get install mkvtoolnix

mkvmerge [global options] {-o out} [options1] {file1} [[options2] {file2}] [@optionsfile] 

AVI

sudo apt-get install transcode transcode-utils
avimerge -i part1.avi part2.avi -o joinedfile.avi

 




Sunday, 6 March 2016

Ubuntu - Node link to nodejs


If you use nodemon or another nodule that refer to node and not nodejs you can create a symbolic link:



sudo ln -s "$(which nodejs)" /usr/bin/node

Monday, 8 June 2015

Graylog2 not starting





I had a issue recently where I had to hard reset a server, afterwards Graylog2 would not start up.
Upon investigation it was found that mongoDB did not start up, this was due to a .lock file still present (not cleanly removed on reset)

to remove the lock:
sudo rm /var/lib/mongodb/mongod.lock

and then start mongodb with


sudo service mongodb start

If it allocates a process id (pid) to it you know it is up and running, can be further confirmed with 
sudo service mongodb status







Tuesday, 5 May 2015

Streaming music via Airplay from Ubuntu to Pioneer VSX-922



So after numerous complaints from my wife that the music setup in our house is not user friendly for her and she can only listen to ad-hoc music from the laptop (as a iPod have a playlist synced to it) I did some research and surprisingly found that pulseaudio had a Airplay module (raop)
The Pioneer amp needed UDP and not TCP streaming as per the native module, so I had to compile and create a icon on the desktop to "click and then listen to music"
That approach is sort of user friendly (still a few clicks to swop between the two pulseaudio versions but it works) next step is to fully automate it.
Installation: 
The complete installation instructions can be found here : http://hfujita.github.io/pulseaudio-raop2/

But the steps are summarised below:


sudo apt-get install build-essential paprefs git pulseaudio-module-raop intltool
sudo apt-get build-dep pulseaudio 
git clone https://github.com/hfujita/pulseaudio-raop2.git
cd pulseaudio-raop2
 ./autogen.sh
  CFLAGS="-ggdb3 -O0" LDFLAGS="-ggdb3" ./configure --prefix=$HOME --enable-x11 --disable-hal-compat
  make  

Thenyou need to configure it to discover AirPlay devices on the network

paprefs &

In the Network Access tab, turn on Make discoverable Apple AirTunes sound devices available locally


Then I wrote a little bash script named "music on amp" with a popup instructing her what to do next.

So currently it is a "guided automation" but it works.

Desktop icon: (music_on_amp.desktop)

[Desktop Entry]
Encoding=UTF-8
Name=Airplay
Comment=Play music to Airplay enabled devices
Exec=/home/user/listen_on_Pioneer.sh
Icon=/home/user/Pictures/airplay.png
Type=Application
Name[en_GB]=Music on AMP

Bash script: (listen_on_pioneer.sh)
#!/bin/bash
# source installed from http://hfujita.github.io/pulseaudio-raop2/
# kill the running pulseaudio
pulseaudio -k
cd ~/pulseaudio-raop2
./src/pulseaudio -n -F src/default.pa -p $(pwd)/src/ &
zenity --info --text 'Dear wife, Please select VSX-922 on next box that will pop up and close' unity-control-center sound
notify-send "Now open Amarok & Enjoy your music my love ..."

I have added a icon & script to change the music back to the laptop (as the Pioneer kept on changing to media source when the laptop send a notification or played music)

Bash script: (listen_on_pc.sh)
#!/bin/bash # kill the running pulseaudio pulseaudio -k
pulseaudio -D # to list the sink # pacmd list-sinks | grep -e 'name:' -e 'index' pacmd set-default-sink 1 pulseaudio -D notify-send "Music will play on PC."

this will kill and start the original pulseaudio and set the source (sink) to the in build speakers.


Wednesday, 25 March 2015

Citrix Receiver on K/Ubuntu 14.10


Installing the Citrix client became a lot easier with time.
Only download the latest version from Citrix website here (time of writing it was icaclient_13.1.0.285639_amd64.deb ) and install.

For Firefox; restart your browser and ensure the plugin is set to "Always Activate"


Should you encounter a SSL Error 61 afterwards just link the Firefox certificates to the Citrix ICAClient keystore :

sudo ln /usr/share/ca-certificates/mozilla/* /opt/Citrix/ICAClient/keystore/cacerts

That should sort out the error.

Handy links:
https://help.ubuntu.com/community/CitrixICAClientHowTo

Monday, 23 June 2014

How to set MTU on Linux interface



The MTU can be set with:
$ sudo ip link set dev tun0 mtu 1350

It can be tested with
$ ip a s 

And will show something like the below:
5: tun0: <POINTOPOINT,MULTICAST,NOARP,UP,LOWER_UP> mtu 1350 qdisc pfifo_fast state UNKNOWN group default qlen 100

link/none 

Friday, 20 June 2014

Ubuntu bulk rename files

If you don't want to use the command line to rename files the following application "pyrenamer" have a lot of functionality and work a charm.


With pyRenamer you can change the name of several files at the same time easily.
→ You can use patterns to rename files.
→ You can use search & replace to rename files.
→ You can use common substitutions.
→ You can manually rename selected files.
→ You can rename images using their metadata.
→ You can rename music using its metadata.

To install it:
sudo apt-get install pyrenamer

Sunday, 2 March 2014

Postgresql on Ubuntu server

Install
To install use the command line and type:


 sudo apt-get install postgresql postgresql-contrib
 
This will install the latest version available in your Ubuntu release and the commonly used add-ons for it.
We then need to change the password for the postgres database user; as postgres we execute the psql command

sudo -u postgres psql postgres
 
and give the user a password

\password postgres
 
type a password and quit psql with Ctrl+D or \quit
to set a *nix password for the user use the

sudo passwd postgres
 
and type the new *nix password for the user

User access
Then to give users access amend the

/etc/postgresql/current/main/pg_hba.conf 
 
and add something like below (granting all users on subnet 10.0.0.0 255.255.255.0 access to all databases with username / password method)

typedatabaseuserip addressmethod
hostallall10.0.0.0/24md5


And make sure postgresql listen on the correct interface / ip address in

/etc/postgresql/current/main/postgresql.conf 
 
by configuring the listen_addresses. Default only listen on localhost.

This can then be tested with the following from a host on the 10.0.0.0/24 subnet:

psql -h 10.0.0.1 -U postgres -d postgres

Add a database and spesific user for it

To create a database with a user that have full rights on the database, use the following command:
sudo -u postgres createuser -D -A -P myuser
sudo -u postgres createdb -O myuser mydb
 
Else install pgadmin to manage the database.


Friday, 23 August 2013

Installing Omnikey CardMan 3x21 in Ubuntu

The OmniKey uses the PCSC spesification, PC/SC (short for "Personal Computer/Smart Card") is a specification for smart-card integration into computer environments.

On Ubuntu Raring (13.04) this can be installed via:
sudo apt-get install pcscd 
sudo apt-get install pcsc-tools

Then download the latest firmware from the hidglobal website (search for the PC/SC CCID version) for x64 system it would be : "CardMan 3x21 PC/SC CCID for Linux X64"

Then unpack the file and run the installer:
cd /home/cccam/ifdokccid_lnx_x64-3.7.0/ 
chmod 755 install
sudo ./install

and lastly run the scanner to search for a card reader in a terminal window
cd 
pcsc_scan

if all go according to plan the following should see:
user@pc:~$ pcsc_scan 
PC/SC device scanner
V 1.4.21 (c) 2001-2011, Ludovic Rousseau <ludovic.rousseau@free.fr>
Compiled with PC/SC lite version: 1.8.6
Using reader plug'n play mechanism
Scanning present readers...
0: OMNIKEY AG CardMan 3021 00 00
Fri Aug 23 20:08:37 2013
Reader 0: OMNIKEY AG CardMan 3021 00 00
  Card state: Card removed, 

Watch SkyGo in Ubuntu

A great new project called pipelight launched that enable the playback of DRM enabled content via a browser plugin in native linux browsers like Firefox and Chrome.

https://launchpad.net/pipelight

I have tested it on Google Chrome 29 and with  a few changes as described as below I could playback SkyGo on my laptop.

The biggest challenge was the fact that SkyGo use the Silverlight 5 libraries and need to report a  "Windows User Agent e.g. Firefox 15 for Windows".

First step is to install pipelight
sudo apt-add-repository ppa:ehoover/compholio
sudo apt-add-repository ppa:mqchael/pipelight-daily
sudo apt-get update
sudo apt-get install pipelight

after that install SilverLight 5.0

sudo apt-get install wine-silverlight5.0-installer

Copy the default configuration file in your user directory:
cp /usr/share/pipelight/pipelight ~/.config/pipelight

and adjust the configuration ~/.config/pipelight such that it matches the specific Silverlight version:
dllPath = c:\Program Files\Silverlight\5.0.61118.0\
silverlightVersion = silverlight5.0

For SkyGo to work change the following as well
fakeVersion = 5.1.20513.0
overwriteArg = minRuntimeVersion=5.0.61118.0

For Chrome install User Agent Switcher  extension and select Windows Firefox 15 from the extension preferences to ensure it reports the correct user agent to Sky. Open the browser and select Firefox 15.
In order to force a reinstallation first close all your browsers and then delete the ~/.wine-pipelight directory.


It will then install the correct Silverlight and apply the "fake version"

Type chrome://plugins/ in the address bar to ensure the plugin loaded correctly.

my complete pipelight config file:

user@pc:~$ egrep -v "^$|^[[:space:]]*#" ~/.config/pipelight
winePath = /opt/wine-compholio/
winePrefix = $HOME/.wine-pipelight/
wineArch = win32
wineDLLOverrides = mscoree,mshtml=
pluginLoaderPath = /usr/share/pipelight/pluginloader.exe
gccRuntimeDlls = /usr/lib/gcc/i686-w64-mingw32/4.6/
dllPath = c:\Program Files\Silverlight\5.0.61118.0\
dllName = npctrl.dll
fakeVersion = 5.1.20513.0
overwriteArg = minRuntimeVersion=5.0.61118.0
overwriteArg = enableGPUAcceleration=false
windowlessMode = false
embed = true
dependencyInstaller = /usr/share/wine-browser-installer/install-dependency
silverlightVersion = silverlight5.0
operaDetection = true
len@madbuntu:~$ sudo apt-get install pipe
pipebench             pipemeter             pipenightdreams-data
pipelight             pipenightdreams       pipewalker
user@pc:~$

Sunday, 3 February 2013

Add ‘Open in Terminal’ in Nautilus

This simple and brief tutorial is going to show you how to add “Open in Terminal” option on Ubuntu Nautilus’ context menu so that you can quickly open up a terminal window and automatically navigate to the selected directory.
Hit Ctrl+Alt+T to open up a terminal window, copy and paste this command and hit enter to install nautilus-open-terminal package:
sudo apt-get install nautilus-open-terminal
or click on this link


then restart or run this command
nautilus -q

Thursday, 31 January 2013

Using 635M Nvidia via Bumblebee on Ubuntu 12.10 64bit

After installing and re-installing the drivers multiple times the following order and packages worked for me. (Basically donig the same as most blogs advise but loaded the Nvidia current updates and configured Bumblebee to use it)

sudo apt-get install bumblebee bumblebee-nvidia linux-headers-generic

sudo apt-get install nvidia-current-updates

then edit /etc/bumblebee/bumblebee.conf

gedit /etc/bumblebee/bumblebee.conf
Driver=nvidia
KernelDriver=nvidia-current-updates
LibraryPath=/usr/lib/nvidia-current-updates:/usr/lib32/nvidia-current-updates
XorgModulePath=/usr/lib/nvidia-current-updates/xorg,/usr/lib/xorg/modules
reboot and test

user@machine:~$ glxspheres
Polygons in scene: 62464
Visual ID of window: 0xb5
Context is Direct
OpenGL Renderer: Mesa DRI Intel(R) Ivybridge Mobile
59.965973 frames/sec - 66.922026 Mpixels/sec
59.915626 frames/sec - 66.865838 Mpixels/sec
59.936809 frames/sec - 66.889479 Mpixels/sec
59.938094 frames/sec - 66.890913 Mpixels/sec
59.933819 frames/sec - 66.886142 Mpixels/sec
59.936031 frames/sec - 66.888611 Mpixels/sec
59.938894 frames/sec - 66.891805 Mpixels/sec
user@machine:~$ optirun glxspheres
Polygons in scene: 62464
Visual ID of window: 0x21
Context is Direct
OpenGL Renderer: GeForce GT 635M/PCIe/SSE2
132.639584 frames/sec - 148.025776 Mpixels/sec
144.849601 frames/sec - 161.652154 Mpixels/sec
143.661287 frames/sec - 160.325996 Mpixels/sec
143.061059 frames/sec - 159.656142 Mpixels/sec
142.425431 frames/sec - 158.946781 Mpixels/sec
152.831347 frames/sec - 170.559784 Mpixels/sec
user@machine:~$


Steam commands for different games:
Left 4 Dead 2 Beta - LD_PRELOAD=./left4dead2/bin/matchmaking.so vblank_mode=0 PRIMUS_SYNC=1 STEAM_RUNTIME=1 primusrun %command%
Dota 2 - optirun --bridge primus %command%
Counter Strike - vblank_mode=0 primusrun %command%

Friday, 18 January 2013

Ubuntu create launcher in unity

I wanted to create some custom launchers on Ubuntu in order to cleanup my desktop and add them to the Unity dash and found

Create-launcher a brilliant app in the Ubuntu Software Centre at https://apps.ubuntu.com/cat/applications/quantal/create-launcher/

To install it just click the below:

Get it from the Ubuntu Software Centre!

Sunday, 11 November 2012

How to install Skype on Ubuntu 12.10 Quantal Quetzal

Type the following in a terminal

sudo add-apt-repository "deb http://archive.canonical.com/ $(lsb_release -sc) partner"

to add the correct repository and then to install skype

sudo apt-get update && sudo apt-get install skype