Directories and Configs
- /etc/init is where the upstart init configs live. While they are not scripts themselves, they essentially execute whatever is required to replace sysvinit scripts.
- /etc/init.d is where all the traditional sysvinit scripts and the backward compatible scripts for upstart live. The backward compatible scripts basically run service myservice start instead of doing anything themselves. Some just show a notice to use the "service" command.
- /etc/init/rc-sysinit.conf controls execution of traditional scripts added manually or with update-rc.d to traditional runlevels in /etc/rc*
- /etc/default has configuration files allowing you to control the behaviour of both traditional sysvinit scripts and new upstart configs.
Using Services
Please note that generally, you can use either traditional sysvinit scripts and the methods of working with them as well as the new upstart configs and the command: "service" interchangeably. It is however recommended you use the new upstart methods which are both forward and backward compatible.
Starting a Service
# Traditional: /etc/init.d/myservice start # Upstart service myservice start
Stopping a Service
# Traditional: /etc/init.d/myservice stop # Upstart service myservice stop
Getting a list of Services
# Traditional: ls /etc/init.d # Upstart: service --status-all
- Note: Upstart method will show both traditional and upstart services.
Adding a Service to Default runlevels
# Traditional update-rc.d apache2 defaults
- Upstart: there is no concept of runlevels, everything is event driven with dependencies. You would add an upstart config to/etc/init and potentially source a config file in /etc/default to allow users to override default behaviour.
Removing a Service from Default runlevels
# Traditional - Something along the lines of rm /etc/rc*/*myscript
- Upstart: If no config is available in /etc/default, edit config in /etc/init
Show the List of Installed Packages on Ubuntu or Debian
The command we need to use is dpkg –get-selections, which will give us a list of all the currently installed packages.$ dpkg --get-selections adduser install alsa-base install alsa-utils install apache2 install apache2-mpm-prefork install apache2-utils install apache2.2-common install apt install apt-utils install
The full list can be long and unwieldy, so it’s much easier to filter through grep to get results for the exact package you need. For instance, I wanted to see which php packages I had already installed through apt-get:dpkg --get-selections | grep phplibapache2-mod-php5 install php-db install php-pear install php-sqlite3 install php5 install php5-cli install php5-common install php5-gd install php5-memcache install php5-mysql install php5-sqlite install php5-sqlite3 install php5-xsl install
For extra credit, you can find the locations of the files within a package from the list by using the dpkg -L command, such as:dpkg -L php5-gd /. /usr /usr/lib /usr/lib/php5 /usr/lib/php5/20060613 /usr/lib/php5/20060613/gd.so /usr/share /usr/share/doc /etc /etc/php5 /etc/php5/conf.d /etc/php5/conf.d/gd.ini /usr/share/doc/php5-gd
Now I can take a look at the gd.ini file and change some settings around…
