Difference between revisions of "Linux cheat sheet"
Directive0 (Talk | contribs) (Created page with "==Run a process beyond an SSH session.== Useful for SSH’n into a machine and then starting a process and being able to close the session without killing the job. Also useful...") |
Directive0 (Talk | contribs) (→get st7735 screen working on pi02w) |
||
(19 intermediate revisions by the same user not shown) | |||
Line 1: | Line 1: | ||
− | ==Run a process beyond an SSH session | + | These tips seem to work with Raspbian and in some cases Ubuntu. |
+ | |||
+ | ==Run a process beyond an SSH session== | ||
Useful for SSH’n into a machine and then starting a process and being able to close the session without killing the job. Also useful for running multiple programs in one ssh session. | Useful for SSH’n into a machine and then starting a process and being able to close the session without killing the job. Also useful for running multiple programs in one ssh session. | ||
− | Install screen if you haven’t already | + | Install [https://linux.die.net/man/1/screen screen] if you haven’t already |
− | sudo apt-get install screen -y | + | sudo apt-get install screen -y |
Run screen on the server and use -S flag to give the session a name. | Run screen on the server and use -S flag to give the session a name. | ||
− | screen -S myjob | + | screen -S myjob |
Log in via ssh from the remote machine and use the -x flag to attach to that session | Log in via ssh from the remote machine and use the -x flag to attach to that session | ||
− | screen -x myjob | + | screen -x myjob |
+ | Press ctl-a and then ctl-d to switch back without closing, or issue the command | ||
− | ==Run a program on a remote display | + | exit |
+ | |||
+ | to close the screen session. | ||
+ | |||
+ | ==Run a program on a remote display== | ||
When you run graphical programs over SSH the server will often throw errors about no screen being present. You need to put the display you want have the program to display to in your environment. You can do this by first runing “w” to see connected displays and then: | When you run graphical programs over SSH the server will often throw errors about no screen being present. You need to put the display you want have the program to display to in your environment. You can do this by first runing “w” to see connected displays and then: | ||
Run export to bring the proper display into your environment. | Run export to bring the proper display into your environment. | ||
− | export DISPLAY=:0 | + | export DISPLAY=:0 |
Run your program. | Run your program. | ||
− | + | python3 samplepythoncode.py | |
− | Quickly determine Pi CPU temperature | + | ==Quickly determine Pi CPU temperature== |
Run the following command in terminal. | Run the following command in terminal. | ||
− | /opt/vc/bin/vcgencmd measure_temp | + | /opt/vc/bin/vcgencmd measure_temp |
− | ==Set up wifi on a Pi with simple file | + | ==Set up wifi on a Pi with simple file== |
Create a file called “wpa_supplicant.conf” with the following content and place at root of “boot” | Create a file called “wpa_supplicant.conf” with the following content and place at root of “boot” | ||
− | network={ | + | network={ |
ssid="SSID Name" | ssid="SSID Name" | ||
psk="Password" | psk="Password" | ||
key_mgmt=WPA-PSK | key_mgmt=WPA-PSK | ||
− | } | + | } |
+ | |||
+ | ==Run Process At Startup== | ||
+ | |||
+ | You can add the job to the crontab | ||
+ | crontab -e | ||
+ | @reboot sleep 60;export DISPLAY=:0 && export XAUTHORITY=/home/user/.Xauthority && cd /home/pi/picorder/ && python picorder.py | ||
+ | |||
+ | |||
+ | Or add it to /etc/rc.local | ||
+ | cd /home/pi/Documents/picorderOS/ | ||
+ | su pi -c "python3 main.py" & | ||
+ | |||
+ | ==Swap Keyboard Key== | ||
+ | |||
+ | xmodmap -e "keycode 94 = Shift_L" | ||
+ | |||
+ | ==Get Pygame2 to work properly on raspberry pi== | ||
+ | |||
+ | sudo apt-get install libsdl2-mixer-2.0-0 | ||
+ | sudo apt-get install libsdl-ttf2.0-0 | ||
+ | sudo apt-get install libsdl-gfx1.2-5 | ||
+ | sudo apt-get install libsdl2-image-2.0-0 | ||
+ | |||
+ | ==get st7735 screen working on pi02w as display== | ||
+ | |||
+ | https://github.com/degzero/st7735fb | ||
+ | |||
+ | https://github.com/degzero/Python_ST7735 | ||
+ | |||
+ | https://www.youtube.com/watch?v=dj0WrkpPRho&ab_channel=Prajnith | ||
+ | |||
+ | sudo nano /boot/cmdline.txt | ||
+ | fbcon=map:10 fbcon=font:VGA8x8 | ||
+ | |||
+ | |||
+ | https://tejaswid.github.io/wikitm/rpi/pi-tft-display |
Latest revision as of 07:55, 10 May 2023
These tips seem to work with Raspbian and in some cases Ubuntu.
Contents
[hide]Run a process beyond an SSH session
Useful for SSH’n into a machine and then starting a process and being able to close the session without killing the job. Also useful for running multiple programs in one ssh session.
Install screen if you haven’t already
sudo apt-get install screen -y
Run screen on the server and use -S flag to give the session a name.
screen -S myjob
Log in via ssh from the remote machine and use the -x flag to attach to that session
screen -x myjob
Press ctl-a and then ctl-d to switch back without closing, or issue the command
exit
to close the screen session.
Run a program on a remote display
When you run graphical programs over SSH the server will often throw errors about no screen being present. You need to put the display you want have the program to display to in your environment. You can do this by first runing “w” to see connected displays and then:
Run export to bring the proper display into your environment.
export DISPLAY=:0
Run your program.
python3 samplepythoncode.py
Quickly determine Pi CPU temperature
Run the following command in terminal.
/opt/vc/bin/vcgencmd measure_temp
Set up wifi on a Pi with simple file
Create a file called “wpa_supplicant.conf” with the following content and place at root of “boot”
network={ ssid="SSID Name" psk="Password" key_mgmt=WPA-PSK }
Run Process At Startup
You can add the job to the crontab
crontab -e @reboot sleep 60;export DISPLAY=:0 && export XAUTHORITY=/home/user/.Xauthority && cd /home/pi/picorder/ && python picorder.py
Or add it to /etc/rc.local
cd /home/pi/Documents/picorderOS/ su pi -c "python3 main.py" &
Swap Keyboard Key
xmodmap -e "keycode 94 = Shift_L"
Get Pygame2 to work properly on raspberry pi
sudo apt-get install libsdl2-mixer-2.0-0 sudo apt-get install libsdl-ttf2.0-0 sudo apt-get install libsdl-gfx1.2-5 sudo apt-get install libsdl2-image-2.0-0
get st7735 screen working on pi02w as display
https://github.com/degzero/st7735fb
https://github.com/degzero/Python_ST7735
https://www.youtube.com/watch?v=dj0WrkpPRho&ab_channel=Prajnith
sudo nano /boot/cmdline.txt fbcon=map:10 fbcon=font:VGA8x8