TE
科技回声
首页24小时热榜最新最佳问答展示工作
GitHubTwitter
首页

科技回声

基于 Next.js 构建的科技新闻平台,提供全球科技新闻和讨论内容。

GitHubTwitter

首页

首页最新最佳问答展示工作

资源链接

HackerNews API原版 HackerNewsNext.js

© 2025 科技回声. 版权所有。

Command line tricks

125 点作者 r11t超过 15 年前

10 条评论

Periodic超过 15 年前
Regarding the SSH tricks:<p>If you change the port of SSH, change it to still use a port under 1024. On most Unix systems these are privileged ports that require root to open. This ensures that if there is a process listening there that it was opened by root and not some intruder hoping to get your password to sudo to higher privileges.<p>Regarding removing reserved space:<p>Be careful doing this on some file systems. Some filesystems may need to write more data to a journal or are set up with copy-on write and will not be able to delete files if you have no space left on the disk. Reserving a little extra space for this can be necessary. A little extra space also lets you have some space to work with if you need to temporarily create or move files before you can free up the space.<p>Also, if you're going to use a non-standard port, set up your .ssh/config!<p><pre><code> Host s hostname server port 666 </code></pre> That is a little more versatile than setting up an alias as it will work from any shell and you can specify any ssh daemon in there.<p>See `man ssh_config` for more info.
评论 #959015 未加载
评论 #959162 未加载
评论 #959380 未加载
mike463超过 15 年前
I loved these tricks. Here's a site dedicated to command line tricks:<p><a href="http://www.commandlinefu.com/commands/browse/sort-by-votes" rel="nofollow">http://www.commandlinefu.com/commands/browse/sort-by-votes</a><p>Being on a Mac, I didn't have the rename or prename command, but after a lot of searching, found it here:<p><a href="http://www.perlmonks.org/?node_id=303814" rel="nofollow">http://www.perlmonks.org/?node_id=303814</a><p>(beware the '+' signs at the beginning of each line)
onewland超过 15 年前
It's a pet peeve of mine to see<p><pre><code> cat [one-file] | less </code></pre> `less` takes a file as an argument.<p><pre><code> less [one-file] </code></pre> only requires you to run one program, and I/O tends to be really slow.
评论 #959586 未加载
评论 #959681 未加载
tudorachim超过 15 年前
tar -xvf infers the filetype from the file; obviating the need for the smart untarring script.<p>edit: Also, another useful thing is &#60;command&#62; | xargs -n1 -I{} &#60;stuff&#62;, which runs stuff once on every element of the output of command, replacing every occurrence of {} with the element. Then you can do something like "ls *.mp4 | xargs -n1 -I{} mv {} `basename {}`.mp3" .
评论 #958575 未加载
评论 #958531 未加载
评论 #959111 未加载
mcantor超过 15 年前
You can also expose a file in a one-shot webserver using netcat:<p><pre><code> cat somefile | nc -q1 -l -p8081</code></pre>
评论 #959366 未加载
JoachimSchipper超过 15 年前
The given syntax for prename is very odd, and e.g. <a href="http://man.he.net/man1/prename" rel="nofollow">http://man.he.net/man1/prename</a> has a much more sensible explanation of what the command does (i.e. <i>remove</i> _bak).<p>The script under "crash test dummy" is hackish and full of race conditions, but that's perhaps acceptable in that case.<p>Leaving webmin and X open to all local users (in the case of webmin, by choosing a bad password) is not a good idea.
tyrmored超过 15 年前
I love this sort of stuff. The first few "top ten" command line tricks articles I found back when I was enthralled with the power of the Bash shell have probably saved entire days of my life by now.
Jach超过 15 年前
I really liked this list, especially all the remote stuff. Though he did make an error: lower nice values get "more favorable scheduling". That's why +10 is default.
ciupicri超过 15 年前
Regarding "Editor redirection": why should we complicate ourselves with /etc/alternatives when the EDITOR and VISUAL environment variables can be used?
ciupicri超过 15 年前
The root account from RHEL and Fedora systems is configured by default with safe-delete command aliases.