Showing posts with label Ubuntu. Show all posts
Showing posts with label Ubuntu. Show all posts

Friday, March 23, 2012

Ubuntu's non persistent network configuration

sudo ip addr add 192.168.1.14/24 dev eth0
sudo ip link set dev eth0 up
sudo ip route add default via 192.168.1.1

Or

ifconfig eth0 192.168.1.14 netmask 255.255.255.0
route add default gw 192.168.1.1 eth0

Tuesday, March 20, 2012

APT and Dpkg Quick Reference Sheet



APT and Dpkg Quick Reference Sheet


Matthew Danish

Common APT usage

apt-get install <package> Downloads <package> and all of its dependencies, and installs or upgrades them. This will also take a package off of hold if it was put on. See below for more info on hold.

apt-get remove [--purge] <package> Removes <package> and any packages that depend on it. --purge specifies that packages should be purged, see dpkg -P for more information.

apt-get update Updates packages listings from Debian mirrors, should be run at least once a day if you install anything that day, and every time after /etc/apt/sources.list is changed.

apt-get upgrade [-u] Upgrades all packages installed to newest versions available. Will not install new or remove old packages. If a package changes dependencies and requires installation of a new package, it will not be upgraded, it will be put on holdinstead. apt-get upgrade will not upgrade packages put on hold (that is the meaning of hold). See below for how to manually put packages on hold. I suggest the `-u' option as well, because then you can see what packages are going to be upgraded.

apt-get dist-upgrade [-u] Similar to apt-get upgrade, except that dist-upgrade will install or remove packages to satisfy dependencies.

apt-cache search <pattern> Searches packages and descriptions for <pattern>.

apt-cache show <package> Shows the full description of <package>.

apt-cache showpkg <package> Shows a lot more detail about <package>, and its relationships to other packages.

dselect
console-apt
aptitude
gnome-apt
 Graphical front ends to APT (some of these may be in their own package, that must be installed before use). While dselect is arguably the most powerful, it's also the oldest and hardest to use.

Common Dpkg usage

dpkg -i <package.deb> Installs a Debian package file; one that you downloaded manually, for example.

dpkg -c <package.deb> Lists the contents of <package.deb>, a .deb file.

dpkg -I <package.deb> Extracts package information from <package.deb>, a .deb file.

dpkg -r <package> Removes an installed package named <package>

dpkg -P <package> Purges an installed package named <package>. The difference between remove and purge is that while remove only deletes data and executables, purge also deletes all configuration files in addition.

dpkg -L <package> Gives a listing of all the files installed by <package>. See also dpkg -c for checking the contents of a .deb file.

dpkg -s <package> Shows information on the installed package <package>. See also apt-cache show for viewing package information in the Debian archive and dpkg -I for viewing package information extracted from a .deb file.

dpkg-reconfigure <package> Reconfigures an installed package, if it uses debconf (debconf provides that consistent configuration interface for package installation). You can reconfigure debconf itself if you want to change the front-end or priority of questions asked. For example, to reconfigure debconf with the dialog front-end, you simply run:

dpkg-reconfigure --frontend=dialog debconf



echo ``<package> hold'' | dpkg --set-selections Put <package> on hold (command line method)

dpkg --get-selections ``<package>'' Get the current status of <package> (command line method)

dpkg -S <file> Searches for <file> in package database, telling you which packages have that file in them.

Building Debian packages from Source

apt-get source [-b] <package> Download the source Debian package for <package> and extract it. You must have deb-src lines in your /etc/apt/sources.list for this to work. If you supply the `-b' option and you are currently root, then the package will be automatically built if possible.

apt-get build-dep <package> Download and install the packages necessary to build the source Debian package <package>. This feature is only present in apt version 0.5 and up. Currently this means that woody and above contain this functionality. If you have an older version of apt then the easiest way to find out the build dependencies is to look in the debian/control file in the source package directory. A common usage of this command is in conjunction with apt-get source -b. For example (as root):

apt-get build-dep <package>
apt-get source -b <package>

Will download the source package, all of its build dependencies, and attempt to compile the source package.

dpkg-source -x <package.dsc> If you have downloaded the source package for a program manually, which includes several files such as a .orig.tar.gz (or .tar.gz if it is Debian native), a .dsc, and a .diff.gz (if it is not Debian native), then you can unpack the source package using this command on the .dsc file.

dpkg-buildpackage Builds a Debian package from a Debian source tree. You must be in the main directory of the source tree for this to work. Sample usage:

dpkg-buildpackage -rfakeroot -uc -b

Where `-rfakeroot' instructs it to use the fakeroot program to simulate root privileges (for ownership purposes), `-uc' stands for ``Don't cryptographically sign the changelog'', and `-b' stands for ``Build the binary package only''

debuild A handy wrapper script around dpkg-buildpackage that will automatically take care of using fakeroot or not, as well as running lintian and gpg for you.

Fixing dependencies

dpkg --configure --pending If dpkg quits with an error while apt-get install, upgrade, or dist-upgradeing try running this to configure the packages that were already unpacked. Then try apt-get install, upgrade, or dist-upgrade -f, and then try apt-get install, upgrade, or dist-upgrade again. Repeat as needed. This usually resolves most dependency problems (also, if it mentions a specific package for some reason, you might want to try installing or removing that package)

apt-get install -f
apt-get upgrade -f
apt-get dist-upgrade -f
 Attempt to fix dependencies while doing one of the above. Note that apt-get install -f does not require a <package> argument.


Taken from: http://www.cyberciti.biz/ref/apt-dpkg-ref.html

Monday, March 19, 2012

Ubuntu EOL (End-Of-Life)


If you only need access to some old repositories the only step you need to apply is adding/editing few lines in /etc/apt/sources.list.

## EOL upgrade sources.list
# Required
deb http://old-releases.ubuntu.com/ubuntu/ CODENAME main restricted universe multiverse
deb http://old-releases.ubuntu.com/ubuntu/ CODENAME-updates main restricted universe multiverse
deb http://old-releases.ubuntu.com/ubuntu/ CODENAME-security main restricted universe multiverse

# Optional
#deb http://old-releases.ubuntu.com/ubuntu/ CODENAME-backports main restricted universe multivers

Now just execute apt-get update and you can use those repositories.

Ubuntu versions


VersionCode nameRelease dateSupported until
DesktopsServers
4.10Warty Warthog20 October 200430 April 2006
5.04Hoary Hedgehog8 April 200531 October 2006
5.10Breezy Badger13 October 200513 April 2007
6.06 LTSDapper Drake1 June 200614 July 20091 June 2011
6.10Edgy Eft26 October 200625 April 2008
7.04Feisty Fawn19 April 200719 October 2008
7.10Gutsy Gibbon18 October 200718 April 2009
8.04 LTSHardy Heron24 April 200812 May 2011April 2013
8.10Intrepid Ibex30 October 200830 April 2010
9.04Jaunty Jackalope23 April 200923 October 2010
9.10Karmic Koala29 October 200930 April 2011
10.04 LTSLucid Lynx29 April 2010April 2013April 2015
10.10Maverick Meerkat10 October 201010 April 2012
11.04Natty Narwhal28 April 2011October 2012
11.10Oneiric Ocelot13 October 2011April 2013
12.04 LTSPrecise Pangolin26 April 2012[135]April 2017[129]

Tuesday, January 24, 2012

Cleaning the boot partition in Ubuntu

Today I found a pop up message on one of my Ubuntu machines that said the boot partition was low on space. I did a search on the web for a cleaning solution for the boot partition and found this page:

http://ubuntugenius.wordpress.com/2011/01/08/ubuntu-cleanup-how-to-remove-all-unused-linux-kernel-headers-images-and-modules/

Basically it is proposed a script for removing all unused Linux kernel headers, images and modules:

dpkg -l 'linux-*' | sed '/^ii/!d;/'"$(uname -r | sed "s/\(.*\)-\([^0-9]\+\)/\1/")"'/d;s/^[^ ]* [^ ]* \([^ ]*\).*/\1/;/[0-9]/!d' | xargs sudo apt-get -y purge

I found some flaws in this script so I came with this one trying to improve it:

dpkg -l 'linux-*' | \
# We only need the second column of the installed linux-* packages list
awk '/^ii/ { print $2 } ' | \
# Take out the packages with the number of the running kernel 
grep -v $(uname -r | sed 's/\([0-9.-]\+\)-[^0-9]\+/\1/') | \
# The -v force me into this extra line
grep '[0-9]' | \
xargs sudo apt-get -y purge


Later I'll try to improve it a little bit more.

Thursday, June 16, 2011

Mounting LVM Disk using Ubuntu livecd

Mounting is an easy process to do, provided the filesystem type you are using is supported. What happen when you have an LVM formatted disk, and you need to mount it because the disk cannot be booted and a hell lot of valuable data kept inside?? Do not worry, because the solution is here.......

1. Get a live cd, for example, Ubuntu. For this article, I use Ubuntu 6.06 (I cannot find any latest version of ubuntu at my place)

2. Boot using the live cd. Search for these tools: lvm2. If the cd do not have it, install it.
# apt-get install lvm2

3. To make sure the harddisk is recognised, you can use fdisk
# fdisk -lu

4. Once installed, run pvscan to scan all disks for physical volume. this to make sure your LVM harddisk is detected by Ubuntu
# pvscan
PV /dev/sda2 VG VolGroup00 lvm2 [74.41 GB / 32.00 MB free]
Total: 1 [74.41 GB] / in use: 1 [74.41 GB] / in no VG: 0 [0 ]

5. After that run vgscan to scan disks for volume groups.
# vgscan
Reading all physical volumes. This may take a while...
Found volume group "VolGroup00" using metadata type lvm2


6. Activate all volume groups available.
# vgchange -a y
2 logical volume(s) in volume group "VolGroup00" now active

7. Run lvscan to scan all disks for logical volume. You can see partitions inside the hard disk now active.
# lvscan
ACTIVE '/dev/VolGroup00/LogVol00' [72.44 GB] inherit
ACTIVE '/dev/VolGroup00/LogVol01' [1.94 GB] inherit

8. Mount the partition to any directory you want, usually to /mnt
# mount /dev/VolGroup00/LogVol00 /mnt

9. You can access the partition in the /mnt directory and can backup your data


(Taken from http://linuxwave.blogspot.com/2007/11/mounting-lvm-disk-using-ubuntu-livecd.html)

Wednesday, June 1, 2011

Ubuntu nasty bug

pam update causes cron to stop working with "Module is unknown" error

https://bugs.launchpad.net/ubuntu/+source/pam/+bug/790538

Friday, July 9, 2010

MSSQL Perl Ubuntu

Ok what I need to do is probably setup a connection using UnixODBC ....
Then i can use that connection to connect to the MS SQL Server .....
which has ODBC compatibility mode enabled ......

1) Install the two packages "odbcinst1" and "libct1" with your
favourite package manager.  Now you have installed UnixODBC and
FreeTDS, respectively.

2) You have to tell FreeTDS about the MS SQL Server it should connect
to: Edit /etc/freetds/freetds.conf (with your favourite editor) and go
to the bottom of the file and copy/modify one of the entries names
MyServer to get something like this:

# Business Data
[BData]
host = 192.168.1.10
port = 1433
tds version = 8.0

where the name in square brackets, "BData", is something you have to
tell ODBC about later on, the "host" line is the DNS name or the IP
number (which is what I used above) of the box running MS SQL Server,
"port" is default for MS SQL Server 1433 and shouldn't have to be
changed unless you have done something funky on your MS SQL Server
installation, and for "tds version" 8.0 corresponds to SQL Server
2000.  (See http://www.freetds.org/userguide/tdshistory.htm for more
on versions.)

If you have more that one server you can add another block.

3) Tell UnixODBC where to find the FreeTDS driver and give it a name:
If /etc/odbcinst.ini does not include a block named "FreeTDS" copy the
content of /usr/share/doc/libct1/examples/odbcinst.ini to
/etc/odbcinst.ini to let UnixODBC know about the FreeTDS driver.
/etc/odbcinst.ini should now look something like this:

[FreeTDS]
Description     = FreeTDS 0.61-5 Deb
Driver          = /usr/lib/odbc/libtdsodbc.so
Setup           = /usr/lib/odbc/libtdsS.so
FileUsage       = 1
CPTimeout       = 5
CPReuse         = 5

where "FreeTDS" is the driver name.  

In this file you can also define ODBC drivers for MySQL, generic ODBC,
etc.

4) Make a named ODBC definition, with a specified FreeTDS database:
Edit /etc/odbc.ini and add a block looking something like this:

[BDataTDS]
Description     = Not That Important Data Server, FreeTDS connection
Driver          = FreeTDS
Servername      = BData
Database        = BigApplicationDB

where "BDataTDS" is the ODBC name to give to your application on the
Ubuntu box (e.g. Open Office), "Description" is just that, "Driver" is
the name defined in /etc/odbcinst.ini (in step 3), "Servername" is the name
defined in /etc/freetds/freetds.conf (in step 2), and "Database" is
the database you want to connect to on the MS SQL Server.

If you want to connect to more than one database, add another block
here.  If it is on the same MS SQL Server you use the same
"Servername", if it is a different one, you have to add another block
in step 2.

5) Try connection to the database, using the the unixODBC tool isql:

isql -v BDataTDS  

Look at http://www.freetds.org/userguide/ for more in depth help!


Friday, January 8, 2010

Hardware info in Ubuntu (Linux)

cat /proc/cpuinfo
cat /proc/meminfo
dmesg
lspci

Wednesday, October 7, 2009

Ubuntu version

lsb_release -a

No LSB modules are available.
Distributor ID: Ubuntu
Description: Ubuntu 9.04
Release: 9.04
Codename: jaunty