All commands (14,187)

  • Simple function to permanently add an alias to your profile. Tested on bash and Ksh, bash version above. Here is the ksh version: PERMA () { print "$@" >> ~/.profile; } Sample usage: PERMA alias la='ls -a'


    2
    PERMA () { echo "$@" >> ~/.bashrc; }
    zlemini · 2009-09-28 16:03:24 9
  • Performs a reverse DNS lookup, variants include: nslookup 74.125.45.100 or: host 74.125.45.100 Show Sample Output


    4
    dig -x 74.125.45.100
    postrational · 2009-09-28 15:13:34 3
  • I've used this a number of times troubleshooting user permissions. Instead of just 'su - user' you can throw another hyphen and stay in the original directory. Show Sample Output


    13
    su -- user
    matthewdavis · 2009-09-28 04:23:43 7
  • gitstart ~/path/to/dir Initialized empty Git repository in /home/user/path/to/dir/.git/


    0
    gitstart () { if ! [[ -d "$@" ]]; then mkdir -p "$@" && cd "$@" && git init; else cd "$@" && git init; fi }
    xyz · 2009-09-28 01:12:32 3
  • I like the fact the Patola's version uses only ones and zeros, but I also like the sparse output of the other versions. This one combines both of those features and eliminates some unnecessary cruft. You can vary the sparseness by changing "$(($RANDOM % 5))" to another number. The number in this term "$(($RANDOM % 4))" controls how frequently the numbers are output bold.


    21
    echo -e "\e[32m"; while :; do for i in {1..16}; do r="$(($RANDOM % 2))"; if [[ $(($RANDOM % 5)) == 1 ]]; then if [[ $(($RANDOM % 4)) == 1 ]]; then v+="\e[1m $r "; else v+="\e[2m $r "; fi; else v+=" "; fi; done; echo -e "$v"; v=""; done
    dennisw · 2009-09-27 15:30:38 16

  • 7
    enscript jrandom.txt -o - | ps2pdf - ~/tmp/jrandom.pdf (from file) or: ls | enscript -o - | ps2pdf - ~/tmp/ls.pdf (from stdout)
    bartonski · 2009-09-27 15:15:16 6

  • 2
    wget 'link of a Picasa WebAlbum' -O - |perl -e'while(<>){while(s/"media":{"content":\[{"url":"(.+?\.JPG)//){print "$1\n"}}' |wget -w1 -i -
    aciancone · 2009-09-27 14:36:27 7
  • convert to debian package file (deb) a redhat package file (rpm) , then you can install it by using dpkg , require alien package ( sudo apt-get install alien first ) Show Sample Output


    -5
    sudo alien --to-deb Your_PackAge.rpm
    eastwind · 2009-09-27 13:49:07 5
  • This command will disable the beep sound from the PC speaker.


    5
    echo "blacklist pcspkr"|sudo tee -a /etc/modprobe.d/blacklist.conf
    sliceoflinux · 2009-09-27 11:42:47 5
  • Date-time format: YYYY-MM-DD HH:MM:SS Show Sample Output


    7
    export HISTTIMEFORMAT='%F %T '
    postrational · 2009-09-26 17:13:23 7
  • The execution of this command will install a LAMP server (Linux, Apache, MySQL and PHP) in a Debian based distribution. For example, in Ubuntu.


    5
    sudo tasksel install lamp-server
    sliceoflinux · 2009-09-26 08:15:03 8
  • Download the last show on your TiVo DVR. Replace $MAK with your MAK see https://www3.tivo.com/tivo-mma/showmakey.do Replace $tivo with your TiVo's IP


    0
    curl -s -c /tmp/cookie -k -u tivo:$MAK --digest "$(curl -s -c /tmp/cookie -k -u tivo:$MAK --digest https://$tivo/nowplaying/index.html | sed 's;.*<a href="\([^"]*\)">Download MPEG-PS</a>.*;\1;' | sed 's|\&amp;|\&|')" | tivodecode -m $MAK -- - > tivo.mpg
    matthewbauer · 2009-09-26 03:00:46 5
  • Log a command's votes, then run: gnuplot -persist <(echo "plot 'votes' with lines")


    0
    while true; do curl -s http://www.commandlinefu.com/commands/view/3643/log-a-commands-votes | grep 'id="num-votes-' | sed 's;.*id="num-votes-[0-9]*">\([0-9\-]*\)</div>;\1;' >> votes; sleep 10; done
    matthewbauer · 2009-09-26 00:55:24 44
  • for the change stay in your history file , export command by writing it into your .bashrc Show Sample Output


    7
    export HISTTIMEFORMAT="%h/%d-%H:%M:%S "
    eastwind · 2009-09-25 22:42:28 7
  • Rip DVD to YouTube ready AVI file, using MPEG-4 video codec and MP3 audio codec. Resizes to 320x240 and deinterlaces as needed.


    4
    mencoder -oac mp3lame -lameopts cbr=128 -ovc lavc -lavcopts vcodec=mpeg4 -ffourcc xvid -vf scale=320:-2,expand=:240:::1 -o output.avi dvd://0
    ivalladt · 2009-09-25 19:29:25 3
  • In color. Additionally you may define in your ~/.gitconfig and run it just as 'git one': one = log --pretty='format:%Cgreen%H %Cred%ai %Creset- %s'


    1
    git log --pretty='format:%Cgreen%H %Cred%ai %Creset- %s'
    levenbrech · 2009-09-25 19:18:37 29
  • or you can add "-x" to get a typical hexdump like output Show Sample Output


    5
    socat -v tcp4-l:<port> tcp4:<host>:<port>
    sitaram · 2009-09-25 17:10:16 4
  • Interacting with Active Directory to add users from one group to another group. This prevents from having to deal with long DNs and copying, pasting problems. It executes once per returned object.


    -3
    for /F "DELIMS=""" %i in ('dsquery group -name SourceGroupName ^| dsget group -members') do dsquery group -name TargetGroupName | dsmod group -addmbr %i
    miketheman · 2009-09-25 16:32:33 10
  • Get all the networking related commands for your distro Show Sample Output


    13
    apropos network |more
    shaiss · 2009-09-25 15:05:33 12
  • If you run this command on a VMWare Virtual Machine, it will return the string "VMware Virtual Platform". If you run it on a physical machine, it will return nothing. Useful for having a script determine if it's running on a VM or not. Of course, you must have dmidecode installed for this to work. Try it this way in a script: ISVM=$(dmidecode | awk '/VMware Virtual Platform/ {print $3,$4,$5}') Then test if $ISVM has text in it, or is blank.


    7
    dmidecode | awk '/VMware Virtual Platform/ {print $3,$4,$5}'
    SuperFly · 2009-09-25 14:46:35 13

  • 0
    ack --pager='less -r'
    unixmonkey5780 · 2009-09-25 13:01:58 3
  • Create/open/use an encrypted directory encfs needs to be installed During creation easiest to use default values The encrypted files will be in ~/.crypt and you will work as usual in ~/crypt To close the encrypted directory run: fusermount -u ~/crypt When you switch off the computer the encrypted directory will be automatically closed This example uses /home/user/crypt as encrypted directory I use ubuntu linux 8.04 and I am also the creator of www.minihowto.org


    8
    encfs ~/.crypt ~/crypt
    bkn390 · 2009-09-25 10:13:39 5
  • Install a deb package you have downloaded (synaptic has to be closed). (dpkg-dev needs to be installed) After that you may have to run following: sudo apt-get install -f (that should fix any dependency problems) I am using ubuntu linux


    -7
    sudo dpkg -i packagename.deb
    bkn390 · 2009-09-25 09:54:04 13

  • 30
    grep . filename > newfilename
    alvinx · 2009-09-25 09:25:34 17
  • No need to loop when we have `xargs`. The sed command filters out the first line of `show databases` output, which is always "Database".


    5
    mysql -e 'show databases' | sed -n '2,$p' | xargs -I DB 'mysqldump DB > DB.sql'
    mislav · 2009-09-25 08:43:06 9
  • ‹ First  < 442 443 444 445 446 >  Last ›

What's this?

commandlinefu.com is the place to record those command-line gems that you return to again and again. 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.

Share Your Commands


Check These Out

list block level layout

Alias TAIL for automatic smart output
Run the alias command, then issue $ps aux | tail and resize your terminal window (putty/console/hyperterm/xterm/etc) then issue the same command and you'll understand. $ ${LINES:-`tput lines 2>/dev/null||echo -n 12`} Insructs the shell that if LINES is not set or null to use the output from `tput lines` ( ncurses based terminal access ) to get the number of lines in your terminal. But furthermore, in case that doesn't work either, it will default to using the default of 80. The default for TAIL is to output the last 10 lines, this alias changes the default to output the last x lines instead, where x is the number of lines currently displayed on your terminal - 7. The -7 is there so that the top line displayed is the command you ran that used TAIL, ie the prompt. Depending on whether your PS1 and/or PROMPT_COMMAND output more than 1 line (mine is 3) you will want to increase from -2. So with my prompt being the following, I need -7, or - 5 if I only want to display the commandline at the top. ( http://www.askapache.com/linux/bash-power-prompt.html ) 275MB/748MB [7995:7993 - 0:186] 06:26:49 Thu Apr 08 [askapache@n1-backbone5:/dev/pts/0 +1] ~ $ In most shells the LINES variable is created automatically at login and updated when the terminal is resized (28 linux, 23/20 others for SIGWINCH) to contain the number of vertical lines that can fit in your terminal window. Because the alias doesn't hard-code the current LINES but relys on the $LINES variable, this is a dynamic alias that will always work on a tty device.

generate a unique and secure password for every website that you login to
usage: sitepass MaStErPaSsWoRd example.com description: An admittedly excessive amount of hashing, but this will give you a pretty secure password, It also eliminates repeated characters and deletes itself from your command history. tr '!-~' 'P-~!-O' # this bit is rot47, kinda like rot13 but more nerdy rev # this avoids the first few bytes of gzip payload, and the magic bytes.

Route outbound SMTP connections through a addtional IP address rather than your primary

View all images
So you are in directory with loads of pictures laying around and you need to quickly scan through them all

Extract the MBR ID of a device
Useful when you want to know the mbrid of a device - for the purpose of making it bootable. Certain hybridiso distros, for eg the OpenSUSE live ISO uses the mbrid to find the live media. Use this command to find out the mbrid of your USB drive and then edit the /grub/mbrid file to match it.

Convert CSV to JSON
Replace 'csv_file.csv' with your filename.

Find files that were modified by a given command
Traces the system calls of a program. See http://linuxhelp.blogspot.com/2006/05/strace-very-powerful-troubleshooting.html for more information.

Check wireless link quality with dialog box
The variable WIRELESSINTERFACE indicates your wireless interface

Show current network interface in use


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: