Linux:Tips and Tricks: Difference between revisions

Peter A. Smode (talk | contribs)
Peter A. Smode (talk | contribs)
mNo edit summary
Line 24: Line 24:


==== Network Diagnostics ====
==== Network Diagnostics ====
See also [https://access.redhat.com/documentation/en-us/red_hat_enterprise_linux/7/html/networking_guide/sec-configuring_ip_networking_with_nmcli Red Hat 7 Networking Guide 3.3. Configuring IP Networking with nmcli] and [https://access.redhat.com/documentation/en-us/red_hat_enterprise_linux/8/html/configuring_and_managing_networking/index RED HAT ENTERPRISE LINUX 8 Configuring and managing networking] and [https://docs.rockylinux.org/guides/network/basic_network_configuration/ Network Configuration - Rocky Linux 9]<syntaxhighlight lang="shell-session">
See also [https://access.redhat.com/documentation/en-us/red_hat_enterprise_linux/7/html/networking_guide/sec-configuring_ip_networking_with_nmcli Red Hat 7 Networking Guide 3.3. Configuring IP Networking with nmcli] and [https://access.redhat.com/documentation/en-us/red_hat_enterprise_linux/8/html/configuring_and_managing_networking/index RED HAT ENTERPRISE LINUX 8 Configuring and managing networking] and [https://docs.rockylinux.org/guides/network/basic_network_configuration/ Network Configuration - Rocky Linux 9] and [https://opensource.com/article/22/8/migrate-networkmanager-keyfiles-configuration How I migrated to NetworkManager keyfiles for configuration]<syntaxhighlight lang="shell-session">
# ip address
# ip address
# ip link
# ip link

Revision as of 18:08, 30 December 2022

1 Find files modified in past N days[edit | edit source]

find path -mtime -N -ls

[psmode@wort ~]$ find /kvm/ -mtime -3 -ls
102090127      4 drwxr-xr-x   7  root     root         4096 Jan  3 09:46 /kvm/
  2038539      4 drwxr-xr-x   2  root     kitsnet_adm     4096 Jan  3 09:13 /kvm/socat-kvm
  2038573      4 -rw-r--r--   1  root     root               5 Jan  3 09:13 /kvm/socat-kvm/uv040
101237691      8 -rw-r--r--   1  root     kitsnet_adm     6370 Jan  3 09:46 /kvm/uv034.xml
102163845     12 -rw-r--r--   1  root     root            9096 Jan  3 09:46 /kvm/uv039.xml
102090129     12 -rw-r--r--   1  root     root            8303 Jan  3 09:46 /kvm/uv040.xml
2 Shell script debugging modes[edit | edit source]

A good explanation of the debugging modes is given by How To Enable Shell Script Debugging Mode in Linux. Basically, there are three modes

  • -v (short for verbose) – tells the shell to show all lines in a script while they are read, it activates verbose mode.
  • -n (short for noexec or no ecxecution) – instructs the shell read all the commands, however doesn’t execute them. This options activates syntax checking mode.
  • -x (short for xtrace or execution trace) – tells the shell to display all commands and their arguments on the terminal while they are executed. This option enables shell tracing mode.

Which may be invoked by any of three different ways:

  1. Modifying the first line of a shell script: #!/bin/sh option(s)
  2. Invoking shell with debugging options: $ /bin/bash option(s) script_name argument1 ... argumentN   
  3. Using set shell built-in command in the middle of the script: $ set -option to enable or $ set +option to disable

3 Network Diagnostics[edit | edit source]

See also Red Hat 7 Networking Guide 3.3. Configuring IP Networking with nmcli and RED HAT ENTERPRISE LINUX 8 Configuring and managing networking and Network Configuration - Rocky Linux 9 and How I migrated to NetworkManager keyfiles for configuration

# ip address
# ip link
# ip route
# ip -6 route
# firewall-cmd --list-all --zone=... (replace ... with whatever zones you are working with)
# nmcli connection show 
# nmcli connection show --active
# nmcli device status
# nmcli connection show <device>
# sysctl -a | grep -E 'forwarding'