All commands (14,187)

  • it does provide much more information , the owner , group , the size in byte , and the last modified time a file or directory was ls -al : list all in long format Show Sample Output


    -11
    ls -al
    eastwind · 2009-11-12 12:27:32 6
  • this is a reference to Antoine de St. Exupery's "The Little Prince" Show Sample Output


    6
    aptitude moo
    eastwind · 2009-11-12 12:24:01 7
  • Watch a TiVo file on your computer.


    0
    curl -s -c /tmp/cookie -k -u tivo:$MAK --digest http://$tivo/download/$filename | tivodecode -m $MAK -- - | mplayer - -cache-min 50 -cache 65536
    matthewbauer · 2009-11-11 23:32:23 3

  • 9
    setterm -powersave off -blank 0
    unixmonkey6999 · 2009-11-11 22:39:50 4
  • trying to copy all your dotfiles from one location to another, this may help Show Sample Output


    -2
    ls -a | egrep "^\.\w"
    kulor · 2009-11-11 18:19:56 12
  • cd to the folder containing the wav files and convert them all to ogg format. in my sample output i use the -a and -l flags to set the author and album title. to get the oggenc program in ubuntu linux run: sudo apt-get install oggenc Show Sample Output


    2
    oggenc *.wav
    nickleus · 2009-11-11 14:26:01 6
  • cd to the folder containing the wav files, then convert them all to flac. yeah baby! in ubuntu, to get the flac program just: sudo apt-get install flac flac file input formats are wav, aiff, raw, flac, oga and ogg Show Sample Output


    3
    flac --best *.wav
    nickleus · 2009-11-11 14:17:24 9

  • -1
    for i in `cat /etc/passwd | awk -F : '{ print $1 }';`; do passwd -e $i; done
    irraz · 2009-11-11 13:01:22 3
  • Create a tar file in multiple parts if it's to large for a single disk, your filesystem, etc. Rejoin later with `cat .tar.*|tar xf -` Show Sample Output


    17
    tar cf - <dir>|split -b<max_size>M - <name>.tar.
    dinomite · 2009-11-11 01:53:33 5
  • The magic is performed by the parameter -t Show Sample Output


    -2
    for F in $(find ./ -name "*.tgz") ; do tar -tvzf $F ; done
    alchandia · 2009-11-11 00:50:52 3
  • 355 # from zsh-users 356 edit_command_line () { 357 # edit current line in $EDITOR 358 local tmpfile=${TMPPREFIX:-/tmp/zsh}ecl$$ 359 360 print -R - "$PREBUFFER$BUFFER" >$tmpfile 361 exec 362 ${VISUAL:-${EDITOR:-vi}} $tmpfile 363 zle kill-buffer 364 BUFFER=${"$( 365 CURSOR=$#BUFFER 366 367 command rm -f $tmpfile 368 zle redisplay 369 } 370 zle -N edit_command_line


    -2
    zsh$ M-v
    bucciarati · 2009-11-10 23:02:56 11

  • -3
    dd if=/dev/<device location> | gzip -c /<path to backup location>/<disk image name>.img.gz
    awjrichards · 2009-11-10 22:57:51 9
  • The pstack command prints a stack trace of running processes without needing to attach a debugger, but what about core files? The answer, of course, is to use this command. Usage: gdbbt program corefile


    3
    alias gdbbt="gdb -q -n -ex bt -batch"
    TeacherTiger · 2009-11-10 22:56:59 647
  • I don't know if you've used sqsh before. But it has a handy feature that allows you to switch into vim to complete editing of whatever complicated SQL statement you are trying to run. But I got to thinking -- why doesn't bash have that? Well, it does. It's called '|'! Jk. Seriously, I'm pretty sure this flow of commands will revolutionize how I administer files. And b/c everything is a file on *nx based distros, well, it's handy. First, if your ls is aliased to ls --color=auto, then create another alias in your .bashrc: alias lsp='ls --color=none' Now, let's say you want to rename all files that begin with the prefix 'ras' to files that begin with a 'raster' prefix. You could do it with some bash substitution. But who remembers that? I remember vim macros because I can remember to press 'qa' and how to move around in vim. Plus, it's more incremental. You can check things along the way. That is the secret to development and probably the universe. So type something like: lsp | grep ras Are those all the files you need to move? If not, modify and re-grep. If so, pipe it to vim. lsp | grep ras | vim - Now run your vim macros to modify the first line. Assuming you use 'w' and 'b' to move around, etc., it should work for all lines. Hold down '@@', etc., until your list of files has been modified from ras_a.h ras_a.cpp ras_b.h ras_b.cpp to: mv ras_a.h raster_a.h mv ras_a.cpp raster_a.cpp mv ras_b.h raster_b.h mv ras_b.h raster_b.cpp then run :%!bash then run :q! then be like, whaaaaa? as you realize your workflow got a little more continuous. maybe. YMMV.


    -3
    vim -
    tmsh · 2009-11-10 22:25:36 12
  • This script creates date based backups of the files. It copies the files to the same place the original ones are but with an additional extension that is the timestamp of the copy on the following format: YearMonthDay-HourMinuteSecond Show Sample Output


    6
    backup() { for i in "$@"; do cp -va $i $i.$(date +%Y%m%d-%H%M%S); done }
    polaco · 2009-11-10 20:59:45 6
  • This script will list all the files in the tarballs present on any folder or subfolder of the provided path. The while loop is for echoing the file name of the tarball before listing the files, so the tarball can be identified


    -2
    find <path> -name "*.tgz" -or -name "*.tar.gz" | while read file; do echo "$file: "; tar -tzf $file; done
    polaco · 2009-11-10 20:39:04 36
  • This command will copy a folder tree (keeping the parent folders) through ssh. It will: - compress the data - stream the compressed data through ssh - decompress the data on the local folder This command will take no additional space on the host machine (no need to create compressed tar files, transfer it and then delete it on the host). There is some situations (like mirroring a remote machine) where you simply cant wait for a huge time taking scp command or cant compress the data to a tarball on the host because of file system space limitation, so this command can do the job quite well. This command performs very well mainly when a lot of data is involved in the process. If you copying a low amount of data, use scp instead (easier to type) Show Sample Output


    12
    ssh <host> 'tar -cz /<folder>/<subfolder>' | tar -xvz
    polaco · 2009-11-10 20:06:47 8

  • 0
    egrep -v "^[[:blank:]]*($|#|//|/\*| \*|\*/)" somefile
    sdadh01 · 2009-11-10 18:49:19 5
  • Find files recursively that were updated in the last hour ignoring SVN files and folders. Incase you do a full svn up on accident.


    2
    find . -mmin -60 -not -path "*svn*" -print|more
    bloodykis · 2009-11-10 18:34:53 7
  • Strips comments from at least bash and php scripts. Normal # and // as well as php block comments removes all of the: empty/blank lines lines beginning with # lines beginning with // lines beginning with /* lines beginning with a space and then * lines beginning with */ It also deletes the lines if there's whitespace before any of the above. Add an alias to use in .bashrc like this: alias stripcomments="sed -e '/^[[:blank:]]*#/d; s/[[:blank:]][[:blank:]]*#.*//' -e '/^$/d' -e '/^\/\/.*/d' -e '/^\/\*/d;/^ \* /d;/^ \*\//d'"


    -3
    sed -e '/^[[:blank:]]*#/d; s/[[:blank:]][[:blank:]]*#.*//' -e '/^$/d' -e '/^\/\/.*/d' -e '/^\/\*/d;/^ \* /d;/^ \*\//d' /a/file/with/comments
    unixmonkey6951 · 2009-11-10 17:47:22 10
  • The legend in the first column: i = installed p = installable Show Sample Output


    -6
    aptitude search NAME
    CafeNinja · 2009-11-10 11:23:18 5
  • The command as given would create the file "/result_path/result.tar.gz" with the contents of the target folder including permissions and sub- folder structure. Show Sample Output


    0
    tar pzcvf /result_path/result.tar.gz /target_path/target_folder
    CafeNinja · 2009-11-10 11:17:00 5
  • will decode a mime message. usefull when you receive some email and file attachment that cant be read.


    3
    munpack file.txt
    Diceroll · 2009-11-10 10:53:49 4
  • search ubuntu's remote package source repositories for a specific program to see which package contains it Show Sample Output


    7
    apt-file find bin/programname
    nickleus · 2009-11-10 10:21:45 6
  • require the pdftk package


    8
    pdftk 1.pdf 2.pdf 3.pdf cat output 123.pdf
    eastwind · 2009-11-10 10:07:37 4
  • ‹ First  < 428 429 430 431 432 >  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

Backup your LDAP
Simple way to backup your LDAP entries: put this line on your crontab. The -n switch identifies the dbnum you want to backup (alternatively you can use -b suffix. Check man slapcat for your personal switches)

capture selected window
I think, this is a shorter one :)

Function to output an ASCII character given its decimal equivalent
I've corrected the function. My octal conversion formula was completely wrong. Thanks to pgas at http://mywiki.wooledge.org/BashFAQ/071 for setting me straight. The new function is from pgas and is very fast.

Extract audio from a video

PRINT LINE the width of screen or specified using any char including Colors, Escapes and metachars
One of the first functions programmers learn is how to print a line. This is my 100% bash builtin function to do it, which makes it as optimal as a function can be. The COLUMNS environment variable is also set by bash (including bash resetting its value when you resize your term) so its very efficient. I like pretty-output in my shells and have experimented with several ways to output a line the width of the screen using a minimal amount of code. This is like version 9,000 lol. This function is what I use, though when using colors or other terminal features I create separate functions that call this one, since this is the lowest level type of function. It might be better named printl(), but since I use it so much it's more optimal to have the name contain less chars (both for my programming and for the internal workings). If you do use terminal escapes this will reset to default. $ tput sgr0 For implementation ideas, check my http://www.askapache.com/linux-unix/bash_profile-functions-advanced-shell.html

list block devices
Shows all block devices in a tree with descruptions of what they are.

Which processes are listening on a specific port (e.g. port 80)
swap out "80" for your port of interest. Can use port number or named ports e.g. "http"

Figure out what shell you're running
short, sweet, and works after sudoing a new shell.

watch iptables counters
This will allow you to watch as matches occur in real-time. To filter out only ACCEPT, DROP, LOG..etc, then run the following command: watch 'iptables -nvL | grep -v "0 0" && grep "ACCEPT"' The -v is used to do an inverted filter. ie. NOT "0 0"

How to copy CD/DVD into hard disk (.iso)
A dear friend of mine asked me how do I copy a DVD to your hard drive? If you want to make a copy of the ISO image that was burned to a CD or DVD, insert that medium into your CD/DVD drive and (assuming /dev/cdrom is associated with your computer?s CD drive) type the following command


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: