Dos commands and linux commands

Dos commands and linux commands

DOS command

1. Query port occupancy: netstat -aon |findstr «8080»; view the port process number;

2. View the process number information: tasklist |findstr «9999»;

3. Kill the process: taskkill -f -t -im javaw.exe;

4. Modify the mysql database password:

mysql>use mysql;
mysql>UPDATE user SET password=PASSWORD('Enter a new password') WHERE user='root';
mysql>FLUSH PRIVILEGES

5. Set environment variables:

6. Dos command output log to file:

Output file directory: dir >> dir.txt Output log append to dir.txt

Dir> dir.txt Enter the log into dir.txt, do not append, overwrite

Check the folder size and output dir /a /s >size.txt

@echo off if "%1" == "h" goto begin mshta vbscript:createobject("wscript.shell").run("%~nx0 h",0)(window.close)&&exit :begin :: Write dos command below E.g: dir > dir.txt
:: DIM objShell set objShell=wscript.createObject("wscript.shell") :: iReturn=objShell.Run("cmd.exe /C c:\1.bat", 0, TRUE) :: (where win.bat is your own batch name, change it yourself) :: Then save this notepad as a file with the suffix of .vbe, then you only need to run this vbe file to achieve your goal! :: It can be simpler: :: Set ws = CreateObject("Wscript.Shell") :: ws.run "cmd /c c:\1.bat",0 :: or CreateObject("WScript.Shell").Run "cmd 1.bat",0 :: (This way of writing is a lot of anti-virus, you need to replace parameter 0) 

Linux commands

1. Query system memory status: (top, free,)

PID: process ID USER: process ownership

PR: The priority of the process, the smaller the priority, the higher the priority

VIRT: The virtual internal space occupied by the process

RES: The physical space occupied by the process

SHR: The shared content used by the process

S: The status of the process. S means dormant, R means running, Z means dead state, N means the process priority value is negative

%CPU: The use of CPU occupied by the process

%MEM: the percentage of physical memory and total memory used by the process

TIME+: The total CPU time occupied after the process is started, that is, the cumulative value of the occupied CPU usage time

COMMAND: Process start command name

2. sftp file download command:

1: Set the destination path you want to download

lcd target path to download

Switch to the download directory

get -r «Folder to be downloaded» (absolute path)

#The command to block a single IP is
iptables -I INPUT -s 123.45.6.7 -j DROP

#Close the entire paragraph, which is the command from 123.0.0.1 to 123.255.255.254
iptables -I INPUT -s 123.0.0.0/8 -j DROP

#The IP segment is the command from 123.45.0.1 to 123.45.255.254
iptables -I INPUT -s 124.45.0.0/16 -j DROP

#Sealing the IP segment is the command from 123.45.6.1 to 123.45.6.254
iptables -I INPUT -s 123.45.6.0/24 -j DROP

The instruction I is an insert instruction, but the instruction will insert in the correct position. It is not like the A instruction to see your own sorting position. Therefore, use the shield because the shielded IP must be loaded at the beginning, so you must use the I command to load, and then pay attention to the execution/ After saving etc/rc.d/init.d/iptables save, restart the service.

Читайте также:  Sane linux по сети

[ro[email protected] ~]# service iptable status —Check firewall status

[[email protected] ~]#servcie iptables stop —Turn off the firewall temporarily

[[email protected] ~]#service iptables start —Start the firewall temporarily

[r[email protected] ~]#service iptables restart —Restart the firewall

[[email protected] ~]#chkconfig iptables off —Turn off the firewall permanently

[[email protected] ~]#chkconfig iptables on —Enable the firewall permanently

3. Check the linux system version:

1) List all version information,

LSB Version: :core-3.1-amd64:core-3.1-ia32:core-3.1-noarch:graphics-3.1-amd64:graphics-3.1-ia32:graphics-3.1-noarch

Description: CentOS release 5.5 (Final)

Note: This command is applicable to all linux, includingRedHat、SUSE, Debian and other distributions.

2) Execute cat /etc/issue, for example as follows:

3) Execute cat /etc/redhat-release, for example as follows:

Check whether the system is 64-bit or 32-bit:

1、getconf LONG_BIT or getconf WORD_BIT

/bin/ls: ELF 64-bit LSB executable, AMD x86-64, version 1 (SYSV), for GNU/Linux 2.6.9, dynamically linked (uses shared libs), for GNU/Linux 2.6.9, stripped

LSB Version: :core-3.1-amd64:core-3.1-ia32:core-3.1-noarch:graphics-3.1-amd64:graphics-3.1-ia32:graphics-3.1-noarch

Description: CentOS release 5.5 (Final)

According to different versions, the commands are different;

4. File decompression command:

1) For files ending in .tar

3) For files ending in .tgz or .tar.gz

4) For files ending in .bz2

5) For files ending with tar.bz2

7) For files ending in .tar.Z

5. Query files larger than 100M

find . -type f -size +100000k -print0 | xargs -0 du -h | sort -nr

(1)find / -name httpd.conf #Find the file httpd.conf in the root directory, which means to search the entire hard disk
(2)find /etc -name httpd.conf #File httpd.conf in the /etc directory
(3)find /etc -name’*srm*’ # Use wildcard * (0 or any number). Means to find the file with the string ‘srm’ in the file name in the /etc directory
(4)find. -Name’srm*’ # means to find the file whose name starts with the string ‘srm’

2. Search according to file characteristics

(1)find / -amin -10 # Find files accessed in the last 10 minutes in the system (access time)
(2)find / -atime -2 # Find files accessed in the last 48 hours in the system
(3)find / -empty # Find files or folders that are empty in the system
(4)find / -group cat # Find files that belong to group cat in the system
(5)find / -mmin -5 # Find files modified in the last 5 minutes in the system (modify time)
(6)find / -mtime -1 #Find files modified in the last 24 hours in the system
(7)find / -user fred #Find files belonging to the user fred in the system
(8)find / -size +10000c #Find files larger than 10000000 bytes (c: byte, w: double word, k: KB, M: MB, G: GB)
(9)find / -size -1000k #find out files smaller than 1000KB

6. Upload the xxx.jar package and set the service (start, stop, status, restart)

  1. Upload xxx.jar to the linux server
  2. Set the jar package as an executable file. chmod +x xxx.jar
  3. Create a soft link under /etc/init.d $ sudo ln -s /var/myapp/myapp.jar /etc/init.d/myapp
  4. Start service service myapp start
Читайте также:  Linux remove usb device

netstat -tunlp |grep port number

8. Copy files on two Centos machines:

One is 192.168.1.1; the other is 192.168.1.2 Now copying a file on 192.168.1.1 to 192.168.1.2. Log in to 192.168.1.1 and run the command

Command:scp /home/look/dev-software/alibaba-rocektmq-3.2.6.tar.gz 192.168.1.2:/home/look/dev-software/

command:scp -r /home/look/dev-software/ 192.168.1.2:/home/look/

Then enter the password of 192.168.1.2

9. Check the application version:

10 View storage usage:

Display the disk space used by each file and directory

-c or —total In addition to displaying the size of individual directories or files, it also displays the sum of all directories or files.

-s or —summarize Only the total is displayed, and only the last totaled value is listed.

-h or —human-readable Take K, M, G as the unit to improve the readability of information.

Show the available space of the specified disk file

-a list of all file systems

-i display inode information

Mem: indicates physical memory statistics

total: indicates the total amount of physical memory (total = used + free)

used: Indicates the total amount allocated to the cache (including buffers and cache), but some of the cache may not be actually used.

free: unallocated memory. shared: shared memory.

buffers: The number of buffers allocated by the system but not used. cached: The number of caches allocated by the system but not used.

-/+ buffers/cache: indicates the cache statistics of physical memory

used2: That is, used-buffers-cached in the first line is also the total amount of memory actually used. //used2 is the second line

free2 = buffers1 + cached1 + free1 //free2 is the second line, buffers1, etc. are the first line

free2: The sum of unused buffers, cache and unallocated memory. This is the actual available memory of the system.

Swap: indicates the usage of the swap partition on the hard disk

11. After opening the file in vi/vim, search for a string:

1. In command mode, enter: /string

For example, to search for user, enter /user

After pressing enter, you can see that vim has moved the cursor to the character and highlighted the matching string

2. To view the next match, press n (lowercase n)

3. Jump to the previous match, press N (uppercase N)

4. After searching, we opened other files and found that they were also highlighted. How to turn off the highlighting?

In command mode, enter: nohlsearch or: set nohlsearch; of course, it can be abbreviated, noh or set noh.

12. The root user is prompted: Solution to Operation not permitted

When using the root user to delete a file on the server, I was told by the system: Operation not permitted. You cannot even use chmod to give 777 permissions.

The underlying implementation of the chmod command we executed above is the chattr command. This command is more powerful and can even lock the file, even if the root user cannot manipulate the file.

chattr is used to change file attributes, lsattr can be used to view file attributes, execute the command lsattr /webapps/.usr.ini to see the current file attributes;

Читайте также:  Установка альт линукс второй системой

It can be found that the current file has an i attribute. You can see that files with the i attribute cannot be modified or deleted even if you are a root user.

Now that the reason why the file cannot be deleted is the addition of the i attribute, the corresponding solution is to remove the i attribute of the file and then delete it.

chattr -i webapps //remove i attribute
rm -rf webapps //Delete folder

Источник

Приложение B. Сравнение общих DOS и Linux команд

Многие команды Linux, вводимые в приглашении командной оболочки похожи на команды, которые вы могли встретить в системе MS-DOS. По сути, многие команды идентичны.

В этом приложении приведены некоторые общие команды, используемые в приглашении MS-DOS в системах Windows 9 x и аналогичные команды в Linux. Также здесь приведены примеры использования команд в приглашении командной оболочки Linux. Заметьте, что эти команды обычно имеют различные параметры. Чтобы больше узнать о каждой команде, прочитайте связанные с ней страницы руководства (например, введите man ls в приглашении оболочки, чтобы получить описание команды ls ).

Таблица B-1. Похожие команды

Предназначение командыMS-DOSLinuxПример использования команды в Linux
Копировать файлы копировать cp cp thisfile.txt /home/ thisdirectory
Переместить файлы move mv mv thisfile.txt /home/ thisdirectory
Просмотреть список файлов dir ls ls
Очистить экран cls clear clear
Закрыть окно приглашения exit exit exit
Просмотреть или изменить дату date date date
Удалить файлы del rm rm thisfile.txt
Вывести сообщение на экран echo echo echo this message
Отредактировать файл в простом текстовом редакторе edit pico [a] pico thisfile.txt
Сравнить содержимое файлов fc diff diff file1 file2
Найти в файле текстовую строку find grep grep this word or phrase thisfile.txt
Отформатировать дискету format a: (если дискета находится в дисководе A: ) mke2fs (или mformat [b] ) /sbin/mke2fs /dev/fd0 ( /dev/fd0 является эквивалентом диска A: в системе Linux)
Вывести справку о команде command /? man [c] man command
Создать каталог mkdir mkdir mkdir directory
Просмотреть файл more less [d] less thisfile.txt
Переименовать файл ren mv mv thisfile.txt thatfile.txt [e]
Вывести текущее расположение в файловой системе chdir pwd pwd
Изменить каталог на указанный ( абсолютный путь ) cd pathname cd pathname cd /directory/directory
Изменить каталог на относительный путь cd .. cd .. cd ..
Вывести текущее время time date date
Вывести общий и используемый объем ОЗУ mem free free
Замечание:
a. Pico — это простой текстовый редактор, вместо Pico вы можете использовать Emacs и vi .
b. При этом диск будет отформатирован для файловой системе DOS.
c. Для некоторых команд вы можете получить дополнительную информацию с помощью info .
d. Команда more может также использоваться для постраничного просмотра файла на экране.
e. Команда mv может как переместить файл, так и переименовать его, «переместив» его внутри одного каталога, как и показано в этом примере.

Источник

Оцените статью
Adblock
detector