Linux 中查看某程序的路径

查看一个程序的完整路径,除了可以了解其是否存在及所处的位置,还有更重要的作用:当系统中有多个同名程序安装在不同目录下时,检查程序的完整路径可以帮助我们确认其是否为我们想要执行的那个。在 Linux 系统中,我习惯使用 which 或 whereis 来查看一个命令的完整路径。 1$ which gcc 2/usr/bin/gcc 但有一天,我遇到了一个情况:程序明明可以在 Bash 里执行,但 which 就是找不到它。后来搜索到这条回答 才了解到,对路径中可能带有的一些特殊符号(如常用的 ~)而言,Bash 会在执行前解析并替换它们;而 which 却不会。因此,若是在 .bashrc 中写入 1export …

"Universal Reference" and Reference Collapsing

This post is just to note down an interesting talk: Universal References in C++11 , presented by Scott Meyers at C++ and Beyond 2012 . The talk shares a good method to understand (or memorize) the rvalue reference and reference collapsing rules in modern C++, with the help of his self-created concept called Univeral …

About Initramfs

1. What is initramfs? It is ramfs that serves as an initial rootfs. It contains a complete set of directories that you would find on a normal root filesystem. It is bundled into a single cpio archive and (optionally) further compressed by one of the common compression algorithms like gzip or xz. 2. What is it used for? …

C/C++ 存储区知识

bss 段:存放未初始化的全局变量(包括静态全局变量)和初始化为0的全局变量(包括静态全局变量),属于静态分配内存(bss = Block Started by Symbol) data 段:数据段,用来存放已经初始化且初始化值为非零的全局变量(包括静态变量) text 段:通常是指用来存放程序执行代码的一块内存区域。这部分区域的大小在程序运行前就已经确定,并且内存区域通常属于只读,某些架构也允许代码段为可写,即允许修改程序。 堆(heap):堆是用于存放进程运行中被动态分配的内存段,它的大小并不固定,可动态扩张或缩减。当进程调用malloc等函数分配内存时,新分配的内存就被动态添加到堆上(堆被扩张);当利用free等函数释放内存 …

TTY, Terminal & Console on Linux

TTY and its Evolution TTY stands for teletype, a device that let you type in and send commands remotely to the computer and execute them. Its development history is well described on this article , with some useful commands of checking and switching TTY devices on modern Linux system. Based on the article, I draw the …