alptugan
6/7/2015 - 10:04 PM

Linux commands Debian

Linux commands Debian

# Change your mac address
ifconfig wlan0 down
macchanger -m 00:11:22:33:44:55 wlan0

# wkae up wlan0 interface
ifconfig wlan0 up

# start wifi 
airmon-ng start wlan0

# check for available wifi routers
airodump-ng [interface name]

# create a handshake
airodump-ng -c [channel number] -w [wifi name] --bssid [bssid Address] [interface name]
airodump-ng -c 11 -w netmaster --bssid [bssid Address] wlan0mon

# then from a new windows run the following command
aireplay-ng -0 10 -a FC:4A:E9:69:1E:8E wlan0mon

# try to crack wifi password via dictionary files
aircrack-ng -w [path to dictionary file] [path to .cap file]
aircrack-ng -w /root/Desktop/pass.txt netmaster-01.cap
# SETUP SD CARD
1- Open virtual box linux
2- Attach sony sd card reader
3- eject it from mac os x 
4- select sony sd card driver from kali linux

#Enable root login from ssh
sudo nano /etc/ssh/sshd_config
->
AllowUsers user1 user2
AllowGroups group1 group2
PermitRootLogin no
Port 22

# to restart ssh 
sudo systemctl start sshd.socket

# enable socket service on restart
sudo systemctl enable sshd.socket

#install openssh
sudo pacman -S openssh

#update & install wget
pacman -Suy && pacman -S wget

# Downgrade a package install via aur
downgrade gcc gcc-libs

Reinstalling all packages:
To reinstall all native packages, use:
# pacman -Qnq | pacman -S -
# Save the following script as .c file. this will generate numbers from 0 to 9999
#include<stdio.h>

int main()
{
    int i;
    for (i = 0; i<= 9999;i++){
        printf("%08d\n",i);
    }
    return 0;
}

# 1. Compile and send output
gcc /root/hacking/passwords_generator.c

# 2. Save output to file
./a.out >> /root/hacking/passwords.txt
# search files
find / -name libssl*
# install parted
apt-get install parted

# install mkfs - dos - fat32
apt-get install dosfstools
# Install dev version of libjpeg
sudo apt-get install libjpeg62-turbo-dev

# Install cmake
sudo apt-get install cmake

# Download mjpg-streamer with raspicam plugin
git clone https://github.com/jacksonliam/mjpg-streamer.git ~/mjpg-streamer

# Change directory
cd ~/mjpg-streamer/mjpg-streamer-experimental

# Compile
make clean all

# Replace old mjpg-streamer
sudo rm -rf /opt/mjpg-streamer
sudo mv ~/mjpg-streamer/mjpg-streamer-experimental /opt/mjpg-streamer
sudo rm -rf ~/mjpg-streamer

# Begin streaming
LD_LIBRARY_PATH=/opt/mjpg-streamer/ /opt/mjpg-streamer/mjpg_streamer -i "input_raspicam.so -fps 15 -q 50 -x 640 -y 480" -o "output_http.so -p 9000 -w /opt/mjpg-streamer/www" &
sudo apt-get update
sudo apt-get upgrade
wget http://lilnetwork.com/download/raspberrypi/mjpg-streamer.tar.gz
tar xvzf mjpg-streamer.tar.gz
sudo apt-get install libjpeg8-dev
sudo apt-get install imagemagick
cd mjpg-streamer/mjpg-streamer
make

https://blog.miguelgrinberg.com/post/stream-video-from-the-raspberry-pi-camera-to-web-browsers-even-on-ios-and-android

enter the exact folder and run
https://miguelmota.com/blog/raspberry-pi-camera-board-video-streaming/

do not forget to pkill processes
then
LD_LIBRARY_PATH=/opt/mjpg-streamer/ /opt/mjpg-streamer/mjpg_streamer -i "input_raspicam.so -fps 15 -q 50 -x 640 -y 480" -o "output_http.so -p 9000 -w /opt/mjpg-streamer/www" &

LD_LIBRARY_PATH=./ ./mjpg_streamer -i "input_raspicam.so -fps 15 -q 50 -x 640 -y 480" -o "output_http.so -p 9000 -w ./www" &

then open browser and type
http://ip_of_slave:PORT_NUMBER


/////////////////////
GSTREAM
/Library/Frameworks/GStreamer.framework/Commands/gst-launch-1.0 -v tcpclientsrc host=slave8.local port=5000 ! gdpdepay ! rtph264depay ! avdec_h264 ! videoconvert ! autovideosink sync=false

// @    WARNING: REMOTE HOST IDENTIFICATION HAS CHANGED!     @
// Do this in master computer
ssh-keygen -R <enter_the_address_of_host_you_can_not_ssh_connection>

// Generate SSH and connect to raspberry pi without password
// On master computer
ls ~/.ssh
ssh-keygen -t rsa -C "Raspberry Pi #123"
copy that file to target pc which you would like to connect without password
cat ~/.ssh/id_rsa.pub | ssh pi@slave10.local 'cat >> .ssh/authorized_keys'

// If your raspi doesn't have this .ssh file 
sudo install -d -m 700 ~/.ssh

// config file for ssh
nano /etc/ssh/sshd_config
// EASY SAMBA SERVER
sudo apt-get update
sudo apt-get install samba samba-common-bin smbclient
http://openframeworks.cc/setup/raspberrypi/raspberry-pi-smb/

// CLEAR FILER CONTENT from Command Line
sudo echo " " > slave.py


# Install avahi to access raspberry via hostname
sudo apt-get install cifs-utils avahi-daemon avahi-utils libavahi-compat-libdnssd-dev

#Update boot startup for avahi-daemon
sudo insserv avahi-daemon

# restart service
sudo /etc/init.d/avahi-daemon restart
// Print Kernel version
uname -r

// Delete folder recursivley
sudo rm -rf folder_name

// Rename folder
sudo mv old_folder_name new_folder_name

// Move contents of folder to parent
sudo mv folder_name/* .

// Duplicate a folder recursively
sudo cp -avr folder_name_to_copy/ new_name_folder

// List of attached usb devices
sudo lsusb

// File system report human readable :)
sudo df -h

// Shutdown Raspberry Pi
sudo poweroff

// Set file permissions for files in a folder
sudo chmod -R 777 folder_name

// Local IP address
hostname -I

// Rooter IP address
host domain_name.com

// Check connected clients to your network
nmap -sn 192.168.1.0/24

// Samba server
// Edit conf file
sudo nano /etc/samba/smb.conf

// Restart server
sudo service samba restart

// List processes
ps -ef

// List processes
ps ax

// Kill a running process
sudo killall my_project.a

// Close startx
pkill x

// Change owner of folder recursively
chown -R pi:root /your/folder/here/*


// Fixing wi-fi dropdown issue
Create and edit a new file in /etc/modprobe.d/8192cu.conf
 sudo nano /etc/modprobe.d/8192cu.conf
and paste the following in
 # Disable power saving
options 8192cu rtw_power_mgnt=0 rtw_enusbss=1 rtw_ips_mode=1


// SCP from python to any computer without password
You can use the sshpass utility to login to the raspberry pi.

You can install the sshpass using 
$sudo apt-get install sshpass
Then you can add the following line to your script for automated login to raspberry pi sshpass -p "password" ssh username@hostname
For example - sshpass -p raspberry ssh pi@192.168.1.1
sshpass -p Koc02082011 scp slave.py alptugan@192.168.1.8:~/Desktop/masterRPi/slave2.py

// QUIT RUNNING APPLICATION ON BACKGROUND rc.local
alt+print+k

// SET HOST NAME
1) Establish Wifi Network Share Connection from Mac
2) ssh to an RPi with its IP Address
3) Console : 
sudo nano /etc/hosts 
change raspberrypi with slave#
4) 
sudo /etc/init.d/hostname.sh
5) 
sudo nano /etc/hostname 
change raspberrypi with slave#
6) 
sudo /etc/init.d/hostname.sh
7) sudo reboot now you can ssh with sudo ssh pi@slave#.local

# start SSH
sudo service ssh restart

# SSH Status
sudo service ssh status

# restart SSH
sudo service ssh restart
update-rc.d -f ssh enable 2 3 4 5

# Enable SSH
sudo apt-get update
sudo apt-get install openssh-server
sudo ufw allow 22
sudo /etc/init.d/ssh restart
sudo systemctl enable ssh


// Autorun : 
sudo nano /etc/rc.local
add code 
sudo python ./home/pi/masterRPi/slave.py
sudo chmod +x /home/pi/masterRPi/slave.py

// System info  32 bit/64 bit/arm6 etc...
https://www.howtogeek.com/198615/how-to-check-if-your-linux-system-is-32-bit-or-64-bit/
// SET HOST NAME
1) Establish Wifi Network Share Connection from Mac
2) ssh to an RPi with its IP Address
3) Console : 
sudo nano /etc/hosts 
change raspberrypi with slave#
4) 
sudo /etc/init.d/hostname.sh
5) 
sudo nano /etc/hostname 
change raspberrypi with slave#
6) 
sudo /etc/init.d/hostname.sh
7) sudo reboot now you can ssh with sudo ssh pi@slave#.local
wget https://www.libarchive.org/downloads/libarchive-3.3.1.tar.gz
tar xzf libarchive-3.3.1.tar.gz
cd libarchive-3.3.1
./configure
make
sudo make install
$ systemctl poweroff
$ systemctl reboot
pacman -Suy

// generate locales
$ locale -a
/etc/locale.gen
// To enable 
locale-gen

// Set system lang
nano /etc/locale.conf

// update 
pacman -Syu

// issue 
// error: failed to commit transaction (conflicting files) ca-certificates-utils: /etc/ssl/certs/ca-certificates.crt exists in filesystem
#rm /etc/ssl/certs/ca-certificates.crt
pacman -Syu
// or
pacman -Syuw
rm /etc/ssl/certs/ca-certificates.crt
pacman -Su

// Connect to wfii enable
// goto
/etc/netctl/examples
// copy wireless-wpa to parent
netctl start wireless-wpa

// enable
netctl enable wireless-wpa
netctl reenable wireless-wpa

// enable sound
echo dtparam=audio=on >> /boot/config.txt

// Cleanup disk size because of installation
pacman -Scc 
pacman-db-upgrade
pacman -Sc
pacman -Qdtq | pacman -Rs -


// Setup ArchLinuxArm
loadkeys uk
echo LANG=en_US.UTF-8 > /etc/locale.conf
echo KEYMAP=tr_q-latin5 > /etc/vconsole.conf
rm /etc/localtime
ln -s /usr/share/zoneinfo/Europe/Istanbul /etc/localtime
sed -i "s/en_US.UTF-8/#en_US.UTF-8/" /etc/locale.conf
export LANGUAGE=en_US.UTF-8
export LANG=en_US.UTF-8
export LC_ALL=en_US.UTF-8
locale-gen en_US.UTF-8

// 2.2. Setup swapfile //
fallocate -l 1024M /swapfile
chmod 600 /swapfile
mkswap /swapfile
swapon /swapfile
echo 'vm.swappiness=1' > /etc/sysctl.d/99-sysctl.conf
# Then add the following line to /etc/fstab:
/swapfile none swap defaults 0 0

// 2.3. Set hardware clock to UTC and set timezone //
timedatectl set-local-rtc 0
nano /etc/timezone ??? Doesn't exist
Set to "Europe/Istanbul" 

// 3.1. Tweak pacman //
sed -i 's/#Color/Color/' /etc/pacman.conf # Add color to pacman


// 3.2. System update //
pacman -Syu
pacman -S wget
pacman -S sudo
# adduser to the sudoers from the following file
nano /etc/sudoers
reboot

pacman-key --init ?????
pacman -S archlinux-keyring ????
pacman-key --populate archlinux ????
pacman -Syu --ignore filesystem ????
pacman -S filesystem --force ????
reboot ????

After the Pi is booted again, connect via SSH (if you don't have attached a keyboard and screen) and login with alarm/alarm and get root again via su.

// 4.4. Additional software //
sudo pacman -S --needed nfs-utils htop openssh autofs alsa-utils alsa-firmware alsa-lib alsa-plugins git zsh wget base-devel diffutils libnewt dialog wpa_supplicant wireless_tools iw crda lshw

// Install yaourt : //
wget https://aur.archlinux.org/cgit/aur.git/snapshot/package-query.tar.gz
tar -xvzf package-query.tar.gz
cd package-query
makepkg -si
cd ..
wget https://aur.archlinux.org/cgit/aur.git/snapshot/yaourt.tar.gz
tar -xvzf yaourt.tar.gz
cd yaourt
makepkg -si

cd ../
rm -rf package-query/ package-query.tar.gz yaourt/ yaourt.tar.gz

// Sound Driver //
Sound won't work! You need to edit /boot/config.txt, adding a line at the end: echo dtparam=audio=on >> /boot/config.txt After rebooting (later), the sound will work.

Install alsa utils: pacman -S alsa-utils.