Вход
  • Главная
  • Документация
  • Главная
  • Документация

АГИС Модули

Главная/Документация/АГИС Модули
Развернуть все Свернуть все
  • База данных
  •  Администрирование
    •   Ubuntu
      •   Установка ubuntu
        • Инсталяция
        • Docker и его установка
      •   LVM&Snapshot
        • LVM
        • Snapshot
        • agis_backup_lvm_xfs-v2
        • Ошибки
      • Резервные копии
      •   Nginx, ssl, letsencrypt
        • Letsencrypt
      •   NAS
        • Synology
      • SSH
      • date and time
      •   Разные команды
        • systemctl
    •   Базы данных
      • Запуск базы данных АГИС
      •   Mongo
        • mongodump-mongorestore
        • Как узнать версию mongodb
        • Test mongo db
        • Запросы mongodb
        • Запуск mongodb
      •   PostgreSQL
        • Test postgis
        • Dump&Restore
        • Установка и запуск
        • PostgreSQL разное
      •   Elastic search
        • Команды elasticsearch
        • Tools to backup and restore ElasticSearch indices
      • Troubleshooting базы данных АГИС
    •   Docker
      • Команды Docker
    •   Разное
      • Сколько байт(бит) в килобайте, мегабайте, гигабайте
  •  АГИС ГИС сервер
    • Запуск и остановка Tile сервера
    • Экспорт шейпа из АГИС ГИС
    • Импорт шейпа в АГИС ГИС
    • Backup&restore postgis(postgres)
    • Troubleshooting postgis
  •  AГИС scada
    •   Паспорта контроллеров
      • Функции zander

Разные команды

246 просмотров 0 30.10.2020 27.12.2020

hostnamectl

$ hostnamectl
Static hostname: agis-asa68
Transient hostname: agis
Icon name: computer-vm
Chassis: vm
Machine ID: f81dc25d05de41bab90ca03496415d8d
Boot ID: 932d53a7b2734607b9f0c00d95a85c44
Virtualization: microsoft
Operating System: Ubuntu 18.04.4 LTS
Kernel: Linux 4.15.0-126-generic
Architecture: x86-64

Поменять

$ sudo hostnamectl set-hostname agis-asa68

Edit the /etc/hosts file

$ sudo cat /etc/hosts
127.0.0.1 localhost.localdomain localhost agis-asa68
::1  localhost6.localdomain6   localhost6

# The following lines are desirable for IPv6 capable hosts
::1     localhost ip6-localhost ip6-loopback
fe00::0 ip6-localnet
ff02::1 ip6-allnodes
ff02::2 ip6-allrouters
ff02::3 ip6-allhosts

Edit the cloud.cfg file.
If the cloud-init package is installed you also need to edit the cloud.cfg file. This package is usually installed by default in the images provided by the cloud providers such as AWS and it is used to handle the initialization of the cloud instances.

To check if the package is installed run the following ls command :

$ ls -l /etc/cloud/cloud.cfg

If you see the following output it means that the package is not installed and no further action is required.

ls: cannot access '/etc/cloud/cloud.cfg': No such file or directory

If the package is installed the output will look like the following:

-rw-r--r-- 1 root root 3169 Apr 27 09:30 /etc/cloud/cloud.cfg

In this case you’ll need to open the /etc/cloud/cloud.cfg file:

sudo nano /etc/cloud/cloud.cfg

Search for preserve_hostname and change the value from false to true:

$ cat /etc/cloud/cloud.cfg
# This will cause the set+update hostname module to not operate (if true)
preserve_hostname: true

Save the file and close your editor.

Verify the change
To verify that the hostname was successfully changed, once again use the hostnamectl command:

$ hostnamectl
   Static hostname: agis-asa68
         Icon name: computer-vm
           Chassis: vm
        Machine ID: f81dc25d05de41bab90ca03496415d8d
           Boot ID: 932d53a7b2734607b9f0c00d95a85c44
    Virtualization: microsoft
  Operating System: Ubuntu 18.04.4 LTS
            Kernel: Linux 4.15.0-126-generic
      Architecture: x86-64
agis@agis-asa68:~$

Grep

Чтобы не выводить все строки с совпадением, а вывести только имя файла, нужно воспользоваться конструкцией (https://eternalhost.net/base/vps-vds/bash-rabota-so-strokami):

$ grep -I "devir" */*/package.*
node_modules/common-tools/package.json:    "url": "http://git.devir.kz:10080/root/common-tools.git"
node_modules/communication-layer/package.json:    "url": "http://git.devir.kz/root/communication-layer.git"
node_modules/data-layer/package.json:    "url": "http://git.devir.kz:10080/root/data-layer.git"
node_modules/zander-data-models/package.json:    "url": "http://git.devir.kz:10080/root/zander-data-models.git"
node_modules/zander-data-models/package.json:    "data-layer": "git+http://git.devir.kz:10080/root/data-layer.git"
node_modules/zander-support/package.json:    "url": "http://git.devir.kz:10080/root/zander-support.git"

Nano. Замена. Жмем ALT+R или Ctrl\

Вводим, что ищем, затем на что меняем. Клавишей Y мы подтверждаем одну замену, а клавишей A — заменить все.

Команды docker

$ – запуск с хоста
# -запуск внутри контейнера

$ docker logs -f --tail 100 container-ID
# apt update
# apt install iputils-ping
# apt install curl

Открытые порты

Netstat — широко используемый инструмент для сбора информации о сетевой подсистеме Linux. Вы можете использовать его для вывода всех открытых портов следующим образом:

$ sudo netstat -ltup

Флаг -l указывает netstat вывести все прослушивающие сокеты (сокет это ip + порт), -t показывает все TCP-соединения, -u отображает все соединения UDP, а -p позволяет выводить имя приложения/программы, прослушивающее порт.

Использование RCP – копирование файлов и директорий между двумя хостами

devir@devir:~$ rcp ./filename.tgz user@192.168.1.10:/data/agis/agis-db
user@192.168.1.10's password:
filename.tgz   		          100% 2432MB  16.3MB/s   02:29

Подавлять ошибки в bash

find / -name file2find 2>/dev/null

Cron

/var/spool/cron/crontabs - где хранится crontab файл юзера
grep CRON /var/log/syslog
40 1 * * * tar czpf /data/gitlab/agis.kz/gitlab/data/backups/ssh_$(date +\%Y-\%m-\%d_\%H-\%M-\%S).tgz /etc/ssh >> /var/log/mycron 2>&1
50 1 * * * tar czpf /data/gitlab/agis.kz/gitlab/data/backups/config_$(date +\%Y-\%m-\%d_\%H-\%M-\%S).tgz /data/gitlab/agis.kz/gitlab/config >> /var/log/mycron 2>&1
0 2 * * * /usr/bin/docker exec -t gitlab_web_1 gitlab-backup create STRATEGY=copy SKIP=registry CRON=1

Параметр CRON=1среды указывает сценарию резервного копирования подавлять все выходные данные о ходе выполнения, если нет ошибок. Это рекомендуется для уменьшения спама в cron

Cron synology

$ nano /etc/crontab
$ synoservice -restart crond

https подключение с помощью CURL из командной строки

Добавить флаг -k к вызову, чтобы разрешить небезопасные соединения

curl -k https://129.10.1.10:30345

Проверка версии Ubuntu из терминала

$ lsb_release -a

Это было полезно?

Да  Нет
Вам может быть интересно
  • Функции zander
  • Паспорта контроллеров
  • AГИС scada
  • systemctl
  • База данных
  • date and time
  • Copyright 2020 AGIS. Все права защищены