Basic Linux terminal commands
After using the Raspberry pi for a really long time now, I’ve finally begun to love the Linux way of things and the power it gives the user. All the commands listed below are from Linux. The Raspberry Pi itself is Debian. Only some path names mentioned below are specific to the Rpi, everything else is same for any Linux distro.
Basic Linux Commands
ls---> list the files in current directorysudo mkdir---> make a new directory (folder)cd /path_to_directory---> navigate to certain directorysudo nano /path_to_file---> text editorsudo rm /path_to_file---> delete a filechmod +x /path_to_file---> make script into executable filesudo reboot---> reboot the deviceshutdown -h now---> shutdown the devicechromium-browser www.google.com---> Open Chromium and go to given URLclear---> clear the terminalpython /path_to_file---> run python scriptsudo pip install package_name---> used to install python packages in rpisudo pip uninstall package_name---> used to uninstall python packages in rpisudo touch /path_to_file---> create a new file at the specified locationsudo apt-get update---> fetch information about latest releasessudo apt-get upgrade---> upgrade OS to latest releasesudo apt autoremove---> to remove downloaded package files after installationkillall name_of_application---> to kill applicationsapt-list --installed---> view list of all installed packagesdf -h---> display disk space informationlxterminal ./path_to_script---> run a bash script in new terminalifconfig---> get IP address and details of network interfaces
Set watchdog to reboot from a crash
sudo nano /etc/systemd/system.conf
Then edit the following lines to:
RuntimeWatchdogSec=20
ShutdownWatchdogSec=10min
Run a command at startup
Edit the following file and add the full path to your script
sudo nano /etc/xdg/lxsession/LXDE-pi/autostart
Add @sh /full_path_to_script
Fetch IP address
gw = os.popen("ip -4 route show default").read().split()
s = socket.socket(socket.AF_INET, socket.SOCK_DGRAM)
s.connect((gw[2], 0))
ipaddr = s.getsockname()[0]
ipdisplay.value = ipaddr
Comments