If you need to know what dns servers you are using on Ubuntu then this command will help:
nm-tool | tail -n 8
If you need to know what dns servers you are using on Ubuntu then this command will help:
nm-tool | tail -n 8
You might want rotate an image from the command line using the command line in Ubuntu. This is really usefull if you are stripting pdf manipulations.
sudo apt-get install pdftk
Then
pdftk input.pdf cat 1east output output.pdf
Happy rotating.
I just installed a new Bacula client but for some reason the server could not connect to it. I found this out by trying to get the status of the client on the server with the following command:
sudo bconsole status client=my.client-rd
Here is the things that I checked on the server.
Step 1 – Check that the service bacula-fd is started:
sudo service bacula-fd status
Step 2 – Check the bacula-fd process is bound to the port 9102
sudo netstat -an|grep 9102
Step 3 – Check that you can telnet into the client port from the server.
telnet ip.ad.dr.ess 9102
I found the the client configuration did have the correct client ipaddress but each of these checks enabled me to narrow down the problem.
I just upgraded Ubuntu and selected the wrong location to install Grub onto. Basically, I installed Grub on /dev/sda1 and not /dev/sda and so I need to repair and installing grub.
I got out an Ubuntu installer cd which is essential a live cd and booted in it up. Then mounted the sda1 partition:
sudo mount /dev/sda1 /mnt
Grub then needs to have access to /dev so:
sudo mount --bind /dev /mnt/dev
To install Grub on sda then:
grub-install /dev/sda --root-directory=/mnt/ /dev/sda
Note: we are using the –root-directory option rather than changing the root directory using the chroot command which sometimes doesn’t work on a live CD.
For a tutorial with more words these two pages might helped you learn more:
If you are install Grub – you will might be given the choice of:
/dev/sda /dev/sda1
The answer is to install it on /dev/sda
Note – If you install grub on a partition (such as sda1) it will only work if you are are chain-loading your bootloader.
If you are creating a KVM host you can sometimes get the error such XML error: expected unicast mac address. Basically, you if you have manually entered a mac address which meets the Unicast standard then it will cause problems.
Here is a quick way of generating a proper MAC Address:
openssl rand 6 | xxd -p | sed 's/\(..\)/\1:/g; s/:$//'
There is a method of hacking php using a security flaw in php in how it handles exif meta data embedded in jpeg, png or gif images. You describe this as an EXIF injection attack. As a precaution it is a good idea to strip all EXIF information from any images that are uploaded to your website.
I have found these two tools really useful to do this and this is a quick outline of how we used them:
Removing EXIF meta data from .jpg on Ubuntu / PHP
There is a really good tool called exiftool. There is a version in the Ubuntu repositories – so it is super easy to install.
apt-get install libimage-exiftool-perl
You can then strip exif meta from a jpeg using the command:
exiftool -all= filename.jpg
So in php this would look like this:
$output = exec(sprintf("exiftool -all= %s", escapeshellarg($_image_path)));
Removing EXIF meta data from .png images on Ubuntu / PHP
The best tool for removing exif information from .pngs is Optipng. You can install optipng on Ubuntu from source using this recipe.
apt-get install optipng
and so again in php it would look something like this:
$output = exec(sprintf('optipng -strip all %s', escapeshellarg($_image_path)));
I hope this helps someone.
On our Ubuntu 13.10 server, I had created an apache configuration file for a virtual host however, I could not enable it using a2ensite. The file was here:
/etc/apache2/sites-available/www.example.com
I tried to enable it:
a2ensite www.example.com
However, the command complained that ERROR: Site www.example.com does not exist! The files clearly exists. It turns out the this command only works if the file ends with .conf. So
mv www.example.com www.example.com.conf a2ensite www.example.com.conf
Voila it now work. Why or why doesn’t the developer give useful error messages. For example they should have write. Error – the files doesn’t have a .conf on the end!
We just had a problem with our DHCP server and there seems to be another dhcp server on the network. To find this I used Wireshark on my Ubuntu machine to find the problem.
1 – Install wireshark
apt-get install wireshark
2 – Launch wireshark with permissions to read the network interfaces.
You can either do this by runnning Wireshark as root (which is really not recommended but a quick hack if you need to get the job done). Or you can give your user permission to read the interfaces which is much better in the longterm.
2.1 – To give your user permission to capture network interfaces do the following:
sudo dpkg-reconfigure wireshark-common
This will ask you the following question. Answer Yes.
This creates a group called wireshark and anyone in this group can capture network data on the interface.
2.2 – Add you user the wireshark group.
sudo adduser $USER wireshark
2.3 – Logout and log back in
For you group permissions to change – you need to log out and then log in again. Alternatively, you can just restart your computer.
3 – Start Capturing With Wireshark
Launch Wireshark either from your launcher or using terminal “wireshark”. On the start screen you should see a list of interfaces on the left hand side. Select the interface you would like to capture data from and press the start button.
4 – Filtering For “bootp” messages
You can then filter Wireshark just to show dhcp messages by filtering for bootp message but typing “bootp” and clicking apply.
5 – Find all the offer packets
If you have multiple DHCP servers – you will have multiple offer packets. You can filter the messages by bringing up the packet details
click View -> Packet Details
This will show the packet details below the message list like so.
You should then go into “Bootstrap Protocol” -> “Options: DHCP Message Type” and right click on “DHCP: Offer” and select “Apply As Filter”.
This will then filter all dhcp offers and you will be able to see what servers are responding on the system.
Great YouTube Video Tutorial
There is also a good wireshark dhcp tutorial on youtube which shows this in action. It is a Windows focused tutorial but explains the other general concepts really well.
I hope this helps someone. Let me know if you have any suggestions of how this tutorial can be improved.
If you need to remove all the old kernels which were not currently being used to free up some space on the boot partition then this will do it for you.
sudo apt-get remove --purge $(dpkg -l 'linux-*' | sed '/^ii/!d;/'"$(uname -r | sed "s/\(.*\)-\([^0-9]\+\)/\1/")"'/d;s/^[^ ]* [^ ]* \([^ ]*\).*/\1/;/[0-9]/!d')