Skip to content

Instantly share code, notes, and snippets.

@arye321
Last active September 26, 2023 17:26
Show Gist options
  • Save arye321/c82b88ac7d2bfc7195390b3cec0bcc75 to your computer and use it in GitHub Desktop.
Save arye321/c82b88ac7d2bfc7195390b3cec0bcc75 to your computer and use it in GitHub Desktop.
linux shit
pip 3 install:
wget https://bootstrap.pypa.io/get-pip.py
sudo python get-pip.py
nano ~/.bashrc
// add at the end of file :
alias pip="pip3"
reset terminal
sudo passwd
su
apt update && apt upgrade -y
sudo apt install python-is-python3 -y
sudo apt install python3-pip -y
sudo apt install ffmpeg
pip install jupyterlab
df -h // shows free space
top // press shift+f -> up/down arrows -> s -> enter -> q
// upload things :
curl --upload-file ./hello.txt https://transfer.sh
// when low on memory:
pip --no-cache-dir install matplotlib
//add virtual memory:
https://www.cyberciti.biz/faq/linux-add-a-swap-file-howto/
https://linuxize.com/post/create-a-linux-swap-file/
sudo fallocate -l 1G /swapfile // <- 1Gb of mem
sudo dd if=/dev/zero of=/swapfile bs=1024 count=1048576 // <- 1048576 = 1024 * 1024 = 1gb of mem
sudo chmod 600 /swapfile
sudo mkswap /swapfile
sudo swapon /swapfile1
//remote bash
apt install ncat
ncat -lvnp 5555 -e /bin/bash // <- host connection on port 5555
ncat 192.168.2.1 5555 // <- connect to remote host
//reset bash
hash -r
// clear trash
rm -rf ~/.local/share/Trash/*
// cron +python
need to add ⌄
#!/usr/bin/env python3
at top of python file
then to edit cron job
crontab -e
exec python every hour:
0 * * * * cd /medcheck/medcheck && ./check_for_updates.py >> /medcheck/medcheck/cron.log 2>&1
every minute:
* * * * * cd /medcheck/medcheck && ./check_for_updates.py >> /medcheck/medcheck/cron.log 2>&1
>> /medcheck/medcheck/cron.log 2>&1 //saves log to cron.log
cd /medcheck/medcheck && ./check_for_updates.py // cd to dir then run the py script
sources:
https://www.howtogeek.com/101288/how-to-schedule-tasks-on-linux-an-introduction-to-crontab-files/
https://www.geeksforgeeks.org/how-to-schedule-python-scripts-as-cron-jobs-with-crontab/
https://unix.stackexchange.com/questions/38951/what-is-the-working-directory-when-cron-executes-a-job

cron +python

need to add

#!/usr/bin/env python3

at top of python file

make .py file accesiable:

sudo chmod +x my_script.py

then to edit cron job

crontab -e

exec python every hour:

0 * * * * cd /medcheck/medcheck && ./check_for_updates.py >> /medcheck/medcheck/cron.log 2>&1

every minute:

* * * * * cd /medcheck/medcheck && ./check_for_updates.py >> /medcheck/medcheck/cron.log 2>&1

>> /medcheck/medcheck/cron.log 2>&1 //saves log to cron.log

cd /medcheck/medcheck && ./check_for_updates.py // cd to dir then run the py script

sources:

https://www.howtogeek.com/101288/how-to-schedule-tasks-on-linux-an-introduction-to-crontab-files/

https://www.geeksforgeeks.org/how-to-schedule-python-scripts-as-cron-jobs-with-crontab/

https://unix.stackexchange.com/questions/38951/what-is-the-working-directory-when-cron-executes-a-job

cron with path (envs) working:

15 16 * * * export PATH=/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/usr/games:/usr/local/games:/snap/bin && cd /forsenmcv3 && ./forsen_mc3.py >> /forsenmcv3/cron.log 2>&1

create
tmux

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