Linux入門命令100條
Linux Commands - Overview and Examples
The command line is one of the most powerful features of Linux. There exists a sea of Linux command line tools, allowing you to do almost everything you can think of doing on your Linux PC. However, this usually creates a problem: with so many commands available to use, you dont know where and how to start learning them, especially when you are beginner.
The command line is one of the most powerful features of Linux. There exists a sea of Linux command line tools, allowing you to do almost everything you can think of doing on your Linux PC. However, this usually creates a problem: with so many commands available to use, you dont know where and how to start learning them, especially when you are beginner.
Author
Himanshu Arora: 印度理工學院、伊利諾伊大學香檳分校;軟體開發工程師。
原文:https://www.howtoforge.com/linux-commands/
本文的特點是非常簡潔,將繁雜的Linux命令行篩選出100條左右,非常適合入門學習。 此外,將領域知識以「條目+示例」的方式來整理,類似編字典一樣,在編輯的過程中可以促進學習者加深認識,也方便日後持續改進(增加註解、參考文獻、索引等),是一種不錯的學習方法。 最後,整理這些命令行的時候,我體會到操作系統最重要的工作實際就是對文件的管理,創建、移動、查看、編輯、銷毀、檢索,都是圍繞文件的操作,事實上也是實際工作中使用最頻繁的需求。對開發者來說,以Linux命令行為模版,命名風格、人機交互、小而美的實現方式,促進自己在其它領域的應用、提高大有裨益。
Adduser/Addgroup
分類:許可權管理;增加用戶、用戶組
The adduser and addgroup commands lets you add a new user and group to a system, respectively. Heres an example for adduser:
$ sudo adduser testusernAdding user `testuser ...nAdding new group `testuser (1003) ...nAdding new user `testuser (1003) with group `testuser ...nCreating home directory `/home/testuser ...nCopying files from `/etc/skel ...nEnter new UNIX password:n
Arch
分類:系統信息;查看CPU架構
The arch command is used to print the machines architecture. For example:
$ archni686nNot sure what i686 means? Head here.n
Cal/Ncal
分類:系統信息;查看日曆
The cal and ncal commands display a calendar in the output.
$ calnMarch 2017nSu Mo Tu We Th Fr San1 2 3 4n5 6 7 8 9 10 11n12 13 14 15 16 17 18n19 20 21 22 23 24 25n26 27 28 29 30 31nn$ ncalnMarch 2017nSu 5 12 19 26nMo 6 13 20 27nTu 7 14 21 28nWe 1 8 15 22 29nTh 2 9 16 23 30nFr 3 10 17 24 31nSa 4 11 18 25n
Cat
分類:文件管理;查看文件內容 The cat command allows you to concatenate files, or data provided on standard input, and print it on the standard output. In layman terms, the command prints the information provided to it, whether through stdin or in the form a file.
$ cat test.txtnHello...how are you?n
Cd
分類:文件管理;切換工作目錄 The cd command is used to change users present working directory.
$ cd /home/himanshu/n
Chgrp
分類:文件管理、許可權管理;切換文件所屬組 The chgrp command allows you to change the group ownership of a file. The command expects new group name as its first argument and the name of file (whose group is being changed) as second argument.
$ chgrp howtoforge test.txtn
Chmod
分類:文件管理、許可權管理;切換文件執行許可權 The chmod command lets you change access permissions for a file. For example, if you have a binary file (say helloWorld), and you want to make it executable, you can run the following command:
chmod +x helloWorldn
Chown
分類:文件管理、許可權管理;切換文件所有者 The chown command allows you to change the ownership and group of a file. For example, to change the owner of a file test.txt to root, as well as set its group as root, execute the following command:
chown root:root test.txtn
Cksum
分類:文件管理;查看文件屬性 The cksum command prints the CRC checksum and byte count for the input file.
$ cksum test.txtn3741370333 20 test.txtnNot sure what checksum is? Head here.n
Clear
分類:人機交互;清屏 The clear command is used to clear the terminal screen.
$ clearn
Cmp
分類:文件管理;文件比對 byte-by-byte The cmp command is used to perform byte-by-byte comparison of two files.
$ cmp file1 file2nfile1 file2 differ: byte 1, line 1n
Comm
分類:文件管理;文件比對 The comm command is used to compare two sorted files line-by-line. For example, if file1 contains numbers 1-5 and file2 contains number 4-8, heres what the comm command produces in this case:
$ comm file1 file2n
支持選項:
-1:不顯示在第一個文件出現的內容;n-2:不顯示在第二個文件中出現的內容;n-3:不顯示同時在兩個文件中都出現的內容。n
Cp
分類:文件管理;文件複製 The cp command is used for copying files and directories.
$ cp test.txt /home//himanshu/Desktop/n
Csplit
分類:文件管理;待補充內容 The csplit command lets you split a file into sections determined by context lines. For example, to split a file into two where the first part contains n-1 lines and the second contains the rest, use the following command:
$ csplit file1 [n]n
The two parts are saved as files with names xx00 and xx01, respectively.
Date
分類:系統信息;查看系統時間 The date command can be used to print (or even set) the system date and time.
$ datenTue Feb 28 17:14:57 IST 2017n
Dd
分類:文件管理;待補充內容 The dd command copies a file, converting and formatting according to the operands. For example, the following command creates an image of /dev/sda partition.
dd if=/dev/sda of=/tmp/dev-sda-part.imgn
Df
分類:文件管理;查看文件系統利用率 The df command displays the file system disk space usage in output.
$ df /dev/sda1nFilesystem 1K-blocks Used Available Use% Mounted onn/dev/sda1 74985616 48138832 23014620 68% /n
Diff
分類:文件管理;文件比對 line-by-line The diff command lets you compare two files line by line.
$ diff file1 file2n
Diff3
分類:文件管理;文件比對,三個文件 The diff3 command, as the name suggests, allows you to compare three files line by line.
diff3 file1 file2 file3n
Dir
分類:文件管理;查看當前目錄文件列表 The dir command lists directory contents. For example:
$ dirntest1 test2 test.7z test.zipn
Dirname
分類:文件管理;查看當前目錄 The dirname command strips last component from a file name/path. In laymans terms, you can think of it as a tool that, for example, removes file name from the files absolute path.
$ dirname /home/himanshu/file1n/home/himanshun
Dmidecode
分類:系統信息;查看硬體信息
The dmidecode command prints a systems DMI (aka SMBIOS) table contents in a human-readable format.
$ sudo dmidecoden# dmidecode 2.12nSMBIOS 2.6 present.n50 structures occupying 2056 bytes.nTable at 0x000FCCA0.nHandle 0x0000, DMI type 0, 24 bytesnBIOS InformationnVendor: American Megatrends Inc.nVersion: 080015nRelease Date: 08/22/2011n...n...n...n
DMI (Desktop Management Interface, DMI)就是幫助收集電腦系統信息的管理系統,DMI信息的收集必須在嚴格遵照SMBIOS規範的前提下進行。 SMBIOS(System Management BIOS)是主板或系統製造者以標準格式顯示產品管理信息所需遵循的統一規範。SMBIOS和DMI是由行業指導機構Desktop Management Task Force (DMTF)起草的開放性的技術標準,其中DMI設計適用於任何的平台和操作系統。
Du
分類:文件管理;查看指定目錄磁碟利用率 The du command displays disk usage of files present in a directory as well as its sub-directories.
$ du /home/himanshu/Desktop/n92 /home/himanshu/Desktop/Downloads/meld/meld/uin88 /home/himanshu/Desktop/Downloads/meld/meld/vcn56 /home/himanshu/Desktop/Downloads/meld/meld/matchersn12 /home/himanshu/Desktop/Downloads/meld/meld/__pycache__n688 /home/himanshu/Desktop/Downloads/meld/meldn16 /home/himanshu/Desktop/Downloads/meld/binn328 /home/himanshu/Desktop/Downloads/meld/data/uin52 /home/himanshu/Desktop/Downloads/meld/data/icons/svgn
Echo
The echo command displays whatever input text is given to it.
$ echo hello hinhello hin
Ed
分類:文件管理;編輯器 ed is a line-oriented text editor.
$ edn
單行純文本編輯器,它有命令模式(command mode)和輸入模式(input mode)兩種工作模式。 支持選項:
A:切換到輸入模式,在文件的最後一行之後輸入新的內容;n C:切換到輸入模式,用輸入的內容替換掉最後一行的內容;n i:切換到輸入模式,在當前行之前加入一個新的空行來輸入內容;n d:用於刪除最後一行文本內容;n n:用於顯示最後一行的行號和內容;n w:<文件名>:一給定的文件名保存當前正在編輯的文件;n q:退出ed編輯器。n
Eject
分類:媒體管理;卸載 The eject command lets you eject removable media (typically, a CD ROM or floppy disk)
$ ejectn
Env
分類:系統信息;查看用戶環境變數 The env command not only displays the current environment, but also lets you edit it.
$ envn
Exit
分類:交互;退出 The exit command causes the shell to exit.
$ exitn
Expand
分類:文件管理;編輯器;將TAB符替換為空格符 The expand command converts tabs present in the input file(s) into spaces, and writes the file contents to standard output.
$ expand file1n
Expr
分類:計算器;表達式 The expr command evaluates expressions. For example:
$ expr 1 + 2n3n
Factor
分類:計算器;分解質因數 The factor command prints the prime factors of the input number.
$ factor 135n135: 3 3 3 5n
Fgrep
分類:文件管理;搜索;匹配指定文件字元
The fgrep command is equivalent to the grep command when executed with the -F command line option. The tool is also known as fixed or fast grep as it doesnt treat regular expression metacharacters as special, processing the information as simple string instead.
For example, if you want to search for dot (.) in a file, and dont want grep to interpret it as a wildcard character, use fgrep in the following way:
$ fgrep "." [file-name]n
Find
分類:文件管理;搜索; The find command lets you search for files in a directory as well as its sub-directories.
$ find test*ntestntest1ntest2ntest.7zntest.cntest.txtnMore examples for the Linux Find command:nn* 14 Practical Examples of Linux Find Command for Beginnersn* Searching For Files And Folders With The find Commandn* Finding Files On The Command Linen
Fmt
分類:文件管理;讀取文件內容並格式化輸出(查看支持選項) fmt is a simple optimal text formatter. It reformats each paragraph in the file passed to it, and writes the file contents to standard output.
$ fmt file1n
Fold
分類:交互;控制文件內容輸出時所佔用的屏幕寬度
The fold command wraps each input line to fit in specified width.
$ fold -w 10nHi my name is himanshu AroranHi my namenis himansnhu Aroran
Free
分類:系統信息;性能監測;查看內存利用情況。詳細介紹 >>>more>>> The free command displays the amount of free and used memory in the system.
$ freen total used free shared buffers cachednMem: 1800032 1355288 444744 79440 9068 216236n-/+ buffers/cache: 1129984 670048nSwap: 1832956 995076 837880n
參考:基於Linux單機的負載評估 參考:Netflix性能分析模型:In 60 Seconds
Grep
分類:文件管理;搜索; The grep command searches for a specified pattern in a file (or files) and displays in output lines containing that pattern.
$ grep Hello test.txtnHello...how are you?nMore tutorials and examples for the Linux Grep command:nn* How to use grep to search for strings in files on the shelln* How to perform pattern search in files using Grepn
Groups
分類:文件管理;搜索; The groups command displays the name of groups a user is part of.
$ groups himanshunhimanshu : himanshu adm cdrom sudo dip plugdev lpadmin sambasharen
Gzip
分類:文件管理;壓縮 The gzip command compresses the input file, replacing the file itself with one having a .gz extension.
$ gzip file1n
Gunzip
分類:文件管理;解壓縮 Files compressed with gzip command can be restored to their original form using the gunzip command.
$ gunzip file1.gzn
Head
分類:文件管理;查看文件 The head command displays the first 10 lines of the file to standard output
$ head CHANGELOG.txtnBEEBEEP (Secure Lan Messanger)nBeeBEEPn2.0.4n- Some GUI improvements (new icons, file sharing tree load faster)n- Always Beep on new message arrived (option)n- Favorite users (right click on user and enable star button) is on top of the listn- improved group usabilityn- Offline users can be removed from list (right click on an offline user in list and then remove)n- Clear all files shared (option)n- Load minimized at startup (option)n
Hostname
分類:系統信息;host name The hostname command not only displays the systems host name, but lets them set it as well.
$ hostnamenhimanshu-desktopn
Id
分類:系統信息;用戶信息 The id command prints user and group information for the current user or specified username.
$ id himanshunuid=1000(himanshu) gid=1000(himanshu) groups=1000(himanshu),4(adm),24(cdrom),27(sudo),30(dip),46(plugdev),108(lpadmin),124(sambashare)n
Kill
分類:進程管理; The kill command, as the name suggests, helps user kill a process by sending the TERM signal to it.
$ kill [process-id]n
Killall
分類:進程管理; The killall command lets you kill a process by name. Unlike kill - which requires ID of the process to be killed - killall just requires the name of the process.
$ killall nautilusn
Last
分類:安全管理;查看最近登錄用戶 The last command shows listing of last logged in users.
$ lastnhimanshu pts/11 :0 Thu Mar 2 09:46 still logged innhimanshu pts/1 :0 Thu Mar 2 09:46 still logged innhimanshu :0 :0 Thu Mar 2 09:42 still logged innreboot system boot 4.4.0-62-generic Thu Mar 2 09:41 - 10:36 (00:54)nhimanshu pts/14 :0 Wed Mar 1 15:17 - 15:52 (00:35)nhimanshu pts/13 :0 Wed Mar 1 14:40 - down (08:06)n
Ldd
分類:軟體包管理;查看一個共享庫的依賴 The ldd command displays in output dependencies of a shared library.
$ ldd /lib/i386-linux-gnu/libcrypt-2.19.sonlinux-gate.so.1 => (0xb77df000)nlibc.so.6 => /lib/i386-linux-gnu/libc.so.6 (0xb75da000)n/lib/ld-linux.so.2 (0x80088000)n
Ln
分類:文件管理;鏈接 The ln command is used for creating link between files. For example, the following command would create a link named lnk to a file with name test.txt:
$ ln test.txt lnkn
Locate
分類:文件管理;搜索 The locate command helps user find a file by name.
$ locate [file-name]n
Logname
分類:登錄信息; The logname command prints the user-name of the current user.
$ lognamenhimanshun
Ls
分類:文件管理;查看文件列表 The ls command lists contents of a directory in output.
$ ls progressncapture.png hlist.o progress progress.h sizes.cnhlist.c LICENSE progress.1 progress.o sizes.hnhlist.h Makefile progress.c README.md sizes.on
Lshw
分類:系統信息;查看硬體信息 The lshw command extracts and displays detailed information on the hardware configuration of the machine.
$ sudo lshwn[sudo] password for himanshu:nhimanshu-desktopndescription: Desktop Computernproduct: To Be Filled By O.E.M. (To Be Filled By O.E.M.)nvendor: To Be Filled By O.E.M.nversion: To Be Filled By O.E.M.nserial: To Be Filled By O.E.M.nwidth: 32 bitsncapabilities: smbios-2.6 dmi-2.6 smp-1.4 smpn...n...n..n
Lscpu
分類:系統信息;查看硬體信息-CPU The lscpu command displays in output systems CPU architecture information (such as number of CPUs, threads, cores, sockets, and more).
$ lscpunArchitecture: i686nCPU op-mode(s): 32-bit, 64-bitnByte Order: Little EndiannCPU(s): 1nOn-line CPU(s) list: 0nThread(s) per core: 1nCore(s) per socket: 1nSocket(s): 1nVendor ID: AuthenticAMDnCPU family: 16nModel: 6nStepping: 3nCPU MHz: 2800.234nBogoMIPS: 5600.46nVirtualization: AMD-VnL1d cache: 64KnL1i cache: 64KnL2 cache: 1024Kn
Man
分類:幫助; man lets you access reference manual for commands, programs/utilities, as well as functions.
$ man lsn
Md5sum
分類:計算器;md5 The md5sum command lets you print or check MD5 (128-bit) checksums.
$ md5sum test.txtnac34b1f34803a6691ff8b732bb97fbba test.txtn
Mkdir
分類:文件管理;創建目錄 The mkdir command lets you create directories.
$ mkdir [dir-name]n
Mkfifo
分類:進程管理 The mkfifo command is used to create named pipes.
$ mkfifo [pipe-name]n
More
分類:交互 more is basically a filter for paging through text one screenful at a time.
$ cat [large-file] | moren
Mv
分類:文件管理;移動 The mv command lets you either move a file from one directory to another, or rename it.
$ mv test.txt /home/himanshu/Desktop/n
Nice
分類:進程管理;指定進程優先順序 The nice command lets you run a program with modified scheduling priority.
$ nice -n[niceness-value] [program]nn$ nice -n15 vimn
Nl
分類:文件管理;輸出行號 The nl command writes contents of a file to output, and prepends each line with line number.
$ nl file1n1 Hin2 How are youn3 Byen
Nm
分類:文件管理 The nm command is used to display symbols from object files.
$ nm testn0804a020 B __bss_startn0804841d T comparen0804a020 b completed.6591n0804a018 D __data_startn0804a018 W data_startn08048360 t deregister_tm_clonesn080483d0 t __do_global_dtors_auxn08049f0c t __do_global_dtors_aux_fini_array_entryn0804a01c D __dso_handlen08049f14 d _DYNAMICn0804a020 D _edatan0804a024 B _endn080484e4 T _finin080484f8 R _fp_hwn080483f0 t frame_dummyn...n...n...n
Nproc
分類:進程管理 The nproc command displays the number of processing units available to the current process.
$ nprocn1n
Od
分類:文件管理 The od command lets you dump files in octal as well as some other formats.
$ od /bin/lsn0000000 042577 043114 000401 000001 000000 000000 000000 000000n0000020 000002 000003 000001 000000 140101 004004 000064 000000n0000040 122104 000001 000000 000000 000064 000040 000011 000050n0000060 000034 000033 000006 000000 000064 000000 100064 004004n0000100 100064 004004 000440 000000 000440 000000 000005 000000n0000120 000004 000000 000003 000000 000524 000000 100524 004004n...n...n...n
Passwd
分類:用戶許可權管理 The passwd command is used for changing passwords for user accounts.
$ passwd himanshunChanging password for himanshu.n(current) UNIX password:n
Paste
分類:交互 The paste command lets you merge lines of files. For example, if file1 contains the following lines:
$ cat file1nHinMy name isnHimanshunAroranInAmnanLinux researchernand tutorialnwriternThen the following paste command will join all the lines of the file:nn$ paste -s file1nHi My name is Himanshu Arora I Am a Linux researcher and tutorial writern
Pidof
分類:進程管理 The pidof command gives you the process ID of a running program/process.
$ pidof nautilusn2714n
Ping
分類:網路管理 The ping command is used to check whether or not a system is up and responding. It sends ICMP ECHO_REQUEST to network hosts.
$ ping howtoforge.comnPING howtoforge.com (104.24.0.68) 56(84) bytes of data.n64 bytes from 104.24.0.68: icmp_seq=1 ttl=58 time=47.3 msn64 bytes from 104.24.0.68: icmp_seq=2 ttl=58 time=51.9 msn64 bytes from 104.24.0.68: icmp_seq=3 ttl=58 time=57.4 msn
Ps
分類:進程管理 The ps command displays information (in the form of a snapshot) about the currently active processes.
$ psnPID TTY TIME CMDn4537 pts/1 00:00:00 bashn20592 pts/1 00:00:00 psn
Pstree
分類:進程管理 The pstree command produces information about running processes in the form of a tree.
$ pstreeninit???ModemManager???2*[{ModemManager}]n??NetworkManager???dhclientn? ??dnsmasqn? ??3*[{NetworkManager}]n??accounts-daemon???2*[{accounts-daemon}]n??acpidn??atopn
Pwd
The pwd command displays the name of current/working directory.
$ pwdn/home/himanshun
Rm
分類:文件管理 The rm command lets you remove files and/or directories.
$ rm [file-name]n
Rmdir
分類:文件管理 The rmdir command allows you delete empty directories.
$ rmdir [dir-name]n
Scp
分類:文件管理 The scp command lets you securely copy files between systems on a network.
$ scp [name-and-path-of-file-to-transfer] [user]@[host]:[dest-path]n
Sdiff
分類:文件管理;文本比對 side-by-side The sdiff command lets you perform a side-by-side merge of differences between two files.
$ sdiff file1 file2n
Sed
分類:文件管理;編程工具 sed is basically a stream editor that allows users to perform basic text transformations on an input stream (a file or input from a pipeline).
$ echo "Welcome to Howtoforge" | sed -e s/Howtoforge/HowtoForge/gnWelcome to HowtoForgen
Seq
分類:計算器 The seq commands prints numbers from FIRST to LAST, in steps of INCREMENT. For example, if FIRST is 1, LAST is 10, and INCREMENT is 2, then heres the output this command produces:
$ seq 1 2 10n1n3n5n7n9n
Sha1sum
分類:計算器 The sha1sum command is used to print or check SHA1 (160-bit) checksums.
$ sha1sum test.txtn955e48dfc9256866b3e5138fcea5ea0406105e68 test.txtn
Shutdown
The shutdown command lets user shut the system in a safe way.
$ shutdownn
Size
分類:文件管理 The size command lists the section sizes as well as the total size for an object or archive file.
$ size testntext data bss dec hex filenamen1204 280 4 1488 5d0 testn
Sleep
The sleep command lets user specify delay for a specified amount of time. You can use it to delay an operation like:
$ sleep 10; shutdownn
Sort
分類:文件管理 The sort command lets you sort lines of text files. For example, if file2 contains the following names:
$ cat file2nzeusnkyannsamnadamnThen running the sort command produces the following output:nn$ sort file2nadamnkyannsamnzeusn
Split
分類:文件管理 The split command, as the name suggests, splits a file into fixed-size pieces. By default, files with name like xaa, xab, and xac are produced.
$ split [file-name]
Ssh
ssh is basically OpenSSH SSH client. It provides secure encrypted communication between two untrusted hosts over an insecure network.
$ ssh [user-name]@[remote-server]n
Stat
分類:文件管理 The stat command displays status related to a file or a file-system.
$ stat test.txtnFile: 『test.txt』nSize: 20 Blocks: 8 IO Block: 4096 regular filenDevice: 801h/2049d Inode: 284762 Links: 2nAccess: (0664/-rw-rw-r--) Uid: ( 0/ root) Gid: ( 0/ root)nAccess: 2017-03-03 12:41:27.791206947 +0530nModify: 2017-02-28 16:05:15.952472926 +0530nChange: 2017-03-02 11:10:00.028548636 +0530nBirth: -n
Strings
分類:文件管理 The strings command displays in output printable character sequences that are at least 4 characters long. For example, when a binary executable test was passed as an argument to this command, following output was produced:
$ strings testn/lib/ld-linux.so.2nlibc.so.6n_IO_stdin_usednputsn__libc_start_mainn__gmon_start__nGLIBC_2.0nPTRhnQVhIn[^_]nEQUALn;*2$"nGCC: (Ubuntu 4.8.4-2ubuntu1~14.04.3) 4.8.4n....n....n....n
Su
分類:用戶許可權管理 The su command lets you change user-identity. Mostly, this command is used to become root or superuser.
$ su [user-name]n
Sudo
分類:用戶許可權管理 The sudo command lets a permitted user run a command as another user (usually root or superuser).
$ sudo [command]n
Sum
分類:文件管理 The sum command prints checksum and block counts for each input file.
$ sum readme.txtn45252 5n
Tac
分類:文件管理 The tac command prints input files in reverse. Functionality-wise, it does the reverse of what the cat command does.
$ cat file2nzeusnkyannsamnadamn$ tac file2nadamnsamnkyannzeusn
Tail
分類:文件管理 The tail command displays in output the last 10 lines of a file.
$ tail [file-name]n
Talk
分類:網路管理 The talk command lets users talk with each other.
$ talk [user-name]n
Tar
分類:文件管理;壓縮&解壓縮 tar is an archiving utility that lets you create as well as extract archive files. For example, to create archive.tar from files foo and bar, use the following command:
$ tar -cf archive.tar foo barnnMore...n
Tee
分類:文件管理 The tee command reads from standard input and write to standard output as well as files.
$ uname | tee file2nLinuxn$ cat file2nLinuxn
Test
分類:計算器 The test command checks file types and compare values. For example, you can use it in the following way:
$ test 7 -gt 5 && echo "true"ntruen
Time
分類:性能監測 The time command is used to summarize system resource usage of a program. For example:
$ time ping google.comnPING google.com (216.58.220.206) 56(84) bytes of data.n64 bytes from del01s08-in-f14.1e100.net (216.58.220.206): icmp_seq=1 ttl=52 time=44.2 msn^Cn--- google.com ping statistics ---n1 packets transmitted, 1 received, 0% packet loss, time 0msnrtt min/avg/max/mdev = 44.288/44.288/44.288/0.000 msnreal 0m0.676snuser 0m0.000snsys 0m0.000sn
Top
分類:系統信息;性能監測;性能概覽。詳細介紹 >>>more>>> The top command gives a dynamic real-time view of a running system (in terms of its processes). For example:
$ topn
參考:基於Linux單機的負載評估 參考:Netflix性能分析模型:In 60 Seconds
Touch
分類:文件管理 The touch command lets you change file timestamps (the access and modification times). When name of a non-existent file is passed as an argument, that file gets created.
$ touch [file-name]n
Tr
分類:文件管理 The tr command can be used to translate/squeeze/delete characters. For example, heres how you can use it to convert lowercase characters to uppercase:
$ echo howtoforge | tr "[:lower:]" "[:upper:]"nHOWTOFORGEn
Tty
分類:資源管理 The tty command prints the filename of the terminal connected to standard input.
$ ttyn/dev/pts/10n
Uname
分類:用戶許可權管理 The uname command prints certain system information.
$ uname -anLinux himanshu-desktop 4.4.0-62-generic #83~14.04.1-Ubuntu SMP Wed Jan 18 18:10:26 UTC 2017 i686 athlon i686 GNU/Linuxn
Uniq
分類:文件管理;待補充信息 The Uniq command is used to report or omit repeated lines. For example, if file2 contains the following data:
$ cat file2nWelcome to HowtoForgenWelcome to HowtoForgenA Linux tutorial websitenThanksnThen you can use the uniq command to omit the repeated line.nn$ uniq file2nWelcome to HowtoForgenA Linux tutorial websitenThanksn
Unexpand
分類:文件管理;待補充信息 The unexpand command converts spaces present in the input file(s) into tabs, and writes the file contents to standard output.
$ unexpand file1n
Uptime
分類:系統信息;性能監測;查看負載。詳細介紹 >>>more>>> The uptime command tells how long the system has been running.
$ uptimen15:59:59 up 6:20, 4 users, load average: 0.81, 0.92, 0.82n
Users
分類:用戶許可權管理;待補充信息 The users command displays in output the usernames of users currently logged in to the current host.
$ usersnhimanshu himanshu himanshu himanshun
Vdir
分類:文件管理;待補充信息 The vdir command lists information about contents of a directory (current directory by default).
$ vdirntotal 1088n-rw-rw-r-- 1 himanshu himanshu 4850 May 20 2015 test_backup.pdfn-rw-rw-r-- 1 himanshu himanshu 2082 May 28 2015 test-filled.pdfn-rw-rw-r-- 1 himanshu himanshu 7101 May 28 2015 test.pdfn
Vim
分類:編輯器 vim is basically a text/programming editor. The name vim stands for Vi IMproved as the editor is upwards compatible to the Vi editor.
$ vim [file-name]n
W
分類:性能監測 The w command displays information about the users currently on the machine, and their processes.
$ wn16:18:07 up 6:39, 4 users, load average: 0.07, 0.32, 0.53nUSER TTY FROM LOGIN@ IDLE JCPU PCPU WHATnhimanshu :0 :0 09:39 ?xdm? 1:08m 0.25s init --usernhimanshu pts/0 :0 09:41 6:36m 0.84s 7.84s gnome-terminalnhimanshu pts/10 :0 14:51 0.00s 0.16s 0.00s wnhimanshu pts/11 :0 15:41 35:19 0.05s 0.05s bashn
Wall
分類:通訊;待補充信息 The wall command lets you write and send a message to other users that are currently logged in.
$ wall [your-message]n
Watch
分類:性能監測 The watch command can be used to monitor a programs output. It runs the program repeatedly, displaying its output and errors. For example:
$ watch daten
Wc
分類:文件管理;待補充信息 The wc command prints newline, word, and byte counts for a file.
$ wc test.txtn0 3 20 test.txtn
Whatis
分類:幫助 The whatis command displays single-line manual page descriptions.
$ whatis mkdirnmkdir (1) - make directoriesnmkdir (2) - create a directorynmkdir (1posix) - make directoriesn
Which
分類:文件管理;以來 The which command basically lets you locate a command - the file and the path of the file that gets executed. For example:
$ which daten/bin/daten
Who
分類:登錄信息 The who command shows who is logged on.
$ whonhimanshu :0 2017-03-03 09:39 (:0)nhimanshu pts/0 2017-03-03 09:41 (:0)nhimanshu pts/10 2017-03-03 14:51 (:0)nhimanshu pts/11 2017-03-03 15:41 (:0)n
Whereis
分類:文件管理;以來 The whereis command shows in output locations of the binary, source, and manual page files for a command.
$ whereis lsnls: /bin/ls /usr/share/man/man1/ls.1posix.gz /usr/share/man/man1/ls.1.gzn
Whoami
分類:登錄信息 The whoami command prints effective userid of the current user.
$ whoaminhimanshun
Xargs
分類:編程工具 The xargs command builds and executes command lines from standard input. In laymans terms, it reads items from stdin and executes a command passed to it as an argument. For example, heres how you can use xargs to find the word "Linux" in the files whose names are passed to it as input.
$ xargs grep "Linux"nfile1nfile2nfile3nfile1:Linux researchernfile2:A Linux tutorial websitenfile3:Linux is opensourcenMore...n
Yes
分類:交互;確認 The Yes command outputs a string repeatedly until killed.
$ yes [string]n
推薦:電子書《Linux Perf Master》
主題以Linux性能為核心,覆蓋評估診斷、監控、優化的工具和方法論,還補充了幾個參考案例。 內容來源於過去一段時間翻譯、發表過的文章,部分章節稍微調整了排版,希望有需要的讀者朋友們喜歡。 本書發表在GitBook平台: Linux Perf Master · GitBook 歡迎訂閱、下載、批評指正。
推薦閱讀:
※Cent OS6裝gcc-4.8和php-7真很tough嗎?
※2017 年 Linux 的五大痛點
※如何在最短時間內掌握Linux精髓?
※我的Linux手冊
※做linux kernel相關研究的如何創(zhuan)業(qian)?