Useful bash commands and how to manage packages with dpkg on a Debian distro.

This is another way to find out who your user is.

bash 07:15:16 Fri Jul 05 [homer@deep-thought $ who is linux
homer    pts/0        2013-07-05 19:10 (:0.0)

And this command lists all logged in users on your Linux system.

bash 07:15:09 Fri Jul 05 [homer@deep-thought $ pinky
Login    Name                 TTY      Idle   When             Where
homer    Homer Simpson        tty7     00:33  2013-07-05 18:43 :0
homer    Homer Simpson        pts/0           2013-07-05 19:10 :0.0

The dpkg command that can be used to install software from Debian packages also has a command-line parameter that will list all files installed onto your computer system when a package is installed. Type dpkg -L {package name} and this information will be printed. An example is below.

bash 07:23:08 Fri Jul 05 [homer@deep-thought $ dpkg -L freedoom
/.
/usr
/usr/games
/usr/games/freedoom
/usr/share
/usr/share/man
/usr/share/man/man6
/usr/share/man/man6/freedoom.6.gz
/usr/share/pixmaps
/usr/share/pixmaps/freedoom.xpm
/usr/share/games
/usr/share/games/doom
/usr/share/games/doom/freedoom.wad
/usr/share/doc
/usr/share/doc/freedoom
/usr/share/doc/freedoom/copyright
/usr/share/doc/freedoom/CREDITS.gz
/usr/share/doc/freedoom/NEWS.gz
/usr/share/doc/freedoom/README.gz
/usr/share/doc/freedoom/changelog.Debian.gz
/usr/share/applications
/usr/share/applications/freedoom.desktop

This is the command used to list packages according to a certain pattern.

bash 07:28:42 Fri Jul 05 [homer@deep-thought $ dpkg -l "freedoom"
Desired=Unknown/Install/Remove/Purge/Hold
| Status=Not/Inst/Conf-files/Unpacked/halF-conf/Half-inst/trig-aWait/Trig-pend
|/ Err?=(none)/Reinst-required (Status,Err: uppercase=bad)
||/ Name                                      Version                   Architecture              Description
+++-=========================================-=========================-=========================-=======================================================================================
ii  freedoom                                  0.8~beta1-1               all                       free game files for the 3D game DOOM

This is how to use wildcards to list packages using dpkg. The dpkg -l vim* command lists all the package names that match this wildcard.

bash 07:30:23 Fri Jul 05 [homer@deep-thought $ dpkg -l vim*
Desired=Unknown/Install/Remove/Purge/Hold
| Status=Not/Inst/Conf-files/Unpacked/halF-conf/Half-inst/trig-aWait/Trig-pend
|/ Err?=(none)/Reinst-required (Status,Err: uppercase=bad)
||/ Name                                      Version                   Architecture              Description
+++-=========================================-=========================-=========================-=======================================================================================
un  vim                                                                                     (no description available)
un  vim-athena                                                                              (no description available)
ii  vim-common                                2:7.3.547-6ubuntu5        amd64                     Vi IMproved - Common files
un  vim-gnome                                                                               (no description available)
un  vim-gtk                                                                                 (no description available)
un  vim-nox                                                                                 (no description available)
ii  vim-tiny                                  2:7.3.547-6ubuntu5        amd64                     Vi IMproved - enhanced vi editor - compact version

Here I am searching for the package that contains the /bin/ls file. This is very useful when you want to remove a file and you are not sure which package it belongs to.

bash 07:33:17 Fri Jul 05 [homer@deep-thought $ dpkg -S "/bin/ls"
coreutils: /bin/ls

And to find out the status of an available package on a Debian system; you use this command.

bash 07:37:26 Fri Jul 05 [homer@deep-thought $ dpkg -s vim-common
Package: vim-common
Status: install ok installed
Priority: important
Section: editors
Installed-Size: 296
Maintainer: Ubuntu Developers <[email protected]>
Architecture: amd64
Source: vim
Version: 2:7.3.547-6ubuntu5
Depends: libc6 (>= 2.3.4)
Recommends: vim | vim-gnome | vim-gtk | vim-athena | vim-nox | vim-tiny
Conffiles:
 /etc/vim/vimrc 682aa2a07693cc27756eee9751db3903
Description: Vi IMproved - Common files
 Vim is an almost compatible version of the UNIX editor Vi.
 .
 Many new features have been added: multi level undo, syntax
 highlighting, command line history, on-line help, filename
 completion, block operations, folding, Unicode support, etc.
 .
 This package contains files shared by all non GUI-enabled vim
 variants (vim and vim-tiny currently) available in Debian.
 Examples of such shared files are: manpages, common executables
 like xxd, and configuration files.
Homepage: http://www.vim.org/
Original-Maintainer: Debian Vim Maintainers <[email protected]>

You may also use the dpkg -C command to check for broken packages on a Debian system. If any are found; type sudo apt-get -f install to fix them.

Post a Comment

Your email is kept private. Required fields are marked *

You may use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>