Using your mac terminal 101

As a web-developer, utilising your terminal becomes crucial as you do the following:

  1. Install Packages
  2. Configure & run scripts
  3. Access a file quickly
  4. Make changes to a file
  5. Integrate the github in the terminal

Manipulating the terminal is a very useful skill that will serve you well in the long term as a developer.

Let’s learn some basics:

  1. How to Clear the terminal
    • type CMD + K or clear + enter
  2. How to access a certain folder
    • cd = change directory
  3. How to list the contents of a certain folder
    • ls : list item
  4. How to exit a directory to go back to previous folder
    • cd ..
  5. How to find out which directory we are at
    • pwd
  6. How to delete files
    • rm filename
  7. How to create a file
    • touch filename.txt
    • you can create other types of files if you want too!
  8. How to download files from a given link with the cURL command
    • The term “cURL” stands for “Client URL,” referring to the command-line tool and library for transferring data with URLs. cURL is widely used for transferring data to or from a server, supporting various protocols such as HTTP, HTTPS, FTP, FTPS, SCP, SFTP, LDAP, TFTP, and many others. It’s a versatile tool commonly used in scripting, testing, and debugging network-related tasks.
      • copy the url of the file you want to download
      • change directory to desktop cd desktop
      • make new directory: mkdir curl/any file name
      • change into the directory we just created: cd curl
      • ls to see what’s in there (you’re expecting nothing here)
      • curl <insert url you copied in step 1>
      • then, in the same line put -o (small o) Intro_To_ Computing (file name you’d like) if you want to keep the file as is, then see step 11
      • type ls to see if that’s there
      • press nano filename
      • you can see that on the terminal
  9. Naming Conventions for cURL: You can also control how you want your files to be named when you are downloading the files given the URL
    • curl -O (capital O) to keep the original file name
    • Note: Keep no spaces in your file name, if not you’re gonna mess up the file when it’s downloading!
  10. How to download multiple files if each of their url’s are specified in a txt file.
    • I know that this seems like a very specific problem to solve, but it is solvable because it was the foundation of Project Kiowa Calendar
    • So, if you ever find yourself in a situation where you have to download multiple files from a txt file which has the url’s of the files you want to download. Simply use this command.
      • extract all the URL’s of the files you want to download and put it into a txt file
      • wget -i filename.txt (the command to be run in your terminal)
      • Make sure that the file exists in the same directory as you are on 2

Final Thoughts:

Being familiar with the terminal can improve your development process and enhance your toolkit as a web developer. Google & Stack Overflow are your best friends when you run into problems. While the list of basic functions is not exhaustive, make sure you explore different terminal commands and practice them.

Please note that these commands work for mac only!

This entry was posted in Coding. Bookmark the permalink.

Comments are closed.