Commands

GENERAL UNIX COMMANDS

  • sudo bash: Running as the super user
  • 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.
  • raspi-config: Opens the configuration settings menu.
  • cat /etc/os-release: Determine the OS running
  • clear: Clears previously run commands and text from the terminal screen.
  • find / -name example.txt: Searches the whole system for the file example.txt and outputs a list of all directories that contain the file.
  • man ls: show more information/help about the command for example “ls”
  • CNTR + U: Paste the line or words
  • CNTR + K: Cut the line or words
  • startx: Opens the GUI (Graphical User Interface).
  • poweroff: To shutdown immediately.
  • reboot: To reboot immediately.
  • shutdown -h now: To shutdown immediately.
  • shutdown -h 01:22: To shutdown at 1:22 AM.
  • sudo poweroff: shuts down

DATE COMMANDS

  • date: Prints the current date.
  • Change the clock format to : %d/%m/%Y %H:%M:%S

FILE AND DIRECTORY COMMANDS

  • mc: midnight commander. It is simply a file management tool that lets you easily copy/move/delete files and perform other operations          on them.
  • cat example.txt: Displays the contents of the file example.txt.
  • nano example.txt: Opens the file example.txt in the Linux text editor Nano.
  • 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; Example: 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).
  • cp oldfile newfile: This creates a copy of the same file with a new name in the same location.
  • cp -r Learning_Curve/ home/pi/Desktop/: This will copy the folder learning_curve and put into choosen directory.
  • ls -l: Lists files in the current directory, along with file size, date modified, and permissions.
  • ls -a: Lists all files including hidden file starting with ‘.‘.
  • mkdir example_directory: Creates a new directory named example_directory inside the current 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).
  • 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).
  • sudo rm -rf lampp: It deletes all files and folders contained in the lampp directory.
  • scp user@10.0.0.32:/some/path/file.txt: Copies a file over SSH. Can be used to download a file from a PC to the Raspberry Pi. user@10.0.0.32 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.
  • touch example.txt: Creates a new, empty file named example.txt in the current directory.
  • xdg-open 2A.pdf : Open 2A.pdf file using command

FILE PERMISSION AND DIRECTORY

  • sudo tar -xzf jdk-8u131-linux-arm32-vfp-hflt.tar.gz: Unzip the .gz
  • ls -l: Lists files in the current directory, along with file size, date modified, and permissions.
  • sudo chown pi: index.html: Change the owner of the file  to pi. It was owned by the root user before.
  • sudo chown pi:pi  button.py : Change the owner of the file  to pi. It was owned by the root user before.
  • sudo chown  pi:pi -R  ArinProject: Change all files in ArinProject folder the owner of the file  to pi. It was owned by the root user before.
  • chmod 777 my_app: Change the file for full permissions to read, write, and execute were to be given to everybody
  • sudo chmod -R 777 ArduinoQRcode/ : Change permission for all files inside that folder

OCTAVE COMMANDS

1) octave –force-gui : To launch OCTAVE with its GUI

2) octave-cli salam.m: To run/compile the file/program “salam.m” without making it executable.

3) chmod +x salam.m: Make a file executable. Making a Octave program executable allows you to run the program without entering octave-cli before the file name

4) ./salam.m: Run the program at the current directory.

 

C++ COMMANDS

1) nano salam.c: open the nano text editor and create a new file with a “ .c ” extension

2) gcc salam.c -o mysalam : Code written in C will need to be compiled before it can be run on a computer. Compiling is the process of converting the code you write into machine readable instructions that can be understood by the computer’s processor. When you compile your source file, a new compiled file gets created.

3) chmod +x mysalam: make the compiled file executable. To do that, we just need to change the file permissions.

4) ./mysalam: Run the program at the current directory.

 

NETWORKING AND INTERNET COMMANDS

  • chromium-browser http://google.com.my : Open the google website using terminal

1) ifconfig: To check the status of the wireless connection you are using (to see if wlan0 has acquired an IP address).
At wlan0, you will see the ip address. For eg: inet: 192.168.43.229

2) iwconfig: To check which network the wireless adapter is using.

3) iwlist wlan0 scan: Prints a list of the currently available wireless networks.

4) iwlist wlan0 scan | grep ESSID: Use grep along with the name of a field to list only the fields you need (for example to just list the ESSIDs).

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

6) 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.

7) ping www.google.com: To test your Pi’s WIFI connection to the internet by pinging google.com

8) wget http://www.website.com/example.txt: Downloads the file example.txt from the web and saves it to the current directory.

9) sudo nano /etc/wpa_supplicant/wpa_supplicant.conf : check and add wireless network details like ID and password

SYSTEM INFORMATION COMMANDS – Memory Size

1) cat /proc/meminfo: Shows details about your memory.

2) cat /proc/partitions: Shows the size and number of partitions on your SD card or hard drive.

3) cat /proc/version: Shows you which version of the Raspberry Pi you are using.

4) df -h: Shows information about the available disk space.

5) df /: Shows how much free disk space is available.

6) dpkg – –get–selections | grep XXX: Shows all of the installed packages that are related to XXX.

7) dpkg – –get–selections: Shows all of your installed packages.

8) free: Shows how much free memory is available.

9) hostname -I: Shows the IP address of your Raspberry Pi.

10) lsusb: Lists USB hardware connected to your Raspberry Pi.

11) UP key: Pressing the UP key will print the last command entered into the command prompt. This is a quick way to repeat previous commands or make corrections to commands.

12) vcgencmd measure_temp: Shows the temperature of the CPU.

13) vcgencmd get_mem arm && vcgencmd get_mem gpu: Shows the memory split between the CPU and GPU.

14) tree -d: Show a tree of directories like “windows file explorer”

15) getconf LONG_BIT: Determine the OS Bit of Raspbian. Since Raspberry Pi is powered by ARM processor and Raspbian is a 32-bit OS

UNIX COMMANDS

1) ps aux :list all processes and their status and resource usage.

a = show processes for all users
u = display the process’s user/owner
x = also show processes not attached to a terminal

2) ps aux  | grep /home/pi/LED.py : list all process by searching the text “/home/pi/LED.py”

3)