News for hackers. Stuff that matters.
Re:Systemd Wants to Expand to Include a Sudo Replacement by agilob on Tuesday April 30, 2024 @03:06PM (#40214923)
> remember when you had to write bash scripts to start, stop, restart services

This was a really big pain, yes, but I also remember how I could `tail -f *.logs`. I remember how I didn't need to remember about `--no-pager` and `--follow`. I knew where the files were, what they were called. I remember how I didn't have to google how to find logs between 10 days ago and 4 days ago, because the logs would be in a .tar created by logrotate with a date in the filename.

The init system was probably peak of systemd, after that they started reinveting things in a more complicated way. Do we really need journald, systemd-boot, machinectl, systemd-networkd, sd-bus, systemd-resolved, systemd-nspawn? Do people actually use it all? Are there any metrics to show how many systems have it installed and in use?

Re:Systemd Wants to Expand to Include a Sudo Replacement by lolinder on Tuesday April 30, 2024 @03:25PM (#40215154)
> I could `tail -f *.logs`. I remember how I didn't need to remember about `--no-pager` and `--follow`.

journalctl supports -f, which by your own account you were already using for tail, so I'm not clear what's worse there.

> I remember how I didn't have to google how to find logs between 10 days ago and 4 days ago, because the logs would be in a .tar created by logrotate with a date in the filename.

My memory of this time was that every single application had its own unique method of handling logs and its own unique location for storing them. So sure, once you found the logs you didn't have to Google how to find the relevant dates if the application is using logrotate as you describe, but finding the logs in the first place was always a challenge. Systemd is nice in that it provides a single place where all logs go and a single interface for navigating them.

Re:Systemd Wants to Expand to Include a Sudo Replacement by cogman10 on Tuesday April 30, 2024 @04:13PM (#40215749)
I think my biggest gripe with journalctl is (and this may just be because I'm novice at using it) that discovering what sort of logs are on the system feels a lot more complex.

With regular logs, I can go to /var/log, ls the dir, and get a nice list of what's being logged. There will be, for example, an `apache.log` file that has all the logs relevant to apache.

Re:Systemd Wants to Expand to Include a Sudo Replacement by tapoxi on Tuesday April 30, 2024 @04:26PM (#40215866)
It's just journalctl -u apache -f, assuming your distribution calls the unit file "apache", and the last few messages of the logfile appear with systemctl status apache

And you don't need to worry about "is this service rotating logs appropriately?"

Re:Systemd Wants to Expand to Include a Sudo Replacement by cogman10 on Tuesday April 30, 2024 @04:30PM (#40215915)
The important thing for me at least isn't he `-u apache` but rather knowing that `apache` exists as one of the installed services on this box.

In the old ways, that was apparent because of the presence of the log file.

Granted, this isn't the problem it used to be for us, however, it would come up because we'd have our services named things like `foo-ws` and knowing that `foo-ws` existed on a given box might be tricky were it not for the log files.

Re:Systemd Wants to Expand to Include a Sudo Replacement by tadfisher on Tuesday April 30, 2024 @04:48PM (#40216154)

    journalctl -f -u <TAB>
Shows you all installed units if you have working shell completion, or 'a<TAB>' gets you all units starting with 'a', etc.
Re:Systemd Wants to Expand to Include a Sudo Replacement by amaterasu on Tuesday April 30, 2024 @07:03PM (#40217538)
In which shell?
Re:Systemd Wants to Expand to Include a Sudo Replacement by ac29 on Tuesday April 30, 2024 @08:01PM (#40217978)
Works in fish, I'll have to remember that one
Re:Systemd Wants to Expand to Include a Sudo Replacement by alright2565 on Tuesday April 30, 2024 @08:40PM (#40218228)
Re:Systemd Wants to Expand to Include a Sudo Replacement by foxhill on Wednesday May 01, 2024 @05:39AM (#40221208)
correct me if i’m wrong, but i believe the point that is trying to be made is;

a system user/admin has an intuition about files. saying that ‘journalctl -f -u’ (fu, indeed :) and whatever else is inherently undiscoverable, and is a.. basically orthogonal mechanism for handling what should be a simple task. i.e., viewing some logs. it’s far easier to compose and extend from files (what if i only care about the mtime of the log, for instance), than this.

look, i think systemd isn’t.. terrible. i also think it’s suffered a bit of complexity fetishisation, and it seems as though that this resulting complexity may have become invisible to you.

run0 doesn’t seem like a bad idea. but i am wincing a bit at the thought of unrestricted javascript determining access control.

Re:Systemd Wants to Expand to Include a Sudo Replacement by tadfisher on Thursday May 02, 2024 @01:10PM (#40238624)
I think you have me confused with someone who cares about the difference between binary and text logs. I have no pony in this race; my comment was just made to help.
Re:Systemd Wants to Expand to Include a Sudo Replacement by foxhill on Thursday May 02, 2024 @06:38PM (#40242150)
fair enough :) apologies!
Re:Systemd Wants to Expand to Include a Sudo Replacement by vbezhenar on Wednesday May 01, 2024 @06:59AM (#40221683)
With `ls -l` I can see file modification dates. How do I do it with journalctl? And why do I need to that that in the first place?

Journald would be perfect if I didn't have to know a thing about it. Work in background, move stuff from stdin/stdout to /var/log/journald/service.log, move old stuff in /var/log/journald/archive/service/2024-04/15.log.gz. I'd be happy. Why do I need this cryptic CLI I don't understand. It brings nothing but pain.

Re:Systemd Wants to Expand to Include a Sudo Replacement by tapoxi on Tuesday April 30, 2024 @04:32PM (#40215947)
I mean "systemctl status" shows all services and their hierarchy, there's also "systemctl list-unit-files" if you want to see things that aren't part of the current target (runlevel).

It's much easier in the systemd world to see the state of the system, the state of the service, and the logs of a service because it enforces this consistency.

Re:Systemd Wants to Expand to Include a Sudo Replacement by cogman10 on Tuesday April 30, 2024 @04:36PM (#40216009)
Ah, good to know. I figured it might be the case that I just needed to RTFM.
Re:Systemd Wants to Expand to Include a Sudo Replacement by kbar13 on Tuesday April 30, 2024 @05:23PM (#40216539)
honestly that's such a niche problem to have that i dont think it's worth throwing the baby out with the bathwater. anyways you shouldn't be discovering installed services by logfile presence, it should be something like querying your package manager.
Re:Systemd Wants to Expand to Include a Sudo Replacement by rixed on Wednesday May 01, 2024 @12:51AM (#40219622)
I wouldn't say it's a niche problem. I also miss being able to go to /var/log and see instantly what's going on.

There should be a command like "journalctl --top" that would list all logging services with amount of logs, oldest and latest log times, and last few lines of each, to improve that experience. Maybe there is already a way to do something similar?

Re:Systemd Wants to Expand to Include a Sudo Replacement by pcthrowaway on Wednesday May 01, 2024 @01:46AM (#40219917)
`systemctl list-unit-files` is too difficult?
Re:Systemd Wants to Expand to Include a Sudo Replacement by saghm on Tuesday April 30, 2024 @03:52PM (#40215510)
> journalctl supports -f, which by your own account you were already using for tail, so I'm not clear what's worse there

Yeah, this is a bit of an odd complaint. If I were this bothered by having to type those, I'd just make an alias to "journalctl --follow --nopager"` and would have forgotten about it years ago.

Re:Systemd Wants to Expand to Include a Sudo Replacement by mdaniel on Tuesday April 30, 2024 @04:20PM (#40215815)
> I'd just make an alias to "journalctl --follow --nopager"` and would have forgotten about it years ago.

You sure would have forgotten about it when you tried to get onto another machine without the magic set of aliases

I am also prepared for someone to chime in that "log egress tools exist" to move up the Maslow's Hierarchy of Log Needs

Re:Systemd Wants to Expand to Include a Sudo Replacement by stoperaticless on Tuesday April 30, 2024 @04:12PM (#40215734)
Never tried it, but if the complainer wrote: tail -f *.logs

Which involves glob’ing. I assume it allows to monitor several services at the same time.

Can systemd do that?

Re:Systemd Wants to Expand to Include a Sudo Replacement by _flux on Tuesday April 30, 2024 @04:35PM (#40215992)
It's the basic function what journalctl -f does by default: follow the global log all jobs write into. -u etc are for filtering that.
Re:Systemd Wants to Expand to Include a Sudo Replacement by tapoxi on Tuesday April 30, 2024 @04:27PM (#40215882)
Yes, journalctl -u postgres -u redis -f etc
Re:Systemd Wants to Expand to Include a Sudo Replacement by mintplant on Tuesday April 30, 2024 @04:36PM (#40216005)
Or just `journalctl -f` to follow all logs.
Re:Systemd Wants to Expand to Include a Sudo Replacement by cduzz on Tuesday April 30, 2024 @05:32PM (#40216628)
I appreciate that someone's invented shoes you inflate and snap. I can see some advantages.

That said, when I'm in a hurry and going to do a thing that I've been doing every day of my life, I'm really not a big fan of having to stop what I'm doing and reexamine a tool I've used all my life to figure out how to use it. I learned this stuff decades ago and I'm not anxious to relearn how to do it for a fractional improvement, and I'm not even really 100% sure that this new "inflate and snap" shoe model is actually an improvement, except for very specific use cases.

Re:Systemd Wants to Expand to Include a Sudo Replacement by acdha on Tuesday April 30, 2024 @06:02PM (#40216961)
Don’t think of it as relearning a tool, think of it as learning one tool which works for everything. You no longer have to implement your own log rotation, compression, etc. or work out which configuration each program needs to do that in the manner you expect – for example, “is it safe to rotate a log file?” requires you to know implementation details on each program.
Re:Systemd Wants to Expand to Include a Sudo Replacement by llm_trw on Tuesday April 30, 2024 @11:32PM (#40219219)
>think of it as learning one tool which works for everything.

For how long?

I've been around for decades at this point with people telling me how the newest and greatest thing will obsolete everything that came before it.

The best way to look through logs is still to materialize them in as text in a files hierarchy and use find with grep to look for issues.

Re:Systemd Wants to Expand to Include a Sudo Replacement by olddustytrail on Wednesday May 01, 2024 @02:02AM (#40220025)
> For how long?

Debian switched to systemd about 12 years ago, so at least that long.

Re:Systemd Wants to Expand to Include a Sudo Replacement by cduzz on Wednesday May 01, 2024 @03:53AM (#40220627)
A quick google indicates that it was made default in debian 8 in 2015, which is 9 years ago, not 12.

Perhaps it was available prior to then, but so were daemontools, upstart, and probably a variety of other alternatives.

Re:Systemd Wants to Expand to Include a Sudo Replacement by acdha on Wednesday May 01, 2024 @12:35PM (#40225617)
One thing to remember is that a lot of people use the testing distribution so they would have seen it before the Debian 8 release changed the default. The debate in the community took ages but one factor in concluding it was that people were using it for years without it being anything like the more hyperbolic predictions some opponents made.
Re:Systemd Wants to Expand to Include a Sudo Replacement by olddustytrail on Wednesday May 01, 2024 @12:55PM (#40225940)
Yes, you're right. I saw when it was added not when it became the default. Still 9 years suggests it's not going to disappear overnight!
Re:Systemd Wants to Expand to Include a Sudo Replacement by llm_trw on Wednesday May 01, 2024 @02:37AM (#40220229)
Find came out in 1974.
Re:Systemd Wants to Expand to Include a Sudo Replacement by acdha on Wednesday May 01, 2024 @06:18AM (#40221429)
I’ve been doing this for decades, too, but I don’t miss having to deal with everyone inventing multiple log hierarchies, different rotation conventions, compression strategies, etc. not to mention all of the other things which systemd removed from daily toil around process management.
Re:Systemd Wants to Expand to Include a Sudo Replacement by Asmod4n on Tuesday April 30, 2024 @05:40PM (#40216689)
Oh the joy it is to have a corrupted log file which the program that wrote it refuses to even read.

Once you deal with that you’ll realize journald is just in the way and needs to be modified to output a human readable log by default.

Re:Systemd Wants to Expand to Include a Sudo Replacement by citrin_ru on Tuesday April 30, 2024 @05:50PM (#40216818)
'journalctl -u service -f' takes many seconds to start showing logs (even with 4GB journal size limit which not that much). 'tail -f /var/log/service' works without a noticeable delay (be it 1kb or 100Gb log file). For me it's a huge regression.
Re:Systemd Wants to Expand to Include a Sudo Replacement by rezonant on Tuesday April 30, 2024 @06:05PM (#40216992)
While I'm very pro journalctl, this is very true. They should put some work into the initial read performance on big journals.
Re:Systemd Wants to Expand to Include a Sudo Replacement by SoftTalker on Tuesday April 30, 2024 @10:39PM (#40218944)
Not my memory at all. In almost all cases the logs were in /var/log and written by syslog. Unless the whole service was in a chroot directory, or the program was written by an amateur who didn't follow logging conventions.
Re:Systemd Wants to Expand to Include a Sudo Replacement by hmmm-i-wonder on Wednesday May 01, 2024 @12:04PM (#40225179)
This and many other discussions misses the point that most people that don't like systemd have with it.

It can largely do everything it replaces, but differently, in some cases with improvements. Every year it increases its scope of 'problems' its solved.

But the issue is it hasn't _ACTUALLY_ solved a problem for me in about a decade, its only introduced problems. Its replaced things that worked perfectly for me and millions of other users for years/decades with something that... also works... but differently. Now to accomplish the _SAME_ outcome without any personal benefit I have to re-learn their new and usually opinionated way.

There was a time I could log into a system, find logs, parse dates and do everything in these discussions reletave to logs, rotation. Regardless of service because the standards were close enough and the basic tooling (tail/find/tar/grep/awk etc.) worked everywhere always, and you never had to google even if the service was one you never worked on before.

For systemd its the opposite, its almost a guarantee you have to google something along the line when interacting with new systems and services. And as soon as their newly enforced opinions and way of doing things is getting comfortable they go and replace something else that was also working... perfectly fine.

If it actively solved problems for the majority of users we wouldn't hate it so much. Instead it requires more mental overhead than anything other than XORG to deal with and constantly manage than anything else in the linux ecosystem.

Re:Systemd Wants to Expand to Include a Sudo Replacement by intelfx on Thursday May 02, 2024 @07:00AM (#40234760)
> If it actively solved problems for the majority of users we wouldn't hate it so much

It does and we don't. The only "we" who are "hating it so much" is a tiny vocal minority.

Re:Systemd Wants to Expand to Include a Sudo Replacement by jordemort on Tuesday April 30, 2024 @04:13PM (#40215742)
systemd-nspawn is actually pretty great, and is mostly just a tool that exposes functionality that systemd already needs for other reasons. IIRC it was originally developed to aid in testing systemd itself, and was initially shipped as an unsupported extra in case other people found it useful.

systemd-resolved is the only way I've ever been able to get dockerd to play nice with Tailscale DNS; it's also the best way that I've found to get a system to pick different upstream DNS servers depending on domain. The alternative is hand-rolling it with dnsmasq or something similar.

I admit I haven't really seen a huge advantage to using systemd-networkd over NetworkManager yet, but for servers with relatively static network configurations, I greatly prefer systemd-networkd over any of the various implementations of ifupdown.

Re:Systemd Wants to Expand to Include a Sudo Replacement by intelfx on Thursday May 02, 2024 @07:02AM (#40234774)
> I admit I haven't really seen a huge advantage to using systemd-networkd over NetworkManager yet

I don't think there is one. systemd-networkd is explicitly not for dynamic environments like personal laptops or workstations; it has a scope and NetworkManager is largely outside it.

Re:Systemd Wants to Expand to Include a Sudo Replacement by hughesjj on Tuesday April 30, 2024 @03:19PM (#40215089)
My 2c, I definitely prefer systemd boot+networkd, fine with journald, don't use the others enough to have an opinion.
Re:Systemd Wants to Expand to Include a Sudo Replacement by iforgotpassword on Tuesday April 30, 2024 @03:44PM (#40215416)
Same. Init system is awesome, love .ini files, networkd is as simple as it can be, journald is fine. Love systemd-nspawn for simple containers as it feels more lightweight than docker. Especially for quick one-offs where I don't need isolated networking you basically have chroot on steroids with "systemd-nspawn -D /path/to/fstree".
Re:Systemd Wants to Expand to Include a Sudo Replacement by superb_dev on Tuesday April 30, 2024 @03:14PM (#40215028)
The follow argument is identical to tail `-f`. `sudo journalctl -f -u <service name>`
Re:Systemd Wants to Expand to Include a Sudo Replacement by rangerelf on Tuesday April 30, 2024 @03:34PM (#40215268)
And what would be the equivalent to, "Oh, I don´t know the name of the log for this process I can see in 'ps aux', let me cd into /var/log and see what filenames I can find ... or grep everything until I can find a couple of words that make some sense so I can keep digging further"?

The lack of explorability in journalctl, the "need" to keep everything locked behind their own flavor of tools and magic file types, is what makes the rest of us abhor them.

Re:Systemd Wants to Expand to Include a Sudo Replacement by ciupicri on Tuesday April 30, 2024 @04:22PM (#40215825)

    # journalctl -f _PID=${your_pid}  # option 1
    # systemctl status ${your_pid}    # option 2
[1]: https://www.freedesktop.org/software/systemd/man/latest/jour...

[2]: https://www.freedesktop.org/software/systemd/man/latest/syst...

Re:Systemd Wants to Expand to Include a Sudo Replacement by Brian_K_White on Tuesday April 30, 2024 @04:43PM (#40216104)
These absolutely SUCK as answers to that question. They entirely miss the point. They provide a specific answer to a general problem.

The problem with systemnd is it assumes that it's possible for all needs to be predicted and accounted for ahead of time. While "look around at directories and files, and grep within them" works after the fact without any special knowledge or tools. The person who wrote the log file did not need to know how someone will maybe try to access it 23 years later on a different OS. It's just a regular file that can be read by anything over any kind of channel on any os. The person finding themselves needing to read the file does not need to have any particular command installed, or installable, or runnable. It does not require the happy path in order to work.

I have a joke I always say, often self-deprecating making fun of my own self for the way I do things sometimes, but also when I'm trying to commiserate with a customer so they don't feel intimidated by "the expert" or "the engineer": "37 easy steps!"

Every answer that starts with "it's simple, just journalctl ..." is FUCKING 37 easy steps. The very name of the program itself is a trainwreck. journalctl... it takes me 18 seconds just to type it.

systemd is great for managing exquisitely washed masses of drone vms. It's utter and complete shit for direct administration, operation, development, debugging, flexibility, or custom integrations.

Re:Systemd Wants to Expand to Include a Sudo Replacement by sgarland on Tuesday April 30, 2024 @07:10PM (#40217591)
Agreed. I’ve tried to get used to it on Debian 12 for personal VMs. I just can’t. I don’t care. grep and awk are always going to be available, and I know how to use them.
Re:Systemd Wants to Expand to Include a Sudo Replacement by robertlagrant on Tuesday April 30, 2024 @05:32PM (#40216624)
> These absolutely SUCK as answers to that question. They entirely miss the point. They provide a specific answer to a general problem.

No they don't. They are good answers. If you want answers to a more general problem, then ask. This is not an emotive topic.

Re:Systemd Wants to Expand to Include a Sudo Replacement by Brian_K_White on Tuesday April 30, 2024 @05:45PM (#40216759)
They may be correct answers, in that they accomplish a task.

They suck in that the proposed method for accomplishing the task is a suck-ass downgrade from the previous ways the new way proposes to displace.

I beg to differ about emotive, because absolutely the other side of this fence behaves every bit as butt-hurt when challenged as I just did. You yourself just said these crappy commands were good, as a purely unfounded assertion. They are great because you just say they are great. That is even less objective than my rant. I at least explained what exactly I find so bad. Tell me more about not emotive.

Re:Systemd Wants to Expand to Include a Sudo Replacement by robertlagrant on Tuesday April 30, 2024 @05:53PM (#40216862)
> You yourself just said these crappy commands were good, as a purely unfounded assertion. They are great because you just say they are great. That is even less objective than my rant. I at least explained what exactly I find so bad. Tell me more about not emotive.

Very well: I didn't say the commands were good or great. If you attempt a little objectivity you'll see it.

Re:Systemd Wants to Expand to Include a Sudo Replacement by Brian_K_White on Tuesday April 30, 2024 @06:19PM (#40217125)
If you attempt a little objectivity, you will see that addressing the answers (vs the commands) was in my first response.

Before even going into the nature of the commands, I said that the answer does not match the question. The answers addressed details, while the details in the question were merely examples.

Missing the point is actually merely one of the at least two dimensions along which the answers suck. Thank you for reminding me about that.

Re:Systemd Wants to Expand to Include a Sudo Replacement by robertlagrant on Tuesday April 30, 2024 @06:52PM (#40217435)
> The answers addressed details, while the details in the question were merely examples.

No, the answers addressed the two scenarios in the question. That's why they don't "SUCK". They are good answers to the question as asked, and not the question as you dreamed it. If you spent ten words on asking the question of your dreams, rather than having a go at people for not answering it (whatever it is), you might have an answer.

Re:Systemd Wants to Expand to Include a Sudo Replacement by sunshowers on Tuesday April 30, 2024 @09:12PM (#40218443)
To be clear -- you can just dump out all the logs to text and then use your standard grep toolkit on them. You can also dump them out to JSON, and use jq on them -- something you can't do with text logs on disk.

And as far as learning the options goes, learning the basics of systemd and journalctl is much easier than learning how to, say, use a source control system effectively.

(And it's definitely worth trying out new source control systems -- for example, I think most people should at least check out Jujutsu, and many people are going to like it more than Git. As simple as Jujutsu is to use, learning it takes a lot longer than learning journalctl.)

Re:Systemd Wants to Expand to Include a Sudo Replacement by superb_dev on Tuesday April 30, 2024 @11:19PM (#40219141)
I didn’t answer the general question because I don’t care, I have no dog in this fight. Im just happy to provide information.

I like systemd and have found it extremely useful. If it doesn’t fill a need for you then use something else.

Re:Systemd Wants to Expand to Include a Sudo Replacement by rcxdude on Wednesday May 01, 2024 @05:01AM (#40221003)
It's way better than the previous status quo: now, more or less whatever distro I'm on, there's one command which answers that question directly, not a process of guessing how this system happens to be set up. You can guess and grep through most any kind of problem, but I don't see why anyone would want to do it as anything but a last resort, and to me that fits '37 easy steps' far more than the 1 consistent step in these replies (notice how none of them say 'oh, but on debian...'?).
Re:Systemd Wants to Expand to Include a Sudo Replacement by throwaway7356 on Saturday May 04, 2024 @06:59AM (#40256621)
> journalctl... it takes me 18 seconds just to type it.

Sounds like you don't use a keyboard often enough to even remember where the keys are. Not sure I would expect deep (or even shallow) knowledge on UNIX system administration from such a person.

Re:Systemd Wants to Expand to Include a Sudo Replacement by superb_dev on Tuesday April 30, 2024 @04:11PM (#40215724)
Well `-u` refers to the unit file, so I would start with `sudo systemctl status` which lists the status of active unit files. I bet I could find the unit name I'm looking for there. If not, then `sudo systemctl list-units` should have it. (and you can grep the output of both)

Systemd and Journald are less opaque than I used to think. Even if you don't want to learn the commands, all of its unit files (and the relationships between them) are available through the filesystem. Most of your unit files will be in `/etc/systemd/system`, and the active relationships between units are expressed through soft links.

Re:Systemd Wants to Expand to Include a Sudo Replacement by aeonik on Tuesday April 30, 2024 @07:33PM (#40217753)
How would you exclude certain units from your logs? Let's say that Auditd is spamming your logs, and you just want to exclude those?

Can you filter on search? How do you prevent applications from writing to Systemd at all?

Re:Systemd Wants to Expand to Include a Sudo Replacement by superb_dev on Tuesday April 30, 2024 @11:13PM (#40219117)
I would start with `man systemd`, or maybe `journalctl —help`.

If you don’t want a service to log to systemd, then don’t run it in systemd?

Re:Systemd Wants to Expand to Include a Sudo Replacement by pcthrowaway on Wednesday May 01, 2024 @01:51AM (#40219957)
I think you can also configure the journal per unit right? Don't remember how exactly, at the very least you can stream logs to a different system.

There are also services which will just use their own logging convention for some reason. Honestly it's easier just to go with journalctl for everything you can.

Re:Systemd Wants to Expand to Include a Sudo Replacement by ramses0 on Tuesday April 30, 2024 @09:41PM (#40218606)
systemctl does not have the Unix nature.
Re:Systemd Wants to Expand to Include a Sudo Replacement by iforgotpassword on Tuesday April 30, 2024 @03:41PM (#40215373)
Huh, isn't grepping journalctl output pretty much the same? It even prefixes messages by the binary name.
Re:Systemd Wants to Expand to Include a Sudo Replacement by mdaniel on Tuesday April 30, 2024 @04:22PM (#40215828)
Pedantically, they're the unit name which only sometimes matches the binary name
Re:Systemd Wants to Expand to Include a Sudo Replacement by rezonant on Tuesday April 30, 2024 @06:12PM (#40217066)
Actually no, they are prefixed by the binary name and the PID number. Technically they are prefixed with: `<date> <host> <binary>[<pid>]`.

You can then use `systemctl status <pid>` to identify the unit if you need to.

I would imagine this is configurable, and this might be the configuration chosen by my distribution (since I have not changed it myself). It would actually be nice to show the unit name instead of the binary/PID combination, though not strictly necessary.

EDIT: Ooh, systemd 239 adds `journalctl -o with-unit` to do this exact thing. There are lots of other formats you can choose from as well.

EDIT 2: Unfortunately there's no way to set this as default, you must use `-o with-unit` each time or set up a shell alias :-\

Re:Systemd Wants to Expand to Include a Sudo Replacement by sunshowers on Tuesday April 30, 2024 @04:42PM (#40216093)
You do have to learn a few new things, yes. But it's not too difficult. We all have to learn new things sometimes.

I spent around 15 minutes a few weeks ago learning how to do a few things with journalctl, and I came away from it with a great appreciation for its power.

Re:Systemd Wants to Expand to Include a Sudo Replacement by rcxdude on Tuesday April 30, 2024 @04:55PM (#40216232)
systemctl status <pid> will show you the unit and helpfully the last few lines of log from it. Journalctl -u <unit name> will then show you the full logs
Re:Systemd Wants to Expand to Include a Sudo Replacement by JoshTriplett on Tuesday April 30, 2024 @06:53PM (#40217449)
> Oh, I don´t know the name of the log for this process I can see in 'ps aux',

With services using journald, there's no "name of the log" because everything's in the journal, so that part isn't a problem. Rather than "is this in auth.log or syslog or thisservice.log", it'll always be in the journal.

> let me cd into /var/log and see what filenames I can find

You can filter journal entries by unit (-u) or by service identifier (-t). Often, though, I find it really useful to be able to see the adjacent entries from other services at the same time, since that can give some indication of what's happening on the system that caused an issue.

> or grep everything until I can find a couple of words that make some sense so I can keep digging further

journalctl --grep, or more conveniently, journalctl and then / to search.

> The lack of explorability in journalctl

It's explorable by dozens of different axes, and if all of those aren't sufficient, you always can get the whole thing as text and run any command you like on it, or get it in structured form and do structured queries on it.

Re:Systemd Wants to Expand to Include a Sudo Replacement by sunshowers on Tuesday April 30, 2024 @04:40PM (#40216065)
I've recently become a fan of the `-x` flag to journalctl, which adds additional context to log entries and even suggests remediations at times. I've identified and fixed several issues on my Linux systems that way. Kind of hard to get that with tail -f!
Re:Systemd Wants to Expand to Include a Sudo Replacement by aeonik on Tuesday April 30, 2024 @06:51PM (#40217427)
How does it work? Can I pipe non-journald logs into the -x flag to take advantage of this lookup?
Re:Systemd Wants to Expand to Include a Sudo Replacement by dumpsterdiver on Tuesday April 30, 2024 @06:31PM (#40217224)
My goto is journalctl -xf. Best of both worlds :)
Re:Systemd Wants to Expand to Include a Sudo Replacement by rezonant on Tuesday April 30, 2024 @06:07PM (#40217016)
Ooh nice. What are some examples of things it will catch?
Re:Systemd Wants to Expand to Include a Sudo Replacement by rezonant on Tuesday April 30, 2024 @05:55PM (#40216893)
> This was a really big pain, yes, but I also remember how I could `tail -f *.logs`.

Others point out that journalctl supports `-f` and `-n` for determining how much journal to return, but for me what's great about journalctl is that I do not need to know where the program is logging to, how it rotates logs (or how it doesn't), or anything else. The program does not need special permissions to a log location in /var/log or /usr/var/log or ~/... or anything else, it just outputs using stdout and it gets captured. When I want to look at logs, I just use the same moniker that I use to control the service: its unit name. It is so incredibly nice- I do not want to go back to the bad old days of spelunking through /var/log and friends.

> --no-pager

To be clear, if you pipe journalctl somewhere, it will automatically skip the pager and just work. `--no-pager` is most useful for when you want to print some unpiped content in an automated script to avoid having a non-existent user exit the pager.

Re:Systemd Wants to Expand to Include a Sudo Replacement by ranger207 on Tuesday April 30, 2024 @06:49PM (#40217407)
I remember, and sometimes still have to deal with, programs that _didn't_ dump their logs in /var/log, forcing me to figure out where the log are in the first place
Re:Systemd Wants to Expand to Include a Sudo Replacement by SoftTalker on Tuesday April 30, 2024 @10:35PM (#40218927)
Those old init scripts were pretty boilerplate and not that hard to write. And in the case of OpenBSD (and maybe other BSDs?) the scripts for /etc/rc.d are usually just a few lines.

With the traditional init system I knew what was going on, and if I didn't, find and grep were your friends. With systemd I'm googling everything every time. The systemctl man page is over 1,100 lines. OpenBSD's rcctl man page is 119 lines.

I'm sure there are use cases for systemd but for running a server that provides a single or a handful of services, it seems like complete overkill.