Page tree

Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.
Comment: Migrated to Confluence 5.3

List of the most useful Ubuntu administration commands.

Package Management

List All Installed Packages

See exactly what is installed in your system,

Code Block
dpkg --get-selections > installed-software.txt

The same list can also be used to install the same packages on another machine... Note I have not tested this command myself yet.

Code Block
dpkg --set-selections < installed-software.txt
dselect

Determine Package Program Belongs To

Find out what packages if any use the specified folder,

Code Block
languagebash
dpkg -S "/etc/ssl/certs"
openssl, ca-certificates: /etc/ssl/certs
Note

The package lookup will only work against the original binary. If it does not appear to work, check if the file you are referencing is actually a symbolic link and follow the links to the real binary file.

List all files relate to a package,

Code Block
languagebash
dpkg -L ca-certificates
/.
/etc
/etc/ssl
/etc/ssl/certs
/etc/ca-certificates
/etc/ca-certificates/update.d
/usr
/usr/sbin
/usr/sbin/update-ca-certificates
/usr/share
/usr/share/ca-certificates
...

Determine if package is installed,

Code Block
languagebash
dpkg - l | grep -i upstart

Service Management

Upstart

Upstart is moving towards being the official service management utility. So not all services are yet converted to upstart. However, for the ones that are, it is very easy to use.

Warning

I'm still filling this out.

Determine if a service is upstart based,

Code Block
sudo status servicename

hmm... does not work with Apache2 so that is not yet managed by upstart but sudo service apache2 status works..... so I wonder if service is better.

See list of upstart jobs running,

Code Block
languagebash
ls /etc/init/*.conf
http://askubuntu.com/questions/42444/the-list-of-running-daemons #possibly upstart way http://askubuntu.com/questions/42444/the-list-of-running-daemons

update-rc.d

Apache for example is not yet moved to upstart. So to manage it, use update-rc.d,

Code Block
languagebash
sudo update-rc.d apache2 disable
update-rc.d: warning: apache2 start runlevel arguments (none) do not match LSB Default-Start values (2 3 4 5)
update-rc.d: warning: apache2 stop runlevel arguments (none) do not match LSB Default-Stop values (0 1 6)
 Disabling system startup links for /etc/init.d/apache2 ...
 Removing any system startup links for /etc/init.d/apache2 ...
   /etc/rc0.d/K09apache2
   /etc/rc1.d/K09apache2
   /etc/rc2.d/S91apache2
   /etc/rc3.d/S91apache2
   /etc/rc4.d/S91apache2
   /etc/rc5.d/S91apache2
   /etc/rc6.d/K09apache2
 Adding system startup for /etc/init.d/apache2 ...
   /etc/rc0.d/K09apache2 -> ../init.d/apache2
   /etc/rc1.d/K09apache2 -> ../init.d/apache2
   /etc/rc6.d/K09apache2 -> ../init.d/apache2
   /etc/rc2.d/K09apache2 -> ../init.d/apache2
   /etc/rc3.d/K09apache2 -> ../init.d/apache2
   /etc/rc4.d/K09apache2 -> ../init.d/apache2
   /etc/rc5.d/K09apache2 -> ../init.d/apache2

Don't just try and manually remove symlinks from intit.d. Services will be enabled during package updates.

References

Start of good reading on upstart - http://askubuntu.com/questions/19320/whats-the-recommend-way-to-enable-disable-services

LSB (Linux Standard Base) way .... talks about legacy command and it's smart to figure it out - http://askubuntu.com/questions/6358/how-do-you-restart-apache