1. > file.txt 命令

这个命令会刷新文件的内容而不需删除然后创建相同的文件。当我们需要反复输出,或者在相同的文件上记录日志时,这个命令就非常有用。

我有一个有很多文字的‘test.txt’文件在我的‘Desktop‘上。

avi@localhost:~/Desktop$ cat test.txt

Linux

GNU

Debian

Fedora

kali

ubuntu

git

Linus

Torvalds

avi@localhost:~/Desktop$ > test.txt

avi@localhost:~/Desktop$ cat test.txt

注意:再说一次,这个命令可能很危险!永远不要尝试刷新系统文件或者某篇日志文件的内容。如果你这么做了,你可能会遭遇严重的问题!

2. at 命令

‘at‘命令与cron 命令相似也可用于安排一个任务或者在某个特定时刻执行命令。

avi@localhost:~/Desktop$ echo "ls -l > /dev/pts/0" | at 14:012

avi@localhost:~/Desktop$ echo "ls -l > /dev/pts/0" | at 2:12 PM

示例输出

-rw-r--r-- 1 avi  avi      220492 Nov  1 13:49 Screenshot-1.png

-rw-r--r-- 1 root root        358 Oct 17 10:11 sources.list

-rw-r--r-- 1 avi  avi  4695982080 Oct 10 20:29 squeeze.iso

..

..

-rw-r--r-- 1 avi  avi       90624 Nov  5 12:59 Untitled 1.doc

-rw-r--r-- 1 avi  avi       96206 Nov  5 12:56 Untitled 1.odt

-rw-r--r-- 1 avi  avi        9405 Nov 12 23:22 Untitled.png

注意:echo “ls -l”的意思是,将这串命令(这里是 ls -l)输出在标准终端上。你可以用你需要或者选择的命令替代‘ls -l‘。

> :重定向输出

/dev/pts/0: 这是输出设备和/或文件,输出到指定的地方,这里输出在终端(/dev/pts/0)。

就我而言,此时我的tty在/dev/pts/0。你可以用tty命令检查你的tty。

avi@localhost:~/Desktop$ tty

/dev/pts/0

注意: ‘at‘会在系统时间匹配到特定时间时会尽快执行。

3. du -h –max-depth=1 命令

下面的命令以人类可读的形式输出当前目录的子目录的大小。

avi@localhost:/home/avi/Desktop# du -h --max-depth=1

38M     ./test

1.1G    ./shivji

42M     ./drupal

6.9G    ./101MSDCF

16G .

注意:上面的命令在检查系统使用率是非常有用。

3. expr 命令

‘expr‘不是那么鲜为人知的命令。这个命令在终端中计算简单的算数时非常有用。

avi@localhost:/home/avi/Desktop# expr 2 + 3

5

avi@localhost:/home/avi/Desktop# expr 6 – 3

3

avi@localhost:/home/avi/Desktop# expr 12 / 3

4

avi@localhost:/home/avi/Desktop# expr 2 \* 9

18

4 . look 命令

在终端上从英文字典上查单词以防混淆。比如说,我记不清了是该拼成carrier还是carieer。

avi@localhost:/home/avi/Documents# look car

Cara

Cara's

...

carps

carpus

carpus's

carrel

carrel's

carrels

carriage

carriage's

carriages

carriageway

carriageway's

carried

carrier

carrier's

carriers

carries

...

caryatids

上面的命令会显示字典上所有以’car’开头的单词。我得到了我想找的。

5. yes 命令

另外一个命令在通常基础上并不会经常使用,但是在脚本语言和系统管理时非常有用。

这个命令会持续地输出给定的字符串,直到由你的中断命令打断。

avi@localhost:~/Desktop$ yes "Tecmint is one of the best site dedicated to Linux, how to"

Tecmint is one of the best site dedicated to Linux, how to

Tecmint is one of the best site dedicated to Linux, how to

Tecmint is one of the best site dedicated to Linux, how to

Tecmint is one of the best site dedicated to Linux, how to

...

Tecmint is one of the best site dedicated to Linux, how to

Tecmint is one of the best site dedicated to Linux, how to

Tecmint is one of the best site dedicated to Linux, how to

6. factor 命令

factor实际是一个源于数学的命令。这个命令会输出所有给定数字的因数。

avi@localhost:~/Desktop$ factor 22

22: 2 11

avi@localhost:~/Desktop$ factor 21

21: 3 7

avi@localhost:~/Desktop$ factor 11

11: 11

7. ping -i 60 -a IP_address

我们都用ping命令检测服务器是否连通。我通常ping google,来检测我是否连接到了因特网。

当你等待或者持续盯着你的终端等待命令的回应或者等待服务器的连接时,有时是很气人的。

一旦服务器连通就有一个声音如何(译注:下面命令是等60秒PING一次)?

avi@localhost:~/Desktop$ ping -i 60 -a www.google.com

PING www.google.com (74.125.200.103) 56(84) bytes of data.

64 bytes from www.google.com (74.125.200.103): icmp_req=1 ttl=44 time=105 ms

64 bytes from 74.125.200.103: icmp_req=2 ttl=44 time=281 ms

注意,当你发现命令不会返回声音时。请确保你的系统不是静音的,声音已经在‘sound preferences(声音选项)‘ 中启用并确保勾选了‘Enable window and window sound‘。

8. tac 命令

这个命令很有趣,他会以倒序输出文本文件的内容。也就是从最后一行到第一行。

在home目录下,我的Documents目录下有一个35.txt文件。用cat 命令检查内容。

avi@localhost:~/Documents$ cat 35.txt

示例输出

  1. Linux is built with certain powerful tools, which are unavailable in windows.

  2. One of such important tool is Shell Scripting. Windows however comes with such a tool but as usual it is much weak as compared to it’s Linux Counterpart.

  3. Shell scripting/programming makes it possible to execute command(s), piped to get desired output in order to automate day-to-day usages.

现在用tac命令反转文件内容(译注:当然,我们知道cat反转过来就是tac)。

avi@localhost:~/Documents$ tac 35.txt

示例输出

  1. Shell scripting/programming makes it possible to execute command(s), piped to get desired output in order to automate day-to-day usages.

  2. One of such important tool is Shell Scripting. Windows however comes with such a tool but as usual it is much weak as compared to it’s Linux Counterpart.

  3. Linux is built with certain powerful tools, which are unavailable in windows.

鲜为人知的Linux命令(3)相关推荐

  1. 十个鲜为人知的Linux命令 - Part 5

    在前四篇 "鲜为人知的Linux命令" 系列文章受到高度赞赏之后,我们将为广大读者呈上此系列的最后一篇文章,虽然是最后一篇,但是其重要性毫不逊于前几篇. 前几篇文章的地址如下: 十 ...

  2. 10 个鲜为人知的 Linux 命令

    Linux命令行吸引了大多数Linux爱好者.一个正常的Linux用户一般掌握大约50-60个命令来处理每日的任务.Linux命令和它们的转换对于Linux用户.Shell脚本程序员和管理员来说是最有 ...

  3. Linux中part指令,10 个鲜为人知的 Linux 命令 - Part 2

    继续上篇文章<11 个很有用但鲜有人知的 Linux 命令>.在本文中,我们将关注其他几个不为人知的Linux命令,有些在管理桌面和服务器方面被证明是非常有用的. 12. 命令 你在终端上 ...

  4. linux命令part,技术|十个鲜为人知的 Linux 命令-Part 3

    我们继续"10个鲜为人知Linux命令系列"的第三部分.或许你已经知道了这些命令,那你无疑是一个有经验而喜欢探索的Linux用户. 22. ^foo^bar 命令 在一个实例中运行 ...

  5. 十个鲜为人知的 Linux 命令 - Part 3

    我们继续"10个鲜为人知Linux命令系列"的第三部分.或许你已经知道了这些命令,那你无疑是一个有经验而喜欢探索的Linux用户. 22. ^foo^bar 命令 在一个实例中运行 ...

  6. 鲜为人知的Linux命令续

    12. <空格> 命令 你在终端上键入的每个命令都会记录到history,也能用history命令重新调用. 如何骗过history 命令呢?呵呵,你可以轻而易举地做到.在终端,只需要在键 ...

  7. 鲜为人知的Linux命令

    Linux命令行吸引了大多数Linux爱好者.一个正常的Linux用户一般掌握大约50-60个命令来处理每日的任务.Linux命令和它们的转换对于Linux用户.Shell脚本程序员和管理员来说是最有 ...

  8. 每天一个linux命令博客nano,11 个鲜为人知的 Linux 命令(1)

    英文:Tecmint,编译:Linux中国 linux.cn/article-2258-1.html 如有好文章 Linux命令行吸引了大多数Linux爱好者.一个正常的Linux用户一般掌握大约50 ...

  9. 运维总监不会告诉你这些有趣但鲜为人知的 Linux 命令

    在这篇文章中和 Carla Schroder 一起探索 Linux 中的一些鲜为人知的强大工具. 本文是一篇关于一些有趣但鲜为人知的工具 termsaver.pv 和 calendar 的文章. te ...

最新文章

  1. VUE初长成【部分小记】
  2. (原) ora-12705 cannot access nls data files or invalid environment specified
  3. Flowable 数据库表结构 ACT_HI_PROCINST
  4. 客服机器人代码_电脑问题不会解决?小白智能客服来帮你!
  5. 腾讯十年经验总结分享!软件测试经典面试题!你招架的住吗?
  6. Leetcode 347.前K个高频元素
  7. java 认证考试题,2017年Java认证考试试题
  8. C语言——实现简单的猜数字游戏
  9. 阿里技术专家:从程序员到技术总监,我的十五年IT路!
  10. 由三点画圆到未来日记:失控中的位置隐私
  11. iOS Programming - Disallow Alphabetic Characters
  12. windows系统重装(绝对干净)、备份还原、引导修复步骤
  13. 第五节:通信之WLAN(MAC地址)
  14. php 插件推荐,Typecho实用插件推荐(一)
  15. 京东物流一体化供应链建设实践
  16. #93 高精度除低精度
  17. 计算机网络工程的话术,话术工具电脑版
  18. 旋转电机设计_尤哈·皮罗内 PDF完整版下载 网盘分享
  19. 新版掩日免杀——搭配CS使用测试
  20. Portraying ride-hailing mobility using multi-day trip order data

热门文章

  1. alm服务java_ALM TFS/VSTS工具 的Java集成
  2. 峨眉派的创始人真的是郭襄吗?
  3. 文本分类从入门到精通—代码展示
  4. java解析多层json,手把手教你怎么解析多层嵌套的JSON数据(使用JSONModel)
  5. python归一化函数_用numpy实现FFT归一化
  6. 祝愿大家在新的一年里,万事大吉,送上我设计的可爱暴富小老虎微信红包封面,祝愿大家新的一年财运旺,事业旺,健康旺。
  7. eovs实训报告总结心得_实训心得10篇完美版
  8. 计算机网络安全-----Internet安全
  9. 我爱赚钱吧:SEO的好处有哪些?
  10. 从Python到TensorFlow,差点把我 六年的电脑砸了,哈哈哈哈(详细安装入门步骤)