Live data from Hacker News

Devops/Sysadmin Cheatsheet

rubytune.com

61–70 of 110 posts

Re: Devops/Sysadmin Cheatsheet

#61
post #28

Earlier quoted context omitted.

So, what's wrong with sudo !! then?

It re-executes your previous command -- this time with root privilege. If and only if you meant to do that, you're fine.

The "only if" part is false: it is certainly possibleto be fine having done sudo !! without meaning to do it.

Re: Devops/Sysadmin Cheatsheet

#63

Earlier quoted context omitted.

I prefer using tcpdump instead of processlist when dealing with pt-query-digest. You get everything instead of just what happens to show up during the interval specified. This is, of course, assuming that you don't allow localhost socket connections.

Very true - extremely fast queries can slip between the processlist checks. The problem I've encountered with tcpdump is that you can cause packet loss by running it. It's not common, but it happens enough that I've become gun shy about using it on production systems. The pt-query-digest function will cause additional load on the DB, but it won't interrupt communications.

What OS will drop packets while tcpdump is running?

Re: Devops/Sysadmin Cheatsheet

#64
Devops/Sysadmin Cheatsheet for Linux

Most of the commands listed rely on various GNU extensions to the various utilities or are only applicable to Linux.

FreeBSD:

strace -> dtrace/ktrace/ lsof -> sockstat/fstat watch -> no idea

sudo -> Almost never installed by default on FreeBSD ps aux --sort=-resident|head -11 -> --sort is not valid ...

And the list goes on ...

Re: Devops/Sysadmin Cheatsheet

#65
post #16

Some random thoughts: - Instead of 'while true;' you can use the shorter 'while :;'. ':' is a null command. - On OS X, dtruss is kinda, sorta like strace (it's a wrapper around dtrace, and the dtruss name comes from Solaris). - For basic host to IP resolution, I prefer ping as it calls gethostbyname(), like most other programs will do. host/dig are suitable for querying/testing DNS independent of how the local box is…

> (Separately, OS X's stub resolver has some neat tricks. e.g., using /etc/resolver/ to route DNS requests for a particular domain to a specific name server.)

I was about to give up and install dnsmasq locally to get around a VPN-related issue. Thanks for the tip!

Re: Devops/Sysadmin Cheatsheet

#66

There's a few typos in this, in case it helps: ps auxww -> ps auxww -H (H is hierarchy) Faster than lsof, and only displays files - although most things in unix are files! lsof -p -> ls -l /proc/$PID/fd Run something forever watch command Overview of all disks du should be df. Find files over 100mb find . -size +100M Low hanging fruit for size ls -al | sort -nk5 Files created (modified) within the past 7 days: find .…

Instead of:

  ls -al | sort -nk5
I suggest:

  ls -larS

Re: Devops/Sysadmin Cheatsheet

#67
post #43

Earlier quoted context omitted.

I use this one like a dozen times a day. user@host$ less /var/log/syslog Permission Denied crap... $ sudo !! sudo less /var/log/syslog Woo!

why would that be bad? You would get to read your file.

It's not bad. It's extremely useful. If someone is so negligent that they run something potentially destructive and then immediately sudo !!, they probably shouldn't be administering systems.

Re: Devops/Sysadmin Cheatsheet

#68

du -h --max-depth=1 -x I use this frequently to keep an eye on disk used by user directories. It returns the disk space used by each directory in the current directory.

So does: du -sh *

Correct with one important caveat: because * is a shell expansion, it will not process any directories starting with a ".". e.g., imap maildir directories.

Re: Devops/Sysadmin Cheatsheet

#70
post #30
post #14

A little gotcha: "iptables -L" doesn't list the NAT table rules; do "iptables -L; iptables -t nat -L" instead.

I also almost always add '-n' to iptables commands to disable reverse name resolution, which can sometimes take a while. Similarly when calling netstat.

Me too. Even more important is that a host on multiple networks may have the same PTR value for each address, and thus one can lose information in the reverse lookup. "host w.x.y.z" ( or Solaris "nslookup -type=ptr z.y.x.w.in-addr.arpa" ) is available if you don't recognize the IP address.
Post reply on HN