Grouped linux command list Users, files, installation, search, archived and compressed, LAN-WAN

Lecture



Files and directories
cd / home go to directory '/ home'
cd .. go to the directory level up
cd ../ .. go to the directory two levels higher
cd go to home directory
cd ~ user go to the user's home directory
cd - go to the directory where you were in before going to the current directory
pwd show current directory
ls display the contents of the current directory
ls -F display the contents of the current directory with the characters that characterize the type added to the names
ls -l show a detailed view of the files and directories in the current directory
ls -a show hidden files and directories in the current directory
ls * [0-9] * show files and directories with numbers in the name
tree show the tree of files and directories, starting from the root (/)
lstree
mkdir dir1 create a directory named 'dir1'
mkdir dir1 dir2 create two directories at the same time
mkdir -p / tmp / dir1 / dir2 create directory tree
rm -f file1 delete the file named 'file1'
rmdir dir1 delete the directory named 'dir1'
rm -rf dir1 delete the directory with the name 'dir1' and recursively all its contents
rm -rf dir1 dir2 delete two directories and recursively their contents
mv dir1 new_dir rename or move file or directory
cp file1 file2 Copy file1 to file2
cp dir / *. copy all files of the dir directory to the current directory
cp -a / tmp / dir1. copy the dir1 directory with all its contents to the current directory
cp -a dir1 dir2 copy dir1 directory to dir2 directory
ln -s file1 lnk1 create a symbolic link to a file or directory
ln file1 lnk1 create a "hard" (physical) link to a file or directory
touch -t 0712250000 fileditest modify the date and time of the file creation, if it is missing, create a file with the specified date and time (YYMMDDhhmm)
File search
find / -name file1 find files and directories named file1. Search start from root (/)
find / -user user1 find the file and directory owned by user1. Search start from root (/)
find / home / user1 -name "* .bin" Find all files and directories with names ending in '. bin '. Search start with '/ home / user1'
find / usr / bin-type f -atime +100 find all files in '/ usr / bin', which last accessed more than 100 days
find / usr / bin -type f -mtime -10 find all files in '/ usr / bin', created or modified in the last 10 days
find / -name * .rpm -exec chmod 755 '{}' \; find all files and directories with names ending in '.rpm' and change access rights to them
find / -xdev -name "* .rpm" find all files and directories whose names end in '.rpm', ignoring removable media such as cdrom, floppy, etc.
locate "* .ps" find all files containing the name '.ps'. Pre-recommended to run the 'updatedb' command
whereis halt shows the placement of binary files, source codes and manuals related to the 'halt' file
which halt displays the full path to the halt file

Mounting File Systems
mount / dev / hda2 / mnt / hda2 mounts the 'hda2' partition to the '/ mnt / hda2' mount point. Make sure the mount point directory is '/ mnt / hda2'
umount / dev / hda2 unmount the 'hda2' partition. Before executing, leave '/ mnt / hda2'
fuser -km / mnt / hda2 forced unmounting of a partition. It is used when a section is occupied by a user.
umount -n / mnt / hda2 perform unmounting without entering information in / etc / mtab. Useful when the file has read-only attributes or insufficient disk space.
mount / dev / fd0 / mnt / floppy mount floppy disk
mount / dev / cdrom / mnt / cdrom mount CD or DVD
mount / dev / hdc / mnt / cdrecorder mount CD-R / CD-RW or DVD-R / DVD-RW (+ -)
mount -o loop file.iso / mnt / cdrom mount ISO image
mount -t vfat / dev / hda5 / mnt / hda5 mount windows file system FAT32
mount -t smbfs -o username = user, password = pass // winclient / share / mnt / share Mount Windows Network File System (SMB / CIFS)
mount -o bind / home / user / prg / var / ftp / user "mounts" a directory into a directory (binding). Available from kernel version 2.4.0. It is useful, for example, to provide the contents of a user directory via ftp when running an ftp server in a sandbox (chroot), when symlinks cannot be made. Running this command will make a copy of the contents of / home / user / prg in / var / ftp / user
Disk space
df -h displays information about mounted partitions showing the total, available and used space (Note of translator. switch -h does not work in all * nix systems)
ls -lSr | more returns a list of files and directories recursively, sorted by increasing size and allows paging
du -sh dir1 calculates and displays the size occupied by the 'dir1' directory (Note of the translator. the -h switch does not work on all * nix systems)
du -sk * | sort -rn displays the size and names of files and directories, with sorting by size
rpm -q -a --qf '% 10 {SIZE} t% {NAME} n' | sort -k1,1n shows the size of the used disk space occupied by the rpm-package files, sorted by size (fedora, redhat, etc.)
dpkg-query -W -f = '$ {Installed-Size; 10} t $ {Package} n' | sort -k1,1n shows the size of the used disk space occupied by the files of the deb-package, sorted by size (ubuntu, debian etc.)

Users and groups
groupadd group_name create a new group named group_name
groupdel group_name delete group group_name
groupmod -n new_group_name old_group_name rename old_group_name to new_group_name
useradd -c "Nome Cognome" -g admin -d / home / user1 -s / bin / bash user1 create user user1, assign it as the home directory / home / user1, as shell / bin / bash, include it in the admin group and add the comment Nome Cognome
useradd user1 create user user1
userdel -r user1 delete user1 and his home directory
usermod -c "User FTP" -g system -d / ftp / user1 -s / bin / nologin user1 change user attributes
passwd Change password
passwd user1 change user1 user password (only root)
chage -E 2005-12-31 user1 set the expiration date of the user1 user account
pwck check the correctness of the system files of accounts. The files / etc / passwd and / etc / shadow are checked.
grpck checks the correctness of the system files of accounts. The / etc / group file is checked.
newgrp [-] group_name changes the primary group of the current user. If you specify "-", the situation will be identical to the one in which the user embroidered from the system and logged in again. If you do not specify a group, the primary group will be assigned from / etc / passwd
Setting / changing permissions for files
ls -lh viewing permissions on files and directories in the current directory
ls / tmp | pr -T5 -W $ COLUMNS output the contents of the / tmp directory and divide the output into five columns
chmod ugo + rwx directory1 add permissions to directory1 directory ugo (User Group Other) + rwx (Read Write eXecute) - all full rights. Similar can be done this way chmod 777 directory1
chmod go-rwx directory1 take away from the group and all the rest all the authority on the directory1 directory.
chown user1 file1 assign user1 to file1
chown -R user1 directory1 recursively set user1 to user1 directory1
chgrp group1 file1 change the group that owns file1 to group1
chown user1: group1 file1 change owner and group of file1
find / -perm -u + s find, starting from the root, all files with exposed SUID
chmod u + s / bin / binary_file assign the SUID bit to the / bin / binary_file file. This allows any user to run a file with the authority of the file owner.
chmod us / bin / binary_file remove the suid-bit from the file / bin / binary_file.
chmod g + s / home / public set the SGID bit of the / home / public directory.
chmod gs / home / public Remove the SGID from the / home / public directory.
chmod o + t / home / public assign STIKY bits to the / home / public directory. Allows deleting files only to owners
chmod ot / home / public remove the STIKY-bit from the directory / home / public
Special file attributes
chattr + a file1 allow to open file for writing only in append mode
chattr + c file1 Allows the kernel to automatically compress / decompress the contents of a file.
chattr + d file1 will tell dump to ignore this file during backup execution
chattr + i file1 makes the file inaccessible for any changes: editing, deleting, moving, creating links to it.
chattr + s file1 allows you to make deleting a file safe, i.e. set attribute s says that when deleting a file, the space occupied by the file on the disk is filled with zeros, which prevents the possibility of data recovery.
chattr + S file1 indicates that, when saving changes, synchronization will be performed, as when the sync command is executed
chattr + u file1 This attribute indicates that when a file is deleted, its contents will be saved and, if necessary, the user will be able to restore it.
lsattr show file attributes
Archiving and file compression
bunzip2 file1.bz2 decompresses the file 'file1.gz'
gunzip file1.gz
gzip file1 compress file 'file1'
bzip2 file1
gzip -9 file1 compress file file1 with maximum compression
rar a file1.rar test_file create a rar-archive 'file1.rar' and include the test_file file in it
rar a file1.rar file1 file2 dir1 create a rar-archive 'file1.rar' and include file1, file2 and dir1
rar x file1.rar unpack rar-archive
unrar x file1.rar
tar -cvf archive.tar file1 create a archive archive tar.tar containing file file1
tar -cvf archive.tar file1 file2 dir1 create a archive archive tar.tar containing the file file1, file2 and dir1
tar -tf archive.tar show archive contents
tar -xvf archive.tar unpack archive
tar -xvf archive.tar -C / tmp unzip the archive in / tmp
tar -cvfj archive.tar.bz2 dir1 create archive and compress it using bzip2 (Note of translator. switch -j does not work in all * nix systems)
tar -xvfj archive.tar.bz2 unzip the archive and unzip it (Note. -j switch does not work in all * nix systems)
tar -cvfz archive.tar.gz dir1 create archive and compress it with gzip
tar -xvfz archive.tar.gz unzip the archive and unpack it
zip file1.zip file1 create compressed zip archive
zip -r file1.zip file1 file2 dir1 create a compressed zip archive and include several files and / or directories in it
unzip file1.zip

unzip and unzip the archive

RAR archive

  #packaging
 rar a archive.rar directory /
 
 # unpacking
 unrar archive.rar 

ZIP archive

  # file archiving
 zip archive.zip file
 # archiving directory
 zip -r archive.zip directory /
 # increase compression level
 zip -0 archive.zip file
 zip -9 archive.zip file
 # password archive protection
 # not recommended option, shows password
 zip -P password archive.zip file
 # secure option, password is requested and hidden as you type
 zip -e archive.zip file
 
 # unzip
 unzip archive.zip
 # detailed information output when unpacking
 unzip -v archive.zip
 # get list of archive contents
 unzip -l archive.zip
 # archive check for damage
 unzip -t archive.zip 

Tar archive

  # archiving a file or directory without compression
 tar -cf archive.tar file
 # additional key "v", for a detailed conclusion of the archiving process
 tar -cvf archive.tar directory /
 
 # archiving using gzip compression
 tar -zcvf archive.tar.gz file
 tar -zcvf archive.tar.gz directory /
 # archiving using bzip2 compression
 tar -jcvf archive.tar.bz2 file
 tar -jcvf archive.tar.bz2 directory /
 
 # checking the gzip archive without unpacking
 tar -zvtf archive.tar.gz
 # bzip2 archive check without unpacking
 tar -jvtf archive.tar.bz2
 
 # unpacking the gzip archive
 tar -zxvf archive.tar.gz
 # unpacking the bzip2 archive with indication of the final folder for files
 tar -jxvf archive.tar.bz2 directory / 

Archive 7z

  # install
 sudo apt-get install p7zip p7zip-full
 
 # archive
 7z a arch.7z file01.foo file02.foo
 
 # unpacking
 7z x arch.7z
 7z x arch.7z -o / where_recover
 
 # view archive
 7z l arch.7z
 7z l -slt arch.7z 

Archive LZMA

  # installation
 sudo aptitude install lzma
 
 # Pack the file.  Attention!  the file itself is archived,
 #those.  from the file get an archive!  the file itself after packaging will not be!
 lzma -z filename
 
 # Unpacking
 lzma -d filename.lzma 

Using atool is a script to manage file archives of various types. Now you do not need to remember that the 7z archives need to be unpacked with one command, and rar with another.

  # installation
 sudo apt-get install atool
 
 # unpacking
 aunpack foobar.tar.gz
 
 # archiving
 apack myarchive.zip file1 file2 

Deb packages (Debian, Ubuntu and the like)
dpkg -i package.deb install / upgrade package
dpkg -r package_name remove package from system
dpkg -l show all packages installed on the system
dpkg -l | grep httpd among all the packages installed in the system, find the package containing "httpd" in your name
dpkg -s package_name display information about a specific package
dpkg -l package_name list the files included in the package installed in the system
dpkg --contents package.deb display the list of files included in the package that is not yet installed in the system
dpkg -S / bin / ping find the package that contains the specified file.
APT - package management tool (Debian, Ubuntu, and the like)
apt-get install package_name install / upgrade package
apt-cdrom install package_name install / update package from cdrom
apt-get update get updated package lists
apt-get upgrade update packages installed on the system
apt-get remove package_name remove the package installed on the system while saving configuration files
apt-get purge package_name remove the package installed in the system with the removal of configuration files
apt-get check check the integrity of dependencies
apt-get clean remove downloaded archive package files
apt-get autoclean delete old downloaded archive files
View file contents
cat file1 output the contents of file1 to standard output
tac file1 output the contents of file1 to the standard output device in reverse order (the last line becomes the first, etc.)
more file1 paginal output of the contents of file1 to standard output
less file1 paginal output of the contents of file1 to a standard output device, but with the possibility of scrolling in both directions (up and down), searching through the contents, etc.
head -2 file1 output the first two lines of file1 to standard output. The default is ten lines.
tail -2 file1 output the last two lines of file1 to standard output. The default is ten lines.
tail -f / var / log / messages output the contents of the file / var / log / messages to the standard output device as text appears in it.
Text manipulations
cat file_originale | [operation: sed, grep, awk, grep, etc.]> result.txt the general syntax for taking actions to process the contents of a file and output the result to a new one
cat file_originale | [operazione: sed, grep, awk, grep etc.] >> result.txt The general syntax for taking actions to process the contents of a file and output the result to an existing file. If the file does not exist, it will be created.
grep Aug / var / log / messages from the file '/ var / log / messages' select and output to the standard output device the lines containing "Aug"
grep ^ Aug / var / log / messages from the file '/ var / log / messages' select and display on the standard output device the lines beginning with "Aug"
grep [0-9] / var / log / messages from the file '/ var / log / messages' select and display on the standard output device lines containing numbers
grep Aug -R / var / log / * select and display on the standard output device the lines containing "Aug" in all files located in the / var / log directory and below
sed 's / stringa1 / stringa2 / g' example.txt in the file example.txt, replace "string1" with "string2", output the result to the standard output device.
sed '/ ^ $ / d' example.txt remove empty lines from example.txt
sed '/ * # / d; / ^ $ / d 'example.txt remove empty lines and comments from the example.txt file
echo 'esempio' | tr '[: lower:]' '[: upper:]' convert lower case to upper case characters
sed -e '1d' result.txt remove the first line from the example.txt file
sed -n '/ string1 / p' display only strings containing "string1"
sed -e 's / * $ //' example.txt remove empty characters in at the end of each line
sed -e 's / string1 // g' example.txt remove the string "string1" from the text without changing everything else
sed -n '1,8p; 5q' example.txt take from the file from the first to the eighth lines and from them output the first five
sed -n '5p; 5q' example.txt display the fifth line
sed -e 's / 0 * / 0 / g' example.txt replace a sequence of any number of zeros with one zero
cat -n file1 number lines when displaying file contents
cat example.txt | awk 'NR% 2 == 1' when displaying the contents of a file, do not display even lines of the file
echo abc | awk '{print $ 1}' display the first column. Split, by default, by space / tab character / tab character
echo abc | awk '{print $ 1, $ 3}' display the first and three columns. Split, by default, by space / tab character / tab character
paste file1 file2 combine the contents of file1 and file2 in the form of a table: line 1 of file1 = line 1 column 1-n, line 1 of file2 = line 1 column n + 1-m
paste -d '+' file1 file2 combine the contents of file1 and file2 as a table with a "+" separator
sort file1 file2 sort the contents of two files
sort file1 file2 | uniq sort the contents of two files without displaying repetitions
sort file1 file2 | uniq -u sort the contents of two files, displaying only unique lines (lines found in both files are not output to standard output)
sort file1 file2 | uniq -d sort the contents of two files, displaying only duplicate lines
comm -1 file1 file2 compare the contents of two files without displaying the lines belonging to the file 'file1'
comm -2 file1 file2 compare the contents of two files without displaying the lines belonging to the file 'file2'
comm -3 file1 file2 compare the contents of two files, deleting lines found in both files
Conversion of character sets and file formats
dos2unix filedos.txt fileunix.txt convert text file from MSDOS to UNIX (difference in carriage return characters)
unix2dos fileunix.txt filedos.txt convert a text file from UNIX to MSDOS (difference in the characters of the return flag)
recode ..HTML <page.txt> page.html convert the contents of the test file page.txt to html-file page.html
recode -l | more list available formats
File System Analysis
badblocks -v / dev / hda1 check hda1 section for bad blocks
fsck / dev / hda1 check / restore the integrity of the linux-file system of the hda1 partition
fsck.ext2 / dev / hda1 check / restore integrity of the ext2 file system of the hda1 partition
e2fsck / dev / hda1
e2fsck -j / dev / hda1 check / restore the integrity of the ext3 file system of the hda1 partition with indication that the log is located there
fsck.ext3 / dev / hda1 check / restore integrity of the ext3 file system of the hda1 partition
fsck.vfat / dev / hda1 check / restore the integrity of the file system fat section hda11
fsck.msdos / dev / hda1
dosfsck / dev / hda1
Formatting file systems
mkfs / dev / hda1 create linux file system on hda1 partition
mke2fs / dev / hda1 create an ext2 file system on hda1 partition
mke2fs -j / dev / hda1 create an ext3 journaling file system on hda1
mkfs -t vfat 32 -F / dev / hda1 create a FAT32 file system on hda1 partition
fdformat -n / dev / fd0 format floppy disk without checking
mkswap / dev / hda3 creating swap space on hda3 partition
swap space
mkswap / dev / hda3 creating swap space on hda3 partition
swapon / dev / hda3 activate swap space located on hda3 partition
swapon / dev / hda2 / dev / hdb3 activate swap spaces located on sections hda2 and hdb3
Creation of backup copies (backup)
dump -0aj -f /tmp/home0.bak / home create a full backup of the / home directory in the /tmp/home0.bak file
dump -1aj -f /tmp/home0.bak / home create an incremental backup of the / home directory in the /tmp/home0.bak file
restore -if /tmp/home0.bak restore from backup /tmp/home0.bak
rsync -rogpav --delete / home / tmp sync / tmp with / home
rsync -rogpav -e ssh --delete / home ip_address: / tmp sync through ssh tunnel
rsync -az -e ssh --delete ip_addr: / home / public / home / local synchronize a local directory with a remote directory through an ssh tunnel with compression
rsync -az -e ssh --delete / home / local ip_addr: / home / public synchronize remote directory with local directory through ssh tunnel with compression
dd bs = 1M if = / dev / hda | gzip | ssh user @ ip_addr 'dd of = hda.gz' make a "cast" of a local disk to a file on a remote computer through an ssh tunnel
tar -Puf backup.tar / home / user создать инкрементальную резервную копию директории '/home/user' в файл backup.tar с сохранением полномочий
( cd /tmp/local/ && tar c . ) | ssh -C user@ip_addr 'cd /home/share/ && tar x -p' копирование содержимого /tmp/local на удалённый компьютер через ssh-туннель в /home/share/
( tar c /home ) | ssh -C user@ip_addr 'cd /home/backup-home && tar x -p' копирование содержимого /home на удалённый компьютер через ssh-туннель в /home/backup-home
tar cf - . | (cd /tmp/backup ; tar xf - ) копирование одной директории в другую с сохранением полномочий и линков
find /home/user1 -name '*.txt' | xargs cp -av --target-directory=/home/backup/ --parents поиск в /home/user1 всех файлов, имена которых оканчиваются на '.txt', и копирование их в другую директорию
find /var/log -name '*.log' | tar cv --files-from=- | bzip2 > log.tar.bz2 поиск в /var/log всех файлов, имена которых оканчиваются на '.log', и создание bzip-архива из них
dd if=/dev/hda of=/dev/fd0 bs=512 count=1 создать копию MBR (Master Boot Record) с /dev/hda на флоппи-диск
dd if=/dev/fd0 of=/dev/hda bs=512 count=1 восстановить MBR с флоппи-диска на /dev/hda
CDROM
cdrecord -v gracetime=2 dev=/dev/cdrom -eject blank=fast -force clean a rewritable cdrom
mkisofs /dev/cdrom > cd.iso create an iso image of cdrom on disk
mkisofs /dev/cdrom | gzip > cd_iso.gz create a compressed iso image of cdrom on disk
mkisofs -J -allow-leading-dots -R -V "Label CD" -iso-level 4 -o ./cd.iso data_cd create an iso image of a directory
cdrecord -v dev=/dev/cdrom cd.iso burn an ISO image
gzip -dc cd_iso.gz | cdrecord dev=/dev/cdrom - burn a compressed ISO image
mount -o loop cd.iso /mnt/iso mount an ISO image
cd-paranoia -B rip audio tracks from a CD to wav files
cd-paranoia -- "-3" rip first three audio tracks from a CD to wav files
cdrecord --scanbus scan bus to identify the channel scsi
Сеть (LAN и WiFi)
ifconfig eth0 показать конфигурацию сетевого интерфейса eth0
ifup eth0 активировать (поднять) интерфейс eth0
ifdown eth0 деактивировать (опустить) интерфейс eth0
ifconfig eth0 192.168.1.1 netmask 255.255.255.0 выставить интерфейсу eth0 ip-адрес и маску подсети
ifconfig eth0 promisc перевести интерфейс eth0 в promiscuous-режим для "отлова" пакетов (sniffing)
ifconfig eth0 -promisc отключить promiscuous-режим на интерфейсе eth0
dhclient eth0 активировать интерфейс eth0 в dhcp-режиме.
route -n вывести локальную таблицу маршрутизации
netstat -rn
route add -net 0/0 gw IP_Gateway задать ip-адрес шлюза по умолчанию (default gateway)
route add -net 192.168.0.0 netmask 255.255.0.0 gw 192.168.1.1 добавить статический маршрут в сеть 192.168.0.0/16 через шлюз с ip-адресом 192.168.1.1
route del 0/0 gw IP_gateway удалить ip-адрес шлюза по умолчанию (default gateway)
echo "1" > /proc/sys/net/ipv4/ip_forward разрешить пересылку пакетов (forwarding)
hostname отобразить имя компьютера
host www.linuxguide.it разрешить имя www.linuxguide.it хоста в ip-адрес и наоборот
host 62.149.140.85
ip link show отобразить состояние всех интерфейсов
mii-tool eth0 отобразить статус и тип соединения для интерфейса eth0
ethtool eth0 отображает статистику интерфеса eth0 с выводом такой информации, как поддерживаемые и текущие режимы соединения
netstat -tupn отображает все установленные сетевые соединения по протоколам TCP и UDP без разрешения имён в ip-адреса и PID'ы и имена процессов, обеспечивающих эти соединения
netstat -tupln отображает все сетевые соединения по протоколам TCP и UDP без разрешения имён в ip-адреса и PID'ы и имена процессов, слушающих порты
tcpdump tcp port 80 отобразить весь трафик на TCP-порт 80 (обычно - HTTP)
iwlist scan просканировать эфир на предмет, доступности беспроводных точек доступа
iwconfig eth1 показать конфигурацию беспроводного сетевого интерфейса eth1
Microsoft Windows networks(SAMBA)
nbtscan ip_addr разрешить netbios-имя nbtscan не во всех системах ставится по-умолчанию, возможно, придётся доустанавливать вручную. nmblookup включен в пакет samba.
nmblookup -A ip_addr
smbclient -L ip_addr/hostname отобразить ресурсы, предоставленные в общий доступ на windows-машине
smbget -Rr smb://ip_addr/share подобно wget может получить файлы с windows-машин через smb-протокол
mount -t smbfs -o username=user,password=pass //winclient/share /mnt/share смонтировать smb-ресурс, предоставленный на windows-машине, в локальную файловую систему
IPTABLES (firewall)
iptables -t filter -nL отобразить все цепочки правил
iptables -nL
iptables -t nat -L отобразить все цепочки правил в NAT-таблице
iptables -t filter -F очистить все цепочки правил в filter-таблице
iptables -F
iptables -t nat -F очистить все цепочки правил в NAT-таблице
iptables -t filter -X удалить все пользовательские цепочки правил в filter-таблице
iptables -t filter -A INPUT -p tcp --dport telnet -j ACCEPT позволить входящее подключение telnet'ом
iptables -t filter -A OUTPUT -p tcp --dport http -j DROP блокировать исходящие HTTP-соединения
iptables -t filter -A FORWARD -p tcp --dport pop3 -j ACCEPT позволить "прокидывать" (forward) POP3-соединения
iptables -t filter -A INPUT -j LOG --log-prefix "DROP INPUT" включить журналирование ядром пакетов, проходящих через цепочку INPUT, и добавлением к сообщению префикса "DROP INPUT"
iptables -t nat -A POSTROUTING -o eth0 -j MASQUERADE включить NAT (Network Address Translate) исходящих пакетов на интерфейс eth0. Допустимо при использовании с динамически выделяемыми ip-адресами.
iptables -t nat -A PREROUTING -d 192.168.0.1 -p tcp -m tcp --dport 22 -j DNAT --to-destination 10.0.0.2:22 перенаправление пакетов, адресованных одному хосту, на другой хост
Мониторинг и отладка
top отобразить запущенные процессы, используемые ими ресурсы и другую полезную информацию (с автоматическим обновлением данных)
ps -eafw отобразить запущенные процессы, используемые ими ресурсы и другую полезную информацию (единожды)
ps -e -o pid,args --forest вывести PID'ы и процессы в виде дерева
pstree отобразить дерево процессов
kill -9 98989 "убить" процесс с PID 98989 "на смерть" (без соблюдения целостности данных)
kill -KILL 98989
kill -TERM 98989 Корректно завершить процесс с PID 98989
kill -1 98989 заставить процесс с PID 98989 перепрочитать файл конфигурации
kill -HUP 98989
lsof -p 98989 отобразить список файлов, открытых процессом с PID 98989
lsof /home/user1 отобразить список открытых файлов из директории /home/user1
strace -c ls >/dev/null вывести список системных вызовов, созданных и полученных процессом ls
strace -f -e open ls >/dev/null вывести вызовы бибилотек
watch -n1 'cat /proc/interrupts' отображать прерывания в режиме реального времени
last reboot отобразить историю перезагрузок системы
last user1 отобразить историю регистрации пользователя user1 в системе и время его нахождения в ней
lsmod вывести загруженные модули ядра
free -m показать состояние оперативной памяти в мегабайтах
smartctl -A /dev/hda контроль состояния жёсткого диска /dev/hda через SMART
smartctl -i /dev/hda проверить доступность SMART на жёстком диске /dev/hda
tail /var/log/dmesg вывести десять последних записей из журнала загрузки ядра
tail /var/log/messages вывести десять последних записей из системного журнала
Другие полезные команды
apropos ...keyword выводит список комманд, которые так или иначе относятся к ключевым словам. Полезно, когда вы знаете что делает программа, но не помните команду
man ping вызов руководства по работе с программой, в данном случае, - ping
whatis ...keyword отображает описание действий указанной программы
mkbootdisk --device /dev/fd0 `uname -r` создаёт загрузочный флоппи-диск
gpg -c file1 шифрует файл file1 с помощью GNU Privacy Guard
gpg file1.gpg дешифрует файл file1 с помощью GNU Privacy Guard
wget -r www.example.com загружает рекурсивно содержимое сайта www.example.com
wget -c www.example.com/file.iso download the file www.example.com/file.iso with the ability to stop and continue later
echo 'wget -c www.example.com/files.iso' | at 09:00 start downloading at a specified time
ldd / usr / bin / ssh list the libraries required for ssh
alias hh = 'history' assign hh alias to history

Comments


To leave a comment
If you have any suggestion, idea, thanks or comment, feel free to write. We really value feedback and are glad to hear your opinion.
To reply

LINUX operating system

Terms: LINUX operating system