https://www.howtoforge.com/linux-commands/
2017-04-27 RiboseYim 睿哥杂货铺
Author : Himanshu Arora
原文:https://www.howtoforge.com/linux-commands/
本文的特点是非常简洁,将繁杂的Linux命令行筛选出100条左右,非常适合入门学习。此外,将领域知识以“条目+示例”的方式来整理,类似编字典一样,在编辑的过程中可以促进学习者加深认识,也方便日后持续改进(增加注解、参考文献、索引等),是一种不错的学习方法。最后,整理这些命令行的时候,我体会到操作系统最重要的工作实际就是对文件的管理,创建、移动、查看、编辑、销毁、检索,都是围绕文件的操作,事实上也是实际工作中使用最频繁的需求。对开发者来说,以Linux命令行为模版,命名风格、人机交互、小而美的实现方式,促进自己在其它领域的应用、提高大有裨益。
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 don’t know where and how to start learning them, especially when you are beginner.
Adduser/Addgroup
The adduser and addgroup commands lets you add a new user and group to a system, respectively. Here’s an example for adduser:
1234567 |
$ sudo adduser testuserAdding user `testuser‘ ...Adding new group `testuser‘ (1003) ...Adding new user `testuser‘ (1003) with group `testuser‘ ...Creating home directory `/home/testuser‘ ...Copying files from `/etc/skel‘ ...Enter new UNIX password: |
Arch
The arch command is used to print the machine’s architecture. For example:
123 |
$ archi686Not sure what ‘i686‘ means? Head here. |
Cal/Ncal
The cal and ncal commands display a calendar in the output.
123456789101112131415161718 |
$ calMarch 2017Su Mo Tu We Th Fr Sa1 2 3 45 6 7 8 9 10 1112 13 14 15 16 17 1819 20 21 22 23 24 2526 27 28 29 30 31 $ ncalMarch 2017Su 5 12 19 26Mo 6 13 20 27Tu 7 14 21 28We 1 8 15 22 29Th 2 9 16 23 30Fr 3 10 17 24 31Sa 4 11 18 25 |
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.
12 |
$ cat test.txtHello...how are you? |
Cd
分类:文件管理;切换工作目录
The cd command is used to change user’s present working directory.
1 |
$ cd /home/himanshu/ |
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.
1 |
$ chgrp howtoforge test.txt |
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:
1 |
chmod +x helloWorld |
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:
1 |
chown root:root test.txt |
Cksum
分类:文件管理;查看文件属性
The cksum command prints the CRC checksum and byte count for the input file.
123 |
$ cksum test.txt3741370333 20 test.txtNot sure what checksum is? Head here. |
Clear
分类:人机交互;清屏
The clear command is used to clear the terminal screen.
1 |
$ clear |
Cmp
分类:文件管理;文件比对 byte-by-byte
The cmp command is used to perform byte-by-byte comparison of two files.
12 |
$ cmp file1 file2file1 file2 differ: byte 1, line 1 |
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, here’s what the ‘comm’ command produces in this case:
1 |
$ comm file1 file2 |
支持选项:
123 |
-1:不显示在第一个文件出现的内容;-2:不显示在第二个文件中出现的内容;-3:不显示同时在两个文件中都出现的内容。 |
Cp
分类:文件管理;文件复制
The cp command is used for copying files and directories.
1 |
$ cp test.txt /home//himanshu/Desktop/ |
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:
1 |
$ csplit file1 [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.
12 |
$ dateTue Feb 28 17:14:57 IST 2017 |
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.
1 |
dd if=/dev/sda of=/tmp/dev-sda-part.img |
Df
分类:文件管理;查看文件系统利用率
The df command displays the file system disk space usage in output.
123 |
$ df /dev/sda1Filesystem 1K-blocks Used Available Use% Mounted on/dev/sda1 74985616 48138832 23014620 68% / |
Diff
分类:文件管理;文件比对 line-by-line
The diff command lets you compare two files line by line.
1 |
$ diff file1 file2 |
Diff3
分类:文件管理;文件比对,三个文件
The diff3 command, as the name suggests, allows you to compare three files line by line.
1 |
diff3 file1 file2 file3 |
Dir
分类:文件管理;查看当前目录文件列表
The dir command lists directory contents. For example:
12 |
$ dirtest1 test2 test.7z test.zip |
Dirname
分类:文件管理;查看当前目录
The
dirname command strips last component from a file name/path. In
layman’s terms, you can think of it as a tool that, for example, removes
file name from the file’s absolute path.
12 |
$ dirname /home/himanshu/file1/home/himanshu |
Dmidecode
The dmidecode command prints a system’s DMI (aka SMBIOS) table contents in a human-readable format.
12345678910111213 |
$ sudo dmidecode# dmidecode 2.12SMBIOS 2.6 present.50 structures occupying 2056 bytes.Table at 0x000FCCA0.Handle 0x0000, DMI type 0, 24 bytesBIOS InformationVendor: American Megatrends Inc.Version: 080015Release Date: 08/22/2011......... |
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.
123456789 |
$ du /home/himanshu/Desktop/92 /home/himanshu/Desktop/Downloads/meld/meld/ui88 /home/himanshu/Desktop/Downloads/meld/meld/vc56 /home/himanshu/Desktop/Downloads/meld/meld/matchers12 /home/himanshu/Desktop/Downloads/meld/meld/__pycache__688 /home/himanshu/Desktop/Downloads/meld/meld16 /home/himanshu/Desktop/Downloads/meld/bin328 /home/himanshu/Desktop/Downloads/meld/data/ui52 /home/himanshu/Desktop/Downloads/meld/data/icons/svg |
Echo
The echo command displays whatever input text is given to it.
12 |
$ echo hello hihello hi |
Ed
分类:文件管理;编辑器
ed is a line-oriented text editor.
1 |
$ ed |
单行纯文本编辑器,它有命令模式(command mode)和输入模式(input mode)两种工作模式。
支持选项:
1234567 |
A:切换到输入模式,在文件的最后一行之后输入新的内容;C:切换到输入模式,用输入的内容替换掉最后一行的内容;i:切换到输入模式,在当前行之前加入一个新的空行来输入内容;d:用于删除最后一行文本内容;n:用于显示最后一行的行号和内容;w:<文件名>:一给定的文件名保存当前正在编辑的文件;q:退出ed编辑器。 |
Eject
分类:媒体管理;卸载
The eject command lets you eject removable media (typically, a CD ROM or floppy disk)
1 |
$ eject |
Env
分类:系统信息;查看用户环境变量
The env command not only displays the current environment, but also lets you edit it.
1 |
$ env |
Exit
分类:交互;退出
The exit command causes the shell to exit.
1 |
$ exit |
Expand
分类:文件管理;编辑器;将TAB符替换为空格符
The expand command converts tabs present in the input file(s) into spaces, and writes the file contents to standard output.
1 |
$ expand file1 |
Expr
分类:计算器;表达式
The expr command evaluates expressions. For example:
12 |
$ expr 1 + 23 |
Factor
分类:计算器;分解质因数
The factor command prints the prime factors of the input number.
12 |
$ factor 135135: 3 3 3 5 |
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 doesn’t 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 don’t want grep to interpret it as a wildcard character, use fgrep in the following way:
1 |
$ fgrep "." [file-name] |
Find
分类:文件管理;搜索;
The find command lets you search for files in a directory as well as its sub-directories.
123456789101112 |
$ find test*testtest1test2test.7ztest.ctest.txtMore examples for the Linux Find command: * 14 Practical Examples of Linux Find Command for Beginners* Searching For Files And Folders With The find Command* Finding Files On The Command Line |
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.
1 |
$ fmt file1 |
Fold
The fold command wraps each input line to fit in specified width.
12345 |
$ fold -w 10Hi my name is himanshu AroraHi my nameis himanshu Arora |
Free
分类:系统信息;性能监测;查看内存利用情况。详细介绍 >>>more>>>
The free command displays the amount of free and used memory in the system.
12345 |
$ free total used free shared buffers cachedMem: 1800032 1355288 444744 79440 9068 216236-/+ buffers/cache: 1129984 670048Swap: 1832956 995076 837880 |
Linus Torvalds: The mind behind Linux
Grep
分类:文件管理;搜索;
The grep command searches for a specified pattern in a file (or files) and displays in output lines containing that pattern.
123456 |
$ grep Hello test.txtHello...how are you?More tutorials and examples for the Linux Grep command: * How to use grep to search for strings in files on the shell* How to perform pattern search in files using Grep |
Groups
分类:文件管理;搜索;
The groups command displays the name of groups a user is part of.
12 |
$ groups himanshuhimanshu : himanshu adm cdrom sudo dip plugdev lpadmin sambashare |
Gzip
分类:文件管理;压缩
The gzip command compresses the input file, replacing the file itself with one having a .gz extension.
1 |
$ gzip file1 |
Gunzip
分类:文件管理;解压缩
Files compressed with gzip command can be restored to their original form using the gunzip command.
1 |
$ gunzip file1.gz |
Head
分类:文件管理;查看文件
The head command displays the first 10 lines of the file to standard output
1234567891011 |
$ head CHANGELOG.txtBEEBEEP (Secure Lan Messanger)BeeBEEP2.0.4- Some GUI improvements (new icons, file sharing tree load faster)- Always Beep on new message arrived (option)- Favorite users (right click on user and enable star button) is on top of the list- improved group usability- Offline users can be removed from list (right click on an offline user in list and then remove)- Clear all files shared (option)- Load minimized at startup (option) |
Hostname
分类:系统信息;host name
The hostname command not only displays the system’s host name, but lets them set it as well.
12 |
$ hostnamehimanshu-desktop |
Id
分类:系统信息;用户信息
The id command prints user and group information for the current user or specified username.
12 |
$ id himanshuuid=1000(himanshu) gid=1000(himanshu) groups=1000(himanshu),4(adm),24(cdrom),27(sudo),30(dip),46(plugdev),108(lpadmin),124(sambashare) |
Kill
分类:进程管理;
The kill command, as the name suggests, helps user kill a process by sending the TERM signal to it.
1 |
$ kill [process-id] |
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.
1 |
$ killall nautilus |
Last
分类:安全管理;查看最近登录用户
The last command shows listing of last logged in users.
1234567 |
$ lasthimanshu pts/11 :0 Thu Mar 2 09:46 still logged inhimanshu pts/1 :0 Thu Mar 2 09:46 still logged inhimanshu :0 :0 Thu Mar 2 09:42 still logged inreboot system boot 4.4.0-62-generic Thu Mar 2 09:41 - 10:36 (00:54)himanshu pts/14 :0 Wed Mar 1 15:17 - 15:52 (00:35)himanshu pts/13 :0 Wed Mar 1 14:40 - down (08:06) |
Ldd
分类:软件包管理;查看一个共享库的依赖
The ldd command displays in output dependencies of a shared library.
1234 |
$ ldd /lib/i386-linux-gnu/libcrypt-2.19.solinux-gate.so.1 => (0xb77df000)libc.so.6 => /lib/i386-linux-gnu/libc.so.6 (0xb75da000)/lib/ld-linux.so.2 (0x80088000) |
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’:
1 |
$ ln test.txt lnk |
Locate
分类:文件管理;搜索
The locate command helps user find a file by name.
1 |
$ locate [file-name] |
Logname
分类:登录信息;
The logname command prints the user-name of the current user.
12 |
$ lognamehimanshu |
Ls
分类:文件管理;查看文件列表
The ls command lists contents of a directory in output.
1234 |
$ ls progresscapture.png hlist.o progress progress.h sizes.chlist.c LICENSE progress.1 progress.o sizes.hhlist.h Makefile progress.c README.md sizes.o |
Lshw
分类:系统信息;查看硬件信息
The lshw command extracts and displays detailed information on the hardware configuration of the machine.
12345678910111213 |
$ sudo lshw[sudo] password for himanshu:himanshu-desktopdescription: Desktop Computerproduct: To Be Filled By O.E.M. (To Be Filled By O.E.M.)vendor: To Be Filled By O.E.M.version: To Be Filled By O.E.M.serial: To Be Filled By O.E.M.width: 32 bitscapabilities: smbios-2.6 dmi-2.6 smp-1.4 smp........ |
Lscpu
分类:系统信息;查看硬件信息-CPU
The
lscpu command displays in output system’s CPU architecture information
(such as number of CPUs, threads, cores, sockets, and more).
12345678910111213141516171819 |
$ lscpuArchitecture: i686CPU op-mode(s): 32-bit, 64-bitByte Order: Little EndianCPU(s): 1On-line CPU(s) list: 0Thread(s) per core: 1Core(s) per socket: 1Socket(s): 1Vendor ID: AuthenticAMDCPU family: 16Model: 6Stepping: 3CPU MHz: 2800.234BogoMIPS: 5600.46Virtualization: AMD-VL1d cache: 64KL1i cache: 64KL2 cache: 1024K |
Man
分类:帮助;
man lets you access reference manual for commands, programs/utilities, as well as functions.
1 |
$ man ls |
Md5sum
分类:计算器;md5
The md5sum command lets you print or check MD5 (128-bit) checksums.
12 |
$ md5sum test.txtac34b1f34803a6691ff8b732bb97fbba test.txt |
Mkdir
分类:文件管理;创建目录
The mkdir command lets you create directories.
1 |
$ mkdir [dir-name] |
Mkfifo
分类:进程管理
The mkfifo command is used to create named pipes.
1 |
$ mkfifo [pipe-name] |
More
分类:交互
more is basically a filter for paging through text one screenful at a time.
1 |
$ cat [large-file] | more |
Mv
分类:文件管理;移动
The mv command lets you either move a file from one directory to another, or rename it.
1 |
$ mv test.txt /home/himanshu/Desktop/ |
Nice
分类:进程管理;指定进程优先级
The nice command lets you run a program with modified scheduling priority.
123 |
$ nice -n[niceness-value] [program] $ nice -n15 vim |
Nl
分类:文件管理;输出行号
The nl command writes contents of a file to output, and prepends each line with line number.
1234 |
$ nl file11 Hi2 How are you3 Bye |
Nm
分类:文件管理
The nm command is used to display symbols from object files.
12345678910111213141516171819 |
$ nm test0804a020 B __bss_start0804841d T compare0804a020 b completed.65910804a018 D __data_start0804a018 W data_start08048360 t deregister_tm_clones080483d0 t __do_global_dtors_aux08049f0c t __do_global_dtors_aux_fini_array_entry0804a01c D __dso_handle08049f14 d _DYNAMIC0804a020 D _edata0804a024 B _end080484e4 T _fini080484f8 R _fp_hw080483f0 t frame_dummy......... |
Nproc
分类:进程管理
The nproc command displays the number of processing units available to the current process.
12 |
$ nproc1 |
Od
分类:文件管理
The od command lets you dump files in octal as well as some other formats.
12345678910 |
$ od /bin/ls0000000 042577 043114 000401 000001 000000 000000 000000 0000000000020 000002 000003 000001 000000 140101 004004 000064 0000000000040 122104 000001 000000 000000 000064 000040 000011 0000500000060 000034 000033 000006 000000 000064 000000 100064 0040040000100 100064 004004 000440 000000 000440 000000 000005 0000000000120 000004 000000 000003 000000 000524 000000 100524 004004......... |
Passwd
分类:用户权限管理
The passwd command is used for changing passwords for user accounts.
123 |
$ passwd himanshuChanging password for himanshu.(current) UNIX password: |
Paste
分类:交互
The paste command lets you merge lines of files. For example, if ‘file1’ contains the following lines:
123456789101112131415 |
$ cat file1HiMy name isHimanshuAroraIAmaLinux researcherand tutorialwriterThen the following ‘paste‘ command will join all the lines of the file: $ paste -s file1Hi My name is Himanshu Arora I Am a Linux researcher and tutorial writer |
Pidof
分类:进程管理
The pidof command gives you the process ID of a running program/process.
12 |
$ pidof nautilus2714 |
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.
12345 |
$ ping howtoforge.comPING howtoforge.com (104.24.0.68) 56(84) bytes of data.64 bytes from 104.24.0.68: icmp_seq=1 ttl=58 time=47.3 ms64 bytes from 104.24.0.68: icmp_seq=2 ttl=58 time=51.9 ms64 bytes from 104.24.0.68: icmp_seq=3 ttl=58 time=57.4 ms |
Ps
分类:进程管理
The ps command displays information (in the form of a snapshot) about the currently active processes.
1234 |
$ psPID TTY TIME CMD4537 pts/1 00:00:00 bash20592 pts/1 00:00:00 ps |
Pstree
分类:进程管理
The pstree command produces information about running processes in the form of a tree.
12345678 |
$ pstreeinit???ModemManager???2*[{ModemManager}]??NetworkManager???dhclient? ??dnsmasq? ??3*[{NetworkManager}]??accounts-daemon???2*[{accounts-daemon}]??acpid??atop |
Pwd
The pwd command displays the name of current/working directory.
12 |
$ pwd/home/himanshu |
Rm
分类:文件管理
The rm command lets you remove files and/or directories.
1 |
$ rm [file-name] |
Rmdir
分类:文件管理
The rmdir command allows you delete empty directories.
1 |
$ rmdir [dir-name] |
Scp
分类:文件管理
The scp command lets you securely copy files between systems on a network.
1 |
$ scp [name-and-path-of-file-to-transfer] [user]@[host]:[dest-path] |
Sdiff
分类:文件管理;文本比对 side-by-side
The sdiff command lets you perform a side-by-side merge of differences between two files.
1 |
$ sdiff file1 file2 |
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).
12 |
$ echo "Welcome to Howtoforge" | sed -e ‘s/Howtoforge/HowtoForge/g‘Welcome to HowtoForge |
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 here’s
the output this command produces:
123456 |
$ seq 1 2 1013579 |
Sha1sum
分类:计算器
The sha1sum command is used to print or check SHA1 (160-bit) checksums.
12 |
$ sha1sum test.txt955e48dfc9256866b3e5138fcea5ea0406105e68 test.txt |
Shutdown
The shutdown command lets user shut the system in a safe way.
1 |
$ shutdown |
Size
分类:文件管理
The size command lists the section sizes as well as the total size for an object or archive file.
123 |
$ size testtext data bss dec hex filename1204 280 4 1488 5d0 test |
Sleep
The sleep command lets user specify delay for a specified amount of time. You can use it to delay an operation like:
1 |
$ sleep 10; shutdown |
Sort
分类:文件管理
The sort command lets you sort lines of text files. For example, if ‘file2’ contains the following names:
123456789101112 |
$ cat file2zeuskyansamadamThen running the sort command produces the following output: $ sort file2adamkyansamzeus |
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.
1 |
$ ssh [user-name]@[remote-server] |
Stat
分类:文件管理
The stat command displays status related to a file or a file-system.
123456789 |
$ stat test.txtFile: ‘test.txt’Size: 20 Blocks: 8 IO Block: 4096 regular fileDevice: 801h/2049d Inode: 284762 Links: 2Access: (0664/-rw-rw-r--) Uid: ( 0/ root) Gid: ( 0/ root)Access: 2017-03-03 12:41:27.791206947 +0530Modify: 2017-02-28 16:05:15.952472926 +0530Change: 2017-03-02 11:10:00.028548636 +0530Birth: - |
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:
1234567891011121314151617 |
$ strings test/lib/ld-linux.so.2libc.so.6_IO_stdin_usedputs__libc_start_main__gmon_start__GLIBC_2.0PTRhQVhI[^_]EQUAL;*2$"GCC: (Ubuntu 4.8.4-2ubuntu1~14.04.3) 4.8.4............ |
Su
分类:用户权限管理
The su command lets you change user-identity. Mostly, this command is used to become root or superuser.
1 |
$ su [user-name] |
Sudo
分类:用户权限管理
The sudo command lets a permitted user run a command as another user (usually root or superuser).
1 |
$ sudo [command] |
Sum
分类:文件管理
The sum command prints checksum and block counts for each input file.
12 |
$ sum readme.txt45252 5 |
Tac
分类:文件管理
The tac command prints input files in reverse. Functionality-wise, it does the reverse of what the cat command does.
12345678910 |
$ cat file2zeuskyansamadam$ tac file2adamsamkyanzeus |
Tail
分类:文件管理
The tail command displays in output the last 10 lines of a file.
1 |
$ tail [file-name] |
Talk
分类:网络管理
The talk command lets users talk with each other.
1 |
$ talk [user-name] |
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:
123 |
$ tar -cf archive.tar foo bar More... |
Tee
分类:文件管理
The tee command reads from standard input and write to standard output as well as files.
1234 |
$ uname | tee file2Linux$ cat file2Linux |
Test
分类:计算器
The test command checks file types and compare values. For example, you can use it in the following way:
12 |
$ test 7 -gt 5 && echo "true"true |
Time
分类:性能监测
The time command is used to summarize system resource usage of a program. For example:
12345678910 |
$ time ping google.comPING google.com (216.58.220.206) 56(84) bytes of data.64 bytes from del01s08-in-f14.1e100.net (216.58.220.206): icmp_seq=1 ttl=52 time=44.2 ms^C--- google.com ping statistics ---1 packets transmitted, 1 received, 0% packet loss, time 0msrtt min/avg/max/mdev = 44.288/44.288/44.288/0.000 msreal 0m0.676suser 0m0.000ssys 0m0.000s |
Top
分类:系统信息;性能监测;性能概览。详细介绍 >>>more>>>
The top command gives a dynamic real-time view of a running system (in terms of its processes). For example:
1 |
$ top |
Linux Performance Analysis in 60,000 Milliseconds
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.
1 |
$ touch [file-name] |
Tr
分类:文件管理
The
tr command can be used to translate/squeeze/delete characters. For
example, here’s how you can use it to convert lowercase characters to
uppercase:
12 |
$ echo ‘howtoforge‘ | tr "[:lower:]" "[:upper:]"HOWTOFORGE |
Tty
分类:资源管理
The tty command prints the filename of the terminal connected to standard input.
12 |
$ tty/dev/pts/10 |
Uname
分类:用户权限管理
The uname command prints certain system information.
12 |
$ uname -aLinux 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/Linux |
Uniq
分类:文件管理;待补充信息
The Uniq command is used to report or omit repeated lines. For example, if ‘file2’ contains the following data:
1234567891011 |
$ cat file2Welcome to HowtoForgeWelcome to HowtoForgeA Linux tutorial websiteThanksThen you can use the uniq command to omit the repeated line. $ uniq file2Welcome to HowtoForgeA Linux tutorial websiteThanks |
Unexpand
分类:文件管理;待补充信息
The unexpand command converts spaces present in the input file(s) into tabs, and writes the file contents to standard output.
1 |
$ unexpand file1 |
Uptime
分类:系统信息;性能监测;查看负载。详细介绍 >>>more>>>
The uptime command tells how long the system has been running.
12 |
$ uptime15:59:59 up 6:20, 4 users, load average: 0.81, 0.92, 0.82 |
Linux Performance Analysis in 60,000 Milliseconds
Users
分类:用户权限管理;待补充信息
The users command displays in output the usernames of users currently logged in to the current host.
12 |
$ usershimanshu himanshu himanshu himanshu |
Vdir
分类:文件管理;待补充信息
The vdir command lists information about contents of a directory (current directory by default).
12345 |
$ vdirtotal 1088-rw-rw-r-- 1 himanshu himanshu 4850 May 20 2015 test_backup.pdf-rw-rw-r-- 1 himanshu himanshu 2082 May 28 2015 test-filled.pdf-rw-rw-r-- 1 himanshu himanshu 7101 May 28 2015 test.pdf |
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.
1 |
$ vim [file-name] |
W
分类:性能监测
The w command displays information about the users currently on the machine, and their processes.
1234567 |
$ w16:18:07 up 6:39, 4 users, load average: 0.07, 0.32, 0.53USER TTY FROM [email protected] IDLE JCPU PCPU WHAThimanshu :0 :0 09:39 ?xdm? 1:08m 0.25s init --userhimanshu pts/0 :0 09:41 6:36m 0.84s 7.84s gnome-terminalhimanshu pts/10 :0 14:51 0.00s 0.16s 0.00s whimanshu pts/11 :0 15:41 35:19 0.05s 0.05s bash |
Wall
分类:通讯;待补充信息
The wall command lets you write and send a message to other users that are currently logged in.
1 |
$ wall [your-message] |
Watch
分类:性能监测
The
watch command can be used to monitor a program’s output. It runs the
program repeatedly, displaying its output and errors. For example:
1 |
$ watch date |
Wc
分类:文件管理;待补充信息
The wc command prints newline, word, and byte counts for a file.
12 |
$ wc test.txt0 3 20 test.txt |
Whatis
分类:帮助
The whatis command displays single-line manual page descriptions.
1234 |
$ whatis mkdirmkdir (1) - make directoriesmkdir (2) - create a directorymkdir (1posix) - make directories |
Which
分类:文件管理;以来
The which command basically lets you locate a command - the file and the path of the file that gets executed. For example:
12 |
$ which date/bin/date |
Who
分类:登录信息
The who command shows who is logged on.
12345 |
$ whohimanshu :0 2017-03-03 09:39 (:0)himanshu pts/0 2017-03-03 09:41 (:0)himanshu pts/10 2017-03-03 14:51 (:0)himanshu pts/11 2017-03-03 15:41 (:0) |
Whereis
分类:文件管理;以来
The whereis command shows in output locations of the binary, source, and manual page files for a command.
12 |
$ whereis lsls: /bin/ls /usr/share/man/man1/ls.1posix.gz /usr/share/man/man1/ls.1.gz |
Whoami
分类:登录信息
The whoami command prints effective userid of the current user.
12 |
$ whoamihimanshu |
Xargs
分类:编程工具
The
xargs command builds and executes command lines from standard input. In
layman’s terms, it reads items from stdin and executes a command passed
to it as an argument. For example, here’s how you can use xargs to find
the word “Linux” in the files whose names are passed to it as input.
12345678 |
$ xargs grep "Linux"file1file2file3file1:Linux researcherfile2:A Linux tutorial websitefile3:Linux is opensourceMore... |