Question : With the installation of new tools on the app servers within the Stratos Datacenter, certain functionalities now necessitate graphical user interface (GUI) access.
Adjust the default runlevel on all App servers in Stratos Datacenter to enable GUI booting by default. It's imperative not to initiate a server reboot after completing this task.
Solution:
1. With the help of sshpass command we can execute command from jump server
thor@jumphost ~$ sshpass -p Ir0nM@n ssh -o StrictHostKeyChecking=no tony@stapp01 "echo Ir0nM@n | sudo -S systemctl set-default graphical.target" Warning: Permanently added 'stapp01' (ED25519) to the list of known hosts. We trust you have received the usual lecture from the local System Administrator. It usually boils down to these three things: #1) Respect the privacy of others. #2) Think before you type. #3) With great power comes great responsibility. [sudo] password for tony: Removed "/etc/systemd/system/default.target". Created symlink /etc/systemd/system/default.target → /usr/lib/systemd/system/graphical.target. thor@jumphost ~$ sshpass -p Ir0nM@n ssh -o StrictHostKeyChecking=no tony@stapp01 "echo Ir0nM@n | sudo -S systemctl start graphical.target && systemctl status graphical.target" [sudo] password for tony: ● graphical.target - Graphical Interface Loaded: loaded (/usr/lib/systemd/system/graphical.target; indirect; preset: disabled) Active: active since Sun 2025-08-03 07:00:06 UTC; 6min ago Until: Sun 2025-08-03 07:00:06 UTC; 6min ago Docs: man:systemd.special(7) Aug 03 07:00:06 stapp01.stratos.xfusioncorp.com systemd[1]: graphical.target: Job 1 graphical.target/start finished, result=done Aug 03 07:00:06 stapp01.stratos.xfusioncorp.com systemd[1]: Reached target Graphical Interface. Aug 03 07:06:12 stapp01.stratos.xfusioncorp.com systemd[1]: graphical.target: Trying to enqueue job graphical.target/start/replace Aug 03 07:06:12 stapp01.stratos.xfusioncorp.com systemd[1]: graphical.target: Installed new job graphical.target/start as 292 Aug 03 07:06:12 stapp01.stratos.xfusioncorp.com systemd[1]: graphical.target: Enqueued job graphical.target/start as 292 Aug 03 07:06:12 stapp01.stratos.xfusioncorp.com systemd[1]: graphical.target: Job 292 graphical.target/start finished, result=done thor@jumphost ~$ |
2. Run Below command to change the run level to graphical.target for all other app servers
thor@jumphost ~$ sshpass -p Am3ric@ ssh -o StrictHostKeyChecking=no steve@stapp02 "echo Am3ric@ | sudo -S systemctl set-default graphical.target"
|
thor@jumphost ~$ sshpass -p Am3ric@ ssh -o StrictHostKeyChecking=no steve@stapp02 "echo Am3ric@ | sudo -S systemctl start graphical.target && systemctl status graphical.target" thor@jumphost ~$sshpass -p BigGr33n ssh -o StrictHostKeyChecking=no banner@stapp03 "echo BigGr33n | sudo -S systemctl start graphical.target && systemctl status graphical.target" |
thor@jumphost ~$ sshpass -p Ir0nM@n ssh -o StrictHostKeyChecking=no tony@stapp01 "echo Ir0nM@n | sudo -S systemctl get-default" [sudo] password for tony: graphical.target thor@jumphost ~$ sshpass -p Am3ric@ ssh -o StrictHostKeyChecking=no steve@stapp02 "echo Am3ric@ | sudo -S systemctl get-default" thor@jumphost ~$ sshpass -p BigGr33n ssh -o StrictHostKeyChecking=no banner@stapp03 "echo BigGr33n | sudo -S systemctl get-default" |
Happy Learning!!!!
0 Comments