Scheduled Maintenance: We are aware of an issue with Google, AOL, and Yahoo services as email providers which are blocking new registrations. We are trying to fix the issue and we have several internal and external support tickets in process to resolve the issue. Please see: viewtopic.php?t=158230

 

 

 

Some useful systemd commands.

Share your HowTo, Documentation, Tips and Tricks. Not for support questions!.
Post Reply
Message
Author
User avatar
edbarx
Posts: 5401
Joined: 2007-07-18 06:19
Location: 35° 50 N, 14 º 35 E
Been thanked: 2 times

Some useful systemd commands.

#1 Post by edbarx »

The world is such, that irrespective of one's values and beliefs, one may find oneself faced with having to learn what one may dislike. Posting this doesn't mean I don't appreciate a system employing what GNU/Linux used to be. However, sometimes one may find oneself doing what one never imagines one will do in a thousand years and this is what is happening to me.

I am posting this as a memory aid for myself and others.

First and foremost, systemd has a manpage which can be accessed as usual. Together with that, systemctl also has a manpage. To access them, use the usual: man command.
  • Stopping, starting and querying services (daemons):
  • To stop the graphical desktop, ie the X server (I have lightdm installed):

    Code: Select all

    # systemctl stop lightdm.service
    At the time of writing, I was presented with an empty window. Don't panic, access a working terminal by pressing: Ctrl+Alt+F1..F6.

    To restart the graphical desktop do:

    Code: Select all

    # systemctl start lightdm.service
    I am using a resurrected desktop instance right now. This command worked in my case under Jessie.

    To start, say privoxy daemon, use systemctl start daemon.service:

    Code: Select all

    # systemctl start privoxy.service
    To stop, say privoxy daemon, use systemctl stop privoxy.service:

    Code: Select all

    # systemctl stop privoxy.service
    To query the status of a service (daemon):

    Code: Select all

    # systemctl status privoxy.service
    Example:
    If you want to query if udev is running:

    Code: Select all

    # systemctl status udev.service
  • System shutdown, restart, reboot, etc:
    To shutdown the system:

    Code: Select all

    # systemctl poweroff
    To reboot the system:

    Code: Select all

    # systemctl reboot
    To suspend the system:

    Code: Select all

    # systemctl suspend
    To hibernate the system:

    Code: Select all

    # systemctl hibernate
  • Changing the hostname:
    To change the hostname of the local machine:

    Code: Select all

    # hostnamectl set-hostname your-new-host-name
  • To get a listing like dmesg:
    This command is like dmesg (You have to press 'q' to exit the listing.):

    Code: Select all

    # journalctl --dmesg
Last edited by edbarx on 2015-05-02 11:37, edited 5 times in total.
Debian == { > 30, 000 packages }; Debian != systemd
The worst infection of all, is a false sense of security!
It is hard to get away from CLI tools.

User avatar
Head_on_a_Stick
Posts: 14114
Joined: 2014-06-01 17:46
Location: London, England
Has thanked: 81 times
Been thanked: 132 times

Re: Some useful systemd commands.

#2 Post by Head_on_a_Stick »

The ArchWiki page on systemd is an excellent guide (as usual):
https://wiki.archlinux.org/index.php/Systemd
deadbang

jesus92gz
Posts: 121
Joined: 2015-02-06 18:07

Re: Some useful systemd commands.

#3 Post by jesus92gz »

How to display debugging messages when restarting services?

I use systemctl restart ssh (for example), but there isn't any debugging output, like in Debian 7.8 running service ssh restart

User avatar
Head_on_a_Stick
Posts: 14114
Joined: 2014-06-01 17:46
Location: London, England
Has thanked: 81 times
Been thanked: 132 times

Re: Some useful systemd commands.

#4 Post by Head_on_a_Stick »

jesus92gz wrote:How to display debugging messages when restarting services?
Have you tried:

Code: Select all

systemctl status ssh.service
Or use this immediately after you restart the .service:

Code: Select all

journalctl -xn
You will need to add your user to the "systemd-journal" group to view these logs:

Code: Select all

# gpasswd -s <user name> systemd-journal
Log out & back in again to effect this change.

See here for more tips on using journalctl:
http://0pointer.de/blog/projects/journalctl.html
deadbang

jesus92gz
Posts: 121
Joined: 2015-02-06 18:07

Re: Some useful systemd commands.

#5 Post by jesus92gz »

Yes, I tried systemctl status ssh and the service's status is being displayed correctly. Then I will have to check if the service restart after running the command.

Thank you.

Post Reply