`
haoningabc
  • 浏览: 1482875 次
  • 性别: Icon_minigender_1
  • 来自: 北京
社区版块
存档分类
最新评论

一些常用的shell

ssh 
阅读更多
sudo !!
2009-01-26 10:26:48
User: root
801
Up
Down
Run the last command as root
Useful when you forget to use sudo for a command. "!!" grabs the last run command.
Comments (30) | Add to favourites | Report as malicious | Submit alternative | Report as a duplicate
python -m SimpleHTTPServer
2009-02-05 11:57:43
User: pixelbeat
Functions: python
608
Up
Down
Serve current directory tree at http://$HOSTNAME:8000/
Comments (21) | Add to favourites | Report as malicious | Submit alternative | Report as a duplicate
:w !sudo tee %
2009-02-25 16:27:24
User: skinp
Functions: tee
Tags: vim sudo tee
573
Up
Down
Save a file you edited in vim without the needed permissions
I often forget to sudo before editing a file I don't have write permissions on. When you come to save that file and get the infamous "E212: Can't open file for writing", just issue that vim command in order to save the file without the need to save it to a temp file and then copy it back again.
Comments (26) | Add to favourites | Report as malicious | Submit alternative | Report as a duplicate
cd -
2009-02-04 22:41:21
User: systemj
Functions: cd
481
Up
Down
change to the previous working directory
Comments (13) | Add to favourites | Report as malicious | Submit alternative | Report as a duplicate
^foo^bar
2009-01-26 13:25:37
User: root
375
Up
Down
Runs previous command but replacing
Really useful for when you have a typo in a previous command. Also, arguments default to empty so if you accidentally run:
echo "no typozs"
you can correct it with
^z
Comments (5) | Add to favourites | Report as malicious | Submit alternative | Report as a duplicate
mtr google.com
2009-02-21 07:53:32
User: fryfrog
354
Up
Down
mtr, better than traceroute and ping combined
mtr combines the functionality of the traceroute and ping programs in a single network diagnostic tool.
As mtr starts, it investigates the network connection between the host mtr runs on and HOSTNAME. by sending packets with purposly low TTLs. It continues to send packets with low TTL, noting the response time of the intervening routers. This allows mtr to print the response percentage and response times of the internet route to HOSTNAME. A sudden increase in packetloss or response time is often an indication of a bad (or simply over‐loaded) link.
Show sample output | Comments (11) | Add to favourites | Report as malicious | Submit alternative | Report as a duplicate
cp filename{,.bak}
2009-02-05 17:12:03
User: elofland
Functions: cp
351
Up
Down
quickly backup or copy a file with bash
Comments (13) | Add to favourites | Report as malicious | Submit alternative | Report as a duplicate
ctrl-x e
2009-03-11 09:26:05
User: fool
323
Up
Down
Rapidly invoke an editor to write a long, complex, or tricky command
Next time you are using your shell, try typing ctrl-x e (that is holding control key press x and then e). The shell will take what you've written on the command line thus far and paste it into the editor specified by $EDITOR. Then you can edit at leisure using all the powerful macros and commands of vi, emacs, nano, or whatever.
Show sample output | Comments (14) | Add to favourites | Report as malicious | Submit alternative | Report as a duplicate
<space>command
2009-03-17 16:25:29
User: eaZy
278
Up
Down
Execute a command without saving it in the history
Prepending one or more spaces to your command won't be saved in history.
Useful for pr0n or passwords on the commandline.
Tested on BASH.
Show sample output | Comments (11) | Add to favourites | Report as malicious | Submit alternative | Report as a duplicate
$ssh-copy-id user@host
2009-02-07 04:58:11
User: senthil
266
Up
Down
Copy ssh keys to user@host to enable password-less ssh logins.
To generate the keys use the command ssh-keygen
Comments (14) | Add to favourites | Report as malicious | Submit alternative | Report as a duplicate
> file.txt
2009-01-26 10:22:31
User: root
259
Up
Down
Empty a file
For when you want to flush all content from a file without removing it (hat-tip to Marc Kilgus).
Comments (16) | Add to favourites | Report as malicious | Submit alternative | Report as a duplicate
reset
2009-01-28 22:22:01
User: root
Functions: reset
213
Up
Down
Salvage a borked terminal
If you bork your terminal by sending binary data to STDOUT or similar, you can get your terminal back using this command rather than killing and restarting the session. Note that you often won't be able to see the characters as you type them.
Show sample output | Comments (11) | Add to favourites | Report as malicious | Submit alternative | Report as a duplicate
ffmpeg -f x11grab -s wxga -r 25 -i :0.0 -sameq /tmp/out.mpg
2009-02-05 17:23:43
User: wwest4
204
Up
Down
Capture video of a linux desktop
Comments (14) | Add to favourites | Report as malicious | Submit alternative | Report as a duplicate
'ALT+.' or '<ESC> .'
2009-03-20 11:36:04
User: atoponce
181
Up
Down
Place the argument of the most recent command on the shell
When typing out long arguments, such as:
cp file.txt /var/www/wp-content/uploads/2009/03/
You can put that argument on your command line by holding down the ALT key and pressing the period '.' or by pressing <ESC> then the period '.'. For example:
cd 'ALT+.'
would put '/var/www/wp-content/uploads/2009/03/ as my argument. Keeping pressing 'ALT+.' to cycle through arguments of your commands starting from most recent to oldest. This can save a ton of typing.
Comments (9) | Add to favourites | Report as malicious | Submit alternative | Report as a duplicate
mount | column -t
2009-03-20 14:18:56
User: thechile
Functions: column mount
Tags: Filesystem mount column
180
Up
Down
currently mounted filesystems in nice layout
Particularly useful if you're mounting different drives, using the following command will allow you to see all the filesystems currently mounted on your computer and their respective specs with the added benefit of nice formatting.
Show sample output | Comments (5) | Add to favourites | Report as malicious | Submit alternative | Report as a duplicate
ssh -N -L2001:localhost:80 somemachine
2009-02-05 09:13:23
User: mischamolhoek
Functions: ssh
170
Up
Down
start a tunnel from some machine's port 80 to your local post 2001
now you can acces the website by going to http://localhost:2001/
Comments (8) | Add to favourites | Report as malicious | Submit alternative | Report as a duplicate
echo "ls -l" | at midnight
2009-01-25 21:07:42
User: root
Functions: at echo
166
Up
Down
Execute a command at a given time
This is an alternative to cron which allows a one-off task to be scheduled for a certain time.
Comments (11) | Add to favourites | Report as malicious | Submit alternative | Report as a duplicate
dig +short txt <keyword>.wp.dg.cx
2009-07-31 16:08:59
User: drizzt
Functions: dig
Tags: dig txt record wikipedia dns
163
Up
Down
Query Wikipedia via console over DNS
Query Wikipedia by issuing a DNS query for a TXT record. The TXT record will also include a short URL to the complete corresponding Wikipedia entry.You can also write a little shell script like:
$ cat wikisole.sh
#!/bin/sh
dig +short txt ${1}.wp.dg.cx
and run it like
./wikisole.sh unix
were your first option ($1) will be used as search term.
Show sample output | Comments (23) | Add to favourites | Report as malicious | Submit alternative | Report as a duplicate
netstat -tlnp
2009-02-15 14:20:25
User: fulat2k
Functions: netstat
156
Up
Down
Lists all listening ports together with the PID of the associated process
The PID will only be printed if you're holding a root equivalent ID.
Comments (8) | Add to favourites | Report as malicious | Submit alternative | Report as a duplicate
dd if=/dev/dsp | ssh -c arcfour -C username@host dd of=/dev/dsp
2009-02-08 10:10:00
User: morpheus
Functions: dd ssh
150
Up
Down
output your microphone to a remote computer's speaker
This will output the sound from your microphone port to the ssh target computer's speaker port. The sound quality is very bad, so you will hear a lot of hissing.
Comments (16) | Add to favourites | Report as malicious | Submit alternative | Report as a duplicate
curl -u user:pass -d status="Tweeting from the shell" http://twitter.com/statuses/update.xml
2009-02-05 18:33:23
User: adamm9
149
Up
Down
Update twitter via curl
Comments (19) | Add to favourites | Report as malicious | Submit alternative | Report as a duplicate
mount -t tmpfs tmpfs /mnt -o size=1024m
2009-02-06 00:33:08
User: ajrobinson
Functions: mount
143
Up
Down
Mount a temporary ram partition
Makes a partition in ram which is useful if you need a temporary working space as read/write access is fast.
Be aware that anything saved in this partition will be gone after your computer is turned off.
Comments (6) | Add to favourites | Report as malicious | Submit alternative | Report as a duplicate
!!:gs/foo/bar
2009-02-11 10:20:15
User: Tronks
142
Up
Down
Runs previous command replacing foo by bar every time that foo appears
Very useful for rerunning a long command changing some arguments globally.
As opposed to ^foo^bar, which only replaces the first occurrence of foo, this one changes every occurrence.
Comments (6) | Add to favourites | Report as malicious | Submit alternative | Report as a duplicate
sshfs name@server:/path/to/folder /path/to/mount/point
2009-02-05 20:17:41
User: ihasn
141
Up
Down
Mount folder/filesystem through SSH
Install SSHFS from http://fuse.sourceforge.net/sshfs.html
Will allow you to mount a folder security over a network.
Show sample output | Comments (6) | Add to favourites | Report as malicious | Submit alternative | Report as a duplicate
man ascii
2009-03-31 10:29:20
User: ntheother
Functions: man
139
Up
Down
Quick access to the ascii table.
Comments (2) | Add to favourites | Report as malicious | Submit alternative | Report as a duplicate
分享到:
评论

相关推荐

    Unix&Liunx 常用的shell命令

    以下是一些常用Shell命令的详细说明: 1. `cat`:用于查看和组合文件内容。`-b`选项会在非空行上显示行号,`-E`会在每行末尾显示'$',`-T`会将制表符转换为'^I'。 2. `chmod`:改变文件或目录的访问权限。`who`...

    shell常用命令

    以下是针对文件和目录操作的一些常用shell命令及其使用说明。 一、文件目录类命令 1. 查看联机帮助信息 使用man命令可以查看系统中任何命令的帮助信息,例如: # man ls 2. 列出当前目录或指定目录的文件名和目录...

    常用shell命令常用shell命令

    以下是一些常用Shell命令的详细说明: 1. **basename**: `basename` 命令用于从路径中提取文件的基本名称,忽略任何路径分隔符和扩展名。例如,`basename /home/user/documents/report.txt` 将返回 "report"。 2...

    一些常用的shell命令

    本文将详细介绍一些常用的 shell 命令,包括系统资源监测命令 sar、正则表达式、文件处理命令 awk 等。 系统资源监测命令 sar sar 命令是用来收集系统统计信息的标准 UNIX 命令,sar 命令的选项很多,可以提供队列...

    Linux Shell编程&常用shell命令

    下面将详细介绍Shell编程的基础知识以及一些常用的Shell命令。 **一、Shell脚本基础** 1. **Shebang**:脚本开头的`#!/bin/bash`声明了使用哪个Shell解析脚本,这里使用的是Bash Shell,是目前最常用的Shell。 2. *...

    Hadoop 分布式文件系统 shell命令1

    下面是 HDFS 的一些常用 shell 命令: 1. hadoop fs -mkdir &lt;dir&gt;:创建一个新的目录。 2. hadoop fs -rm &lt;file&gt;:删除一个文件。 3. hadoop fs -cp &lt;src&gt; &lt;dst&gt;:复制文件或目录。 4. hadoop fs -mv &lt;src&gt; &lt;dst&gt;:...

    linux常用shell脚本

    以上是对"linux常用shell脚本"中涉及的一些关键知识点的概述。通过学习和实践这些内容,运维人员能够更高效地管理系统,自动化日常任务。在实际工作中,还可以结合具体的脚本及配置文件进一步了解和掌握各种实用技巧...

    常用shell脚本源码

    这个压缩包文件“常用shell脚本源码”显然包含了若干个可以用于日常任务的预编写脚本,这些脚本可以帮助用户自动化重复性工作,提高效率。下面我们将深入探讨shell脚本的一些核心知识点。 1. **基础语法**: - ...

    Linux常用shell命令大全.pdf

    ### Linux常用Shell命令详解 #### 一、基本命令 **1. 重启与关机** - **立即重启:** - `shutdown -r now` - `reboot` - **立即关机:** - `shutdown -h now` - `poweroff` - **定时重启(2分钟后):** -...

    常用SHELL命令列表

    在开发ARM Linux时,掌握一系列常用的shell命令对于提高开发效率和维护系统的便捷性有着至关重要的作用。本文档将列举一系列在ARM Linux开发中常用的shell命令,以便开发者能快速查找并使用它们来执行各种任务。 ...

    一些常用的shell脚本

    shell脚本

    linux操作系统中的一些简单命令,比较常用

    以下将详细介绍Linux操作系统中的一些常用Shell命令以及它们的使用方法和技巧。 首先,Shell命令基础部分讲述了Shell的作用和命令的基本格式。Shell作为Linux操作系统的用户界面,允许用户通过输入命令来控制计算机...

    监控Oracle数据库的常用shell脚本

    Unix 命令是 DBA 的基本工具,以下是一些常用的 Unix 命令: * ps -- 显示进程 * grep -- 搜索文件中的某种文本模式 * mailx -- 读取或者发送 mail * cat -- 连接文件或者显示它们 * cut -- 选择显示的列 * awk --...

    efi shell常用工具

    4. **脚本和批处理文件**:一些预先编写好的Shell脚本,可以自动执行一系列命令,提高工作效率。 5. **文档**:可能包含关于如何使用这些工具的说明或参考指南,这对于初学者尤其有用。 使用EFI Shell工具包时,...

    常用shell命令linux

    以下是一些常用的Bash命令: 1. **ls**:列出目录内容。 2. **cd**:切换当前工作目录。 3. **mv**:移动或重命名文件和目录。 4. **cp**:复制文件和目录。 5. **rm**:删除文件和目录(谨慎使用,删除操作不可逆)...

    Shell常用命令整理

    以上就是一些常用的Shell命令介绍。熟练掌握这些命令,能够显著提高我们在Linux环境下的工作效率。此外,对于命令中的选项(如 `-l`, `-a` 等),建议查阅官方文档或使用 `man` 命令获取更详细的说明。

    常用shell脚本总结

    本篇文章将深入探讨shell脚本的基础知识,包括基本语法、变量、条件语句、循环结构、函数以及一些实用的内置命令。 首先,让我们了解什么是Shell。Shell是操作系统提供的一种命令解释器,用户可以通过Shell与系统...

    hadoop2安装和常用shell命令

    ### Hadoop2安装与常用Shell命令详解 #### Hadoop2安装步骤 在开始Hadoop2的安装之前,首先需要确保所有节点的操作系统版本为CentOS/Red Hat Linux 6.4_x64,并且每台服务器都已完成基本的系统配置。 ##### 系统...

    linux-一些常用的shell脚本用于webserver的服务安装线上代码发布推送等

    总结,"linux-一些常用的shell脚本用于webserver的服务安装线上代码发布推送等"提供了宝贵的资源,不仅能够帮助我们自动化日常运维任务,提高工作效率,还能作为学习和提升Linux技能的有效途径。通过深入理解和应用...

Global site tag (gtag.js) - Google Analytics