Cannot create "Hello World" module (and NVIDIA, and VirtualBox)

First off, the details. **BEFORE:** kernel: 3.2.0-2-amd64, nvidia driver: 295.59 **AFTER:** kernel: 3.2.0-3-amd64, nvidia driver: 302.17-3 My Debian wheezy is kept recent at all times. Actually, doing daily `apt-get upgrade -s` got me in this trouble in the first place. Evidently, after an `apt-get upgrade`, something "broke" on my Debian -- something related to the build ecosystem and/or DKMS itself. The NVIDIA driver cannot get build by ANY method recommended in the official Wikis. Including the NVIDIA official binary (log snippet from that at one of the updates). Here's the output of `dpkg-reconfigure nvidia-kernel-dkms`:               # dpkg-reconfigure nvidia-kernel-dkms          ------------------------------     Deleting module version: 302.17     completely from the DKMS tree.     ------------------------------     Done.     Loading new nvidia-302.17 DKMS files...     Building only for 3.2.0-3-amd64     Building initial module for 3.2.0-3-amd64     Error!  Build of nvidia.ko failed for: 3.2.0-3-amd64 (x86_64)     Consult the make.log in the build directory     /var/lib/dkms/nvidia/302.17/build/ for more information.      A relevant snippet from `/var/lib/dkms/nvidia/302.17/build/make.log` follows. The problem is **not** in the compilation, I can guarantee that.                 LD [M]  /var/lib/dkms/nvidia/302.17/build/nvidia.o       Building modules, stage 2.       MODPOST 0 modules     make[1]: Leaving directory `/usr/src/linux-headers-3.2.0-3-amd64'     make: Leaving directory `/var/lib/dkms/nvidia/302.17/build'      And that's it. No explanation of any kind in any other files in the same directory (at least as far as I checked). Before I ask my questions: I am using nouveau driver now (it's not like I got any choice anyway), but it doesn't work too well for me. I got 3 desktops, constantly playing movies on 1 of them, and being a very busy developer on the other 2. The nouveau driver fails a little bit there (the movies on the second screen get horizontal stripes all the time, the XFCE consoles lag a bit on the scrolling, etc.) **Questions:**   * Should I change my kernel version? Tried `3.2.0-2-amd64` and `3.2.0-3-amd64`, to no avail. Trying `3.2.0-3-rt-amd64` makes my machine freeze after few minutes of operation, thus I don't dare to install it again.   * Should I change a version of something in my build environment? (As pointed in the updates, it's not just NVIDIA problem, as it turns out).   * Should I assume that my linker is at fault (I am _not_ using `gold`, I am using `ld` from the `binutils` package) and if so, what could I do do make the DKMS method finally work? Since the problem does seem to manifest itself on the linkage phase (and MODPOST shows 0 modules). On a personal note, this disturbs me on a lot deeper level I care to usually admit. I had a **big respect to Debian** , which at the moment is shattered. C'mon, a simple `apt-get upgrade` breaks all open-source kernel drivers compilations / linkages? Extremely disappointing. **UPDATE #1:** I did in fact try to install the official 304.22 NVIDIA drivers, here's the log file. Looks like the linking does indeed fail, does it? Also, if I try to also enable DKMS integration, I get a message of the sorts that the script cannot determine the current kernel version (text in the 3rd update).               nvidia-installer log file '/var/log/nvidia-installer.log'     creation time: Sat Jul 21 22:59:30 2012     installer version: 304.22          PATH: /usr/local/rvm/gems/ruby-1.9.3-p194/bin:/usr/local/rvm/gems/ruby-1.9.3-p194@global/bin:/usr/local/rvm/rubies/ruby-1.9.3-p194/bin:/usr/local/rvm/bin:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin          nvidia-installer command line:         ./nvidia-installer          Using: nvidia-installer ncurses user interface     -> License accepted.     -> Installing NVIDIA driver version 304.22.     -> There appears to already be a driver installed on your system (version: 304.22).  As part of installing this driver (version: 304.22), the existing driver will be uninstalled.  Are you sure you want to continue? ('no' will abort installation) (Answer: Yes)     -> Would you like to register the kernel module sources with DKMS? This will allow DKMS to automatically build a new module, if you install a different kernel later. (Answer: No)     -> Performing CC sanity check with CC="gcc-4.6".     -> Performing CC version check with CC="gcc-4.6".     -> Kernel source path: '/lib/modules/3.2.0-3-amd64/source'     -> Kernel output path: '/lib/modules/3.2.0-3-amd64/build'     -> Performing rivafb check.     -> Performing nvidiafb check.     -> Performing Xen check.     -> Cleaning kernel module build directory.        executing: 'cd ./kernel; make clean'...     -> Building kernel module:        executing: 'cd ./kernel; make module SYSSRC=/lib/modules/3.2.0-3-amd64/source SYSOUT=/lib/modules/3.2.0-3-amd64/build'...        NVIDIA: calling KBUILD...        make -C /lib/modules/3.2.0-3-amd64/build \         KBUILD_SRC=/usr/src/linux-headers-3.2.0-3-common \         KBUILD_EXTMOD="/tmp/selfgz10141/NVIDIA-Linux-x86_64-304.22/kernel" -f /usr/src/linux-headers-3.2.0-3-common/Makefile \         modules        test -e include/generated/autoconf.h -a -e include/config/auto.conf || (     \         echo;                               \         echo "  ERROR: Kernel configuration is invalid.";       \         echo "         include/generated/autoconf.h or include/config/auto.conf are missing.";\         echo "         Run 'make oldconfig && make prepare' on kernel src to fix it.";  \         echo;                               \         /bin/false)        mkdir -p /tmp/selfgz10141/NVIDIA-Linux-x86_64-304.22/kernel/.tmp_versions ; rm -f /tmp/selfgz10141/NVIDIA-Linux-x86_64-304.22/kernel/.tmp_versions/*        make -f /usr/src/linux-headers-3.2.0-3-common/scripts/Makefile.build obj=/tmp/selfgz10141/NVIDIA-Linux-x86_64-304.22/kernel          gcc-4.6 -Wp,-MD,/tmp/selfgz10141/NVIDIA-Linux-x86_64-304.22/kernel/.nv.o.d  -nostdinc -isystem /usr/lib/gcc/x86_64-linux-gnu/4.6/include -I/usr/src/linux-headers-3.2.0-3-common/arch/x86/include -Iarch/x86/include/generated -Iinclude  -I/usr/src/linux-headers-3.2.0-3-common/include -include /usr/src/linux-headers-3.2.0-3-common/include/linux/kconfig.h   -I/tmp/selfgz10141/NVIDIA-Linux-x86_64-304.22/kernel -D__KERNEL__ -Wall -Wundef -Wstrict-prototypes -Wno-trigraphs -fno-strict-aliasing -fno-common -Werror-implicit-function-declaration -Wno-format-security -fno-delete-null-pointer-checks -Os -m64 -mtune=generic -mno-red-zone -mcmodel=kernel -funit-at-a-time -maccumulate-outgoing-args -fstack-protector -DCONFIG_AS_CFI=1 -DCONFIG_AS_CFI_SIGNAL_FRAME=1 -DCONFIG_AS_CFI_SECTIONS=1 -DCONFIG_AS_FXSAVEQ=1 -pipe -Wno-sign-compare -fno-asynchronous-unwind-tables -mno-sse -mno-mmx -mno-sse2 -mno-3dnow -Wframe-larger-than=2048 -Wno-unused-but-set-variable -fomit-frame-pointer -g -Wdeclaration-after-statement -Wno-pointer-sign -fno-strict-overflow -fconserve-stack -DCC_HAVE_ASM_GOTO   -I/tmp/selfgz10141/NVIDIA-Linux-x86_64-304.22/kernel -Wall -MD -Wsign-compare -Wno-cast-        qual -Wno-error -D__KERNEL__ -DMODULE -DNVRM -DNV_VERSION_STRING=\"304.22\" -Wno-unused-function -Wuninitialized -mno-red-zone -mcmodel=kernel -UDEBUG -U_DEBUG -DNDEBUG  -DMODULE  -D"KBUILD_STR(s)=#s" -D"KBUILD_BASENAME=KBUILD_STR(nv)"  -D"KBUILD_MODNAME=KBUILD_STR(nvidia)" -c -o /tmp/selfgz10141/NVIDIA-Linux-x86_64-304.22/kernel/.tmp_nv.o /tmp/selfgz10141/NVIDIA-Linux-x86_64-304.22/kernel/nv.c        In file included from /usr/src/linux-headers-3.2.0-3-common/include/linux/kernel.h:17:0,                         from /usr/src/linux-headers-3.2.0-3-common/include/linux/sched.h:55,                         from /usr/src/linux-headers-3.2.0-3-common/include/linux/utsname.h:35,                         from /tmp/selfgz10141/NVIDIA-Linux-x86_64-304.22/kernel/nv-linux.h:38,                         from /tmp/selfgz10141/NVIDIA-Linux-x86_64-304.22/kernel/nv.c:13:        /usr/src/linux-headers-3.2.0-3-common/include/linux/bitops.h: In function ‘hweight_long’:        /usr/src/linux-headers-3.2.0-3-common/include/linux/bitops.h:49:41: warning: signed and unsigned type in conditional expression [-Wsign-compare]        In file included from /usr/src/linux-headers-3.2.0-3-common/arch/x86/include/asm/uaccess.h:575:0,                         from /usr/src/linux-headers-3.2.0-3-common/include/linux/poll.h:14,                         from /tmp/selfgz10141/NVIDIA-Linux-x86_64-304.22/kernel/nv-linux.h:97,                         from /tmp/selfgz10141/NVIDIA-Linux-x86_64-304.22/kernel/nv.c:13:        /usr/src/linux-headers-3.2.0-3-common/arch/x86/include/asm/uaccess_64.h: In function ‘copy_from_user’:        /usr/src/linux-headers-3.2.0-3-common/arch/x86/include/asm/uaccess_64.h:53:6: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]          ...snipped lots of compile output with the same warning...               ld -m elf_x86_64   -r -o /tmp/selfgz10141/NVIDIA-Linux-x86_64-304.22/kernel/nvidia.o /tmp/selfgz10141/NVIDIA-Linux-x86_64-304.22/kernel/nv-kernel.o /tmp/selfgz10141/NVIDIA-Linux-x86_64-304.22/kernel/nv.o /tmp/selfgz10141/NVIDIA-Linux-x86_64-304.22/kernel/nv-acpi.o /tmp/selfgz10141/NVIDIA-Linux-x86_64-304.22/kernel/nv-chrdev.o /tmp/selfgz10141/NVIDIA-Linux-x86_64-304.22/kernel/nv-cray.o /tmp/selfgz10141/NVIDIA-Linux-x86_64-304.22/kernel/nv-gvi.o /tmp/selfgz10141/NVIDIA-Linux-x86_64-304.22/kernel/nv-i2c.o /tmp/selfgz10141/NVIDIA-Linux-x86_64-304.22/kernel/nv-mempool.o /tmp/selfgz10141/NVI        DIA-Linux-x86_64-304.22/kernel/nv-mlock.o /tmp/selfgz10141/NVIDIA-Linux-x86_64-304.22/kernel/nv-mmap.o /tmp/selfgz10141/NVIDIA-Linux-x86_64-304.22/kernel/nv-p2p.o /tmp/selfgz10141/NVIDIA-Linux-x86_64-304.22/kernel/nv-pat.o /tmp/selfgz10141/NVIDIA-Linux-x86_64-304.22/kernel/nv-procfs.o /tmp/selfgz10141/NVIDIA-Linux-x86_64-304.22/kernel/nv-usermap.o /tmp/selfgz10141/NVIDIA-Linux-x86_64-304.22/kernel/nv-vm.o /tmp/selfgz10141/NVIDIA-Linux-x86_64-304.22/kernel/nv-vtophys.o /tmp/selfgz10141/NVIDIA-Linux-x86_64-304.22/kernel/os-agp.o /tmp/selfgz10141/NVIDIA-Linux-x86_64-304.22/kernel/os-interface.o /tmp/selfgz10141/NVIDIA-Linux-x86_64-304.22/kernel/os-mtrr.o /tmp/selfgz10141/NVIDIA-Linux-x86_64-304.22/kernel/os-registry.o /tmp/selfgz10141/NVIDIA-Linux-x86_64-304.22/kernel/os-smp.o /tmp/selfgz10141/NVIDIA-Linux-x86_64-304.22/kernel/os-usermap.o         (cat /dev/null;   echo kernel//tmp/selfgz10141/NVIDIA-Linux-x86_64-304.22/kernel/nvidia.ko;) > /tmp/selfgz10141/NVIDIA-Linux-x86_64-304.22/kernel/modules.order        make -f /usr/src/linux-headers-3.2.0-3-common/scripts/Makefile.modpost          scripts/mod/modpost -m  -i /usr/src/linux-headers-3.2.0-3-amd64/Module.symvers -I /tmp/selfgz10141/NVIDIA-Linux-x86_64-304.22/kernel/Module.symvers  -o /tmp/selfgz10141/NVIDIA-Linux-x86_64-304.22/kernel/Module.symvers -S -w  -s        NVIDIA: left KBUILD.        nvidia.ko failed to build!        make[1]: *** [module] Error 1        make: *** [module] Error 2     -> Error.     ERROR: Unable to build the NVIDIA kernel module.     ERROR: Installation has failed.  Please see the file '/var/log/nvidia-installer.log' for details.  You may find suggestions on fixing installation problems in the README available on the Linux driver download page at www.nvidia.com.      **UPDATE #2:** As per the suggestion of _StarNamer_ , I did reinstall `linux- headers-3.2.0-3-amd64`. After that was done, DKMS kicked in and tried again to compile the NVIDIA driver. Here's the contents of the file `/var/lib/dkms/nvidia/304.22/build/make.log`:               DKMS make.log for nvidia-304.22 for kernel 3.2.0-3-amd64 (x86_64)     Sun Jul 22 14:50:58 EEST 2012     If you are using a Linux 2.4 kernel, please make sure     you either have configured kernel sources matching your     kernel or the correct set of kernel headers installed     on your system.          If you are using a Linux 2.6 kernel, please make sure     you have configured kernel sources matching your kernel     installed on your system. If you specified a separate     output directory using either the "KBUILD_OUTPUT" or     the "O" KBUILD parameter, make sure to specify this     directory with the SYSOUT environment variable or with     the equivalent nvidia-installer command line option.          Depending on where and how the kernel sources (or the     kernel headers) were installed, you may need to specify     their location with the SYSSRC environment variable or     the equivalent nvidia-installer command line option.          *** Unable to determine the target kernel version. ***          make: *** [select_makefile] Error 1      **UPDATE #3:** After days and days of googling, I started to wonder if that's NVIDIA's fault at all. Turns out, it's not. I tried to install Virtual Box 4.1 (from the `testing` repo), and I stumbled upon **this again** :               # cat /var/lib/dkms/virtualbox/4.1.18/build/make.log      DKMS make.log for virtualbox-4.1.18 for kernel 3.2.0-3-amd64 (x86_64)     Tue Jul 24 17:58:57 EEST 2012     make: Entering directory `/usr/src/linux-headers-3.2.0-3-amd64'       LD      /var/lib/dkms/virtualbox/4.1.18/build/built-in.o       LD      /var/lib/dkms/virtualbox/4.1.18/build/vboxdrv/built-in.o       CC [M]  /var/lib/dkms/virtualbox/4.1.18/build/vboxdrv/linux/SUPDrv-linux.o     ... snipped ...       CC [M]  /var/lib/dkms/virtualbox/4.1.18/build/vboxpci/SUPR0IdcClientComponent.o       CC [M]  /var/lib/dkms/virtualbox/4.1.18/build/vboxpci/linux/SUPR0IdcClient-linux.o       LD [M]  /var/lib/dkms/virtualbox/4.1.18/build/vboxpci/vboxpci.o       Building modules, stage 2.       MODPOST 0 modules     make: Leaving directory `/usr/src/linux-headers-3.2.0-3-amd64'      And of course, no more details (as already have been said, it does _seem_ like a linker problem, but I cannot be sure yet). So this must be more of a Debian / DKMS problem or misconfiguration of some kind. However, I swear I didn't touch anything. I was simply doing daily `apt-get upgrade`-s. Then _something_ went not so well, obviously. **UPDATE #4:** I did try create a small module as described here: http://stackoverflow.com/questions/4715259/linux-modpost-does-not-build- anything. Indeed I am still seeing `MODPOST 0 modules`. Here's the output when I put `V=1` in the Makefile:               # make     make -C /lib/modules/3.2.0-3-amd64/build M=/home/dimi/code/hello V=1 modules     make[1]: Entering directory `/usr/src/linux-headers-3.2.0-3-amd64'     make -C /usr/src/linux-headers-3.2.0-3-amd64 \         KBUILD_SRC=/usr/src/linux-headers-3.2.0-3-common \         KBUILD_EXTMOD="/home/dimi/code/hello" -f /usr/src/linux-headers-3.2.0-3-common/Makefile \         modules     test -e include/generated/autoconf.h -a -e include/config/auto.conf || (        \         echo;                               \         echo "  ERROR: Kernel configuration is invalid.";       \         echo "         include/generated/autoconf.h or include/config/auto.conf are missing.";\         echo "         Run 'make oldconfig && make prepare' on kernel src to fix it.";  \         echo;                               \         /bin/false)     mkdir -p /home/dimi/code/hello/.tmp_versions ; rm -f /home/dimi/code/hello/.tmp_versions/*     make -f /usr/src/linux-headers-3.2.0-3-common/scripts/Makefile.build obj=/home/dimi/code/hello        gcc-4.6 -Wp,-MD,/home/dimi/code/hello/.hello.o.d  -nostdinc -isystem /usr/lib/gcc/x86_64-linux-gnu/4.6/include -I/usr/src/linux-headers-3.2.0-3-common/arch/x86/include -Iarch/x86/include/generated -Iinclude  -I/usr/src/linux-headers-3.2.0-3-common/include -include /usr/src/linux-headers-3.2.0-3-common/include/linux/kconfig.h   -I/home/dimi/code/hello -D__KERNEL__ -Wall -Wundef -Wstrict-prototypes -Wno-trigraphs -fno-strict-aliasing -fno-common -Werror-implicit-function-declaration -Wno-format-security -fno-delete-null-pointer-checks -Os -m64 -mtune=generic -mno-red-zone -mcmodel=kernel -funit-at-a-time -maccumulate-outgoing-args -fstack-protector -DCONFIG_AS_CFI=1 -DCONFIG_AS_CFI_SIGNAL_FRAME=1 -DCONFIG_AS_CFI_SECTIONS=1 -DCONFIG_AS_FXSAVEQ=1 -pipe -Wno-sign-compare -fno-asynchronous-unwind-tables -mno-sse -mno-mmx -mno-sse2 -mno-3dnow -Wframe-larger-than=2048 -Wno-unused-but-set-variable -fomit-frame-pointer -g -Wdeclaration-after-statement -Wno-pointer-sign -fno-strict-overflow -fconserve-stack -DCC_HAVE_ASM_GOTO  -DMODULE  -D"KBUILD_STR(s)=#s" -D"KBUILD_BASENAME=KBUILD_STR(hello)"  -D"KBUILD_MODNAME=KBUILD_STR(hello)" -c -o /home/dimi/code/hello/.tmp_hello.o /home/dimi/code/hello/hello.c     (cat /dev/null;   echo kernel//home/dimi/code/hello/hello.ko;) > /home/dimi/code/hello/modules.order     make -f /usr/src/linux-headers-3.2.0-3-common/scripts/Makefile.modpost       scripts/mod/modpost -m  -i /usr/src/linux-headers-3.2.0-3-amd64/Module.symvers -I /home/dimi/code/hello/Module.symvers  -o /home/dimi/code/hello/Module.symvers -S -w -c -s     make[1]: Leaving directory `/usr/src/linux-headers-3.2.0-3-amd64'      And here is what I see when I remove `V=1`:               # make     make -C /lib/modules/3.2.0-3-amd64/build M=/home/dimi/code/hello modules     make[1]: Entering directory `/usr/src/linux-headers-3.2.0-3-amd64'       CC [M]  /home/dimi/code/hello/hello.o       Building modules, stage 2.       MODPOST 0 modules     make[1]: Leaving directory `/usr/src/linux-headers-3.2.0-3-amd64'      Someone, please! I cannot be the only one who ever had this problem!


How to understand what's taking up space?

I'm looking for a linux alternative to WinDirStat. I would like to know what is taking up space on my hard drives. A program that works on console and doesn't require a UI is preferred .


Command line linux alternative for Windirstat/SpaceMonger?

> **Possible Duplicate:**   >  How to understand what's taking up space? What's a good command line utility/script to analyze a folder structure and find out what's taking up all the space? The granularity of `df` is way to large. Specifically I'd like something that can run with limited permissions (e.g. on shared hosting) I seem to be running on Redhat, if that matters.


Disk space disappearing

> **Possible Duplicate:**   >  How to understand what's taking up space? Hi, I am using Ubuntu 10.10.   I have 40G of disk space in my partition /home and have used up 10 G of it, so I should have 30G left. But somehow disk space disappeared almost completely. I don't know what ate up the disk space. I checked with `ps ax` and then `du` and couldn't find strange activities.   I would need to reboot the system to recover the free space! Any ideas?


Init script partially launches java app

I have a java application that I manage to execute by hand. The application normally opens several ports for local communications (7180 => 7183). Port 7182 serves as a web console and allows me to quickly check that everything went fine.               java -cp $ARCHIVES -Djava.security.policy=$POLICY -Dconfigfile=$CONFIG_FILE $CLASS      As soon as I put this in an init script, the ports are not open but the app somehow manages to start with the following message: 'Dead or echo port not responding'. Here is the start-stop-daemon line in my init script:               start-stop-daemon --start --chuid thomas --quiet --make-pidfile --pidfile $PIDFILE --exec $DAEMON -- \         $DAEMON_ARGS \      What difference between manual execution and scripted execution could explain that the app is half started? * * * As an additionnal information, the application is SIPS Office Server (payment solution).


Is there any way to deploy an virtual machine software via command line on centos3

I have a centos3 based legacy distribution with all the desktop environment removed. I have only access via command line. I am now asked to run a centos 6.1 distribution on a virtual machine on this system. From what I understand, the virtual machine software (qemu, vmplayer, virtual box) will have to create a window to show the guest operating system and will therefore need a desktop environment. Is there any way possible to run centos 6.1 via virtual machine without a desktop environment?


How can I see moved lines in a file comparison with vimdiff / diff?

Moved lines are frequently annotated as deletes and adds but they can be shown as moved-from and moved-to instead. Like in this screenshot of Notepad++. ![Notepad++ diff'ing moved lines](http://i.stack.imgur.com/jF26O.png)


How can I get distribution name and version number in a simple shell script?

I'm working on a simple bash script that should be able to run on Ubuntu and CentOS distributions (support for Debian and Fedora/RHEL would be a plus) and I need to know the name and version of the distribution the script is running (in order to trigger specific actions, for instance the creation of repositories). So far what I've got is this:               OS=$(awk '/DISTRIB_ID=/' /etc/*-release | sed 's/DISTRIB_ID=//' | tr '[:upper:]' '[:lower:]')     ARCH=$(uname -m | sed 's/x86_//;s/i[3-6]86/32/')     VERSION=$(awk '/DISTRIB_RELEASE=/' /etc/*-release | sed 's/DISTRIB_RELEASE=//' | sed 's/[.]0/./')          if [ -z "$OS" ]; then         OS=$(awk '{print $1}' /etc/*-release | tr '[:upper:]' '[:lower:]')     fi          if [ -z "$VERSION" ]; then         VERSION=$(awk '{print $3}' /etc/*-release)     fi          echo $OS     echo $ARCH     echo $VERSION      This _seems_ to work, returning `ubuntu` or `centos` (I haven't tried others) as the release name however, I have a feeling that there must be an easier, more reliable way of finding this out... No? It doesn't work for RedHat. /etc/redhat-release contains : Redhat Linux Entreprise release 5.5 So, the version is not the third word, you'd better use :               OS_MAJOR_VERSION=`sed -rn 's/.*([0-9])\.[0-9].*/\1/p' /etc/redhat-release`     OS_MINOR_VERSION=`sed -rn 's/.*[0-9].([0-9]).*/\1/p' /etc/redhat-release`     echo "RedHat/CentOS $OS_MAJOR_VERSION.$OS_MINOR_VERSION"


How to determine distribution from command line?

> **Possible Duplicate:**   >  Bash: Get Distribution Name and Version Number Given (root) access to a machine with Linux through the command line(over ssh), how can I determine which distribution is actually running on the system?


Reading Linux distribution name from filesystem or command

I need to collect some system info from linux machines and decide what to do based on some distribution/version -specific conditionals. To simplify my example, I concocted a fictitious `my_function_display_operating_system` function. It is a useless function but it frames the problem:   1. detect the general OS type (osx, linux, etc.)   2. detect some version information about the OS   3. detect the distribution _friendly name_ Point `3.` is what I most need help with, please. Is there a reliable way to read a string indicating the host linux distribution name? I am using `/etc/issue` in the example below as I know of no other way, or set of ways, to get to this information. I am happy with a _it depends_ answer, I can build a quite involved `case` `esac` switch statement if need be. I just need to know where to look, and I can't download/install VMs for all the distros I know of to "look around" and/or grep for the name.. * * *               # Displays operating system.          function my_function_display_operating_system() {       local operating_system       case $my_global_os_type in         OSX)           printf -v operating_system \                     'OS X v%s (build %s)' \                     $(sw_vers -productVersion) \                     $(sw_vers -buildVersion)           ;;         Linux)           local -r linux_kernel_version=$(uname -r)           printf -v operating_system \                     'GNU/Linux (kernel %s)' \                     "$linux_kernel_version"           if [[ -f /etc/issue ]]; then             local -r distribution=$(cat /etc/issue | sed 's/ \\n \\l//g')             operating_system+="\nDistribution: $distribution"           fi           ;;         *)           operating_system=Unknown           ;;       esac       printf "Operating system: $operating_system\n"     }      * * * Sample output: * * *               > my_function_display_system_information     Operating system   GNU/Linux (kernel 3.5.0-25-generic)     Distribution       Ubuntu 12.10     System memory      1 GB     Bash               v4.2.37(1)-release     Vim                VIM - Vi IMproved 7.3 (2010 Aug 15, compiled Oct 26 2012 16  45  54)     # ... etc ...      * * *


How do I identify which Linux distro is running?

We have some new hardware in our office which runs its own customized Linux OS. How do I go about figuring which distro it's based on?


Finding out what Linux I'm running

> **Possible Duplicate:**   >  Bash: Get Distribution Name and Version Number Is there any consistent way of determining the Linux Distribution / Release that a machine is running if you don't already know what it is? Assume that no GUI access is possible.


Figure out which distro I'm using with Zsh script

I'm making a script that installs some basic needs of mine on my newly installed Linux. However depending on the Linux distro the contents and commands would be different. In Arch Linux I would use `pacman -S ...`, in Ubuntu I would use `apt-get ...`. So my question is how I can differentiate all of these different distros? Of course it would go along with differentiating the kernel as well (if possible). Thanks for your help!


How can I identify the variant of Unix/Linux from a shell?

> **Possible Duplicate:**   >  How can I get distribution name and version number in a simple shell > script? Given a shell, how can I identify the variant of Unix/Linux that is running on a remote server?


find action not working for specific search

I'm trying to use the `find` command to list the size of a certain set of files but am getting no output. The command I use is:               find POD -type f -name *.mp3 -or -name *.ogg -ls      Which produces no output. While:               find POD -type f -name *.mp3 -or -name *.ogg      does produce output, I've also tried the actions:               -printf "%p %k KB\n"     -exec ls -ls '{}' \;     -print0      but all of these give no output. When I use any of these actions with a different expression e.g.:               find . -maxdepth 1 -type f -printf "%p %k KB\n"      I also get the expected output. Does anybody have any idea what the problem is? I'm running:               Linux irimi 3.10.37-1-MANJARO #1 SMP Mon Apr 14 20:56:29 UTC 2014 x86_64 GNU/Linux      aka an up to date Manjaro linux distribution. The shell I use is: `/bin/bash` version `4.3.8(1)-release`. The content of my `SHELLOPTS` environment variable is:               braceexpand:emacs:hashall:histexpand:history:interactive-comments:monitor      my `BASHOPTS` environment variable is:               cdspell:checkwinsize:cmdhist:complete_fullquote:dotglob:expand_aliases:extglob:extquote:force_fignore:histappend:hostcomplete:interactive_comments:nocaseglob:progcomp:promptvars:sourcepath      Again any help on trying to debug this would be very much appreciated.


Cannot access disk, partition table broken

I was so dumb, to turn of the power on my Readynas Ultra 4 when it was installing the disk (3TB WD Green), I had no time to wait for it as I was going to return it (It was to damn noisy) The disk installation was at 0% and stayed like that for 2minutes, so I decided to turn it off without really thinking about the consequences. Anyways, now it’s done, and I need to put it into my new NAS (Synology 413j), but that’s not going very good. The disk is recognized in BIOS, and I get it up as /dev/sdc when i run gparted live on USB. But it is not shown in Windows device manager or in ubuntu. When I run sudo gparted on a live ubuntu USB, I get Input/output error during read on /dev/sdc. I have tried more stuff in gparted live, but to sum it up, it is very similar to whats happening here: http://ubuntuforums.org/archive/index.php/t-1492414.html Up to the part where he runs badsectors, and get alot of errors, I ran badsectors -vs (I guess that is just read, and show output. I ran it for about 3000sectors, and for each block it counted the output was: (and so on)               1     2     3     4     5     6     7     8     9     10     11     12     13     140.00% done, 0:01 elapsed. (14/0/0 errors)     15     16     17     18     19     20     21     22     23     24     25     26     27     28     29     30     310.00% done, 0:02 elapsed. (31/0/0 errors)      In gparted(live) the /dev/sdc disk shows, but its all unallocated, and it shows an input/output read error when it scans all disks. When I try to create a new partition, I get an error with no partition table. I go to device - create partition table, and select gpt, I get about 5-6 errors with input/output read and also write on /dev/sdc. When I enter gdisk on gparted(live) I get:               Warning! Read error 5; strange behavior now likely!     Warning! Read error 5; strange behavior now likely!     Partition table scan:     MBR: not present     BSD: not present     APM: not present     GPT: not present          Creating new GPT entries.      When I run smartctl:               ubuntu@ubuntu:~$ sudo smartctl --all /dev/sdc     smartctl 5.41 2011-06-09 r3365 [x86_64-linux-3.2.0-29-generic] (local build)     Copyright (C) 2002-11 by Bruce Allen, http://smartmontools.sourceforge.net          === START OF INFORMATION SECTION ===     Device Model:     WDC WD30EZRX-00MMMB0     Serial Number:    WD-WCAWZ2205xxxxx     LU WWN Device Id: 5 0014ee 25c5f8480     Firmware Version: 80.00A80     User Capacity:    3,000,592,982,016 bytes [3.00 TB]     Sector Sizes:     512 bytes logical, 4096 bytes physical     Device is:        Not in smartctl database [for details use: -P showall]     ATA Version is:   8     ATA Standard is:  Exact ATA specification draft version not indicated     Local Time is:    Sat Sep 29 15:53:44 2012 UTC     SMART support is: Available - device has SMART capability.     SMART support is: Enabled          === START OF READ SMART DATA SECTION ===     SMART overall-health self-assessment test result: PASSED          General SMART Values:     Offline data collection status:  (0x84)    Offline data collection activity                         was suspended by an interrupting command from host.                         Auto Offline Data Collection: Enabled.     Self-test execution status:      (   0)    The previous self-test routine completed                         without error or no self-test has ever                         been run.     Total time to complete Offline     data collection:         (50700) seconds.     Offline data collection     capabilities:              (0x7b) SMART execute Offline immediate.                         Auto Offline data collection on/off support.                         Suspend Offline collection upon new                         command.                         Offline surface scan supported.                         Self-test supported.                         Conveyance Self-test supported.                         Selective Self-test supported.     SMART capabilities:            (0x0003)    Saves SMART data before entering                         power-saving mode.                         Supports SMART auto save timer.     Error logging capability:        (0x01)    Error logging supported.                         General Purpose Logging supported.     Short self-test routine     recommended polling time:      (   2) minutes.     Extended self-test routine     recommended polling time:      ( 255) minutes.     Conveyance self-test routine     recommended polling time:      (   5) minutes.     SCT capabilities:            (0x3035)    SCT Status supported.                         SCT Feature Control supported.                         SCT Data Table supported.          SMART Attributes Data Structure revision number: 16     Vendor Specific SMART Attributes with Thresholds:     ID# ATTRIBUTE_NAME          FLAG     VALUE WORST THRESH TYPE      UPDATED  WHEN_FAILED RAW_VALUE       1 Raw_Read_Error_Rate     0x002f   200   200   051    Pre-fail  Always       -       0       3 Spin_Up_Time            0x0027   199   140   021    Pre-fail  Always       -       7050       4 Start_Stop_Count        0x0032   100   100   000    Old_age   Always       -       483       5 Reallocated_Sector_Ct   0x0033   200   200   140    Pre-fail  Always       -       0       7 Seek_Error_Rate         0x002e   200   200   000    Old_age   Always       -       0       9 Power_On_Hours          0x0032   100   100   000    Old_age   Always       -       572      10 Spin_Retry_Count        0x0032   100   100   000    Old_age   Always       -       0      11 Calibration_Retry_Count 0x0032   100   100   000    Old_age   Always       -       0      12 Power_Cycle_Count       0x0032   100   100   000    Old_age   Always       -       142     192 Power-Off_Retract_Count 0x0032   200   200   000    Old_age   Always       -       31     193 Load_Cycle_Count        0x0032   198   198   000    Old_age   Always       -       8522     194 Temperature_Celsius     0x0022   114   095   000    Old_age   Always       -       38     196 Reallocated_Event_Count 0x0032   200   200   000    Old_age   Always       -       0     197 Current_Pending_Sector  0x0032   200   200   000    Old_age   Always       -       1     198 Offline_Uncorrectable   0x0030   200   200   000    Old_age   Offline      -       0     199 UDMA_CRC_Error_Count    0x0032   200   200   000    Old_age   Always       -       0     200 Multi_Zone_Error_Rate   0x0008   200   200   000    Old_age   Offline      -       0          SMART Error Log Version: 1     No Errors Logged          SMART Self-test log structure revision number 1     Num  Test_Description    Status                  Remaining  LifeTime(hours)  LBA_of_first_error     # 1  Short offline       Completed: read failure       90%       569         42084912     # 2  Short offline       Completed without error       00%       388         -          SMART Selective self-test log data structure revision number 1      SPAN  MIN_LBA  MAX_LBA  CURRENT_TEST_STATUS         1        0        0  Not_testing         2        0        0  Not_testing         3        0        0  Not_testing         4        0        0  Not_testing         5        0        0  Not_testing     Selective self-test flags (0x0):       After scanning selected spans, do NOT read-scan remainder of disk.     If Selective self-test is pending on power-up, resume after 0 minute delay.      My gdisk session under here: But the most usefull I got to in the end: Warning! Main partition table overlaps the first partition by 34 blocks! You will need to delete this partition or resize it in another utility.               user@debian:~$ sudo gdisk     GPT fdisk (gdisk) version 0.8.5          Type device filename, or press <Enter> to exit: /dev/sdc     Warning! Read error 5; strange behavior now likely!     Warning! Read error 5; strange behavior now likely!     Partition table scan:       MBR: not present       BSD: not present       APM: not present       GPT: not present          Creating new GPT entries.          Command (? for help): ?     b   back up GPT data to a file     c   change a partition's name     d   delete a partition     i   show detailed information on a partition     l   list known partition types     n   add a new partition     o   create a new empty GUID partition table (GPT)     p   print the partition table     q   quit without saving changes     r   recovery and transformation options (experts only)     s   sort partitions     t   change a partition's type code     v   verify disk     w   write table to disk and exit     x   extra functionality (experts only)     ?   print this menu          Command (? for help): n     Partition number (1-128, default 1): 1     First sector (34-5860533134, default = 2048) or {+-}size{KMGTP}: 2048     Last sector (2048-5860533134, default = 5860533134) or {+-}size{KMGTP}: 5860533134     Current type is 'Linux filesystem'     Hex code or GUID (L to show codes, Enter = 8300): l      0700 Microsoft basic data  0c01 Microsoft reserved    2700 Windows RE               4200 Windows LDM data      4201 Windows LDM metadata  7501 IBM GPFS                 7f00 ChromeOS kernel       7f01 ChromeOS root         7f02 ChromeOS reserved        8200 Linux swap            8300 Linux filesystem      8301 Linux reserved           8e00 Linux LVM             a500 FreeBSD disklabel     a501 FreeBSD boot             a502 FreeBSD swap          a503 FreeBSD UFS           a504 FreeBSD ZFS              a505 FreeBSD Vinum/RAID    a580 Midnight BSD data     a581 Midnight BSD boot        a582 Midnight BSD swap     a583 Midnight BSD UFS      a584 Midnight BSD ZFS         a585 Midnight BSD Vinum    a800 Apple UFS             a901 NetBSD swap              a902 NetBSD FFS            a903 NetBSD LFS            a904 NetBSD concatenated      a905 NetBSD encrypted      a906 NetBSD RAID           ab00 Apple boot               af00 Apple HFS/HFS+        af01 Apple RAID            af02 Apple RAID offline       af03 Apple label           af04 AppleTV recovery      af05 Apple Core Storage       be00 Solaris boot          bf00 Solaris root          bf01 Solaris /usr & Mac Z     bf02 Solaris swap          bf03 Solaris backup        bf04 Solaris /var             bf05 Solaris /home         bf06 Solaris alternate se  bf07 Solaris Reserved 1       bf08 Solaris Reserved 2    bf09 Solaris Reserved 3    bf0a Solaris Reserved 4       bf0b Solaris Reserved 5    c001 HP-UX data            c002 HP-UX service            ef00 EFI System            ef01 MBR partition scheme  ef02 BIOS boot partition      fd00 Linux RAID                 Hex code or GUID (L to show codes, Enter = 8300): ef01     Changed type of partition to 'MBR partition scheme'          Command (? for help): ?     b   back up GPT data to a file     c   change a partition's name     d   delete a partition     i   show detailed information on a partition     l   list known partition types     n   add a new partition     o   create a new empty GUID partition table (GPT)     p   print the partition table     q   quit without saving changes     r   recovery and transformation options (experts only)     s   sort partitions     t   change a partition's type code     v   verify disk     w   write table to disk and exit     x   extra functionality (experts only)     ?   print this menu          Command (? for help): w          Final checks complete. About to write GPT data. THIS WILL OVERWRITE EXISTING     PARTITIONS!!          Do you want to proceed? (Y/N): Y     OK; writing new GUID partition table (GPT) to /dev/sdc.     Unable to save backup partition table! Perhaps the 'e' option on the experts'     menu will resolve this problem.     Warning! An error was reported when writing the partition table! This error     MIGHT be harmless, or the disk might be damaged! Checking it is advisable.          Command (? for help): o        This option deletes all partitions and creates a new protective MBR.     Proceed? (Y/N): Y          Command (? for help): p     Disk /dev/sdc: 5860533168 sectors, 2.7 TiB     Logical sector size: 512 bytes     Disk identifier (GUID): 3995C753-D73D-4386-8818-3A9AF06E3B2C     Partition table holds up to 128 entries     First usable sector is 34, last usable sector is 5860533134     Partitions will be aligned on 2048-sector boundaries     Total free space is 5860533101 sectors (2.7 TiB)          Number  Start (sector)    End (sector)  Size       Code  Name          Command (? for help): o     This option deletes all partitions and creates a new protective MBR.     Proceed? (Y/N): Y          Command (? for help): w          Final checks complete. About to write GPT data. THIS WILL OVERWRITE EXISTING     PARTITIONS!!          Do you want to proceed? (Y/N): Y     OK; writing new GUID partition table (GPT) to /dev/sdc.     Unable to save backup partition table! Perhaps the 'e' option on the experts'     menu will resolve this problem.     Warning! An error was reported when writing the partition table! This error     MIGHT be harmless, or the disk might be damaged! Checking it is advisable.          Command (? for help): p     Disk /dev/sdc: 5860533168 sectors, 2.7 TiB     Logical sector size: 512 bytes     Disk identifier (GUID): F1AE4B7D-9CCE-4211-BE3D-88DFFCCD3696     Partition table holds up to 128 entries     First usable sector is 34, last usable sector is 5860533134     Partitions will be aligned on 2048-sector boundaries     Total free space is 5860533101 sectors (2.7 TiB)          Number  Start (sector)    End (sector)  Size       Code  Name          Command (? for help): o     This option deletes all partitions and creates a new protective MBR.     Proceed? (Y/N): n          Command (? for help): ?     b   back up GPT data to a file     c   change a partition's name     d   delete a partition     i   show detailed information on a partition     l   list known partition types     n   add a new partition     o   create a new empty GUID partition table (GPT)     p   print the partition table     q   quit without saving changes     r   recovery and transformation options (experts only)     s   sort partitions     t   change a partition's type code     v   verify disk     w   write table to disk and exit     x   extra functionality (experts only)     ?   print this menu          Command (? for help): d     No partitions          Command (? for help): i     No partitions          Command (? for help): r          Recovery/transformation command (? for help): ?     b   use backup GPT header (rebuilding main)     c   load backup partition table from disk (rebuilding main)     d   use main GPT header (rebuilding backup)     e   load main partition table from disk (rebuilding backup)     f   load MBR and build fresh GPT from it     g   convert GPT into MBR and exit     h   make hybrid MBR     i   show detailed information on a partition     l   load partition data from a backup file     m   return to main menu     o   print protective MBR data     p   print the partition table     q   quit without saving changes     t   transform BSD disklabel partition     v   verify disk     w   write table to disk and exit     x   extra functionality (experts only)     ?   print this menu          Recovery/transformation command (? for help): f     Warning! This will destroy the currently defined partitions! Proceed? (Y/N): Y     Problem loading MBR! GPT is untouched; regenerating protective MBR!          Recovery/transformation command (? for help): ?     b   use backup GPT header (rebuilding main)     c   load backup partition table from disk (rebuilding main)     d   use main GPT header (rebuilding backup)     e   load main partition table from disk (rebuilding backup)     f   load MBR and build fresh GPT from it     g   convert GPT into MBR and exit     h   make hybrid MBR     i   show detailed information on a partition     l   load partition data from a backup file     m   return to main menu     o   print protective MBR data     p   print the partition table     q   quit without saving changes     t   transform BSD disklabel partition     v   verify disk     w   write table to disk and exit     x   extra functionality (experts only)     ?   print this menu          Recovery/transformation command (? for help): v          No problems found. 5860533101 free sectors (2.7 TiB) available in 1     segments, the largest of which is 5860533101 (2.7 TiB) in size.          Recovery/transformation command (? for help): b          Recovery/transformation command (? for help): c     Warning! This will probably do weird things if you've converted an MBR to     GPT form and haven't yet saved the GPT! Proceed? (Y/N): Y     Warning! Read error 5! Misbehavior now likely!     Caution! After loading partitions, the CRC doesn't check out!          Recovery/transformation command (? for help): w     Warning! Main partition table overlaps the first partition by 34 blocks!     You will need to delete this partition or resize it in another utility.     Aborting write of new partition table.      No matter what I try to do, I seem to get the input/output error, I tried installing ubuntu on it, and it seems to create the partition table, but when I start the install..input/output error. Anyone have any idea on how I can fix this? I’m happy to post more logfiles or whatever, but I’m not experienced with linux, I just use it for this kind of stuff. The disk is very new, just some moths, so I doubt it’s any bad sectors. Thank you for all input!


Starting a new instance of GDM in Fedora 19

In Fedora 18, I could use `gdmflexiserver` to start up a new instance of X and GDM on a new VT. In Fedora 19, `gdmflexiserver` appears to have lost the ability to do this, and I'm looking for its replacement.


What do the flags in /proc/cpuinfo mean?

How can I tell whether my processor has a particular feature? (64-bit instruction set, hardware-assisted virtualization, cryptographic accelerators, etc.) I know that the file `/proc/cpuinfo` contains this information, in the `flags` line, but what do all these cryptic abbreviations mean? For example, given the following extract from `/proc/cpuinfo`, do I have a 64-bit CPU? Do I have hardware virtualization?               model name      : Intel(R) Core(TM)2 Duo CPU     E8400  @ 3.00GHz     …     flags           : fpu vme de pse tsc msr pae mce cx8 apic sep mtrr pge mca cmov pat pse36 clflush dts acpi mmx fxsr sse sse2 ss ht tm pbe syscall nx lm constant_tsc arch_perfmon pebs bts rep_good aperfmperf pni dtes64 monitor ds_cpl vmx smx est tm2 ssse3 cx16 xtpr pdcm sse4_1 lahf_lm tpr_shadow vnmi flexpriority


256 color in real console

I have in my .bashrc               export TERM=xterm-256color      but this cause blinking all colored text (ls --color, in vim etc.) in real console (CTRL + ALT + F1) . So is there any possibility to recognize in which console I am (real or virtual) so I can export TERM variable with valid value? [EDIT] I found alternative solution only: for vim user (in .vimrc)               set t_Co=256      or for xterm in .Xdefaults (after that xrdb -load .Xdefaults)               XTerm*termName:         xterm-256color      or for screen (.screenrc)               term screen-256color


How to force Thunar to remember sort order for different folders?

I want all the files in my Downloads folder to be sorted by modification date, but all other folders, and files in other partitions to be sorted by name. How can I make Thunar to remember the sort order for different folders?


Building an Arch Linux based live CD/USB

After bootstrapping my Arch live CD, I try to install the `archiso` package with:               pacman -Sy archiso      but I get:               error: failed to commit transaction (conflicting files)     archiso: /usr/lib/initcpio/archiso_shutdown exists in filesystem     archiso: /usr/lib/initcpio/hooks/archiso exists in filesystem     archiso: /usr/lib/initcpio/hooks/archiso_loop_mnt exists in filesystem     archiso: /usr/lib/initcpio/hooks/archiso_pxe_common exists in filesystem     archiso: /usr/lib/initcpio/hooks/archiso_pxe_http exists in filesystem     archiso: /usr/lib/initcpio/hooks/archiso_pxe_nbd exists in filesystem     archiso: /usr/lib/initcpio/hooks/archiso_pxe_nfs exists in filesystem     archiso: /usr/lib/initcpio/hooks/archiso_shutdown exists in filesystem     archiso: /usr/lib/initcpio/install/archiso exists in filesystem     archiso: /usr/lib/initcpio/install/archiso_kms exists in filesystem     archiso: /usr/lib/initcpio/install/archiso_loop_mnt exists in filesystem     archiso: /usr/lib/initcpio/install/archiso_pxe_common exists in filesystem     archiso: /usr/lib/initcpio/install/archiso_pxe_http exists in filesystem     archiso: /usr/lib/initcpio/install/archiso_pxe_nbd exists in filesystem     archiso: /usr/lib/initcpio/install/archiso_pxe_nfs exists in filesystem     archiso: /usr/lib/initcpio/install/archiso_shutdown exists in filesystem     Errors occurred, no packages were upgraded.      I read pacman wiki. So I tried:               pacman -Qo  /usr/lib/initcpio/archiso_shutdown       and I get:               error: No package owns /usr/lib/initcpio/archiso_shutdown      As for: > If you had installed a program manually without using pacman or a frontend, > you have to remove it and all its files and reinstall properly using pacman. After bootstrapping the live CD, `pacman` is the first program run.


External ext4 drive unmounted after some time (Raspbian)

I am using BitTorrent Sync on my Raspberry Pi (Raspbian) which syncs files on the external hard drive (ext4). I wrote a small script that spins down the drive after 5 minutes of inactivity. As soon as I read something it starts to spin again, so that seems to work fine. Here is the spindown script which is executed every 5 minutes via cronjob:               # !/bin/sh          # Get new state from diskstats     NEWstate=$(cat /proc/diskstats | grep $1)     echo $NEWstate > /home/pi/bin/spindown/NEWstate.txt          # compare md5 sums     md5new=$(md5sum /home/pi/bin/spindown/NEWstate.txt | sed 's/ .*//')     md5old=$(md5sum /home/pi/bin/spindown/OLDstate.txt | sed 's/ .*//')          # if no changes, power down     if [ "$md5new" = "$md5old" ]; then             sdparm --flexible --command=stop /dev/$1 &>/dev/null     fi          # Write current state to file     echo $NEWstate > /home/pi/bin/spindown/OLDstate.txt      But after a few hours the hard drive is being unmounted and BT Sync can not work properly anymore. I want to use it as a private backup server so it should run all the time. It's mounted via the `/etc/fstab` file like this: `/dev/sda5 /media/External ext4 defaults,noatime 0 0 ` Is there a way that remounts the drive automatically as soon as it gets unmounted or (even better) prevents it from doing so?


Logrotate maually on FreeBSD 8

I am able to rotate any log file manually via logroatate like this:               logrotate -f /etc/logrotate.d/my-hourly-file      I want to know how to perform the same action on FreeBSD 8? My investigation shows that `newsyslog` can be used for this purpose. If so how can I download and install `newsyslog`? Update: I think `newsyslog` has been installed and modifying the `/etc/newsyslog.conf` file will be enough for automatic installation. But how can I trigger it manually? Update2: when I search all newsyslog words starting from /, I only found /etc/rc.d/newsyslog script. Inside the script I realized that newsyslog command is defined under /usr/sbin/newsyslog. But there is not newsyslog file under /usr/sbin/newsyslog. I am stuck that how I can install newsyslog package into FreBSD 8


grep on line before the match plus the match

zzzzzzzzz     aaaaaaaaa     bbbbbbbbb &     ccccccccc &     ddddddddd     hhhhhhhhh     eeeeeeeee     fffffffff &     ggggggggg &      in the above line, what i want is to `grep`/`sed`/`awk` (any method is fine) line that have `&` sign plus one line on top of them. so for example the desired output will look like :               aaaaaaaaa     bbbbbbbbb &     ccccccccc &     eeeeeeeee     fffffffff &     ggggggggg &      following is what i have tried with no luck.               egrep "&" | -b 1 file.txt


Use server name instead of IP address

Installed apache 2 in my Ubuntu server and I use many web application like osc, glpi. To browse these applications I have to write @ip/glpi in browser. my purpose is to use servername instead of ip address. What is the way to do this action System info: Ubuntu 11.10 PHP 5.3.6 Apache 2.2.20 MySQL 5.1.67


'who --message' -> which message?

I found the following in `man who`: > `-T, -w, --mesg` add user's message status as +, - or ?   >  `\--message` same as -T   >  `\--writable`same as -T   > So looked up `info who` and found > `-w -T --mesg --message --writable` After each login name print a character > indicating the user's message status   >  `+` allowing 'write' messages   >  `-` disallowing 'write' messages   >  `?` 'cannot find terminal device' **Question** : What 'message', which kind of 'message' is meant?


Redirecting output in the shell, permissions

I have a question about permissions. Distro: Debian GNU/Linux 6.0.4 (squeeze) So I have a folder with a php script in it. Both folder and file are owned by User1 If I do this: `php script.php` I get a permission denied error. Fair enough; I'm User2, not User1. If I do `sudo php script.php` this works because my user account is setup for that. So I wrote this script to accept an optional argument to output some stuff, like a "debug" mode, so if I do this: `sudo php script.php debug` It outputs some stuff to CLI. So far so good. But sometimes the output from the script is too long and I can't scroll up to see the output from the beginning, so I want to be able to redirect the output to a file. **So I have tried the following:** _This gives me a permission denied error._ `sudo php script.php debug >> results.txt` _This works_               sudo touch results.txt     sudo chown User1 results.txt     sudo chmod 777 results.txt     sudo php script.php debug >> results.txt      _Alternatively, this works_               sudo su -     php script.php debug >> results.txt      So what I want to know is... why did the first one give me a permission denied error? I thought the point of the sudo prefix is that I run the command as root, which works for running the php script...but it seems to me that this doesn't extend to executing the redirect? Can someone explain why? _**EDIT:_** So I found something from another post on here that works: `sudo php script.php debug | sudo tee results.txt` The answer there confirms my suspicion about the redirect still being run under my user and not sudo, but it doesn't explain why...can anybody explain why?


Overflow /tmp mounted when there is free space on /

I recently faced an "overflow" issue on `/tmp`. I don't have a separate `/tmp` partition, and there is 17% free in `/` - then why did I get an overflow `tmp` filesystem? ![enter image description here](http://i.stack.imgur.com/Z9gr3.png) ![enter image description here](http://i.stack.imgur.com/PC4yr.png)               # /etc/fstab: static file system information.     #     # Use 'blkid -o value -s UUID' to print the universally unique identifier     # for a device; this may be used with UUID= as a more robust way to name     # devices that works even if disks are added and removed. See fstab(5).     #     # <file system> <mount point>   <type>  <options>       <dump>  <pass>     proc            /proc           proc    nodev,noexec,nosuid 0       0     /dev/mapper/safesquid-root /               ext4    errors=remount-ro 0       1     # /boot was on /dev/sda1 during installation     UUID=d029e04b-11e9-42e1-b1d3-9cde73cb3b67 /boot           ext2    defaults        0       2     /dev/mapper/safesquid-swap_1 none            swap    sw              0       0      `mount` output               /dev/mapper/safesquid-root on / type ext4 (rw,errors=remount-ro)     proc on /proc type proc (rw,noexec,nosuid,nodev)     sysfs on /sys type sysfs (rw,noexec,nosuid,nodev)     none on /sys/fs/fuse/connections type fusectl (rw)     none on /sys/kernel/debug type debugfs (rw)     none on /sys/kernel/security type securityfs (rw)     udev on /dev type devtmpfs (rw,mode=0755)     devpts on /dev/pts type devpts (rw,noexec,nosuid,gid=5,mode=0620)     tmpfs on /run type tmpfs (rw,noexec,nosuid,size=10%,mode=0755)     none on /run/lock type tmpfs (rw,noexec,nosuid,nodev,size=5242880)     none on /run/shm type tmpfs (rw,nosuid,nodev)     /dev/sda1 on /boot type ext2 (rw)     overflow on /tmp type tmpfs (rw,size=1048576,mode=1777)     rpc_pipefs on /run/rpc_pipefs type rpc_pipefs (rw)     nfsd on /proc/fs/nfsd type nfsd (rw)               root@safesquid:~# free -m                  total       used       free     shared    buffers     cached     Mem:          2009        182       1826          0          9         48     -/+ buffers/cache:        124       1885     Swap:          715        130        585     root@safesquid:~# uname -a          Linux safesquid 2.6.32-41-server #94-Ubuntu SMP Fri Jul 6 18:15:07 UTC 2012 x86_64 x86_64 x86_64 GNU/Linux      I'm running Ubuntu 12.04.1 LTS. I also checked `df -i`, there are free inodes.


How to install parted?

root@host [/]# parted     -bash: parted: command not found      I am using CentOS. Looks like I simply have to yum it first or something. How would I do so?


How to enable libass on Linux?

I tried to enable libass for ffmpeg with this `\--enable-libass` in command but it didn't recognise the command. Does anyone know how to enable libass on Linux?


Set sudo password differently from login one

As a privileged user I am trying to set the `sudo` password to another then the one used at login. I have done some research but have not found an answer. Does `sudo` support that kind of configuration? _**Edit:_** The problem is that if you ever lose your password, you lose everything. Someone could log in and promote himself to `root` with the same password. `sudo` has an option to ask for `root` password instead of invoked user password, (`rootpw`), but sharing `root` password is definitely not an option, that is why we set up `sudo`. I did `config 2FA` in the past, it worked great, but also defeats the automation purpose. For example if you want to execute a privileged command across a dozen of servers with an `expect` script, adding `2FA` doesn't allow you to do that. The closest solution I have found is to only allow SSH private key and setup pass-phrase with a key which differs from the `sudo` (login) password. Still, it is not comfy, because in an emergency situation you can't login with a PC where it doesn't have that key.


Centos 6.3 on Oracle VirtualBox 4.3.6 GUI flickering after startup

My CentOS 6.3 installation in Oracle Virtual Box 4.3.6 was working fine until this morning when the UI would not startup properly and started flickering. ![image 1](http://s30.postimg.org/9f3z18jup/Cent_OS63.png) In the UI there is a white box (3x2 size) that flickers (was not able to capture it) continuously. I am able to login to the system using ssh using IP from another machine and I see all files are intact... not sure why the UI is not materializing properly. I even changed display memory in VirtualBox settings to 128MB but to no avail. Please help me to resolve this. I dont want to re-install the Centos again (setting up system again is quite a step). The below is the VirtualBox's log:               00:01:01.045427 AIOMgr: Endpoint for file 'E:\VirtualBox\VDI\CentOS63.vdi' (flags 000c0723) created successfully     00:01:01.079417 Changing the VM state from 'RESUMING' to 'RUNNING'.     00:01:02.559869 AIOMgr: Preparing flush failed with VERR_NOT_SUPPORTED, disabling async flushes     00:01:03.828410 Changing the VM state from 'RUNNING' to 'SUSPENDING'.     00:01:03.857120 PDMR3Suspend: after    28 ms, 1 loops: 1 async tasks - ahci/0     00:01:03.888235 AIOMgr: Endpoint for file 'E:\VirtualBox\VDI\CentOS63.vdi' (flags 000c0781) created successfully     00:01:03.979697 PDMR3Suspend: 151 237 774 ns run time     00:01:03.979715 Changing the VM state from 'SUSPENDING' to 'SUSPENDED'.     00:01:05.724688 Changing the VM state from 'SUSPENDED' to 'RESUMING'.     00:01:05.725398 AIOMgr: Endpoint for file 'E:\VirtualBox\VDI\CentOS63.vdi' (flags 000c0723) created successfully     00:01:05.760108 Changing the VM state from 'RESUMING' to 'RUNNING'.     00:01:09.391589 AIOMgr: Preparing flush failed with VERR_NOT_SUPPORTED, disabling async flushes     00:01:40.621357 Changing the VM state from 'RUNNING' to 'SUSPENDING'.     00:01:40.623377 AIOMgr: Endpoint for file 'E:\VirtualBox\VDI\CentOS63.vdi' (flags 000c0781) created successfully     00:01:40.664968 PDMR3Suspend: 43 513 184 ns run time     00:01:40.664986 Changing the VM state from 'SUSPENDING' to 'SUSPENDED'.     00:01:43.567279 Changing the VM state from 'SUSPENDED' to 'RESUMING'.     00:01:43.567908 AIOMgr: Endpoint for file 'E:\VirtualBox\VDI\CentOS63.vdi' (flags 000c0723) created successfully     00:01:43.601704 Changing the VM state from 'RESUMING' to 'RUNNING'.     00:01:44.142130 AIOMgr: Preparing flush failed with VERR_NOT_SUPPORTED, disabling async flushes      .. more...               00:46:49.034055 AIOMgr: Endpoint for file 'E:\VirtualBox\VDI\CentOS63.vdi' (flags 000c0723) created successfully     00:46:49.067998 Changing the VM state from 'RESUMING' to 'RUNNING'.     00:46:49.354161 AIOMgr: Preparing flush failed with VERR_NOT_SUPPORTED, disabling async flushes     00:48:27.339663 Guest Additions capability report: (0x4 -> 0x0) seamless: no, hostWindowMapping: no, graphics: no     00:48:27.348469 Display::handleDisplayResize(): uScreenId = 0, pvVRAM=0000000000000000 w=720 h=400 bpp=0 cbLine=0x0, flags=0x1     00:48:41.643962 OHCI: USB Reset     00:48:41.774693 Entering S5 power state (power down)     00:48:41.774768 Changing the VM state from 'RUNNING' to 'POWERING_OFF'.


Loop in WildCard as Input of Script

I want to use my script on many files sometimes. I used this for the purpose:               for etminput in $1     do         #process     done      But this just gives the first input. How can I do the process on every wildcard matches?


How can I append multiple extensions to a string with sed?

I want to create a script that will let me download images from entire subreddits at once, but I'm currently stuck on just getting the links right (one problem at a time! ^^). Anyway, since I can't think of a way to determine what format the image in the link will be, I was hoping _sed_ could be used to specify multiple extensions during replacement (e.g. (jpg|png|gif)), but this does not seem to work.               grep -E "href=\"/r/bacon/*" bacon.htm | sed "s .*/r/bacon/\(.*\)\".* http://i.imgur.com/\1.\(\jpg\|\png\|\gif\) "      expected:               http://i.imgur.com/foo.jpg     http://i.imgur.com/foo.png     http://i.imgur.com/foo.gif      got:               http://i.imgur.com/foo.(jpg|png|gif)      Google also does not seem to have an answer to this, admittedly, weird problem or at least I am having trouble coming up with meaningful ways to describe it. Any ideas or should I try this from a different angle?


How to run a script by shortkey in elementaryOS?

I want to be able to run certain scripts by shortcut the way I do in ubuntu - for example some similar to this awesome script. (On that model I can search google the text selected in any text editor, or even translate it various languages, search it on different sites, etc). How to use this type of script in elementaryOS?


Reusing a variable

I was breaking my head for a day still not successful. I have this script:               #!/bin/ksh          fname=$1          for batchname in $(grep -i "Processing batch" $fname | cut -d "'" -f2)     do     Batch_state=`grep -c -i "Batch '$batchname' was successful" $fname`     if [[ "$Batch_state"  -ge 1 ]];then     {     S_Time=`awk '/[0-9]_[0-9].*successful/{getline;getline;getline;print}' $fname | awk '{print $2}'`     E_Time=`awk '/[0-9]_[0-9].*successful/{getline;getline;getline;getline;print}' $fname | awk '{print $2}'`     echo -e $batchname"\t"$S_Time"\t"$E_Time     }     else     {     echo $batchname encountered an error     }     fi     done      Output this code is producing:               02_1231324      14:29:04 15:29:11   14:32:19 15:33:11     79_3097935      14:29:04 15:29:11   14:32:19 15:33:11      Desired Output:               02_1231324      14:29:04    14:32:19     79_3097935      15:29:11    15:33:11       Sample Input:               2013/06/11 14:29:04 <0999> (725102)     Creating batch '02_1231324.0'...     2013/06/11 14:29:04 <0999> (725102)     Batch '02_1231324' was successful     2013/06/11 14:29:04 <0999> (725102)     TMR:Child ZERO, 160 Docs 320 Pgs 3874 KByts Tot 0.42 WAL 0.10 WALIO 0.15 IO 0.03 secs     2013/06/11 14:29:04 <0999> (725102)  Processing batch '02_1231324'     2013/06/11 14:32:19 <0999> (725102)     Total in batch: 160 documents using 4 KBytes     2013/06/11 15:29:11 <0999> (725102)     Creating batch '79_3097935.0'...     2013/06/11 15:29:11 <0999> (725102)     Batch '79_3097935' was successful     2013/06/11 15:29:11 <0999> (725102)     TMR:Child ZERO, 160 Docs 320 Pgs 3874 KByts Tot 0.42 WAL 0.10 WALIO 0.15 IO 0.03 secs     2013/06/11 15:29:11 <0999> (725102)  Processing batch '79_3097935'     2013/06/11 15:33:11 <0999> (725102)     Total in batch: 160 documents using 4 KBytes     TMR:Child ZERO, 160 Docs 320 Pgs 3874 KByts Tot 0.42 WAL 0.10 WALIO 0.15 IO 0.03 secs     2013/06/11 13:26:57 <0999> (725102)  Processing batch '12_2013162201'     2013/06/11 13:26:57 <0999> (725102)     Total in batch: 160 documents using 4 KBytes      So, what is wrong with my script? How can I get the desired output?


How do I install Exim and Horde on Centos 7 with MariaDB 10?

I can't find a guide for this (they are old and don't work) and I can't seem to manage to install it. I can't install Postfix because of its dependencies, so I'm going with Exim, which I installed through `yum install exim` and it was the latest version. However, I have no idea where to go from here. I know that I need to install Dovecot or Cyrus and I want to install Horde (not Squirrelmail). Not to mention that I also want to keep MariaDB 10, which I installed from its repository, as well as PHP 5.5. I don't know where to go from here.


pysqlite install error on FreeBSD in virtualenv

I am trying to install pysqlite using pip under a virtualenv in FreeBSD 7.3, with Python version 2.6.2. I didn't have any issues for installing other packages like Django, PIL etc. All of them I installed after activating virtualenv only. But I get a huge error for `pip install sqlite`. Here's the tail of the error               src/module.c:426: warning: implicit declaration of function 'sqlite3_libversion'     src/module.c:426: warning: passing argument 1 of 'PyString_FromString' makes pointer from integer without a cast     error: command 'gcc' failed with exit status 1     Command /usr/home/myuser/python-sites/virtpython/bin/python -c "import setuptools;__file__='/usr/home/myuser/python-sites/virtpython/build/pysqlite/setup.py';exec(compile(open(__file__).read().replace('\r\n', '\n'), __file__, 'exec'))" install --record /usr/tmp/pip-N3U6Px-record/install-record.txt --single-version-externally-managed --install-headers /usr/home/myuser/python-sites/virtpython/include/site/python2.6 failed with error code 1 in /usr/home/myuser/python-sites/virtpython/build/pysqlite     Exception information:     Traceback (most recent call last):       File "/usr/home/myuser/python-sites/virtpython/lib/python2.6/site-packages/pip-1.2.1-py2.6.egg/pip/basecommand.py", line 107, in main         status = self.run(options, args)       File "/usr/home/myuser/python-sites/virtpython/lib/python2.6/site-packages/pip-1.2.1-py2.6.egg/pip/commands/install.py", line 261, in run         requirement_set.install(install_options, global_options)       File "/usr/home/myuser/python-sites/virtpython/lib/python2.6/site-packages/pip-1.2.1-py2.6.egg/pip/req.py", line 1166, in install         requirement.install(install_options, global_options)       File "/usr/home/myuser/python-sites/virtpython/lib/python2.6/site-packages/pip-1.2.1-py2.6.egg/pip/req.py", line 589, in install         cwd=self.source_dir, filter_stdout=self._filter_install, show_stdout=False)       File "/usr/home/myuser/python-sites/virtpython/lib/python2.6/site-packages/pip-1.2.1-py2.6.egg/pip/util.py", line 612, in call_subprocess         % (command_desc, proc.returncode, cwd))     InstallationError: Command /usr/home/myuser/python-sites/virtpython/bin/python -c "import setuptools;__file__='/usr/home/myuser/python-sites/virtpython/build/pysqlite/setup.py';exec(compile(open(__file__).read().replace('\r\n', '\n'), __file__, 'exec'))" install --record /usr/tmp/pip-N3U6Px-record/install-record.txt --single-version-externally-managed --install-headers /usr/home/myuser/python-sites/virtpython/include/site/python2.6 failed with error code 1 in /usr/home/myuser/python-sites/virtpython/build/pysqlite      'virtpython' is my virtualenv               % pkg_info | grep sqlite     sqlite-2.8.17_1     An SQL database engine in a C library     sqlite3-3.6.11      An SQL database engine in a C library      If there is a sqlite devel package for FreeBSD, where can I find it? Or the issue is something else??


Installing centos server in a virtual machine

I have little Unix/Linux experience, so sorry if this sounds stupid. What I want to do is simple: I want to learn CentOs so that I can manage my own web server. I did so by buying a dedicated and setting up CentOs. It's good, but the latency (around 300ms with Putty) is killing me when typing. So I have decided to setup CentOS on my local machine. I have Windows XP and Virtual Box installed. Simply, I want to install CentOs (the Server, not the Desktop GUI) either on the Virtual Box or as a separate OS (neck to neck with Windows XP) whichever is best and easier. I'm looking for suggestions or possible solutions. I'm overwhelmed with the tons of articles/packages out there. Thank you!


Running 'Leafpad' on terminal opens Gedit

I am running leafpad on the terminal but it opens gedit instead. Any Ideas why this happens? I am using Openbox btw.


Extract UNIX dump file in Windows 7

I have a dump-file of the UFS partition created with FreeBSD's `dump`. How to view its content and extract some files from it on Windows 7? Cygwin's `restore` provides very limited functionality and doesn't have an interactive mode like BSD's `restore`. Installing virtual machine is not a option. **Needs to be right on Windows.** Please help.


How to restore the original Backtrack Taskbar

I accidentally removed the my taskbar on Backtrack 5 and am having trouble returning it. If I minimize anything it gets lost and I can't access it again. How do I go about restoring it?


CentOS 6.3 Device eth0 does not seem to be present (Minimal non-cloned setup)

I installed CentOS 6.3 on my hardrive partition (new install...minimal install). After successful installation, I see that eth0 was down looked for 70-persistent-net.rules file under /etc/udev .. did not find it Here are my ifcfg-eth0 settings: **Note I had to create this file manually**               DEVICE=eth0     HWADDR=*     BOOTPROTO=dhcp     ONBOOT=yes     TYPE=ETHERNET      This machine is connected to ethernet(I have Windows 7 on another partition and I am able to connect to Internet)               ifconfig -a | grep eth      returns no result               ethtool eth0       returns `Cannot get device settings : No such device...` What can I try to get CentOS to detect eth0?


Locate disk in SAS enclosure

I want to blink the failing device in my 24-disk SAS enclosure. I have found `sg_ses --index 7 --set=locate /dev/sg24` which is supposed to identify slot 7. But how do I figure out which slot/index `/dev/sdh` is? This is not obvious as Linux does not name /dev/sdX after the slot, but after the sequence it was detected. Think what happens if slot 1 is empty at boot, but is filled later. Edit: The controller is a SAS2008.


\uFFFD character in directory name

I have a lot of directories with a \uFFFD (65533) character in it. The problem is that I can't really access this directory because of this character. For example I got a directory with the name: `Foo�o` (� == `\uFFFD`)   1. `ls Foo�o` is not working (so `tab` is always showing the only possible file but it will never complete it 'cause it's not working)   2. `ls Foo*` is working The problem is that I can't use the 2. way because there might be other directories starting with the same characters. So the actual question is if there's a way to escape a character like this. So I'm searching for a working version of this: `ls Foo\uFFFDo` <= not working


Failed updating posts on wordpress when use linux, but succeed on windows

I'm using Wordpress for blogging. And I use Windows 7 accompanied with Linux Mint on my PC. Recently I find that I can't update my posts on Wordpress when using Linux Mint. However, when I switch to Windows 7, I can update my post again. And another issue is I can upload files through FileZilla or FireFTP to my server on Linux Mint with no error, but the files become zero bytes. However, the same problem DOES NOT occur on Windows 7. So, what's the real cause? Should any settings to be done on the Linux network? ## Addition I have Linux Mint and Windows 7 Pro on my PC, both **not** running in a virtual machine. I use both Chrome (31.0.1626.0 dev) and Firefox (23.0) on Mint               No LSB modules are available     Distributor ID: LinuxMint     Description:    Linux Mint 15 Olivia     Release:    15     Codename:   olivia      for updating my posts but both browsers can't update the posts. ## Update Not only "Update" failed, "Save Draft", "Preview" and "Publish" all failed, even after I deactivated all the plugins.   Another issue occurs. On Linux Mint, I'm not able to post **questions with long content** on Stackoverflow, while on Windows 7 I can.


Emacs alternate editor client server start

How can I get Emacs to start in server mode with the alternate editor? From this conversation, I was able to enable the server with the alternate editor. However, I just re-installed emacs and I am receiving the following error now:               emacsclient: can't find socket; have you started the server?     To start the server in Emacs, type "M-x server-start".          Warning: due to a long standing Gtk+ bug      I added this to my bashrc:               #  aliases     # Emacs from the terminal as a client     alias emacs='emacsclient -t --alternate-editor='      but it isn't working as it did last time. I am on Emacs-snapshot-gtk. I was told this may be due to reading a server from another version so here is my `readlink` info.               dustin@dustin:~$ readlink -f $(type -p emacs)     /usr/bin/emacs-snapshot-gtk     dustin@dustin:~$ readlink -f $(type -p emacsclient)     /usr/bin/emacsclient.emacs-snapshot     dustin@dustin:~$      Does anyone know what I can do to fix this? * * * **Edit:** I found this add on for emacs: https://github.com/ahyatt/emacs-websocket However, I don't know if it will help or how to implement it.


Space left on Linux RAM/TMP,FS

Recently I have come to believe a number of unusual occurrences that have happened while running a Parted Magic Live CD, are the result of running out of space on the RAM based filesystem, namely:   * Folder contents disappearing, only to reappear later   * `Mount-gtk` not showing single mounted drive/not allowing unmount (While bash `mount` commands function normally)   * Firefox freezing, then seemingly freezing the GUI.   * My Firefox session recovering as if the browser crashes at each clean close   * Loosing last x minutes of Firefox session history   * Sound/clipboard redirection intermittently not working in `rdesktop`   * `Conky` crashing periodically ...Not despite the SpaceFM warning of no space to store state data **AND** some of these problems disappearing only after moving some files off the filesystem. Problem being, I am not sure how to (at least) keep an eye on the "space" left of the filesystem (Note: There is no entry for the `/` partition in the output of `df`, `fdisk -l` or `mount`), let alone (assuming I am right that the filesystem space not being relative to the system memory, that I had been monitoring with `conky`) how to go about increasing the sizing ?at boot time? Help? P.S Thought it most appropriate to tag this question with parted-magic, ramfs (or tmpfs... Not sure how to identify which one is in use) and low-disk-space like tags, but alas there doesn't appear to be any of them. If the community doesn't want to create one/all, please feel free to suggest other tags that others feel are appropriate.


What is "Exit 2" from finished background job status?

I have an exercise to put in a file some data (*conf from some directories) and need to do this in background. I did it and I am wondering what is the meaning of output messages:               [A@localhost tests]$ ls -ld /etc/*conf /usr/*conf > test1_6_conf.txt 2>&1 &      Enter rises this row:               [1] 2533      what does it mean? After other Enter, another messages appear               [A@localhost tests]$     [1]+  Exit 2                  ls --color=auto -ld /etc/*conf /usr/*conf > test1_6_conf.txt 2>&1      What does it mean? What is "Exit 2"? Enter an check results - seems to be all OK.               [A@localhost tests]$     [A@localhost tests]$ ls -l test1_6_conf.txt     -rw-rw-r--. 1 A A 2641 Nov 22 14:19 test1_6_conf.txt     [A@localhost tests]$       I am using CentOS 6.4, Gnome Terminal Emulator.


Is it possible to strace the builtin commands to Bash?

Inspired by this question, titled: When are the built-in commands loaded to memory, while attempting to answer this I tried the following command and was a bit surprised that I couldn't run it:               $ strace cd $HOME      Is there a method I can make use of to run strace for the builtin commands to Bash?


Fedora 18 in VM locks the CD drive

I have windows 7 and I installed VMware (VMware-player-5.0,2-1031769) and want to put fedora 18 in it but after complete installation is done I'm getting the below error: > The guest operating system has locked the cd-rom door and is probably using > the cd-rom which can prevent the guest from recognition media changes. If > possible eject the CD-ROM from inside the guest before the disconnection. Disconnect anyway and override the lock? Can anyone help me to come out of this problem...


Why does dd change the filesystem on the external disk?

I took out a 250 GB SATA disk from my netbook, filled it with zeroes with dd and connected it to my laptop via the usb adapter. It's correctly detected by fdisk:               Disk /dev/sdb: 250.1 GB, 250059350016 bytes     255 heads, 63 sectors/track, 30401 cylinders, total 488397168 sectors     Units = sectors of 1 * 512 = 512 bytes     Sector size (logical/physical): 512 bytes / 512 bytes     I/O size (minimum/optimal): 512 bytes / 512 bytes     Disk identifier: 0x475fa272             Device Boot      Start         End      Blocks   Id  System      I created a primary partition and used the following command to create a ext4 filesystem:               mkfs.ext4 /dev/sdb1      Now fidsk shows:               Disk /dev/sdb: 250.1 GB, 250059350016 bytes     81 heads, 63 sectors/track, 95707 cylinders, total 488397168 sectors     Units = sectors of 1 * 512 = 512 bytes     Sector size (logical/physical): 512 bytes / 512 bytes     I/O size (minimum/optimal): 512 bytes / 512 bytes     Disk identifier: 0x475fa272             Device Boot      Start         End      Blocks   Id  System     /dev/sdb1            2048   488397167   244197560   83  Linux      Ok, no surprise so far. Next, I wanted to extract Ubuntu ISO image with the following command:               dd if=~/ubuntu-12.10-desktop-i386.iso of=/dev/sdb      To my surprise, filesystem changed to 'Hidden HPFS/NTFS':               Disk /dev/sdb: 250.1 GB, 250059350016 bytes     19 heads, 24 sectors/track, 1071046 cylinders, total 488397168 sectors     Units = sectors of 1 * 512 = 512 bytes     Sector size (logical/physical): 512 bytes / 512 bytes     I/O size (minimum/optimal): 512 bytes / 512 bytes     Disk identifier: 0x475fa272             Device Boot      Start         End      Blocks   Id  System     /dev/sdb1   *          64     1542743      771340   17  Hidden HPFS/NTFS      What's the CORRECT way to extract ISO image to the external drive using dd with preserving the current filesystem?


FreeBSD 9 KDE4 No Mouse or keyboard at KDE login screen

Fresh Install of FreeBSD 9 and KDE 4. System boots to KDE log in screen, but no mouse or keyboard when I get there. I can `Ctrl``Alt``F1` out of the KDE. I Have the following lines in rc.conf:               moused_port="/dev/psm0"     moused_type="auto"     moused_enable"YES"     Option "AutoAddDevices" "false"     local_startup="$(local_start_up) /usr/local/kde4/etc/rc.d"     hald_enable="YES"     dbus_enable="YES"     kdm_enable="YES"


Automatically printing images with added captions

I have a lot of scanned images and images/photos I'm working on with multiple versions. When I print them (using various programs), all I get is the image and, often, it's difficult to tell which image came from which file. This is particularly frustrating with my (27K) photos when I have a print and want another copy and can't find it. (The photos are in KPhotoAlbum, so I can find the minority that I have actually tagged correctly.) What I would like is a utility that would print a bunch of images (e.g. doit *.jpg) and include an automatic (program generated) caption (hopefully configurable) with something like the full path of the file in it. gnome- photo-printer would be perfect if it had an option to print the full paths of the images with them. I need this while projects are in progress and for cleaning up afterwards. This is not for "final" images. It would be cool (and economical) if I could also specify the print size of the image because, often, smaller "thumbnail" images may be enough for organizing/cleaning up and they would save a bunch of time, paper, and ink/toner. I know I could manually create a document with an embedded picture in something like LO writer, but that would be totally manual (at least with my level of expertise) and thus very slow. It would be particularly nice to have the caption "outside" the picture so it would not interfere with the content and so I could control the background and font colors for readability. * * * I figured out (in principle) how to build something like this in bash using convert a couple of times along with composite (both from ImageMagick), but it's fairly convoluted and I'm hoping for something simpler.


Problems installing Arch Linux: cannot mount the installation media

> **Possible Duplicate:**   >  mounting problem during installation of archlinux on dell xps one I am trying to install Arch Linux on my Acer Aspire 4830tg, but I keep running into problems. I am trying to install Arch off a USB stick and I got the iso image using Bittorrent. I am also trying to install it alongside of Windows 8 (which is already installed). When I boot into Arch linux I get this error               :: Mounting '/dev/disk/by-label/ARCH_201212' to 'run/archiso/bootmnt'     Waiting 30 seconds for device /dev/disk/by-label/ARCH_201212 ...     ERROR: '/dev/disk/by-label/ARCH_201212' device did not show up after 30 seconds...     Falling back to interactive prompt     You can try to fix the problem manually, log out when you are finished     sh: can't access tty; job control turned off      So I know that it will work if I run it on a virtual machine but whenever I try to install it on my laptop I keep getting this error.


Why can't a normal user `chown` a file?

Why is the `chown` command root-only? Why can't non-root users use chown to give away files they own?


file owner not able to renounce the ownership to root? But root can!

I logged in as username 'ravbholua' I created a file `bb` as below:               ravbholua@ravi:~/Pictures$ echo>bb     ravbholua@ravi:~/Pictures$ ll     total 12     drwxr-xr-x  2 ravbholua sudo 4096 Oct 13 11:18 ./     drwxr-xr-x 23 root      sudo 4096 Oct 13 11:03 ../     -rw-r--r--  1 ravbholua sudo    1 Oct 13 11:18 bb     ravbholua@ravi:~/Pictures$      Please note the owner of `bb` is me (ravbholua). But I am not able to renounce the ownership to root.               ravbholua@ravi:~/Pictures$ chown root bb     chown: changing ownership of 'bb': Operation not permitted     ravbholua@ravi:~/Pictures$       But root can change the ownership of my file.               ravbholua@ravi:~/Pictures$ ll     total 12     drwxr-xr-x  2 ravbholua sudo 4096 Oct 13 11:18 ./     drwxr-xr-x 23 root      sudo 4096 Oct 13 11:03 ../     -rw-r--r--  1 root      sudo    1 Oct 13 11:18 bb     ravbholua@ravi:~/Pictures$      I am working on Ubuntu13.04 Earlier when I had worked on Fedora9, there the file owner was able to change the ownership. I think linux Operating System allows the file owner to do so.


can not chown a file from my $user to another $user

I am on slackware64 v14.0 and I have file that belongs to me:               -rwxrwxr-x+   1 nass  shares    137934 Mar  7 00:06 myfile.csv*      I am a member of the "shares" group. The folder that contains `myfile` looks like this               drwxrwsr-x+  12 nass shares 4096 Mar 12 04:54 winmx/      I now want to give ownership of this file to another user of this pc. The other user is also a member of the shares group. However,               chown otheruser myfile.csv         does not do the trick. I get a               chown: changing ownership of 'myfile.csv': Operation not permitted      I had recently asked a similar question about `gid`, but this is not the same problem. How can I solve this ?


Find all folders in a directory with the same content

In Ubuntu, is there any to find duplicate folders in a directory (i. e., folders with the same content)? I think there are already some command-line tools available for finding duplicate files (such as fdupes), but I want to find duplicate folders instead. That is, find folders which match in terms of the contents of the files they contain (though the filenames and other metadata might differ).


Printing connected users in bash script

I have a script file like this:               #!/bin/bash     clear           echo "The script starts now."     echo "Hi, user!"     echo           echo "I will now fetch you a list of connected users:"     echo      w          echo "I'm setting two variables now."     COLOUR="black"     VALUE="9"          echo "This is a string: $COLOUR"     echo "And this is a number: $VALUE"     echo       I observed that the effect of w is that it prints the following:                18:06:36 up  7:43,  3 users,  load average: 0.40, 0.56, 0.64     USER     TTY      FROM              LOGIN@   IDLE   JCPU   PCPU WHAT     hes      tty7                      10:23    7:43m 12:31   0.96s gnome-session -     hes      pts/0    :0               15:41    4.00s  1.38s 11.46s gnome-terminal     hes       pts/2    :0               17:20   44:52   0.79s 11.46s gnome-terminal      when I typed echo " statement" in terminal , it prints the statement. But I could not understand w here. in terminal echo w , prints w not as above. I am a beginner in scripting, so can someone help me in understanding how this work?


APF IPTABLES automaticly removing allow hosts

I'm using apf for configure iptables. From last 5 days, apf automaticly removing IP from `/etc/apf/allow_hosts.rules` Please help me to clear this issue.


Configure Postfix to Relay and Login From External Machine

I hope someone can offer me some assistance with this, its driving me bonkers. There maybe a hole in my understanding on how this should work, so be gentle with me. I have a Crunchbang Debian LAMP server which I use to host some Mailing list applications. I also use it at a mail server running Dovecot and Postfix. Postfix is configured to relay to my Pro SMTP server account. Any email sent via application internally is sent perfectly via relay and any email sent to a user on my machine is received and Dovecot functions well as an IMAP Server. I can log into my machine from outside the LAN and read IMAP mails for any user. However, when I try to use Postfix from outside my network to send email via my relay the application trying to authenticate to Postfix as an SMTP just stalls or fails .. I am presuming that Postfix requires the same authentication as in via a Unix User and their associated password .. and have tried several different configs to now avail. Do I have to use another Port to relay via my Postfix config? My main.cf reads :-               # See /usr/share/postfix/main.cf.dist for a commented, more complete version               # Debian specific:  Specifying a file name will cause the first     # line of that file to be used as the name.  The Debian default     # is /etc/mailname.     #myorigin = /etc/mailname          smtpd_banner = $myhostname ESMTP $mail_name (Debian/GNU)     biff = no          # appending .domain is the MUA's job.     append_dot_mydomain = no          # Uncomment the next line to generate "delayed mail" warnings     #delay_warning_time = 4h          readme_directory = no          # TLS parameters     smtpd_tls_cert_file = /etc/ssl/certs/ssl-cert-snakeoil.pem     smtpd_tls_key_file = /etc/ssl/private/ssl-cert-snakeoil.key     smtpd_use_tls=yes     smtpd_tls_session_cache_database = btree:${data_directory}/smtpd_scache     smtp_tls_session_cache_database = btree:${data_directory}/smtp_scache          # See /usr/share/doc/postfix/TLS_README.gz in the postfix-doc package for     # information on enabling SSL in the smtp client.          myhostname = italchemists.twilightparadox.com     alias_maps = hash:/etc/aliases     alias_database = hash:/etc/aliases     myorigin = /etc/mailname     mydestination = italchemists.twilightparadox.com, italchemists-server, localhost.localdomain, localhost     relayhost = [pro.turbo-smtp.com]:587     smtp_sasl_auth_enable = yes     smtp_sasl_password_maps = hash:/etc/postfix/smtp_sasl_password_map     smtp_sasl_security_options = noanonymous     smtp_use_tls = yes     mynetworks = 127.0.0.0/8 [::ffff:127.0.0.0]/104 [::1]/128     mailbox_size_limit = 0     recipient_delimiter = +     inet_interfaces = all     home_mailbox = Maildir/     smtpd_recipient_restrictions = permit_sasl_authenticated          smtpd_tls_security_level = may     smtpd_delay_reject = no


Find a file in the path without "which"?

I am (somehow) able to run a script:               $ assemble.sh file     ... [output]      But `which` can't find it:               $ which assemble.sh     which: no assemble.sh in (/s/std/bin:/usr/afsws/bin:/opt/SUNWspro/bin:/usr/ccs/bin:/usr/ucb:/bin:/usr/bin:/usr/stat/bin:/usr/X11R6/bin:.        1. How is this possible?   2. How can I find where this file is? I'm using bash.


Reconfiguring GNOME keyring daemon

I have a really strange problem when using GNOME keyring daemon. I had an old SSH key which I've now retired and started using a new, stronger keyfile. However, every time I attempt to SSH into one of my servers, SSH tells me               Agent admitted failure to sign using the key.     Permission denied (publickey).     fatal: The remote end hung up unexpectedly      I'm pretty sure that the keyring daemon is trying to use my old key for some strange reason. How can I reconfigure the keyring daemon to delete any knowledge of my old key?


Issue when setting a default path in BASH

I have a BASH scripting question. I'd like the mention that I am new to BASH scripting; however, I am not new to programming. I am developing a simple BASH script to watch a given compass project. My script is shown below. I would like to allow a user to optionally enter a custom path or use the default `http_path` value. I'm not sure how to set the `path` variable equal to the `http_path` variable where my default Apache directory is located using my current script. If any one has better suggestions and/or resources for learning how to write BASH scripts, please share! **Note:** I have searched this site, Google, and stackoverflow for an answer. If you find one with a solution to my issue, please let me know!               #!/bin/bash     # This script will watch a given compass project     http_path=/var/www/          echo -n "Enter in a new path and press. To use the default path $http_path press [ENTER] twice"          while read path; do         if [ -z "${path}" ]; then             clear               # these two lines enable the script to work if I do not             # I do not prompt for default path. It's been tested and works             # echo "That was empty, do it again!"             # echo -n "Enter in a compass project directory and press [ENTER]"             echo "Are you sure you would like to use the default path? Press [ENTER] to continue..."             $path=$http_path         else             echo "Checking now..."             break         fi     done          echo -n "Enter in a project to watch and prss [ENTER]"          while read project; do         if [ -z "${project}" ]; then             clear               echo "That was empty, do it again!"             echo -n "Enter in a compass project name and press [ENTER]"         else             echo "Checking now..."             break         fi     done          echo "Watching" $project "project in directory" $path     echo "To exit project press Command/Control + C"          cd $path     compass watch $project      See problem solution here


Is it possible to have a bashrc for a usergroup?

Is it possible to execute some bashrc file for all users in a group? If you can do that system-wide in /etc/profile then why not for a usergroup?


Error : .onLoad failed in loadNamespace() for 'cairoDevice' on a Linux Machine

After spending 1 hour searching for the solution I am posting this here. Does any one know how to install cairoDevice,package on R, Linux Server.               R CMD INSTALL cairoDevice_2.19.tar.gz      * installing to library 'software/R/R-2.15.2/library'     * installing *source* package 'cairoDevice' ...     ** package 'cairoDevice' successfully unpacked and MD5 sums checked     checking for pkg-config... pkg-config     configure: creating ./config.status     config.status: creating src/Makevars     ** libs     gcc -std=gnu99 -I/software/R/R-2.15.2/include -DNDEBUG -I/usr/include/gtk-2.0 -I/usr/lib64/gtk-2.0/include -I/usr/include/atk-1.0 -I/usr/include/cairo -I/usr/include/pango-1.0 -I/usr/include/glib-2.0 -I/usr/lib64/glib-2.0/include -I/usr/include/pixman-1 -I/usr/include/freetype2 -I/usr/include/libpng12   -g -I/usr/local/include    -fpic  -g -O2  -c cairoDevice.c -o cairoDevice.o     gcc -std=gnu99 -I/users/GR/mb/gbogu/software/R/R-2.15.2/include -DNDEBUG -I/usr/include/gtk-2.0 -I/usr/lib64/gtk-2.0/include -I/usr/include/atk-1.0 -I/usr/include/cairo -I/usr/include/pango-1.0 -I/usr/include/glib-2.0 -I/usr/lib64/glib-2.0/include -I/usr/include/pixman-1 -I/usr/include/freetype2 -I/usr/include/libpng12   -g -I/usr/local/include    -fpic  -g -O2  -c gtk.c -o gtk.o     gcc -std=gnu99 -shared -L/usr/local/lib64 -o cairoDevice.so cairoDevice.o gtk.o -lgtk-x11-2.0 -lgdk-x11-2.0 -latk-1.0 -lgio-2.0 -lpangoft2-1.0 -lgdk_pixbuf-2.0 -lpangocairo-1.0 -lcairo -lpango-1.0 -lfreetype -lfontconfig -lgobject-2.0 -lgmodule-2.0 -lglib-2.0     installing to software/R/R-2.15.2/library/cairoDevice/libs     ** R     ** demo     ** preparing package for lazy loading     ** help     *** installing help indices     ** building package indices     ** testing if installed package can be loaded     Error : .onLoad failed in loadNamespace() for 'cairoDevice', details:       call: fun(libname, pkgname)       error: GDK display not found - please make sure X11 is running     Error: loading failed     Execution halted     ERROR: loading failed     * removing 'software/R/R-2.15.2/library/cairoDevice'     * restoring previous 'software/R/R-2.15.2/library/cairoDevice'


History in the Almquist shell in the NetBSD

In NetBSD `/bin/sh` is a modified version of the Almquist shell. With the command `fc -l` it is possible to view the last 16 commands typed in the prompt in the **current** session and **not the older ones**. The environment variable `HISTSIZE` is set at 1000 and in `bash` this means that the last 1000 commands ( **whether or not** they were typed in the current session) are saved in a file named `.bash_history` in the home directory. But here it seems to mean just that the last 1000 commands in this session are keeped in the history, and the history does not seem to be saved in a file. I am looking for a history which allows not only to read the last commands of the current session, but also **the commands of the previous sessions** (for example, the previous time I started the system, not the actual time). Does `/bin/sh` in NetBSD have by default **such an history**? If not, is it possible to create such an history in that shell?


Prompt "-bash-3.2$" vs. "bash-3.2$" in SunOS 5.10

When I log into a server running SunOS 5.10, my prompt initially is "-bash-3.2$" Then when I run the following commands, I can see that the prompt is slightly different after typing `bash` (it no longer begins with a dash), yet echo $SHELL gives the same result.               -bash-3.2$ echo $SHELL     /bin/bash     -bash-3.2$ bash     bash-3.2$ echo $SHELL     /bin/bash      What does this mean, and what implications does it have?


Emulating a file

I have certain application that opens a file with given path (presumably with `fopen` or derivative), reads the file, possibly writes to it and closes it. I have no control over this application other than specifying the path. What I am trying to do is 'emulate' a file within the local filesystem to pass it to the application. That is, I want the file to appear as an ordinary file in the filesystem, however the streams are redirected to another application that handles them correctly and outputs appropriate data. Essentially, I want to create a pseudo-device, except that it is not a device at all. Is this doable at all? How would I approach this problem?


Why does dig take much longer than DNS query time?

I'm investigating slow DNS responses on Ubuntu, I have installed `bind9` to improve times from local cache, but still something is odd. What could make `dig` wait for 10 seconds and say that query time took 0?               time dig google.ro +all          ; <<>> DiG 9.9.3-rpz2+rl.13214.22-P2-Ubuntu-1:9.9.3.dfsg.P2-4ubuntu1.1 <<>> google.ro +all     ;; global options: +cmd     ;; Got answer:     ;; ->>HEADER<<- opcode: QUERY, status: SERVFAIL, id: 9665     ;; flags: qr rd ra; QUERY: 1, ANSWER: 0, AUTHORITY: 0, ADDITIONAL: 1          ;; OPT PSEUDOSECTION:     ; EDNS: version: 0, flags:; udp: 4096     ;; QUESTION SECTION:     ;google.ro.                     IN      A          ;; Query time: 0 msec     ;; SERVER: 127.0.0.1#53(127.0.0.1)     ;; WHEN: Mon Feb 17 20:15:19 CET 2014     ;; MSG SIZE  rcvd: 38          dig google.ro +all  0.01s user 0.00s system 0% cpu 10.012 total