DEV Community

Arnold Ho
Arnold Ho

Posted on

Terminal 101 cheatsheet

Terminal/Console/Command Line cheatsheets like this is everywhere on the internet, however I am still going to make my own in the spirit of learning in public :)
Also please do let me know if I didn't get something quite right the first time!


pwd
Enter fullscreen mode Exit fullscreen mode

Print Working Directory, this will show you where you currently are


.
Enter fullscreen mode Exit fullscreen mode

A dot means your current directory, so the location shown when you type your pwd


..
Enter fullscreen mode Exit fullscreen mode

Your parent directory, this is one folder above your current directory


~
Enter fullscreen mode Exit fullscreen mode

This is your home directory


cd <folder_name>
Enter fullscreen mode Exit fullscreen mode

Change directory, this will move your position into the folder name, you can also cd into a path so that you can move a few folders in. You can also do cd .. to go back a directory


ls
Enter fullscreen mode Exit fullscreen mode

This will show all the files and folders in your current directory


ll
Enter fullscreen mode Exit fullscreen mode

Another way of checking all files and folders in your current directory, it will return a table format


mkdir <folder_name>
Enter fullscreen mode Exit fullscreen mode

Make directory, this will create a new directory at your current directory (This creates a folder within your current folder)


touch <file_name>
Enter fullscreen mode Exit fullscreen mode

This creates a file, for example, touch index.html creates index.html within your current directory


mv <file_location> <file_location2>
Enter fullscreen mode Exit fullscreen mode

This moves the file from location one to location 2.
For example:

mv index.html tmp/index.html
Enter fullscreen mode Exit fullscreen mode

moves the file index.html from the current directory into a directory called tmp within the current directory


rm <file_name>
Enter fullscreen mode Exit fullscreen mode

Remove, but PLEASE MAKE SURE YOU NO WHAT YOU"RE DOING WHEN YOU USE THIS. Sometimes a stack overflow answer might ask you to use this to clear a roadblock. THINK TWICE before blindly using rm because once you've removed your file. It's gone, you can't revert back the change unless you use version control.

When you use rm, sometimes your command prompt will have a safe gate message, this is because rm is so dangerous your terminal is asking you whether you are sure you wanna remove that thing. If you are 100% sure you want to rm something, do the following:

rm -rf <file_name>
Enter fullscreen mode Exit fullscreen mode

That's it for the Terminal 101 cheatsheet. These are the most basic command line tools you might use. I recommend trying to play around with this, create new files and folders, move things into different folders, and as much as possible try to navigate your files and folders using terminal only to get good.

For extra resource, try learn enough command line to be dangerous

Hope that helps and let me know what other command line tools you use daily :) Happy coding!

Top comments (0)