DEV Community

Shreya
Shreya

Posted on

How to use the command line

Terminal

Mac:

  • Click the "spotlight search" icon in the top right corner.
  • Search for "terminal".
  • Click terminal to open it (right click it to run as admin).

terminal

Windows:

  • Click the search bar in the bottom left corner.
  • Search for "command prompt".
  • Click terminal to open it (right click and say "run as administrator" to run as admin).

commandprompt

Basic Terminal Commands

Shortcuts:

  • . : current directory
  • .. : previous directory
  • ~ : home directory

Directory (folder):

  • pwd : print current directory (if you're lost, or need the full path to the current directory you're in)
  • ls : list everything in current directory (super useful to know which files/folders you can currently access)
  • ls [directory path] : list everything in current [directory path]
  • cd [directory path] : change directory to [directory path]
    • cd /home/users/Shreya/Documents/terminal.md
    • cd . : change directory to current directory (doesn't really do much)
    • cd .. : change directory to previous directory (useful)
    • cd ../some_folder_name : change directory to some_folder_name directory in previous directory (sort of like going back one and into another folder)
    • cd . : change directory to home directory

Opening files (in terminal, you don't need this if you're using GitHub desktop)

In file:

Running a program

  • ./[program_name.extension] [any other expected arguments]
    • ./sumarray.js (week 2)
    • ./romanint.js 78 (week 3)

Find more useful commands: https://www.techrepublic.com/article/16-terminal-commands-every-user-should-know/

Not sure which command to use or how it works? Google it! Everyone uses terminal so there's a lot of useful content/blogs/video tutorials online. You can also ask your mentor for help if you're not sure where to start.

Top comments (5)

Collapse
 
rahul_1210 profile image
Rahul Prajapati

Good explanation thanks for the writing up.

Collapse
 
rahul_1210 profile image
Rahul Prajapati

in what technology you are into if i may ask?

Collapse
 
shreythecray profile image
Shreya

I wrote this up for a coding bootcamp I developed for JavaScript last year

Thread Thread
 
rahul_1210 profile image
Rahul Prajapati

Woah that sounds amazing Shreya. Me just started working on the Backend side development.

Thread Thread
 
rahul_1210 profile image
Rahul Prajapati

Have you heard about loopback4 framework?