Commands by m33600 (23)

  • change gpeXX by the culprit you discovered on phase 1 In case of this example, the culprit is the biggest number, ie, gpe1C /sys/firmware/acpi/interrupts/ff_gbl_lock: 0 enabled /sys/firmware/acpi/interrupts/gpe01: 0 enabled /sys/firmware/acpi/interrupts/gpe06: 0 enabled /sys/firmware/acpi/interrupts/gpe17: 2 enabled /sys/firmware/acpi/interrupts/gpe18: 0 enabled /sys/firmware/acpi/interrupts/gpe1C: 19 enabled This procedure,if solved this universal issue all linix distros are experimenting for more than 2 years, may be included at startup, via cron. But try first commandline.


    0
    echo "disable" > /sys/firmware/acpi/interrupts/gpeXX
    m33600 · 2013-07-16 03:53:20 8
  • Goto phase 2 to clobber the interrupt that is problematic. Show Sample Output


    0
    grep enabled /sys/firmware/acpi/interrupts/*
    m33600 · 2013-07-16 03:46:23 7
  • Knoppix is Debian running in RAM, one of the best distros I've seen, but I had to left click the hardware button to use the system, because touchpad ignored taps. Not anymore


    0
    synclient TapButton1=1 TapButton2=2 TapButton3=3
    m33600 · 2013-07-16 03:37:21 7

  • 2
    sendEmail -f anything@anithing.com -u subject of nessage -t youfriend@hisdomain -m message to him
    m33600 · 2011-03-06 16:30:40 5
  • Your IP is resolved by OpenDns Server (like a caller ID telephone, every server knows who is calling ;-) Change user:password by yours Be Happy Show Sample Output


    2
    curl -i -m 60 -k -u user:password 'https://updates.opendns.com/account/ddns.php?'
    m33600 · 2010-02-07 02:40:38 6

  • 0
    curl -u user:passwd -T /home/dir/local_file_to_upload ftp://your_host.com/subdir/
    m33600 · 2009-12-26 02:48:05 4
  • 0-1279 = desktop 1 region = face 1 1280-2559 = face 2 ==>> wmctrl 1280 = wmctrl (1281,...2559) are all the same for a 1280 monitor resolution math: argument of wmctrl -o = ( DesiredFace * HorizontalResolution - 1)


    1
    wmctrl -o 1280,0
    m33600 · 2009-11-18 11:06:29 32
  • Changes the wallpaper for the last IR picture of the sun taken by SOHO satellite. Lesser size, try curl http://sohowww.nascom.nasa.gov/data/realtime/eit_195/512/latest.jpg | xli -onroot -fullscreen -xzoom 120 -yzoom 120 -border black stdin I use inside kalarm(kde), updating every 15 minutes needs xli , curl


    9
    curl http://sohowww.nascom.nasa.gov/data/realtime/eit_195/512/latest.jpg | xli -onroot -fill stdin
    m33600 · 2009-11-12 22:00:19 6
  • Changes the wallpaper to the last satellite image. Tha url above shows latin america. Seek the best url for your location Now I have a usefull background image in my desktop I use it inside kalarm updating every 15 minutes. May be done with 'watch' instead It s an option to xplanet ( kde ) and xearth needs xli , curl


    5
    curl http://www.cpa.unicamp.br/imagens/satelite/ult.gif | xli -onroot -fill stdin
    m33600 · 2009-11-12 21:52:19 8
  • I have a custmer's Geovision DVR installed on a closed proxi (only logme-in reaches it). I have to check for reliability but logmein hangs and is too slow a process I made the Geovision software send e-mail every minute to the www.spam.la site. All this script does is to retrieve the e-mail header from spam.la ( no login!), filtering sender, stopping at the first occurrence of the word "secs" ( the age of the last e-mail ). The result is the age of the sender's last e-mail, tiny published on top of my screen once a minute. I can refresh www.spam.la via web browser, but have other things to do. I use it inside Kalarm ( kde task schedule ) set to 1 minute repeat. It can be done without kalarm, using Watch outside the script. Try it out now using my account = geo1 ( change sender by geo1 in this script) Needs curl , osd-bin


    -1
    curl http://www.spam.la/?f=sender | grep secs| awk '{print; exit}' | osd_cat -i 40 -d 30 -l 2
    m33600 · 2009-11-12 21:33:06 6
  • Easy way to find your computers IP in one place, ie, twitter It suppress the need of dyndns clients and remembering the complex names they give you. I put it inside KAlarm ( the cron GUI for KDE, ubuntu), to update my ip every 3 minutes. I did not add the cron statements to keep the code clean. Show Sample Output


    -1
    STAT=`curl http://www.whatismyip.org/`; curl -u YourUserName:YourPassword -d status=$STAT http://twitter.com/statuses/update.xml
    m33600 · 2009-10-26 23:02:30 6
  • Strip my code to: wmctrl -o 0,0 # autorotates to the first face. In fact [0-1279],0 wmctrl - 1280,0 # goes to the second face wmctrl -o 2560,0 # goes to the third face, and so on. # Use multiples of the horizontal display resolution. My example work for 1280x800 display, been 1280 the number of interest. Tweak the number, try a biiiig one and see your cube spinning... I put a complex example to show how fun things can be, even for my ademco and paradox alarm central network advisor interface xpto etc. It rotates two faces, print the alarm message, and goes back tho where it was. Tested on BIGLINUX 4.2, equivalent to ubuntu LTS hardy. Do not forget to activate 3D efects ( compiz cube ) Show Sample Output


    5
    wmctrl -o 2560,0 ;sleep 2 ; echo "FIRE 001" | osd_cat -o 470 -s 8 -c red -d 10 -f -*-bitstream\ vera\ sans-*-*-*--250-*-*-*-*-*-*-* ; sleep 1; wmctrl -o 0,0
    m33600 · 2009-10-23 10:00:51 17
  • already described on the other two versions, this one uses ascii characters on game style to display elapsed time. Show Sample Output


    0
    export I=$(date +%s); watch -t -n 1 'T=$(date +%s);E=$(($T-$I));hours=$((E / 3600)) ; seconds=$((E % 3600)) ; minutes=$((seconds / 60)) ; seconds=$((seconds % 60)) ; echo $(printf "%02d:%02d:%02d" $hours $minutes $seconds) | toilet -f shadow'
    m33600 · 2009-10-23 07:56:30 10
  • Variation of the theme, this one blinks in low profile on top level of X, ie, it is visible, indeed small. Try changing fonts and sizes of osd_cat


    0
    export I=$(date +%s); watch -t -n 1 'T=$(date +%s);E=$(($T-$I));hours=$((E / 3600)) ; seconds=$((E % 3600)) ; minutes=$((seconds / 60)) ; seconds=$((seconds % 60)) ; echo $(printf "%02d:%02d:%02d" $hours $minutes $seconds) | osd_cat -o 20 -d 1 -p bottom'
    m33600 · 2009-10-23 07:47:11 3
  • Works on real time clock, unix time based, decrementing the actual time from initial time saved in an environment variable exported to child process inside watch Shows elapsed time from start of script in hh:mm:ss format Non afected by system slow down due to the use of date.


    3
    export I=$(date +%s); watch -t -n 1 'T=$(date +%s);E=$(($T-$I));hours=$((E / 3600)) ; seconds=$((E % 3600)) ; minutes=$((seconds / 60)) ; seconds=$((seconds % 60)) ; echo $(printf "%02d:%02d:%02d" $hours $minutes $seconds)'
    m33600 · 2009-10-23 07:31:44 8
  • My firefox overheats my cpu, sometimes above 90 degrees Celsius ( hence the name? ) To keep an eye on temperature, I put this command inside KAlarm ( a kind of cron) to be repeated every minute, for 5 seconds, color red ( default for osd_cat). Its pretty, ultra small, displays a micro 2 lines text on every desktop and over everything and do not steal focus or interrupt any task. I get the information passively, in the low profile bottom of the screen. Of course you can use it inside a terminal. Just do it: watch -n 60 'acpi -t | osd_cat -p bottom'


    2
    acpi -t | osd_cat -p bottom
    m33600 · 2009-10-23 05:22:01 3
  • Usefull as a light blink to remember events, mails, intrusions, etc... yet another output Since nobody ever uses the scroll lock function... Usefull to interface a linux system with some hardware, for example, opto interfacing the keyboard led to a relay to remotely reset, etc. ( a simple LDR glued over the LED will do the trick ) xset led 3 turns on the third led, ie, Scroll lock xset -led 3 turns it off xset led 1 turns on Numerical Lock led ( doesn t work on all computer ) xset led 2 turns on Caps Lock led ( idem ) Using it as a reset watchdog, the relay expected light pulses. Shall the computer hangs, the relay releases and reset the machine ( discharge of a capacitor ) ;-)


    5
    xset led 3
    m33600 · 2009-10-23 00:25:56 15
  • This time I added a print to reemaining energy, every minute, time stamped. The example shown here is complete and point to large discrepancies as time passes, converging to accuracy near the end. Show Sample Output


    1
    echo start > battery.txt; watch -n 60 'date >> battery.txt ; acpi -b >> battery.txt'
    m33600 · 2009-10-19 05:28:15 4
  • Fully recharge your computer battery and start this script. It will create or clean the file named battery.txt, print a start on it and every minute it will append a time stamp to it. Batteries last few hours, and each hour will have 60 lines of time stamping. Really good for assuring the system was tested in real life with no surprises. The last time stamp inside the battery.txt file is of interest. It is the time the computer went off, as the battery was dead! Turn on your computer after that, on AC power of course, and open battery.txt. Read the first and last time stamps and now you really know if you can trust your computer sensors. If you want a simple line of text inside the battery.txt file, use this: watch -n 60 'date > battery.txt' The time of death will be printed inside Show Sample Output


    0
    echo start > battery.txt; watch -n 60 'date >> battery.txt'
    m33600 · 2009-10-18 07:00:26 4
  • Found it on snipt, pok3, is it yours? I put my user = m33600, the password and the status was my robot message: Settima robot message: ALARM ZONE 3 (sent via command line). Now bots may have their identity on twitter... Show Sample Output


    2
    curl -u YourUsername:YourPassword -d status="Your status message go here" http://twitter.com/statuses/update.xml
    m33600 · 2009-06-27 21:47:48 12
  • w3m is a commanline web browser, full of options, I used -dump_head for less unnecessary page download. With awk, I can retrieve dynamic changes in webpages in this very econnomical fashion Show Sample Output


    -1
    w3m -dump_head www.fiat.com | awk '/Date+/{print $6, $7}'
    m33600 · 2009-06-08 00:06:01 7
  • evento.sh needed for awk syntax the aplay command makes a camera sound. It takes a picture of who looked at the display #!/bin/bash # evento.sh: deteta evento e fala awk '{print}' | espeak -v pt -stdin awk '/e/{print "emergencia"}' | espeak -v pt -stdin aplay -q /home/mm/bash/camera.wav # -q inibe verbose do comand aplay exit 0


    -7
    watch '/home/mm/bash/keypress.sh |/home/mm/bash/evento.sh'
    m33600 · 2009-06-07 20:57:49 5
  • Speaks whatever comes in via stdin (-v pt = portuguese, default = englisg) ..speech part of keyboard event talker. Made to accomplish a simple alarm central based on a cheap keyboard circuit. This way I have one zone per direct keypress. Depends on keypress.sh. It speaks out loud wich zone (key) has been pressed ( faulted ). Here is keypress.sh : #!/bin/bash # keypress.sh: Detect a user keypress ("hot keys"). echo old_tty_settings=$(stty -g) # Save old settings (why?). stty -icanon Keypress=$(head -c1) # or $(dd bs=1 count=1 2> /dev/null) # on non-GNU systems aplay -q /home/mm/bash/beep-1.wav echo echo "Chamada quarto \""$Keypress"\"." echo stty "$old_tty_settings" # Restore old settings. # Thanks, Stephane Chazelas. exit 0


    0
    awk '{print}' | espeak -v pt -stdin
    m33600 · 2009-06-07 20:45:44 5

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

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"

Grep without having it show its own process in the results
The trick here is to use the brackets [ ] around any one of the characters of the grep string. This uses the fact that [?] is a character class of one letter and will be removed when parsed by the shell. This is useful when you want to parse the output of grep or use the return value in an if-statement without having its own process causing it to erroneously return TRUE.

Show highlighted text with full terminal width
Show a full terminal line inverted with custom text.

Download SSL/TLS pem format cert from https web host

Search through all installed packages names (on RPM systems)
You can use wildcard with rpm search but you have to do 2 things: 1. use "-a" switch (means "all") with query ("-q") switch - argument is a pattern to use while searching for package names of all installed packages 2. protect wildcards, so that shell could not eat them - escape it with backslash ("\") or enclose all pattern between apostrophes ("'"): $ rpm -qa 'co*de' As you can see above it is possible to insert wildcards into middle of the pattern. If you want, you can add "-i" or another rpm query options, "-i" will print package information for all installed packages matching pattern.

split a string (2)

disable history for current shell session
this will cause any commands that you have executed in the current shell session to not be written in your bash_history file upon logout

du and sort to find the biggest directories in defined filesystem
This command give a human readable result without messing up the sorting.

Get AWS temporary credentials ready to export based on a MFA virtual appliance
You might want to secure your AWS operations requiring to use a MFA token. But then to use API or tools, you need to pass credentials generated with a MFA token. This commands asks you for the MFA code and retrieves these credentials using AWS Cli. To print the exports, you can use: `awk '{ print "export AWS_ACCESS_KEY_ID=\"" $1 "\"\n" "export AWS_SECRET_ACCESS_KEY=\"" $2 "\"\n" "export AWS_SESSION_TOKEN=\"" $3 "\"" }'` You must adapt the command line to include: * $MFA_IDis ARN of the virtual MFA or serial number of the physical one * TTL for the credentials

delete all bitbucket repos via rest API v2 (req: jq and curl)
bitbucket paginates at around 1360 characters, so if you have several pages of repos in git hub you can just add "?page={1..4}" the url used to get all the repos. you can also use -v for the deletion curl if you want to see the response from the server.


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: