Commands I Needed to Start Using the Command Line

Basic Commands

The ls command list the contents of the current directory. A more detailed form would be ls -la which lists the contents along with their file permissions.

The cd command lets you move back and forth from folders by adding the folder name afterwards. cd .. lets you move back by one folder and cd - lets you jump back and forth between the last changed spots.

The mkdir command makes a folder while rmdir removes an empty folder.

cp can copy files where the the first group is the target and the second group is the destination.

mv moves files and works similarly to cp except the first group is deleted afterwards.

The rm command deletes a file and passing in additional flags like rm -rf would delete a whole folder along with its contents.

Useful Commands

man followed by another command would show the complete help section on how to use that command. Whenever I’m lost or forgot how to use a particular command, I would use this to figure out how it works.

sudo can be prepended to other commands that need super user permission to execute.

chmod can change the file permissions of a file enabling you to edit or use thE FIle.

grep lets you search through the file’s or output’s contents using a regular expression. There are other commands that other people use to perform the same function but this is the most common one.

head and tail - Shows the first of last ten lines for a file or output. They’re useful for logs and when piping a string of commands.

rails has their own set of commands along with rake commands for migrations. I end up using rails console the most when debugging a problem or exploring an application.

Optional Commands

vagrant up and vagrant ssh - I had a lot of trouble with setting up a development environment since I had a Windows 8 laptop. I learned that Vagrant was the easiest way to start using a virtual machine at the time and I started with the rails dev box.

rvm was how I managed my environments and it helped me separate incompatible gems. A Gemfile should manage most of these but I had trouble figuring out where errors were coming from when installing gems and this was an easier solution at the time.

vim - I started with vim because I couldn’t figure out how to share folders between the virtual machine and the local machine but I ended up enjoying being able to quickly switch between the editor and shell so much that I stuck with it.

tmux - I began learning this on an Upcase trail and using it finally convinced me to install a Linux distribution. It became more evident that developing in a virtual machine was the bottleneck for me when I became comfortable enough in a tmux session, especially when running tests.