Write a given command into an empty pluma text file and save it as "name.sh" (where "name" is some name you have given it that identifies the command contained in the file on some meaningful way). You need to save the file to /home/username/.config/caja/scripts (where "username" is your own username)
You will notice that the ".config" part of that save-path has a "." just in front of it. This means it is a hidden folder. So, when you save your file, you will need to ensure that all hidden files and folders are visible in the save dialog box in order for you to be able to navigate to the correct folder. See below:
Once you have saved it. Close pluma, open your home folder in caja and press CTRL/h and this will display your hidden files and folders. Navigate to your file contained in the /home/username/.config/caja/scripts folder. Once there, right-click the file and choose "properties". Then, choose the "permissions" tab and check the "allow executing file as program" checkbox. See below:
Then close the "properties" dialog box and close caja so that you are back at the desktop.
If you now right-click to bring up your context menu you will notice that there is a new item displayed called "scripts". If you go into the "scripts" sub-menu you will see your newly created file and, if you select that file, your command will execute.
I should also say, you are able to create sub-folders in the scripts folder and place your various scripts in the sub-folders. That way, if you end up creating a large number of useful scripts, you don’t have to have them all in a single big column in the context-menu scripts folder. In other words, you can organize them according to their function. See below:
However, there is one caveat to the above. If your command contains the "sudo" sub-command, then it would, all other things being equal, require that you enter your login password in order for the command to execute. This is fine if you are executing your command inside a terminal, since it gives you the opportunity to enter your password. However, by executing it from the context menu, you are not given this opportunity. In which case, the command will simply not execute.
I am about to show you a method for getting around the requirement for a sudo password, in turn allowing commands to be successfully executed from the caja-script context menu even if they contain a sudo sub-command inside them.
The following steps show how to disable the sudo password prompt, thus rendering you no longer required to enter it,
Be warned, though. Disabling your sudo password requires that you edit a very important file called the “sudoer” file and if you screw up while you are editing it, you can knacker your entire system and you will have to re-write it. I know this because I have done precisely that myself on a previous occasion. Furthermore, disabling your sudo passsword prompt is viewed by some as leaving your system less secure. However, I am less personally concerned about this than others and so I have no problem with disabling it. It's a matter of taste and risk-tolerance I guess. In any event, you still have to enter your password at boot-up.
-
Open up a terminal. Type “sudo visudo” and press the “Enter” key. After typing in your password at the prompt, press “Enter”. You will be taken into something called the “sudoer” file.
-
Hold the down arrow key and you will see the cursor move to the bottom of the file. Paste the following line below all other lines (in order to paste using only the keyboard in a terminal, you need to press the CTRL/SHIFT/V keys simultaneously):
yourusername ALL=NOPASSWD: ALL
where “yourusername” should be replaced with your actual user-name (mine, for example, is “stephen”)
- You now need to save and close the file. To do this you need to:
a) press CTRL and X
b) You will be prompted to type Y or N in order to save or discard the modifications. You must type Type Y
c) You will be given another prompt for the name that is given. Simply press the “Enter” key.
You should now find you have dropped out of the sudoer file and are back at the normal terminal prompt. That's it, you can close the terminal at that point. From now on, any time you would normally be asked for your password in a terminal, you now won't be.
I have noticed that the above procedure seems to have the effect of requiring you to enter fewer passwords on the main GUI desktop as well. But you are still asked for them sometimes when doing things like system management stuff (installing certain software in the software centre or opening synaptic, etc).
P.S.
I've just had a hunt about on the Ubuntu forums and the commands for shutting down/restarting your system are:
sudo shutdown -r now = to reboot the system
sudo shutdown -h now = to close the system
sudo halt -p = to shut and turnoff the system
sudo halt = to close the system
sudo reboot = to reboot the system
You could test these from a terminal first to see how they work and what, if any, differences there are between them. My guess is the first two will be best suited to your needs.