Skip to main content

10 APT Commands to Make Life Simpler

10 APT Commands to Make Life Simpler


Here are 10 simple tricks for APT, the Advanced Packaging Tool used on Debian and Debian-based distributions like Ubuntu.

1. View all the packages installed on a system
The easiest way to do it is:

dpkg --get-selections

It does not require to be root, and will display all the packages installed via APT. For example, the first lines may look something like:
$ dpkg --get-selections | head
acetoneiso2 install
acidrip install
acpi-support-base install
acpid install
adduser install
akregator install
alien install
alsa-base install
alsa-oss install
alsa-utils install

You can also put the entire list in a text file by redirecting the output, like this:

dpkg --get-selections > installed_packages.txt

Then read this file with a text editor or using less installed_packages.txt.

2. List files which get installed by a package
-L is a handy parameter to dpkg which will show you what files a package will install.

dpkg -L package_name

For example:

dpkg -L amarok

Will show all the files which are going to be installed by package amarok. You dont have to be root to run it.

3. Upgrade your system using a one-liner
Type as root:

apt-get update && apt-get dist-upgrade

This command will update your list of packages, and if its return status is successful, it will proceed to the next command, apt-get dist-upgrade, which will upgrade all of your packages and will install new dependencies if needed. Use dist-upgrade when you want all of your packages to be installed, and no package left as being kept back.

4. Install the dependencies of an application
Sometimes you need to compile from source a newer version of an application which is already included in the repositories. For example, to install the development libraries for BasKet, you would run as root:

apt-get build-dep basket

And then you can proceed to compile your application. Note that sometimes newer versions of applications may depend on newer libraries or other packages than you do not have in the repositories, so this wont always work.

5. Remove unused package files
When you install software using APT, the DEB packages are kept inside the /var/cache/apt/archives directory. In time, the size of it could get very large. To see what is the size of that directory, you can use:
$ du -h /var/cache/apt/archives/
4.0K /var/cache/apt/archives/partial
956M /var/cache/apt/archives/
In order to clean up all these packages you can use, as root:

apt-get clean

This command will remove all the packages except files which are locked. There is another command, apt-get autoclean, which will remove all the packages which are no longer available in the repository (older versions of packages which cant be downloaded any more).

6. Add repositories from a CD or DVD
If you need an offline repository for packages, you can download all the ISO images for your distribution, eventually burn them on CDs/DVDs and add them manually to the /etc/apt/sources.list file using apt-cdrom (as root):

apt-cdrom add

Enter the CD/DVD in the drive and let APT scan for packages.

Another great solution is to not even burn the ISO images to CD, just mount them and add them to your sources.list this way. Heres what you have to do:

First, type:

apt-cdrom -d=/cdrom add

Or replace /cdrom with some empty directory of your choice, thats where the ISO images will be mounted. I use here /mnt/iso0, /mnt/iso1 etc. Just make sure the directory is empty. The output of the above command looks something like this:

# apt-cdrom -d=/cdrom add
Using CD-ROM mount point /cdrom/
Unmounting CD-ROM
Waiting for disc...
Please insert a Disc in the drive and press enter

Now dont press Enter, instead open another terminal session and mount the image in that directory (as root):

mount -o loop /path/to/iso/file.iso /cdrom

Then return to the shell where you started apt-cdrom and press Enter. It should scan the directory where the ISO image was mounted. Im not very sure this is the only method, but this worked very well for me. If you mount the ISO the first time and then execute apt-cdrom, it first umounts it and then it fails with the message E: Failed to mount the cdrom.


7. Use dpkg -S to search for a specific file
dpkg -S filename will search for filename in all the packages available and return all the packages which have a file (or the path to that file) with the same name. Notice that the name can also be included in the found files. For example, typing dpkg -S bash will return all the packages which contain the name bash in their files, including mybashburn, bash and several other packages. On the other hand, searching for dpkg -S /bin/bash will only return package bash, since dpkg will match the whole path to the bash binary. See the screenshots below for examples:

8. Use apt-file to search for files in packages
This is a tool which creates a cache with info about all the packages available in the repositories, and it allows to search for specific files in a package and show what files a package will install (including packages which are not already installed). To get it, type as root:

sudo apt-get install apt-file

Next, update its cache:

sudo apt-file update

Use it like this:

apt-file search filename

Or:

apt-file search file_path

This will also return paths which include the name file_path. To show what files a package will install, use:

apt-file show package_name
9. Remove unnecessary packages
This was a feature which existed for while in aptitude, but not in apt. Once you remove an application, it may be possible that some libraries on which that application depended to remain installed in the system. In order to get rid of those too, use:

apt-get autoremove --purge

Notice that this command will only remove packages which are not needed any more by some other application or that are not marked as installed manually. This means packages which you did not specifically installed yourself.

10. List files in a package
Just use dpkg -L package_name for this one. Example:

dpkg -L amarok
dpkg -L bash

...

This will list all the packages installed by the respective package. Notice that it wont list anything if the specified package is not installed.

Comments

Popular posts from this blog

150 Gesture Perspective Study By Krenz

150 Gesture Perspective Study By Krenz 150+ Gesture & Perspective Study By Krenz An Amazing Gesture and Perspective Studies By Cushart (Krenz) make sure to follow all of his awesome artwork! facebook page : LINK deviantart : LINK artstation : LINK For Drawing Reference Request Please Comment below or PM us HERE If you like this Reference Pack share and we will be very greatful and motivated to do more compilations. Dont forget to like and Share our Facebook Page HERE and follow us on Instagram HERE Download this Gesture & Study Pack below LINK Decrytion Key Here: !Uf7vVuX1veJMLr_g94sqytIzmovcKzAe5UmFUp-a5_E

10 Cara Untuk Download Berbagai Macam Video di Internet

10 Cara Untuk Download Berbagai Macam Video di Internet Setiap hari orang  men-download, menonton, dan berbagi video dari situs video-sharing seperti  YouTube ,  Google Video ,  Metacafe ,  Dailymotion ,  Break , dan berbagai situs serupa lainnya. Apakah Anda ingin menonton video pada iPod Anda saat bekerja keluar, masukkan ke dalam presentasi PowerPoint untuk menambahkan beberapa slide, atau hanya mendownload video sebelum itu dihapus, ini cukup penting untuk mengetahui cara men-download, mengubah, dan memainkan video. Layanan Web gratis untuk download video dari situs video-sharing 1. ClipNabber  memungkinkan Anda untuk men-download video dari YouTube, Metacafe, dll dengan hanya menyalin dan menyisipkan URL. Anda kemudian akan mendapatkan link dimana Anda dapat men-download file ke komputer Anda, iPod, iPhone, atau media player lainnya. Anda harus memiliki FLV player untuk video YouTube. Cepat dan sangat mudah digunakan! 2. Zamzar  adalah aplikasi konversi file online web gratis yang

2 7 stable 9 vs TProxy on Ubnt

2 7 stable 9 vs TProxy on Ubnt Quote: idealnya proxy itu emang harus transparent. namun untuk squid2.7stable9 belum bener2 transparent. lah maksudnya transparent gimana? gini lho.. ketika client di bawah proxy request http yang masuk ke proxy kan ip client. trus yang keluar malah ip proxy. emang namanya transparent. cuman blom transparent menurut ane. kalo kita bikin proxy model gini dan mau limit traffic ya susah.. karena yang keluar dari proxy adalah ip proxy. bukan ip client. lah trus setelah pake TProxy hasilnya gimana? diharapkan setelah pake TProxy ip yang keluar dari proxy bener2 pure ip client. bukan proxy. jadi lebih mudah untuk management bandwidth. udah ngerti kan? (mudah2an blom) POC tweak dulo systemnya supaya traffic bisa lebih optimal Code: echo "*             soft    nofile          65535" >> /etc/security/limits.conf echo "*             hard    nofile          65535" >> /etc/security/limits.conf echo "net.ipv4.conf.all.rp_filter=0&