Recently, I found myself in a technical challenge using Bash, which is a Unix shell and command language. One of the tasks involved a reorganization of a directory, with specific files of different types ending up in different directories. This took me back to one of the first things I learned when programming, and I though I’d revisit this with this piece. Below I review some of my most used commands.

mkdir

This is generally a command I’ll use when setting up a new app or new code base, it stands for “make directory”. The directory remains empty until files are added to it, possibly using the next command.

touch

This will create a new file, whether on its own or within a directory. In both mkdir and touch, the created file or directory must be named at the time of creation. This leads to commands that look like “mkdir newdirectory” or “touch newdirectory/newfile.js” (.js being the file extension for a javascript file.

pwd

This one stands for “print working directory”. When using the terminal with unix commands, it can be easy to get lost within the directories of a system. the command pwd will print to the screen the current directory, essentially a “where am i” command, very helpful for determining your location when navigating.

ls

This is the list command, this will display to the screen a list of what the contents are of the current directory. This allows for easier navigation down into other directories and files.

cd

Standing for “change directory”, this will allow you to navigate up and down a directory. This is one I use most often when navigating, as I can call a specific directory I want to navigate to, or go back up a directory with the command “cd ..”, or go to the top of my directory tree with “cd ~”

rm

This is one you should be very careful when using, as this is the remove command. Warning: there is no confirmation once this command is entered, and will execute immediately, so be sure when using this command.

Flatiron School DC. Learning to code one day at a time.