Linux 命令行
2021-12-15
Fedora 36 将采用 plocate 替代 mlocate 成为默认的查找索引,据说更快。
而且 Debian 也早采纳了 plocate。
安装
apt show plocate
# Package: plocate
# Version: 1.1.8-2
# Priority: optional
# Section: universe/utils
# Origin: Ubuntu
# Maintainer: Ubuntu Developers <ubuntu-devel-discuss@lists.ubuntu.com>
# Original-Maintainer: Steinar H. Gunderson <sesse@debian.org>
# Bugs: https://bugs.launchpad.net/ubuntu/+filebug
# Installed-Size: 510 kB
# Depends: libc6 (>= 2.33), libgcc-s1 (>= 3.3.1), libstdc++6 (>= 6), liburing1 (>= 0.7), libzstd1 (>= 1.4.0)
# Suggests: systemd-sysv | powermgmt-base, systemd-sysv | nocache
# Breaks: mlocate
# Replaces: mlocate
# Homepage: https://plocate.sesse.net/
# Task: xubuntu-desktop, ubuntu-budgie-desktop, ubuntu-budgie-desktop-raspi
# Download-Size: 119 kB
# APT-Manual-Installed: yes
# APT-Sources: https://mirrors.cloud.tencent.com/ubuntu impish/universe amd64 Packages
# Description: much faster locate
# plocate is a locate(1) based on posting lists, giving much faster searches
# on a much smaller index. It is a drop-in replacement for mlocate in nearly
# all aspects, and is fast on SSDs and non-SSDs alike.
sudo apt install -y plocate
使用
根据 apt show 信息,plocate 会 break mlocate。
updatedb 命令会改由 plocate 提供。
ll /usr/bin/locate /usr/bin/updatedb /etc/alternatives/locate /etc/alternatives/updatedb
lrwxrwxrwx 1 root root 16 2021-12-15 11:51:56 /etc/alternatives/locate -> /usr/bin/plocate
lrwxrwxrwx 1 root root 26 2021-12-15 11:51:56 /etc/alternatives/updatedb -> /usr/sbin/updatedb.plocate
lrwxrwxrwx 1 root root 24 2021-12-15 11:51:56 /usr/bin/locate -> /etc/alternatives/locate
lrwxrwxrwx 1 root root 26 2021-12-15 11:51:56 /usr/bin/updatedb -> /etc/alternatives/updatedb
根据官网提供的演示数据,其 DB 只有 mlocate 的 40%,查询时间只有 mlocate 的万分之四。
其具体操作和 mlocate 类似:
sudo updatedb
locate go.mod
有没有 2500 倍的提升我不知道,但是感觉好像确实快。挺好!
参考资料与拓展阅读
Windows 命令行
2018-01-15
Active Directory
ADmodcmd Active Directory Bulk Modify
CSVDE Import or Export Active Directory data
DSACLs Active Directory ACLs
DSAdd Add items to active directory (user group computer)
DSGet View items in active directory (user group computer)
DSQuery Search for items in active directory (user group computer)
DSMod Modify items in active directory (user group computer)
DSMove Move an Active directory Object
DSRM Remove items from Active Directory
Batch Files
CALL Call one batch program from another 内部命令
CHOICE Accept keyboard input to a batch file
CLIP Copy STDIN to the Windows clipboard
CLS Clear the screen 内部命令
CMD Start a new CMD shell
COLOR Change colors of the CMD window 内部命令
DOSKEY Edit command line, recall commands, and create macros
ECHO Display message on screen 内部命令
ENDLOCAL End localisation of environment changes in a batch file 内部命令
EVENTCREATE Add a message to the Windows event log
EXIT Quit the current script/routine and set an errorlevel 内部命令
FOR /F Loop command: against a set of files 内部命令
FOR /F Loop command: against the results of another command 内部命令
FOR Loop command: all options Files, Directory, List 内部命令
GOTO Direct a batch program to jump to a labelled line 内部命令
IF Conditionally perform a command 内部命令
IFMEMBER Is the current user a member of a Workgroup
LOGTIME Log the date and time in a file
MAPISEND Send email from the command line
MORE Display output, one screen at a time
PAUSE Suspend processing of a batch file and display a message 内部命令
PROMPT Change the command prompt 内部命令
REM Record comments (remarks) in a batch file 内部命令
RUN Start | RUN commands
RUNAS Execute a program under a different user account
SET Display, set, or remove session environment variables 内部命令
SETLOCAL Control the visibility of environment variables 内部命令
SETX Set environment variables
SORT Sort input
SHIFT Shift the position of batch file parameters 内部命令
SLEEP Wait for x seconds
START Start a program, command or batch file 内部命令
TIMEOUT Delay processing of a batch file
TITLE Set the window title for a CMD.EXE session 内部命令
WAITFOR Wait for or send a signal
WMIC WMI Commands
:: Comment / Remark 内部命令
Disk Management
BCDBOOT Create or repair a system partition
BCDEDIT Manage Boot Configuration Data
CONVERT Convert a FAT drive to NTFS
CHKDSK Check Disk - check and repair disk problems
CHKNTFS Check the NTFS file system
DEFRAG Defragment hard drive
DISKPART Disk Administration
DISKSHADOW Volume Shadow Copy Service
DriverQuery Display installed device drivers
FORMAT Format a disk
FREEDISK Check free disk space (in bytes)
LABEL Edit a disk label
MOUNTVOL Manage a volume mount point
NTBACKUP Backup folders to tape
SFC System File Checker
VOL Display a disk label 内部命令
Files and Folders
ASSOC Change file extension associations 内部命令
ASSOCIAT One step file association
ATTRIB Change file attributes
BITSADMIN Background Intelligent Transfer Service
CACLS Change file permissions
CD Change Directory - move to a specific Folder 内部命令
CIPHER Encrypt or Decrypt files/folders
COMP Compare the contents of two files or sets of files
COMPACT Compress files or folders on an NTFS partition
COMPRESS Compress individual files on an NTFS partition
COPY Copy one or more files to another location 内部命令
CSCcmd Client-side caching (Offline Files)
DEL Delete one or more files 内部命令
DELTREE Delete a folder and all subfolders
DIR Display a list of files and folders 内部命令
ERASE Delete one or more files 内部命令
EXPAND Uncompress files
EXTRACT Uncompress CAB files
FC Compare two files
FIND Search for a text string in a file
FINDSTR Search for strings in files
FORFILES Batch process multiple files
FSUTIL File and Volume utilities
FTP File Transfer Protocol
FTYPE File extension file type associations 内部命令
iCACLS Change file and folder permissions
MD Create new folders 内部命令
MOVE Move files from one folder to another 内部命令
MKLINK Create a symbolic link (linkd)
OPENFILES Query or display open files
POPD Return to a previous directory saved by PUSHD 内部命令
PsFile Show files opened remotely
PUSHD Save and then change the current directory 内部命令
RECOVER Recover a damaged file from a defective disk
REN Rename a file or files 内部命令
REPLACE Replace or update one file with another
RD Delete folder(s) 内部命令
RMTSHARE Share a folder or a printer
ROBOCOPY Robust File and Folder Copy
SHARE List or edit a file share or print share
SHORTCUT Create a windows shortcut (.LNK file)
SUBINACL Edit file and folder Permissions, Ownership and Domain
TAKEOWN Take ownership of a file
TOUCH Change file timestamps
TREE Graphical display of folder structure
TYPE Display the contents of a text file 内部命令
WHERE Locate and display files in a directory tree
WINDIFF Compare the contents of two files or sets of files
XCACLS Change file and folder permissions
XCOPY Copy files and folders
Group Policy/Windows Installer
DevCon Device Manager Command Line Utility
GPRESULT Display Resultant Set of Policy information
GPUPDATE Update Group Policy settings
MSIEXEC Microsoft Windows Installer
PsInfo List information about a system
PsShutdown Shutdown or reboot a computer
REGSVR32 Register or unregister a DLL
SHUTDOWN Shutdown the computer
SLMGR Software Licensing Management (Vista/2008)
WUAUCLT Windows Update
Networking
ARP Address Resolution Protocol
BROWSTAT Get domain, browser and PDC info
DNSSTAT DNS Statistics
GETMAC Display the Media Access Control (MAC) address
IPCONFIG Configure IP
NET Manage network resources
NETDOM Domain Manager
NETSH Configure Network Interfaces, Windows Firewall & Remote access
NBTSTAT Display networking statistics (NetBIOS over TCP/IP)
NETSTAT Display networking statistics (TCP/IP)
NMBIND Manage Hyper-V network bindings
NSLOOKUP Name server lookup
PATHPING Trace route plus network latency and packet loss
PsPing Measure network performance
PING Test a network connection
ROUTE Manipulate network routing tables
TRACERT Trace route to a remote host
Processes
PATH Display or set a search path for executable files 内部命令
PsExec Execute process remotely
PsKill Kill processes by name or process ID
PsList List detailed information about processes
PsGetSid Display the SID of a computer or a user
PsSuspend Suspend processes
SCHTASKS Schedule a command to run at a specific time
SYSMON Monitor and log system activity to the Windows event log
TASKLIST List running applications and services
TASKKILL End a running process
TSKILL End a running process
TLIST Task list with full path
Printing
MODE Configure a system device
PRINT Print a text file
PRINTBRM Print queue Backup/Recovery
RUNDLL32 Run a DLL command (add/remove print connections)
Recovery
BOOTREC Repair or replace a partition boot sector (WinRE).
BCDBOOT Create or repair a system partition.
BCDEDIT Manage Boot Configuration Data.
WPEUTIL Run commands during a Windows Preinstallation Environment (WinPE) session.
Registry
REG Registry: Read, Set, Export, Delete keys and values
REGEDIT Import or export registry settings
REGINI Change Registry Permissions
Remote Desktop
CHANGE Change Terminal Server Session properties
Query Process Display processes (TS/Remote Desktop)
Query Session Display all sessions (TS/Remote Desktop)
Query TermServer List all servers (TS/Remote Desktop)
Query User Display user sessions (TS/Remote Desktop)
MSTSC Terminal Server Connection (Remote Desktop Protocol)
RASDIAL Manage RAS connections
RASPHONE Manage RAS connections
Reset Session Delete a Remote Desktop Session
TSDISCON Disconnect a Remote Desktop Session
WINRM Windows Remote Management
WINRS Windows Remote Shell
Services
CASPOL Code Access Security Policy Tool.
PORTQRY Display the status of ports and services
PsService View and control services
SC Service Control
System Information
CHANGEPK Upgrade device Edition/Product Key
DATE Display or set the date 内部命令
HELP Online Help
LOGMAN Manage Performance Monitor logs
MBSAcli Baseline Security Analyzer
MSINFO32 System Information
NOW Display the current Date and Time
NTRIGHTS Edit user account rights
PsLogList Event log records
SFC System File Checker
SXSTRACE Diagnose side-by-side problems.
SYSMON Monitor and log system activity to the Windows event log
SYSTEMINFO List system configuration
TIME Display or set the system time 内部命令
TypePerf Write performance data to a log file
VER Display version information 内部命令
VERIFY Verify that files have been saved 内部命令
WHOAMI Output the current UserName and domain
User Administration
ADDUSERS Add or list users to/from a CSV file
CERTREQ Request certificate from a certification authority
CleanMgr Automated cleanup of Temp files, recycle bin
CON2PRT Connect or disconnect a Printer
CMDKEY Manage stored usernames/passwords
DELPROF Delete user profiles
DIRUSE Display disk usage
LOGOFF Log a user off
MOVEUSER Move a user from one domain to another
MSG Send a message
PERMS Show permissions for a user
POWERCFG Configure power settings
PsLoggedOn Who's logged on (locally or via resource sharing)
PsPasswd Change account password
SUBST Associate a path with a drive letter
Commands marked • are Internal commands only available within the CMD shell.
All other commands (not marked with •) are external commands.
External commands may be used under the CMD shell, PowerShell, or directly from START-RUN.
参考资料与拓展阅读
Bash Linux 命令行
2018-01-11
我写 Shell 脚本一般都是用 bash 执行,一般我会在头部插入 set -xue 命令, 助记:蛇血。
那么这个命令的作用是什么呢?
set 是 bash 提供的一个命令,用来管理 bash 的一些行为。
x: 在执行命令前,输出所有命令,包括参数。
u: 遇到未定义变量时,报错。
e: 如果遇到错误,程序退出。
其他更多参数,参考:set --help 或 help set。
Linux 命令行 终端
2016-05-13
在命令行中输出颜色文字。