Live data from Hacker News

Devops/Sysadmin Cheatsheet

rubytune.com

31–40 of 110 posts

Re: Devops/Sysadmin Cheatsheet

#31

Earlier quoted context omitted.

I suppose if you type it at any random point it might be. It's useful more when typed something that you forgot to sudo.

If you are running sudo, the long-term payoff is probably higher if you never use sudo !!. The very small chance of a huge disaster is still a lot higher than up arrow. Unless you are on a laggy connection and up arrow delays and you push it twice and end up running the wrong command! If you have lots of jitter and lag, i suggest using Mosh which I've found to be amazingly awesome when using it on Amtrak's spotty fre…

I think it's meant for when you run a command normally, but then realize you should have sudoed (sudid?) it. Though in that situation, I would still be inclined to do "↑ esc a sudo ". It's not a lot more work, but it is a lot less uncertain.

Re: Devops/Sysadmin Cheatsheet

#32

Earlier quoted context omitted.

If you are running sudo, the long-term payoff is probably higher if you never use sudo !!. The very small chance of a huge disaster is still a lot higher than up arrow. Unless you are on a laggy connection and up arrow delays and you push it twice and end up running the wrong command! If you have lots of jitter and lag, i suggest using Mosh which I've found to be amazingly awesome when using it on Amtrak's spotty fre…

I've never had any incidents with `sudo !!`, however, I should point out that zsh (maybe other shells as well) replaces the `!!` with the full command and requires another press of Enter. $ rm -rf /root rm: cannot remove `root': Permission denied $ sudo !! # Does not run this, but returns the line below. $ sudo rm -rf /root # Then you say, "Wait I dont want to do this."

Interesting. Bash on my OS X box shows the command you're running, but doesn't give you a chance to cancel it. It looks like this:

  $ rm -rf /root
  rm: cannot remove `root': Permission denied
  $ sudo !!
  sudo rm -rf /root
  # /root is now kaput

Re: Devops/Sysadmin Cheatsheet

#34
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 . -mtime -7

Find files older than 14 days: find .gz -mtime +14 -type f This will break when you have more archived files in the directory than the shell's glob char can support. Use: find . -mtime +14 -type f -name '*.gz' and it will run quicker too.

TCP Sockets in use, "netstat -antp" will be faster and also lists the process id.

EDIT: formatting

Re: Devops/Sysadmin Cheatsheet

#35
post #18

Okay, I'll admit it. I don't actually know what devops is. I know what developers do and what sysadmins do. Is devops just a buzzword for one person who can do both? Or does it mean something other than that?

At the moment, it's mostly an overloaded buzzword. :) The best definition I've found is that it's a culture of collaboration and integration between development and operations, rather than a role for one specific person.

Ben Rockwood from Joyent has a good conceptual talk at http://www.youtube.com/watch?v=h5E--QSBVBY , "DevOps Demysitified".

Re: Devops/Sysadmin Cheatsheet

#36
post #31

Earlier quoted context omitted.

If you are running sudo, the long-term payoff is probably higher if you never use sudo !!. The very small chance of a huge disaster is still a lot higher than up arrow. Unless you are on a laggy connection and up arrow delays and you push it twice and end up running the wrong command! If you have lots of jitter and lag, i suggest using Mosh which I've found to be amazingly awesome when using it on Amtrak's spotty fre…

I think it's meant for when you run a command normally, but then realize you should have sudoed (sudid?) it. Though in that situation, I would still be inclined to do "↑ esc a sudo ". It's not a lot more work, but it is a lot less uncertain.

Shoulda sudone it!

Re: Devops/Sysadmin Cheatsheet

#39

Great list. A few more (related or building on those there) Quick mysql "why is my database under so much load suddenly" that doesn't rely on the slow query log: pt-query-digest --processlist h= --interval=0.01 --print > /tmp/queries.out pt-query-digest /tmp/queries.out Tracking down what files exactly are filling up the disk. Go to /, and follow the big numbers: du -smc * Combine strace (for the file handle no), lso…

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.

Re: Devops/Sysadmin Cheatsheet

#40
post #9

I would warn anyone that read this to understand what each command does before actually running anything on a machine. Things like "sudo !!" are INCREDIBLY dangerous, and I would never put that on a cheat sheet.

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!
Post reply on HN