Unix commands that are actually useful…

It’s been a hot minute since I’ve been on here. I graduated from Flatiron School’s SENG Immersive at the end of January 2021, took a bit of time to myself, and then at the end of February, started a job as a junior developer. It’s been kind of a hectic time for sure. At Flatiron School, we are taught concepts in principles using Ruby on Rails and JavaScript, which is great! Until, you get a job using Go and TypeScript…then, everything is kind of thrown out the window.

In the last 4–5 weeks, I have really started to get comfortable in Go and TypeScript, but also…in my terminal. As new devs, I think we tend to forget the power of efficiency that your terminal gives you. How efficiently and quickly you get your tasks done sometimes boils down to how little you touch your mouse. I recently took a 4 week course from John Hopkins University on Unix on Coursera, and it was fantastic. Here are my favorite tools that I use daily in my work:

  1. The most basic and most useful: cd
    If changing directories isn’t the first thing you learn in your command line, I don’t know what is. The power of moving through all your files and folders seamlessly without needing to visually search: *chef’s kiss*. Don’t forget cd .. to move back/up and cd ~ to get back to your home directory.
  2. Another basic: ls
    Forget what’s in your current directory? Type ls and see all the files and directories you can head into.
  3. mkdir/rmdir
    In my bootcamp, I saw a lot of my instructors creating folders and files from VSCode. Of course, this isn’t a bad way to do it. And it’s pretty quick as well. But what’s faster? mkdir. In your terminal, type mkdir <directory-name>. A nice ls will show you that you just made a new folder with that directory name.
    If you change your mind, rmdir <directory-name> removes that directory.
  4. touch
    Going along with mkdir, touch creates files. I notice myself using this a lot in React. Rather than creating components and containers after components and containers in VSCode, a simple touch <file-name> in your terminal does the same thing. Use a relative path or cd into the right directory if needed. Use rm <file-name> to remove.
    This will add the file right where you want it: touch src/results/containers/resultsContainer.tsx
  5. clear
    Some people use command+K to clear our their terminal, but I like clear. With clear, if you need to, you can always scroll up and see what you were just doing. For anxious-folk like myself, it can be a real lifesaver where command+K would be a real nightmare. But if you’re already used to command+K, the next one is your friend.
  6. history
    Ever wondered what were your last command line commands? Yes, the up and down arrows show you them one by one, but history shows you all the commands you’ve written in this current shell. A life saver when you need a command you used an hour ago and can’t remember for the life of you what dependencies you used. Now, instead of re-googling that command, history will show you right away.
  7. echo
    The terminal’s own console.log(), print, fmt.Println, etc.
  8. >
    I don’t actually know what to call this, but it’s NOT “greater than” (The command line has -gt for greater than). > lets you add lines to files, or add files into files. Say you want the line “There will be ice cream” in a file. No need to open that file and type it in there. From your terminal, type echo "There will be ice cream" > file-name and there you go. That line is now in your file.
  9. cat
    Speaking of adding things into files, say you want a whole file’s content to also be in another file. cat file-name > other-file-name.
    OR, you have a small file you need to read the contents of: cat file-name. There’s the file’s content right in your terminal.
  10. mv
    Move. You want to move a file into a different directory? mv file-name directory-name. Simple as that.
  11. cp
    Copy. You want a file to stay in it’s current directory, but also be in a different directory. cp file-name directory-name.
  12. man
    Saving the best for last, say you want to see what other commands are out there for you in your terminal, man. man is your directory of command line commands. If you have a specific command that you forget what dependencies you can add to it to get the exact action you want, man command-name to see that specific command’s definition and possible dependencies.

As junior developers, we are always searching for the next language/framework to learn or the next data structure and algorithms course to take to ace our interviews. But I’d like to challenge all of us to take a breather and think about what would make me the most effective programmer right now? The truth is, you’ll always have to continue learning, whether you have a job or are searching for one. But as time goes on in your career, you’ll have less time to code the same amount of work, so get good at being as efficient as possible from the beginning and embrace your command line.

Software Engineer