SOHO : Small Office Home Office
Freeware - Opensource software tips, tricks, tweaks & fixes for managing, securing, improving the performance of SOHO Desktop, Laptop, Networks

Friday, April 16, 2010

Working quicker in Ubuntu by using bash scripts

I’m sure that there are a couple of commands you use on a regular basis when working in Ubuntu. I for instance often open the file browser by pressing ALT+F2 and entering ‘gksu nautilus’ which opens the file browser as root. The same goes for the ‘gksu gnome-terminal’ command. Entering commands with ALT+F2 is cool and all but when the commands start to leave a lot of room for typo’s it can be annoying.

I knew that I could make bash scripts in Linux to execute certain commands so I figured I’d simply make some bash scripts for these commands. The way to do that is like so:

Press ALT+F2 and enter ‘gksu gedit /usr/local/bin/sunau’. This opens the text editor with new file called ’sunau’ in the location /usr/local/bin. We’ll make a script in this file that opens the file browser as root. Enter the following into the empty file:

#!/bin/bash
gksu nautilus

Now save the script and close the editor. The only thing left now is to make the script executable. Press ALT+F2 again and enter ’sudo chmod +x /usr/local/bin/sunau’. After this you can call your script by pressing ALT+F2 and entering ’sunau’. This will start the file browser as root. By changing the contents of the file you can execute all kinds of commands with bash scripts.

No comments:

Post a Comment