Default GUI Boot Configuration Level 1 Linux KodeKloud Engineer Task Success Sshpass script to Automate task

Ticker

6/recent/ticker-posts

Default GUI Boot Configuration Level 1 Linux KodeKloud Engineer Task Success Sshpass script to Automate task

 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.

Please Note :-  Perform the below commands based on your question  server,  user name & other details might differ . So please read task carefully before executing. All the Best 👍


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 BigGr33n  ssh -o StrictHostKeyChecking=no banner@stapp03 "echo BigGr33n  | sudo -S systemctl set-default graphical.target" 


3. Run Below command to restart the services on all app servers
        

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"


4. Post set default start graphical service & validate  the status on all the app server


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"


                
 5.  Click on Finish & Confirm to complete the task successful

Happy Learning!!!!


Apart from this if you need more clarity,  I have made a  tutorial video on this , please go through and share your comments. Like and share the knowledge




Post a Comment

0 Comments

Latest Posts

Timezone Alignment Level 1 Linux KodeKloud Engineer Task Success  Sshpass script to Automate task