Skip to content

Instantly share code, notes, and snippets.

@innat
Last active May 9, 2018 09:16
Show Gist options
  • Select an option

  • Save innat/92c29a45ffdd73b0e327301840e9b3b3 to your computer and use it in GitHub Desktop.

Select an option

Save innat/92c29a45ffdd73b0e327301840e9b3b3 to your computer and use it in GitHub Desktop.

General Commands

  • apt-get update

    Synchronizes the list of packages on your system to the list in the repositories. Use it before installing new packages to make sure you are installing the latest version.

  • apt-get upgrade

    Upgrades all of the software packages you have installed.

  • clear

    Clears previously run commands and text from the terminal screen.

  • date

    print the current date

  • nano

    Opens the file example.txt in the Linux text editor Nano

  • raspi-config

    Opens the configuration settings menu.

  • reboot

    To reboot immediately

  • poweroff

    To shutdown immediately

  • shutdown -h now

    To shutdown immediately

  • shutdown -h 01:22

    To shutdown at 1:22 AM.

    
    

File and Directory Commands

  • cat example.txt

    Displays the contents of the file example.txt.

  • cd /abc/xyz

    Changes the current directory to the /abc/xyz directory

  • ls -l

    Lists files in the current directory, along with file size, date modified, and permissions.

  • cp XXX

    Copies the file or directory XXX and pastes it to a specified location; i.e. cp examplefile.txt /home/pi/office/ copies examplefile.txt in the current directory and pastes it into the /home/pi/ directory. If the file is not in the current directory, add the path of the file’s location (i.e. cp /home/pi/documents/examplefile.txt /home/pi/office/ copies the file from the documents directory to the office directory).

  • mv XXX

    Moves the file or directory named XXX to a specified location. For example, mv examplefile.txt /home/pi/office/ moves examplefile.txt in the current directory to the /home/pi/office directory. If the file is not in the current directory, add the path of the file’s location (i.e. cp /home/pi/documents/examplefile.txt /home/pi/office/ moves the file from the documents directory to the office directory). This command can also be used to rename files (but only within the same directory). For example, mv examplefile.txt newfile.txt renames examplefile.txt to newfile.txt, and keeps it in the same directory

  • mkdir example_directory

    Creates a new directory named example_directory inside the current directory

  • rm example.txt

    Deletes the file example.txt

  • rmdir example_directory

    Deletes the directory example_directory (only if it is empty)

  • rm -rf theDir

    Removing directories and the stuff in them.

  • touch example.txt

    Creates a new, empty file named example.txt in the current directory.

  • scp [email protected]:/some/path/file.txt

    Copies a file over SSH. Can be used to download a file from a PC to the Raspberry Pi. [email protected] is the username and local IP address of the PC, and /some/path/file.txt is the path and file name of the file on the PC.

    
    

Networking and Internet Commands

  • ifconfig

    To check the status of the wireless connection you are using (to see if wlan0 has acquired an IP address).

  • iwconfig

    To check which network the wireless adapter is using

  • iwlist wlan0 scan

    Prints a list of the currently available wireless networks.

  • nmap

    Scans your network and lists connected devices, port number, protocol, state (open or closed) operating system, MAC addresses, and other information.

  • ping

    Tests connectivity between two devices connected on a network. For example, ping 10.0.0.32 will send a packet to the device at IP 10.0.0.32 and wait for a response. It also works with website addresses.

  • wget http://www.website.com/example.txt

    Downloads the file example.txt from the web and saves it to the current directory.

    
    

System Information

  • cat /proc/meminfo

    Shows details about your memory.

  • cat /proc/partitions

    Shows the size and number of partitions on your SD card or hard drive.

  • cat /proc/version

    Shows you which version of the Raspberry Pi you are using.

  • df -h

    Shows information about the available disk space

  • df /

    Shows how much free disk space is available.

  • dpkg ––get–selections

    Shows all of your installed packages.

  • free

    Shows how much free memory is available

  • hostname -I

    Shows the IP address of your Raspberry Pi

  • lsusb

    Lists USB hardware connected to your Raspberry Pi

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment