Перейти к содержанию

System Commands Reference

Print all environment variables:

printenv

Manual: printenv

In case you need to stop/start the local PostgreSQL:

sudo systemctl status postgresql
sudo systemctl stop postgresql
sudo systemctl start postgresql

Manual: systemctl

How to print all .py files in a project folder except some folders:

find . -type d \( -path ./.tox -o -path ./venv_py39 -o -path ./venv_py310 \) -prune -o -name '*.py' -print

How to find all folders and files where the word "telegram" occurs:

find / -iname "*telegram*" 2>/dev/null

How to display a tree of directories and files of a Python project:

# Using
tree -a -I 'venv_py310|.idea|.git|.pytest_cache|.mypy_cache|.hypothesis|.coverage|__pycache__|docs|tests|src|*.sql|*.xml' --dirsfirst --sort=name -n -A

Print operating system version:

lsb_release -a

No LSB modules are available.
Distributor ID: Ubuntu
Description:    Ubuntu 20.04.3 LTS
Release:    20.04
Codename:   focal

Find currently running shell:

ls -l /proc/$$/exe

# /proc/19624/exe -> /usr/bin/bash

Getting the default shell information:

echo $SHELL

# /bin/bash

Manual: grep

kubectl explain pod --recursive | grep -A5 tolerations

Find out host IP addresses:

ip address show
Manual: ip-address

To see what is currently listening on which port:

$ sudo netstat -tulpn

Active Internet connections (only servers)
Proto Recv-Q Send-Q Local Address           Foreign Address         State       PID/Program name
tcp        0      0 127.0.0.53:53           0.0.0.0:*               LISTEN      917/systemd-resolve
tcp        0      0 127.0.0.1:631           0.0.0.0:*               LISTEN      952/cupsd
tcp        0      0 127.0.0.1:5432          0.0.0.0:*               LISTEN      1186/postgres
tcp        0      0 127.0.0.1:8000          0.0.0.0:*               LISTEN      25428/python
tcp6       0      0 127.0.0.1:63342         :::*                    LISTEN      8920/java
tcp6       0      0 ::1:631                 :::*                    LISTEN      952/cupsd
tcp6       0      0 127.0.0.1:6942          :::*                    LISTEN      8920/java
udp        0      0 0.0.0.0:57025           0.0.0.0:*                           948/avahi-daemon: r
udp        0      0 127.0.0.53:53           0.0.0.0:*                           917/systemd-resolve
udp        0      0 0.0.0.0:631             0.0.0.0:*                           1050/cups-browsed
udp        0      0 0.0.0.0:5353            0.0.0.0:*                           948/avahi-daemon: r
udp6       0      0 :::41301                :::*                                8920/java
udp6       0      0 :::8976                 :::*                                8920/java
udp6       0      0 :::60237                :::*                                948/avahi-daemon: r
udp6       0      0 :::5353                 :::*                                948/avahi-daemon: r
Manual: netstat