Commands matching du (714)


  • 12
    sudo dmidecode | grep Product
    bbbco · 2012-02-07 16:26:23 16

  • 11
    ruby -ryaml -rjson -e 'puts YAML.dump(JSON.parse(STDIN.read))' < file.json > file.yaml
    wejn · 2013-04-24 07:20:37 127
  • Search for files and list the 20 largest. find . -type f gives us a list of file, recursively, starting from here (.) -print0 | xargs -0 du -h separate the names of files with NULL characters, so we're not confused by spaces then xargs run the du command to find their size (in human-readable form -- 64M not 64123456) | sort -hr use sort to arrange the list in size order. sort -h knows that 1M is bigger than 9K | head -20 finally only select the top twenty out of the list Show Sample Output


    11
    find . -type f -print0 | xargs -0 du -h | sort -hr | head -20
    flatcap · 2012-03-30 10:21:12 9
  • the command is obvious, I know, but maybe not everyone knows that using the parameter "-l" you can limit the use of bandwidth command scp. In this example fetch all files from the directory zutaniddu and I copy them locally using only 10 Kbs


    11
    scp -l10 pippo@serverciccio:/home/zutaniddu/* .
    0disse0 · 2010-02-19 16:44:24 13
  • Very useful when you need disk space. It calculates the disk usage of all files and dirs (descending them) located at the current directory (including hidden ones). Then sort puts them in order.


    11
    du -cs * .[^\.]* | sort -n
    cemsbr · 2009-03-02 18:43:48 16
  • Use this as a quick and simple alternative to the slightly verbose "du -s --max-depth=1" Show Sample Output


    11
    du -sh *
    larsr · 2009-02-05 16:39:14 34
  • Avoiding a for loop brought this time down to less than 3 seconds on my old machine. And just to be clear, 33554432 = 8192 * 4086.


    10
    base64 /dev/urandom | head -c 33554432 | split -b 8192 -da 4 - dummy.
    pdxdoughnut · 2013-11-12 17:56:23 8

  • 10
    find . -size +100000k -exec du -h {} \;
    binarysys · 2011-01-09 19:42:01 6
  • Not as taxing on the CPU.


    10
    while [ true ]; do head -n 100 /dev/urandom; sleep .1; done | hexdump -C | grep "ca fe"
    campassi · 2010-10-05 16:23:31 5
  • change the *.avi to whatever you want to match, you can remove it altogether if you want to check all files.


    10
    find -type f -name "*.avi" -print0 | xargs -0 mplayer -vo dummy -ao dummy -identify 2>/dev/null | perl -nle '/ID_LENGTH=([0-9\.]+)/ && ($t +=$1) && printf "%02d:%02d:%02d\n",$t/3600,$t/60%60,$t%60' | tail -n 1
    grokskookum · 2009-09-24 15:50:39 33

  • 9
    sudo tcpdump port http or port ftp or port smtp or port imap or port pop3 or port telnet -l -A | egrep -i -B5 'pass=|pwd=|log=|login=|user=|username=|pw=|passw=|passwd=|password=|pass:|user:|username:|password:|login:|pass |user '
    wuseman1 · 2019-02-03 05:13:58 72
  • Convert JSON to YAML. Note that you'll need to have PyYaml installed.


    9
    python -c 'import sys, yaml, json; yaml.safe_dump(json.load(sys.stdin), sys.stdout, default_flow_style=False)' < file.json > file.yaml
    tebeka · 2013-04-24 00:31:39 92

  • 9
    find . -type f -print0 | xargs -0 du -h | sort -hr | head -10
    netaxiz · 2012-06-30 10:03:31 4
  • Real gurus don't need fancy tools like iftop or jnettop. Show Sample Output


    9
    tcpdump -w - |pv -bert >/dev/null
    h3xx · 2011-12-14 00:24:02 7
  • This microscript looks up a man page for each word possible, and if the correct page is not found, uses w3m and Google's "I'm feeling lucky" to output a first possible result. This script was made as a result of an idea on a popular Linux forum, where users often send other people to RTFM by saying something like "man backup" or "man ubuntu one". To make this script replace the usual man command, save it as ".man.sh" in your home folder and add the following string to the end of your .bashrc file: alias man='~/.man.sh' Show Sample Output


    9
    /usr/bin/man $* || w3m -dump http://google.com/search?q="$*"\&btnI | less
    d1337r · 2010-10-05 13:51:39 6
  • backup big mysql db to remote machine over ssh. "--skip-opt" option is needed when you can?t allocate full database in ram.


    9
    mysqldump -q --skip-opt --force --log-error=dbname_error.log -uroot -pmysqlpassword dbname | ssh -C user@sshserver 'cd /path/to/backup/dir; cat > dbname.sql'
    esplinter · 2010-05-29 23:06:04 6
  • use "watch" instead of while-loops in these simple cases


    9
    watch -n60 du /var/log/messages
    matrixguy · 2009-10-09 18:37:45 6

  • 9
    du -sk * |sort -rn |head
    realist · 2009-08-19 02:31:30 6
  • I use this command to save RTSP video streams over night from one of our national TV stations, so I won't have to squeeze the data through my slow internet connection when I want to watch it the next day. For ease of use, you might want to put this in a file: #!/bin/bash FILE="`basename \"$1\"`" mplayer -dumpstream -dumpfile "$FILE" -playlist "$1"


    9
    mplayer -dumpstream -dumpfile "yourfile" -playlist "URL"
    Alanceil · 2009-02-28 22:18:17 7
  • Backups all MySQL databases to individual files. Can be put into a script that grabs current date so you have per day backups.


    9
    for I in `echo "show databases;" | mysql | grep -v Database`; do mysqldump $I > "$I.sql"; done
    ruedu · 2009-02-16 16:41:05 773
  • MySQL: CHARSET from latin1 to utf8


    9
    mysqldump --add-drop-table -uroot -p "DB_name" | replace CHARSET=latin1 CHARSET=utf8 | iconv -f latin1 -t utf8 | mysql -uroot -p "DB_name"
    paradox · 2009-02-16 16:23:27 721
  • why make it complicated ? : ] -------------------- I just noticed someone else has posted this on this site before me (sorry I am now a duplicate :/) http://www.commandlinefu.com/commands/view/4313


    8
    du -hs */
    manurevah · 2010-04-11 22:48:31 4

  • 8
    du -cks * | sort -rn | while read size fname; do for unit in k M G T P E Z Y; do if [ $size -lt 1024 ]; then echo -e "${size}${unit}\t${fname}"; break; fi; size=$((size/1024)); done; done
    askedrelic · 2010-04-05 17:09:14 5
  • This command will dump a database on a remote stream to stdout, compress it, stream it to your local machine, decompress it and put it into a file called database.sql.You could even pipe it into mysql on your local machine to restore it immediately. I had to use this recently because the server I needed a backup from didn't have enough disk space.


    8
    ssh user@host "mysqldump -h localhost -u mysqluser -pP@$$W3rD databasename | gzip -cf" | gunzip -c > database.sql
    daws · 2009-10-05 00:57:51 10
  • This command securely erases all the unused blocks on a partition. The unused blocks are the "free space" on the partition. Some of these blocks will contain data from previously deleted files. You might want to use this if you are given access to an old computer and you do not know its provenance. The command could be used while booted from a LiveCD to clear freespace space on old HD. On modern Linux LiveCDs, the "ntfs-3g" system provides ReadWrite access to NTFS partitions thus enabling this method to also be used on Wind'ohs drives. NB depending on the size of the partition, this command could take a while to complete. Show Sample Output


    8
    # cd $partition; dd if=/dev/zero of=ShredUnusedBlocks bs=512M; shred -vzu ShredUnusedBlocks
    mpb · 2009-06-21 14:17:22 12
  •  < 1 2 3 4 >  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

find largest file in /var
find largest file in /var

Extracts PDF pages as images

Make a DVD ISO Image from a VIDEO_TS folder on MacOSX
/path/ is the root folder of the DVD, not the VIDEO_TS folder.

Create a CD/DVD ISO image from disk.

Advanced LS Output using Find for Formatted/Sortable File Stat info
I love this function because it tells me everything I want to know about files, more than stat, more than ls. It's very useful and infinitely expandable. $ find $PWD -maxdepth 1 -printf '%.5m %10M %#9u:%-9g %#5U:%-5G [%AD | %TD | %CD] [%Y] %p\n' | sort -rgbS 50% 00761 drwxrw---x askapache:askapache 777:666 [06/10/10 | 06/10/10 | 06/10/10] [d] /web/cg/tmp The key is: # -printf '%.5m %10M %#9u:%-9g %#5U:%-5G [%AD | %TD | %CD] [%Y] %p\n' which believe it or not took me hundreds of tweaking before I was happy with the output. You can easily use this within a function to do whatever you want.. This simple function works recursively if you call it with -r as an argument, and sorts by file permissions. $ lsl(){ O="-maxdepth 1";sed -n '/-r/!Q1'

Copy a directory recursively without data/files

Display kernel profile of currently executing functions in Solaris.
Lockstat will sample the kernel 977 times per second, and print out the functions that it sees executing on the CPU during the sample. The -s 10 switch tells lockstsat to not only print that function, but also show the call stack (up to 10 deep).

Convert seconds to [DD:][HH:]MM:SS
Converts any number of seconds into days, hours, minutes and seconds. sec2dhms() { declare -i SS="$1" D=$(( SS / 86400 )) H=$(( SS % 86400 / 3600 )) M=$(( SS % 3600 / 60 )) S=$(( SS % 60 )) [ "$D" -gt 0 ] && echo -n "${D}:" [ "$H" -gt 0 ] && printf "%02g:" "$H" printf "%02g:%02g\n" "$M" "$S" }

Mount partition from image (without offset mount)

Find the real procesor speed when you use CPU scaling [cpuspeed]
We don't use CPU scaling, but just in case you do, there is something interesting to note. If you look at the /proc/cpuinfo, the speed listed is current running speed of the processors and not the real speed of the chip.


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: