Showing posts with label linux. Show all posts
Showing posts with label linux. Show all posts

Thursday, June 15, 2017

Linux Again

HOW TO ADD A SHELL SCRIPT ON STARTUP
save script in /etc/init.d
make a new script start with "#! /bin/bash"

MAKE A BRIDGE

INSTALL AIRCRACK-NG (NEW GENERATION)
#! /bin/bash/
sudo apt-get install ethtool
sudo apt-get install rfkill
sudo apt-get install libnl-3-dev libnl-genl-3-dev
sudo apt-get install libssl-dev
 wget http://download.aircrack-ng.org/aircrack-ng-1.2-rc4.tar.gz
 tar -zxvf aircrack-ng-1.2-rc4.tar.gz
 cd aircrack-ng-1.2-rc4
 make
 sudo make install

https://www.aircrack-ng.org/doku.php?id=install_aircrack
MAKING BASH FILE and EXECUTE IT:
Start with this line:

#! /bin/bash
https://bash.cyberciti.biz/guide/Hello,_World!_Tutorial
https://community.linuxmint.com/tutorial/view/313

set chmod +x name_of_file.sh
sh ./name_of_file.sh to execute the file

SET DELAY IN BASH:
sleep(time in second)



PID is unique

Kill a process: kill -TSTP [pid]
or kill -STOP [pid]


Need to learn how to config chmod and chown
https://timleland.com/wireless-power-outlets/

CHMOD - CHANGE MODE
666

ls -al <directory> # to see the mode of the file
For example:
ls -l /dev/video0 
crw-rw----+ 


HOW TO MANAGE SERVICE IN DEBIAN?

lost /dev/video0 file
how to solve?
try rpi-update
sudo apt-get install rpi-update
sudo rpi-update
waiting
....
reboot
sudo apt-get --purge remove motion
raspi-config -> enable camera
reboot.
Work!

NEED TO LEARN HTACCESS NEXT TIME.

TAB COMPLETION IS USEFUL:
In terminal, when you want it to guest a typing word for you, you just need to hit Enter

PIPES
using both command with "|",
ex: ls | grep funny
ls is list function
grep is the find function
the function above will find the file's name has a word "funny"
and list it

OUTPUT REDIRECTION
 using >
Ex:
ifconfig > /home/xyz/myNi

https://askubuntu.com/questions/754572/cannot-restart-samba-samba-service-is-masked




Thursday, February 23, 2017

Learn Linux with Raspberry Pi and Android

2/22/2016
So today, I wanted to move all files to another file except one, I found that I can use MC (midnight commander)
I also learned that ssh password is the password of user
In terminal type "mc" to use the commander 



Establishing SSH on Raspberry Pi



Create Password for Apache2
1_: create user with password in htpswd
2_: add directory to 000-default.conf
3_: 
I made a stupid mistake again, instead of typing "etc" I typed "ect".


WORKING WITH CRON

see cron that was executed:
grep 'CRON.*(pi)' /var/log/syslog

Setting cron to turn on and off light with RFoutlet

00 7 * * * cd /var/www/html && ./codesend ____ -l 180 -p 0
40 23 * * * cd /var/www/html && ./codesend ____ -l 180 -p 0
sudo service cron reload -- use this after change crontab
cron test

Yesterday, when I logged in again, crontab was saved in tmp folder to keep conflicting with other task
Cron has this form

minute hour

TASK MANAGER FOR LINUX
sudo apt-get install htop


Easily Change hosts File on Android (Updated secured kernel)
Use adb root mount -o rw,remount /system -> Use this to mount system on android
adb mount
1. Pull hosts file from android device by: adb pull hosts
2. Remount /system as above
3. Move your file to storage or sdcard (mine is /storage/emulated/0/)
4. adb shell su (mv <source> <destination>)

Make a batch file to change hosts
https://ss64.com/nt/
Make sure you have platform tool for Android to use adb. Then, open notepad and copy this code, save as .bat file and run.

cls
ECHO Change hosts file for Android devices
adb root mount -o rw,remount /system
adb pull /system/etc/hosts
start /W notepad "hosts"
adb push hosts /storage/emulated/0/
adb root shell mv /storage/emulated/0/hosts /system/etc/hosts
ECHO DONE!
PAUSE

PHP CGI
POST
CURL
post to website
curl -x post -d <'var=value'> <your address>

($_GET['n']=="1" && $_GET['s']=="on")

TASKER:
html get: <name>:<password>@host

STANDARD USB CAMERA
1. Use fswebcam
2.

USING RSYNC
https://help.resilio.com/hc/en-us/articles/206178924

INSTALLING SAMBA TO SHARE FOLDER (success)
http://raspberrywebserver.com/serveradmin/share-your-raspberry-pis-files-and-folders-across-a-network.html
http://raspberrypihq.com/how-to-share-a-folder-with-a-windows-computer-from-a-raspberry-pi/
https://help.lafayette.edu/samba/win7nondomain


For win10




IMPLEMENT C WITH PHP

ASKING PASSWORD WHEN TYPE SUDO

Exit SSH
press Ctrl+D