shortcut to restart or stop a service
Is it possible to make a shortcut on desktop to stop or restart a service in Linux?
Thanks in Advance hasmeet |
Greetingz!
Depending on your Windows Manger (GNOME or KDE), you can create a shortcut to run the commands needed to stop/start a service. Otherwise you'll have to write a tiny script, then create a shortcut for it. RHEL-based service servicename restart SVR4-based /etc/init.d/servicename restart BSD-based /etc/rc.d/rc.servicename restart Heck, if you use Fluxbox, you can just add a line in your ~/.fluxbox/menu file. |
Quote:
Thanks for your reply ..... Buddy....i am looking for that tiny script about which you were talking in your answer....Will you please help me in getting that script. |
Quote:
1) What UNIX/Linux distribution (and version) are you running? 2) What Window Manager are you running (GNOME, KDE, fluxbox, blackbox, etc) 3) The name of the service you're trying to restart? Bonus: How do you stop/start the service via the command-line? |
Quote:
GNOME service to be restarted is "network" |
Great! Let's get started!
Okay, in these examples, I make one very important assumption; "The user logged into GNOME is not root, and is just a regular user". Script-Method 1) First, let's make a place to store all the scripts you'll eventually write. Open a Terminal window, and type the following; mkdir ~/scripts 2) Now change into that directory cd ~/scripts 3) Use your favorite command-line text-editor (vim, nano, emacs...) vim ~/scripts/restart_network.sh 4) Put this into the script* service network stop ; sleep 3 ; service network start 5) Now save the script, and exit your text-editor. 6) Okay, now to make sure this script has the correct permissions chmod 4750 ~/scripts/restart_network.sh Note: We're setting a "sticky bit" (the "4" is used). This means the script will run with the permissions of the owner... 7) We're going to need to change the ownership, too. So (as root, or via sudo), do the following; chown root:wheel ~/scripts/restart_network.sh Note: So now whenever someone in the wheel group runs this script, it will run with root's permissions. Now just right-click on your desktop, select "Create Launcher", and fill in the "Name", "Command", and "Comment" fields! WARNING: SUID files can be dangerous make sure only root can modify the contents of those kinds of files! |
All times are GMT -5. The time now is 04:27 AM. |