{"id":564,"date":"2007-08-03T13:23:38","date_gmt":"2007-08-03T20:23:38","guid":{"rendered":"http:\/\/www.gubatron.com\/blog\/2007\/08\/03\/2-linux-commands-i-always-forget\/"},"modified":"2017-02-01T21:17:37","modified_gmt":"2017-02-01T21:17:37","slug":"2-linux-commands-i-always-forget","status":"publish","type":"post","link":"https:\/\/www.gubatron.com\/blog\/2-linux-commands-i-always-forget\/","title":{"rendered":"2 Linux Commands I always forget"},"content":{"rendered":"<p><img data-recalc-dims=\"1\" decoding=\"async\" src=\"https:\/\/i0.wp.com\/farm2.static.flickr.com\/1003\/719169325_64b79209c0.jpg?w=640\" alt=\"Taken on the museum of sex in paris\"\/><\/p>\n<p><strong>ldd<\/strong><\/p>\n<p>ldd is good when you need to know what shared dependencies has an executable file. For example.<\/p>\n<pre>\nangel@mbweb1:\/bin$ ldd \/bin\/bash\n        libncurses.so.5 => \/lib\/libncurses.so.5 (0x00002ac651098000)\n        libdl.so.2 => \/lib\/libdl.so.2 (0x00002ac6512f4000)\n        libc.so.6 => \/lib\/libc.so.6 (0x00002ac6514f8000)\n        \/lib64\/ld-linux-x86-64.so.2 (0x00002ac650e7b000)\n<\/pre>\n<p><strong>ltrace \/ dtruss for mac<\/strong><\/p>\n<p>As seen in the manual:<\/p>\n<blockquote><p>ltrace  is  a  program  that simply runs the specified command until it exits.  It intercepts and records the dynamic library calls which are called by the executed process and the signals which are received by that process.  It can also intercept and  print  the system calls executed by the program.<\/p><\/blockquote>\n<p>Here&#8217;s some sample output of ltrace<\/p>\n<pre>\nltrace -p 929\n--- SIGSTOP (Stopped (signal)) ---\n--- SIGSTOP (Stopped (signal)) ---\nfcntl(10, 4, 2050, 12, 0)                                                              = 0\naccept(10, 0x7fffb0855b30, 0x7fffb08557ac, -1, 0)                                      = 76\nfcntl(10, 4, 2, 0, 0)                                                                  = 0\nsignal(17, NULL)                                                                       = NULL\nrequest_init(0x7fffb08557b0, 2, 0x7fffb0857ac5, 1, 76)                                 = 0x7fffb08557b0\nsock_host(0x7fffb08557b0, 0, 0x7fffb08555d8, 40, 0x7fffb085583a)                       = 0\nhosts_access(0x7fffb08557b0, 0x2b0bfaa95580, 0x7fffb0853648, -1, 0x7fffb085583a)       = 1\ngetsockname(76, 0x7fffb0855b20, 0x7fffb08557ac, 0x2aaab0000000, 0x2aaab0017ea0)        = 0\nmalloc(8496)                                                                           = 0x2aaab01857b0\nmalloc(256)                                                                            = 0x2aaab000b490\nmalloc(256)                                                                            = 0x2aaab000b5a0\nmemset(0x2aaab0186678, '00', 472)                                                    = 0x2aaab0186678\nmemset(0x2aaab0186b48, '00', 72)                                                     = 0x2aaab0186b48\nmemset(0x2aaab0186558, '00', 72)                                                     = 0x2aaab0186558\nmemset(0x2aaab0186608, '00', 112)                                                    = 0x2aaab0186608\npthread_mutex_init(0x2aaab01863c0, 0xda6668, 0, 0x2aaab0186678, 0)                     = 0\npthread_mutex_lock(0xd94200, 0xda6668, 0, 0x2aaab0186678, 0xda6668)                    = 0\nmemcpy(0x2aaab0185c68, \"\", 528)                                                        = 0x2aaab0185c68\nmalloc(41)                                                                             = 0x2aaab0002f80\nmemcpy(0x2aaab0002fa0, \"%H:%i:%s\", 8)                                                  = 0x2aaab0002fa0\nmalloc(41)                                                                             = 0x2aaab00646e0\nmemcpy(0x2aaab0064700, \"%Y-%m-%d\", 8)                                                  = 0x2aaab0064700\nmalloc(50)                                                                             = 0x2aaab0064720\nmemcpy(0x2aaab0064740, \"%Y-%m-%d %H:%i:%s\", 17)                                        = 0x2aaab0064740\npthread_mutex_unlock(0xd94200, 0xdaaab1, 17, 0, 64)                                    = 0\nstrcmp(\"latin1\", \"utf8\")                                                               = -1\nmemset(0x2aaab0185e78, '00', 1312)                                                   = 0x2aaab0185e78\nmalloc(1040)                                                                           = 0x2aaab00576e0\nmalloc(256)                                                                            = 0x2aaab0017ea0\npthread_mutex_lock(0xd93f00, 0x2aaab0185bf8, 0, 704, 128)                              = 0\npthread_mutex_unlock(0xd93f00, 0x2aaab0185bf8, 0x3252d661, 1, 128)                     = 0\npthread_self(0x2aaab0186398, 0x2aab7963b5ce, 0x39988b2e, 0xf9988b2b, 0xd93f00)         = 0x2b0bfbde9e70\npthread_self(0x2aaab0186398, 0x2aab7963b5ce, 0x39988b2e, 0xf9988b2b, 0xd93f00)         = 0x2b0bfbde9e70\nmalloc(240)                                                                            = 0x2aaab0017d20\nmemset(0x2aaab0017d20, '00', 240)                                                    = 0x2aaab0017d20\nsprintf(\"\", \"\")                                                                        = 11\nfcntl(76, 4, 0, 0x7fffb0855450, 0)                                                     = 0\nfcntl(76, 3, 0, -1, 0)                                                                 = 2\nmalloc(16391)                                                                          = 0x2aaab0131590\nfcntl(76, 4, 2050, 0, 0x200000)                                                        = 0\nsetsockopt(76, 0, 1, 0x7fffb0855634, 4)                                                = 0\nsetsockopt(76, 6, 1, 0x7fffb0855634, 4)                                                = 0\npthread_mutex_lock(0xd93f00, 6, 501, -1, 4)                                            = 0\npthread_cond_signal(0xd94920, 6, 0x2aaab01857c0, 0, 4)                                 = 0\npthread_mutex_unlock(0xd93f00, 5, 1, -1, 0xd94920)                                     = 0\nselect(13, 0x7fffb0855720, 0, 0, 0)                                                    = 1\nfcntl(10, 4, 2050, 12, 0)                                                              = 0\naccept(10, 0x7fffb0855b30, 0x7fffb08557ac, -1, 0)                                      = 80\nfcntl(10, 4, 2, 0, 0)                                                                  = 0\nsignal(17, NULL)                                                                       = NULL\nrequest_init(0x7fffb08557b0, 2, 0x7fffb0857ac5, 1, 80)                                 = 0x7fffb08557b0\nsock_host(0x7fffb08557b0, 0, 0x7fffb08555d8, 40, 0x7fffb085583a)                       = 0\nhosts_access(0x7fffb08557b0, 0x2b0bfaa95580, 0x7fffb0853648, -1, 0x7fffb085583a)       = 1\ngetsockname(80, 0x7fffb0855b20, 0x7fffb08557ac, 0x2aaab0000000, 0x2aaab0017fb0)        = 0\nmalloc(8496)                                                                           = 0x2aaab01355a0\nmalloc(256)                                                                            = 0x2aaab0017fb0\nmalloc(256)                                                                            = 0x2aaab00180c0\nmemset(0x2aaab0136468, '00', 472)                                                    = 0x2aaab0136468\n...\n<\/pre>\n<p><strong>strace<\/strong><\/p>\n<p>the same as ltrace, but only for system calls.<\/p>\n","protected":false},"excerpt":{"rendered":"<p>ldd ldd is good when you need to know what shared dependencies has an executable file. For example. angel@mbweb1:\/bin$ ldd \/bin\/bash libncurses.so.5 => \/lib\/libncurses.so.5 (0x00002ac651098000) libdl.so.2 => \/lib\/libdl.so.2 (0x00002ac6512f4000) libc.so.6 => \/lib\/libc.so.6 (0x00002ac6514f8000) \/lib64\/ld-linux-x86-64.so.2 (0x00002ac650e7b000) ltrace \/ dtruss for mac As seen in the manual: ltrace is a program that simply runs the specified command [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"closed","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"_jetpack_newsletter_access":"","_jetpack_dont_email_post_to_subs":true,"_jetpack_newsletter_tier_id":0,"_jetpack_memberships_contains_paywalled_content":false,"_jetpack_feature_clip_id":0,"_jetpack_memberships_contains_paid_content":false,"footnotes":"","jetpack_publicize_message":"","jetpack_publicize_feature_enabled":true,"jetpack_social_post_already_shared":false,"jetpack_social_options":{"image_generator_settings":{"template":"highway","default_image_id":0,"font":"","enabled":false},"version":2},"jetpack_post_was_ever_published":false},"categories":[30,43],"tags":[],"class_list":["post-564","post","type-post","status-publish","format-standard","hentry","category-geeklife","category-linux"],"jetpack_publicize_connections":[],"jetpack_featured_media_url":"","jetpack_sharing_enabled":true,"jetpack_shortlink":"https:\/\/wp.me\/p5Unzf-96","jetpack-related-posts":[{"id":584,"url":"https:\/\/www.gubatron.com\/blog\/svn-gotchas-importing-a-folder-in-one-step\/","url_meta":{"origin":564,"position":0},"title":"svn gotchas: Importing a Folder in one step","author":"gubatron","date":"September 6, 2007","format":false,"excerpt":"Up until this day when my friend Gabe told me how, I didn't know how to import a folder, without doing this first: svn mkdir svn+ssh:\/\/server.com\/path\/to\/repo\/myfolder svn import myFolder svn+ssh:\/\/server.com\/path\/to\/repo\/myfolder If I didn't do that, If I just imported the local \"myFolder\", it would end up adding all the files\u2026","rel":"","context":"In &quot;Code&quot;","block_context":{"text":"Code","link":"https:\/\/www.gubatron.com\/blog\/category\/code\/"},"img":{"alt_text":"","src":"","width":0,"height":0},"classes":[]},{"id":2767,"url":"https:\/\/www.gubatron.com\/blog\/ubuntu-packages-for-a-kick-ass-web-server\/","url_meta":{"origin":564,"position":1},"title":"ubuntu packages for a kick ass web server","author":"gubatron","date":"September 7, 2012","format":false,"excerpt":"Copy and paste the following list on a file, say \"packages.txt\". To install all just do: sudo apt-get install $(cat packages.txt) accountsservice acpid adduser ant ant-optional apache2-utils apparmor apport apport-symptoms apt apt-transport-https apt-utils apt-xapian-index aptitude at base-files base-passwd bash bash-completion bc bind9-host bsdmainutils bsdutils busybox-initramfs busybox-static byobu bzip2 ca-certificates ca-certificates-java\u2026","rel":"","context":"In &quot;Code&quot;","block_context":{"text":"Code","link":"https:\/\/www.gubatron.com\/blog\/category\/code\/"},"img":{"alt_text":"","src":"","width":0,"height":0},"classes":[]},{"id":3383,"url":"https:\/\/www.gubatron.com\/blog\/things-to-remember-when-compilinglinking-cc-software\/","url_meta":{"origin":564,"position":2},"title":"# Things to remember when compiling\/linking C\/C++ software","author":"gubatron","date":"March 18, 2015","format":false,"excerpt":"by Angel Leon. March 17, 2015. Include Paths On the compilation phase, you will usually need to specify the different include paths so that the interfaces (.h, .hpp) which define structs, classes, constans, and functions can be found. With gcc and llvm include paths are passed with -I\/path\/to\/includes, you can\u2026","rel":"","context":"In &quot;Code&quot;","block_context":{"text":"Code","link":"https:\/\/www.gubatron.com\/blog\/category\/code\/"},"img":{"alt_text":"","src":"https:\/\/i0.wp.com\/www.gubatron.com\/blog\/wp-content\/uploads\/2015\/03\/make-all-executables.png?fit=680%2C510&ssl=1&resize=350%2C200","width":350,"height":200,"srcset":"https:\/\/i0.wp.com\/www.gubatron.com\/blog\/wp-content\/uploads\/2015\/03\/make-all-executables.png?fit=680%2C510&ssl=1&resize=350%2C200 1x, https:\/\/i0.wp.com\/www.gubatron.com\/blog\/wp-content\/uploads\/2015\/03\/make-all-executables.png?fit=680%2C510&ssl=1&resize=525%2C300 1.5x"},"classes":[]},{"id":1336,"url":"https:\/\/www.gubatron.com\/blog\/compiling-ghost-white-crab-on-linux-x86_64-ubuntu-linux\/","url_meta":{"origin":564,"position":3},"title":"Compiling Ghost White Crab on Linux x86_64 Ubuntu Linux","author":"gubatron","date":"July 26, 2009","format":false,"excerpt":"Compiling this software is usually just a matter of running 'make', but if you try to do so in Ubuntu 64bit, you'll encounter the following error on the config_test.log file skipping incompatible \/usr\/lib\/gcc\/x86_64-linux-gnu\/4.3.3\/libgcc.a when searching for -lgcc To solve this issue just do the following: apt-get install libc6-dev-i386 This makes\u2026","rel":"","context":"In &quot;Geeklife&quot;","block_context":{"text":"Geeklife","link":"https:\/\/www.gubatron.com\/blog\/category\/geeklife\/"},"img":{"alt_text":"","src":"","width":0,"height":0},"classes":[]},{"id":582,"url":"https:\/\/www.gubatron.com\/blog\/linuxcomo-copiar-un-archivo-a-multiples-ubicaciones-con-un-solo-comando\/","url_meta":{"origin":564,"position":4},"title":"Linux: Como copiar un archivo a multiples ubicaciones con un solo comando","author":"gubatron","date":"August 29, 2007","format":false,"excerpt":"Aprovecho la ocasion para ilustrar un poco el poder del bash a los amigos que recien se unen al mundo de linux. Muchas veces tienes que hacer operaciones en las cuales tienes que tocar multiples archivos, por ejemplo, remplazar un archivo en varios lugares. Yendo a un ejemplo concreto, El\u2026","rel":"","context":"In &quot;Geeklife&quot;","block_context":{"text":"Geeklife","link":"https:\/\/www.gubatron.com\/blog\/category\/geeklife\/"},"img":{"alt_text":"","src":"","width":0,"height":0},"classes":[]},{"id":4135,"url":"https:\/\/www.gubatron.com\/blog\/the-curious-case-of-inconsistent-cargo-fmt-formatting-and-how-to-fix-it\/","url_meta":{"origin":564,"position":5},"title":"The Curious Case of Inconsistent cargo fmt Formatting (and How to Fix It)","author":"gubatron","date":"February 17, 2025","format":false,"excerpt":"Have you ever run into a situation where\u00a0cargo fmt, Rust's code formatter, produces different output on different machines, even though you're working on the same project? This can be incredibly frustrating, especially when you're trying to maintain consistent code style across a team or between your own development environments. I\u2026","rel":"","context":"In &quot;Code&quot;","block_context":{"text":"Code","link":"https:\/\/www.gubatron.com\/blog\/category\/code\/"},"img":{"alt_text":"","src":"https:\/\/i0.wp.com\/www.gubatron.com\/blog\/wp-content\/uploads\/2025\/02\/gubatron_Abstract_digital_art_fragmented_code_snippets_floati_e3f2c486-78ad-4b2a-b86a-e792a1970064_2.png?fit=1024%2C1024&ssl=1&resize=350%2C200","width":350,"height":200,"srcset":"https:\/\/i0.wp.com\/www.gubatron.com\/blog\/wp-content\/uploads\/2025\/02\/gubatron_Abstract_digital_art_fragmented_code_snippets_floati_e3f2c486-78ad-4b2a-b86a-e792a1970064_2.png?fit=1024%2C1024&ssl=1&resize=350%2C200 1x, https:\/\/i0.wp.com\/www.gubatron.com\/blog\/wp-content\/uploads\/2025\/02\/gubatron_Abstract_digital_art_fragmented_code_snippets_floati_e3f2c486-78ad-4b2a-b86a-e792a1970064_2.png?fit=1024%2C1024&ssl=1&resize=525%2C300 1.5x, https:\/\/i0.wp.com\/www.gubatron.com\/blog\/wp-content\/uploads\/2025\/02\/gubatron_Abstract_digital_art_fragmented_code_snippets_floati_e3f2c486-78ad-4b2a-b86a-e792a1970064_2.png?fit=1024%2C1024&ssl=1&resize=700%2C400 2x"},"classes":[]}],"_links":{"self":[{"href":"https:\/\/www.gubatron.com\/blog\/wp-json\/wp\/v2\/posts\/564","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.gubatron.com\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.gubatron.com\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.gubatron.com\/blog\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/www.gubatron.com\/blog\/wp-json\/wp\/v2\/comments?post=564"}],"version-history":[{"count":1,"href":"https:\/\/www.gubatron.com\/blog\/wp-json\/wp\/v2\/posts\/564\/revisions"}],"predecessor-version":[{"id":3678,"href":"https:\/\/www.gubatron.com\/blog\/wp-json\/wp\/v2\/posts\/564\/revisions\/3678"}],"wp:attachment":[{"href":"https:\/\/www.gubatron.com\/blog\/wp-json\/wp\/v2\/media?parent=564"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.gubatron.com\/blog\/wp-json\/wp\/v2\/categories?post=564"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.gubatron.com\/blog\/wp-json\/wp\/v2\/tags?post=564"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}