[{"data":1,"prerenderedAt":115},["ShallowReactive",2],{"\u002Ftlt-2018.11.12-destroy-things":3},{"id":4,"title":5,"body":6,"createdAt":102,"description":12,"draft":103,"extension":104,"image":105,"mastodonThread":105,"meta":106,"navigation":107,"path":108,"seo":109,"stem":110,"tags":111,"updatedAt":113,"__hash__":114},"content\u002FTLT - 2018.11.12 - Destroy Things.md","TLT_-_2018.11.12_-_Destroy_Things",{"type":7,"value":8,"toc":99},"minimark",[9,13,16,27,30,33,39,42,48,51,57,60,66,69,75,78,84,87,93,96],[10,11,12],"p",{},"I think it's important to learn through destruction. I like to probe the edges of things, and one of the best ways of knowing where IS the edge is to go over it. So ... let's go over the edge.",[10,14,15],{},"First we need a nice fresh ubuntu:",[17,18,23],"pre",{"className":19,"code":21,"language":22},[20],"language-text","awwaiid@zokei:~$ docker run -it ubuntu bash\nroot@1cf14a7465fd:\u002F#\n","text",[24,25,21],"code",{"__ignoreMap":26},"",[10,28,29],{},"Now, this isn't a completely isolated machine or anything, but it'll do. Keep in mind that this is running as root on your machine (if you're running a Linux host at least, this is probably safer on osx), so you should be a little afraid. Fear will keep you on your toes!",[10,31,32],{},"Let's cause a little destruction! Make sure you are INSIDE of this new ubuntu container, and then:",[17,34,37],{"className":35,"code":36,"language":22},[20],"root@1cf14a7465fd:\u002F# rm -rf \u002F\n",[24,38,36],{"__ignoreMap":26},[10,40,41],{},"They always joke that you shouldn't do that. Turns out our lovely ubuntu is trying to help us not hurt ourselves, so we have to pass a special flag:",[17,43,46],{"className":44,"code":45,"language":22},[20],"root@1cf14a7465fd:\u002F# rm -rf --no-preserve-root \u002F\n",[24,47,45],{"__ignoreMap":26},[10,49,50],{},"WHOA! Whole lot of errors. Many of them are very good things about how you can't remove stuff in \u002Fsys\u002Fdevices because of it being a read-only filesystem (remember that running as root bit?). And now the fun begins.",[17,52,55],{"className":53,"code":54,"language":22},[20],"root@1cf14a7465fd:\u002F# ls\nbash: ls: command not found\n",[24,56,54],{"__ignoreMap":26},[10,58,59],{},"Oh right. \"ls\" is a command that is an executable program that lives at \u002Fbin\u002Fls. Correction: LIVED. But no longer. That's ok ... tab completion still works!",[17,61,64],{"className":62,"code":63,"language":22},[20],"root@1cf14a7465fd:\u002F# cd \u003Ctab>\u003Ctab>\ndev\u002F  etc\u002F  proc\u002F sys\u002F\nroot@1cf14a7465fd:\u002F# cd etc\nroot@1cf14a7465fd:\u002Fetc#\n",[24,65,63],{"__ignoreMap":26},[10,67,68],{},"Great! So we can get directory lists. Let's look at some files",[17,70,73],{"className":71,"code":72,"language":22},[20],"root@1cf14a7465fd:\u002F# cat \u003Ctab>\u003Ctab>\nhostname     hosts        resolv.conf  \nroot@1cf14a7465fd:\u002F# cat resolv.conf\nbash: cat: command not found\n",[24,74,72],{"__ignoreMap":26},[10,76,77],{},"Oh right. No \"cat\" command either. What commands DO we have? Well, we have any bash built-in. And we have bash as a programming language with loops and all that. Now we start to get fancy.",[17,79,82],{"className":80,"code":81,"language":22},[20],"root@1cf14a7465fd:\u002F# while read p; do echo $p; done \u003C \u002Fetc\u002Fhostname\n1cf14a7465fd\n",[24,83,81],{"__ignoreMap":26},[10,85,86],{},"Nice. We can now look at the contents of files. But if we are ever going to rebuild our system we'll also need to write files. Easy!",[17,88,91],{"className":89,"code":90,"language":22},[20],"root@1cf14a7465fd:\u002Fetc# echo 'echo \"hello!\"' > hello.sh\nroot@1cf14a7465fd:\u002Fetc# . \u002Fetc\u002Fhello.sh\nhello!\n",[24,92,90],{"__ignoreMap":26},[10,94,95],{},"We cheated a bit with that \".\" to \"source\" the file. I'm not sure how to make it executable, since we no longer have chmod. Maybe we'll try that next time.",[10,97,98],{},"Enjoy your broken docker container!",{"title":26,"searchDepth":100,"depth":100,"links":101},2,[],"2018-11-12T23:04-05:00",false,"md",null,{},true,"\u002Ftlt-2018.11.12-destroy-things",{"title":5,"description":12},"TLT - 2018.11.12 - Destroy Things",[112],"blog","2018-11-12T23:07-05:00","XcUo333mfvtawxe5gT-vLYqjg8r8aMUti9oIlkXTZHg",1778988314640]