Howto Ubuntu

From DiLab

Jump to: navigation, search

Contents

Notes for after a fresh ubuntu install:

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)
    • XMMS setup for Ubuntu Hardy - from deb.
  • 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
Personal tools