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…
Devops/Sysadmin Cheatsheet
31–40 of 110 posts
Re: Devops/Sysadmin Cheatsheet
#32Earlier 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."
$ rm -rf /root
rm: cannot remove `root': Permission denied
$ sudo !!
sudo rm -rf /root
# /root is now kaputRe: Devops/Sysadmin Cheatsheet
#33 df -h
not du -shRe: Devops/Sysadmin Cheatsheet
#34 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/fdRun 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
#35Okay, 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?
Ben Rockwood from Joyent has a good conceptual talk at http://www.youtube.com/watch?v=h5E--QSBVBY , "DevOps Demysitified".
Re: Devops/Sysadmin Cheatsheet
#36Earlier 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.
Re: Devops/Sysadmin Cheatsheet
#37Re: Devops/Sysadmin Cheatsheet
#38Re: Devops/Sysadmin Cheatsheet
#39Great 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…
Re: Devops/Sysadmin Cheatsheet
#40I 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.
user@host$ less /var/log/syslog
Permission Denied
crap... $ sudo !!
sudo less /var/log/syslog
Woo!