All commands (14,187)

  • This doesn't make any assumptions about your IP address and prints out one IP address per line if you have multiple network interfaces. Show Sample Output


    -3
    ifconfig | sed '/.*addr.*Bcast.*/ ! d'| sed 's/.*addr:\([0-9\.]*\).*/\1/'
    Haegin · 2010-03-26 08:13:13 3
  • This assumes your local ip starts with 192.something (e.g. 192.168), it greps ifconfig output for an ip that starts with 192, then strips the extra garbage (besides the ip) Maybe `ifconfig | grep addr | grep Bcast` would also do it Show Sample Output


    -5
    ifconfig | grep addr:192 | sed s/Bcast.*// | sed 's/^.*inet addr://'
    hasenj · 2010-03-26 07:37:21 4
  • This is useful for examining the path. Show Sample Output


    6
    printf ${PATH//:/\\n}
    haivu · 2010-03-26 04:37:33 5
  • Okay, Jimmy, the command 'optical-monitor' is needed within the global config. for this command to work (and if supported by your licsense: yada yada, blah, blah). But, like its mad PHAT Kid, you dig? Basically, a Foundry/Brocade switch is reading the Laser light levels just like those Fiber test kits from Owl that cost 4k. I know, I also find it hard to contain myeself ;-) No really..... Show Sample Output


    -3
    show optic <slot #>
    rootgeek · 2010-03-26 03:07:22 3
  • You need all those commands, in the sample output. I had some of this, but had to play, add remove, type random stuff like a monkey to finally get this working (clearly those IP's are fake to protect the guilty, and so is the key). Show Sample Output


    -3
    aaa authentication login default local tacacs+
    rootgeek · 2010-03-26 02:58:03 3
  • This is how you make sure that ports in a VLAN remain, root ports. Typically, you would use this command on all your Core-1 switch VLAN ports, and then use 'rstp priority 1' on all your Core-2 switches. This is if you have a dual L3 core that is. Show Sample Output


    -3
    rstp priority 0
    rootgeek · 2010-03-26 02:51:54 3
  • 'no untag' is applied to _all_ ports under the default VLAN. Otherwise the default VLAN runs untagged over all physical ports. Pretty good idea to 'prune' your VLANs and define which ones pass over and across trunks that carry the default VLAN traffic. Show Sample Output


    -3
    no untag
    rootgeek · 2010-03-26 02:45:32 3
  • The sample output, is the command with a ?, to show you all the stuff you can look at. Show Sample Output


    -4
    dm ?
    rootgeek · 2010-03-26 02:42:21 3
  • The sample output, is a display of the values you can change, using this command. After a change of of these settings you will need to reload the box, by typing...wait...wait for IT: 'reload'. This comes in handy when working with the RX hardware, for example, which has a base limitation of 32 (RSTP (802-1w) instances. For all of you paying attention that means if you run RSTP on a RX you can only have 32 VLANs. Sure, you can have common groups of VLANs, like back in the day style MSTP, PVST, PVST+ (and all that old STP (802.1d) mess), before "per vlan spanning-tree", RSTP (802-1w), was made. But who wants to do all that? Show Sample Output


    -2
    system max <some value>
    rootgeek · 2010-03-26 02:39:00 5

  • -4
    sh default values
    rootgeek · 2010-03-26 02:36:57 4
  • Here "^M" is NOT "SHIFT+6" and "M". Type CTRL+V+M to get it instead. Its shortest and easy. And its sed!, which is available by default in all linux flavours.. no need to install extra tools like fromdos.


    4
    sed -i 's/^M//' file
    sata · 2010-03-25 19:34:08 7
  • This is easy to type if you are looking for a few (hundred) "missing" megabytes (and don't mind the occasional K slipping in)... A variation without false positives and also finding gigabytes (but - depending on your keyboard setup - more painful to type): du -hs *|grep -P '^(\d|,)+(M|G)'|sort -n (NOTE: you might want to replace the ',' according to your locale!) Don't forget that you can modify the globbing as needed! (e.g. '.[^\.]* *' to include hidden files and directories (w/ bash)) in its core similar to: http://www.commandlinefu.com/commands/view/706/show-sorted-list-of-files-with-sizes-more-than-1mb-in-the-current-dir Show Sample Output


    3
    du -hs *|grep M|sort -n
    tuxlifan · 2010-03-25 19:20:24 4
  • Finds all C++, Python, SWIG files in your present directory (uses "*" rather than "." to exclude invisibles) and counts how many lines are in them. Returns only the last line (the total). Show Sample Output


    2
    find * \( -name "*.[hc]pp" -or -name "*.py" -or -name "*.i" \) -print0 | xargs -0 wc -l | tail -n 1
    neologism · 2010-03-25 18:58:29 4

  • 2
    ls -d $(echo ${PATH//:/ }) > /dev/null
    ger · 2010-03-25 17:38:57 3
  • Using this command one can cut a piece from the end of an audio file.


    1
    sox input.wav output.wav reverse trim 00:00:00.3 reverse
    bodo · 2010-03-25 13:38:44 3

  • -2
    printf "%.50d" 0 | tr 0 -
    sata · 2010-03-25 12:52:45 3
  • essentially the ruby one, but perhaps has a larger installed base


    9
    python -c 'print "-"*50'
    funky · 2010-03-25 11:09:30 6
  • This feels more intuitive to me.


    1
    for i in `seq 1 1 50`; do echo -n -; done
    Gosha · 2010-03-25 10:22:19 3

  • 5
    svn log -r {`date +"%Y-%m-%d" -d "1 month ago"`}:HEAD|grep '^r[0-9]' |cut -d\| -f2|sort|uniq -c
    ivanatora · 2010-03-25 09:43:15 4
  • Get there by going backwards and forgetting the numbers.


    5
    seq -s" " -50 -1 | tr -dc -
    DoNotRememberMe · 2010-03-25 06:00:24 32
  • If you want to relocate a package on your own, or you just want to know what those PREIN/UN and POSTIN/UN scripts will do, this will dump out all that detail simply. You may want to expand the egrep out other verbose flags like CHANGELOGTEXT etc, as your needs require. It isn't clear, but the formatting around $tag is important: %{$tag} just prints out the first line, while [%{$tag }] iterates thru multi-line output, joining the lines with a space (yes, there's a space between the g and } characters. To break it out for all newlines, use [%{$tag\n}] but the output will be long. This is aside from rpm2cpio | cpio -ivd to extract the package files.


    0
    rpm --querytags | egrep -v HEADERIMMUTABLE | sort | while read tag ; do rpm -q --queryformat "$tag: [%{$tag} ]\n" -p $SomeRPMfile ; done
    DoNotRememberMe · 2010-03-25 05:40:48 3
  • The example is a little bit bogus, but applies to any command that takes a while interactively, or might be a bit of a drag on system resources. Once the command's output is saved to a variable, you can then echo "$OUTPUT" to see it in multi-line glory after that. The use of double-quotes around the backticks and during the variable expansion disables any IFS conversion during those two operations. Very useful for reporting that might pull different lines out, like from dmidecode, inq or any other disk detail command. The only caveat is that storing too much in a variable might make your shell process grow.


    0
    OUTPUT="`find / -type f`" ; echo "$OUTPUT" | grep sysrq ; echo "$OUTPUT" | grep sysctl ; echo "$OUTPUT" | less
    DoNotRememberMe · 2010-03-25 05:02:10 5
  • I had problems in Ubuntu while trying to edit /etc/resolv.conf, even with sudo I couldn't make any change. After a 2 minutes search on google I found this command. Hope someone finds it useful. It works like chmod, with + and - to denote which attributes are being added and which are being removed. See other attributes on man pages or on wikipedia http://en.wikipedia.org/wiki/Chattr


    1
    sudo chattr -i <file that cannot be modified>
    leovailati · 2010-03-25 03:14:34 4

  • 2
    aptitude search '~i!~E' | grep -v "i A" | cut -d " " -f 4
    XORwell · 2010-03-25 00:40:51 6
  • Write a file you edited in Vim but that you do not have the permissions to write to (unless you use sudo.) Same as #1204 but without the echo to stdout that I find annoying.


    32
    :w !sudo tee > /dev/null %
    idemal · 2010-03-24 20:04:26 13
  • ‹ First  < 388 389 390 391 392 >  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

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"

Rename files in batch

Download an Entire website with wget

Set laptop display brightness
Run as root. Path may vary depending on laptop model and video card (this was tested on an Acer laptop with ATI HD3200 video). $ cat /proc/acpi/video/VGA/LCD/brightness to discover the possible values for your display.

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

a short counter
Maybe you know shorter ?

Log colorizer for OSX (ccze alternative)
Download colorizer by @raszi @ http://github.com/raszi/colorize

add all files not under version control to repository
This should handle whitespaces well and will not get confused if your filenames have "?" in them

back ssh from firewalled hosts
host B (you) redirects a modem port (62220) to his local ssh. host A is a remote machine (the ones that issues the ssh cmd). once connected port 5497 is in listening mode on host B. host B just do a ssh 127.0.0.1 -p 5497 -l user and reaches the remote host'ssh. This can be used also for vnc and so on.

Happy Days
AFAIR this is the wording ;)


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: