TranslateProject/published/201401/8 Interesting Linux Tips And Tricks!.md
wxy 1ee2fc7cbe renamed: 10 Lesser Known Useful Linux Commands- Part V.md -> 201401/10 Lesser Known Useful Linux Commands- Part V.md
renamed:    10 Useful Chaining Operators in Linux with Practical Examples.md -> 201401/10 Useful Chaining Operators in Linux with Practical Examples.md
	renamed:    10 basic examples of linux netstat command.md -> 201401/10 basic examples of linux netstat command.md
	renamed:    12 Advanced Commands For Linux Server Admins!.md -> 201401/12 Advanced Commands For Linux Server Admins!.md
	renamed:    14 New Linux Distros That Were Introduced In 2013.md -> 201401/14 New Linux Distros That Were Introduced In 2013.md
	renamed:    15 Basic MySQL Interview Questions for Database Administrators.md -> 201401/15 Basic MySQL Interview Questions for Database Administrators.md
	renamed:    "2013\357\274\232The Golden Year for Linux \342\200\223 10 Biggest Linux Achievements.md" -> "201401/2013\357\274\232The Golden Year for Linux \342\200\223 10 Biggest Linux Achievements.md"
	renamed:    2014--The year of the Linux car.md -> 201401/2014--The year of the Linux car.md
	renamed:    5 Things To Love And Hate About Ubuntu 13.10.md -> 201401/5 Things To Love And Hate About Ubuntu 13.10.md
	renamed:    8 Interesting Linux Tips And Tricks!.md -> 201401/8 Interesting Linux Tips And Tricks!.md
	renamed:    CentOS 6.5 desktop installation guide with screenshots.md -> 201401/CentOS 6.5 desktop installation guide with screenshots.md
	renamed:    "Command Line Basics \342\200\223 watch.md" -> "201401/Command Line Basics \342\200\223 watch.md"
	renamed:    Configure Your Browser To Use Tor On Ubuntu or Debian or Linux Mint.md -> 201401/Configure Your Browser To Use Tor On Ubuntu or Debian or Linux Mint.md
	renamed:    Daily Ubuntu Tips - Mount Partitions In Ubuntu From Your Desktop GUI.md -> 201401/Daily Ubuntu Tips - Mount Partitions In Ubuntu From Your Desktop GUI.md
	renamed:    "Daily Ubuntu Tips \342\200\223 Do Nothing When Laptop Lid Is Closed.md" -> "201401/Daily Ubuntu Tips \342\200\223 Do Nothing When Laptop Lid Is Closed.md"
	renamed:    "Daily Ubuntu Tips \342\200\224 Install VMware Workstation In Ubuntu.md" -> "201401/Daily Ubuntu Tips \342\200\224 Install VMware Workstation In Ubuntu.md"
	renamed:    "Daily Ubuntu Tips \342\200\224 Windows Disk Management Equivalent In Ubuntu.md" -> "201401/Daily Ubuntu Tips \342\200\224 Windows Disk Management Equivalent In Ubuntu.md"
	renamed:    "Gnu--toward the post-scarcity world \342\200\223 the Free Software Column.md" -> "201401/Gnu--toward the post-scarcity world \342\200\223 the Free Software Column.md"
	renamed:    How to Dual Boot Ubuntu and Windows Properly.md -> 201401/How to Dual Boot Ubuntu and Windows Properly.md
	renamed:    "How to Install and Configure UFW \342\200\223 An Un-complicated FireWall in Debian or Ubuntu.md" -> "201401/How to Install and Configure UFW \342\200\223 An Un-complicated FireWall in Debian or Ubuntu.md"
	renamed:    How to Upgrade to GNOME 3.10 in Ubuntu 13.10.md -> 201401/How to Upgrade to GNOME 3.10 in Ubuntu 13.10.md
	renamed:    How to install and configure Nagios on Linux.md -> 201401/How to install and configure Nagios on Linux.md
	renamed:    How to set password policy on Linux.md -> 201401/How to set password policy on Linux.md
	renamed:    How to stitch photos together on Linux.md -> 201401/How to stitch photos together on Linux.md
	renamed:    How to upgrade MySQL server on Debian or Ubuntu.md -> 201401/How to upgrade MySQL server on Debian or Ubuntu.md
	renamed:    Juju ice-cream icon design.md -> 201401/Juju ice-cream icon design.md
	renamed:    Linus Torvalds Releases Last Linux Kernel 3.13 RC for 2013.md -> 201401/Linus Torvalds Releases Last Linux Kernel 3.13 RC for 2013.md
	renamed:    Linus Torvalds Says All Contributor License Agreements Are Broken.md -> 201401/Linus Torvalds Says All Contributor License Agreements Are Broken.md
	renamed:    Linux free Command - Display Free and used Memory in the System.md -> 201401/Linux free Command - Display Free and used Memory in the System.md
	renamed:    Linux id Command - Print user ID and group ID information.md -> 201401/Linux id Command - Print user ID and group ID information.md
	renamed:    Linux is Everywhere. We show you exactly where.md -> 201401/Linux is Everywhere. We show you exactly where.md
	renamed:    Linux lsusb Command to Print information about USB on System.md -> 201401/Linux lsusb Command to Print information about USB on System.md
	renamed:    Linux vmstat Command - Tool to Report Virtual Memory Statistics.md -> 201401/Linux vmstat Command - Tool to Report Virtual Memory Statistics.md
	renamed:    "Linux who command \342\200\223 Displays who is on the system.md" -> "201401/Linux who command \342\200\223 Displays who is on the system.md"
	renamed:    "Move Dropbox\342\200\231s Folder To An External Drive In Ubuntu.md" -> "201401/Move Dropbox\342\200\231s Folder To An External Drive In Ubuntu.md"
	renamed:    New Ubuntu 14.04 Icons Are Drop-Dead Gorgeous, Might Not Arrive in Desktop Version.md -> 201401/New Ubuntu 14.04 Icons Are Drop-Dead Gorgeous, Might Not Arrive in Desktop Version.md
	renamed:    Our Top 10 Linux Applications of 2013.md -> 201401/Our Top 10 Linux Applications of 2013.md
	renamed:    Setup your personal Cloud server in minutes using ownCloud On RHEL, CentOS, Scientific Linux 6.5.md -> 201401/Setup your personal Cloud server in minutes using ownCloud On RHEL, CentOS, Scientific Linux 6.5.md
	renamed:    Software May Be Eating The World, But Open Source Software Is Eating Itself.md -> 201401/Software May Be Eating The World, But Open Source Software Is Eating Itself.md
	renamed:    The Debian Administrator's Handbook updated for Debian 7 Wheezy published and freely available for download.md -> 201401/The Debian Administrator's Handbook updated for Debian 7 Wheezy published and freely available for download.md
	renamed:    The Fedora Project Will No Longer Name Its Linux Distributions.md -> 201401/The Fedora Project Will No Longer Name Its Linux Distributions.md
	renamed:    The Genius Of Linux Is Community, Not Technology.md -> 201401/The Genius Of Linux Is Community, Not Technology.md
	renamed:    Top 10 Linux Distros For Hackers!.md -> 201401/Top 10 Linux Distros For Hackers!.md
	renamed:    Tunnel SSH Connections Over SSL Using 'Stunnel' On Debian 7  Ubuntu 13.10.md -> 201401/Tunnel SSH Connections Over SSL Using 'Stunnel' On Debian 7  Ubuntu 13.10.md
	renamed:    Ubuntu Stores Your Wi-Fi Passwords By Default!.md -> 201401/Ubuntu Stores Your Wi-Fi Passwords By Default!.md
	renamed:    Ubuntu Will Reach True Convergence Before Microsoft, Says Shuttleworth.md -> 201401/Ubuntu Will Reach True Convergence Before Microsoft, Says Shuttleworth.md
	renamed:    Understanding Linux cd Command with Examples.md -> 201401/Understanding Linux cd Command with Examples.md
	renamed:    look--Linux Command To Verify Spellings And Display Lines Beginning With A String.md -> 201401/look--Linux Command To Verify Spellings And Display Lines Beginning With A String.md
2014-02-03 20:55:51 +08:00

5.5 KiB
Raw Blame History

8个有趣的Linux提示与技巧

我们时不时给你带来关于Linux的提示与技巧。和这个系列保持一致这里有8个我们从读者收到最有趣的提示和技巧。我们希望你喜欢它。请继续读下去。。。

以它们的大小列出文件

如果你想要一个基于它们大小排序的文件列表,你可以使用下面的命令。

它会以递减顺序排列文件。

# ls -l | grep ^- | sort -nr -k 5 | more

如果你想要递归地做相同的事,你可以使用下面的第二个命令。

# ls -lR | grep ^- | sort -nr -k 5 | more

—Sumedh Gajbhiye, sumedh.gajbhiye1985@gmail.com

重置奇怪的终端

如果感觉你的bash终端错误地显示垃圾的提示字符信息并无论你输入任何命令都显示非ASCII字符-下面的命令可以让事情回到正轨。

在终端盲打输入(译注:因为你其实看不到你输入的这些字符的正确显示,不过尽管输入好了!)下面的命令并按回车:

# reset

如果那个不能修复这个问题,试一下下面的:

# stty sane

—Sudheer Divakaran, cdsudheer@gmail.com

记录并回放终端会话

下面是一个简单的贴士来记录并回放终端回放。它通过使用命令script和scriptreplay。

这在使用终端制作教程时非常方便。

要开始记录你的终端会话,使用下面的命令:

$ script -t 2> timing.log -a output.session

接着输入:

$ ls
$touch test
.....

$ exit

这里script命令取两个文件作为参数timing.log(它记录了每个命令执行的时间信息)和output.session(存储了命令的输出)。

现在要回访记录的会话使用下面所示的scriptplay。

$ scriptreplay timing.log output.session

timing.log和output.session可以被任何想要在自己的终端上重放会话的人使用。

—Abhishek Singh, abhishekkumarsingh.cse@gmail.com

使用shell脚本生成随机数

有时当你想要用shell脚本编程时可能需要生成一个随机数来用于脚本。

这里是获得一个3位随机数的代码。

var=$(dd if=/dev/urandom count=1 2> /dev/null | cksum | cut -f1 -d” “ | cut -c 3-5);

这回存储随机生成的数字在名为var的变量中。

—Arpan Chavda, 09bce006@nirmauni.ac.in

以root用户运行Linux上的软件

作为一名root用户为了让某些不能在root身份运行的软件运行译注典型的是google chrome你需要在软件的二进制文件中改变geteuid调用为getppid。

这个技术在操作系统中非常有用比如backtrack这里的大多数安装工作都以root用户完成。

比如:为了以root用户运行Google Chrome使用下面的命令:

# hexedit /opt/google/chome/chrome

接着按下Ctrl+S并在16进制转储文件中搜寻geteuid字符串。用字符串getppid代替。按下Ctrl+X来保存并退出编辑器。

现在浏览器就可以以root用户运行了。

# google-chrome

—Mayank Bhanderi, mbhanderi24@gmail.com

用gzip压缩优化你的站点

压缩是一种简单、有效的方法来节约带宽和加速你的站点。在压缩的帮助下多数站点的主页面会从100KB变成10KB。

为了在Apache Web服务器中启用这个特性你需要在httpd.conf中包含deflate_module并且在Apache配置文件中加入下面的行 (/etc/httpd/conf/httpd.conf)来压缩text、html、 javascript、 css 和 xml 文件:

AddOutputFilterByType DEFLATE text/plain
AddOutputFilterByType DEFLATE text/html
AddOutputFilterByType DEFLATE text/xml
AddOutputFilterByType DEFLATE text/css
AddOutputFilterByType DEFLATE application/xml
AddOutputFilterByType DEFLATE application/xhtml+xml
AddOutputFilterByType DEFLATE application/rss+xml
AddOutputFilterByType DEFLATE application/javascript
AddOutputFilterByType DEFLATE application/x-javascript

—Munish Kumar, munishtotech@gmail.com

在登陆时检查服务器负载信息

这里有一个贴士来在你登陆服务器的时候检查服务器平均负载。创建一个sload.sh的文本文件内容如下:

#!/bin/bash
gh=$(uptime | awk -F, {print $3})
echo -e “Server$gh\n”

现在,为了在登陆时检查服务器负载,通过/root/.bashrc调用sload.sh脚本。

记住如下设置脚本权限:

# chmod 755 /root/sload.sh

要调用sload.sh脚本如下在/root/.bashrc后追加

/root/sload.sh

或者你还可以这样追加sload.sh的内容到.bashrc中。

$echo “/root/sload.sh” >> /root/.bashrc

当你完成上面的步骤后,你可以登出并再次登陆来查看服务器负载。

—Ranjith Kumar T, ranjith.stc@gmail.com

在特定时间开始你的任务

你可以使用下面的命令来在特定时间调度你的作业:

# at 2015

> >vlc /music/rockstar.mp3

这个命令会在2015小时后使用vlc播放器播放rockstar.mp3。你可以在at命令后跟上-l选项来检查挂起的作业

# at -l

更多at命令的信息可以在man页找到。

—Manas Pradhan, acmeofmanas@gmail.com


via: http://www.efytimes.com/e1/fullnews.asp?edid=127250

译者:geekpi 校对:wxy

本文由 LCTT 原创翻译,Linux中国 荣誉推出