Common Commands

I got this idea from a posting on circuit basic, the idea is it list 42 commands you us often but struggle to remember the syntax. I have personalized it extending the idea to include Python.

General Commands

  • clear: Clears the terminal screen of previously run commands and text.
  • find / -name example.txt: Searches the whole system for the file example.txt and outputs a list of all directories that contain the file.
  • shutdown -h 01:22: To shutdown at 1:22 AM.

File/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.
  • 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).
  • ls -l: Lists files in the current directory, along with file size, date modified, and permissions.
  • 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.
  • rm example.txt: Deletes the file example.txt.
  • rmdir example_directory: Deletes the directory example_directory (only if it is empty).

Networking/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.
  • wget http://www.website.com/example.txt: Downloads the file example.txt from the web and saves it to the current directory.

System Information Commands

  • 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 | grep XXX: Shows all of the installed packages that are related to XXX.
  • dpkg –get-selections: Shows all of your installed packages.
  • hostname -I: Shows the IP address of your Raspberry Pi.
  • lsusb: Lists USB hardware connected to your Raspberry Pi.
  • vcgencmd measure_temp: Shows the temperature of the CPU.
  • vcgencmd get_mem arm && vcgencmd get_mem gpu: Shows the memory split between the CPU and GPU.

Taking Screenshots

The ‘scrot’ application is great for this – it comes ready installed in Rasbian

scrot -d10   -- to delay 10 seconds before you take the picture
scrot -s     -- to select a particular bit of the screen

for more have a look at this post on raspberry-pi-spy

Python Commands  – this is a still work in progress

%a Weekday as locale’s abbreviated name. Mon
%d Day of the month as a zero-padded decimal number. 30
%b Month as locale’s abbreviated name. Sep
%B Month as locale’s full name. September
%m Month as a zero-padded decimal number. 09
%Y Year with century as a decimal number. 2013
%H Hour (24-hour clock) as a zero-padded decimal number. 07
%-H Hour (24-hour clock) as a decimal number. (Platform specific) 7
%I Hour (12-hour clock) as a zero-padded decimal number. 07
%M Minute as a zero-padded decimal number. 06
%S Second as a zero-padded decimal number. 05
%x Locale’s appropriate date representation. 09/30/13
%X Locale’s appropriate time representation. 07:06:05
Advertisements