Configuration files

Where a system's and a user's settings live, the common formats (key=value, INI, YAML, JSON), the priority order of the sources and the need to reload the service.

  • 24 cards
  • 4 topics
  • Free

The outline, topic by topic

Each topic is weighted the way the exam weighs it.

  1. Concepts
  2. Questions
  3. Sort and link
  4. Scenarios

A few cards from the deck

  • Configuration file: what is it?

    Show the answer

    A text file that holds a program's settings, read at launch to decide its behaviour without changing the program itself.

    On Linux, the system's live in /etc and a user's in their home directory. A syntax error in one can stop the program from starting.

  • ls does not list the .bashrc file in the home directory. Which command shows it?

    • ls -a
    • ls -l
    • ls -R
    • ls -h
    Show the answer

    ls -a

    -a lists everything, including names that start with a dot. -l adds details without revealing hidden files, -R descends into subdirectories, -h makes sizes readable.

  • To add settings without touching the main file, many programs also read every file in a directory whose name ends in ….

    Show the answer

    To add settings without touching the main file, many programs also read every file in a directory whose name ends in .d.

    For example /etc/apt/sources.list.d/ next to /etc/apt/sources.list. Each file in the directory contributes a piece of configuration: a package can add or remove its own without rewriting a shared file.

  • Hidden file: what is it?

    Show the answer

    A file or directory whose name starts with a dot, which ls does not list without the -a option, and which programs use for a user's settings.

    ~/.bashrc, ~/.gitconfig and ~/.ssh/ are examples. The dot is only a display convention: it does not protect the file.

  • The port was changed in sshd_config, but the service still listens on port 22. What are the most likely cause and fix?

    • The service has not reread its file; restart it with systemctl
    • The file is only read when the machine boots; the whole system must be restarted
    • The user's ~/.sshd_config file takes over from the system's; delete it
    • Port 22 is reserved for SSH; changing it requires recompiling the server
    Show the answer

    The service has not reread its file; restart it with systemctl

    A service keeps its settings in memory since launch. After a change, sudo systemctl restart ssh (the service name on Debian) rereads them; on recent Ubuntu releases, where ssh.socket does the listening, you need sudo systemctl daemon-reload then sudo systemctl restart ssh.socket. Rebooting the machine would work, but is out of proportion. Testing with sudo sshd -t before restarting the service avoids locking yourself out remotely.