Commands matching du (714)


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

  • 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 798
  • 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 764
  • 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

List all available python modules

Shows space used by each directory of the root filesystem excluding mountpoints/external filesystems (and sort the output)

Read and write to TCP or UDP sockets with common bash tools
Ever needed to test firewalls but didn't have netcat, telnet or even FTP? Enter /dev/tcp, your new best friend. /dev/tcp/(hostname)/(port) is a bash builtin that bash can use to open connections to TCP and UDP ports. This one-liner opens a connection on a port to a server and lets you read and write to it from the terminal. How it works: First, exec sets up a redirect for /dev/tcp/$server/$port to file descriptor 5. Then, as per some excellent feedback from @flatcap, we launch a redirect from file descriptor 5 to STDOUT and send that to the background (which is what causes the PID to be printed when the commands are run), and then redirect STDIN to file descriptor 5 with the second cat. Finally, when the second cat dies (the connection is closed), we clean up the file descriptor with 'exec 5>&-'. It can be used to test FTP, HTTP, NTP, or can connect to netcat listening on a port (makes for a simple chat client!) Replace /tcp/ with /udp/ to use UDP instead.

"Pretty print" $PATH, show directories in $PATH, one per line with replacement pattern using shell parameter expansion
Can be used to create path alias. From: https://www.cyberciti.biz/tips/bash-aliases-mac-centos-linux-unix.html. #9

Find usb device in realtime
Using this command you can track a moment when usb device was attached.

Search through files, ignoring .svn

pushd rotates the stack so that the second directory comes at the top.
'pushd +1' is equivalent to 'pushd'. Can be 'pushd +3' or more generaly 'pushd +N'. Can also be 'pushd -N'. More description in 'man bash'.

List files by quoting or escaping special characters.
Tested and works on Linux.

mirrors directory to a ftp server
http://lftp.yar.ru/

Take screenshots with imagemagick
Now try this. Ones you see small cross arrow, double click on any window you like to make a screenshot "selectively".


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: