一些常用的shell

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
  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值