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

General Discussion

What is the Command Line?

What is the command line? and why do we need to know how to use it?

Thank you

6 Answers

Thank you both I now have a better understanding on what the command line is and what it does, but I still dont understand, Why I need to use it? or when I would need to use it?

Mike Morales
Mike Morales
19,833 Points

Khader -

Using a terminal is a pretty powerful tool to use as well as knowing the different types of commands you can use to create a folder, and create another folder inside a folder. You can do a lot with the command lines such as shutdown your computer, visit a website(without the pictures, though), add files to a folder, and a ton more. You will need to know how to use commands in Ruby on Rails, I find Ruby on Rails to be a lot of fun.

You don't "need" to use it, but once you can use it it is very powerful and will vastly improve your workflow and understanding of the operating system IMO.

To add, you can:

  • automate things to improve your workflow - run scripts directly from the terminal to automate tasks, e.g. compile your css/software, check for code quality (jshint), and lots more. This would be cumbersome and take much longer using a GUI tool.
  • quickly search directories of files for text and patterns using tools like grep/ack/ag, then use the output in another program (pipes in unix)
  • automatically modify multiple files at once using tools like sed using regular expressions
  • access remote machines using ssh (e.g. your web server) and run scripts
  • deploy and update your software in a cluster (using git maybe)
James Barnett
James Barnett
39,199 Points

Writing scripts to automate things is like the greatest thing sense like ever.

My general view is if you want to do something across multiple files, the command line is great.

If you want to do something on a single file I've found it almost easier to find the right GUI. There are great GUIs for jshint, Sass, git, grep & ssh.

To echo Stein's comment about automating, here is a slightly exaggerated example. Imagine the scenario where you have 4000 CSV files in a folder, and you want to do this:

  • Extract values from the third column from each file except those where the line begins with a number or #
  • Sorted
  • Remove all duplicates

Here are how different people would approach the problem:

  1. Novices would try to use Excel before giving up;
  2. Programmers would start coding, estimated lines for this problem in C is 20 if you are good.
  3. Command line users would do this one line or something similar:
cat *.csv | grep '^[^0-9#]' | cut -d',' -f3 | sort | uniq > output