Linux and Bash One Liners
Command Line Fu – Top One Liners
- Thu, 17 Feb 2011 11:13:19 +0000: Put a console clock in top right corner - All commands sorted by votes
$ while sleep 1;do tput sc;tput cup 0 $(($(tput cols)-29));date;tput rc;done &
A nice way to use the console in full screen without forget the current time. you can too add other infos like cpu and mem use.Diff your entire server config at ScriptRock.com
- Fri, 23 Jul 2010 03:33:46 +0000: type partial command, kill this command, check something you forgot, yank the command, resume typing. - All commands sorted by votes
$ <ctrl+u> [...] <ctrl+y>
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!
Diff your entire server config at ScriptRock.com
- Wed, 21 Apr 2010 13:10:33 +0000: Get your external IP address - All commands sorted by votes
$ curl ifconfig.me
curl ifconfig.me/ip -> IP Adress curl ifconfig.me/host -> Remote Host curl ifconfig.me/ua ->User Agent curl ifconfig.me/port -> Port thonks to http://ifconfig.me/Diff your entire server config at ScriptRock.com
- Sat, 08 Aug 2009 21:22:19 +0000: 32 bits or 64 bits? - All commands sorted by votes
$ getconf LONG_BIT
Easy and direct way to find this out.Diff your entire server config at ScriptRock.com
- Fri, 31 Jul 2009 16:08:59 +0000: Query Wikipedia via console over DNS - All commands sorted by votes
$ dig +short txt <keyword>.wp.dg.cx
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.Diff your entire server config at ScriptRock.com
- Fri, 10 Apr 2009 12:22:34 +0000: Close shell keeping all subprocess running - All commands sorted by votes
$ disown -a && exit
Diff your entire server config at ScriptRock.com
- Tue, 31 Mar 2009 10:29:20 +0000: Quick access to the ascii table. - All commands sorted by votes
$ man ascii
Diff your entire server config at ScriptRock.com
- Thu, 26 Mar 2009 22:59:48 +0000: Watch Star Wars via telnet - All commands sorted by votes
$ telnet towel.blinkenlights.nl
Use Ctrl-] to stop it.Diff your entire server config at ScriptRock.com
- Fri, 20 Mar 2009 22:50:06 +0000: A very simple and useful stopwatch - All commands sorted by votes
$ time read (ctrl-d to stop)
time read -sn1 (s:silent, n:number of characters. Press any character to stop)Diff your entire server config at ScriptRock.com
- Fri, 20 Mar 2009 14:18:56 +0000: currently mounted filesystems in nice layout - All commands sorted by votes
$ mount | column -t
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.Diff your entire server config at ScriptRock.com
- Fri, 20 Mar 2009 11:36:04 +0000: Place the argument of the most recent command on the shell - All commands sorted by votes
$ 'ALT+.' or '<ESC> .'
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.Diff your entire server config at ScriptRock.com
- Wed, 18 Mar 2009 17:38:49 +0000: Clear the terminal screen - All commands sorted by votes
$ ctrl-l
Diff your entire server config at ScriptRock.com
- Wed, 11 Mar 2009 09:26:05 +0000: Rapidly invoke an editor to write a long, complex, or tricky command - All commands sorted by votes
$ ctrl-x e
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.Diff your entire server config at ScriptRock.com
- Tue, 03 Mar 2009 23:21:36 +0000: SSH connection through host in the middle - All commands sorted by votes
$ ssh -t reachable_host ssh unreachable_host
Unreachable_host is unavailable from local network, but it's available from reachable_host's network. This command creates a connection to unreachable_host through "hidden" connection to reachable_host.Diff your entire server config at ScriptRock.com
- Thu, 19 Feb 2009 14:33:46 +0000: Make 'less' behave like 'tail -f'. - All commands sorted by votes
$ less +F somelogfile
Using +F will put less in follow mode. This works similar to 'tail -f'. To stop scrolling, use the interrupt. Then you'll get the normal benefits of less (scroll, etc.). Pressing SHIFT-F will resume the 'tailling'.Diff your entire server config at ScriptRock.com
- Tue, 17 Feb 2009 22:53:07 +0000: Download an entire website - All commands sorted by votes
$ wget --random-wait -r -p -e robots=off -U mozilla http://www.example.com
-p parameter tells wget to include all files, including images. -e robots=off you don't want wget to obey by the robots.txt file -U mozilla as your browsers identity. --random-wait to let wget chose a random number of seconds to wait, avoid get into black list. Other Useful wget Parameters: --limit-rate=20k limits the rate at which it downloads files. -b continues wget after logging out. -o $HOME/wget_log.txt logs the outputDiff your entire server config at ScriptRock.com
- Sun, 08 Feb 2009 10:10:00 +0000: output your microphone to a remote computer's speaker - All commands sorted by votes
$ dd if=/dev/dsp | ssh -c arcfour -C username@host dd of=/dev/dsp
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.Diff your entire server config at ScriptRock.com
- Fri, 06 Feb 2009 00:33:08 +0000: Mount a temporary ram partition - All commands sorted by votes
$ mount -t tmpfs tmpfs /mnt -o size=1024m
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.Diff your entire server config at ScriptRock.com
- Thu, 05 Feb 2009 20:17:41 +0000: Mount folder/filesystem through SSH - All commands sorted by votes
$ sshfs name@server:/path/to/folder /path/to/mount/point
Install SSHFS from http://fuse.sourceforge.net/sshfs.html Will allow you to mount a folder security over a network.Diff your entire server config at ScriptRock.com
- Thu, 05 Feb 2009 18:33:23 +0000: Update twitter via curl - All commands sorted by votes
$ curl -u user:pass -d status="Tweeting from the shell" http://twitter.com/statuses/update.xml
Diff your entire server config at ScriptRock.com