Commands by totti (87)


  • 1
    pmi action suspend
    totti · 2013-01-15 18:44:31 4
  • set how many commands to keep in history Default is 500 Saved in /home/$USER/.bash_history Add this to /home/$USER/.bashrc HISTFILESIZE=1000000000 HISTSIZE=1000000


    2
    export HISTFILESIZE=99999
    totti · 2013-01-02 09:25:06 5
  • Use optimized sed to big file/stream to reduce execution time Use sed '/foo/ s/foo/foobar/g' <filename> insted of sed 's/foo/foobar/g' <filename>


    -6
    sed '/foo/ s/foo/foobar/g' <filename>
    totti · 2013-01-02 08:52:44 389
  • Accidentally deleted some file while used by a program ? (Eg: a song) Use this command to find the file handle and recover using cp /proc/pid/fd/filehandle /new/recoverd-file.ext Show Sample Output


    0
    ls -l /proc/*/fd/* | grep 'deleted'| grep "\/proc.*\file-name-part"
    totti · 2012-09-13 09:54:16 5
  • EG: aspectRatio 1920 1200 For display a image in full screen it should be in any of the resolution obtained from the output. So resize an image to any of it and you can display it in full screen For general aspect ratio : aspectRatio () { for i in `seq 1 1000 `; do awk "BEGIN {print $1/$i, $2/$i}"; done |grep -v "\." |tail -1; } Show Sample Output


    0
    aspectRatio () { for i in `seq 1 1000 `; do awk "BEGIN {print $1/$i, $2/$i}"; done |grep -v "\."; }
    totti · 2012-03-07 06:22:25 3
  • Redshift will adjust the color temperature and protects eye at night -b : will adjust the brightness


    2
    redshiftgui -o -b 0.5
    totti · 2012-02-26 16:10:02 14

  • 0
    identify image.jpg |grep -o "[[:digit:]]*x[[:digit:]]*" |tail -1
    totti · 2012-02-19 06:49:38 5

  • -10
    grep -r <searchterm> *
    totti · 2012-02-08 11:48:08 7

  • 33
    showkey -a
    totti · 2012-01-26 10:47:19 15

  • 4
    xdotool getmouselocation
    totti · 2012-01-19 14:58:13 4
  • For a demo try wmctrl -o 100,0; sleep 3; wmctrl -o 1500,0; sleep 3; wmctrl -o 3000,0; sleep 3; wmctrl -o 4500,0; Actually wmctrl -o <width x Number>,0; to switch to that workspace


    0
    wmctrl -o 100,0
    totti · 2012-01-19 14:36:20 13
  • In order to create a new encrypted filing system managed by cryptmount, you can use the supplied 'cryptmount-setup' program, which can be used by the superuser to interactively configure a basic setup. Alternatively, suppose that we wish to setup a new encrypted filing system, that will have a target-name of "opaque". If we have a free disk partition available, say /dev/hdb63, then we can use this directly to store the encrypted filing system. Alternatively, if we want to store the encrypted filing system within an ordinary file, we need to create space using a recipe such as: dd if=/dev/zero of=/home/opaque.fs bs=1M count=512 . cryptmount --generate-key 32 opaque . cryptmount --prepare opaque . mke2fs /dev/mapper/opaque . cryptmount --release opaque . mkdir /home/crypt . cryptmount -m opaque . cryptmount -u opaque For detail see sample output Show Sample Output


    -2
    cryptmount -m <name>
    totti · 2012-01-17 18:02:47 8
  • Used by virtualbox and others to create '.run' file.


    -1
    makeself <archive_dir> <file_name> <label>
    totti · 2012-01-10 18:08:50 147
  • Best result when file size less than half of RAM size


    9
    cat <file> > /dev/null
    totti · 2011-11-12 15:45:27 8

  • 0
    stat --format "%s" <file>
    totti · 2011-11-12 15:41:09 4
  • Faster then other method using wget For obtain all commands use nu=`curl http://www.commandlinefu.com/commands/browse |grep -o "Terminal - All commands -.*results$" | grep -oE "[[:digit:],]{4,}" | sed 's/,//'`; curl http://www.commandlinefu.com/commands/browse/sort-by-votes/plaintext/[0-"$nu":25] | grep -vE "_curl_|\.com by David" > clf-ALL.txt For more version specific nu=`curl http://www.commandlinefu.com/commands/browse |grep -o "Terminal - All commands -.*results$" | grep -oE "[[:digit:],]{4,}" | sed 's/,//'`; curl http://www.commandlinefu.com/commands/browse/sort-by-votes/plaintext/[0-"$nu":25] | grep -vE "_curl_|\.com by David" > clf-ALL_"$nu".txt Also download dirctly from my dropbox My drop box invitaion link is http://db.tt/sRdJWvQq . Use it and get free 2.5 GB space. Show Sample Output


    2
    curl http://www.commandlinefu.com/commands/browse/sort-by-votes/plaintext/[0-9000:25] | grep -vE "_curl_|\.com by David" > clf-ALL.txt
    totti · 2011-11-08 12:19:48 123
  • thumbnail gallery of video using totem Show Sample Output


    4
    totem-video-thumbnailer -pg 25 in_video out_png
    totti · 2011-10-31 18:07:36 8
  • Faster thumbnail creation than '-itsoffset' ffmpeg -itsoffset -4 -i test.avi -vcodec mjpeg -vframes 1 -an -f rawvideo -s 320x240 test.jpg Show Sample Output


    2
    ffmpeg -ss 5 -i video.avi -vframes 1 -s 320x240 thumb.jpg
    totti · 2011-10-31 17:19:33 18
  • Handle any bad named file which contains ",',\n,\b,\t,` etc Store the file name as null character separated list find . -print0 >name.lst and retrieve it using read -r -d "" Eg: find . -print0 >name.lst; cat name.lst| while IFS="" read -r -d "" file; do ls -l "$file"; done Show Sample Output


    1
    read -d ""
    totti · 2011-10-25 18:44:11 16

  • 4
    find . ! -name "$(printf '*[\001-\037\177]*')"
    totti · 2011-10-25 17:29:19 5
  • Add the followin to ~/.bashrc #colour export LESS_TERMCAP_mb=$'\E[01;31m' export LESS_TERMCAP_md=$'\E[01;37m' export LESS_TERMCAP_me=$'\E[0m' export LESS_TERMCAP_se=$'\E[0m' export LESS_TERMCAP_so=$'\E[01;44;33m' export LESS_TERMCAP_ue=$'\E[0m' export LESS_TERMCAP_us=$'\E[01;32m'


    15
    echo "export LESS_TERMCAP_mb=$'\E[01;31m'" >> ~/.bashrc
    totti · 2011-10-20 17:34:14 8

  • 4
    filext () { echo ${1##*.}; }
    totti · 2011-10-20 16:35:25 3
  • Then exit from the shell. exit some time need to exit twice exit exit Now the OS will boot with the new parameters.


    0
    echo "root=/dev/sda7" > /proc/param.conf
    totti · 2011-09-27 18:06:53 5
  • From live CD mount(open) the Ubuntu installed drive. Copy the location (press Ctrl+l, Ctrl+c ) eg: /media/ubuntuuuu Open terminal (Apllication->accessories->terminal) Type this: sudo grub-install --root-directory=/media/ubuntuuuu /dev/sda (replace /media/ubuntuuuu with what u got (ie paste)) Will show success message. Now reboot


    -2
    sudo grub-install --root-directory=/media/ubuntu /dev/sda
    totti · 2011-09-27 17:51:56 3
  • Consider the following simple situation [ reading something using while and read ] [See script 1 in sample output] --------------------------------------------------- The variable var is assigned with "nullll" at first. Inside the while loop [piped while] it is assigned with "whillleeee". [Onlly 2 assignments stmts]. Outside the loop the last assigned value for "var" [and no variable] inside the while can't be accessed [Due to pipe, var is executed in a sub shell]. In these type of situation variables can be accessed by modifying as follows. [See script 2 in sample output] ___________________________ Vary helpful when reading a set of items, say file names, stored on a file [or variable] to an array an use it later. Is there any other way 2 access variables inside and outside the loop ?? Show Sample Output


    -5
    while read line; do echo $line; done <<< "$var"
    totti · 2011-09-22 16:53:32 5
  •  < 1 2 3 4 > 

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

Adding Prefix to File name
Adding course name prefix to lecture pdfs

Rename all subtitles files with the same name of mp4 files in same folder
Use this command if you want to rename all subtitles for them to have the same name as the mp4 files. NOTE: The order of "ls -1 *.mp4" must match the order of "ls -1 *.srt", run the command bellow to make sure the *.srt files will really match the movies after run this command: paste -d:

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" }

Google Translate
$ translate [output-language] [source-language] 1) "some phrase" should be in quotes 2) [output-language] - optional (default: English) 3) [source-language] - optional (default: auto) $ translate "bonjour petit lapin" hello little rabbit $ translate "bonjour petit lapin" en hello little rabbit $ translate "bonjour petit lapin" en fr hello little rabbit

Calculate days on which Friday the 13th occurs (inspired from the work of the user justsomeguy)
Friday is the 5th day of the week, monday is the 1st. Output may be affected by locale.

Check if the LHC has destroyed the world
This says if the LHC has destroyed the world. Run it in a loop to monitor the state of Earth. Might not work reliable, if the world has actually been destroyed.

Use socat to emulate an SMTP mail SERVER
Lots of scripts show you how to use socat to send an email to an SMTP server; this command actually emulates an SMTP server! It assumes the client is only sending to one recipient, and it's not at all smart, but it'll capture the email into a log file and the client will stop retrying. I used this to diagnose what emails were being sent by cron and subsequently discarded, but you can use it for all sorts of things.

find the rpm package name that provides a specific file
For Linux distributions using rpm (eg Mandriva), this command will find the rpm package name that provides a file.

Redirect STDIN
Several times, I find myself hitting my up arrow, and changing the search term. Unfortunately, I find myself wasting too much time typing: $ grep kernel /var/log/messages Redirecting STDIN allows me to put the search term at the end so I less cursor movement to change what I'm searching for: $ < /var/log/messages grep kernel If you're using the emacs keyboard binding, then after you press your up arrow, press CTRL+w to erase the word. If this has already been submitted, I couldn't find it with the search utility.

dd with progress bar and statistics
Will automatically take the size of the file but longer, usefull only if in an function.


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: