Рубрики
Uncategorized

Практикуйте основные команды Linux

Unix Tools Bash Commands uname-a ## Получить версию ядра … Теги с Linux, Devops.

Команды Bash

uname -a                ## Get the Kernel Version
lsb_release -a          # Release or Distibution info
cat /etc/SuSE-release   # Suse Linux Version Check
cat /etc/debian_version # Debian Version check

Основные команды, чтобы узнать статус сервера

uptime                  # it will shows how long the system has been running
hostname                # System Host Name
hostname -i             # To Display to the ip address of the Host, Linux based distribution
man hier                # File system hierarchy Description
last reboot             # to know the system reboot history

Аппаратная информация

Ядро обнаружил HW

dmesg                   # Detect Hardware and Boot messages
lsdev                   # Info about the installed Hardware like PCI Card
dd if=/dev/mem bs=1k skip=768 count=256 2>/dev/null | strings -n 8  # Read BIOS

Linux.

cat /proc/cpuinfo                # CPU Model
cat /proc/meminfo                # Hardware Memory
grep MemTotal /proc/meminfo      # Physical Memory
watch -n1 'cat /proc/interrupts' # watch changecable interrupts
free -m                          # To know the used & free memory ( -m for MB)
cat /proc/devices                # Configured devices
lspci -tv                        # PCI Device info
lsusb -tv                        # USB Device info
lshal                            # List all devices with properties
dmidecode                        # DMI/SMBIOS: hw info from the BIOS

Бесплатный BSD

sysctl hw.model                 # CPU Model
sysctl hw                       # More information about hardware
sysctl hw.ncpu                  # No. of active CPU's Installed
sysctl vm                       # Memory Usage
sysctl hw.realmem               # Hardware Memory (Physical)
sysctl -a | grep mem            # Kernel memory settings and info
sysctl dev                      # Configured devices
pciconf -l -cv                  # PCI Device info
usbdevs -v                      # USB Device info
atacontrol list                 # ATA Device info
camcontrol devlist -v           # SCSI Device info

Нагрузка, статистика и сообщения

Следующие команды полезны, чтобы узнать, что происходит в системе в реальном времени.

top                             # display & update the top CPU processes
mpstat 1                        # display processors related statistics
vmstat 2                        # virtual memory statistics
iostat 2                        # I/O statistics - 2sec intervals
systat -vmstat 1                # system statistics - 1sec intervals
systat -tcp 1                   # tcp connections (try also -ip)
systat -netstat 1               # active network connections - BSD
systat -ifstat 1                # network traffic through active interfaces - BSD
systat -iostat 1                # CPU and Disk throughput - BSD
ipcs -a                         # info on system V interprocess
tail -n 500 /var/log/messages   # Last 500 Kernel/syslog messages
tail /var/log/warn              # System Warnings messages see syslog.conf

Пользователи

id                                                  # To display the active user ID with login & group
last                                                # To know the last logins on the server
who or w                                            # Who is logged on the server currently in simple type "w"
groupadd admin                                      # Adding group "admin"
useradd -c "Dhanesh Kumar" -g admin -m colin        # Creating user "Dhanesh Kumar", with "admin" group
usermod -a -G                          # Adding existing user to the group - Debian Based
groupmod -A                            # Adding existing user to the group - Suse Linux
userdel dhanesh                                     # delete the user "dhanesh" (linux / Solaris)
adduser dhanesh                                     # FreeBSD add user joe (interactive)
rmuser dhanesh                                      # FreeBSD delete user joe (interactive)
pw groupadd admin                                   # Use pw on FreeBSD
pw groupmod admin -m newmember                      # Add a new member to a group
pw useradd dhanesh -c "Dhanesh Kumar" -g admin -m -s /bin/tcsh
pw userdel dhanesh; pw groupdel admin

/etc/Тень — зашифрованные пароли хранятся

Временно предотвратить системные буквы для всего пользователя, кроме пользователя root, с помощью Nologin.

echo "Apologies no login now" > /etc/nologin     #(linux)
echo "Apologies no login now" > /var/run/nologin #(FreeBSD)

Пределы в Linux.

Некоторое приложение требует ограничения Higer на открытых файлах и сокетах (например, прокси-сервер, база данных). Ограничения по умолчанию обычно слишком низки.

Shell/Script.

Оригинал: «https://dev.to/dhanupreeth/practise-the-linux-basic-commands-31i5»