# Linux

<table data-header-hidden><thead><tr><th width="303"></th><th></th></tr></thead><tbody><tr><td>Hostname</td><td><code>hostname</code></td></tr><tr><td>Username</td><td><code>whoami</code></td></tr><tr><td>User context</td><td><code>id</code><br><code>id &#x3C;USERNAME></code></td></tr><tr><td>Operating System, Version</td><td><code>cat /etc/issue</code><br><code>cat /etc/*-release</code></td></tr><tr><td>Kernel, Version and Architecture</td><td><code>uname -a</code> <br><code>uname -r</code>  <em>(only kernel version)</em> <br><code>arch</code>  <em>(only architecture)</em> <br><code>lsb_release -a</code>  <em>(distribution)</em> <br><code>cat /proc/version</code></td></tr><tr><td>Other users and groups</td><td><code>cat /etc/passwd</code><br><code>cat /etc/group</code><br><code>groups</code><br><code>groups &#x3C;USER></code> <em>(current user's groups)</em><br><code>getent group &#x3C;GROUP></code> <em>(users in that group)</em></td></tr><tr><td>Connected users</td><td><code>who</code>  (<code>w</code>)<br><code>finger</code></td></tr><tr><td>Last user login</td><td><code>lastlog</code></td></tr><tr><td>Network information</td><td><code>ifconfig</code><br><code>ip a</code><br><code>arp -a</code><br><code>route</code><br><code>routel</code><br><code>ss -anp</code> <br><code>netstat -tulpn</code><br><code>/etc/hosts</code><br><code>/etc/resolv.conf</code>  <em>(DNS)</em><br><code>/etc/network/interfaces</code> <em>(if you make changes: <code>sudo systemctl restart networking</code>)</em></td></tr><tr><td>Open port</td><td><code>netstat -atunp</code></td></tr><tr><td>Rule iptables</td><td><code>cat /etc/iptables/rules.v4</code></td></tr><tr><td>Active Directory</td><td><code>realm list</code><br><code>ps -ef | grep -i "winbind\|sssd"</code>  <em>(others like</em> <a href="https://sssd.io/"><em>sssd</em></a> <em>or</em> <a href="https://www.samba.org/samba/docs/current/man-html/winbindd.8.html"><em>winbind</em></a><em>)</em></td></tr><tr><td>Installed applications</td><td><code>dpkg -l</code> <br><code>apt list --installed | tr "/" " " | cut -d" " -f1,3 | sed 's/[0-9]://g' | tee -a installed_pkgs.list</code></td></tr><tr><td>Binaries</td><td><code>ls -l /bin /usr/bin/ /usr/sbin/</code></td></tr><tr><td>Service list</td><td><code>systemctl list-units --type=service</code> <em>(currently active)</em><br><code>systemctl list-unit-files --type=service</code> <em>(all, active and non-active)</em></td></tr><tr><td>Running processes</td><td><code>ps aux</code><br><code>top</code>  <em>(dynamic)</em></td></tr><tr><td>Scheduled tasks</td><td><code>ls -lah /etc/cron*</code><br><code>crontab -l</code>  <em>(current user's job)</em><br><code>cat /etc/crontab</code><br><code>ls /etc/cron.d</code><br><code>cat /var/spool/cron/crontabs/root</code></td></tr><tr><td>Disks/Drives mounted</td><td><code>df -h</code>  <em>(<code>-t ext4</code> for only /dev/sda)</em><br><code>mount</code><br><code>cat /etc/fstab</code>  <em>(drives mounted at boot time)</em><br><code>cat /etc/fstab | grep -v "#" | column -t</code>  <em>(unmounted file systems)</em><br><code>lsblk</code>  <em>(all disks available)</em></td></tr><tr><td>Drivers and Kernel modules</td><td><code>lsmod</code><br><code>/sbin/modinfo &#x3C;MODULE_NAME></code>  <em>(module taken from the command above)</em></td></tr><tr><td>Various listing</td><td><code>lsblk</code>  <em>(block devices)</em><br><code>lsusb</code>  <em>(dispositivi usb)</em><br><code>lsof</code>  <em>(open file)</em><br><code>lspci</code>  <em>(PCI device)</em><br><code>lscpu</code>  <em>(CPU)</em></td></tr><tr><td>History</td><td><code>history</code><br><code>cat ~/.*history</code></td></tr><tr><td>Environment variables</td><td><code>env</code><br><code>cat /proc/self/environ</code>  <em>(file containing environment variables)</em></td></tr><tr><td>PATH variable</td><td><code>$PATH</code></td></tr></tbody></table>

## Warnings

* `cat /var/log/syslog | grep <STRING>` \
  It allows you to search the logs, check why something is going wrong, what is blocking it etc.
