Home > Uncategorized > Locating Information from the Command Line

Locating Information from the Command Line

Specific searches for information can provide excellent resources for troubleshooting. This section will help you examine a number of ways to find the information that you need.

Search Packages

When Ubuntu updates packages it keeps a package cache of .deb files in /var/cache/apt/archives. This archive can be used to review recent changes on your server. Here are a series of examples to help with searching packages.

Search packages added in last week

find /var/cache/apt/archives -iname ‘*.deb’ -atime -7

Note that atime is used because packages in this directory are not modified they are only added.

Search for packages which have a specific name
Be sure to use the “-n” option as it will force the search to be used for file that have the text string, in this example “apache”, in the name. Otherwise it will include those who have that text string in the description.

apt-cache search -n apache

This search will provide very helpful information for what packages were changed on an update. The “reverse depends” list shows packages which require, recommend or suggest the package searched. The “dependencies” list shows which packages are required, recommended, or suggested for your searched package.

Search for Sizes

Find all files over 10 MB
find / -size +10000000c 2> /dev/null

Find all files over 50 MB
find / -size +50000000c 2> /dev/null

The “2> /dev/null” sends all error messages to the trash instead of the screen.

Search User Owned Files

If you want to find files that belong to only a certain user, you can do that with the “-user” switch. Add a second criterion to find only files of a certain type that belong to a certain user.

find / -user tom -iname ‘*.txt’

You can adjust this search by changing the text string which represents the file type. In the example, “.txt” is used but that could be changed to and file type, like; “.rtf”,”.conf”,”.jpg”,”.gif”, etc.

Managing Versions
Using the “-v” option you can show the version of many programs to verify which version is current. Here are a few examples.

apache2 -v
Server version: Apache/2.2.8 (Ubuntu)
Server built: Jun 25 2008 13:54:13

syslogd -v
syslogd 1.5.0


Using Aptitude to Locate Information

Aptitude is a text mode tool with a menu front end for apt. It can easily provide information about packages and the versions that you currently have installed as well as packages that are not installed. You can access aptitude with:

sudo aptitude

When you open aptitude you will see a menu bar at the top of the screen with two panes below the menu bar. The top pane lists package categories and the bottom pane contains information related to the packages and package categories that you select.

Caution: You can easily break your system using aptitude carelessly as you will be running as root and you can easily install or uninstall packages.

— Installed Packages
— Not Installed Packages
— Obsolete and Locally Create Packages
— Virtual Packages (do not exist but the names are required by other programs)
— Tasks (select packages by groups)

Select any of the five categories and it will expand to show groups related to software packages. For example if you select Installed Packages you will see a list of categories that starts like this:

— admin
— main (Fully supported software)
I grub 0.97-29ubu
— universe (Unsupported software)
— base
—comm

Select a specific category and you will see the individual repository that the packages come from. When you select a repository you will see a list of applications followed by the version that is used. If you see an “I” it indicates that it is installed on the system. In the bottom pane you will see a description of the package.

Whenever you list packages they will have one of these indicators in front of the package to indicate the status of the package.

i: Installed package
c: Package not installed, but package configuration remains on system
p: Purged from system
v: Virtual package –
B: Broken package
u: Unpacked files, but package not yet configured
C: Half-configured – Configuration failed and requires fix
H: Half-installed – Removal failed and requires fix

You can use the F10 key to access the menu across the top.

Actions Undo Package Resolver Search Options Views Help

Actions – install and uninstall options, clean cache
Undo – undo actions

Package – manage install, remove, purge, etc of packages
Resolver – try to resolve issues with conflicts
Find – locate packages
Options – display options
Views – quick access to various view options
Help – basic help

Using dpkg to Locate Information

The dpkg or Debian Package Management tool is an additional way to locate information about packages. If you use the “-l” option you can provide a topic and it will list the package version that is installed.

dpkg -l apache2
Desired=Unknown/Install/Remove/Purge/Hold
| Status=Not/Installed/Config-f/Unpacked/Failed-cfg/Half-inst/t-aWait/T-pend
|/ Err?=(none)/Hold/Reinst-required/X=both-problems (Status,Err: uppercase=bad)
||/ Name Version Description
+++-====================-====================-
ii apache2 2.2.8-1ubuntu0.3 Next generation, scalable, extendable web server

dpkg -l cron
Desired=Unknown/Install/Remove/Purge/Hold
| Status=Not/Installed/Config-f/Unpacked/Failed-cfg/Half-inst/t-aWait/T-pend
|/ Err?=(none)/Hold/Reinst-required/X=both-problems (Status,Err: uppercase=bad)
||/ Name Version Description
+++-====================-====================-
ii cron 3.0pl1-100ubuntu2 management of regular background processing

If you want to list all packages installed use “-l” alone. It will list the package name, version and brief description.

Desired=Unknown/Install/Remove/Purge/Hold
| Status=Not/Installed/Config-f/Unpacked/Failed-cfg/Half-inst/t-aWait/T-pend
|/ Err?=(none)/Hold/Reinst-required/X=both-problems (Status,Err: uppercase=bad)
||/ Name Version Description
+++-==========================================

ii acl 2.2.45-1 Access control li
st utilities
ii acpi 0.09-3ubuntu1 displays information on ACPI devices
ii acpi-support 0.109 a collection of useful events for acpi
ii acpid 1.0.4-5ubuntu9 Utilities for using ACPI power management
ii adduser 3.105ubuntu1 add and remove users and groups

  1. No comments yet.
  1. No trackbacks yet.

Leave a comment