Q.) How will you reboot a linux server when the “reboot” command or “shutdown” command is not working ?
Q.) Explain the command :
date;ps -ef | tail -n +2 | awk '{print $1}'| sort | uniq | wc -l >> file.log
Q.) SCP file transfer is really slow - what could be the reasons ( assume that network is sufficiently fast ). What alternative will you choose in its place and why ?
I'll be posting a series of Linux-related questions covering various skill levels. Feel free to share your insights and expertise. Your contributions will benefit learners at all stages, from those in current roles to those preparing for Linux interviews.
On that first question, is this too simple: # systemctl reboot
Well, here's a little something that I used to demonstrate quite frequently:
# init 6
Seems like it's been years since I've touched it, but I demonstrated it so much
when I did touch it, I could never forget it. Anyway, l await your verdict
@Trevor init 6, reboot, and systemctl reboot should all behave the same as init and reboot are symbolic links to systemd/systemctl. This means all three commands are calling systemd/systemctl on rhel7+ systems. Now, if the binary is called "init" and it is not the first PID in the system , then for SysV compatibility, it will call telinit and see this :
So, init 6 instructs the system's initialization process to perform a graceful shutdown. It sequentially stops all running processes and daemons according to the order specified in the system's initialization configuration files. Once all processes are terminated, the system is rebooted using the shutdown -r now command.
Hence given the scenario, this is also not working - now the original question has become Thanos and is telling : "You should have gone for the head" LOL!
Question #1
What to you mean by "not working", is it hanging, the command execute but there no action?
"systemctl reboot -ff" could be an option?
Reboot binary is not working not even with systemctl too ( this is the scenario here )
For rebooting question, this might work?
echo b > /proc/sysrq-trigger
Bingo! Magic system request key!
but it is either not enabled by default or always enabled via a kernel boot parameter "sysrq_always_enabled=1".
You can enable it via /proc/sys/kernel/sysrq though however the above kernel boot parameter overrides the proc sysrq boolean.
did you try to kill pid 0
Red Hat
Learning Community
A collaborative learning environment, enabling open source skill development.