Skip to content

Instantly share code, notes, and snippets.

@alexandrinos
alexandrinos / tar.sh
Created December 28, 2015 13:59
Tar Command
#Linux Tar usefull commands
#-x extract -z typecompression(gz) -v verbose -f use the following tar achive
tar -xzvf tarfile.tar.gz #for tar.bz2 or bzip use -xjvf tar.bz2
#extract to specific path -C path
tar -xzvf tarfile.tar.gz -C /mypath
#extract a single file ; just add the name of the file and the path after the command
tar -xzv -f file.tar.gz "./new/abc.text"
#extract multiple files
tar -xzv -f file.tar.gz "./new/abc.text" "./new/xyz.txt"
#extract multiple files using *
@alexandrinos
alexandrinos / chat.sh
Last active December 29, 2015 14:57
Netcat
#from
# https://www.youtube.com/watch?v=LQSMJtckzYI
# simple chat coomunication between 2 machines with netcat
#This works with linux, Win
# to install apt-get install netcat-traditional #buntu
#IP 192.168.33.10
nc 192.168.33.10 3137
#IP 192.168.33.11 ; so this machine is listening on the ß0rt 3137 for what 192.168.33.10 is sending, and vicevers
nc -l -p 3137
@alexandrinos
alexandrinos / vagrant.st
Created December 27, 2015 09:37
Vagrant- login as another user from outside
#
ssh -l vagrant -i /home/glasslab/.vagrant.d/insecure_private_key 127.0.0.1 -p 2222
@alexandrinos
alexandrinos / firewall.sh
Created December 27, 2015 00:38
Firewal Linux aka iptables
#show all rules in a table ; you can use alternatively -L
sudo iptables -S
#show rule number in each of the 3 possible cases: INPUT OUTPUT FORWARD
sudo iptables -L --line-numbers
#delete a rule with a number; syntax: iptables -D <OUTPUT|INPUT|FORWARD> <line_number>
sudo iptables -D OUTPUT 3
#delete all rules in a chain ;chain= INPUT, OUTPUT or FORWARD
sudo iptables -F INPUT
#
@alexandrinos
alexandrinos / language.sh
Last active December 25, 2015 19:36
Language change keyboard Linux
#show language
locale
#change keyboard quickly
loadkeys de
#for X
setxkbmap de
#system wide, if ubuntu
sudo dpkg-reconfigure console-setup
#toggle us de
setxkbmap -option grp:alt_shift_toggle us,de
@alexandrinos
alexandrinos / firewall.ps1
Created December 25, 2015 12:26
Firewall info -open ports etc with Powershell
Function Get-EnabledRules
{
Param($profile)
$rules = (New-Object -comObject HNetCfg.FwPolicy2).rules
$rules = $rules | where-object {$_.Enabled -eq $true}
$rules = $rules | where-object {$_.Profiles -bAND $profile}
$rules
}
$networkListManager = [Activator]::CreateInstance([Type]::GetTypeFromCLSID([Guid]"{DCB00C01-570F-4A9B-8D69-199FDBA5723B}"))
@alexandrinos
alexandrinos / infos_sharing_win7
Created December 24, 2015 18:40
Windows 7- PUBLIC PRIVATE DOMAIN aka PUBLIC HOME WORK
Difference between Home,Work,Public is about SHARING policy.
Public to be used when using a public Internet connection, for example
"Public" Network Profile: -more secure
- turn off sharing and not allow others to see your computer
"Home" Network- win7 network.Mixed XP,Linux or Max could be dangerous
-like an open network, joined by a SINGLE password and supports media sharing
"Work" Network- is XP style file sharing- with username and pass to connect to other comps
-is safe because is controlled by user account and share permissions, for example
in mixed OSs cases.
@alexandrinos
alexandrinos / samba_ubuntu_win7
Last active December 22, 2017 23:57
Samba - Sharing Files with Win 7
sudo apt-get update
sudo apt-get install samba
#we need a different username and password for sambaserver
#for convenience, the user and passsword could be same as the username we are logged in linux
sudo smbpasswd -a <user_name>
#optional if the user is not the owner of the folder
#if apache and the user has is not owner(usually root) we need to chmod with and chown
#sudo chmod 2775 /var/www -R
#sudo chown root:<user_name> /var/www
sudo chown <user_name> /var/opt/folder
@alexandrinos
alexandrinos / windowsnetworking.bat
Last active January 3, 2023 03:24
Windows - Firewall / PortForwarding / Network
# ------------------ NETSH ---------------
#
#for help: $ netsh /?
#NETSTAT
#
#usefull
netstat -bn
@alexandrinos
alexandrinos / add_public_key_to_authorized
Last active December 27, 2015 15:32
Usefull commands network, environment Linux
#see https://help.ubuntu.com/community/SSH/OpenSSH/Keys
#add a public key to the authorized_keys on the server, if authorized_keys already exist on the server
cat ~/.ssh/id_rsa.pub | ssh user@machine "mkdir ~/.ssh; cat >> ~/.ssh/authorized_keys"
#add a public key to the authorized_keys on the server, if authorized_keys not exist
cat ~/.ssh/id_rsa.pub | ssh user@machine "mkdir ~/.ssh; cat >> ~/.ssh/authorized_keys"
#ssh-copy-id doesn't work here on Ubuntu with Myngw64 Win7
#use extended variant,for permissions issues
host=user@]machine;
ssh $host 'mkdir -pm 700 ~/.ssh; echo ' $key ' >> ~/.ssh/authorized_keys ; chmod 600 ~/.ssh/authorized_keys'