Commands matching ls (1,289)

  • This is an alternative to cron which allows a one-off task to be scheduled for a certain time.


    266
    echo "ls -l" | at midnight
    root · 2009-01-25 21:07:42 85
  • A nice way to use the console in full screen without forget the current time. you can too add other infos like cpu and mem use. Show Sample Output


    148
    while sleep 1;do tput sc;tput cup 0 $(($(tput cols)-29));date;tput rc;done &
    glaudiston · 2011-02-17 11:13:19 80

  • 101
    lsof -i
    hank · 2009-04-25 14:24:04 24

  • 99
    lsof -P -i -n
    OJM · 2009-09-19 18:28:48 33
  • Prints a graphical directory tree from your current directory Show Sample Output


    62
    ls -R | grep ":$" | sed -e 's/:$//' -e 's/[^-][^\/]*\//--/g' -e 's/^/ /' -e 's/-/|/'
    unixmonkey842 · 2009-02-15 20:43:21 25
  • This is the result of a several week venture without X. I found myself totally happy without X (and by extension without flash) and was able to do just about anything but watch YouTube videos... so this a the solution I came up with for that. I am sure this can be done better but this does indeed work... and tends to work far better than YouTube's ghetto proprietary flash player ;-) Replace $i with any YouTube ID you want and this will scrape the site for the _real_ URL to the full quality .FLV file on Youtube's server and will then will hand that over to mplayer (or vlc or whatever you want) to be streamed. In some browsers you can replace $i with just a % or put this in a shell script so all YouTube IDs can be handed directly off to your media player of choice for true streaming without the need for Flash or a downloader like clive. (I do however fully recommend clive if you wish to archive videos instead of streaming them) If any interest is shown I would be more than happy to provide similar commands for other sites. Most streaming flash players use similar logic to YouTube. Edit: 05/03/2011 - Updated line to work with current YouTube. It could be a lot prettier but I will probably follow up with another update when I figure out how to get rid of that pesky Grep. Sed should take that syntax... but it doesn't. Original (no longer working) command: mplayer -fs $(echo "http://youtube.com/get_video.php?$(curl -s $youtube_url | sed -n "/watch_fullscreen/s;.*\(video_id.\+\)&title.*;\1;p")") Show Sample Output


    58
    i="8uyxVmdaJ-w";mplayer -fs $(curl -s "http://www.youtube.com/get_video_info?&video_id=$i" | echo -e $(sed 's/%/\\x/g;s/.*\(v[0-9]\.lscache.*\)/http:\/\/\1/g') | grep -oP '^[^|,]*')
    lrvick · 2009-03-09 03:57:44 53
  • 'dpkg -S' just matches the string you supply it, so just using 'ls' as an argument matches any file from any package that has 'ls' anywhere in the filename. So usually it's a good idea to use an absolute path. You can see in the second example that 12 thousand files that are known to dpkg match the bare string 'ls'. Show Sample Output


    45
    dpkg -S /usr/bin/ls
    bwoodacre · 2009-04-18 18:18:23 25
  • This command takes a snapshot of the open files for a PID 1234 then waits 10 seconds and takes another snapshot of the same PID, it then displays the difference between each snapshot to give you an insight into what the application is doing.


    42
    diff <(lsof -p 1234) <(sleep 10; lsof -p 1234)
    zlemini · 2010-03-15 22:55:32 13
  • Sometimes you need to use a port that is already opened by some program , and you don't know who to "kill" for it to release - so, now you do ! Show Sample Output


    41
    lsof -i tcp:80
    ar_levi · 2009-04-16 14:51:53 25
  • -d: list directory entries instead of contents, and do not dereference symbolic links


    39
    ls -d */
    brianmuckian · 2009-10-08 22:07:22 28
  • parse `lsmod' output and pass to `dot' drawing utility then finally pass it to an image viewer


    35
    lsmod | perl -e 'print "digraph \"lsmod\" {";<>;while(<>){@_=split/\s+/; print "\"$_[0]\" -> \"$_\"\n" for split/,/,$_[3]}print "}"' | dot -Tpng | display -
    bandie91 · 2011-11-27 14:02:35 22
  • show only the name of the apps that are using internet Show Sample Output


    35
    lsof -P -i -n | cut -f 1 -d " "| uniq | tail -n +2
    edo · 2009-09-19 21:23:54 25
  • Negative shell globs already come with bash. Make sure to turn on extended pattern matching with 'shopt -e extglob'.


    31
    ls !(*.gz)
    c0t0d0 · 2010-07-29 23:47:26 9
  • You have an external USB drive or key. Apply this command (using the file path of anything on your device) and it will simulate the unplug of this device. If you just want the port, just type : echo $(sudo lshw -businfo | grep -B 1 -m 1 $(df "/path/to/file" | tail -1 | awk '{print $1}' | cut -c 6-8) | head -n 1 | awk '{print $1}' | cut -c 5- | tr ":" "-") Show Sample Output


    30
    echo $(sudo lshw -businfo | grep -B 1 -m 1 $(df "/path/to/file" | tail -1 | awk '{print $1}' | cut -c 6-8) | head -n 1 | awk '{print $1}' | cut -c 5- | tr ":" "-") | sudo tee /sys/bus/usb/drivers/usb/unbind
    tweet78 · 2014-04-06 12:06:29 19
  • This command is more portable than it's cousin netstat. It works well on all the BSDs, GNU/Linux, AIX and Mac OS X. You won't find lsof by default on Solaris or HPUX by default, but packages exist around the web for installation, if needed, and the command works as shown. This is the most portable command I can find that lists listening ports and their associated pid. Show Sample Output


    29
    lsof -Pan -i tcp -i udp
    atoponce · 2010-06-07 15:22:44 13
  • After the command is done, open the html file in a browser


    29
    lshw -html > hardware.html
    flart · 2009-06-04 07:14:03 16
  • (relies on 'imagemagick') This command will convert all .pdf files in a directory into a 800px (wide or height, whichever is smaller) image (with the aspect ratio kept) .jpg. If the file is named 'example1.pdf' it will be named 'example1.jpg' when it is complete. This is a VERY worthwhile command! People pay hundreds of dollars for this in the Windows world. My .jpg files average between 150kB to 300kB, but your's may differ. Show Sample Output


    29
    for file in `ls *.pdf`; do convert -verbose -colorspace RGB -resize 800 -interlace none -density 300 -quality 80 $file `echo $file | sed 's/\.pdf$/\.jpg/'`; done
    brettalton · 2009-02-15 23:27:43 20
  • I often use it to find recently added ou removed device, or using find in /dev, or anything similar. Just run the command, plug the device, and wait to see him and only him Show Sample Output


    28
    diff <(lsusb) <(sleep 3s && lsusb)
    Juluan · 2010-12-27 22:46:54 57
  • the -x option is for binding to a shell command


    27
    bind -x '"\C-l":ls -l'
    roalddevries · 2010-12-25 22:55:33 8
  • List all file opened by a particular command based on it's command name. Show Sample Output


    25
    lsof -c dhcpd
    d4n3sh · 2009-04-17 07:18:38 11
  • Now type Ctrl-l and it will list all files


    23
    bind '"\C-l":"ls -l\n"'
    strzel_a · 2010-11-19 09:14:16 13

  • 23
    ls -Q
    stubby · 2010-08-17 15:01:50 13
  • I like the fact the Patola's version uses only ones and zeros, but I also like the sparse output of the other versions. This one combines both of those features and eliminates some unnecessary cruft. You can vary the sparseness by changing "$(($RANDOM % 5))" to another number. The number in this term "$(($RANDOM % 4))" controls how frequently the numbers are output bold.


    21
    echo -e "\e[32m"; while :; do for i in {1..16}; do r="$(($RANDOM % 2))"; if [[ $(($RANDOM % 5)) == 1 ]]; then if [[ $(($RANDOM % 4)) == 1 ]]; then v+="\e[1m $r "; else v+="\e[2m $r "; fi; else v+=" "; fi; done; echo -e "$v"; v=""; done
    dennisw · 2009-09-27 15:30:38 16
  • I often deal with long file names and the 'ls -l' command leaves very little room for file names. An alternative is to use the -h -o and -g flags (or together, -hog). * The -h flag produces human-readable file size (e.g. 91K instead of 92728) * The -o suppresses the owner column * The -g suppresses the group column Since I use to alias ll='ls -l', I now do alias ll='ls -hog' Show Sample Output


    21
    ls -hog
    haivu · 2009-03-21 05:24:49 11
  • This command handles git rm'ing files that you've deleted. Show Sample Output


    21
    git rm $(git ls-files --deleted)
    technicalpickles · 2009-02-26 21:21:02 18
  •  1 2 3 >  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

determine if tcp port is open
@putnamhill, no need if statement in that case. && is a AND and || is a OR

Setting reserved blocks percentage to 1%
According to tune2fs manual, reserved blocks are designed to keep your system from failing when you run out of space. Its reserves space for privileged processes such as daemons (like syslogd, for ex.) and other root level processes; also the reserved space can prevent the filesystem from fragmenting as it fills up. By default this is 5% regardless of the size of the partition. http://www.ducea.com/2008/03/04/ext3-reserved-blocks-percentage/

Top ten (or whatever) memory utilizing processes (with children aggregate) - Can be done without the multi-dimensional array

Show apps that use internet connection at the moment.
show only the name of the apps that are using internet

Find out how much ram memory has your video (graphic) card

Read just the IP address of a device

External IP (raw data)

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"

Does a traceroute. Lookup and display the network or AS names and AS numbers.
From the man page. lft ? display the route packets take to a network host/socket using one of several layer-4 protocols and methods; optionally show heuristic network information in transitu -A Enable lookup and display of of AS (autonomous system) numbers (e.g., [1]). This option queries one of several whois servers (see options 'C' and 'r') in order to ascertain the origin ASN of the IP address in question. By default, LFT uses the pWhoIs service whose ASN data tends to be more accurate and more timely than using the RADB as it is derived from the Internet's global routing table. -N Enable lookup and display of network or AS names (e.g., [GNTY-NETBLK-4]). This option queries Prefix WhoIs, RIPE NCC, or the RADB (as requested). In the case of Prefix WhoIs or RADB, the network name is displayed. In the case of RIPE NCC, the AS name is displayed.

how to export a table in .csv file
Exports the result of query in a csv file


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: