Why Ubuntu 18.04 use `/sbin/init` instead of `systemd`? [closed] - linux

Closed. This question does not meet Stack Overflow guidelines. It is not currently accepting answers.
This question does not appear to be about a specific programming problem, a software algorithm, or software tools primarily used by programmers. If you believe the question would be on-topic on another Stack Exchange site, you can leave a comment to explain where the question may be able to be answered.
Closed 3 years ago.
Improve this question
First of all, Here is my environment of system:
# cat /proc/version
Linux version 4.15.0-52-generic (buildd#lgw01-amd64-051) (gcc version 7.3.0 (Ubuntu 7.3.0-16ubuntu3)) #56-Ubuntu SMP Tue Jun 4 22:49:08 UTC 2019
# cat /etc/issue
Ubuntu 18.04.2 LTS \n \l
Refer to this Ubuntu Wiki, ubuntu has used Systemd by default since 15.04 and Systemd runs with PID 1 as /sbin/init. However, I found the different result on my ubuntu 18.04:
# ps aux | awk '$2==1{print $0}'
root 1 0.0 0.8 159692 8784 ? Ss Oct24 0:21 /sbin/init noibrs splash
# lsof -p 1 | grep txt
systemd 1 root txt REG 252,1 1595792 927033 /lib/systemd/systemd
So, my question is that:
Why Ubuntu 18.04 use /sbin/init instead of /lib/systemd/systemd?
Why lsof -p 1 | grep txt return /lib/systemd/systemd while the process of PID 1 is /sbin/init?

/sbin/init is a symbolic link to /lib/systemd/systemd
Take a look at the output of stat /sbin/init or readlink /sbin/init
This is what they mean by systemd "running as /sbin/init". The systemd binary is linked as /sbin/init and started by that link name.
Update
To further explain the difference between the ps and lsof output: ps is showing the command that started the process, while lsof is showing which files a process has opened.
When systemd was started, it was called by /sbin/init noibrs splash, the file system resolved the link to the file /lib/systemd/systemd which was then read from disk and executed.

Related

No coredump file generated in configured directory sometimes [closed]

Closed. This question does not meet Stack Overflow guidelines. It is not currently accepting answers.
This question does not appear to be about a specific programming problem, a software algorithm, or software tools primarily used by programmers. If you believe the question would be on-topic on another Stack Exchange site, you can leave a comment to explain where the question may be able to be answered.
Closed 2 years ago.
Improve this question
I configured one of my Ubuntu1804 user to dump ,
> ulimit -a | grep core
core file size (blocks, -c) unlimited
> cat /proc/sys/kernel/core_pattern
/var/tmp/cores/core.%e.%p.%h.%t.%s
> ls /var/tmp/cores/ -ld
drwxrwxrwx 2 root root 36864 Mar 10 00:05 /var/tmp/cores/
I can get most of the core dumps of crashed process in /var/tmp/cores, but sometimes some crashed process caused by SIGTERM has no coredump file in the directory.
I checked the log of the process missing process, the log said the aborting signal was SIGTERM.
So how came no dump file for it ?
the default action in Linux as described in man 7 signal is to terminate without coredump.
Signal Value Action Comment
────────────────────────────────────────────────────────
SIGTERM 15 Term Termination signal

Difference between pidof and pgrep? [closed]

Closed. This question does not meet Stack Overflow guidelines. It is not currently accepting answers.
This question does not appear to be about a specific programming problem, a software algorithm, or software tools primarily used by programmers. If you believe the question would be on-topic on another Stack Exchange site, you can leave a comment to explain where the question may be able to be answered.
Closed 4 years ago.
Improve this question
I'm not sure why pidof doesn’t work, but pgrep works.
$ pidof squid
returns nothing
$ pgrep squid
returns 3322
How can I get the 3322 using pidof?
pidof will return details regarding the name of a actual program whereas pgrep will return details regarding any processes that match the provided pattern. This is clearly stated in the man pages of both tools.
pidof [-s] [-c] [-n] [-x] [-m] [-o omitpid[,omitpid..]] [-o omitpid[,omitpid..]..] program [program..]
vs.
pgrep [options] pattern
When you're looking for the executable squid, pgrep can match it because the pattern matches /usr/bin/squid*. Whereas pidof cannot find a program called squid, because the Squid daemon is likely called something like /usr/bin/squid-server.
For example, here I'm looking at the output of ps and looking for programs running with the name systemd within them:
$ ps -eaf | grep systemd
root 1 0 0 Sep03 ? 00:00:05 /usr/lib/systemd/systemd --switched-root --system --deserialize 21
root 425 1 0 Sep03 ? 00:00:03 /usr/lib/systemd/systemd-journald
root 480 1 0 Sep03 ? 00:00:00 /usr/lib/systemd/systemd-udevd
dbus 630 1 0 Sep03 ? 00:00:01 /usr/bin/dbus-daemon --system --address=systemd: --nofork --nopidfile --systemd-activation
root 648 1 0 Sep03 ? 00:00:00 /usr/lib/systemd/systemd-logind
pgrep is able to find them as well:
$ pgrep -l systemd
1 systemd
425 systemd-journal
480 systemd-udevd
648 systemd-logind
But pidof only finds the first one:
$ pidof systemd
1
That's because the PID 1, has the name /usr/bin/systemd.

can't change to sudoers.d directory [closed]

Closed. This question does not meet Stack Overflow guidelines. It is not currently accepting answers.
This question does not appear to be about a specific programming problem, a software algorithm, or software tools primarily used by programmers. If you believe the question would be on-topic on another Stack Exchange site, you can leave a comment to explain where the question may be able to be answered.
Closed 6 years ago.
Improve this question
Simple question: I have a user called "user" on my system. This user has sudo privileges. Why can't I browse into the sudoer.d directory then?
Is it because cd is a built-in command?
[user#localhost etc]$ ls -al | grep sudoers.d
drwxr-x---. 2 root root 4096 Apr 4 18:09 sudoers.d
[user#localhost etc]$ sudo cd sudoers.d
[user#localhost etc]$ pwd
/etc
[user#localhost etc]$ sudo ls -la sudoers.d/
total 12
drwxr-x---. 2 root root 4096 Apr 4 18:09 .
drwxr-xr-x. 79 root root 4096 May 5 05:20 ..
-r--r-----. 1 root root 33 Apr 4 18:09 vagrant
[user#localhost etc]$ sudo vim sudoers.d/vagrant
[user#localhost etc]$
Thanks a lot.
It happens because sudo simply executes the command executable you pass to it with elevated privileges, and forwards the rest of arguments. Since cd is a shell builtin, sudo won't find the file to execute, which results in an error.
If you wish to have an interactive shell with elevated privileges, use sudo su
sudo opens a new shell. That shell changes its working directory. And then it exits. The original shell's working directory is never changed, nor can it be.

Trouble running statrup script on Linux [closed]

Closed. This question does not meet Stack Overflow guidelines. It is not currently accepting answers.
Closed 8 years ago.
This question does not appear to be about a specific programming problem, a software algorithm, or software tools primarily used by programmers. If you believe the question would be on-topic on another Stack Exchange site, you can leave a comment to explain where the question may be able to be answered.
This question does not appear to be about a specific programming problem, a software algorithm, or software tools primarily used by programmers. If you believe the question would be on-topic on another Stack Exchange site, you can leave a comment to explain where the question may be able to be answered.
Improve this question
I'm using the Amazon flavor of Linux
uname -a
Linux mydomain.org 3.19.25-82.99.amzn1.x86_64 #1 SMP Wed Dec 3 21:29:43 UTC 2014 x86_64 x86_64 x86_64 GNU/Linux
and I want to run the following script upon system reboot ...
ls -al /home/davea/install/apache-tomcat-6.0.35/bin/startup.sh
-rwxr-xr-x 1 davea mycompany 2023 Nov 28 2011 /home/davea/install/apache-tomcat-6.0.35/bin/startup.sh
So I created this file,
-rwxr-xr-x 1 root root 73 Dec 10 19:29 /etc/init.d/start_tomcat
with the lines
#!/bin/sh
sh /home/davea/install/apache-tomcat-6.0.35/bin/startup.sh
However, when I reboot my system, this script isn't getting invoked. What steps have I left out? I can run the script fine at a command line when I'm logged in.
Edit: Also, I created this symlink in /etc/rc.d ...
ls -al /etc/rc.d/start_tomcat
lrwxrwxrwx 1 root root 24 Dec 10 19:29 /etc/rc.d/start_tomcat -> /etc/init.d/start_tomcat
Still no luck.
You have to add the start-up script under init.d to your default runlevel.
sudo update-rc.d /etc/init.d/start_tomcat defaults
Which should create symlinks to your script under the appropriate /etc/rc?.d folder(s).
This depends on which startup program is being used. Assuming you have privileges to do so, and if the star up program is the chkconfig program your etc/init.d/start script must follow suit in that you need such header fields like:
# chkconfig: <levels> <start> <stop>
# description: <some description>
For other programs, like systemctl (redhat/fedora) you'll need to create a file with directives in it in the following folder:
/etc/systemd/system/
You'd typically make a file called serviceName.service with the following entries:
[Unit]
Description=MyApp
[Service]
ExecStart=/path/to/myService/executable.sh
[Install]
WantedBy=multi-user.target
Then run:
sudo systemctl enable /etc/systemd/system/hello.service
sudo systemctl start hello.service
If this is a LSB (Linux Standards Based) OS/Startup you should follow the tutorial below:
https://wiki.debian.org/LSBInitScripts

Reserved Process ID [closed]

Closed. This question is off-topic. It is not currently accepting answers.
Want to improve this question? Update the question so it's on-topic for Stack Overflow.
Closed 9 years ago.
Improve this question
As per my knowledge Process ID 1 is reserved for init.
What does process id 2 indicate? why no softlink to the binary executable for this process ID.
sudo ls -l /proc/1/exe
lrwxrwxrwx 1 root root 0 Apr 24 14:53 /proc/1/exe --> /sbin/init
But for /proc/2/exe
ls : cannot read symbolic link /proc/2/exe: No such file or directory
lrwxrwxrwx 1 root root 0 Apr 24 14:53 /proc/2/exe
Im using Ubuntu 12.04.
pls share your knowledge.
It's because there is no binary to link to. This process was probably started by the kernel itself. Take a look at the out put of ps aux. Any process you see listed in brackets will not have a exe soft link either.
because at the moment you are asking there is no process of pid 2.
the kernel allocates pids at will.
Or because pid 2 is for some kernel task; on my machine it is for kthreadd which is some pure kernel process. See this answer.

Resources