Last active
December 17, 2015 15:29
-
-
Save onel0p3z/5632448 to your computer and use it in GitHub Desktop.
From, my HOW TO's
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Add a second HDD | |
In this tutorial we will add a second hard drive to our machine running Debian linux. | |
If you have just added a virtual disk, make sure you restart the virtual machine before mounting the new disk. | |
First we'll have to find out what the device name is for this disk | |
fdisk -l | |
This will give you output similar to this: | |
Disk /dev/sda: 21.4 GB, 21474836480 bytes | |
255 heads, 63 sectors/track, 2610 cylinders | |
Units = cylinders of 16065 * 512 = 8225280 bytes | |
Device Boot Start End Blocks Id System | |
/dev/sda1 * 1 2517 20217771 83 Linux | |
/dev/sda2 2518 2610 747022+ 5 Extended | |
/dev/sda5 2518 2610 746991 82 Linux swap / Solaris | |
Disk /dev/sdb: 32.2 GB, 32212254720 bytes | |
255 heads, 63 sectors/track, 3916 cylinders | |
Units = cylinders of 16065 * 512 = 8225280 bytes | |
Disk /dev/sdb doesn't contain a valid partition table | |
Next we'll partion the new disk using the following command: | |
cfdisk /dev/sdb | |
New -> Primary -> Specify size in MB | |
Write | |
Quit | |
Format the new disk using the ext3 filessystem | |
mkfs.ext3 /dev/sdb1 | |
Mounting the drive to a new folder | |
mkdir /disk2 | |
mount -t ext3 /dev/sdb1 /disk2 | |
You can name the folder whatever your want and place it in subfolders of another drive, for example /var/disk2 | |
Add the new drive to fstab so that it will automatically mount when we reboot the machine. Add the following line to your fstab file (pico /etc/fstab) | |
/dev/sdb1 /disk2 ext3 defaults,errors=remount-ro 0 1 | |
Now your new hard disk is mounted. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Backup installed packages | |
sudo dpkg --get-selections>packages.txt | |
sudo dpkg --clear-selections | |
sudo dpkg --set-selections<packages.txt | |
sudo apt-get update | |
sudo apt-get dselect-upgrade |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Change Django password | |
python manage.py shell | |
then use following script in shell | |
from django.contrib.auth.models import User | |
User.objects.filter(username__icontains='a part of your username') | |
will list you all usernames contains what you write. if you recognize yur username from the list: | |
usr = User.objects.get(username__icontains='your username') | |
usr.set_password('raw password') |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Check failed registrations from Asterisk log | |
for f in /var/log/asterisk/*; do echo "${f}:" && egrep -i 'Registration from.*failed for.*' ${f} ; done |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Counting failed registrations from Asterisk logs | |
for f in /var/log/asterisk/*; do echo "${f}:" && egrep -ci 'Registration from.*failed for.*' ${f} ; done |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Getting IP Addr | |
# Assigned IP to interface | |
ifconfig | sed -n '2p'| awk -F: '{print $2}'| awk '{print $1}' | |
# External IP behind NAT | |
curl -s http://checkip.dyndns.org/ | cut -d ' ' -f 6 | sed s/"body\|html\|<\|>\|\/"//g |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Install Codec g729 | |
#!/bin/bash | |
if [ "`uname -m`" = "i686" ]; then # system is x86_32 | |
cd /usr/lib/asterisk/modules | |
echo "We are in: `pwd`" | |
fi | |
# system is x86_64 | |
cd /usr/lib64/asterisk/modules | |
echo "We are in: `pwd`" | |
# Asterisk Version | |
#asterisk -v | grep Copy | awk '{print $2}' | |
# Asterisk 1.8 | |
#wget http://asterisk.hosting.lv/bin/codec_g729-ast18-gcc4-glibc-x86_64-core2.so | |
#mv codec_g729-ast18-gcc4-glibc-x86_64-core2.so codec_g729.so | |
# Asterisk 10 | |
wget http://asterisk.hosting.lv/bin/codec_g729-ast100-gcc4-glibc-x86_64-core2.so | |
mv codec_g729-ast100-gcc4-glibc-x86_64-core2.so codec_g729.so | |
chmod 0755 codec_g729.so | |
rasterisk -x 'module load codec_g729.so' && rasterisk -x 'core show translation' |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Install HTOP | |
#!/bin/bash | |
yum -y install make ncurses ncurses-devel gcc | |
cd /tmp | |
wget http://sourceforge.net/projects/htop/files/latest/download | |
tar xvzf htop-1.0.2.tar.gz | |
cd htop-1.0.2 | |
./configure | |
make | |
make install |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Install rootsh | |
wget http://sourceforge.net/projects/rootsh/files/rootsh/1.5.3/rootsh-1.5.3.tar.gz/download | |
tar -zxvf rootsh-1.5.3.tar.gz | |
Create logs directory : | |
mkdir -vp /secure/admins-logs | |
./configure --disable-syslog --disable-linenumbering --with-logdir=/secure/admins-logs/ | |
make && make install | |
Create a group for your admins so limited users can write to this folder. | |
groupadd admins | |
Creating a testadmin user and adding it to the group. | |
useradd testadmin | |
usermod -G testadmin admins | |
Applying appropriate permissions to logs folder & apply attributes. | |
chmod 770 /secure/admins-logs | |
chgrp admins /secure/admins-logs | |
chattr +a /secure/admins-logs | |
Edit /etc/shells to allow our new loggable shell. | |
echo "/usr/local/bin/rootsh" >> /etc/shells | |
Enable logging for our user testadmin | |
vim /etc/passwd | |
search for a user testadmin and replace /bin/bash with /usr/local/bin/rootsh |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Install VMware Tools from CLI | |
#!/bin/bash | |
mkdir /media/cdrom | |
mount /dev/cdrom /media/cdrom/ | |
cd /media/cdrom/ | |
cp VMwareTools-8.3.7-341836.tar.gz /tmp | |
cd /tmp | |
tar vzxf VMwareTools-8.3.7-341836.tar.gz | |
cd vmware-tools-distrib/ | |
./vmware-install.pl |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
OpenVZ Multiple NICs | |
Via 'man vzctl', for veth, you should end up with something like: | |
vzctl set <VMID> --netif_add eth<N>,,,,vmbr<M> --save | |
for adding an interface eth<N> in the container <VMID> to bridge vmbr<M> in the host. | |
To remove eth<N> from container <VMID> trigger: | |
vzctl set <VMID> --netif_del eth<N> --save |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Serial Port in KVM | |
If you want to access the COM/serial port of your host machine from a KVM virtual machine in Proxmox VE, simply do the following : | |
vim /etc/qemu-server/104.conf | |
where 104 is the ID of the VM | |
add "args: -serial /dev/ttyS0" to the end of the file | |
It should look like this : | |
name: testVM | |
ide2: debian-500-i386-netinst.iso,media=cdrom | |
smp: 1 | |
vlan0: rtl8139=XX:XX:XX:XX:XX:XX | |
bootdisk: ide0 | |
ide0: vm-104-disk.qcow2 | |
ostype: other | |
memory: 256 | |
args: -serial /dev/ttyS0 | |
If the VM is already running, you may have to stop the VM completely and start it again for it to see the COM port. | |
If you simply reboot the machine, it may not see it. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Site-2-Site OpenVPN | |
gwA # cat /etc/openvpn/server.conf | |
# gwA | |
local 172.20.0.1 | |
port 1194 | |
proto udp | |
dev tun | |
topology subnet | |
mode server | |
tls-server | |
ifconfig 10.0.0.1 255.255.255.0 | |
route 192.168.2.0 255.255.255.0 10.0.0.2 | |
route 192.168.3.0 255.255.255.0 10.0.0.3 | |
client-config-dir ccd | |
# snip rest of config | |
gwA # cat /etc/openvpn/ccd/gwB | |
ifconfig-push 10.0.0.2 255.255.255.0 | |
push "route 192.168.1.0 255.255.255.0 10.0.0.1" | |
iroute 192.168.2.0 255.255.255.0 | |
gwA # cat /etc/openvpn/ccd/gwC | |
ifconfig-push 10.0.0.3 255.255.255.0 | |
push "route 192.168.1.0 255.255.255.0 10.0.0.1" | |
iroute 192.168.3.0 255.255.255.0 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Static IP on OpenVZ RHEL container | |
cd /etc/sysconfig/network-scripts/ | |
Create the ethX interface | |
vim ifcfg-ethX | |
Insert the following Info: | |
DEVICE=ethX | |
BOOTPROTO=static | |
DHCPCLASS= | |
HWADDR=(ifconfig -look at HWadd) | |
IPADDR=x.x.x.x | |
NETMASK=255.255.255.0 | |
ONBOOT=yes | |
Create the gateway and DNS domain entries: | |
vim /etc/sysconfig/network | |
Insert: | |
NETWORKING=yes | |
HOSTNAME=YOUR.HOSTNAME.COM | |
GATEWAY=x.x.x.x.x | |
Setup your nameservers: | |
vim /etc/resolv.conf | |
Insert: | |
nameserver x.x.x.x | |
And finally restart the networking interface: | |
Code: | |
/etc/init.d/network restart |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Static routes from CLI | |
******************************************************** | |
RHEL / CentOS LINUX STATIC ROUTING FOR TWO INTERFACES: | |
******************************************************** | |
you can add static router for eth0 network interface by editing /etc/sysconfig/network-scripts/route-eth0 | |
file to define static routes for eth0 interface: | |
# cat /etc/sysconfig/network-scripts/route-eth0 | |
Sample Output: | |
GATEWAY0=192.168.1.254 | |
NETMASK0=255.255.255.0 | |
ADDRESS0=192.168.1.1 | |
GATEWAY1=10.0.0.1 | |
NETMASK1= 255.255.255.0 | |
ADDRESS1=10.0.0.2 | |
How do I define static routing for network 10.0.0.0/8 via 10.9.38.65 router? | |
Open /etc/sysconfig/network-scripts/route-eth0: | |
# vi /etc/sysconfig/network-scripts/route-eth0 | |
Append following line: | |
10.0.0.0/8 via 10.0.0.1 | |
Save and close the file. Restart networking: | |
# service network restart | |
Verify new routing table: | |
# route -n | |
# ip route show | |
You can add static route using following command: | |
ip route add {NETWORK} via {IP} dev {DEVICE} | |
For example network 192.168.1.0/24 available via 192.168.1.254: | |
# ip route add 192.168.1.0/24 via 192.168.1.254 dev eth1 | |
******************************************************** | |
DEBIAN / UBUNTU LINUX STATIC ROUTING FOR TWO INTERFACES: | |
******************************************************** | |
auto lo | |
iface lo inet loopback | |
auto eth0 | |
iface eth0 inet static | |
address 10.0.0.1 | |
netmask 255.255.255.0 | |
network 10.0.0.0 | |
broadcast 10.0.0.255 | |
### static routing ### | |
post-up route add -net 10.0.0.0 netmask 255.0.0.0 gw X.X.X.X | |
pre-down route del -net 10.0.0.0 netmask 255.0.0.0 gw X.X.X.X | |
auto eth1 | |
iface eth1 inet static | |
address 192.168.1.1 | |
netmask 255.255.255.0 | |
network 192.168.1.0 | |
broadcast 192.168.1.255 | |
gateway 192.168.1.254 | |
# dns-* options are implemented by the resolvconf package, if installed | |
dns-nameservers 4.2.2.1 8.8.8.8 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
USB passthrough on OpenVZ | |
# stop machine | |
vzctl stop XXX | |
# share "device" to container XXX with "rw"(read,write) permissions | |
vzctl set XXX --devnodes device:rw --save | |
#check config | |
cat /etc/pve/openvz/XXX.conf | |
# start machine | |
vzctl enter XXX | |
# enter machine | |
vzctl enter XXX | |
# check device is added | |
ls -la | grep device | |
## NOT REQUIRED ## | |
vzctl exec 1000 chown -R user:group /dev/device | |
vzctl exec 1000 chown -R user:group /lib/udev/devices/device | |
adduser user | |
chown -R user:group /dev/device |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment