Take the 2-minute tour ×
Raspberry Pi Stack Exchange is a question and answer site for users and developers of hardware and software for Raspberry Pi. It's 100% free, no registration required.

I'm very new to Linux environment and I just got myself a Pi to play with it. Recently I found this command to check my Pi's temperature which is /opt/vc/bin/vcgencmd measure_temp

Is it possible to save that command somewhere with a shortcut or an alias? So that I could just type in like checktemp and it would run the command.

Ignore me if I'm asking a nonsense question.

share|improve this question
add comment

3 Answers 3

up vote 6 down vote accepted

You can use the alias command. To make it persistent, you'll have to modify the ~/.bash_aliases file.

  1. Open the ~/.bash_aliases file with your favorite editor (nano, vim, ...)

    $ nano ~/.bash_aliases
    
  2. Add to the end of the file the following line

    alias checktemp='/opt/vc/bin/vcgencmd measure_temp'
    

    , where checktemp is the command you want to use.

  3. Exit your bash session:

    $ exit
    

    Then log in.

  4. You are ready to use your brand new command:

    $ checktemp
    temp=48.7'C
    
share|improve this answer
    
Exactly what I need. Thanks :) –  Ye Myat Aung Jan 3 '13 at 14:20
add comment

Don't need to exit bash, just reload your profile.

From anywhere: $ . ~/.profile

From your home dir: $ . .profile

share|improve this answer
add comment

What they did above was good. FYI .bash_aliases is not there by default in new Raspian OS. If you are using a non-root user to run these change the above that Morgan Courbet Said to this:

alias checktemp='sudo /opt/vc/bin/vcgencmd measure_temp'

Then reload like the others said like this:

. ~/.bash_aliases

So you can add a .bash_aliases and still work. I think its better than putting into another file since you usually want many aliases to make it easier. Also, for the sudo command to work, you need to have you user in visudo like this.

visudo

anthony ALL=(ALL:ALL) NOPASSWD: ALL

I hope this helps clarify some.

share|improve this answer
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.