Welcome to the Treehouse Community

Want to collaborate on code errors? Have bugs you need feedback on? Looking for an extra set of eyes on your latest project? Get support with fellow developers, designers, and programmers of all backgrounds and skill levels here with the Treehouse Community! While you're at it, check out some resources Treehouse students have shared here.

Looking to learn something new?

Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and join thousands of Treehouse students and alumni in the community today.

Start your free trial

Development Tools Console Foundations Users and Permissions Sudo

adam jensen
PLUS
adam jensen
Courses Plus Student 8,652 Points

What is the difference between !! (bang) compared to using the UP arrow to scroll through previous commands?

Any explanation would be apprciated..

3 Answers

Gavin Ralston
Gavin Ralston
28,770 Points

One doesn't require your hands to leave the home row, where some smaller keyboards have the arrows in different spots, making running the previous command easier with !! than an up arrow.

Edgar Lopez
Edgar Lopez
3,003 Points

What people are missing is that !! gives you the ability to run an altered version of the previous command. Like in the example of running a command that needs sudo, but you forget to type it. you then type: sudo !!

and that runs the previous command with the "sudo" preceding it.

hitting up would just give you the same previous command, that did not run the last attempt

I think the !! command is useful because you dont need to move your cursor all the way to the beginning to add sudo, for example, as well as being convenient to add another command onto one you've just typed.