Difference between revisions of "Howto Ubuntu"

From DiLab
Jump to: navigation, search
(Other nice external links and howto-s)
(Making videos smaller)
 
(100 intermediate revisions by the same user not shown)
Line 1: Line 1:
{{TocRight}}
Notes about installing and setup of various apps and features in Ubuntu.


Notes for after a fresh ubuntu install:
* [[Mediawiki setup]]
* [[Leo:Ubuntu config | My ubuntu setup cache]]
* [[Mysql notes]]
* [[Octave setup]]
* [[Trac setup]]
* [[OpenOffice setup]]


See also
* [[Linux on MacBook]] - I want to run Ubuntu on my mac...


==Making videos smaller==
* [[ssh with a private-public key]]
Using ffmpeg with -crf between 24-28 may reduce your video. Smaller value is better quality but larger file.
* [[svn notes]] - Subversion
ffmpeg -i input.mp4 -vcodec libx264 -crf 24 output.mp4
* [[SciTe notes]] - the lightweight programmers editor
More [https://unix.stackexchange.com/questions/28803/how-can-i-reduce-a-videos-size-with-ffmpeg here].

==Working with Ubuntu from Windows 10==
Windows 10 has a feature for running Ubuntu shell within a window.
It is called [https://msdn.microsoft.com/en-us/commandline/wsl/install_guide Windows Subsystem for Linux]
This is how to enable it:
# Settings => Update & Security -> For Developers. Activate the “Developer Mode”
# Control Panel => Programs -> Programs and Features => Turn Windows Features On or Off. Enable the “Windows Subsystem for Linux (Beta)”
# Windows will (ask to) restart
# Under Start type "bash" and follow the prompts.
Now you can run "bash" to get a window with a Linux environment.

==Notes about installing and setup of various apps and features in Ubuntu==

==== General configuration ====
* Ubuntu setup
** [[Ubuntu:permissions | Users and permissions]] in Linux / Ubuntu
** [[Leo:Ubuntu_config | My config for a fresh Ubuntu]]

* Backup before the setup
** One easy way to backup the files that we have in Ubuntu is using "cp" command using the following switches: -r for recursive through directories, -p for preserving the attributes and ownership information, and -x to stay in one file system, not following the links. Finally, you can include -v for verbose, listing the files copied:
cp -rpx <source-path> <target-path>
* Restoring the backup files is the same process.

==== Web server and clients ====
* Apache
** [[Apache:configuration]]
** [[Apache:htaccess | Secure directories under Apache (htaccess style)]]
* [[RoR_setup | Ruby and Rails]] and RVM

* [[Mediawiki setup | Mediawiki]]
* [[Mysql notes | Mysql]]

==== Communications ====
* [[SSH]]
* [[simpleproxy]] - Simple TCP proxy for linux
* [[simpleproxy]] - Simple TCP proxy for linux
* [[iptables]] - managing the firewall


==== Development ====
* [[svn notes | SVN]] - Subversion
* [[grep notes | Grep]] - grep and egrep usage tips
* [[SDCC]]
* [[Octave setup | Octave]] (MatLab alternative)
* [[GNU Make]] - make using all cores and other notes
* [[Trac setup | Trac]]


==== Editors ====
* [[XMMS setup]] for Ubuntu 8.04 and up - from source
* [[Sublime_Text_cheat_sheet | Sublime Text editor (cheat sheet)]] - my favorite for source code and beyond
* XMMS setup for Ubuntu Hardy - [https://launchpad.net/ubuntu/hardy/i386/xmms from deb].
* [[Emacs notes | Emacs]] - some of my favoritre customizations
* [[SciTe notes | SciTe / Scintilla]] - the lightweight programmers editor
* [[OpenOffice setup | OpenOffice]]
* [[Latex_on_Ubuntu | Latex support]]
* [https://code-industry.net/free-pdf-editor/ Master PDF editor] for digging into PDFs


==== Virtual environments ====
* [[VirtualBox]] - run other OS-es in parallel
* [[Wine]] - run windows apps within linux


==== Audio and Video ====
* [[XMMS setup]] for Ubuntu 8.04 and up - from source (depreciated)
** XMMS setup for Ubuntu Hardy - [https://launchpad.net/ubuntu/hardy/i386/xmms from deb].


* Notes for [[Video processing]], for desktop capture, video editing and conversion, etc.


==Other nice external links and howto-s==
==Other nice external links and howto-s==


==== Remap mouse buttons ====


My middle mouse button was glitchy, so I remapped it to a scroll-left button (#11 to #2). But before that I needed to query the id for the mouse device. Finally, save all this to <code>.xsessionrc</code>
==== Tunneling ====
[http://ubuntu.wordpress.com/2006/12/08/ssh-tunnel-socks-proxy-forwarding-secure-browsing/ ssh-tunnel-socks-proxy]
In short:
$ssh -D 9999 username@ip-address-of-ssh-server
Then set in Firefox to use a SOCKS proxy: “localhost", port 9999


# Remap mouse scroll-left (#11) as middle button
==== Acroread on Ubuntu ====
mouse_id=$(xinput list | grep "Logitech M705" | awk {'print substr($5,4,22)'})
The link: [http://ubuntu-tutorials.com/2008/06/23/install-adobe-acrobat-reader-812-on-ubuntu-804/]
xinput set-button-map $mouse_id 1 11 3 4 5 6 7 8 9 10 2 12 13 14 15 16


==== Resize PDF to smaller ====

[http://bit.ly/1aCbzSd Using ''convert''], will convert to image and then to pdf, but you can fiddle withthe resolution. Can also trim the whitespace.

convert -density 150 -trim in.pdf -quality 100 out.pdf


[http://bit.ly/1aCbKNs Using ''GS''], will preserve PDF text structures, but resample images:

gs -sDEVICE=pdfwrite -dCompatibilityLevel=1.4 -dPDFSETTINGS=/ebook -dNOPAUSE -dQUIET -dBATCH -sOutputFile=small.pdf big.pdf

Can use other -dPDFSETTINGS, for example /printer, /screen,...


==== Edit Ubuntu Places menu bookmarks ====
Edit or remove old Places-bookmarks like this:
gedit ~/.gtk-bookmarks

Also, the volume icons on the desktop are removeable. Run gconf-editor and uncheck /apps/nautilus/desktop volumes_visible as needed.

==== Mount a remote volume over ssh (using sshfs) ====

sudo apt-get install sshfs
sudo adduser your-username fuse (logout and login after this)
sudo mkdir /media/dir-name
sudo chown your-username /media/dir-name
sshfs example.com:/stuff /media/dir-name


==== Mount an iso image as a CDROM ====

sudo mount -t iso9660 -o loop 'path/to/my.iso' /cdrom

==== Make an iso image from a CD ====
cat /dev/scd0 > mycd.iso

==== Mass search and replace in files (with sed) ====
for i in $(find . -type f); do sed 's/oldstring/newstring/g' $i > $i-tmp; mv $i $i-backup; mv $i-tmp $i; done

==== Mass file rename ====
Replace spaces with underscores in all file names of the directory. then rename *.JPG to *.jpg
rename 's/ /_/g' *
rename 's/.JPG/.jpg/g' *

It is recommended that you use the -n switch for testing before the real action. See ''man rename''.

==== DV/Firewire for Ubuntu ====
https://help.ubuntu.com/community/Firewire




==== Acrobat read on Ubuntu ====

[http://ubuntuhandbook.org/index.php/2014/10/install-adobe-reader-ubuntu-14-10/ The link]


==== Check the ports and apps listening on them ====
==== Check the ports and apps listening on them ====
netstat -lnptu
netstat -lnptu



==== Listing members of a group ====
==== Listing members of a group ====
Line 39: Line 150:
sudo apt-get install members [if needed]
sudo apt-get install members [if needed]
members groupname
members groupname


==== Custom autocomplete in Ubuntu ====

It is nice to use TAB key to autocomlete path for example, for a ls command in bash.
It turns out, you can also autocomplete certain command arguments, e.g. <code>apt-get inst<TAB></code> expands to apt-get install.
Even better, you can define your own completion rules for other commands and applications.

Read more on "howto" here: [http://www.debian-administration.org/articles/316 part 1] and [http://www.debian-administration.org/article/An_introduction_to_bash_completion_part_2 part 2]


==== Create your own apt-get repositories ====

The [http://mediakey.dk/~cc/howto-create-your-own-debian-or-ubuntu-package-repository/ link].

A short example:

Get the tools

sudo aptitude install dpkg-dev

Create the repository structure. You can use any other location accessible from the web.
cd ~/public_html
mkdir my-repository
cd my-repository
mkdir binary
mkdir source

Copy your deb packages to your repository

cp src/bzr_0.11-1.1_all.deb public_html/my-repository/binary/

Create a repository index

cd my-repository
dpkg-scanpackages binary /dev/null | gzip -9c > binary/Packages.gz
dpkg-scansources source /dev/null | gzip -9c > source/Sources.gz

Using the repository. Add these two lines into the /etc/apt/sources.list

deb http://example.com/~myuser/my-repository binary/
deb-src http://example.com/~myuser/my-repository source/

Optionally, add the security key. Read about it elsewhere...

==== Kill-ing a process for sure ====
The [http://linux.byexamples.com/archives/157/kill-process-with-care/ link].

In short, ways to kill in the order of fierceness:
ps aux | grep gaim
kill 1234
pkill gaim
sudo kill 1234
kill -1 1234
kill -2 1234
kill -9 1234
killall gaim
killall -9 gaim


==== How to merge PDF documents ====

Nice writeup was found [http://www.ubuntuhowtos.com/howtos/merge_pdf_files here] and [https://www.maketecheasier.com/combine-multiple-pdf-files-with-pdftk/ here].
You need to install pdftk, unless you have it already.
Then use it like this to merge files 1,2 and 3 to a file merged.pdf.

sudo apt-get install pdftk
pdftk 1.pdf 2.pdf 3.pdf cat output merged.pdf

Or do it with separate pages:

pdftk A=one.pdf B=two.pdf cat A1-7 B1-5 A8 output combined.pdf

==== Howto make deb packages ====
* http://tldp.org/HOWTO/html_single/Debian-Binary-Package-Building-HOWTO/
* http://www.debian.org/doc/maint-guide/


==== How to restore Ubuntu Gnome panel ====
Say your kid deleted the menu panel. This restores default:
gconftool-2 --shutdown
rm -rf ~/.gconf/apps/panel
pkill gnome-panel


==== List all installed packages ====
dpkg --get-selections
More info at [http://ubuntuforums.org/showthread.php?t=261366 this link].


==== Virtual CD from iso ====
mkdir cdiso
sudo mount cd.iso cdiso -o loop

Now cdiso is your virtual cd with the cd.iso image in it.


==== CUPS 400 Bad Request problem ====

Fix this by adding '''ServerAlias *''' in /etc/cupsd/cupsd.conf . For example:

# Administrator user group...
SystemGroup sys root users
# Only listen for connections from the local machine.
Listen 631
Listen /var/run/cups/cups.sock
# Show shared printers on the local network.
Browsing On
BrowseOrder allow,deny
BrowseAllow @LOCAL
BrowseAllow All
# Default authentication type, when authentication is required...
DefaultAuthType Basic
DefaultEncryption Never
ServerAlias * <--------------------------------------------
...

==== Mplayer normalize sound for AC3 ====

Use "-a52drc 1" codec switch to make the loud quieter and the quet louder, look up manpages for the details.
mplayer -a52drc 1 mymovie.mkv

==== Create a bootable USB disk with Free-DOS in Ubuntu ====

Get qemu

sudo apt-get install qemu

Partition the USB disk with a single fat16 partition. Maybe fat32 works too.

Get a DOS image. Suppose you found a dos622.iso image, then boot from it with the USB disk at /dev/sdb like this:

qemu -cdrom dos622.iso -boot d -hda /dev/sdb

Then format from qemu-booted-dos the drive C: that is really your USB drive (be careful not to wipe the real hard drive!)

a:> format /s c:

Then exit qemu and test if you can boot from the new USB drive:
qemu -hda /dev/sdb


The idea came from [http://jachermocilla.blogspot.com/2009/11/making-dos-bootable-usb-disk-from.html this blog] and qemu wiki.

==== Upgrade bios in Ubuntu ====
Now, this could be dangerous. Use if you understand and at your own risk. Conceptual info only, not up to date.

Source: http://ubuntuforums.org/showthread.php?t=318789

In essence:

wget http://www.fdos.org/bootdisks/autogen/FDOEM.144.gz
gunzip FDOEM.144.gz
mkdir /tmp/floppy
sudo mount -t vfat -o loop,quiet,umask=000 FDOEM.144 /tmp/floppy
unzip my-newBIOS.zip -d /tmp/floppy
sudo umount /tmp/floppy
rmdir /tmp/floppy
sudo mv FDOEM.144 /boot/biosupdate.img
sudo apt-get install syslinux
sudo cp /usr/lib/syslinux/memdisk /boot/

sudo vim /boot/grub/menu.lst

title BIOS upgrade
kernel /boot/memdisk
initrd /boot/biosupdate.img

==== SSD tweaks in Linux ====
See [http://selavo.lv/dilab/index.php/Leo:Ubuntu_config here]

==== Disable Bluetooth on startup ====

Put this in "/etc/rc.local" before "exit 0"
rfkill block bluetooth

==== Get Gnome old desktop on Ubuntu 11.10 ====

You can select Gnome as your desktop environment in the login screen after you do:
sudo apt-get install gnome-panel

==== Ubuntu wakeup problems after suspend or hibernate ====
This might be useful:
* From [http://thecodecentral.com/2011/01/18/fix-ubuntu-10-10-suspendhibernate-not-working-bug thecodecentral]


==== HDMI troubleshooting ====

Enable HDMI sound (Ubuntu 11.04) by selecting speaker icon on the top panel -> Sound Preferences -> Hardware -> Profiles -> HDMI output.


Check alsamixer or gnome-alsamixer that SPDIF devices are not muted.


Still no HDMI sound? Find HDMI device(s):

aplay -l

For my Asus i5 with Intel CougarPoint HDMI I get:

**** List of PLAYBACK Hardware Devices ****
card 0: PCH [HDA Intel PCH], device 0: ALC892 Analog [ALC892 Analog]
Subdevices: 1/1
Subdevice #0: subdevice #0
card 0: PCH [HDA Intel PCH], device 1: ALC892 Digital [ALC892 Digital]
Subdevices: 1/1
Subdevice #0: subdevice #0
card 0: PCH [HDA Intel PCH], device 3: HDMI 0 [HDMI 0]
Subdevices: 1/1
Subdevice #0: subdevice #0
card 0: PCH [HDA Intel PCH], device 7: HDMI 1 [HDMI 1]
Subdevices: 1/1
Subdevice #0: subdevice #0

Test sound from command line (note, in my case that was the second HDMI, so I had to use device 0,7 rather than 0,3):
aplay -D plughw:0,7 /usr/share/sounds/alsa/Front_Center.wav


===== HDMI on mplayer =====
For the setup above I need to use the second HDMI port, i.e. hw:0.7. This is how you play with mplayer on this port:

mplayer -ao alsa:device=hw=0.7 myvideo.avi

Note, you may need to use the mplayer controls (keys 9 and 0) to decrease or increase the volume.
Here are some more [http://www.keyxl.com/aaa2fa5/302/MPlayer-keyboard-shortcuts.htm mplayer keyboard shortcuts]


==== Remap keyboard keys ====
I often use the Delete key, therefore on Mac laptop I remapped it to what would be the Right-Control key.
To do the same on T61 Lenovo laptop in Ubuntu do the following:

xmodmap -e "keycode 105 = Delete"

If you want to remap other keys, use xev utility to capture the key codes and names that you can later use with xmodmap.
Then place the commands in .xsessionrc to make them run on login.


==== Porwerpoint crash on start in Wine ====

Powerpoint 2007 needs the MS Office version of the riched20.dll to be set in winecfg:

* Use the Add Application button and then navigate to where you installed PowerPoint.
* Click on the powerpoint executable and then go back and click on the application and then the Libraries tab.
* Select riched20 and that should set it to "Native, builtin".
* Click on the Apply button to save this change. Do not click on the OK button as this will close winecfg.
* Click to the Applications tab and click on the Default Settings item.
* Then click on libraries and remove the riched20 AND riched32 entries.

Source [https://www.winehq.org/pipermail/wine-users/2011-February/086675.html here].

==== Contiki ====

[[Contiki OS]] - installation and usage.


==== List of IP addresses in localnet ====
...can be obtained using arp-scan, as follows:
sudo arp-scan --interface=eth0 --localnet


==== Add UDEV rule for a usb device ====
If you want to access a usb device without sudo, then create a file with the following content (the example is for a Hiletgo ISP programmer for Atmel ATTINY devices).
Note, that you can get the device vendor and product ids with lsusb.
Also note, that the rule makes the device accessible to a group "adm". If you can use sudo, you are probably in this group anyway.

SUBSYSTEM=="usb", ATTRS{idVendor}=="16c0", ATTRS{idProduct}=="05dc", GROUP="adm", MODE="0666"

Name the file something like '''10-mydevice.rules''' and place in '''/etc/udev/rules.d'''

Then restart the udev manager:

sudo udevadm control --reload-rules

The device should be accessible now.

==== Add page numbers to a PDF file====
1. Create a Latex document numbers.tex with page numbers only, as you please:
\documentclass[12pt,a4paper]{article}
\usepackage{multido}
\usepackage[hmargin=.8cm,vmargin=1.5cm,nohead,nofoot]{geometry}
\begin{document}
% Total number of pages here is 12
\multido{}{12}{\vphantom{x}\newpage}
\end{document}
2. Edit the numbers.tex with the appropriate number of max pages. You may also edit the location of the page number, margins, etc.
pdflatex numbers.tex
3. Add page numbers using "multistamp" feature of pdftk. The source pdf file used in the example below is aa.pdf
pdftk aa.pdf multistamp numbers.pdf output aa_numbered.pdf

====Moving Home to a new partition====
More details here: https://help.ubuntu.com/community/Partitioning/Home/Moving

Things to do:
1. Set-up your new partition

2. Find the uuid (=address) of the new partition
sudo blkid
3. Backup and edit your fstab to mount the new partition as /media/home (just for the time being) and reboot.
sudo cp /etc/fstab /etc/fstab.$(date +%Y-%m-%d)
cmp /etc/fstab /etc/fstab.$(date +%Y-%m-%d)
sudo gedit /etc/fstab
Addthe following to fstab and replace the "????????" with the UUID number of the intended /home partition:
# (identifier) (location, eg sda5) (format, eg ext3 or ext4) (some settings)
UUID=???????? /media/home ext3 defaults 0 2
Save and close the file. Make a temp mount directory for the new partition:
sudo mkdir /media/home
Restart. Then:
sudo mount -a

4. Use rsync to migrate all data from /home into /media/home
sudo rsync -aXS --exclude='/*/.gvfs' /home/. /media/home/.
For more verbose output use:
sudo rsync -aXS -v --stats --progress --exclude='/*/.gvfs' /home/. /media/home/.


5. Check copying worked!
sudo diff -r /home /media/home -x ".gvfs/*"


6. Edit fstab again so the new partition mounts as /home instead of as /media/home
sudo gedit /etc/fstab
Edit the lines you added earlier, changing the "/media/home" part to simply say "/home" so that it looks like this:
# (identifier) (location, eg sda5) (format, eg ext3 or ext4) (some settings)
UUID=???????? /home ext3 defaults 0 2

7. Move /home to /old_home to avoid confusion later!
cd / && sudo mv /home /old_home && sudo mkdir /home

8. Reboot or remount all. Check system seems to be working well
Remount fstab without rebooting like this:
sudo umount /media/home/
sudo mount -a

9. Delete the /old_home when sure that all is well with the new setup.
cd /
sudo rm -rI /old_home

Latest revision as of 21:57, 7 March 2021

Contents

Notes for after a fresh ubuntu install:

See also

Making videos smaller

Using ffmpeg with -crf between 24-28 may reduce your video. Smaller value is better quality but larger file.

ffmpeg -i input.mp4 -vcodec libx264 -crf 24 output.mp4

More here.

Working with Ubuntu from Windows 10

Windows 10 has a feature for running Ubuntu shell within a window. It is called Windows Subsystem for Linux This is how to enable it:

  1. Settings => Update & Security -> For Developers. Activate the “Developer Mode”
  2. Control Panel => Programs -> Programs and Features => Turn Windows Features On or Off. Enable the “Windows Subsystem for Linux (Beta)”
  3. Windows will (ask to) restart
  4. Under Start type "bash" and follow the prompts.

Now you can run "bash" to get a window with a Linux environment.

Notes about installing and setup of various apps and features in Ubuntu

General configuration

  • Backup before the setup
    • One easy way to backup the files that we have in Ubuntu is using "cp" command using the following switches: -r for recursive through directories, -p for preserving the attributes and ownership information, and -x to stay in one file system, not following the links. Finally, you can include -v for verbose, listing the files copied:
cp -rpx <source-path> <target-path>
  • Restoring the backup files is the same process.

Web server and clients

Communications

Development

Editors

Virtual environments

  • VirtualBox - run other OS-es in parallel
  • Wine - run windows apps within linux

Audio and Video

  • XMMS setup for Ubuntu 8.04 and up - from source (depreciated)
  • Notes for Video processing, for desktop capture, video editing and conversion, etc.

Other nice external links and howto-s

Remap mouse buttons

My middle mouse button was glitchy, so I remapped it to a scroll-left button (#11 to #2). But before that I needed to query the id for the mouse device. Finally, save all this to .xsessionrc

# Remap mouse scroll-left (#11) as middle button
mouse_id=$(xinput list | grep "Logitech M705" | awk {'print substr($5,4,22)'})
xinput set-button-map $mouse_id 1 11 3 4 5 6 7 8 9 10 2 12 13 14 15 16


Resize PDF to smaller

Using convert, will convert to image and then to pdf, but you can fiddle withthe resolution. Can also trim the whitespace.

convert -density 150 -trim in.pdf -quality 100 out.pdf


Using GS, will preserve PDF text structures, but resample images:

gs -sDEVICE=pdfwrite -dCompatibilityLevel=1.4 -dPDFSETTINGS=/ebook -dNOPAUSE -dQUIET -dBATCH -sOutputFile=small.pdf big.pdf

Can use other -dPDFSETTINGS, for example /printer, /screen,...


Edit Ubuntu Places menu bookmarks

Edit or remove old Places-bookmarks like this:

gedit ~/.gtk-bookmarks

Also, the volume icons on the desktop are removeable. Run gconf-editor and uncheck /apps/nautilus/desktop volumes_visible as needed.

Mount a remote volume over ssh (using sshfs)

sudo apt-get install sshfs
sudo adduser your-username fuse              (logout and login after this)

sudo mkdir /media/dir-name
sudo chown your-username /media/dir-name
sshfs example.com:/stuff /media/dir-name


Mount an iso image as a CDROM

sudo mount -t iso9660 -o loop 'path/to/my.iso' /cdrom

Make an iso image from a CD

cat /dev/scd0 > mycd.iso

Mass search and replace in files (with sed)

for i in $(find . -type f); do sed 's/oldstring/newstring/g' $i > $i-tmp; mv $i $i-backup; mv $i-tmp $i; done

Mass file rename

Replace spaces with underscores in all file names of the directory. then rename *.JPG to *.jpg

rename 's/ /_/g' *
rename 's/.JPG/.jpg/g' *

It is recommended that you use the -n switch for testing before the real action. See man rename.

DV/Firewire for Ubuntu

https://help.ubuntu.com/community/Firewire



Acrobat read on Ubuntu

The link

Check the ports and apps listening on them

netstat -lnptu


Listing members of a group

I.e., the opposite to the command 'groups myuser'

sudo apt-get install members     [if needed]
members groupname


Custom autocomplete in Ubuntu

It is nice to use TAB key to autocomlete path for example, for a ls command in bash. It turns out, you can also autocomplete certain command arguments, e.g. apt-get inst<TAB> expands to apt-get install. Even better, you can define your own completion rules for other commands and applications.

Read more on "howto" here: part 1 and part 2


Create your own apt-get repositories

The link.

A short example:

Get the tools

sudo aptitude install dpkg-dev

Create the repository structure. You can use any other location accessible from the web.

cd ~/public_html
mkdir my-repository
cd my-repository
mkdir binary
mkdir source

Copy your deb packages to your repository

cp src/bzr_0.11-1.1_all.deb public_html/my-repository/binary/

Create a repository index

cd my-repository
dpkg-scanpackages binary /dev/null | gzip -9c > binary/Packages.gz
dpkg-scansources source /dev/null | gzip -9c > source/Sources.gz

Using the repository. Add these two lines into the /etc/apt/sources.list

deb http://example.com/~myuser/my-repository binary/
deb-src http://example.com/~myuser/my-repository source/

Optionally, add the security key. Read about it elsewhere...

Kill-ing a process for sure

The link.

In short, ways to kill in the order of fierceness:

ps aux | grep gaim
kill 1234
pkill gaim
sudo kill 1234
kill -1 1234
kill -2 1234
kill -9 1234
killall gaim
killall -9 gaim


How to merge PDF documents

Nice writeup was found here and here. You need to install pdftk, unless you have it already. Then use it like this to merge files 1,2 and 3 to a file merged.pdf.

sudo apt-get install pdftk
pdftk 1.pdf 2.pdf 3.pdf cat output merged.pdf

Or do it with separate pages:

pdftk A=one.pdf B=two.pdf cat A1-7 B1-5 A8 output combined.pdf

Howto make deb packages


How to restore Ubuntu Gnome panel

Say your kid deleted the menu panel. This restores default:

gconftool-2 --shutdown
rm -rf ~/.gconf/apps/panel
pkill gnome-panel


List all installed packages

dpkg --get-selections

More info at this link.


Virtual CD from iso

mkdir cdiso
sudo mount cd.iso cdiso -o loop

Now cdiso is your virtual cd with the cd.iso image in it.


CUPS 400 Bad Request problem

Fix this by adding ServerAlias * in /etc/cupsd/cupsd.conf . For example:

# Administrator user group...
SystemGroup sys root users

# Only listen for connections from the local machine.
Listen 631
Listen /var/run/cups/cups.sock

# Show shared printers on the local network.
Browsing On
BrowseOrder allow,deny
BrowseAllow @LOCAL
BrowseAllow All
# Default authentication type, when authentication is required...
DefaultAuthType Basic
DefaultEncryption Never
ServerAlias *  <--------------------------------------------
...

Mplayer normalize sound for AC3

Use "-a52drc 1" codec switch to make the loud quieter and the quet louder, look up manpages for the details.

mplayer -a52drc 1 mymovie.mkv

Create a bootable USB disk with Free-DOS in Ubuntu

Get qemu

sudo apt-get install qemu

Partition the USB disk with a single fat16 partition. Maybe fat32 works too.

Get a DOS image. Suppose you found a dos622.iso image, then boot from it with the USB disk at /dev/sdb like this:

qemu -cdrom dos622.iso -boot d -hda /dev/sdb

Then format from qemu-booted-dos the drive C: that is really your USB drive (be careful not to wipe the real hard drive!)

a:> format /s c:

Then exit qemu and test if you can boot from the new USB drive:

qemu -hda /dev/sdb


The idea came from this blog and qemu wiki.

Upgrade bios in Ubuntu

Now, this could be dangerous. Use if you understand and at your own risk. Conceptual info only, not up to date.

Source: http://ubuntuforums.org/showthread.php?t=318789

In essence:

wget http://www.fdos.org/bootdisks/autogen/FDOEM.144.gz
gunzip FDOEM.144.gz
mkdir /tmp/floppy
sudo mount -t vfat -o loop,quiet,umask=000 FDOEM.144 /tmp/floppy
unzip my-newBIOS.zip -d /tmp/floppy
sudo umount /tmp/floppy
rmdir /tmp/floppy
sudo mv FDOEM.144 /boot/biosupdate.img
sudo apt-get install syslinux
sudo cp /usr/lib/syslinux/memdisk /boot/
sudo vim /boot/grub/menu.lst
title       BIOS upgrade
kernel      /boot/memdisk
initrd      /boot/biosupdate.img

SSD tweaks in Linux

See here

Disable Bluetooth on startup

Put this in "/etc/rc.local" before "exit 0"

rfkill block bluetooth

Get Gnome old desktop on Ubuntu 11.10

You can select Gnome as your desktop environment in the login screen after you do:

sudo apt-get install gnome-panel

Ubuntu wakeup problems after suspend or hibernate

This might be useful:


HDMI troubleshooting

Enable HDMI sound (Ubuntu 11.04) by selecting speaker icon on the top panel -> Sound Preferences -> Hardware -> Profiles -> HDMI output.


Check alsamixer or gnome-alsamixer that SPDIF devices are not muted.


Still no HDMI sound? Find HDMI device(s):

aplay -l

For my Asus i5 with Intel CougarPoint HDMI I get:

**** List of PLAYBACK Hardware Devices ****
card 0: PCH [HDA Intel PCH], device 0: ALC892 Analog [ALC892 Analog]
  Subdevices: 1/1
  Subdevice #0: subdevice #0
card 0: PCH [HDA Intel PCH], device 1: ALC892 Digital [ALC892 Digital]
  Subdevices: 1/1
  Subdevice #0: subdevice #0
card 0: PCH [HDA Intel PCH], device 3: HDMI 0 [HDMI 0]
  Subdevices: 1/1
  Subdevice #0: subdevice #0
card 0: PCH [HDA Intel PCH], device 7: HDMI 1 [HDMI 1]
  Subdevices: 1/1
  Subdevice #0: subdevice #0

Test sound from command line (note, in my case that was the second HDMI, so I had to use device 0,7 rather than 0,3):

aplay -D plughw:0,7 /usr/share/sounds/alsa/Front_Center.wav


HDMI on mplayer

For the setup above I need to use the second HDMI port, i.e. hw:0.7. This is how you play with mplayer on this port:

mplayer -ao alsa:device=hw=0.7 myvideo.avi

Note, you may need to use the mplayer controls (keys 9 and 0) to decrease or increase the volume. Here are some more mplayer keyboard shortcuts


Remap keyboard keys

I often use the Delete key, therefore on Mac laptop I remapped it to what would be the Right-Control key. To do the same on T61 Lenovo laptop in Ubuntu do the following:

xmodmap -e "keycode 105 = Delete"

If you want to remap other keys, use xev utility to capture the key codes and names that you can later use with xmodmap. Then place the commands in .xsessionrc to make them run on login.


Porwerpoint crash on start in Wine

Powerpoint 2007 needs the MS Office version of the riched20.dll to be set in winecfg:

  • Use the Add Application button and then navigate to where you installed PowerPoint.
  • Click on the powerpoint executable and then go back and click on the application and then the Libraries tab.
  • Select riched20 and that should set it to "Native, builtin".
  • Click on the Apply button to save this change. Do not click on the OK button as this will close winecfg.
  • Click to the Applications tab and click on the Default Settings item.
  • Then click on libraries and remove the riched20 AND riched32 entries.

Source here.

Contiki

Contiki OS - installation and usage.


List of IP addresses in localnet

...can be obtained using arp-scan, as follows:

sudo arp-scan --interface=eth0 --localnet


Add UDEV rule for a usb device

If you want to access a usb device without sudo, then create a file with the following content (the example is for a Hiletgo ISP programmer for Atmel ATTINY devices). Note, that you can get the device vendor and product ids with lsusb. Also note, that the rule makes the device accessible to a group "adm". If you can use sudo, you are probably in this group anyway.

SUBSYSTEM=="usb", ATTRS{idVendor}=="16c0", ATTRS{idProduct}=="05dc", GROUP="adm", MODE="0666"

Name the file something like 10-mydevice.rules and place in /etc/udev/rules.d

Then restart the udev manager:

sudo udevadm control --reload-rules

The device should be accessible now.

Add page numbers to a PDF file

1. Create a Latex document numbers.tex with page numbers only, as you please:

\documentclass[12pt,a4paper]{article}
\usepackage{multido}
\usepackage[hmargin=.8cm,vmargin=1.5cm,nohead,nofoot]{geometry}
\begin{document}
% Total number of pages here is 12
\multido{}{12}{\vphantom{x}\newpage}
\end{document}

2. Edit the numbers.tex with the appropriate number of max pages. You may also edit the location of the page number, margins, etc.

pdflatex numbers.tex

3. Add page numbers using "multistamp" feature of pdftk. The source pdf file used in the example below is aa.pdf

pdftk aa.pdf multistamp numbers.pdf output aa_numbered.pdf

Moving Home to a new partition

More details here: https://help.ubuntu.com/community/Partitioning/Home/Moving

Things to do: 1. Set-up your new partition

2. Find the uuid (=address) of the new partition

sudo blkid

3. Backup and edit your fstab to mount the new partition as /media/home (just for the time being) and reboot.

sudo cp /etc/fstab /etc/fstab.$(date +%Y-%m-%d)
cmp /etc/fstab /etc/fstab.$(date +%Y-%m-%d)

sudo gedit /etc/fstab 

Addthe following to fstab and replace the "????????" with the UUID number of the intended /home partition:

# (identifier)  (location, eg sda5)   (format, eg ext3 or ext4)      (some settings) 
UUID=????????   /media/home    ext3          defaults       0       2 

Save and close the file. Make a temp mount directory for the new partition:

sudo mkdir /media/home

Restart. Then:

sudo mount -a

4. Use rsync to migrate all data from /home into /media/home

sudo rsync -aXS --exclude='/*/.gvfs' /home/. /media/home/.

For more verbose output use:

sudo rsync -aXS -v --stats --progress --exclude='/*/.gvfs' /home/. /media/home/.


5. Check copying worked!

sudo diff -r /home /media/home -x ".gvfs/*"


6. Edit fstab again so the new partition mounts as /home instead of as /media/home

sudo gedit /etc/fstab

Edit the lines you added earlier, changing the "/media/home" part to simply say "/home" so that it looks like this:

# (identifier)  (location, eg sda5)   (format, eg ext3 or ext4)      (some settings) 
UUID=????????   /home    ext3          defaults       0       2

7. Move /home to /old_home to avoid confusion later!

cd / && sudo mv /home /old_home && sudo mkdir /home

8. Reboot or remount all. Check system seems to be working well Remount fstab without rebooting like this:

sudo umount /media/home/
sudo mount -a

9. Delete the /old_home when sure that all is well with the new setup.

cd /
sudo rm -rI /old_home