Afegir usuari als sudoers:
usermod -aG sudo <username>
Accedir a un servei de xarxa amb netcat (permet canonades d'entrada i sortida):
nc HOST PORT
Amb l'opció -l pots engegar un servidor.
Per Windows, hi ha aquesta versió. Pots utilitzar TCPView per monitoritzar els serveis de la teva màquina.
Permetre que l'usuari root pugui utilitzar aplicacions visuals (X Server):
xhost +si:localuser:root
xhost -si:localuser:root
Com fer un túnel al port 1234 un servidor de la xarxa local (192.168.X.Y) si tenim accès a un compte de ssh.youroffice.com:
ssh -L 8888:192.168.X.Y:1234 bob@ssh.youroffice.com
For dynamic, edit /etc/network/interfaces:
auto eth0
iface eth0 inet dhcp
For static, edit /etc/network/interfaces:
auto eth0
iface eth0 inet static
netmask 255.255.255.0
address 192.168.0.101
gateway 192.168.0.1 // only if it is a gateway
Finally:
/etc/init.d/networking restart
or
systemctl restart networking.service
Edit /etc/netplan/01-netcfg.yaml.
For dhcp:
network:
version: 2
renderer: networkd
ethernets:
eth0:
dhcp4: true
For static:
network:
version: 2
renderer: networkd
ethernets:
eth0:
addresses:[192.168.0.101/24]
gateway4: 192.168.0.1
Test/apply:
netplan try
netplan apply
Es pot fer editant l'arxiu /etc/resolv.conf, i afegint un servidor DNS o més per resoldre les adreces. Per exemple, el de Google: 8.8.8.8.
nameserver 8.8.8.8
# apt install snmp
# snmpwalk -v 2c -c public IPADDRESS
usermod -aG wireshark <username>
Origen:
$ cat arxiu.bin | base64 -w 0 > arxiu.b64
Destí:
$ cat arxiu.b64 | base64 -d > arxiu.bin
Ves a Control Panel > Programs > Programs and Features > Turn Windows features on or off
A la llista, activa "Simple TCP/IP services"
Busca el servei del mateix nom, i arrenca'l (no cal que el deixis en automàtic, millor manual)
Ves a Control Panel > Programs > Programs and Features > Turn Windows features on or off
A la llista, activa "Telnet Client"
apt-get update
apt-get upgrade
apt-get install build-essential module-assistant
m-a prepare
cd /media/cdrom/
sh /media/cdrom/VBoxLinuxAdditions.run
reboot
$ vboxmanage dhcpserver add --netname intnet --ip 10.10.0.1 --netmask 255.255.0.0 --lowerip 10.10.10.1 --upperip 10.10.10.255 --enable
$ vboxmanage dhcpserver remove --netname intnet
Veure: building an internal network in VirtualBox
VirtualBox/Hyper-V conflict: WHvSetupPartition (Windows)
C:\> bcdedit /set hypervisorlaunchtype off
Enable query log at my.ini:
[mysqld]
...
general_log=on
general_log_file=/path/query.log
Afegir un usuari i donar-li permisos per localhost / qualsevol host a una BD "database" o a qualsevol:
> CREATE USER 'newuser'@'localhost' IDENTIFIED BY 'password';
> CREATE USER 'newuser'@'%' IDENTIFIED BY 'password';
> GRANT ALL PRIVILEGES ON database.* TO 'newuser'@'localhost';
> GRANT ALL PRIVILEGES ON database.* TO 'newuser'@'%';
> GRANT ALL PRIVILEGES ON *.* TO 'newuser'@'%';
You want to run a java-based service using user theusername.
Edit a file named "/etc/systemd/system/servicename.service":
[Unit]
Description=Service name description
After=network.target
[Service]
User=theusername
TimeoutStartSec=0
Type=simple
KillMode=process
WorkingDirectory=/home/theusername
ExecStart=/usr/bin/java -cp "path1:path2:...:path3" package.ClassName
Restart=always
RestartSec=2
[Install]
WantedBy=multi-user.target
Commands for enabling/disabling/starting/stopping:
systemctl enable servicename
systemctl disable servicename
systemctl start servicename
systemctl stop servicename