Commands sorted by votes

Commands sorted by votes

Content #

Run the last command as root #

Useful when you forget to use sudo for a command. “!!” grabs the last run command.

sudo !!

Serve current directory tree at http://$hostname:8000/ #

python -m SimpleHTTPServer

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

^foo^bar

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.

ctrl-x e

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.

'ALT+.' or '<ESC> .'

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.

mount | column -t

Get your external IP address #

curl ifconfig.me

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.

echo "ls -l" | at midnight

Quick access to the ascii table. #

man ascii

type partial command, kill this command, check something you forgot, yank the command, resume typing. #

Example :

  • vim /etc/fstab
  • ## damn
  • <ctrl+u>
  • sudo <ctrl+y>
  • ## like a boss.

Example 2 :

  • sudo vim root/bin
  • ##uh… autocomplete doesn’t work…
  • <ctrl+u>
  • sudo ls /root/bin
  • ##ah! that’s the name of the file!
  • <ctrl+y> sudo vim root/bin
  • ##resume here!

Thanks readline!

<ctrl+u> [...] <ctrl+y>

Query Wikipedia via console over DNS #

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.

dig +short txt <keyword>.wp.dg.cx

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.

sshfs name@server:/path/to/folder /path/to/mount/point

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.

mount -t tmpfs tmpfs /mnt -o size=1024m

Download an entire website Compare a remote file with a local file SSH connection through host in the middle A very simple and useful stopwatch

Clear the terminal screen

ctrl-l

From #

https://www.commandlinefu.com/commands/browse/sort-by-votes