Debian

Aus robopagex.com
Zur Navigation springen Zur Suche springen

Logs|Error|Messages

$  journalctl 
$  journalctl -b 
$  journalctl --list-boots 
$  journalctl -b N 
$  journalctl -b 0 
$  systemctl --failed
$  systemctl list-unit-files
$  cd /var/log

/etc/systemd/system.conf

lid swicth

$  nano /etc/systemd/logind.conf 
 HandleLidSwitch=ignore 
 HandleLidSwitchExternalPower=ignore 
 HandleLidSwitchDocked=ignore 
$  systemctl restart systemd-logind 

/etc/fstab | mount on boot

UUID=X.X.X.X.X /LOCAL ext4 user,defaults 0 2

Show all established connections

$  lsof -i| grep ESTABLISHED 

Listing Running Services

SYSTEMCTL

List all loaded services on your system

$  systemctl 
$  systemctl list-units --type=service 
$  systemctl --type=service 

List all loaded but active services

$  systemctl list-units --type=service --state=active 
$  systemctl --type=service --state=active 

Get a quick glance of all running services

$  systemctl list-units --type=service --state=running 
$  systemctl --type=service --state=running 

Stop, Disable service

$  systemctl stop [servicename] 
$  systemctl disable [servicename] 
$  rm /etc/systemd/system/[servicename] 
$  rm /etc/systemd/system/[servicename]  and symlinks that might be related
$  rm /usr/lib/systemd/system/[servicename]  
$  rm /usr/lib/systemd/system/[servicename]  and symlinks that might be related
$  systemctl daemon-reload
$  systemctl reset-failed
SERVICE
$service --status-alls
$service [NAME]
$service [NAME] status
SysVinit/init.d
$ls -l /etc/init.d/*

netstat

$  netstat -tlnp 
$  netstat -lnp 

Ports

Listing of every port available

$  less /etc/services 

Locate listening ports

$ ss -tulwn | grep LISTEN 

Kill process running on port ***

$ kill -9 `sudo lsof -t -i:3002` 

User

To add user
adduser username
You can use the following command:
$ useradd -r subversion
-r, --system                  create a system account
The -r flag will create a system user - one which does not have a password, a home dir and is unable to login.
For more info, check manual pages with this command:
$ man useradd
You will find in this documentation the following flag that can be used for your purpose.
You can use the -M switch (make sure it's a capital) to ensure no home directory will be created:
$ useradd -M subversion
then lock the account to prevent logging in:
$ usermod -L subversion


This isn't a particularly strong answer, the user created by this means still has a shell. And you did not even warn the OP that this was the case. Retrospectively that would be usermod -s /bin/false subversion, or with --shell /bin/false to useradd 
$ usermod user --shell /bin/false
To delete the user, without removing the user files, run:
deluser username
If you want to delete the user and its home directory and mail spool, use the --remove-home flag:
deluser --remove-home username

Network

$  /sbin/ifup eth0 
$  /sbin/ifdown eth0 
$  ifdown eth0 && sudo ifup eth0 
$  ip addr flush dev eth0 
$  /etc/init.d/networking restart 
$  /etc/init.d/networking stop
$  /etc/init.d/networking start
$  systemctl restart networking
$  systemctl status networking.service 
$  cat /run/network/ifstate 

Disable *ping*

$  echo “1” > /proc/sys/net/ipv4/icmp_echo_ignore_all 
$  echo “net.ipv4.icmp_echo_ignore_all = 1” >> /etc/sysctl.conf 
$  sysctl -p
Add the following lines to /etc/sysctl.conf
$  net.ipv4.icmp_echo_ignore_all = 1
$  sysctl -p
ERROR
$  net.ipv4.icmp_echo_ignore_broadcasts = 1

Network iwlwifi Wlan

 $  apt install firmware-iwlwifi 
 $  $ modprobe -r iwlwifi ; modprobe iwlwifi 

LIST/CHECK Network Devices

Check network in kernel log [Blockchain Office]

List looks like:
   lo = loopback
   enp7s0 = ethernet
   lp5s0 = wlan
   virbr* = virtual bridge
   lxcbr* = lxc/lxd
   docker* = docker
   br* = docker bridge
   veth* = virtual Ethernet devices
Ue the nmcli(network manager) and run:
$ nmcli device list

For docker containers run:
$ docker network ls
$ docker network inspect [USE THE NETWORK ID FROM THE FIRST COMMAND]
Get a list of the network devices:
$ echo /sys/class/net/*
Get more informations with udevadm:
$ udevadm info -a -p /sys/class/net/[NETWORK DEVICE NAME]

Example:
$ udevadm info -a -p /sys/class/net/enp0s25
With ip:
$ ip -r link
$ ip -br link
$ ip -br -c link show
$ ip token
$ ip -s -s link show dev docker0
$ ip -h -a -o -br tcp_metrics
With lshw:
$ lshw -class network
$ lshw -class network -short

More detail information with networkctl
$ networkctl
$ networkctl status
$ networkctl status --all
Get more informations from this manpages:
   man systemd.netdev
   man systemd.link
   man systemd.network
   man7.org/linux/man-pages/man8/ip-netns.8.html 
   man7.org/linux/man-pages/man7/network_namespaces.7.html

Network Debian

/etc/network/interfaces

 auto lo 
 iface lo inet loopback 
 auto eth0 
 allow-hotplug eth0 
 iface eth0 inet static 
 address x.x.x.x 
 netmask x.x.x.x 
 #gateway x.x.x.x 
 #gateway 192.168.x.x 
 #dns-nameserver 192.168.x.x 
 #dns-nameserver 8.8.8.8 
 #nameserver 8.8.8.8 
 auto eth0:0 
 allow-hotplug eth0:0 
 iface eth0:0 inet static 
 address 192.168.x.x 
 netmask 255.255.255.0 
 #gateway 192.168.x.x 
 #dns-nameserver 192.168.x.x 
 #dns-nameserver 8.8.8.8 
 #nameserver 8.8.8.8  

Nameserver Debian

create /etc/resolve.conf
nameserver 192.168.x.x(local) or 8.8.8.8(google) | one or both

/etc/network/interfaces
dns-nameserver 192.168.x.x
dns-nameservers 192.168.x.x
nameserver 192.168.x.x

Flash DNS

$ lsof -i :53 -S
$ systemd-resolve --flush-caches
$ resolvectl flush-caches
$ systemd-resolve --statistics
$ killall -USR2 systemd-resolved
$ killall -USR1 systemd-resolved
$ journalctl -r -u systemd-resolved
$ systemctl is-active dnsmasq


/etc/systemd/network
netstat --inet
ss -o | grep tcp
ss -p
ss -p | grep firefox
lsof -nP -i | grep 'LISTEN\|UDP'
lsof -nP -i | grep 'LISTEN\|TCP'
lsof -nP -i | grep 'firefox'