11 cool Linux terminal command Daquan

Today to share with a decade of Linux summed up 11 cool Linux terminal command Guinness, today through this article I will show you a series of Linux commands , tools and techniques, hoping to help to you.


11 cool Linux terminal command Daquan 11 a cool Linux terminal command Daquan

 


1. Command Line Daily shortcuts

The following shortcuts are useful, can greatly enhance your productivity:

CTRL + U content before shear cursor 

CTRL + K content at the end of the line to cut cursor 

CTRL + Y Paste 

CTRL + E to move the cursor to the end of the line 

CTRL + A to move the cursor to the beginning 

ALT + F hop down a space 

ALT + B jumping back on a space 

ALT + Backspace to delete a word before the 

CTRL + W after cutting the cursor one word 

Shift + Insert to paste text into the terminal

To make it easier to understand the above point of view the following command line.

sudo apt-get intall programname

As you can see, the command is misspelled need for proper implementation of the "intall" replaced by "install".

Now imagine being the end of the cursor line, we have many ways to install and replace the word she returned it.

I twice ALT + B so that the position of the cursor will be in the following (herein refer to the position of the cursor).

sudo apt-get install programname
现在你可以按两下方向键并将“s”插入到install中去了。

如果你想将浏览器中的文本复制到终端,可以使用快捷键"shift + insert"。

2. SUDO !!

sudo 这个命令权限委派,在自己平时练习的环境可能遇到的少,但是在企业环境中经常遇到这个命令。因为如果你不知道的话,那每次你在输入长串命令后看到“permission denied”后一定会痛苦不堪。 如何使用sudo !!?很简单。试想你刚输入了如下命令:

apt-get install ranger

一定会出现“Permission denied”,除非你已经登录了足够高权限的账户。

sudo !!就会用sudo的形式运行上一条命令。所以上一条命令就变成了这样:

sudo apt-get install ranger

3.暂停并在后台运行命令

CTRL + Z       \\暂停应用程序

fg                       \\重新将程序唤到前台

使用实例:

假设你在使用"sudo nano abc.txt"编辑到一半时你意识到你需要马上在终端输入些命令,但是nano在前台运行让你不能输入。你可能觉得唯一的方法就是保存文件,退出nano,运行命令以后在重新打开nano。

其实你只要按CTRL + Z,前台的命令就会暂停,画面就切回到命令行了。然后你就能运行你想要运行命令,等命令运行完后在终端窗口输入“fg”就可以回到先前暂停的任务。

4.使用nohup在登出SSH会话后仍运行命令

如果你用ssh登录别的机器时,nohup命令真的非常有用。那么怎么使用nohup呢?

举个例子,因为测试的需要,我用树莓派来下载发行版。一般我总是用SSH从笔记本电脑连接到树莓派。如果我在不用nohup的情况下使用树莓派下载大型文件,那我就必须等待到下载完成后,才能登出ssh会话关掉笔记本。可如果是这样,那我为什么要使用树莓派下文件呢?

使用nohup的方法也很简单,只需如下例中在nohup后输入要执行的命令即可:

nohup wget http://mirror.is.co.za/mirrors/linuxmint.com/iso//stable/17.1/linuxmint-17.1-cinnamon-64bit.iso &

5.在特定的时间运行Linux命令

‘nohup’命令在你用SSH连接到服务器,并在上面保持执行SSH登出前任务的时候十分有用。
想一下如果你需要在特定的时间执行相同的命令,这种情况该怎么办呢?
命令‘at’就能妥善解决这一情况。以下是‘at’使用示例。

#at 10:38 PM Friat
at>cowsay 'hello'
at> CTRL + D

上面的命令能在周五下午10时38分运行程序cowsay。

使用的语法就是‘at’后追加日期时间。当at>提示符出现后就可以输入你想在那个时间运行的命令了。CTRL + D返回终端。
还有许多日期和时间的格式,都需要你好好翻一翻‘at’的man手册来找到更多的使用方式。

6. Man手册

Man手册会为你列出命令和参数的使用大纲,教你如何使用她们。Man手册看起来沉闷呆板。不过这不代表你不能做些什么来使她们变得漂亮些:
export PAGER=most   你需要安装‘most’;她会使你的你的man手册的色彩更加绚丽。
你可以用以下命令给man手册设定指定的行长:
export MANWIDTH=80     最后,如果你有一个可用的浏览器,你可以使用-H在默认浏览器中打开任意的man页。
man -H     注意啦,以上的命令只有在你将默认的浏览器设置到环境变量$BROWSER中了之后才效果哟。

7.使用htop查看和管理进程

你用哪个命令找出电脑上正在运行的进程的呢?我敢打赌是‘ps’并在其后加不同的参数来得到你所想要的不同输出。

安装‘htop’吧!绝对让你相见恨晚。

htop在终端中将进程以列表的方式呈现,有点类似于Windows中的任务管理器。你可以使用功能键的组合来切换排列的方式和展示出来的项。你也可以在htop中直接杀死进程。

在终端中简单的输入htop即可运行。

8.使用ranger浏览文件系统

如果说htop是命令行进程控制的好帮手,那么ranger就是命令行浏览文件系统的好帮手。

你在用之前可能需要先安装,不过一旦安装了以后就可以在命令行输入以下命令启动她:

ranger在命令行窗口中ranger和一些别的文件管理器很像,但是相比上下结构布局,她是左右结构的,这意味着你按左方向键你将前进到上一个文件夹,而右方向键则会切换到下一个。

在使用前ranger的man手册还是值得一读的,这样你就可以用快捷键操作ranger了。

9.取消关机

无论是在命令行还是图形用户界面关机后,才发现自己不是真的想要关机。

shutdown -c       、pkill shutdown

10.杀死挂起进程的简单方法  -xkill

When you find an application running in the dead of unknown causes. You can use the 'ps -ef' kill or be found using the 'htop' command after the process.

There is a faster, easier command is called xkill.

Simply enter the following command in the terminal and click on the application you want to kill in the window.

xkill kill the process, if the system is stuck up how it? Simple command:

Press and hold the keyboard 'alt' and 'sysrq' button, then slowly enter the following keys:
REISUB
so do not press the power button on your computer can restart.

11. Download Youtube Videos

In general most of us like to watch Youtube video, will play streaming media via Youtube favorite player. Share Youtube video below to watch offline, where you need to install youtube-dl.
You can click on the link to get the video url to share in Youtubu video page. Simply copy and paste the link in the command line is ok ...

youtube-dl url-to-video


Guess you like

Origin blog.51cto.com/14414295/2482955