Commands matching ls (1,289)

  • Usage: flight_status airline_code flight_number (optional)_offset_of_departure_date_from_today So for instance, to track a flight which departed yesterday, the optional 3rd parameter should have a value of -1. eg. flight_status ua 3655 -1 output --------- Status: Arrived Departure: San Francisco, CA (SFO) Scheduled: 6:30 AM, Jan 3 Takeoff: 7:18 AM, Jan 3 Term-Gate: Term 1 - 32A Arrival: Newark, NJ (EWR) Scheduled: 2:55 PM, Jan 3 At Gate: 3:42 PM, Jan 3 Term-Gate: Term C - C131 Note: html2text needs to be installed for this command. only tested on ubuntu 9.10 Show Sample Output


    19
    flight_status() { if [[ $# -eq 3 ]];then offset=$3; else offset=0; fi; curl "http://mobile.flightview.com/TrackByRoute.aspx?view=detail&al="$1"&fn="$2"&dpdat=$(date +%Y%m%d -d ${offset}day)" 2>/dev/null |html2text |grep ":"; }
    suhasgupta · 2010-01-04 15:49:09 19
  • Tested in Linux and OSX Show Sample Output


    19
    lsof -Pni4 | grep LISTEN
    evenme · 2009-08-21 22:51:41 70
  • If you are already running screen then you often want to start a command in a fresh window. You use this alias by typing 's whatever' from your command line and 'whatever' starts running in a new window. Good with interactive commands like info, vim, and nethack.


    19
    alias s='screen -X screen'; s top; s vi; s man ls;
    jonty · 2009-02-05 13:47:14 38
  • Particularly useful on OS X where netstat doesn't have -p option. Show Sample Output


    18
    lsof -i -P | grep -i "listen"
    patko · 2010-10-14 09:37:51 10
  • This command finds and prints all the symbolic and hard links to a file. Note that the file argument itself be a link and it will find the original file as well. You can also do this with the inode number for a file or directory by first using stat or ls or some other tool to get the number like so: stat -Lc %i file or ls -Hid file And then using: find -L / -inum INODE_NUMBER -exec ls -ld {} +


    17
    find -L / -samefile /path/to/file -exec ls -ld {} +
    eightmillion · 2011-04-27 06:14:15 8
  • shorter than alternative


    17
    printf "%`tput cols`s"|tr ' ' '#'
    kamathln · 2010-04-05 17:12:35 9
  • If your last command was a dud, your bash prompt will be angry at you. Otherwise it's happy. Soon you will crave its constant approval and your linux skills will improve simply to avoid low self-esteem. Show Sample Output


    17
    PS1="\`if [ \$? = 0 ]; then echo \e[33\;40m\\\^\\\_\\\^\e[0m; else echo \e[36\;40m\\\-\e[0m\\\_\e[36\;40m\\\-\e[0m; fi\` \u \w:\h)"
    digitalsushi · 2009-06-30 14:29:55 376
  • I have come across a situation in the past where someone has unlinked a file by running an 'rm' command against it while it was still being written to by a running process. The problem manifested itself when a 'df' command showed a filesystem at 100%, but this did not match the total value of a 'du -sk *'. When this happens, the process continues to write to the file but you can no longer see the file on the filesystem. Stopping and starting the process will, more often than not, get rid of the unlinked file, however this is not always possible on a live server. When you are in this situation you can use the 'lsof' command above to get the PID of the process that owns the file (in the sample output this is 23521). Run the following command to see a sym-link to the file (marked as deleted): cd /proc/23521/fd && ls -l Truncate the sym-link to regain your disk space: > /proc/23521/fd/3 I should point out that this is pretty brutal and *could* potentially destabilise your system depending on what process the file belongs to that you are truncating. Show Sample Output


    16
    lsof +L1
    dopeman · 2010-07-14 17:21:01 6
  • View all files opened by a user in specified directory. The +D option makes lsof search all sub-directories to complete depth, while ignoring symbolic links.


    16
    sudo lsof -u someuser -a +D /etc
    zlemini · 2010-06-11 06:37:27 6
  • This is a very simple and lightweight way to play DI.FM stations For a more complete version of the command with proper strings in the menu, try: (couldnt fit in the command field above) zenity --list --width 500 --height 500 --title 'DI.FM' --text 'Pick a Radio' --column 'radio' --column 'url' --print-column 2 $(curl -s http://www.di.fm/ | awk -F '"' '/href="http:.*\.pls.*96k/ {print $2}' | sort | awk -F '/|\.' '{print $(NF-1) " " $0}') | xargs mplayer This command line parses the html returned from http://di.fm and display all radio stations in a nice graphical menu. After the radio is chosen, the url is passed to mplayer so the music can start dependencies: - x11 with gtk environment - zenity: simple app for displaying gtk menus (sudo apt-get install zenity on ubuntu) - mplayer: simple audio player (sudo apt-get install mplayer on ubuntu) Show Sample Output


    16
    zenity --list --width 500 --height 500 --column 'radio' --column 'url' --print-column 2 $(curl -s http://www.di.fm/ | awk -F '"' '/href="http:.*\.pls.*96k/ {print $2}' | sort | awk -F '/|\.' '{print $(NF-1) " " $0}') | xargs mplayer
    polaco · 2010-04-28 23:45:35 14
  • The "-r 2" option puts lsof in repeat mode, with updates every 2 seconds. (Ctrl -c quits) The "-p" option is used to specify the application PID you want to monitor. The "-u' option can be used to keep an eye on a users network activity. "lsof -r 2 -u username -i -a"


    16
    lsof -r 2 -p PID -i -a
    zlemini · 2010-03-16 20:37:16 18
  • I'm working in a group project currently and annoyed at the lack of output by my teammates. Wanting hard metrics of how awesome I am and how awesome they aren't, I wrote this command up. It will print a full repository listing of all files, remove the directories which confuse blame, run svn blame on each individual file, and tally the resulting line counts. It seems quite slow, depending on your repository location, because blame must hit the server for each individual file. You can remove the -R on the first part to print out the tallies for just the current directory. Show Sample Output


    16
    svn ls -R | egrep -v -e "\/$" | xargs svn blame | awk '{print $2}' | sort | uniq -c | sort -r
    askedrelic · 2009-07-29 02:10:45 16
  • The URL can then be pasted with a middle click. This is probably useful when trying to explain problems over instant messaging when you don't have some sort of shared desktop.


    16
    ls | curl -F 'sprunge=<-' http://sprunge.us | xclip
    tatwright · 2009-06-06 11:35:14 19
  • List the files a process is using.


    16
    lsof +p xxxx
    rockon · 2009-03-02 04:49:23 18
  • parse "lsmod" output to "dot" format and pass it to "display". Without perl!


    15
    lsmod | awk 'BEGIN{print "digraph{"}{split($4, a, ","); for (i in a) print $1, "->", a[i]}END{print "}"}'|display
    point_to_null · 2011-12-04 01:41:23 7
  • You can convert any UNIX man page to .txt


    15
    man ls | col -b > ~/Desktop/man_ls.txt
    vigo · 2009-06-13 11:49:33 18
  • this leaves the cursor at the bottom of the terminal screen, where your eyes are. ctrl-l moves it to the top, forcing you to look up.


    14
    cls(){ printf "\33[2J";} or, if no printf, cat >cls;<ctrl-v><ctrl+[>[2J<enter><ctrl+d> cls(){ cat cls;}
    argv · 2011-04-06 01:51:45 17
  • Plot your most used commands with gnuplot.


    14
    history | awk '{a[$2]++}END{for(i in a){print a[i] " " i}}' | sort -rn | head > /tmp/cmds | gnuplot -persist <(echo 'plot "/tmp/cmds" using 1:xticlabels(2) with boxes')
    sthrs · 2010-06-13 23:35:13 7
  • Ever since the switch to pulseaudio, Ubuntu users including myself have found themselves with no sound intermittently. To fix this, just use this command and restarts firefox or mplayer or whatever.


    14
    sudo killall -9 pulseaudio; pulseaudio >/dev/null 2>&1 &
    hank · 2009-04-11 20:18:35 8
  • It may be helpful in case you need to umount a directory and some process is preventing you to do so keeping the folder busy. The lsof may process the +D option slowly and may require a significant amount of memory because it will descend the full dir tree. On the other hand it will neither follow symlinks nor other file systems.


    13
    lsof +D <dirname>
    ztank1013 · 2011-09-18 00:01:25 4
  • Commandlinefu.com is great but has a few bugs when people are submitting new commands: . 1. There is no preview button. This was a minor inconvenience before, but now is a major problem since new commands won't show up to be edited until they have been moderated. . 2. White space in the description field and in the comments is almost completely lost. People resort to using periods in between paragraphs to force a line break. Indentation of code is ridiculous. . 3. Many characters get munged. . 3a. For example, a less than character in the description gets read as an HTML tag and discarded. In order to type a less than, I've had to type "&lt;" (I hope that comes out right). Unfortunately, when re-editing a command, the HTML entity is turned into a literal less than character, which I have to change back by hand before saving. 3b. Some unicode characters work in the description field, but turn into ugly literal HTML strings when put in the sample output or in an additional command using the $ prefix. . For example, here is a unicode character: ❥ Here is the same character after a dollar sign: &#10085; . 3c. Some unicode characters don't work anywhere. Bizarrely, it appears to be the most commonly needed ones, such as Latin-1 accented characters. Here are some examples, . Bullet: ?, Center dot: ?, Umlaut u: ?. . 4. Here is an example of the greater than, >, and less than, . 5. Commandlinefu used to abbreviate long descriptions on the front page and had a "more..." button so that people could read the rest if they wanted. That's a good feature as it encourages people to explain their commands more fully. Either, the feature has gone missing, or, perhaps, I was just hallucinating it existed in the first place. If the former, please bring it back, If the latter, please implement this great new feature I just thought up. . 6. Tags cannot include Unicode characters. If you try to type one in, the cursor will just spin and spin as it attempt to look up if that tag exists already. For example, try typing Ctrl+Shift+u 2 7 6 5 SPC as a tag name. Show Sample Output


    13
    echo "?????, these are the umlauted vowels I sing to you. Oh, and sometimes ?, but I don't sing that one cause it doesn't rhyme."
    hackerb9 · 2011-01-05 05:56:20 9
  • I prefer to use this and not the -n variety, so I get DNS-resolved hostnames. Nice when I'm trying to figure out who's got that port open.


    13
    lsof -i
    unixmonkey4503 · 2009-06-30 22:36:00 8
  • Merge all pdf files in the directory into one pdf file (the out.pdf file)


    13
    gs -q -sPAPERSIZE=letter -dNOPAUSE -dBATCH -sDEVICE=pdfwrite -sOutputFile=out.pdf `ls *.pdf`
    oops66 · 2009-03-13 22:34:14 40
  • That is useful to discover the start time of process older than 1 day. You can also run: ls -ld /proc/PID That's returning the creation date of the proc files from the process. Some users reported that this way might show you a wrong date since any other process like cron, for example, could change this date. Show Sample Output


    12
    ps -eo pid,lstart,cmd
    kruspemsv · 2013-06-17 12:52:53 15

  • 12
    dpkg -S $( which ls )
    rubenmoran · 2011-02-09 10:28:58 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

Quickly re-execute a recent command in bash
! will expand to the last time you ran , options and all. It's a nicer alternative to ^R for simple cases, and it's quite helpful for those long commands you run every now and then and haven't made aliases or functions for. It's similar to command 3966, in some sense.

Look for English words in /dev/urandom
* to get the English dictionary: wget http://www.mavi1.org/web_security/wordlists/webster-dictionary.txt

HTTP GET request on wireshark remotly

Find out if a module is installed in perl
Shows the path if the module is installed or exit quietly (to simply avoid the 'No documentation found' msg).

diff the same file in two directories.
This is useful when you're diffing two files of the same name in radically different directory trees. For example: Set $ path1='/some/long/convoluted/path/to/all/of/your/source/from/a/long/dead/machine' then $ path2='/local/version/of/same/file' then run the command. Much easier on the eyes when you're looking back across your command history, especially if you're doing the same diff over and over again.

connects to db2 database instance/alias "stgndv2" user "pmserver" using password "xxxxxxx"
db2 => ? connect CONNECT [USER username [{USING password [NEW new-password CONFIRM confirm-password] | CHANGE PASSWORD}]] CONNECT RESET CONNECT TO database-alias [IN {SHARE MODE | EXCLUSIVE MODE [ON SINGLE DBPARTITIONNUM]}] [USER username [{USING password [NEW new-password CONFIRM confirm-password] | CHANGE PASSWORD}]]

blktrace - generate traces of the i/o traffic on block devices
blktrace is a block layer IO tracing mechanism which provide detailed information about request queue operations up to user space. blkparse will combine streams of events for various devices on various CPUs, and produce a formatted output the the event information. It take the output of above tool blktrace and convert those information into fency readable form.

Convert CSV to JSON
Replace 'csv_file.csv' with your filename.

Multiple variable assignments from command output in BASH
No command substitution but subshell redirection

files and directories in the last 1 hour
added alias in ~/.bashrc alias lf='find ./* -ctime -1 | xargs ls -ltr --color'


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: