I do awesome things and write about them

The Basics of using Command Line

The Basics of using Command Line

During my recent decision to take on some projects for my Raspberry Pi over Christmas, one of the little things I often struggle with is using the command line. I loved working on Craig Richardson’s Python Programming with Minecraft Pi, but sometimes it referenced tasks such as installing a program, creating a directory or copying files from one directory to another using command line, and I think it had an assumption that the user would know how to perform these tasks. Unfortunately, not only am I not confident using command line, but when I do learn how to perform a task, I often forget it quite quickly.

In order to try and combat this I have created this command line cheat sheet (some is Raspberry Pi specific);

Setup
username    pi
password    raspberry
launch desktop     startx
Packages
to update the OS software sudo    apt-get update
sudo is seen in a lot of commands, it means that the command following it will be executed as a superuser, and is used to get updates and install programs
apt-get is a packaging tool (a package is a piece of software), and can be used to install, remove, update and upgrade packages
if the required package is in the repository, you can simply type sudo apt-get install (package name), if the package is not in the repository it become a touch more complicated, and is not covered here
Navigation
to display which directory you are currently in with full path (print working directory)    pwd
to list contents of the current directory    dir
to list contents of the current directory, with type indicator    ls
to move into a directory    cd (directory name)/
typing the first few letters of the directory followed by tab will auto complete the directory name
to go down one directory    cd ../
Directory Management
to make a new directory in current location    mkdir (directory name)
to copy a file from one directory to another    cp (enter path of current location) (file name) (enter path of new location)
to move a file from one directory to another    mv (enter path of current location) (file name) (enter path of new location)
File Management
to unzip the contents of a file to current directory    unzip (path to file)
to unzip the contents of a file to specified location    unzip (path to file) -d (path to desired location)
Quick Tip
arrow up will recall the last entered piece of code, continue to arrow up to scroll through code from most recent to least recent

Thanks for reading!
GirlGeekUpNorth
Like me on Facebook - Follow me on Instagram - Follow me on Twitter

Leave a Reply

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.