Debian: Unterschied zwischen den Versionen
Zur Navigation springen
Zur Suche springen
Geist (Diskussion | Beiträge) (Die Seite wurde neu angelegt: „=== ''Journalctl'' === $ ''' journalctl -b ''' === ''lid swicth'' === $ ''' nano /etc/systemd/logind.conf ''' ''' HandleLidSwitch=ignore ''' ''' HandleLi…“) |
Geist (Diskussion | Beiträge) |
||
(20 dazwischenliegende Versionen desselben Benutzers werden nicht angezeigt) | |||
Zeile 1: | Zeile 1: | ||
− | === '' | + | === ''Logs|Error|Messages'' === |
+ | $ ''' journalctl ''' | ||
$ ''' journalctl -b ''' | $ ''' 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'' === | === ''lid swicth'' === | ||
Zeile 10: | Zeile 19: | ||
$ ''' systemctl restart systemd-logind ''' | $ ''' 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'' === | === ''Show all established connections'' === | ||
Zeile 15: | Zeile 27: | ||
=== ''Listing Running Services'' === | === ''Listing Running Services'' === | ||
+ | ===== SYSTEMCTL ===== | ||
''List all loaded services on your system'' | ''List all loaded services on your system'' | ||
$ ''' systemctl ''' | $ ''' systemctl ''' | ||
Zeile 37: | Zeile 50: | ||
$ ''' systemctl daemon-reload | $ ''' systemctl daemon-reload | ||
$ ''' systemctl reset-failed | $ ''' systemctl reset-failed | ||
+ | |||
+ | ===== SERVICE ===== | ||
+ | $'''service --status-alls''' | ||
+ | $'''service [NAME]''' | ||
+ | $'''service [NAME] status''' | ||
+ | |||
+ | ===== SysVinit/init.d ===== | ||
+ | $'''ls -l /etc/init.d/*''' | ||
=== ''netstat'' === | === ''netstat'' === | ||
Zeile 91: | Zeile 112: | ||
'''deluser --remove-home username''' | '''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'' === | ||
+ | [https://unix.stackexchange.com/questions/693006/what-are-these-unexpected-network-devices-which-appear-in-kernel-log/693011#comment1310798_693011 Check network in kernel log [Blockchain Office<nowiki>]</nowiki>] | ||
+ | |||
+ | 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' |
Aktuelle Version vom 12. April 2022, 08:43 Uhr
Inhaltsverzeichnis
- 1 Logs|Error|Messages
- 2 /etc/systemd/system.conf
- 3 lid swicth
- 4 /etc/fstab | mount on boot
- 5 Show all established connections
- 6 Listing Running Services
- 7 netstat
- 8 Ports
- 9 User
- 10 Network
- 11 Disable *ping*
- 12 Network iwlwifi Wlan
- 13 LIST/CHECK Network Devices
- 14 Network Debian
- 15 Nameserver Debian
- 16 Flash DNS
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'