Commands matching stat (598)

  • Trace python statement execution and syscalls invoked during that simultaneously Show Sample Output


    1
    strace python -m trace --trace myprog.py | grep -v 'write(1,'
    roolebo · 2016-05-27 21:01:01 64
  • Formats nicely the Openvpn log file. Show Sample Output


    0
    column -ts , /etc/openvpn/openvpn-status.log
    luxaeterna101 · 2016-05-17 09:36:58 11

  • 9
    command systemctl --no-page --no-legend --plain -t service --state=running
    Xk2c · 2016-04-30 10:35:05 18

  • 0
    systemctl --no-page -t service -a --state running --no-legend
    nadavkav · 2016-04-30 08:41:57 13
  • This commands does just two things: fakes user agent (the one was taken from recent Android app) and sends the (possibly) listener ID (it can be any - I put "1" here because it works like a charm - after the name of stream ?1 as you can see). Look for the list of stations here: http://pub7.di.fm Or here: https://goo.gl/pdhhpQ Best regards, sxiii :) Show Sample Output


    2
    mplayer http://pub7.di.fm/di_ambient_aac?1 -user-agent "AudioAddict-di/3.2.0.3240 Android/5.1"
    sxiii · 2016-04-29 23:41:17 21
  • Coreutils 8.24 added status=progress


    0
    dd if=foo of=bar status=progress
    ptman · 2016-04-15 08:43:40 12

  • 0
    docker stats --no-stream $( docker ps -q ) | sed -e "$( docker ps --format "{{.ID}} {{.Names}}" | sed -e "s/\(.*\) \(.*\)/s\/\1\/\2\t\/g;/" )"
    gtron · 2016-04-14 15:20:13 12
  • Using GNU Grep with perl regexp (works on newer Ubuntus) Show Sample Output


    0
    ss -t -o state established '( dport = :443 || dport = :80 )' | grep -Po '([0-9a-z:.]*)(?=:http[s])' | sort -u|netcat whois.cymru.com 43|grep -v "AS Name"|sort -t'|' -k3
    miniker84 · 2016-04-08 09:07:39 12
  • I just needed to store the LAN IP (for ipv4) in a variable for a specific task in a bash script. I figured I'd share. I sent it to a variable with VAR=$(stuff) and used it later on. I put the exit 0 in the if statement to make it so that it breaks if there are more than one IPv4 addresses assigned. I only wanted the first one. Edit: Bear in mind, my network mask is a double digit number so if you have a smaller nw mask you'd need to edit the sed statement. Show Sample Output


    0
    ip addr show | grep "inet " | while read INET IP TRASH; do if [ $IP != "127.0.0.1/8" ]; then echo $IP; exit 0; fi; done | sed s:/[1-9][1-9]:"":
    Meh · 2016-04-07 17:46:20 11

  • 3
    ss -t -o state established '( dport = :443 || dport = :80 )'|grep tcp|awk '{ print $5 }'|sed s/:http[s]*//g|sort -u|netcat whois.cymru.com 43|grep -v "AS Name"|sort -t'|' -k3
    koppi · 2016-04-07 01:48:44 16
  • This command will take the output of curl and read it line by line, skipping a step in downloading the file then parsing it. You can then parse each line, or only print the lines that contain certain works using if statements, or whatever you can come up with. Or you can change IFS and use it to parse based on separators other than newline.


    0
    while read line; do echo $line;done < <(curl -s <URL of file to read>)
    baize · 2016-02-05 17:04:15 18
  • This command telnet and and looks for a line starting with "SSH" - works for OpenSSH since the SSH banner is something like "SSH-2.0-OpenSSH_6.0p1 Debian-4+deb7u3". Then it triggers an action accordingly. It can be packed as a script file to echo 0/1 indicating the SSH service availability: if [[ "$(sleep 1 | telnet -c <host> <port> 2>&1 | grep '^SSH')" == SSH* ]]; then echo 1; else echo 0; fi; Alternative uses: Trigger an action when server is UP (using &&): [[ "$(sleep 1 | telnet -c <host> <port> 2>&1 | grep '^SSH')" == SSH* ]] && <command when up> Trigger an action when server is DOWN (using ||): [[ "$(sleep 1 | telnet -c <host> <port> 2>&1 | grep '^SSH')" == SSH* ]] || <command when down>


    0
    $if [[ "$(sleep 1 | telnet -c <host> <port> 2>&1 | grep '^SSH')" == SSH* ]]; then <command when up>; else <command when down>; fi;
    paulera · 2016-02-02 13:06:51 16
  • 1. No for-loop, but xargs. 2. Append "--" in git-reset HEAD command to deal with filenames contained leading hyphen/minus sign (-). 3. Add "--porcelain" option in git-status command for easy-to-parse format when scripting. 4. Add "--no-run-if-empty" option in xargs command to prevent you run it twice and accidentally reset all staged changes. 5. Use zero byte (NUL character) as line terminator instead of newline (\n) to make it more robust to deal with filename with whitespaces. pipe#1: git-status. pipe#2: Use "grep" to filter out "non-added" files. pipe#3: use "sed" to Trim out the leading three characters, reserve the filename. pipe#4: xargs + git-reset... p.s. The "HEAD" in git-reset can be omitted . And, maybe, the third part of this shell pipe (sed) has potential to be enhanced.


    0
    git status --porcelain -z | grep -zZ '^A[ MD] ' | sed -z 's/^...//' | xargs -0 --no-run-if-empty git reset HEAD --
    goldie · 2016-01-24 16:20:08 10
  • Put the command in background running state. Apart from that, it also maintains a log file called nohup.out


    0
    nohup <command>
    ramya · 2016-01-21 11:07:33 13

  • 0
    upower -i /org/freedesktop/UPower/devices/battery_BAT0
    captwachira · 2016-01-17 04:42:59 13

  • -2
    stat -f '%Su' /dev/console
    thealanberman · 2016-01-13 20:53:13 10
  • Requires jq (JSON parser) and curl (wget could do the same with some changes)


    0
    while true; do pos=$(curl -s "http://api.open-notify.org/iss-now.json"); echo "lat=$(echo $pos | jq ".iss_position.latitude"), lon=$(echo $pos | jq ".iss_position.longitude")"; sleep 1; done
    TheMadScientist · 2016-01-08 16:32:34 10
  • IMPORTANT: You need Windows PowerShell to run this command - in your Windows Command Prompt, type powershell Uses sajb to start a PowerShell background job that pings an IP host every 10 seconds. Any changes in the host's Up/Down state is time-stamped and logged to a file. Date/time stamps are logged in two formats: Unix and human-readable. A while(1) loop repeats the test every 10 seconds by using the sleep command. See the Sample Output for more detail. I use this command to log Up/Down events of my Motorola SB6141 cable modem (192.168.100.1). To end the logging, close the PowerShell window or use the "exit" command. Show Sample Output


    0
    sajb {$ip="192.168.100.1";$old=0;while(1){$up=test-connection -quiet -count 1 $ip;if($up-ne$old){$s=(date -u %s).split('.')[0]+' '+(date -f s).replace('T',' ')+' '+$ip+' '+$(if($up){'Up'}else{'Down'});echo $s|out-file -a $home\ping.txt;$old=$up}sleep 10}}
    omap7777 · 2015-12-28 20:33:08 15

  • 0
    for f in `git status | grep new | awk '{print $3}'`; do git reset HEAD $f ; done
    Wafelijzer · 2015-12-16 22:24:34 16

  • 0
    alias dps='docker ps --format "table {{.Names}}\t{{.Status}}\t{{.Ports}}"'
    bradym · 2015-12-11 00:44:00 10
  • Observe the process of your dd command on Mac the Mac bash when you burn an .iso or .img on a SD-Card. This command avoids permission errors.


    0
    while pgrep ^dd; do sudo pkill -INFO dd; sleep 20; done
    kassnik · 2015-12-06 20:16:34 10
  • On debian parent process is running as root, workers as www-data. You can run strace in backgroud, get its PID, curl your webpage, kill strace and read your stats.


    0
    strace -c $(ps -u www-data o pid= | sed 's/^/-p/')
    brablc · 2015-11-25 08:10:52 11

  • 0
    awk '/VmSwap/{print $2 " " $3}' /proc/$PID/status
    lolssl · 2015-10-02 19:43:46 10
  • Sort your files in folders/chronological order Linux 4.1.6-1-ARCH Show Sample Output


    0
    perl -MPOSIX=strftime -MFile::Path -e 'for(glob"*"){mkpath$d=strftime"%Y-%m-%d", localtime((stat)[9]);rename$_,"$d/$_"}'
    olto · 2015-10-02 07:51:58 10
  • Force computer "idle" state when lid is closed, regardless of inhibitors (power manager) in place, and runs logind preset action (sleep, suspend...). See http://www.freedesktop.org/software/systemd/man/logind.conf.html


    0
    echo 'LidSwitchIgnoreInhibited=no' > /etc/systemd/logind.conf.d/respect-inhibit-lid.conf
    lolssl · 2015-10-01 17:20:26 12
  • ‹ First  < 2 3 4 5 6 >  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

Check if *hardware* is 32bit or 64bit
This command tell you if your hardware is 32 or 64 bits even if you install a 32bits OS on a 64 bits hardware. If your distro don't support the -q switch, try doing : $ grep &>/dev/null '\' /proc/cpuinfo && echo 64 bits || echo 32 bits

Kills a process that is locking a file.
Useful when you're trying to unmount a volume and other sticky situations where a rogue process is annoying the hell out of you.

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

Get the list of root nameservers for a given TLD

Rename files in batch

list block devices
Shows all block devices in a tree with descruptions of what they are.

complete extraction of a debian-package
extracts the debian-package $debfile to $extractdir, including all packaging-information. to repack the package, just type: $dpkg-deb -b $extractdir

Install your ssh key file on a remote system

Terminal redirection
Will redirect output of current session to another terminal, e.g. /dev/pts/3 Courtesy of bassu, http://www.commandlinefu.com/commands/by/bassu

Selecting a random file/folder of a folder
Also looks in subfolders


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: