Friday, June 11, 2010

Create A Local Repository

##################### Ubuntu/Debian ##########################

With every distribution upgrade, one generally has to go re-download all their additional application all over again, consuming time and bandwidth. However with a local repository that no longer becomes a problem. Creating a local repository on your Ubuntu system is rather quick and pretty easy.

How to create your own local repository stored on you Ubuntu PC
Your system probably has a vast collection of deb packages stored on it from previous synaptic installations. To start off we will copy all those deb packages to your local repository.

1. Create your repository folder, anywhere you please, location isn’t really important. I prefer to place mine in the /home folder
2. Copy all the contents of /var/cache/apt/archives (synaptic cache folder) into your new repository folder, mine being /home/repository, alternatively you can achieve this in one swift swoop by entering this into the terminal:

cp /var/cache/apt/archives/*.deb ~/home/repository

3. Create a folder in your repository called partial

mkdir /home/repository/partial

4. Now you ready to build your packages index

sudo dpkg-scanpackages . /dev/null | gzip -9c > Packages.gz

Note: The above command will have to be run everytime you update your packages in your repository folder. The build-essential package is required to run the above command, if it’s not already installed on your system, run the following command.

sudo apt-get install build-essential

5. Your local repository has now been created, all that needs to be done is to add it to your software sources by editing your sources list

sudo gedit /etc/apt/sources.list

add this to the end of the opened file in Gedit

deb file:/home/repository/ /

6. Now reload your package index

sudo aptitude update

That’s it, now before your next upgrade be sure to update your local repository from your /var/cache/apt/archives folder and you wont need to waste time on downloading and installing all your additional packages after the installation process.

#######################################################
Both Debian and Ubuntu Linux provides a number of package management tools.
#######################################################

(1) apt-get : APT is acronym for Advanced Package Tool. It supports installing packages over internet (ftp or http). You can also upgrade all packages in single operations, which makes it even more attractive.

(2) dpkg : Debian packaging tool which can be use to install, query, uninstall packages.

(3) Gui tools:
You can also try GUI based or high level interface to the Debian GNU/Linux package system. Following list summaries them:
(1) aptitude: It is a text-based interface to the Debian GNU/Linux package system.
(2) synaptic: GUI front end for APT

Red hat Linux package names generally end in .rpm similarly Debian package names end in .deb

Add a new package called samba
Syntax: apt-get install {package-name}

# apt-get install samba

apt-get remove the package called samba but keep the configuration files
Syntax: apt-get remove {package-name}

# apt-get remove samba

apt-get remove (erase) package and configuration file

Syntax: apt-get --purge remove {package-name}

# apt-get --purge remove samba

apt-get Update (upgrade) package

Syntax: apt-get upgrade

To upgrade individual package called sudo, enter:
# apt-get install sudo

apt-get display available software updates
# apt-get upgrade samba (Individual package)

dpkg command to get package information such as description of package, version etc.
# dpkg --info sudo_1.6.7p5-2_i386.deb | less

List all installed packages
# dpkg -l

To list individual package try such as apache
# dpkg -l apache
# dpkg -l | grep -i 'sudo' (To verify if package sudo is installed or not)
# dpkg -l '*apache*' ( To list packages related to the apache )

List files provided (or owned) by the installed package (for example what files are provided by the installed samba package)
# dpkg -L samba
# dpkg --contents sudo_1.6.7p5-2_i386.deb

Find, what package owns the file /bin/netstat?
# dpkg -S /bin/netstat

Search for package or package description
Syntax: apt-cache search "Text-to-search"

Find out all the Debian package which can be used for Intrusion Detection
# apt-cache search "Intrusion Detection"
# apt-cache search sniffer

Find out if Debian package is installed or not (status)
# dpkg -s samba| grep Status

List ach dependency a package has...
Display a listing of each dependency a package has and all the possible other packages that can fulfill that dependency. You hardly use this command as apt-get does decent job fulfill all package dependencies.
# apt-cache depends package-name


########################## Redhat/Centos############################

Yet to post...

No comments: