Making the terminal more friendly

4 03 2008

Ah the terminal, the terrifying black box that scares many new users off. “But don’t you have to program it and use it all the time?” is regularly heard from uninformed Windows and Mac users. Once you give it a go though, the terminal is your friend, the stigma lifts and you realise its your flexible customisable friend! One thing that I find really annoying though, is the way that you have all these commands and keywords to remember, I especially have using chmod and all its options, as well as tar. They’ve got loads of different arguments when in reality, you only use one particular combination all the time.

Heres where your .bashrc file comes in, with this file, you can make it easier to execute the commands you enter most often, imagine instead of having to type “sudo mount -t vfat /media/sbd1″, which I have to do everytime i want to mount my external hard drive (If you know of a fix, please tell me!), all you have to type is “mhd”!

This is really simple to do, all you have to do is add this line to your .bashrc file – alias mhd=”sudo mount -t vfat /media/sbd1″ Now every time you type mhd, it executes the command shown. Here’s a step by step

1. Open a terminal

2. Open the .bashrc file, “sudo gedit /.bashrc”

3. Add the required lines

4. Save the file

5. Run the following command, “source /.bashrc “

6. You’re good to go!


Actions

Information

6 responses

4 03 2008
Greg

It’s not a workaround but you could add it in System->Preferences->Session to startup every time you load your computer not only every time you open a terminal.

4 03 2008
slibuntu

I had a feeling that would be said all right, the only thing is, it’s not always connected to my machine, it’s a laptop, and when it is, I always forget to turn the friggin thing on until I go into Rhythmbox and all my songs start dissapearing! So I’d just like it to happen automatically when I plug it in, at this stage I’m hoping Hardy will solve the problem, given it wasn’t a problem under Dapper!

6 03 2008
Dr Small

You can also uncomment Alias definitions in .bashrc and then use .bash_aliases for all of your aliases ;)

9 03 2008
davetheroyale

Hey I’m glad that you are spreading the knowledge and learning. I like your blog.
please visit my one:
|Link removed| Reason: Spam, unrelated to computers

Keep it up.

9 04 2008
Morten Juhl-Johansen Zölde-Fejér

I made a launcher menu with buttons for such things, like for my wireless and clock update. As you can see from my screenshot from the day before yesterday, there is a screenshot button – essentially a shortcut to an ‘import’ command from ImageMagick.
And my wireless button is a shortcut for ’sudo dhcpcd ath0 && sudo ntpdate ntp.cyberdoc.dk’ in order to bring up the wireless and, at the same time, sync my clock.

22 04 2008
Brendon Dugan

Very nice post, I think BASH aliases are such a timesaver for simple tasks you do often. One thing I would like to say though, is that technically you should use the command ‘gksudo gedit /.bashrc’ , because that is safer with a graphical program like Gedit.

By the way, I found your blog on blogbuntu forums. Have a great day!

Leave a comment