Live data from Hacker News

Devops/Sysadmin Cheatsheet

rubytune.com

71–80 of 110 posts

Re: Devops/Sysadmin Cheatsheet

#71
post #70
post #30

Earlier quoted context omitted.

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.

dig -x

Will also correctly do a PTR query for the reverse entry for that IP. Also functions correctly with IPv6, so you don't need to remember to split the IPv6 address up into a lot of dots :P

Re: Devops/Sysadmin Cheatsheet

#72

Earlier quoted context omitted.

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.

du -sh .* *

Problem solved.

Re: Devops/Sysadmin Cheatsheet

#73
Be careful when you think you really understand the meaning of atime/mtime of findutils.

E.g. man find

  -atime n
    File  was  last  accessed  n*24  hours ago.  When find figures out how many 
    24-hour periods ago the file was last accessed, any fractional part is 
    ignored, so to match -atime +1, a file has to have been accessed at least 
    two days ago.

Re: Devops/Sysadmin Cheatsheet

#74

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 ...

If you're going down that path, add windows servers to your list and find more things missing.

Re: Devops/Sysadmin Cheatsheet

#75
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.

Why else would you type it in? I can't imagine many people saying "hm, that command I didn't intend to run didn't work. Maybe I should run it as root instead."

Hopefully if you're in a NOPASSWD user/group, you know what root can do if you're careless; if you're not, there's yet another point where you'd have go out of your way to do damage with this shorthand.

Re: Devops/Sysadmin Cheatsheet

#76

Earlier quoted context omitted.

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.

That's fair, but for the proposed use, checking the size of home directories, .* directories are of little concern.

Honestly, when I have to get fine grained enough to dig into disk usage using 'du', I'm rarely concerned with hidden directories (and I typically append a 'c' to the command as well, so if I do have to pay attention to . directories, I will notice the discrepancy between reported sizes).

Re: Devops/Sysadmin Cheatsheet

#77

Earlier quoted context omitted.

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?

Linux. :)

If tcpdump can't keep up with the incoming traffic, the kernel will drop the packets in its buffer (or rather overwrite them with new packets).

Throw in TCP's flow and congestion control protocols, and dropped packets can have disastrous effects on your database.

Google has many references you might find useful on this subject.

Re: Devops/Sysadmin Cheatsheet

#78
Meta question: where do you actually learn this stuff? I am a developer with an intermediate desktop level command line knowledge learnt mostly on the job but would appreciate a crash course on system-level command line, diagnostics, devops, etc.

Re: Devops/Sysadmin Cheatsheet

#79

Earlier quoted context omitted.

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

That's fair, but for the proposed use, checking the size of home directories, .* directories are of little concern. Honestly, when I have to get fine grained enough to dig into disk usage using 'du', I'm rarely concerned with hidden directories (and I typically append a 'c' to the command as well, so if I do have to pay attention to . directories, I will notice the discrepancy between reported sizes).

We have lots of imap maildir directories; e.g., ".Junk", ".Trash", ".Sent", ".Inbox", for each mail account on the server. It's kind of a special case though; I'll agree that in all other cases, your version is simpler and easier to remember.

Re: Devops/Sysadmin Cheatsheet

#80

Earlier quoted context omitted.

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

du -sh .* * Problem solved.

You might be right. I have some recollection of .* stabbing me in the back once before in this command, and I know I put -x (do not traverse file systems) in there for a reason -- but I don't have any notes on why, so I can't say anything smart about it.
Post reply on HN