Upgrade Ubuntu

Preferred method

sudo apt-get install update-manager-core
sudo do-release-upgrade

or

sudo apt-get update
sudo apt-get upgrade
sudo apt-get -f install (not "install -f"!)
sudo apt-get -y install apt
sudo do-release-upgrade

Use the update-manager

sudo apt-get install update-manager
sudo update-manager -d

Can also been used

sudo apt-get update
sudo apt-get upgrade
sudo apt-get dist-upgrade

Ubuntu Saucy – Upgrading from older versions

FAQ

How to Upgrade From Ubuntu 12.04 LTS to Ubuntu 13.04
How To Upgrade From Ubuntu 13.04 Raring To Ubuntu 13.10 Saucy Salamander – See more at: http://www.unixmen.com/upgrade-ubuntu-13-04-raring-ubuntu-13-10-saucy-salamander/#sthash.00K4bvFQ.dpuf
Can I skip over releases when upgrading?
Upgrade from 12.04 to 13.04?

How do I fix a “Could not get lock /var/lib/dpkg/lock” problem?
/var/cache/debconf/config.dat is locked by another process
debconf: DbDriver “config”: /var/cache/debconf/config.dat is locked by another process
Unable to install due to debconf problem

What do I select for “GRUB install devices” after an update?

Question

$ sudo apt-get install -f
E: Could not get lock /var/lib/dpkg/lock - open (11: Resource temporarily unavailable)
E: Unable to lock the administration directory (/var/lib/dpkg/), is another process using it?

Answer

$ sudo rm /var/lib/dpkg/lock 
$ sudo rm /var/cache/apt/archives/lock
$ sudo rm /var/lib/apt/lists/lock

Question

$ sudo apt-get install -f
E: dpkg was interrupted, you must manually run 'sudo dpkg --configure -a' to correct the problem. 

Answer

$ sudo dpkg --configure -a
[...]
debconf: DbDriver "config": /var/cache/debconf/config.dat is locked by another process: Resource temporarily unavailable
dpkg: error processing samba-common (--configure):
 subprocess installed post-installation script returned error exit status 1
[...]
dpkg: dependency problems prevent configuration of smbclient:
 smbclient depends on samba-common (= 2:3.6.6-3ubuntu5.3); however:
  Package samba-common is not configured yet.

dpkg: error processing smbclient (--configure):
 dependency problems - leaving unconfigured
[...]
Errors were encountered while processing:
 samba-common
 smbclient
 samba-common-bin
 rsyslog
 isc-dhcp-client
 samba
 network-manager

Question

debconf: DbDriver "config": /var/cache/debconf/config.dat is locked by another process: Resource temporarily unavailable
dpkg: error processing samba-common (--configure)

Answer

$ fuser -v /var/cache/debconf/config.dat
# No process uses this file
# cp -R /var/cache/debconf /var/cache/debconf.backup
# rm /var/cache/debconf/*.dat
# dpkg --configure -a
Setting up samba-common (2:3.6.6-3ubuntu5.3) ...
Replacing config file /etc/samba/smb.conf with new version
Setting up smbclient (2:3.6.6-3ubuntu5.3) ...
Setting up samba-common-bin (2:3.6.6-3ubuntu5.3) ...
Setting up rsyslog (5.8.6-1ubuntu9.3) ...
Skipping profile in /etc/apparmor.d/disable: usr.sbin.rsyslogd
rsyslog stop/waiting
rsyslog start/running, process 3290
Setting up isc-dhcp-client (4.2.4-1ubuntu10.4) ...
Setting up samba (2:3.6.6-3ubuntu5.3) ...
smbd start/running, process 3348
nmbd start/running, process 3382
Setting up network-manager (0.9.6.0-0ubuntu7.1) ...

Question

Trigger für ureadahead (0.100.0-19) werden verarbeitet ...
Trigger für dbus (1.10.6-1ubuntu3) werden verarbeitet ...
Trigger für systemd (229-4ubuntu6) werden verarbeitet ...
Trigger für initramfs-tools (0.122ubuntu8.1) werden verarbeitet ...
update-initramfs: Generating /boot/initrd.img-4.4.0-28-generic
Fehler traten auf beim Bearbeiten von:
 apt
 apt-utils
 apt-offline
E: Sub-process /usr/bin/dpkg returned an error code (1)

##############

apt (1.2.12~ubuntu16.04.1) wird eingerichtet ...
useradd: existing lock file /etc/gshadow.lock without a PID
useradd: /etc/gshadow konnte nicht gesperrt werden; versuchen Sie es später noch einmal.
adduser: »/usr/sbin/useradd -d /nonexistent -g nogroup -s /bin/false -u 122 _apt« gab den Fehlercode 10 zurück. Programmende.
usermod: Benutzer »_apt« ist nicht vorhanden.
dpkg: Fehler beim Bearbeiten des Paketes apt (--configure):
 Unterprozess installiertes post-installation-Skript gab den Fehlerwert 6 zurück
dpkg: Abhängigkeitsprobleme verhindern Konfiguration von apt-utils:
 apt-utils hängt ab von apt (= 1.2.12~ubuntu16.04.1); aber:
  Paket apt ist noch nicht konfiguriert.

dpkg: Fehler beim Bearbeiten des Paketes apt-utils (--configure):
 Abhängigkeitsprobleme - verbleibt unkonfiguriert
dpkg: Abhängigkeitsprobleme verhindern Konfiguration von apt-offline:
 apt-offline hängt ab von apt; aber:
  Paket apt ist noch nicht konfiguriert.

dpkg: Fehler beim Bearbeiten des Paketes apt-offline (--configure):
 Abhängigkeitsprobleme - verbleibt unkonfiguriert
Trigger für libc-bin (2.23-0ubuntu3) werden verarbeitet ...
Es wurde kein Apport-Bericht verfasst, da die Fehlermeldung darauf hindeutet, dass dies lediglich ein Folgefehler eines vorherigen Problems ist.
                                                                                                                                                Es wurde kein Apport-Bericht verfasst, da die Fehlermeldung darauf hindeutet, dass dies lediglich ein Folgefehler eines vorherigen Problems ist.
                                                                                                            /sbin/ldconfig.real: /usr/lib/libbrscandec2.so.1 is not a symbolic link

/sbin/ldconfig.real: /usr/lib/libbrcolm2.so.1 is not a symbolic link

Fehler traten auf beim Bearbeiten von:
 apt
 apt-utils
 apt-offline
W: No sandbox user '_apt' on the system, can not drop privileges
E: Sub-process /usr/bin/dpkg returned an error code (1)

Answer

$ sudo mv /etc/sub /etc/gshadow.lock_old
$ sudo mv /etc/subgid.lock /etc/subgid.lock_old
$ sudo mv /etc/subuid.lock /etc/subuid.lock_old
$ sudo /usr/sbin/useradd -d /nonexistent -g nogroup -s /bin/false -u 122 _apt

Byte Stream to Hex String

Perl one-liner

00c03a701e7900c03a702d2908004500
00602cc000003c11ba74c0a80b05c0a8
0b03043059d9004c0000000000000000
000000000000000000000001549606c8
5f9b0000004400000000000000000000
00000000000000000000000000040002
$ cat message.txt | perl -pe 's/([0-9a-f]{2})/0x$1, /g'
0x00, 0xc0, 0x3a, 0x70, 0x1e, 0x79, 0x00, 0xc0, 0x3a, 0x70, 0x2d, 0x29, 0x08, 0x00, 0x45, 0x00, 
0x00, 0x60, 0x2c, 0xc0, 0x00, 0x00, 0x3c, 0x11, 0xba, 0x74, 0xc0, 0xa8, 0x0b, 0x05, 0xc0, 0xa8, 
0x0b, 0x03, 0x04, 0x30, 0x59, 0xd9, 0x00, 0x4c, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0x54, 0x96, 0x06, 0xc8, 
0x5f, 0x9b, 0x00, 0x00, 0x00, 0x44, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x04, 0x00, 0x02, 

jEdit BeanShell

26 08 00 11 00 00 00 00 00 00 00 1c 72 65 73 74
72 69 63 74 20 31 39 32 2e 31 36 38 2e 37 2e 38
20 76 65 72 73 69 6f 6e 00 00 00 0a 86 be ad 02
89 51 bb 99 9d 7f 15 71 c6 a2 cf d4
Search: [0-9a-z][0-9a-z]
Replace: "0x"+_0+","
0x26, 0x08, 0x00, 0x11, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x1c, 0x72, 0x65, 0x73, 0x74,
0x72, 0x69, 0x63, 0x74, 0x20, 0x31, 0x39, 0x32, 0x2e, 0x31, 0x36, 0x38, 0x2e, 0x37, 0x2e, 0x38,
0x20, 0x76, 0x65, 0x72, 0x73, 0x69, 0x6f, 0x6e, 0x00, 0x00, 0x00, 0x0a, 0x86, 0xbe, 0xad, 0x02,
0x89, 0x51, 0xbb, 0x99, 0x9d, 0x7f, 0x15, 0x71, 0xc6, 0xa2, 0xcf, 0xd4,

Eclipse Indigo SP2 doesn’t know uint8_t

How do I test the current version of GCC?

__GNUC__              = 4 // major
__GNUC_MINOR__        = 8 // minor
__GNUC_PATCHLEVEL__   // patch

Multiple “could not be resolved” problems using Eclipse with minGW

Go to Project -> Properties -> C/C++ General -> Preprocessor Include Paths, Macros, etc. -> Providers -> CDT GCC built-in compiler settings, deactivate Use global provider shared between projects and add the command line argument -std=c++11.

Eclipse 3.7.0 Indigo with CDT shows many false compilation errors

/usr/include/c++/4.6.1
/usr/include/                
/usr/include/c++             
/usr/include/c++/4.6         
/usr/include/x86_64-linux-gnu
/usr/include/asm-generic
/usr/include/c++/4.6.1/x86_64-linux-gnu/
File doesn't include these definitions
/opt/altera12.1sp1/nios2eds/bin/gnu/H-i686-pc-linux-gnu/nios2-elf/include/sys/config.h

__LONG_LONG_MAX__ = 9223372036854775807LL
__LONG_MAX__      = 2147483647L
__WCHAR_MAX__     = 2147483647L
__INT_MAX__       = 2147483647L
__SHRT_MAX__      = 32767L
__SCHAR_MAX__     = 127L

Eclipse CDT Project Properties (nios2_limits.xml)

Vi / Vim “VIsual IMproved”

:%s/foo/bar/g        Find each occurrence of 'foo' (in all lines), and replace it with 'bar'. 

:s/foo/bar/g         Find each occurrence of 'foo' (in the current line only), and replace it with 'bar'. 

:%s/foo/bar/gc       Change each 'foo' to 'bar', but ask for confirmation first. 

:%s/\<foo\>/bar/gc   Change only whole words exactly matching 'foo' to 'bar'; ask for confirmation. 

:%s/foo/bar/gci      Change each 'foo' (case insensitive) to 'bar'; ask for confirmation. 
                     This may be wanted after using :set noignorecase to make searches case sensitive (the default). 

:%s/foo/bar/gcI      Change each 'foo' (case sensitive) to 'bar'; ask for confirmation. 
                     This may be wanted after using :set ignorecase to make searches case insensitive. 

Search and replace

Convert the line endings from DOS to UNIX format

CR = Carriage Return
LF = Line Feed

Betriebssystem Zeichensatz Abkürzung Code Hex Code Dezimal Escape-Sequenz
Unix, Linux, Android, Mac OS X, AmigaOS, BSD ASCII LF 0A 10 \n
Windows, DOS, OS/2, CP/M, TOS (Atari) ASCII CR LF 0D 0A 13 10 \r\n
Mac OS bis Version 9, Apple II, C64 ASCII CR 0D 13 \r
AIX OS & OS/390 EBCDIC NEL 15 21 \025

sed

NAME          sed - stream editor for filtering and transforming text
DESCRIPTION   Sed is a stream editor. A stream editor is used to perform
              basic text transformations on an input stream.
# DOS => UNIX
# replace every "\r" with ""
$ sed "s/\r//" infile >outfile

# UNIX => DOS
# add in every line-end (RegEx $) before \n the character \r
$ sed "s/$/\r/" infile >outfile

How to convert DOS/Windows newline to Unix newline in bash script?
sed Tutorium – Eine Einführung in sed
Useful one-line scripts for sed

tr

NAME          tr - translate or delete characters
DESCRIPTION   Translate, squeeze, and/or delete characters
              from standard input, writing to standard output.
# delete every "\r"
tr -d \r <infile >outfile