Hide

What's this?

commandlinefu.com is the place to record those command-line gems that you return to again and again.

Delete that bloated snippets file you've been using and share your personal repository with the world. That way others can gain from your CLI wisdom and you from theirs too. All commands can be commented on, discussed and voted up or down.


If you have a new feature suggestion or find a bug, please get in touch via http://commandlinefu.uservoice.com/

Get involved!

You can sign-in using OpenID credentials, or register a traditional username and password.

First-time OpenID users will be automatically assigned a username which can be changed after signing in.

Hide

Stay in the loop…

Follow the Tweets.

Every new command is wrapped in a tweet and posted to Twitter. Following the stream is a great way of staying abreast of the latest commands. For the more discerning, there are Twitter accounts for commands that get a minimum of 3 and 10 votes - that way only the great commands get tweeted.

» http://twitter.com/commandlinefu
» http://twitter.com/commandlinefu3
» http://twitter.com/commandlinefu10

Subscribe to the feeds.

Use your favourite RSS aggregator to stay in touch with the latest commands. There are feeds mirroring the 3 Twitter streams as well as for virtually every other subset (users, tags, functions,…):

Subscribe to the feed for:

Hide

News

2011-03-12 - Confoo 2011 presentation
Slides are available from the commandlinefu presentation at Confoo 2011: http://presentations.codeinthehole.com/confoo2011/
2011-01-04 - Moderation now required for new commands
To try and put and end to the spamming, new commands require moderation before they will appear on the site.
2010-12-27 - Apologies for not banning the trolls sooner
Have been away from the interwebs over Christmas. Will be more vigilant henceforth.
2010-09-24 - OAuth and pagination problems fixed
Apologies for the delay in getting Twitter's OAuth supported. Annoying pagination gremlin also fixed.
Hide

Tags

Hide

Functions

Commands tagged console from sorted by
Terminal - Commands tagged console - 16 results
cat /etc/named.conf | grep -Po '(?<=(named/)).*(?=\.db)'
2014-10-25 20:16:17
User: KonKar
Functions: cat grep
0

Allows you to have a list of the domains on the server.

bashrc-reload() { builtin unalias -a; builtin unset -f $(builtin declare -F | sed 's/^.*declare[[:blank:]]\+-f[[:blank:]]\+//'); . ~/.bashrc; }
2014-03-02 14:24:18
User: Xk2c
Functions: sed unalias unset
2

Simply sourcing .bashrc does not function correctly when you edit it and change an alias for a function or the other way round with the *same name*.

I therefor use this function. Prior to re-sourcing .bashrc it unsets all aliases and functions.

socat unix-connect:/tmp/socket stdio,echo=0,raw
2012-12-19 07:58:09
User: mhs
1

Create a serial console with "socket (named pipe)" of "/tmp/socket", "from:server, to:virtual machine" in vmware player, etc.. gui. Run the above command after you have booted the guest OS (which should also be configured for serial console).

newgrp -
2012-10-01 10:23:56
User: dendoes
Functions: newgrp
2

Changes your group to the default group, has the same effect as sourcing your profile/rc file (in any shell) or logging out and back in again.

. ~/.bashrc
source ~/.bashrc
2012-10-01 08:30:19
User: knoppix5
4

Any changes to BASH shell made in .bashrc will be active in the current terminal window from the moment you execute this command, ie. aliases, prompt settings etc. No need to restart terminal.

(In BASH 'source' simile to 'eval' lets you generally execute any bunch of commands stacked in a text file).

echo 'hardstatus alwayslastline " %d-%m-%y %c:%s | %w"' >> $HOME/.screenrc; screen
2011-02-16 08:04:56
User: olorin
Functions: echo
4

Configures screen to always display the clock in the last line (has to be configured only once).

After that you not only have got the possibility to detach sessions and run them in background, but also have got a nice clock permanently on your screen.

yes 'clear;printf "`date`\n" | figlet -f starwars | boxes;sleep 1' | sh
2011-02-16 03:58:19
User: lkjoel
Functions: printf sleep yes
0

This is a different version from my original command: Console clock -- Beautiful (http://www.commandlinefu.com/commands/view/7902/console-clock-beautiful )

This one uses Boxes and Figlet.

To install the dependencies on Ubuntu, type in:

sudo apt-get install boxes figlet

To install the dependencies on Debian, type in:

aptitude install boxes figlet
yes 'clear;printf "\n\n`date`\n" | figlet -f starwars;sleep 1' | sh
2011-02-16 03:05:52
User: lkjoel
Functions: printf sleep yes
1

This will show a console clock with Figlet.

This is with the Star Wars font.

Change the -f option to anything else.

Notice: You need Figlet installed for this to work.

To install Figlet on Ubuntu, type in:

sudo apt-get install figlet

To install Figlet on Debian, type in:

aptitude install figlet
yes 'clear;printf "\n\n\n\n\t\t\t`date`\n";sleep 1' | sh
2011-02-16 02:57:16
User: lkjoel
Functions: printf sleep yes
2

This command will automatically clear the old clock time, and show the new clock time.

It will also slightly format it.

while :; do ping -W1 -c1 -n 8.8.8.8 > /dev/null || tput bel > /dev/console; sleep 1; done
2010-09-24 06:34:12
User: hackerb9
Functions: ping sleep tput
0

This is like ping -a, but it does the opposite. It alerts you if the network is down, not up. Note that the beep will be from the speaker on the server, not from your terminal.

Once a second, this script checks if the Internet is accessible and beeps if it is not. I define the Net as being "UP", if I can ping Google's public DNS server (8.8.8.8), but of course you could pick a different static IP address. I redirect the beep to /dev/console so that I can run this in the background from /etc/rc.local. Of course, doing that requires that the script is run by a UID or GID that has write permissions to /dev/console (usually only root).

Question: I am not sure if the -W1 flag works under BSD. I have only tested this under GNU/Linux using ping from iputils. If anybody knows how portable -W is, please post a comment.

alias onlyx='nohup startx & disown ; exit'
2010-07-26 12:44:13
User: elementa13
Functions: alias
Tags: X console tty
1

There are different ways to run X, I prefer to run it without xdm/gdm. The problem is you can't lock X because one can press Ctrl+Alt+F1, press Ctrl+Z and kill you X locking process. Of course you can disable Ctrl+Alt* or Ctrl+Alt+Backspace keys, but it's inconvinient if you really need to switch into console.

screen /dev/tty<device> 9600
mplayer -vo caca foo.avi
2009-05-25 09:29:24
User: farwarx
-11

Permet de lire une video dans une console, meme sans interface graphique.

Interet limite, mais a connaitre au cas ou.