command line, linux, networking

Linux server information gathering

Hostname

$ hostname
jumphost

# all FQDN's (check 'search' field in /etc/resolv.conf)
$ hostname -A
jumphost.b.google.internal

# addresses for the host namea
$ hostname -i
10.31.30.10

Kernel name, hostname, processor, operating system

$ uname -a
Linux jumphost 4.19.0-19-cloud-amd64 #1 SMP Debian 4.19.232-1 (2022-03-07) x86_64 GNU/Linux

$ lscpu
Architecture:        x86_64
CPU op-mode(s):      32-bit, 64-bit
Byte Order:          Little Endian
Address sizes:       46 bits physical, 48 bits virtual
CPU(s):              2
On-line CPU(s) list: 0,1
Thread(s) per core:  2

[...]

$ cat /proc/cpuinfo
processor       : 0
vendor_id       : GenuineIntel
cpu family      : 6
model           : 79
model name      : Intel(R) Xeon(R) CPU @ 2.20GHz
stepping        : 0
microcode       : 0x1
cpu MHz         : 2199.998
cache size      : 56320 KB
[...]

processor       : 1
vendor_id       : GenuineIntel
cpu family      : 6
model           : 79
model name      : Intel(R) Xeon(R) CPU @ 2.20GHz
stepping        : 0
microcode       : 0x1
cpu MHz         : 2199.998
cache size      : 56320 KB
[...]

# RAID info
$ cat /proc/mdstat

Distribution details

$ lsb_release -a
No LSB modules are available.
Distributor ID: Debian
Description:    Debian GNU/Linux 10 (buster)
Release:        10
Codename:       buster

$ cat /etc/os-release
PRETTY_NAME="Debian GNU/Linux 10 (buster)"
NAME="Debian GNU/Linux"
VERSION_ID="10"
VERSION="10 (buster)"
VERSION_CODENAME=buster
ID=debian
HOME_URL="https://www.debian.org/"
SUPPORT_URL="https://www.debian.org/support"
BUG_REPORT_URL="https://bugs.debian.org/"

Process list

$ pstree
systemd-+-agent---9*[{agent}]
        |-2*[agetty]
        |-auditd---{auditd}
        |-cron
        |-dbus-daemon
        |-dhclient
        |-google_guest_ag---8*[{google_guest_ag}]
        |-google_osconfig---8*[{google_osconfig}]
        |-haveged
        |-ntpd---{ntpd}
        |-packagekitd---2*[{packagekitd}]
        |-polkitd---2*[{polkitd}]
        |-process-agent---8*[{process-agent}]
        |-rsyslogd---3*[{rsyslogd}]
        |-sshd-+-2*[sshd---sshd---bash]
        |      |-sshd---sshd---zsh---sudo---su---bash---pstree
        |      |-sshd---sshd
        |      `-sshd---sshd---kubectl---7*[{kubectl}]
        |-stackdriver-col---stackdriver-col---12*[{stackdriver-col}]
        |-3*[systemd---(sd-pam)]
        |-systemd-journal
        |-systemd-logind
        |-systemd-udevd
        |-tinyproxy---10*[tinyproxy]
        |-trace-agent---8*[{trace-agent}]
        |-unattended-upgr---{unattended-upgr}
        |-zsh---gitstatusd-linu---4*[{gitstatusd-linu}]
        `-2*[zsh]

Docker

# show all containers (stopped ones as well)
$ docker ps -a
[ ... ]                               

Crontabs

$ crontab -l
no crontab for bob

# crontabs for all users
# ls -la /var/spool/cron/crontabs/
total 16
drwx-wx--T 2 root                    crontab 4096 Feb 16  2022 .
drwxr-xr-x 3 root                    root    4096 Feb 16  2021 ..
-rw------- 1 bob                     crontab 1174 Feb 16  2022 bob

$ ls -la /etc/ | grep cron
drwxr-xr-x   2 root     root      4096 Mar 22  2022 cron.d
drwxr-xr-x   2 root     root      4096 May 26 06:17 cron.daily
drwxr-xr-x   2 root     root      4096 Feb 16  2021 cron.hourly
drwxr-xr-x   2 root     root      4096 Feb 16  2021 cron.monthly
drwxr-xr-x   2 root     root      4096 Feb 16  2021 cron.weekly
-rw-r--r--   1 root     root      1042 Oct 11  2019 crontab

Name servers (DNS)

$ nslookup prezydent.pl
Server:         169.254.169.254
Address:        169.254.169.254#53

Non-authoritative answer:
Name:   prezydent.pl
Address: 172.67.10.17
Name:   prezydent.pl
Address: 104.22.38.232
Name:   prezydent.pl
Address: 104.22.39.23

$ cat /etc/resolv.conf
nameserver 169.254.169.254

Routing

$ ip r s
default via 10.31.30.1 dev ens4
10.31.30.1 dev ens4 scope link

$ route -n
Kernel IP routing table
Destination     Gateway         Genmask         Flags Metric Ref    Use Iface
0.0.0.0         10.31.30.1      0.0.0.0         UG    0      0        0 ens4
10.31.30.1      0.0.0.0         255.255.255.255 UH    0      0        0 ens4

Network interfaces

$ ifconfig -a
ens4: flags=4163<UP,BROADCAST,RUNNING,MULTICAST>  mtu 1460
        inet 10.31.30.10  netmask 255.255.255.255  broadcast 10.31.30.10
        inet6 fe80::aff:fe1f:1e0a  prefixlen 64  scopeid 0x20<link>
        ether 42:01:0a:1f:1e:0a  txqueuelen 1000  (Ethernet)
        RX packets 145905643  bytes 512380185405 (477.1 GiB)
        RX errors 0  dropped 0  overruns 0  frame 0
        TX packets 133263861  bytes 82742313864 (77.0 GiB)
        TX errors 0  dropped 0 overruns 0  carrier 0  collisions 0

lo: flags=73<UP,LOOPBACK,RUNNING>  mtu 65536
        inet 127.0.0.1  netmask 255.0.0.0
        inet6 ::1  prefixlen 128  scopeid 0x10<host>
        loop  txqueuelen 1000  (Local Loopback)
        RX packets 126771002  bytes 18588316602 (17.3 GiB)
        RX errors 0  dropped 0  overruns 0  frame 0
        TX packets 126771002  bytes 18588316602 (17.3 GiB)
        TX errors 0  dropped 0 overruns 0  carrier 0  collisions 0

Firewall

$ iptables-save
# Generated by iptables-save v1.8.7 on Tue Oct 11 16:56:06 2022
*filter
:INPUT ACCEPT [0:0]
:FORWARD DROP [0:0]
:OUTPUT ACCEPT [0:0]
:DOCKER - [0:0]
:DOCKER-ISOLATION-STAGE-1 - [0:0]
:DOCKER-ISOLATION-STAGE-2 - [0:0]
:DOCKER-USER - [0:0]
-A FORWARD -j DOCKER-USER
-A FORWARD -j DOCKER-ISOLATION-STAGE-1
-A FORWARD -o br-65cfc1a5890f -m conntrack --ctstate RELATED,ESTABLISHED -j ACCEPT
COMMIT
# Completed on Tue Oct 11 16:56:06 2022
# Generated by iptables-save v1.8.7 on Tue Oct 11 16:56:06 2022
*nat
:PREROUTING ACCEPT [0:0]
:INPUT ACCEPT [0:0]
:OUTPUT ACCEPT [0:0]
:POSTROUTING ACCEPT [0:0]
:DOCKER - [0:0]
-A PREROUTING -m addrtype --dst-type LOCAL -j DOCKER
-A OUTPUT ! -d 127.0.0.0/8 -m addrtype --dst-type LOCAL -j DOCKER
-A DOCKER ! -i br-65cfc1a5890f -p tcp -m tcp --dport 443 -j DNAT --to-destination 172.20.0.3:443
-A DOCKER ! -i br-65cfc1a5890f -p tcp -m tcp --dport 80 -j DNAT --to-destination 172.20.0.3:80
COMMIT
# Completed on Tue Oct 11 16:56:06 2022

Time & date

$ date
Tue May 11 16:26:28 UTC 2022

Memory

$ free -m
              total        used        free      shared  buff/cache   available
Mem:           1992         541         988          20         462        1275
Swap:             0           0           0

Storage

$ df -h
Filesystem      Size  Used Avail Use% Mounted on
udev            988M     0  988M   0% /dev
tmpfs           200M   21M  179M  11% /run
/dev/sda1        30G   17G   12G  61% /
tmpfs           997M     0  997M   0% /dev/shm
tmpfs           5.0M     0  5.0M   0% /run/lock
tmpfs           997M     0  997M   0% /sys/fs/cgroup
/dev/sda15      124M  5.9M  118M   5% /boot/efi

$ lsblk
NAME    MAJ:MIN RM  SIZE RO TYPE MOUNTPOINT
sda       8:0    0   30G  0 disk
|-sda1    8:1    0 29.9G  0 part /
|-sda14   8:14   0    3M  0 part
`-sda15   8:15   0  124M  0 part /boot/ef

$ cat /etc/fstab
# /etc/fstab: static file system information
UUID=2af9b9e0-f31f-4f6c-8245-fba3fa511c66 / ext4 rw,discard,errors=remount-ro,x-systemd.growfs 0 1
UUID=164A-AEA1 /boot/efi vfat defaults 0 0

$ blkid
/dev/sda1: UUID="2af9b9e0-f31f-4f6c-8245-fba3fa511c66" TYPE="ext4" PARTUUID="1165fbaa-f9b2-414f-bf97-59191a1c8654"
/dev/sda14: PARTUUID="fb1f4866-67d3-2948-8b85-07d8cc0a429d"
/dev/sda15: SEC_TYPE="msdos" UUID="164A-AEA1" TYPE="vfat" PARTUUID="e2b0a385-c802-0345-bd6c-839c40cc674e"

$ fdisk -l
Disk /dev/sda: 30 GiB, 32212254720 bytes, 62914560 sectors
Disk model: PersistentDisk
Units: sectors of 1 * 512 = 512 bytes
Sector size (logical/physical): 512 bytes / 4096 bytes
I/O size (minimum/optimal): 4096 bytes / 4096 bytes
Disklabel type: gpt
Disk identifier: 3948AFEB-2993-D54E-A66C-392005D28B38

Device      Start      End  Sectors  Size Type
/dev/sda1  262144 62914526 62652383 29.9G Linux filesystem
/dev/sda14   2048     8191     6144    3M BIOS boot
/dev/sda15   8192   262143   253952  124M EFI System

Partition table entries are not in disk order.

#swap info
$ cat /proc/swaps
Filename                                Type            Size            Used            Priority

# NFS
$ cat /etc/exports
cat: /etc/exports: No such file or directoryl

# logical volumes
$ lvs

# groups
$ vgs

# physical devices
$ pvs

$ mount | grep -v cgroup | column -t
sysfs        on  /sys                       type  sysfs        (rw,nosuid,nodev,noexec,relatime)
proc         on  /proc                      type  proc         (rw,nosuid,nodev,noexec,relatime)
udev         on  /dev                       type  devtmpfs     (rw,nosuid,relatime,size=1011104k,nr_inodes=252776,mode=755)
devpts       on  /dev/pts                   type  devpts       (rw,nosuid,noexec,relatime,gid=5,mode=620,ptmxmode=000)
tmpfs        on  /run                       type  tmpfs        (rw,nosuid,noexec,relatime,size=204080k,mode=755)
/dev/sda1    on  /                          type  ext4         (rw,relatime,discard,errors=remount-ro)
securityfs   on  /sys/kernel/security       type  securityfs   (rw,nosuid,nodev,noexec,relatime)

Systemd services

$ systemctl --all --type=service list-unit-files
UNIT FILE                              STATE
proc-sys-fs-binfmt_misc.automount      static
-.mount                                generated
boot-efi.mount                         generated
dev-hugepages.mount                    static
dev-mqueue.mount                       static
proc-sys-fs-binfmt_misc.mount          static
systemd-ask-password-wall.path         static
apparmor.service                       enabled
apt-daily-upgrade.service              static
apt-daily.service                      static
auditd.service                         enabled
[email protected]                        enabled

Bash history

$ history -w /dev/stdout | sort | uniq -c | sort -nr | head
46 exit
27 ls -la
11 apt update
10 cd ..

Startup services

$ runlevel
N 5
$ ls /etc/rc5.d/
S01auditd  S01chrony  S01cron  S01dbus  S01haveged  S01ntp  S01rsyslog  S01saned  S01ssh  S01stackdriver-agent  S01sudo  S01sysstat  S01tinyproxy  S01unattended-upgrades

Hardware info

$ lshw
jumphost
    description: Computer
    product: Google Compute Engine
    vendor: Google
    serial: GoogleCloud-F99EA9D2F727207E633234F62763D
    width: 64 bits
    capabilities: smbios-2.4 dmi-2.4 smp vsyscall32
    configuration: boot=normal uuid=F99EA9D2-F7f7-2062-A7E6-33234F62763D
  *-core
       description: Motherboard
       product: Google Compute Engine
       vendor: Google
       physical id: 0
       serial: Board-GoogleCloud-F99EA9D2F7277E633234F62763D
     *-firmware
          description: BIOS
          vendor: Google
          physical id: 0
          version: Google
          date: 01/01/2011
          size: 96KiB
[...]

# list all PCI devices
$ lspci
00:00.0 Host bridge: Intel Corporation 440FX - 82441FX PMC [Natoma] (rev 02)
00:01.0 ISA bridge: Intel Corporation 82371AB/EB/MB PIIX4 ISA (rev 03)
00:01.3 Bridge: Intel Corporation 82371AB/EB/MB PIIX4 ACPI (rev 03)
00:03.0 Non-VGA unclassified device: Red Hat, Inc Virtio SCSI
00:04.0 Ethernet controller: Red Hat, Inc Virtio network device
00:05.0 Unclassified device [00ff]: Red Hat, Inc Virtio memory balloon
00:06.0 Unclassified device [00ff]: Red Hat, Inc Virtio RNG