Tag Archives: debian

[debian] apt command to search which packages that provide certain file/library

Suppose you want to compile an application that need some library file such as libcurl.so but you don’t know the exact packages name. Sure, you can guess by using apt-cache search but the result might not be pleasant. (apt-cache search result when combined with file name will –usally– return empty result).
Here, I’ll show you other alternative to apt-cache search to search packages name who provide certain files/libraries.

  • Install apt-file package:


  • before using apt-file, you should update the database first (you need internet connection to do this):

  • wait until all package databases from repository downloaded. Now you can use it:

that command will search which packages from repository that provide libcurl.so file. Use –package-only to only package name, without this option, the result will also include file name and directory name inside packages (which –in my opinion– quite distracting). Oh, almost forgot, apt-file can be used by non-root users.
man apt-file for more complete usage!

[debian] apt-get install specific version of package

When you’re adding additional repositories beside the default in your /etc/apt/sources.list, Debian will provide more than one version of package where available. You can use “apt-cache policy package-name” to check the package’s available version. For example, you want to check available ffmpeg version on your repositories, you can use this command:

If you add additional repositories other than default, you may have several version of ffmpeg. This one is the output example on my server (I add debian-multimedia and backports repository beside the default):

Those lines above show you which ffmpeg version is already installed and which one is available on other repository.
Suppose you want to install ffmpeg version 5:0.7.11-0.1 from debian-multimedia repository, you can use this command:

Notice that I put “=” and the version number [omitting the last number (0)] after the package name. That apt-get command will install ffmpeg from debian-multimedia and removing the one from backports that already installed.
When a package have some configuration file (such as Apache with it’s apache2.conf), apt-get will ask you whether to keep your current configuration or use the new version (overwrite the old one).

find file based on its content

On my last post I’ve mentioned tool called Agent Ransack for Windows that has ability to search file based on it’s content (and other criteria such as modification time). On Linux, there’s no need to install additional package/application. There is already a command line tool that will do the trick, i.e. grep.

For example, you want to find all php files in the current folder and its subfolder that contain word “stat

Parameters explanation:
–color=auto : this will made the word ‘stat‘ highlighted
-i : ignore pattern case (case in-sensitive — the pattern is ‘stat’)
-nH : show filename and the line number

grep example output

example output

If you want to add file modification time as the other criterion, you must combine find and grep command.
For example, you want to search all php files in the current folder and its subfolder that contain word ‘stat‘ and the file was last modified within less than one day a go:

Please refer to find man pages for more option about file modification/access/creation time options.

super easy installing ffmpeg, ffmpeg-php, lame, libogg, libvorbis, mplayer, mencoder and flvtool2 in Debian 6

There are new comer Linux users that still think that installing ffmpeg, mencoder and flvtool2 is hard to do in Linux. I can understand this because not many tutorial site tell them how to do it easily. If you do not need “bleeding-edge” features of the latest ffmpeg, ffmpeg-php, mencoder, mplayer and flvtool2, you can use this tip I wrote. You need additional Debian repository to do this tip.

Add debian-multimedia repository in your /etc/apt/sources.list (edit this file using your favorite text editor such as vim or nano)

You can choose the nearest debian-multimedia repository server here: http://debian-multimedia.org/debian-m.php. Choose the one that near your server, at least in the same continent.

After adding to sources.list, do some:

then, to install ffmpeg, mencoder, mplayer and flvtool2 in Debian Squeeze, do some:

you’re done! It should be less than 5 minutes for a fast server.
apt-get will handle the dependency (such as libmp3lame, libogg, libvorbis) for you! No meddling with source code, no need to compile by yourself, no dependency headache, no libraries conflict, just working environment with some simple steps!

For ffmpeg-php there is additional repository: dotdeb repository. Read the instruction on how to add dotdeb repository in your current Debian 6 /etc/apt/sources.list
After adding dotdeb repository, you can simply install ffmpeg-php by:

That easy!

kick/force logout other users from SSH shell

Sometimes you just want to kick or force logout other users on the SSH sell like bash. There are various reason for this: maybe you just want to eradicate your double login, maybe you own a server and allow other users to login to your server and this user just long enough using the server that make you pissed of or this user had run a process that eat a lot of server resources. So, here’s a way to kick that particular user:

Login as root to your SSH server

use “w” command to check which user logged in which terminal and currently running what command

w command resultAs you can see in the above screenshot, there are 2 root users currently logged in the server. The first “root” logged in via “pts/0” virtual terminal and currently running “htop” command (see in “WHAT” column). Let’s say that we want to kick this “root” user in “pts/0“.

Next, we need to find the sshd process that this root user is currently use. Do type this command

ps grep pts/0note the first ssh process in the “pts/0” terminal. The process number is 2098. We just need to kill this process number to kick this other user.

To make sure, do “w” command again

w second resultYup, that user had been kicked out from the server.