Converting documents from JPG to PDF or vice versa, compressing and scaling images is a relatively common task for me. After installing the required ImageMagick
package in Ubuntu, I tried running the convert
command but to my surprise, got the following error message:
$ convert source.jpg destination.pdf
convert-im6.q16: attempt to perform an operation not allowed by the security policy `PDF' @ error/constitute.c/IsCoderAuthorized/408.
After little searching I found the resolution as mention below.
Open the Terminal on type the command:
$ sudo vim /etc/ImageMagick-6/policy.xml
You will get the output based on the devices attached to you system:
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE policymap [
<!ELEMENT policymap (policy)+>
<!ATTLIST policymap xmlns CDATA #FIXED ''>
<!ELEMENT policy EMPTY>
<!ATTLIST policy xmlns CDATA #FIXED '' domain NMTOKEN #REQUIRED
name NMTOKEN #IMPLIED pattern CDATA #IMPLIED rights NMTOKEN #IMPLIED
stealth NMTOKEN #IMPLIED value CDATA #IMPLIED>
]>
<!--
Configure ImageMagick policies.
Domains include system, delegate, coder, filter, path, or resource.
Rights include none, read, write, execute and all. Use | to combine them,
for example: "read | write" to permit read from, or write to, a path.
......
Rules are processed in order. Here we want to restrict ImageMagick to only
read or write a small subset of proven web-safe image types:
<policy domain="delegate" rights="none" pattern="*" />
<policy domain="filter" rights="none" pattern="*" />
<policy domain="coder" rights="none" pattern="*" />
<policy domain="coder" rights="read|write" pattern="{GIF,JPEG,PNG,WEBP}" />
-->
<policymap>
<!-- <policy domain="system" name="shred" value="2"/> -->
......
<policy domain="coder" rights="none" pattern="PS" />
<policy domain="coder" rights="none" pattern="EPS" />
<policy domain="coder" rights="read | write" pattern="PDF" />
<policy domain="coder" rights="none" pattern="XPS" />
</policymap>
The only change is the highlighted line in which none
was replaced with read | write
and the file was saved. Now running the convert
command again worked as expected 👍🏼
The first time I purchased Dell's XPS 13 notebook was in 2015 and couldn't be more satisfied. Now I own Dell XPS 13 9380 with Ubuntu 18.04 pre-installed. After initial testing the hardware, I immediately installed a fresh 19.04 and everything was well supported.
However there is no proper was of enabling or disabling the Touchpad. In the Knowledge Base provided by Dell, there is no mention of Ubuntu even though the OS is officially supported. Dell had another link to the Linux issue which didn't look easy to follow. So I am sharing a more simpler fix.
Open the Terminal on type the command:
$ xinput list
You will get the output based on the devices attached to you system:
⎡ Virtual core pointer id=2 [master pointer (3)]
⎜ ↳ Virtual core XTEST pointer id=4 [slave pointer (2)]
⎜ ↳ ELAN2930:00 04F3:2930 id=10 [slave pointer (2)]
⎜ ↳ Logitech MX Anywhere 2S id=21 [slave pointer (2)]
⎜ ↳ DELL08AF:00 06CB:76AF Touchpad id=11 [slave pointer (2)]
⎣ Virtual core keyboard id=3 [master keyboard (2)]
↳ Virtual core XTEST keyboard id=5 [slave keyboard (3)]
↳ Video Bus id=6 [slave keyboard (3)]
↳ Power Button id=7 [slave keyboard (3)]
↳ Sleep Button id=8 [slave keyboard (3)]
↳ Integrated_Webcam_HD: Integrate id=9 [slave keyboard (3)]
↳ Intel HID events id=12 [slave keyboard (3)]
↳ Intel HID 5 button array id=13 [slave keyboard (3)]
↳ Dell WMI hotkeys id=14 [slave keyboard (3)]
↳ AT Translated Set 2 keyboard id=15 [slave keyboard (3)]
↳ Logitech MX Anywhere 2S id=22 [slave keyboard (3)]
For my case DELL08AF:00 06CB:76AF Touchpad id=11 [slave pointer (2)]
is line of which is telling me that the Touchpad is using the ID 11
, Perfect!
Now all I have to do is to disable this device using the command:
$ xinput --disable 11
Try using the Touchpad and it will not respond. To enable it again:
$ xinput --enable 11
And its done! Just in case you want to get the details of this device, run the command:
$ xinput list-props 11
In that case look for the Knowledge Base I have shared in the start and following those instructions.
In this tutorial, we will learn how to execute a bash script at upstart.
Upstart is an event-based replacement for the /sbin/init daemon which handles starting of tasks and services during boot, stopping them during shutdown and supervising them while the system is running.
Create a Job in /etc/init
.
sudo gedit /etc/init/sync_user.conf
Job configuration files are named as
<name>.conf
Add the following lines to sync_user.conf
start on filesystem and net-device-up IFACE!=lo
stop on runlevel [016]
script
exec bash -c 'path_to_bash_script_file/file_name start'
end script
To ensure that you haven't misused the Upstart syntax, use the init-checkconf command:
init-checkconf sync_user.conf
Then start the job
sudo start sync_user
start on filesystem and net-device-up IFACE=lo
Job will be started when the filesystem
is mounted and net-device-up IFACE=lo
event, which signifies the local network (for example, 127.0.0.0 for IPv4) is available.
stop on runlevel [016]
This ensures the job will be stopped on shutdown[0], when switching to single-user mode[1] and on reboot[6].
Runlevels for Debian and Ubuntu systems are generally as follows:
0 : System halt.
1 : Single-User mode.
2 : Graphical multi-user plus networking (DEFAULT)
3 : Same as "2", but not used.
4 : Same as "2", but not used.
5 : Same as "2", but not used.
6 : System reboot.
All job files must have either an
exec
orscript
stanza. This specifies what will be run for the job.
script
exec bash -c '/opt/local/our-sync-pkg-2.0/sync_users start'
end script
exec
gives the path to a binary on the filesystem and optional arguments to pass to it.
By default, Upstart uses "/bin/sh" to execute script sections. You can change the default shell.
But it can done in simplest way by executing this line:
exec bash -c '/opt/local/our-sync-pkg-2.0/sync_users start'
bash
in exec
is used because we're executing the bash script.
-c
option after bash
means that commands are read from string.
end script
will terminate the script.
This will work! If you have any suggestions on improving this post, let me know.
In this tutorial we will look through how to package some simple hello world script. A quote from debian maintainer's guide:
One thing is certain, though: to properly create and maintain Debian packages takes many hours. Make no mistake, for our system to work the maintainers need to be both technically competent and diligent.
We have many methods to create a Debian package In this tutorial we will use FPM.
This method requires minimum effort follow this if you don't want to upload to PPA. However it requires ruby gem and package name FPM. check wiki for further details.
mkdir -p ~/via-fpm/debian/usr/bin/
cd ~/via-fpm/debian/
touch ~/via-fpm/debian/usr/bin/hello-via-fpm.sh
gedit ~/via-fpm/debian/usr/bin/hello-via-fpm.sh
Add following lines to script.
#!/bin/bash
echo "hello debian packaging via fpm"
Save and close that file. whatever folder structure you will put in your source folder it will automatically copied into respected folders. There is no need to to copy them. For example if you want to put some sources file in /opt/local/sources then you must have same structure in you application source. Similarly usr/bin/ files will automatically copied to their respected folder in this case that will be /usr/bin.
Next we will come towards the scripts that will automatically run like preinstall , post install , pre un-install and post un-install . If you want to create user, directories, set permissions then these scrips are for you. You can use bash here.
In this demo we will use "postinst" script to set permission for ~/via-fpm/debian/usr/bin/hello-via-fpm.sh
create postint file in described location and add the following code.
mkdir -p opt/local/
touch opt/local/postinst
gedit opt/local/postinst
Set so that user can execute command from shell.
#!/bin/bash
set -e
sudo chmod +x ~/via-fpm/debian/usr/bin/hello-via-fpm.sh
exit 0
It't time for packaging.
cd ~/via-fpm
fpm --epoch 1 -s dir -e -C debian \
-a all -m "uncle demo <UncleDemo@example.com>" \
--description "our absurd debian package for demo via fpm" \
-v 1.0 -t deb -n hello-via-fpm --after-install debian/opt/local/postinst
Switches that we have used and their meaning
-epoch: Used for epoch value is somehow versioning number
-e: Edit the package spec before building. (default: false)
-C: Change directory to here before searching for files
-a: The architecture name. Usually matches 'uname -m'. For automatic values, you can use '-a all' or '-a: native'. These two strings will be translated into the correct value for your platform and target package type.
-m: The maintainer of this package. (default: "djhaskin987@djhaskin987-S301LA")
--description: add description
-v: specify version number
-t: output type
-n: Name to give to the package
--after-install: file to run after post install
Because it will automatically create necessary files like control, rules and lot other necessary stuff for you. There are other proper ways to do that using official Debian package management through which you can upload your package to PPA. That we will discuss in next demo.
To install that package either open via Ubuntu software center or run command sudo dpkg -i hello-via-fpm_1.0_all.deb
Now try to run command from shell hello-via-fpm.sh
to see that your package is installed now and further you can create your own with customizations.
The latest version of LibreOffice is here but unfortunately its not going to be available in Ubuntu 14.04 and 12.04 by default. But the good news is that we can upgrade existing version by typing these commands:
sudo add-apt-repository ppa:libreoffice/ppa
sudo apt-get update && sudo apt-get -y dist-upgrade
That should be enough! :-)
Ubuntu has a special account, named Guest
, which allows access (login) to the system without asking for any password. Although there are limitation applied to this account but maybe its not always desirable to have it. These steps will help in disabling it (tested under 12.04 and 14.04):
Open the file /etc/lightdm/lightdm.conf
and add the following line to it at the end:
allow-guest=false
If the file lightdm.conf
is missing, then paste the following contents in the blank file:
[SeatDefaults]
allow-guest=false
Once thats done, restart the relevant service:
sudo restart lightdm
This should work!
If you have made a fresh clean installation of Ubuntu 13.10, you would have noticed one announced missing feature. The Ubuntu One icons and context menu is missing from Nautilis (File Manager). Why is it missing?? Couldn’t find a valid reason even in Launchpad although Ubuntu One was supposed to be important to Ubuntu. Anyway…
To fix, you will need to install to packages from 13.04 and restart Nautilis. Follow these steps:
Download the required two packages:
wget https://launchpad.net/ubuntu/+source/ubuntuone-client-gnome/4.2.0-0ubuntu1/+build/4405128/+files/ubuntuone-client-gnome_4.2.0-0ubuntu1_amd64.deb -O ubuntuone-client-gnome_4.2.0-0ubuntu1_amd64.deb
wget https://launchpad.net/ubuntu/+source/ubuntuone-client/4.2.0-0ubuntu1/+build/4405191/+files/libsyncdaemon-1.0-1_4.2.0-0ubuntu1_amd64.deb -O libsyncdaemon-1.0-1_4.2.0-0ubuntu1_amd64.deb
Install them:
sudo dpkg -i ubuntuone-client-gnome_4.2.0-0ubuntu1_amd64.deb
sudo dpkg -i libsyncdaemon-1.0-1_4.2.0-0ubuntu1_amd64.deb
Restart Nautilus:
nautilus -q
Back to the day and satisfied days 🙂
It is now possible to have multiple audio tracks in a single video. This is becoming common for Movies and Documentaries. This way a single video is good for serving people of different lingual backgrounds. However, like me you might not be interested in all those tracks. In this tutorial, we will remove all the unwanted tracks.
The tool we will be using is avconv and in a previous post I have mentioned how to install it in Ubuntu, so I will not be going into the installation part again.
First of all we need to check on the track details and for that, run the following command (the extension can be mp4, mov, mkv, avi or any other):
avconv -i file_name.mkv
In my case, I got the following output:
avconv version 0.8.6-6:0.8.6-1ubuntu2, Copyright (c) 2000-2013 the Libav developers
built on Mar 30 2013 22:20:06 with gcc 4.7.2
[matroska,webm @ 0xc31d40] Estimating duration from bitrate, this may be inaccurate
Input #0, matroska,webm, from 'file_name.mkv':
Duration: 00:46:15.28, start: 0.000000, bitrate: 768 kb/s
Stream #0.0(eng): Video: h264 (High), yuv420p, 1280x720, PAR 1:1 DAR 16:9, 25 fps, 25 tbr, 1k tbn, 50 tbc (default)
Stream #0.1(rus): Audio: ac3, 48000 Hz, 5.1, s16, 384 kb/s (default)
Stream #0.2(eng): Audio: ac3, 48000 Hz, 5.1, s16, 384 kb/s
At least one output file must be specified
The lines in bold tell us how many tracks are there.
Since I have no interest in Russia audio, I would like to remove it. In my case I would like to keep the second track. Here is the command:
avconv -i file_name.mkv -map 0:0 -map 0:2 -acodec copy -vcodec copy output.mkv
If your track is different, for instance you want to keep the first track, replace -map 0:2
with -map 0:1
and it will work.
Another advantage you will get is a reduction in file size, which is always a good news. 🙂
To change the Screen Resolution in Ubuntu, simply type Display
in the Unity Launcher and run the application. The snapshot of the Display application is taken from Ubuntu 12.10 and is also the same in previous versions also. Similar application is available in other Linux distributions.
But there is a handy command that can do the same thing even faster or can help you create a script (depends how creative and productive you plan to be). The command is simple:
xrandr
This will display all the possible resolution profiles available for the current system (more can also be added and you can find help on https://www.x.org/archive/X11R7.5/doc/man/man1/xrandr.1.html).
To change to a known resolution:
xrandr -s 1024x768
And you have it! 🙂
Document Foundation, the developers behind LibreOffice released Version 4.0 on 7th February 2013. Ubuntu 12.04 however is still stuck with Version 3.5 and Ubuntu 12.10 with Version 3.6 of LibreOffice. Its always nice to be up-to-date with the latest versions. This is what is covered in this post.
The first step is to install the PPA repository and there are two choices you have.
To Add 4.0 Repository (this will remain limited to 4.0 and its subversions only like 4.0.x):
sudo add-apt-repository ppa:libreoffice/libreoffice-4-0
To Add Latest Repository (also offers 4.0.x but later will automatically update to 4.x and above):
sudo add-apt-repository ppa:libreoffice/ppa
Which ever road you take, the next steps are the same. Run the update command and upgrade the distribution (simple upgrade won’t work):
sudo apt-get update
sudo apt-get dist-upgrade
And you have the latest LibreOffice 🙂
Today I was installing Ubuntu in my Olives School lab. There are 20 systems in total. After installing it in the first PC, I ran the Update and there were 443 of them which amounted for 337MB approx. As it can be imagined it took some time to get the first PC updated. This was clearly not what I was going to do with the rest and I had to come up with a solution.
When Ubuntu downloads these updates, it places them in /var/cache/apt/archives/
folder. In fact even after installing updates, they are not removed from the system. So a solution was simple:
Copy all the downloaded packages to a USB
On the next PC, run the command:
sudo cp [path-to-usb]/* /var/cache/apt/archives
Once all the files have been pasted, run the Update Manager tool and it will tell you that updates have been downloaded but not yet installed.
Click on Install :-)
In an earlier post, I mentioned about the Runlevels in Ubuntu and how its different from the rest of the Linux family. Each Runlevel can be configured to start with certain services. A tool to manage the Services in Ubuntu is sysv-rc-config
This tool can be installed using the command:
sudo apt-get install sysv-rc-conf
Once installed, it can be used as:
sudo sysv-rc-conf
This tool will display all the services and the runlevels. You can easily choose which services to load and which not to. The screenshot shows how it will appear. To exit the tool, press q
key.
Although I am not a fan of Internet Explorer but sometimes it cannot be ignored especially when few websites have limited their access to IE browsers only or some old websites with poor markup which only renders on IE.
Internet Explorer (IE 5, 5.5, 6 and 7) can be installed and run on any Linux distribution. The package can be found and downloaded from these links:
When installing IEs4Linux, the Linux X-Window may crash, giving you the following error message:
The program ‘ies4linux-gtk.py’ received an X Window System error.
This probably reflects a bug in the program.
The error was ‘RenderBadPicture (invalid Picture parameter)’.
(Details: serial 5546 error_code 158 request_code 148 minor_code 7)
(Note to programmers: normally, X errors are reported asynchronously;
that is, you will receive the error a while after causing it.
To debug your program, run it with the –sync command line
option to change this behavior. You can then get a meaningful
backtrace from your debugger if you break on the gdk_x_error() function.)
The workaround this is to use the non-GUI, command based installation. To install use the command:
./ies4linux --no-gui
For further help:
./ies4linux --help
I hope the day comes when all of this is not required and we have a true cross-browser web.
When we download video from Youtube or any other website, 90% chances are you are watching them using Flash Video Player whose format is FLV. Some of the videos uploaded in Youtube are sliced into multiple parts especially when Youtube only allowed you to upload a video of maximum 10 minute duration.
There is a simple but useful way of joining these files into a single under Ubuntu.
First you will need to install the package:
sudo apt-get install avidemux
Next, keeping the audio/video encoding unchanged, just join them (change the filenames accordingly):
mencoder -forceidx -of lavf -oac copy -ovc copy -o output.flv clip1.flv clip2.flv clip3.flv
Sometimes Google Chrome under Linux or Ubuntu gives the following error:
Your preferences can not be read. Some features may be unavailable and changes to preferences won’t be saved.
This is because the owner of the following files have been changed for some unknown reason:
Under /home/[user]/.config/google-chrome/
the file Locale State
and under /home/[user]/.config/google-chrome/Default
the file Preferences
.
Note: This tip works for Linux, for Windows the steps have not been personally tested.
If you are using Windows XP:
C:\Documents and Settings\[Username]\Local Settings\Application Data\Google\Chrome\User Data\Default
If you are using Windows 7:
C:\Users\[Username]\AppData\Local\Google\Chrome\User Data\Default
If you are using Linux:
/home/[Username]/.config/google-chrome/Default
Where user is the supposed name of the user.
To fix the problem, run the following commands (replacing user
with the actual username):
sudo chown user:user /home/user/.config/google-chrome/Locale\ State
sudo chown user:user /home/user/.config/google-chrome/Default/Preferences
To fix the permissions in Windows, visit this link: How do I change folder and file Permissions?. Simply deleting the Google
folder in the paths specified will also help.
InshAllah the problem will be solved!
Installing these packages on Ubuntu is very simple. Just execute the following commands and you will be done with everything.
sudo apt-get install apache2
sudo apt-get install php5 libapache2-mod-php5
sudo apt-get install mysql-server libapache2-mod-auth-mysql php5-mysql
sudo /etc/init.d/apache2 restart
sudo apt-get install mysql-query-browser
MySQL has officially declared EOL (End of Life) for Query Browser. You can check it on http://dev.mysql.com/doc/query-browser/en/
MySQL Workbench is its replacement and its now available in Ubuntu 12.04 repositories:
sudo apt-get install mysql-workbench
All features are supported by Workbench. Additionally you can check my answer on askubuntu.com
With the release of Ubuntu 10.04, the Window buttons have been moved from the right side to the left. In other words, from Windows way to MAC style.
To get it back to where I was so used to, I found this very helpful post: http://www.howtogeek.com/howto/13535/move-window-buttons-back-to-the-right-in-ubuntu-10.04/
Old is gold!
Mounting ISO files in Linux is quite straight forward and simple e.g. using the mounter function in Ubuntu straight from the context menu or by using a command line like this:
mount -o loop image.iso /mnt
Anyway mounting BIN/CUE image files is not that straight forward as they’ll need conversion to ISO before mounting, however the process is quite simple, but it need a small application called bchunk. The bchunk package contains a UNIX/C rewrite of the BinChunker program. It converts a CD image in a .bin/.cue format (sometimes .raw/.cue) into a set of .iso and .cdr/.wav tracks. The .bin/.cue format is used by some non-UNIX CD-writing software, but is not supported on most other CD-writing programs.
To install the package:
sudo aptitude install bchunk
In order to convert a bin/cue image set:
bchunk image.bin image.cue image.iso
Then to mount the iso image using this command:
mount -o loop image.iso /mnt
Now you can view the contents in the folder /mnt
.
Support for RAR and 7-ZIP compressed files can be added to Ubuntu simply by running the following commands:
sudo apt-get update
sudo apt-get install unrar p7zip
Google provides repositories for installing its packages in various Linux distributions. These repositories are automatically added if you simply download, for instance, Google Chrome and install it.
You can visit the following link providing by Google to add the repo using command line also: http://www.google.com/linuxrepositories/
Update and upgrade the package manager after following the mentioned steps.
With Ubuntu 9.10, GRUB 2 is installed by default as the boot loader (although it is still in beta version). The files and commands have been changed.
GRUB 2 settings can be viewed using the command:
sudo gedit /boot/grub/grub.cfg
(You can replace gedit
with vim
or whichever editor you prefer). This grub.cfg
contains the menu entries but it is NOT recommended to change anything in this file. Infact, this file is compiled.
To alter the default menu item, timeout etc, open the grub
file using the command:
sudo gedit /etc/default/grub
Make the required changes, for instance in my case I made you changes:
GRUB_DEFAULT=4
GRUB_GFXMODE=1280x800
After making the changes, save the file and compile the output using the command:
sudo update-grub
Reboot and see the results!
Runlevel is the mode in which the operating system like Linux is running. Conventionally, seven runlevels from 0 to 6 existed. Where 0 meant shutdown and 6 meant Reboot.
In previous versions, Ubuntu used to the /etc/inittab
file to manage runlevels, just like most of the Linux distributions. This file was based on traditional init
daemon, which is used to perform system startup tasks. This was replaced in Ubuntu 6.10 (Release date: 26th-Oct-2006) with Upstart, an event based daemon. Now there are several files under the /etc/events.d/
directory.
The runlevels that Ubuntu handles by default are:
For more details visit Ubuntu’s Upstart section.
Normally, a system can not communicate with another system belonging to a different network address. IP forwarding is the mechanism of forwarding an IP packet from one network (example: 192.168.1.0) to another network (example: 192.168.2.0).
By default, IP forwarding is disabled in linux. The current setting can be verfied using the command:
cat /proc/sys/net/ipv4/ip_forward
This will give the output: 0
Another way to test is to run:
sysctl net.ipv4.ip_forward
This will give the output:
net.ipv4.ip_forward = 0
Where 0
means disabled and 1
means enabled.
Running either of commands will perform the task:
sysctl -w net.ipv4.ip_forward = 1
or
echo 1 > /proc/sys/net/ipv4/ip_forward
But this is only for the current running kernel session. After reboot the old values will be restored.
Open the required in VIM or any other text editor:
vim /etc/sysctl.conf
Locate the line and modify it as under:
net.ipv4.ip_forward = 1
But these changes will not take effect unless the system is restarted or the command is run:
sysctl -p /etc/sysctll.conf
For Redhat systems, restarting the network service will automatically reload the changes to sysctl.conf
:
service network restart
On Ubuntu, this is also possible by restarting the procps
service:
/etc/init.d/procps.sh restart
For Debian distributions open the /etc/network/options
and make the following changes and restart the network
service or reboot:
ip_forward = yes
For Redhat distribution open /etc/sysconfig/network
and do the same:
FORWARD_IPV4 = true
The changes can be viewed using the commands mentioned above.