title: How do I count the exact total of created and deleted sqlite journal files?

text: I'm trying to figure this out. Scenario is this: A threaded tcp socket daemon with a sqlite back-end stores information in a unique sqlite2 file per IMEI ID, in an unique sub-directory per day (`pseudo: 2012/11/01/event_$imei.sqlite`). About 3000 of them for each day. As you know, there is a phase that an sqlite journal file is being created and deleted while receiving and storing incoming data. This application only writes in either today's or yesterdays directory, (small) datafeeds can take up to 255 seconds. So there is a phase-over at 00:00 UTC. During a connection multiple writes can happen, the network link stays open and the assets can send additional bursts of new data while the connection is open. No explicit locking is going on at all, sqlite handles itself, a connection is simply unique per imei, so never there are 2 threads writing to the same file. With other words, the controlling daemon doesn't have a clue of what sqlite does nor does it care. I want to count the number of sqlite journal files ever created as a 2 totals at a given point in time of course. Essentially they are about the same but never really the same, they only live for very short amount of time anyway. Monitoring systems usually count the number of present files as a snapshot in time. That is not the sort of metric I'm looking for. So How can you accurately do this sort of count with the smallest footprint on the load ? There must be a trick, it's *nix after all. The system here is an Ubuntu server but I slightly prefer -but not limited to- a general solution. But keep in mind new directories will be created as time passes and I should be able to follow that, and I want it volatile (so a reboot can(must) reset this). Thanks in advance for bootstrapping me in any direction.


title: How can I get GRUB to configure my screen properly?

text: My screen says that it can't display the stream, and to use 1680x1050@60Hz as soon as grub would be loaded. I was told by #hardware on irc.freenode.net that this was due to grub missconfiguring the screen. I've haven't found anything whatsoever in the GRUB docs. Google talks about apparently outdated software like BURG. How can I fix this?


In Emacs, how do I inspect what has been modified in a buffer (before saving and overwriting the file)? (In a sense, the requested action is an analog of `git status` and `git add -i` showing what has been modified, only the comparison should be done between the buffer contents (in Emacs's memory) and the file on disk.) Sometime, I forget what has been modified in a buffer, and would like to call a command to remind me.


title: Share keyboard over network as separate device?

text: I am trying to achieve something similar to this: http://superuser.com/questions/67659/linux-share-keyboard-over-network The difference is that I need the remote keyboard to be usable _separate from my local keyboard_. The method described in the link seems to pipe the events into an existing device file. I need the remote keyboard to show as a physical (slave) device when I run `xinput list` Why do I need this? I am trying to play a two player game but I don't have an external USB keyboard, so I want to pipe the keypresses from the remote computer to a fake device (so I can assign one device per player).


title: Segfault on a debian server

text: We moved our retail software to new hardware (we passed from an IBM x3200 with SATA 7200rpm disks to an IBM x3200 with SAS 15000rpm disks) but after a few days with no problem at all we keep getting > Aug 29 08:39:50 server01 kernel: [64680.439253] retail-soft[1089]: segfault > at 104 ip ? 081106ea sp bfd1b7c0 error 4 in retail-soft[8048000+18b000] in `/var/log/messages` and the software just hangs or gets closed. We changed the RAM assuming that was the problem but it keeps happening. What else can we check? We have installed the latest stable release of Debian. We also discarded a programming failure because the same software is running in other servers with no problems at all.


title: How do I restore my console default font, and why has it changed?

text: I'm using Lubuntu 11.10, and I use my console a lot. Today I discovered that its font was changed; specifically, this screen is from yesterday: ![yesterday](http://i.stack.imgur.com/VStb5.png) and this is from today: ![today](http://i.stack.imgur.com/WhO5V.png) First of all, any idea of how I changed it? I'm pretty sure I did nothing to justify this, but I'm also certain that if something happened there's always a reason, so... Besides, how do I restore the previous font? The main issue is that I'm not sure what it was.


title: Login by ssh , exec one command and i don't want to quit the bash

text: I want to change PS1 when i ssh another centos                   strshell = 'PS1="remote!"'         os.system("ssh -i %s -l%s -p%s %s %s"%(SSH_KEY,SSH_USER,SSH_PORT,des,strshell))        ssh quit automatically. I want to stay in this shell.How to achieve it. I just change another way to do this                tin = ' sudo -i ; export PS1="Remote! \W :"; exec /bin/bash -i'      os.system("ssh  -i%s -l%s -p%s %s -t%s" % (SSH_KEY, SSH_USER, SSH_PORT, des, tin))        but i changed my local machine prompt not the remote one. why?   **os.system is a python function**


title: Log from TCP Port breaking messages on characters other than newline

text: I'm working on a set of scripts to monitor some external services that log to a TCP port.               function handleMessage {       while read message       do         # Handle $message       done     }     nc -d $ipadd $port | handleMessage      This code works fine when log messages are delimited by new lines like the following > Service started > > ERROR: Something terrible happened > > Service stopped But one of the services delimits messages using LOGXXXX and allows new lines within messages so it's output looks more like this: > LOG0001 Service startedLOG0002 ERROR: Something terrible happened > > NullPointerException at SomeMethod (File1.java) > > SomeOtherMethod (File2.java)LOG0003 Service stopped Using my code above handleMessage is called for each of the lines instead of for each set of LOGXXXX segments and if time passes with no messages containing newlines my script gets very far behind in handling messages. Is there an option on nc or another program I can use to read from this TCP port and break on a custom delimiter, or some option to have a bash function handle each write to stdout instead of only being called for each line?


title: badblocks only takes 32-bit integer as start/end values

text: I have a 4TB drive with a 4096 byte block size. I want to check a very specific set of blocks, around the 700,000,000th block or so for bad sectors. However, `badblocks` seems to only support `int32` as the stop and start block counts, which means that it's impossible for me to specify this range of blocks. Is there another way I can scan this drive for badblocks? I don't want to wait the 7 hours it's going to take to test the whole drive. It is a single drive from an `mdadm` array so it does not contain a usable file system.


title: Virsh hangs while trying to connect

text: Running this command:               # virsh -c qemu:///system list       As root user, hangs with no error message. Not sure what's causing this. This problem started after a power failure in my lab. When I brought the hypervisor server up (Oracle Linux 6.3, 2.6.39-300.17.3.el6uek.x86_64) I had to reconfigure the network because the device names (eth4 -> eth0) changed and network config reverted to dhcp for some strange reason. Even after resolving this, it virsh hangs with no error message. Where should I be looking with regard to troubleshooting?


title: Use Emulated Scrollwheel Instead of Real One X11

text: So I've got this Kensington trackball that ships with a pretty horrible scrollwheel/touchring doohicky, and only two physical buttons. I'd like to disable the touchscroll entirely, enable 3 button emulation and use the emulated third button as the emulated wheel activator. When I do               Section "InputClass"         Option "EmulateWheel" "true"         Option "EmulateWheelButton" "2"         Option "Emulate3Buttons" "true"         Option "ButtonMapping" "1 2 3 0 0"         Option "YAxisMapping" "4 5"         Option "XAxisMapping" "6 7"     EndSection      The touchscroll is disabled, but so is the logical X11 YAxis buttons (4 & 5) so I can only scroll horizontally. Anyone know if its possible to preference emulated scrolling over the wheel itself? Edit: Made some progress. X11 manual mentions the "ZAxisMapping" which changes the buttons that initiate a scroll event (I think).               Section "InputClass"         Option "EmulateWheel" "true"         Option "EmulateWheelButton" "2"         Option "Emulate3Buttons" "true"         Option "ButtonMapping" "1 2 3 0 0"         Option "YAxisMapping" "11 12"         Option "XAxisMapping" "6 7"         Option "ZAxisMapping" "11 12 6 7"     EndSection      Making the arguments match what I've mapped to the emulated scrollwheel seems to work in urxvt, but not in any gtk apps. (I assume gtk doesn't utilize the ZAxisMapping option from xorg.conf but rather continues to listen for the disabled 4 and 5 butons.)


title: Has anyone actually tested laptop battery life under different CPU governors?

text: In theory, switching from the ondemand governor to conservative should save battery life on laptops. However, I don't think I've _ever_ seen any tests done to verify this or show how significant a saving can be made. Can anyone find a source where such tests have been done?


title: How to burn iso image to DVD using dd command

text: I was looking at the command to burn iso image to a dvd. But I couldnt get the name of the device. In the `/dev/` I could see `cdrom`,`cdrw`,`dvd`,`dvdrw`. I am using debian. When I gave the command, I got the following output               dd if=debian-6.0.7-i386-DVD-1.iso of=/dev/dvdrw      dd: opening `/dev/dvdrw': Read-only file system


title: How to get data count between two strings with multiple occurences in the same file

text: I have the data in my file as               START-OF-FIELDS     ID     NAME     DEPT     END-OF-FIELDS          START-OF-DATA     1|joy|cs     2|sam|ec     END-OF-DATA          START-OF-FIELDS     ID      NAME     DOB     DEPT     ADDRESS     END-OF-FIELDS          START-OF-DATA     5|joe|13/2/2001/|ee|street1     3|gwen|4/08/1999|cs|street2     END-OF-DATA      EXPECTED OUTPUT:-               ID     NAME     DEPT      Count for data set 1 is: 3               ID      NAME     DOB     DEPT     ADDRESS      Count for data set 2 is: 5 and so on for dynamic no. of data sets. I want count of data between both START-OF-FIELDS & END-OF-FIELDS & for START- OF-DATA & END-OF-DATA. can any body give me exact code to do this. I have used               sed -n '/^START-OF-FIELDS/,/END-OF-FIELDS/{s/^START-OF-FIELDS//;/^END-OF-FIELDS/d;p;}' Sourcefile.txt > START_OF_FIELDS.TXT          wc -l START_OF_FIELDS.TXT      But I am not getting desired result.


title: Can't installing RPM package intltool?

text: I want to install on my Linux Red Hat machine (6.3 64 bit) the rpm - `intltool-0.41.0-1.1.el6.src.rpm`. For some unclear reason I get this:                /var/tmp]# rpm -i  intltool-0.41.0-1.1.el6.src.rpm      warning: intltool-0.41.0-1.1.el6.src.rpm: Header V3 RSA/SHA256 Signature, key ID fd431d51: NOKEY      warning: user mockbuild does not exist - using root      warning: group mockbuild does not exist - using root      warning: user mockbuild does not exist - using root      warning: group mockbuild does not exist - using root      warning: user mockbuild does not exist - using root      warning: group mockbuild does not exist - using root      /var/tmp]# rpm -qa | grep -i  intltool      /var/tmp]#       ### Questions   * What's the problem?   * How can I fix this?


title: Escape code 50 in xterm

text: My coworker has the following in the `~/.bash_profile` of many of our servers:               echo -e "\033]50;SetProfile=Production\a"      The text doesn't seem to matter, since this also works:               echo -e "\033]50;ANY_TEXT\a"      But no text doesn't work; the `\a` is also required. This causes his terminal in OSX to change profiles (different colours, etc.); but in my xterm, it changes the font to huge; which I can't seem to reset. I have tried to reset this with:   1. Setting VT fonts with shift+right click   2. Do "soft reset" and "full reset" with shift+middle click   3. Sending of various escape codes & commands:              $ echo -e "\033c"    # Reset terminal, no effect     $ echo -e "\033[0;m" # Reset attributes, no effect     $ tput sgr0          # No effect     $ tput reset         # No effect      My questions:   1. Why does this work on xterm & what exactly does it do? Code 50 is listed as "Reserved"?   2. How do I reset this? Screenshot: ![enter image description here](http://i.stack.imgur.com/wjrjQ.png)


title: Change default monitor screen in GRUB 2

text: Recently my notebook screen died and I started using an external VGA monitor. When my computer boots the monitor is off until GRUB 2 starts the OS. Is it possible to make GRUB 2 display its menu in the external monitor?


title: ask for comfirmation when file is replaced using a redirection

text: I'm a careless terminal driver scared of accidentally deleting files, hence using some aliases like `alias rm='rm -i'` for `rm`, `mv`, `cp`. How can I get a similar confirmation behavior for file redirections (e.g `echo "I'm silly" > very_important_file.txt`). The common case is that I usually use replace (`>`) instead of append (`>>`) and so I ended up accidentally deleting some mid-important files. What are your suggestions?


title: Create PKGBUILD from .deb

text: I have a `.deb` debian package which essentially contains the binaries of the software as a `/usr/share/bin` folder in a compressed `data` file, and another metadata compressed file containing the checksums of the other files. My goal is to create a `PKGBUILD` to install such .deb package correctly on archlinux. What's the proper way to do that? Is enough to copy the contents of that `/usr/share/bin` directory into the `pkg` `/usr/share/bin` fakeroot environment using the `build()` function? The folder will be copied to the true `/usr/share/bin` location when the builded package is actually installed?


title: Executing zsh rehash after build

text: I have a build script that can change what binaries are in my $PATH (it doesn't edit $PATH itself, but it adds/deletes files to folders that are already in $PATH). zsh's autocompletion doesn't update to reflect the files that have been added/deleted in response to the build, so I have to either restart the shell or execute the 'rehash' shell built-in to tell it to update its autocomplete cache. I decided I wanted to automate running rehash so at first I did this:               build() {         ~/bin/real_build && rehash     }      But shell functions run in their own subshell, so rehash would update the cache for the subshell, instead of the shell in the terminal I was using. So I switched to this:               alias build='~/bin/real_build && rehash'      Which works, except when I want to pass arguments to build. If I pass 'clean' I'd like it to execute:               ~/bin/real_build clean && rehash      But instead it will do:               ~/bin/real_build && rehash clean      So I'm stuck -- I can use an alias and not be able to pass arguments, or I can use a function and not have it actually update the autocomplete entries. Is there a way to make both work?


title: Why the differences in color between SSH terminal sessions in OSX?

text: I'm trying to get the colors in an SSH terminal session with a CentOS machine to look the same as it does when I'm SSH'd into my Ubuntu server. If I run `echo $TERM` in both I get `xterm-color` as output. I'm not sure what other information to give besides a couple screens and the .bashrc files from my home directory in each. What's driving me nuts the most is getting `lpeabody@webtest` to show up the same as it does for the Ubuntu SSH session (i.e. that same color green, etc.). Thoughts? ![Screenshot of Ubuntu SSH session.](http://i.stack.imgur.com/AlFSn.png) ![Screenshot of CentOS session.](http://i.stack.imgur.com/U6rBy.png) Ubuntu .bashrc:               # ~/.bashrc: executed by bash(1) for non-login shells.     # see /usr/share/doc/bash/examples/startup-files (in the package bash-doc)     # for examples          # If not running interactively, don't do anything     [ -z "$PS1" ] && return          # don't put duplicate lines in the history. See bash(1) for more options     # ... or force ignoredups and ignorespace     HISTCONTROL=ignoredups:ignorespace          # append to the history file, don't overwrite it     shopt -s histappend          # for setting history length see HISTSIZE and HISTFILESIZE in bash(1)     HISTSIZE=1000     HISTFILESIZE=2000          # check the window size after each command and, if necessary,     # update the values of LINES and COLUMNS.     shopt -s checkwinsize          # make less more friendly for non-text input files, see lesspipe(1)     [ -x /usr/bin/lesspipe ] && eval "$(SHELL=/bin/sh lesspipe)"          # set variable identifying the chroot you work in (used in the prompt below)     if [ -z "$debian_chroot" ] && [ -r /etc/debian_chroot ]; then         debian_chroot=$(cat /etc/debian_chroot)     fi          # set a fancy prompt (non-color, unless we know we "want" color)     case "$TERM" in         xterm-color) color_prompt=yes;;     esac          # uncomment for a colored prompt, if the terminal has the capability; turned     # off by default to not distract the user: the focus in a terminal window     # should be on the output of commands, not on the prompt     #force_color_prompt=yes          if [ -n "$force_color_prompt" ]; then         if [ -x /usr/bin/tput ] && tput setaf 1 >&/dev/null; then         # We have color support; assume it's compliant with Ecma-48         # (ISO/IEC-6429). (Lack of such support is extremely rare, and such         # a case would tend to support setf rather than setaf.)         color_prompt=yes         else         color_prompt=         fi     fi          if [ "$color_prompt" = yes ]; then         PS1='${debian_chroot:+($debian_chroot)}\[\033[01;32m\]\u@\h\[\033[00m\]:\[\033[01;34m\]\w\[\033[00m\]\$ '     else         PS1='${debian_chroot:+($debian_chroot)}\u@\h:\w\$ '     fi     unset color_prompt force_color_prompt          # If this is an xterm set the title to user@host:dir     case "$TERM" in     xterm*|rxvt*)         PS1="\[\e]0;${debian_chroot:+($debian_chroot)}\u@\h: \w\a\]$PS1"         ;;     *)         ;;     esac          # enable color support of ls and also add handy aliases     if [ -x /usr/bin/dircolors ]; then         test -r ~/.dircolors && eval "$(dircolors -b ~/.dircolors)" || eval "$(dircolors -b)"         alias ls='ls --color=auto'         #alias dir='dir --color=auto'         #alias vdir='vdir --color=auto'              alias grep='grep --color=auto'         alias fgrep='fgrep --color=auto'         alias egrep='egrep --color=auto'     fi          # some more ls aliases     alias ll='ls -alF'     alias la='ls -A'     alias l='ls -CF'          # Alias definitions.     # You may want to put all your additions into a separate file like     # ~/.bash_aliases, instead of adding them here directly.     # See /usr/share/doc/bash-doc/examples in the bash-doc package.          if [ -f ~/.bash_aliases ]; then         . ~/.bash_aliases     fi          # enable programmable completion features (you don't need to enable     # this, if it's already enabled in /etc/bash.bashrc and /etc/profile     # sources /etc/bash.bashrc).     if [ -f /etc/bash_completion ] && ! shopt -oq posix; then         . /etc/bash_completion     fi          PATH=$PATH:$HOME/node_modules/less/bin          . /etc/profile.d/rvm.sh      The CentOS machine is pretty much a fresh install, here is my .bashrc for that machine:               # .bashrc          # Source global definitions     if [ -f /etc/bashrc ]; then         . /etc/bashrc     fi          # User specific aliases and functions


title: When a command is over half the terminal size it breaks

text: Whenever I type in a `bash` command longer than about half the width of the shell window I'm in, the command breaks like it would if I filled the whole screen ![image of problem](http://i.stack.imgur.com/C8I9C.png)   * 3rd command in image - typed a few `x`s and got the expected result.   * 4th command - **typed a load more`x`s, and the command broke back to the start as though it had filled the whole line.** **I'm connecting through Putty.** I'm running Raspbian (a distro based on Debian) _If I'm not being clear enough please say, it's not easy to explain._


title: Start network service at boot time on CentOS

text: I've recently reinstalled CentOS onto a computer of mine. I have OpenSSH Server on it now, as did I before I reinstalled the operating system. Here's the difference: Before, SSH started without even having to login to an account. Now, it seems like I have to login to an account on the machine before being able to remotely connect via SSH. Can anyone help? I tried using `chkconfig`, but that didn't appear to do anything differently.


title: bash scripts - remove duplicate rows with smaller value

text: Here is an example file:               1 5 20 40 60     2 1 20 20 20     2 2 30 30 30     4 5 40 40 40     7 2 50 30 30     7 1 20 20 20      I would like to remove duplicate rows (with the same value in the first column) with a bigger value in the second column. I want to leave only rows with uniqe values in the first column. In this case I have duplicated rows:               2 1 20 20 20     2 2 30 30 30      and               7 2 50 30 30     7 1 20 20 20      I would like to remove rows with bigger values in the second column, in this case:               2 2 30 30 30      and               7 2 50 30 30      Hence, my goal is to select and generate the following file:               1 5 20 40 60     2 1 20 20 20     4 5 40 40 40     7 1 20 20 20      I suppose I have manage to do this in awk:               sort -nk2 | awk '{if(a[$1]){a[$1]=a[$1] } else {a[$1]=$0}}END{for (k in a) {print a[k]}}' | sort      However it works on small files. How can I replace it with something more efficient (for file with near a million of rows)?


title: How do I create a USB image with a partition table?

text: I want to create an image of some directory tree that is writable directly to an USB drive, just like the images of many linux distributions. For example, with openSUSE you can download an ISO image that is writable directly the USB using `dd`.               root@computer# dd if=openSUSE.iso of=/dev/sdb      I tried to create images using `mkisofs`, but when I ran the `dd` command above with that image didn't get a partition table, which made windows not recognize the format of the drive and linux didn't present `/dev/sdb1`. I also tried to create an empty file, and then create a filesystem in that file using `mkfs.vfat`. There seem to be a lot of tutorials on the web on how to write images to USB drives as well as dumping an usb drive to file, but I haven't found anything on creating an image with a partition table. The problem I'm trying to solve with this is to distribute a preformated USB stick, so there is no need for the stick to be bootable, and I would also like to make this process scriptable.


title: Sed : Replace pattern on every second occurence?

text: Is there a way to tell `sed` to replace the pattern on every second occurrence? Or at least on every second line? (Sure it's possible with a script, but I was asking myself if `sed` can do it to). Thanks. **Edit** I found               sed -e "s/pattern/replacement/g;n"      But it replaced every first occurence, not the second.


title: temporary setting the path in an "init" file

text: I have an "init" file that reads               #!/bin/sh          export PATH=$PATH:/home/me/morph_numsys/software/bin      by which I'd just like to set the path to that folder for only this bash session. However, when I execute the script, `sh init`, it still doesn't recognize the path. However, if I just say `export PATH=$PATH:/home/me/morph_numsys/software/bin`, then it works fine. Any ideas how I can do this? I'm on ubuntu and xterm.


title: Kill an unresponsive ssh session without closing the terminal

text: Is there a way to disconnect from an SSH session that has become unresponsive without killing the whole terminal? Specifically I'm using konsole, and the machine I'm working with sometimes hangs, but doesn't actually die (thus killing the connection). So SSH just hangs and I have to close the terminal and open a new one to try to ssh back into it or do anything else. Is there a way to effectively ctrl+c out of an ssh session?


title: Enabling UTS Namespaces in the Linux Kernel

text: When configuring the Linux kernel, what are the advantages and disadvantages of enabling UTS namespaces? Would the new system be harmed if UTS namespaces were disabled?


title: How do I make kvkbd virtual keyboard appear on the login screen?

text: I am trying to set up Fedora (KDE desktop) on a PC with a touch screen. I got kvkbd working which I am finding works decently enough that I might be able to use this machine without a keyboard at all, which is the final goal. But for now I have no access to it from the login screen, so I need to use an actual keyboard just for that part. **How can I configure it to appear at login, before entering the user's desktop?** I have followed some of the directions in the 'Kvkbd Handbook' in the help menu of the software, including adding lines to /etc/kde/kdm/Xsetup and using the `\--loginhelper` parameter. So far, no luck.


title: How can I downgrade a glibc version?

text: I upgraded glibc for a reason that isn't arround anymore so i want to downgrade it again. The stupid thing is a lot of programms rely on glibc at the moment. I still have the 2.4 version on the system as the command below shows, but i'm not able to delete the 2.9 version.               # rpm -qa|grep  glibc     glibc-32bit-2.4-31.74.1     glibc-locale-2.4-31.74.1     glibc-locale-32bit-2.4-31.74.1     glibc-info-2.4-31.74.1     glibc-devel-2.4-31.74.1     glibc-2.9-2.9     glibc-i18ndata-2.4-31.74.1     glibc-devel-32bit-2.4-31.74.1      I've tried `rpm -e glibc-2.9-2.9` but the system just tells me that a huge amount of stuff depends on glibc. So I was wondering if _I_ can somehow set the 2.4 version to default or so and then remove the 2.9 version.


title: sudo -u username -s "cmd arg" returns command not found

text: I used to execute the command:               sudo -u elasticsearch -s "ulimit -Hn"      and it was returning the value of ulimit -Hn as seen by user elasticsearch until I tried it on Ubuntu 11.10. There it returns:               /bin/bash: ulimit -Hn: command not found      I tried a few different commands, and when I use an argument I always get "command not found":               $ sudo -u elasticsearch -s "ls all.sh"     /bin/bash: ls all.sh: command not found      Any ideas on how can I execute a command that requires arguments through `sudo`? Thanks!


title: Mac OS X partition type problem

text: As a 2 decades of MS-Windows user I have switched to Mac OS X a month ago. And my knowledge is not enough to fix my big problem which I encountered yesterday and my brand new MBPro is dead now. I installed Win-7 x64 on Boot Camp. My mistake at first is I have allocated very little space to Windows from my precious SSD disk. Yesterday I have tried to increase the Boot Camp partition from 80GB to 250GB. What exactly I did is;   1. Started in Windows 7, taken a full Windows system backup into an external USB Disk.   2. Switched to OS X and created a disk image (dmg) from my existing Boot Camp partition (Using Std. OS X's Disk Utility) this was my second backup. Since I don't want to get in trouble with activation of all my MS Office, Windows 7, Games etc. I was planning to restore one of those to my New Windows with larger disk capacity.   3. in OS X, I have erased the Boot Camp partition (disk0s4) and enlarged the master HFS+ partition (disk0s2) to maximum physical disk capacity (~750GB) using Disk Utility   4. Started Boot Camp and performed a clean copy of Windows x64 and this time I have given a disk size of 268GB for the new Boot Camp partition (simply; 250GB to Boot Camp, 500GB to OS X)   5. Standard installation went well. Windows installation asked for product key, I skipped this and started new Windows for the first time. I shut it down and restart in OS X.   6. Now the first of the series of the problems that eventually ended up with the death of my MBPro is coming up, Disk Utility refused to restore from DMG file (ref. step 2 - image was created from previous Windows partition so it is NTFS!) to new pysical Boot Camp partition (also NTFS). It said something like both disks were not identical or something like that. I checked the block sizes etc. Both was 512kb. I googled and found an alternative way to restore and skipped Disk Utility and switched to terminal window. Executed `dd if=dmg of=disk04s` to copy content of backup DMG file to new Boot Camp partition. Needles to say, Windows didn't start up, a black screen appeared and the worst thing is when I started in OS X, Disk Utility was showing only 80GB for the Boot Camp partition (which has to be 268). The capacity was overwritten by the previous partition's image file and all of a sudden I happen to lost 250-80=170GB.   7. I decided to go with the other option to install a clean windows and use Windows7@s Backup/restore. To be able to do this I needed to start over and delete the Boot Camp partition again and resized the master HFS volume to its Max (of 768) as I already did in step 3-4.   8. Started Boot Camp, this time Boot Camp gave me an error saying 'Can't install Boot Camp to multiple partitioned disk'. I already knew that Boot Camp requires a single OS X (HFS) partitioned disk so he can manage the partition table withing his screens. I was amazed with this error cause I knew that I already removed the last Boot Camp partition and resized the main HFS partition to its maximum.   9. The golden shot, I have restarted my OS X. And it never came back. Thanks God, my repair partition was still healthy so I booted with command+r in repair mode. Now I have terminal windows open. I have run `diskutil list` and I couldn't believe the thing I saw, Boot Camp (or Disk Utility not sure) has changed the type of my primary OS X partition to MS-DOS (Fat 32) I guess, it says 'Microsoft Basic Data'. I've been desperately looking for a way to change the corrupted type of my existing primary HFS+ partition (I know all my data is healthy and waiting for me if I could manage to reach them) Here's the outputs of `diskutil list`:               /dev/disk0           :  TYPE NAME                    SIZE       IDENTIFIER          0:      GUID_partition_scheme                        *751.3 GB   disk0          1:                        EFI                         209.7 MB   disk0s1          2:       Microsoft Basic Data                         750.4 GB   disk0s2          3:                 Apple_Boot Recovery HD             650.0 MB   disk0s3          /dev/disk1           :                       TYPE NAME                    SIZE       IDENTIFIER          0:     Apple_partition_scheme                        *1.3 GB     disk1          1:        Apple_partition_map                         30.7 KB    disk1s1          2:                  Apple_HFS Mac OS X Base System    1.3 GB     disk1s2          /dev/disk2           :                       TYPE NAME                    SIZE       IDENTIFIER          0:                            untitled               *524.3 KB   disk2 (*I cleared the rest as they're irrelevant with various mount points of repair disk) And `df`:               Filesystem    512-blocks    Used Available Capacity iused ifree %iused  Mounted on          /dev/disk1s2     2464464 2223200    216624    92%  280978 27078   91%   /          devfs                399     399         0   100%     691     0  100%   /dev          /dev/disk2          1024     288       736    29%      34    92   27%   /Volumes          /dev/disk3          1024     280       744    28%      33    93   26%   /private/var/tmp          /dev/disk4          1024     312       712    31%      37    89   29%   /private/var/run          /dev/disk5          1024     280       744    28%      33    93   26%   /System/Installation          /dev/disk6          1024     528       496    52%      64    62   51%   /private/var/db          /dev/disk7         12288    3304      8984    27%     411  1123   27%   /private/var/folders          /dev/disk8          4096     832      3264    21%     102   408   20% /private/var/root/Library          /dev/disk9          2048     288      1760    15%      34   220   13%   /Library/ColorSync/Profiles/Displays          /dev/disk10         1024     336       688    33%      40    86   32%   /Library/Preferences          /dev/disk11         1024     312       712    31%      37    89   29%   /Library/Preferences/SystemConfiguration          /dev/disk12         2048     280      1768    14%      33   221   13%   /Library/Keychains          /dev/disk13s1   15600632  283400  15317232     2%       0     0  100%   /Volumes/GPARTED BTW, I have the OS X Mountain Lion with latest updates (10.8.x). Until now, I have tried GParted (made a bootable thumb-drive, it didn't run, it has frozen in keyboard selection screen), I have tried TestDisk, it didn't run either, simply returned an error code, made a search about gpt, fdisk etc. but couldn't find any information that's worth to try. So I'm here and waiting for an answer from you guys, can you suggest me any direction to go, a tool to use to fix my existing partition with the wrong file system type?


title: Bash script to copy *.log files into a new directory

text: I have some files like this:               2012-12-17_083213_1.log       2012-12-17_083213_1.log_stats       2012-12-17_083213_1.logaccount_ptr       2012-12-17_083213_1.loginitial_ptr       2012-12-17_083213_1.logptr       2012-12-17_093049_2.log       2012-12-17_093049_2.log_stats       2012-12-17_093049_2.logaccount_ptr       2012-12-17_093049_2.loginitial_ptr       2012-12-17_093049_2.logptr In here every 1G of data, a new file is created with the name in Year-Month- Day_HourMinuteSecond_number.log format (as you can see above). I want to   1. Copy all *.log files to a new folder named with the format Year-Month-Day, so for these it would be named: 2012-12-17    2. `tgz` that folder    3. Send it to a server IP. I don't know how exactly. I want it as a bash script so that I can run it every day for the newly added files.


title: lsmod returns error unless called with sudo

text: Fixed: The install README for libusb suggests added a call to               export LD_PRELOAD=/path/to/libusb-driver.so       It was this .so file that was getting called and interefering with lsmod (and it turns out some other commands as well). To fix this I moved the libusb- driver.so file to the Xilinx/.../common/bin/lin64 folder. All tools can access the cable without sudo calls. In addition I found that the Xilinx settingsXX.sh script was breaking my PATH. Changed this script to append to end of PATH instead of front of PATH. Thanks Y'all. Fedora 17, Linux 3.4.4 After installing the Xilinx cable drivers, which didn't work with Linux 3.4.4 I installed the libusb solution. The cables detect and I can access them from within the Xilinx tools. However, now everytime I try an lsmod I get the following error:               libkmod: kmod_module_get_holders: could not open '/sys/module/windrvr6/holders': No such file or directory     windrvr6                   1  -2           libkmod: kmod_module_get_holders: could not open '/sys/module/parport_pc/holders': No such file or directory     parport_pc      sudo lsmod does work, and these modules are not shown as loaded. rmmod reports that the modules aren't loaded. I have poked around /sys/module , /etc/modprobe.d and a couple of locations I can't recall at this second. I can find no reference to windrvr6 anywhere. Any suggestions about how to remove calls to these modules would be great. I also tried making a new user and the problem persists there. I logged in as root and the problem persists there as well, unless I call lsmod with sudo, it errors. Thanks, Camille


title: Replacing XML entity values with positive lookaround

text: I'm trying to do some pretty simple `sed`ding of a file:               sed 's:(?<=<Type>)default(?=</Type>):super:' < myfile.xml      The concept's pretty simple, using positive lookaround, find the tags and replace the contents with "super". Unfortunately, it doesn't work, nothing is replaced. What am I doing wrong? I'm looking to "edit" a file similar to this:               <Hello>         <World>             <Type>default</Type>         </World>     </Hello>      so that it looks like this:               <Hello>         <World>             <Type>super</Type>         </World>     </Hello>


title: Is there a better way to stop and restart Apache server every 30 minutes?

text: I have to stop and restart Apache every 30 minutes in order to avoid it becoming extremely slow over time. The cron job that I use as follows:               @echo off     rem Launch google.com, wait 2 seconds, then close the browser.     net stop "Apache2.2"     ping 127.0.0.1 -n 30 -w 5000 > nul     net start "Apache2.2"     ping 127.0.0.1 -n 30 -w 5000 > nul     exit      Is there a better not to do the stop and restart because every time I stop the server, users will get the error message on the website. The server runs php scripts and MySQL, and have about 500 users login throughout the day.


title: How to redefine kde4 keyboard shortcuts

text: I recently switched to using KDE 4, and I don't like that KDE uses so many of the Ctrl-Fn shortcut keys, since I use them for other purposes. Specifically, I'd like to disable the Ctrl-F4 shortcut in KDE. However, I have not been able to find this shortcut in System Settings -> Shortcuts and Gestures. UPDATE: Another shortcut I'd like to redefine is the "Show window menu" shortcut, which I like on Alt-Space, but which KDE has on Alt-F3. I have not been able to find a global place to change all shortcuts.


title: Remove large chunks from json using vim

text: I have a huge file (1/2 million lines) of json. I need to delete a set of entries that contain a certain string.               {         "bla1": {             "Part1": "Plop1",             "Part2": "Plop2",             "Part3": "BadFling1<stuff>",             "part4": "Plop4",         },         "bla2": {             "Part1": "Plop1",             "Part2": "Plop2",             "Part3": "<stuff>",             "part4": "Plop4",         },         // etc for many more entries     }      All the entries have "BadFling1" as the prefix to the "Part3" entry. I was wondering how the best way to automate removing all entries that include "BadFling1". So for example the result of removing the bad entry from above is:               {         "bla2": {             "Part1": "Plop1",             "Part2": "Plop2",             "Part3": "<stuff>",             "part4": "Plop4",         },         // etc for many more entries     }      My first attempt was working but not fast enough (as it was slightly manual).               /BadFling1     qan3k5ddq     :map z n@a      Now hold down the 'z' key. My vim foo is not strong enough, so I am unsure how to automate the processes better in vim. Any help appreciated. Alternative approaches in bash (or other command line tools also welcome).


title: Install Sublime Text 2 on Ubuntu

text: I installed Ubuntu Linux (via VMWare). I'm trying to install Sublime Text 2 on Ubuntu, so I entered these lines:               tar xf Sublime\ Text\ 2.0.1\ x64.tar.bz2     sudo mv Sublime\ Text\ 2 /opt/     sudo ln -s /opt/Sublime\ Text\ 2/sublime_text /usr/bin/sublime      Now, I need to do:               sudo sublime /usr/share/applications/sublime.desktop      but, when I executed it, I got an error:               (sublime:2331): Gtk-WARNING **: cannot open display:      Does someone know how to fix it?


title: dowload find binary , accidentally deleted /usr/bin/find binary file

text: I accidentally deleted all some binaries by rm -r f*, when my current directory was /usr/bin/ . So i couldn't install any files including findutils, since 'find' binary is the prerequisite for installations. Can you help me , where to download or find the binary file for this? My OS is Mint Olivia 15


title: Invalid cross-device link while Hardlinking in the same file system

text: I have **/home/myuser/Desktop/rc/.netrc** file that i want hardlink to **/root** , ie home directory of **root** user. When i do: `ln /home/user/Destkop/rc/.netrc /root` it gives the following error: > ln: creating hard link `/root/.netrc' =>`.netrc': Invalid cross-device link but it works when i hardlink the file to **myuser** 's home, ie to **/home/myuser**. So, what's the problem, why it says invalid cross-devices when there is only one file system here? **PS.** I am using **RHEL6**


title: Is there a condensed side-by-side diff format?

text: I have two log files with thousands of lines. After pre-processing, only some lines differ. These remaining lines are either real differences, or shuffled groups of lines. Unified diffs allow me to see the detailed differences, but it makes manual comparison with eye balls hard. Side-by-side diffs seems more useful for comparison, but it also adds thousands of unchanged files. Is there a way to get advantage of both worlds? Note, these log files are generated by `xscope` which is a program that monitors Xorg protocol data. I am looking for general-purpose tools that can be applied to situation similar to the above, not specialized webserver access log analysis tools for example. * * * Two example log files are available at http://lekensteyn.nl/files/qemu-sdl- debug/ (`log13` and `log14`). A pre-processor command can be found in the `xscope-filter` file which removes timestamps and other minor details.


title: How to setup a rsync server and client?

text: I have worked on rsync for the whole afternoon. I have set a rsync server,but I don't know how to use it. I have two machines:66 and 12. 66 is the server,I want to back 66's data to 12,so I use rsync. I have done the following: **In 66:**               sudo apt-get install xinetd           sudo vim /etc/xinetd.d/rsync      service rsync          {              disable         = no              socket_type     = stream              wait            = no              user            = root              server          = /usr/bin/rsync              server_args     = --daemon              log_on_failure  += USERID          }           sudo nano  /etc/rsyncd.conf           max connections = 2      log file = /var/log/rsync.log      timeout = 300             [wwwroot]        comment = Public Share        path = /home/wwwroot        read only = no        list = yes        uid = nobody        gid = nogroup        auth userusers = user        secrets file = /home/rsync.secrets          sudo /etc/init.d/xinetd restart        **in 12:**               rsync -v  user@192.168.1.100::wwwroot  /home/young001/backup --password-file=/home/rsync.pass       and it tells:               skipping directory .          sent 4 bytes  received 6 bytes  2.86 bytes/sec     total size is 0  speedup is 0.00      the log is:               2013/06/12 03:18:18 [30477] name lookup failed for 125.221.225.12: Name or service not known     2013/06/12 03:18:18 [30477] connect from UNKNOWN (125.221.225.12)     2013/06/12 10:18:18 [30477] rsync on ctp/ from young001@UNKNOWN (125.221.225.12)     2013/06/12 10:18:18 [30477] building file list     2013/06/12 10:18:18 [30477] skipping directory .     2013/06/12 10:18:18 [30477] sent 98 bytes  received 54 bytes  total size 0     2013/06/12 03:19:59 [30484] name lookup failed for 125.221.225.12: Name or service not known     2013/06/12 03:19:59 [30484] connect from UNKNOWN (125.221.225.12)     2013/06/12 10:19:59 [30484] rsync on ctp/ from young001@UNKNOWN (125.221.225.12)     2013/06/12 10:19:59 [30484] building file list     2013/06/12 10:19:59 [30484] skipping directory .     2013/06/12 10:19:59 [30484] sent 98 bytes  received 54 bytes  total size 0      it seems to tell that the directory is empty,but I don't know which directory is empty. /home/young001/backup is a empty directory,and /home/wwwroot is not a empty directory. I want to sync wwwroot to backup,so where did I do wrong?


title: Matching several patterns on one line

text: I often use a program called `tty0tty`, which creates a null modem using PTYs. Now I want to make it part of an automated process. When I start `tty0tty` it prints               (/dev/pts/1) <=> (/dev/pts/2)      Would it be possible to parse the output and use the matches as parameters to another program? So that the following lines could be automated:               linux$ tty0tty &     (/dev/pts/X) <=> (/dev/pts/Y)     linux$ someprogram /dev/pts/X &     linux$ microcom /dev/pts/Y


title: Log every invocation of every SUID program?

text: I would like to have a log file that contains an entry for every time a user runs any suid program, containing the user name, the program and any command line arguments passed to it. Is there a standard way to achieve this on Linux?


title: Swf file won't play anymore in Iceweasel / chromium

text: I'm running on Debian 3.2.46-1+deb7u1 x86_64 GNU/Linux Sid Since roughly the beginning of the year I can't seem to play a swf file from my navigators. Chrome instead of playing it will save it automatically. Iceweasel did the same at first, but now It will open new tabs endlessly when trying to open it. The flash files I try to open are downloaded from this page : http://www.online-stopwatch.com/download-stopwatch/ The flash file tested : This one : http://www.online-stopwatch.com/download- stopwatch/download.php?f=interval-timer-offline The files are located under my personal download directory. I've also tried to put them on my personal web server with the same results. I don't know where/how to report this bug if this is really one. In the mean time I'd take any alternative way, tried gnash without success. Thanks for your help ! edit : corrected links


title: Dollar sign interpolation inside quotes in bash

text: I am running this little test script I wrote :               #!/bin/bash          TESTCASE=$@     testHarness <<runTest     $TESTCASE     runTest      from the command line :               ./test.sh "1092$212"      but the dollar sign is being stripped out. If I escape it, it works. But I thought the double quotes would protect me from needing to do this. Can someone please help me understand whats going on and how to fix this?


title: Description of kernel.printk values

text: Between Debian 5 and 6, the default suggested value for kernel.printk in `/etc/sysctl.conf` was changed from `kernel.printk = 4 4 1 7` to `kernel.printk = 3 4 1 3`. I understand that the first value corresponds to what is going to the console. What are the next 3 values for? Do the numerical values have the same meaning as the syslog log levels? Or do they have different definitions? Am I missing some documentation in my searching, or is the only location to figure this out the kernel source.


title: Let the server own the file created by the client on a Samba share

text: I'm sharing a directory on my Mac using Samba. When the client (Raspebian) creates a file on the mounted share, the file is owned by the user on the client and the permissions are set to -rw-------.   Is it possible to have the user on the server own the file? If not, how do I make newly created files have different permissions? My fstab looks like this:               proc            /proc           proc    defaults          0       0     /dev/mmcblk0p1  /boot           vfat    defaults          0       2     /dev/mmcblk0p2  /               ext4    defaults,noatime  0       1     # a swapfile is not a swap partition, so no using swapon|off from here on, use  dphys-swapfile swap[on|off]  for that     /dev/sda1       /mnt/tm         auto    defaults        0       0     /dev/sda2       /mnt/data       auto    defaults        0       0     //mbp/Downloaded        /mnt/downloaded cifs    defaults,user=usr,password=xxxx,uid=usr,gid=usr,nosetuids,rw,nounix,sec=ntlmssp      0       0      P.S. the last two options are apparently necessary for mounting shares from OS X. I couldn't mount without them.


title: Why are text files 4kB?

text: For some reason, when I make a text file on OS X, it's always at least 4kB, unless it's blank. Why is this? Could there be 4,000 bytes of metadata about 1 byte of plain text? ![enter image description here](http://i.stack.imgur.com/kokJa.png)


title: What is the Linux distro ranking based on number of packages?

text: I am looking for hard data for at least top 10 Linux distro or (better) an address of a web page which keeps such data and (maybe) updates it from time to time (after all repositories are public to view). The criteria is -- the number of native (rpm for SUSE, deb for Ubuntu, etc.) packages programs, libraries, and available in repositories (not on install CD/DVD). For example library counts as 1, not as 10 just because there are 10 packages (ARM, Intel, SPARC, etc.) of it. Thank you in advance. _If you are interested why I am asking about this. Well, I am a bit tired searching repo, finding out there is no package, downloading zip/gz/bz2 of it, finding out how to make an rpm (in case of top layer software of another software, for example Rattle, it is not trivial task), and finally installing it. So it would be good for me to consider other distros which are higher in such ranking._


title: What's the easiest way to create a pre-built "image" of a Debian/Rasbian host?

text: I'm playing around with my raspberry pi project and have made a number of customizations to my device OS (simple stuff... configuration files... installed packages... etc). I would like to make a "copy" of my system available for others to download/use. What's the easiest way to do this?


title: Grubby fatal error in Linux kernel installation

text: I have compiled Linux kernel 2.6.24.6 from source (without problem) and tried to install it. Specifically, after unpacking the Linux source code, I did               make && make modules      to compile. Then after some configuration, I simply used               sudo make modules_install install      to install the newly built binary. During this process, there is an error about locating file `/sys/class/net/eth0/device/bus`. It also throws grubby fatal error. Detailed error stack is as follows:               sh /mnt/factor/myProj3/linux-2.6.24.6/arch/x86/boot/install.sh 2.6.24.6 arch/x86/boot/bzImage System.map "/boot"     unable to stat /sys/class/net/eth0/device/bus: No such file or directory     WARNING: No module xenblk found for kernel 2.6.24.6, continuing anyway     grubby fatal error: unable to find a suitable template      The source code should be all right. What could be the cause of this fatal error? Without fixing it, I can't get Linux installed. Please advise.


title: Why does the paste command add line breaks?

text: I have 2 files: _d_ and _t_. I would like to be able to combine these files so that the first line of file t is followed by a tab and then the first line of d. For shorter lines, `paste t d` seems to work fine.               $ cat d t     Highly reactive metals in group 1A of the periodic table.     Fairly reactive metals in group 2A of the periodic table.     alkali metals     alkaline earth metals     $ paste d t     Highly reactive metals in group 1A of the periodic table.   alkali metals     Fairly reactive metals in group 2A of the periodic table.   alkaline earth metals     $ paste t d     alkali mHighly reactive metals in group 1A of the periodic table.     alkalineFairly reactive metals in group 2A of the periodic table.      Trying to paste full sentences seems to act strangely. As seen above, the terms get trimmed down to the first 8 characters.               $ paste t d > temp     $ gedit temp &     $ vim temp      Opening gedit shows line breaks following each term. Vim shows this:               alkali metals^M Highly reactive metals in group 1A of the periodic table.     alkaline earth metals^M Fairly reactive metals in group 2A of the periodic table.      Well, that seems to be easy enough to fix. `:%s/^V^M//g` removes all of the carriage returns, and everything shows up correctly. But how did those carriage returns end up there in the first place? While my question does involve carriage returns in a text file from Windows making things act strangely in a Unix-like environment, it is not a duplicate of this question. The problems are similar, but the manifestations are very different. It took me around an hour to figure out that carriage returns were even the culprit because I could not find an instance of a similar enough problem through web searches. That is why I posted this after having solved it myself.


title: Should I clean up the home directory prior installing a new distribution?

text: I'm used to keep all my files in my `/home` directory after whiping out my root `/` device and reinstalling distributions. This is pretty handy as all private files and personal settings are kept after reinstallation of a linux distribution. Now I noticed that there are like ~ 300k files are currently in my `/home` device. I'm wondering:   * Should I clean up or even whipe out `/home` before I install a new distro?   * Is there anything that could cause problems If I use `/home` directory across multiple (different) linux distributions?


title: stopping atd job at specified time

text: I'm trying to schedule download at nights. I have created a `atd` job which starts download script at 2 AM. Now I want to stop the same job at 7 AM if it is still running. What I'm doing now is just `shutdown -h 7:00`. Is it possible to stop `atd` job at specified time?


title: How to configure OpenBSD pf to only allow inbound from given countries?

text: I have an OpenBSD 5.2 box what's running a webserver on port 80 and an SSHD server on port 2222. How can I configure OpenBSD's pf to only allow connections from given countries to port 80 and 2222?


title: How to apply new wireless settings on an OpenWRT router without rebooting it?

text: After I manually edit the:               vi /etc/config/wireless      file, what should I do to apply the modifications? Until this day I rebooted the router, but aren't there any better solutions? (and no, www is disabled on the router)


title: Dnsmasq cannot create listening socket for port 53

text: I am trying to set up a DNS server on a Raspberry pi running Raspbian. I have been following tutorials online on how to setup a DNS server, and I found this one that was very easy to follow. http://www.heystephenwood.com/2013/06/use-your-raspberry-pi-as-dns-cache- to.html I followed the directions and installed dnsmasq via the link listed on this site `curl "https://raw.github.com/stephendotexe/raspberrypi/master/roles/dnsmasq_server" | sudo sh`, but when it attempted to start dnsmasq, it gave me the error;               dnsmasq: failed to create listening socket for port 53: Address already in use failed!      I did some research and I came across this post on the Askubuntu site. http://askubuntu.com/questions/191226/dnsmasq-failed-to-create-listening- socket-for-port-53-address-already-in-use Again, I followed the directions and it appeared that dnsmasq interferes with Network Manager, so I ran the following commands, as directed by the post.               sudo apt-get remove dnsmasq-base     sudo apt-get install dnsmasq     sudo apt-get install network-manager network-manager-gnome      Again, this didn't solve my problem. I tried to use `lsof` to figure out what is using port 53, so I installed it with `sudo apt-get install lsof` and ran the command; `sudo lsof -Pn +M | grep ':53 (LISTEN)` I got this output               COMMAND  PID USER   FD   TYPE DEVICE SIZE/OFF NODE NAME     named   1955 bind   20u  IPv4   2467      0t0  TCP 127.0.0.1:53 (LISTEN)     named   1955 bind   21u  IPv4   2469      0t0  TCP 192.168.0.102:53 (LISTEN)     named   1955 bind  512u  IPv4   2466      0t0  UDP 127.0.0.1:53      named   1955 bind  513u  IPv4   2468      0t0  UDP 192.168.0.102:53      I assume this means I need to uninstall BIND or at least make it not execute on startup.


title: Apache + mod_fcgid + chroot with mod_security. CentOS/RHEL 6

text: I am trying to setup a web server running Apache + mod_fcgid + mod_security chroot enabled and having a real hard time to get this working. Apache was installed from official CentOS repo and mod_fcgid and mod_security were installed from EPEL repo. At first, I even was unable to start Apache while chroot is enabled but I've fixed lots of stuff but there's still some I need to sort out. First problem, when I try to start Apache while it's stopped, it does start with no problems, however, when I try to restart it while running this is what I get;               $ service httpd restart     Stopping httpd:                                            [FAILED]     Starting httpd: (98)Address already in use: make_sock: could not bind to address [::]:80     (98)Address already in use: make_sock: could not bind to address 0.0.0.0:80     no listening sockets available, shutting down     Unable to open logs                                                                [FAILED]      Apache Error Log;               [Mon Jun 17 07:47:51 2013] [notice] suEXEC mechanism enabled (wrapper: /usr/sbin/suexec)     [Mon Jun 17 07:47:52 2013] [notice] ModSecurity: chroot checkpoint #1 (pid=954 ppid=953)     [Mon Jun 17 07:47:52 2013] [notice] ModSecurity for Apache/2.7.3 (http://www.modsecurity.org/) configured.     [Mon Jun 17 07:47:52 2013] [notice] ModSecurity: APR compiled version="1.3.9"; loaded version="1.3.9"     [Mon Jun 17 07:47:52 2013] [notice] ModSecurity: PCRE compiled version="7.8 "; loaded version="7.8 2008-09-05"     [Mon Jun 17 07:47:52 2013] [notice] ModSecurity: LUA compiled version="Lua 5.1"     [Mon Jun 17 07:47:52 2013] [notice] ModSecurity: LIBXML compiled version="2.7.6"     [Mon Jun 17 07:47:52 2013] [notice] Digest: generating secret for digest authentication ...     [Mon Jun 17 07:47:52 2013] [notice] Digest: done     [Mon Jun 17 07:47:53 2013] [notice] ModSecurity: chroot checkpoint #2 (pid=955 ppid=1)     [Mon Jun 17 07:47:53 2013] [notice] ModSecurity: chroot successful, path=/var/www     [Mon Jun 17 07:47:53 2013] [notice] Apache/2.2.15 (Unix) DAV/2 mod_fcgid/2.3.7 configured -- resuming normal operations      The second problem is that regular HTML files are being served with no problems but PHP pages are not. mod_security logs;               --98586c48-A--     [17/Jun/2013:08:01:37 --0400] Ub76oUJVtI0AAAPEDiYAAAAG CLIENT_IP_GOES_HERE 51722 SERVER_IP_GOES_HERE 80     --98586c48-B--     GET /testphp.php HTTP/1.1     Host: hostname     User-Agent: Mozilla/5.0 (Windows NT 6.2; WOW64; rv:20.0) Gecko/20100101 Firefox/20.0     Accept: text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8     Accept-Language: en-gb,en;q=0.5     Accept-Encoding: gzip, deflate     Cookie: PHPSESSID=5a9jqak7dt30l2vvrs9c74lo81     Connection: keep-alive     Cache-Control: max-age=0          --98586c48-F--     HTTP/1.1 500 Internal Server Error     Content-Length: 543     Connection: close     Content-Type: text/html; charset=iso-8859-1          --98586c48-E--          --98586c48-H--     Apache-Error: [file "fcgid_proc_unix.c"] [line 637] [level 4] [status 104] mod_fcgid: error reading data from FastCGI server     Apache-Error: [file "/builddir/build/BUILD/httpd-2.2.15/server/util_script.c"] [line 435] [level 19] Premature end of script headers: testphp.php     Apache-Handler: fcgid-script     Stopwatch: 1371470497629709 2809 (- - -)     Stopwatch2: 1371470497629709 2809; combined=25, p1=3, p2=10, p3=1, p4=1, p5=9, sr=0, sw=1, l=0, gc=0     Response-Body-Transformed: Dechunked     Producer: ModSecurity for Apache/2.7.3 (http://www.modsecurity.org/).     Server: Apache     Engine-Mode: "ENABLED"          --98586c48-Z--      Where I'm wrong at? What I'm missing?


title: Server socket location, startup and monitoring

text: I'm writing a server on a shared development desktop that moonlights as a server. This is my first attempt at writing a linux server for someone else on a shared box. I'd like to conform to unix standards and make it as professional as possible. In what directory should the websocket server be placed? I was thinking `/var`, but it's `root`'s, so I don't know how exactly to navigate that. How should execution be managed? In other words, should a new group be made that has permissions to execute the server in case it crashes or needs restarting? If so, how?


title: How to suid iwconfig on Debian wheezy?

text: I have a script running under my own user account that takes care of all sorts of wireless interfaces. It (more or less) intelligently switches wireless LAN off and on and so forth. However, it does so by calling on tools such as `iwconfig` and `hciconfig` to bring the devices up and down. But since these require super user privileges I decided to create a copy of these binaries in my personal script folder and set the suid flag (I am the only one who can read and execute that directory). So the permissions on these binaries look like `-rwsr-x---` and they belong to `root` and my own primary group. However, the suid bit appears to be completely ignored because I get the following result when executing that binary:               me@host:~/scripts/suid$ stat iwconfig       File: `iwconfig'       Size: 26968       Blocks: 72         IO Block: 4096   regular file     Device: 15h/21d Inode: 4194732     Links: 1     Access: (4750/-rwsr-x---)  Uid: (    0/    root)   Gid: ( 1000/   me)     Access: 2011-08-24 04:15:39.008148182 +0200     Modify: 2013-02-09 21:25:47.777488386 +0100     Change: 2013-03-12 15:55:20.765681857 +0100      Birth: -     me@host:~/scripts/suid$ ./iwconfig wlan0 txpower off     Error for wireless request "Set Tx Power" (8B26) :         SET failed on device wlan0 ; Operation not permitted.      I also tried setting the group to root, the guid bit and making the binaries world executable and readable. With the same outcome. **So, why is that and how can I fix it?**


title: Copy / paste text selections between tmux and the clipboard

text: I am running the latest version of tmux (from the git repository) and xclip (0.12), and I would like to be able to use Emacs-like keyboard bindings to move around the text in `copy-mode`, copy (`M-w`) selections to the clipboard, and paste (`C-y`) from/to the copy buffer to the clipboard. So far I have been able to paste text with `C-y`, and move around in `copy- mode` with Emacs-like keyboard bindings, but **I am still unable to copy text** from a tmux buffer (e.g. in `copy-mode`) I found this thread for copying the entire buffer to the clipboard (and viceversa), but it does not seem to be working for me. Also, in the `tmux-users` mail list I was told that recent versions of tmux (only in the git repo) provide a command called `copy-pipe`. The man page says the following about this command: > One command in accepts an argument, copy-pipe, which copies the selection > and pipes it to a command. For example the following will bind ‘C-q’ to copy > the selection into /tmp as well as the paste buffer: >   >   >            bind-key -temacs-copy C-q copy-pipe "cat >/tmp/out" >   It looks like `copy-pype` is meant to be used in part to pipe the selection to another command. There also seem to be some typos in this description and in the command (what is `temacs-copy`?) Either way, what I would like to do is: ### Copying:   1. Enter copy mode   2. Move to the text I want to copy using Emacs navigation commands (i.e. `C-f`,`C-b`, `M-f`, `M-b`, `C-a`, `C-e` etc. to move the cursor). **No prefix** for any of these.   3. Copy the selected text into the clipboard with: `M-w` ( **no prefix** either) ### Pasting:   1. I would like to be able to type `C-y` ( **without** having to enter `copy-mode`) to paste text in the terminal ( **no prefix** either) I have tried the following for copying without luck:               bind-key -n M-w run "tmux save-buffer - | xclip -i -selection clipboard"       However, pasting works great:               bind-key -n C-y run "xclip -o | tmux load-buffer - ; tmux paste-buffer"      The odd thing is that I know that the "`xclip -i -selection clipboard`" part of the copy command above works well, since **I can** copy things to the clipboard in the command line, e.g.:               echo "Hello world. How are you?" | xclip -i -selection clipboard      With all this, **how can I copy a selection from copy mode to the clipboard?**


title: Can I "yum upgrade" to a specific CentOS version?

text: I'm using a third party proprietary application on CentOS 5.4, which is known to malfunction on pristine 5.9 or later. I would like to incrementally upgrade to the latest CentOS version where that application works. Since `yum update` brings me to 5.9 right away, that's not an option. I thought of burning all four Install-DVDs 5.5 through 5.8 and installing each to find out the hard way where the breakage sets in, but maybe there's an easier way frobbing the `/etc/yum.conf.d` files to go from 5.4 to 5.5 etc. Can anyone provide some guidance? (Sadly, it is not an option to ask the vendor of that application for a fix, since it was acquired by a big blue company and terminated a little while after that.) **Edit** : Further investigation revealed it is an incompatibility in the GNU C library. With glibc-2.5-58 the app runs fine on CentOS 5.9, with stock glibc-2.5-107 it hangs. I now point LD_LIBRARY_PATH at the older glibc when running the app.


title: clear full-screen in script and get the previous prompts after exiting script

text: Today I was using `glance` tool in my office to monitor CPU utilization.When I run `glance` from terminal ,the command clears the screen and after all the work when I quit back to the terminal,the previous prompts are still there on my screen.I mean that I can see all the previous lines.My question is how is this effect of clearing screen achieved.If they had used command like `clear`,It should have cleared the whole screen,how did they manage to get back all the previous prompts ? I want to implement the same feature for some of my scripts. Similarly when using `vi` command ,the screen is fully occupied and after exiting,we are able to view previous prompts as well.


title: GNU/Linux: overlay block device / stackable block device

text: GNU/Linux has union mount that overlays dirs. So you can mount a writeable dir on top of a read-only dir. When the writeable dir is unmounted the read-only dir is untouched. I am looking for the same functionality for block devices - preferably with the writeable part stored in a file. So I would like to run something like:               device-setup /dev/newdevice /dev/read-only-device overlayfile      If I write to /dev/newdevice the changes should be stored in overlayfile. If I read the sectors written to, I should get the data from overlayfile. If I read sectors not written to, I should get the data from /dev/read-only-device. Does such a tool exist?


title: Debian wheezy - display- fresh copy (installed twice)

text: I'm totally new to Linux. I installed a fresh copy of Debian wheezy and everything installed fine. After first boot my screen is not set to proper resolution. I tried all the tech tips in Google which I ended up in re- installing Debian twice. (after trying tips on Google I rebooted and it was blank screen and keeps rebooting from grub and blank screen) - so me! My xrandr output... (FYI. I am working on Lenvo laptop which has best resolution 1366x768 - single laptop screen only)               Screen 0: minimum 320 x 200, current 1024 x 768, maximum 8192 x 8192     LVDS1 connected 1024x768+0+0 (normal left inverted right x axis y axis) 344mm x 194mm     1366x768 60. 0 +     1360x768 59. 8 60. 0     1024x768 60. 0*     800x600 60. 3 56. 2     640x480 59. 9     VGA1 connected 1024x768+0+0 (normal left inverted right x axis y axis) 0mm x 0mm     1024x768 60. 0*     800x600 60. 3 56. 2     848x480 60. 0     640x480 59. 9     HDMI1 disconnected (normal left inverted right x axis y axis)     DP1 disconnected (normal left inverted right x axis y axis)      My above xrandr show's two screen connected. Also I couldn't find any `xorg.conf` also               Root@debian:/etc/X11# ls     app-defaults rgb.txt xkb Xresources Xsession. Options     default-display-manager X Xreset Xsession XvMCConfig     fonts xinit Xreset. D Xsession. D Xwrapper. Config      Also my boot screen also seems to have low resolution. And in settings -> Display "mirror display" is selected. If I un-select it the display goes blank. I'm waiting for with low resolution.


title: How come each program or service has an account of its own in /etc/passwd?

text: I checked out the /etc/passwd file and I'm surprised to see that there are 35 different accounts, even though I'm the only user on this computer. I see that the accounts have names like mail, news, www-data, irc, pulse, etc. Why do those each have their own accounts and how are they used?


title: GnuPG : representations of key IDs and fingerprints

text: In `gpg`'s man page, there are examples of key IDs :               234567C4     0F34E556E     01347A56A     0xAB123456          234AABBCC34567C4     0F323456784E56EAB     01AB3FED1347A5612     0x234AABBCC34567C4      and fingerprints :               1234343434343434C434343434343434     123434343434343C3434343434343734349A3434     0E12343434343434343434EAB3484343434343434     0xE12343434343434343434EAB3484343434343434      My intuition would have been that a leading 0 is for octal and a leading 0x for hexadecimal, but it does not seem like it is. What are the different representations?


title: GNU/Hurd vs. GNU/Linux

text: I was quite surprised to learn that the GNU project has an independent kernel of their own called Hurd. And there are mainstream distributions like Arch Hurd and Debian GNU/Hurd which uses it. Is there any significant advantage for Hurd over Linux?


title: Why is sudo telling me my password is wrong?

text: I recently installed OpenBSD 4.9 in my computer, so I could learn a little bit about Unix-like operating systems. I added a new user to the system called bruno. Ok. When I use the 'sudo' command, it asks me for a password. So, I enter the password. But it keeps me telling that the password is wrong, even though I'm sure that the password is correct. What am I missing here? I know if add                bruno ALL = (ALL) NOPASSWD: ALL      to the /etc/sudoers file it stops asking for the password, and I can execute the sudo command. What should I do here? What's the most correct/secure option? I'm sorry if it's a trivial question. I couldn't find a good explanation for this issue. I'm not only looking for solutions, but for explanations on how this whole user/permission/password thing works.


title: Arch Linux doesn't connect to a wireless network

text: I'm using Arch Linux on a Thinkpad machine. Everything was satisfactory but today I restarted my router and the machine doesn't connect. The router is fine (another machine and a cell phone connect to it easily). I'm using `wicd` from a terminal and all I get is a "not connected" message. How can I fix/diagnose this? _Edit_ I tried this without the script and replaced dhclient with dhcpcd (open network) and all I get is a connection time out.


title: How to boot xenomai on ubuntu 10.04?

text: I install xenomai by               sudo apt-get install xenomai-*      It installed               dctrl-tools libxenomai-dev libxenomai1 linux-patch-xenomai xenomai-doc xenomai-runtime.      But when I check `/boot/grub/grub.cfg`, it seems it didn't change anything. How do I boot `xenomai` on Ubuntu 10.04? Should I followed Building Debian packages's Building a Xenomai patched Linux kernel package? But it uses kernel 2.6.35, which is newer than mine (2.6.32). Thank you~


title: How to insert a new line after every second line?

text: sed/bash/wharever :D INPUT:               sadf     asdf     yxcv     cxv     eqrt     asdf      OUTPUT:               sadf     asdf          yxcv     cxv          eqrt     asdf


title: How do I remove acpi Warning on boot?

text: I have this message in `dmesg` log with linux 3.11.6-1 (2013-10-27) (debian version). I wonder how to fix/remove it?                    [    5.098132] ACPI Warning: 0x0000000000000428-0x000000000000042f SystemIO conflicts with Region \PMIO 1 (20130517/utaddress-251)          [    5.098147] ACPI: If an ACPI driver is available for this device, you should use it instead of the native driver          [    5.098156] ACPI Warning: 0x0000000000000530-0x000000000000053f SystemIO conflicts with Region \GPIO 1 (20130517/utaddress-251)          [    5.098167] ACPI: If an ACPI driver is available for this device, you should use it instead of the native driver          [    5.098171] ACPI Warning: 0x0000000000000500-0x000000000000052f SystemIO conflicts with Region \GPIO 1 (20130517/utaddress-251)          [    5.098180] ACPI: If an ACPI driver is available for this device, you should use it instead of the native driver          [    5.098186] lpc_ich: Resource conflict(s) found affecting gpio_ich          [    5.099072] ACPI Warning: 0x000000000000f040-0x000000000000f05f  SystemIO conflicts with Region \_SB_.PCI0.SBUS.SMBI 1    (20130517/utaddress-251)          [    5.099085] ACPI: If an ACPI driver is available for this device,     you should use it instead of the native driver      lspci :               $ lspci     00:00.0 Host bridge: Intel Corporation 3rd Gen Core processor DRAM Controller (rev 09)     00:02.0 VGA compatible controller: Intel Corporation 3rd Gen Core processor Graphics Controller (rev 09)     00:14.0 USB controller: Intel Corporation 7 Series/C210 Series Chipset Family USB xHCI Host Controller (rev 04)     00:16.0 Communication controller: Intel Corporation 7 Series/C210 Series Chipset Family MEI Controller #1 (rev 04)     00:19.0 Ethernet controller: Intel Corporation 82579LM Gigabit Network Connection (rev 04)     00:1a.0 USB controller: Intel Corporation 7 Series/C210 Series Chipset Family USB Enhanced Host Controller #2 (rev 04)     00:1b.0 Audio device: Intel Corporation 7 Series/C210 Series Chipset Family High Definition Audio Controller (rev 04)     00:1c.0 PCI bridge: Intel Corporation 7 Series/C210 Series Chipset Family PCI Express Root Port 1 (rev c4)     00:1c.1 PCI bridge: Intel Corporation 7 Series/C210 Series Chipset Family PCI Express Root Port 2 (rev c4)     00:1c.5 PCI bridge: Intel Corporation 7 Series/C210 Series Chipset Family PCI Express Root Port 6 (rev c4)     00:1d.0 USB controller: Intel Corporation 7 Series/C210 Series Chipset Family USB Enhanced Host Controller #1 (rev 04)     00:1f.0 ISA bridge: Intel Corporation QM77 Express Chipset LPC Controller (rev 04)     00:1f.2 SATA controller: Intel Corporation 7 Series Chipset Family 6-port SATA Controller [AHCI mode] (rev 04)     00:1f.3 SMBus: Intel Corporation 7 Series/C210 Series Chipset Family SMBus Controller (rev 04)     02:00.0 Network controller: Intel Corporation Centrino Ultimate-N 6300 (rev 35)     03:00.0 SD Host controller: O2 Micro, Inc. Device 8221 (rev 05)


title: Having several qdisc for each device, which is the first to process?

text: I have read about queuing disciplines here http://lartc.org/. Having this traffic shaping policy:               ....     qdisc pfifo_fast 0: dev ppp0 root bands 3 priomap  1 2 2 2 1 2 0 0 1 1 1 1 1 1 1 1     qdisc pfifo_fast 0: dev ppp2 root bands 3 priomap  1 2 2 2 1 2 0 0 1 1 1 1 1 1 1 1      Assuming that there is only outgoing traffic in band 0 of ppp0 qdisc and band 2 of ppp2 qdisc, which is dequeued first? I understand that band 0 is prioritized over band 2 within same qdisc, but is band 0 of ppp0 qdisc prioritized over band 2 of ppp2 qdisc?.


title: Listing a hardrive partition by blocks using LBA

text: Most hard drive and partition inspection tools seem to list the items using sectors, head.. etc. From another question I was told that these are virtual because they have to be converted from lba, which causes conversion errors. Are there any unix tools that list a hard drive by logical blocks?


title: wget command still downloads folder after exclusion

text: I am trying to learn wget better. However when I run my code it still downloads the forum section. Where am I going wrong?                   wget --recursive --no-clobber --page-requisites --html-extension --convert-links --limit-rate=50k --random-wait --exclude-domains http://domain.com/forums/ --no-parent http://domain.com/      referenced


title: Does a parent bash script remember the cd history from a child bash script?

text: Example: mainscript.sh               cd /mnt/something     ./buildscripts/000-script.sh      000-script.sh               cd /mnt/otherthing     mkdir something     exit


title: Can the UNIX command tree display only directories matching a pattern?

text: I'm trying to figure out if there is a way to get the UNIX command `tree` to display only directories that match a specific pattern.               % tree -d tstdir -P '*qm*' -L 1     tstdir     |-- d1     |-- d2     |-- qm1     |-- qm2     `-- qm3          5 directories      The **man page** shows this bit about the switch. > -P pattern List only those files that match the wild-card pattern. Note: you > must use the -a option to also consider those files beginning with a dot `.' > for matching. Valid wildcard operators are`*' (any zero or more characters), > `?' (any single character),`[...]' (any single character listed between > brackets (optional - (dash) for character range may be used: ex: [A-Z]), and > `[^...]' (any single character not listed in brackets) and`|' sepa‐ rates > alternate patterns. I'm assuming that the bit about **...List only those files...** is the issue. Am I correct in my interpretation that this switch will only pattern match on files and **NOT** directories? **EDIT #1** @f-hauri looks to have the best reason as to why this doesn't work the way one would think from the switches available in the `tree` man page. I missed this bit in the BUGS section.               BUGS        Tree  does not prune "empty" directories when the -P and -I options are        used.  Tree prints directories as it comes to them, so  cannot  accumu‐        late  information  on files and directories beneath the directory it is        printing.      Given this limitation it looks like `tree` isn't the best way to accomplish an inclusive filtered list, but a exclusive filtered list would be an alternative way using the `-I` switch. In lieu of this it would look like either shell wildcards, the find command, or a Perl script would be a more appropriate way to accomplish this. See @f-hauri's fine answer for some of these alternative methods.


title: Are there plans to get ATI stream SDK working properly on BSD?

text: I have BSD functioning exactly as I would like for workstations/laptops. I'm looking at getting in to OpenCL applications and would prefer to use BSD with fglrx or some workaround to get opencl working without doubling to cost to get Nvidia cards. There were plans to get USB passthrough vbox OSE working on BSD for a while and I waited it out. Great stuff btw. I'm wondering about opencl on ATI. I can't seem to find a definitive answer anywhere.


title: How to disable energy saving on notebook screen when using Scientific Linux 6.3?

text: So there is a notebook that has Scientific Linux 6.3 installed with GNOME 2. ~~If we don't press any button on the keyboard or move the mouse,~~ the screen of it turns black. But: if we move the mouse/hit a button when the screen of it went black.. it still stays black.. it's not a hardware problem, it's a problem related to the OS. I didn't find any energy saving options for this in the BIOS. If the screen is black, we can slightly see that the OS is still running, but it's very-very-very dark.. The only solution is to press the power-on button for 5 seconds to turn the machine off.. Any solutions/settings? Please halp. UPDATE#1: (I can only rarely get to this notebook, that's why I can only answer rarely, sorry) So I found a settings in gnome-screensaver-preferences: "Activate screensaver when computer is idle" was enabled. I disabled it, and we are waiting for the blank screen to appear again, but this takes time, because I found out that the screen goes to blank randomly (!). Even if there was somebody in front of the notebook and was using the ex.: USB mouse.. strange.. I will update the Q/accept the good answer if this helps:D UPDATE#2: Until the outcome the xset -q output is this:               [root@HOSTNAME ~]# xset -q     Keyboard Control:       auto repeat:  on    key click percent:  0    LED mask:  00000000       XKB indicators:         00: Caps Lock:   off    01: Num Lock:    off    02: Scroll Lock: off         03: Compose:     off    04: Kana:        off    05: Sleep:       off         06: Suspend:     off    07: Mute:        off    08: Misc:        off         09: Mail:        off    10: Charging:    off    11: Shift Lock:  off         12: Group 2:     off    13: Mouse Keys:  off       auto repeat delay:  500    repeat rate:  30       auto repeating keys:  00ffffffdffffbbf                         fadfffefffedffff                         9fffffffffffffff                         fff7ffffffffffff       bell percent:  50    bell pitch:  400    bell duration:  100     Pointer Control:       acceleration:  2/1    threshold:  4     Screen Saver:       prefer blanking:  yes    allow exposures:  yes       timeout:  0    cycle:  0     Colors:       default colormap:  0x20    BlackPixel:  0    WhitePixel:  16777215     Font Path:       catalogue:/etc/X11/fontpath.d,built-ins     DPMS (Energy Star):       Standby: 0    Suspend: 0    Off: 0       DPMS is Enabled       Monitor is On     [root@HOSTNAME ~]#


title: Clipboard doesn't work in KVM.

text: I have a RHEL 6 Desktop with a windows KVM. How could I get the clipboard working, just as there is a solution in VirtualBox to share the clipboard between host and guest?


title: Bluetooth headset profile not working with recent kernel

text: I have a Plantronics 590 bluetooth headset (the type probably does not matter, but I have no alternative to test). Using the old 3.02 I was able to use this via pulseaudio. With the current 3.11-amd64 kernel this does no longer work. I am still able to pair and to connect to the headset, using HSP profile. I get a "beep" on the headset to confirm connection. Unfortunataly there is neither input nor output in pulseaudio (with the old kernel `pavucontrol` shot the headset). This is most likely related to the kernel or a module. I am using debian testing (jessie).   * The current version of linux-image-amd64 is 3.13+56   * The current version of bluez is 4.101-4.1   * The current version of pulseaudio and pulseaudio-module-bluetooth is 5.0-2   * The current version of alsa-base is 1.0.25+3 I also tried debian stable (wheezy), 32bit, not working, but different: I can connect the device, it appears in `pavucontrol` but sound does not work.   * The current version of linux-image-686-pae is 3.2+46   * The current version of bluez is 4.99-2   * The current version of pulseaudio and pulseaudio-module-bluetooth is 2.0-6.1   * The current version of alsa-base is 1.0.25+3~deb7u1


title: Allow other user to copy the files from my folder?

text: I am working with Ubuntu and I have a jar file in this folder `/export/home/david` And I am logged in `machineB` as `david` user. Some other user is also logged in that same machine. And I want other user to copy the above jar file from my location. But somehow they are not able to do that as they are getting permission denied. Is there any way I can add some permission on that jar file or on my folder so that anybody can copy the files from that folder? **Update:-** Below is the result I got -               david@machineB:~$ groups david     david : uucp          otheruser@machineB:~$ groups otheruser     otheruser : app          david@machineB:~$ ls -l foo.jar     -rw-r--r-- 1 david uucp 6543346 2014-03-07 18:27 foo.jar          david@machineB:~$ ls -ld $(echo "/home/david/foo.jar" | sed -r ':a; s#(.*)/[^/]*$#\1#;p;ta')     drwxr-xr-x 22 root   root 4096 2014-05-04 08:04 /home     drwx------  4 david uucp 4096 2014-03-07 18:36 /home/david


title: Where is $_ defined by POSIX?

text: In the comments to the accepted answer to this Unix & Linux StackExchange question, it is stated that `$_` is "one of only some 7 special parameters defined by POSIX". I can't find that definition although I can find eight other special parameters defined by POSIX and I've seen `$_` defined in the ksh and bash man pages. Can someone point me to the definition in POSIX?


title: Run script in a non interactive shell?

text: I have a cron job that is running a script. When I run the script via an interactive shell (ssh'ed to bash) it works fine. When the script runs by itself via cron it fails. My guess is that it is using some of the environmental variables that are set in the interactive shell. I'm going to troubleshoot the script and try and remove these. After I make changes, I know I could queue up the script in cron to have it run as it would normally, but **is there a way I can run the script from the command line, but tell it to run as it would from from - i.e. in a non- interactive environment?**


title: How do I change permissions on a directory without losing setgid?

text: When I change permissions for other or user on a setgid directory, the directory loses its setgid. How do I make the change without loosing it? sudo is not an option. Is it possible? Here is some context.               $ whoami     webmin     $ groups     webmin     $ echo $SHELL     /bin/bash     $ uname -srvm     Linux 2.6.38-12-server #51-Ubuntu SMP Wed Sep 28 16:07:08 UTC 2011 x86_64      Here is an example.               $ ls -la     drwxr-s--- 4 webmin www-data    4096 2011-11-03 10:59 .     drwxr-s--- 4 webmin www-data    4096 2011-10-26 15:53 ..     $ mkdir libraries     $ ls -ld libraries     drwxr-sr-x 2 webmin www-data    4096 2011-11-03 11:01 libraries     $ chmod o= libraries     $ ls -ld libraries     drwxr-x--- 2 webmin www-data    4096 2011-11-03 11:01 libraries           ^            `- The problem      The same happens if I modify the user's permissions on the directory. The following fails too.               $ chmod g=rxs,o= libraries      === UPDATE ==== Kevin's answer led me to what I believe is the cause of the problem. Apparently, you must be a member of the group assigned to the file. For example               $ whoami     webmin     $ groups     webmin www-data      <---- Now we are in the www-data group.     $ mkdir t     $ ls -ld t     drwxr-sr-x 2 webmin www-data 4096 2011-11-03 12:03 t     $ chmod o= t     $ ls -ld t     drwxr-s--- 2 webmin www-data 4096 2011-11-03 12:03 t           ^            `- Yeah!      So is the answer is "yes" as long as you are a member of the group, otherwise "no"?


title: Wikilink to a symbolic link in ikiwiki

text: I am running an ikiwiki for my personal use on my laptop via apache2 (os: ubuntu 10.04). If I want to make a link to a local pdf-file I put the file into my scrdir and use the usual wikilink syntax. However if I put only a symbolic link into the scrdir instead of the actual file, it doesn't work. Is there a way to make that ikiwiki handles symbolic links in this situation?


title: replicate and isolating user environments on the fly

text: I will be using Ubuntu Linux for this project. For training of a particular application at a conference I need:   1. To have each student be able to ssh into the _same_ user account on a server   2. Upon each login automatically put the user in separate isolated environments   3. Each isolated environment includes the application, example config files, and the standard unix toolset (e.g. grep, awk, sort, uniq, etc.) However, access to an entire linux filesystem is fine too as long as the user can only damage his own isolated environment and not those of others.   4. The virtual environments should be destroyed when the users SSH session ends For #1 we would like to do the single user account so we don't have to deal with creating an account for each student and handing out the user names and passwords. Does anyone know how I can meet these goals? Which technology e.g. LXC, Chroot, etc. is best for this? I've been toying with the idea of using .bash_profile and .bash_logout to handle the creation and destruction of these environments but not sure which technology is capable of creating the environments I need.


title: Change motd value in UNIX Operating System

text: I need to change the value of MOTD using a script but I do not know how I should start. Am attaching sample MOTD if anyone can help.            ![enter image description here](http://i.stack.imgur.com/ErQfp.jpg)


title: ulimit vs. limit on FreeBSD 8.3

text: I had the same issue with the error as this and this question (both of which I read and understood), the message being:               $ ulimit -n 20000     ulimit: bad limit: Operation not permitted      I encountered this issue on **FreeBSD 8.3** after an upgrade from 7.3 and thought it may have had something to do with the upgrade. I also had all sorts of issues running the command as root and could only run it as a standard user - which is what I wanted in any case. The issue is that with FreeBSD the command is `limit`, not `ulimit`. When I ran as a normal user:               %limits -n 20000      I got the exact result I wanted which was to increase the openfile limit from 11095 to 20000, or so I thought. The output was:               Resource limits (current):       openfiles               20000      However when I ran the limit command again the `limit` is shown back at 11095. * * * How do I change either the hard/soft limit on a FreeBSD 8.3 box?


title: Why am I still getting pkg deprecation warnings?

text: I'm still getting warnings about the old pkg tools being deprecated and saying I should switch to pkgng, despite the fact that I followed the directions to switch weeks ago. I did the pkg2ng thing, and the old pkg can't even read the info anymore (shows as corrupt if I try). My /etc/make.conf is set to use pkgng as well. Yet, doing ports updates (via portmaster) I still see warnings about the old pkg system going away. What have I missed?


title: How to properly run "top" command through SSH?

text: I have to run **top** command on one computer being on another. My targeted PC has IP 192.168.0.81 I was trying to do it: **ssh 192.168.0.81 top** But I got this result: **top: tcgetattr() failed: Invalid argument** Could anybody help me with this issue? System info: Linux iRP-C-09 2.4.18-timesys-4.0.642 Top version: 2.0.7


title: Late running of scripts during bootup, ending with a reboot without the login prompt

text: I'm making a special "installer" for an embedded system where I'd like the kernel to boot up, execute a set of things very late in the process where the peripherals have been set up and then reboot the system without the login prompt ever happening. I'm vaguely familiar with init and runlevels, I presume at this point that this is how I'll most easily achieve this. Can I put a script (then where/how?) in the init sequence that runs my stuff and then puts the machine to a reboot afterwards ? If it matters the rootfs is debian.


title: How to install D-Link DWA-510 for Debian 7?

text: I just bought a D-Link DWA-510. But I can't install it on my Debian 7 32 bits. And I want to use in a runlevel 3. How can I use this D-link? Thanks!


title: Linux console: only kernel messages are printed

text: My Linux system is built by Buildroot and runs on a Raspberry Pi. I use a Usb to TTL Serial cable to get a console. Here comes cmdline.txt               dwc_otg.fiq_fix_enable=1 sdhci-bcm2708.sync_after_dma=0 dwc_otg.lpm_enable=0     console=ttyAMA0,115200 kgdboc=ttyAMA0,115200 console=tty1     root=/dev/mmcblk0p2 rootwait      Here comes the getty related part of /etc/inittab               # Put a getty on the serial port     ttyAMA0::respawn:/sbin/getty -L  ttyAMA0 115200 vt100 # GENERIC_SERIAL      Only kernel messages are printed; no daemons ones (such as sshd). How can this issue be fixed?


title: Where did nvidia-driver go?

text: As far as I'm aware, all nvidia driver installation instructions in Debian Jessie are the same as the Debian Wheezy's and involve the instalation of `nvidia-kernel-dkms` and `nvidia-driver` packages. The problem is that both packages are now gone. Can anyone provide updated driver installation instructions? I own a GeForce GTX 750, my current kernel is 3.14-1-amd64 and I'd like to keep using Debian's repositories since they (usually) are the most convenient way to keep drivers updated.


title: Why isn't a semicolon accepted after then?

text: I'm new to shell programming, and noticed that the following is accepted:               if [ $table = "Session" ]; then     continue; fi      And so is the following:               if [ $table = "Session" ]; then continue; fi      While the following produces a syntax error:               if [ $table = "Session" ]; then; continue; fi      Why is the `then` keyword different from the others?


title: Extract substring from 'list' of strings

text: I have a file with lines with IDs, and I'm extracting certain substrings from each line. I've seen this answer, which is great, but I don't know how to get it to execute on each line. I figure `xargs` should be part of this, but I'm not sure. As an example, I have this: 1234 **0001** 1234   9737 **0002** 1234   28399 **0003** 1235   8279 **0004** 1234 (Emboldedned for clarity) And I want to _for each_ line above to extract this: 0001   0002   0003   0004 Now I know that if _one_ of the lines was `$line_one`, I could use `echo ${line_one: -8:4}` to grab the first 4 characters, of the last 8 characters. But I have the lines coming out of the previous command (which is something like `cut -d "|" f1`, (I think, I'm not at the PC that has the file in question, and that PC doesn't have internet)). What I'm imagining is some world where I can run this:               cut -d "|" -f1 | xargs echo ${xargs_line: -8:4}      To get my output.... Is this possible? If so how?


title: How to guarantee writes are physically committed before reported completed?

text: When my system boots, as it probes the external, USB-attached hard drive, I get the message `Assuming drive cache: write through` in the dmesg output, tagged with the device name of the external drive. Since I use this drive to store backups, I'd really prefer **the system to not make any assumptions about the drive's characteristics**. _I'm willing to trade write performance_ for secure knowledge that when something has been written to a file system on the drive in question, **it really has been committed to permanent storage** and isn't sitting in a cache somewhere (preferably not even on the drive itself, since a power failure will cause both the computer and the drive to lose power immediately). A possibly complicating factor is that the drive holds a single partition, which is LUKS encrypted. The file system only exists within that LUKS container, like so:               +- physical drive ------------------------+     |                                         |     |  +- partition -----------------------+  |     |  |                                   |  |     |  |  +- LUKS encryption -----------+  |  |     |  |  |                             |  |  |     |  |  |  +- file system ---------+  |  |  |     |  |  |  |                       |  |  |  |     |  |  |  |      actual data      |  |  |  |     |  |  |  |                       |  |  |  |     |  |  |  +-----------------------+  |  |  |     |  |  |                             |  |  |     |  |  +-----------------------------+  |  |     |  |                                   |  |     |  +-----------------------------------+  |     |                                         |     +-----------------------------------------+      Hence my question: How can I make sure that all writes are committed to physical storage before being reported back to the userspace application as completed?


title: difference between .* and * in regular Expression

text: I've a file named "test" that contains               linux     Unixlinux     Linuxunix     it's linux     l...x      now when i use `grep '\<l.*x\>'` , it matches :               linux     it's linux     l...x      but when i use `grep '\<l*x\>'` , it only matches: `l...x` , but according to the reference guide, when using * , The preceding item will be matched zero or more times, i.e it should match anything that starts with 'l' and ends with 'x' Can anyone explain why ,it's not showing the desired result or if i've understood it wrong ?


title: Difference between "echo $SHELL" and "which bash"

text: I am trying to determine the location of bash interpreter on my Solaris system and I am a bit confused. When I type:               echo $SHELL      The resulting path is:               /bin/bash      And when I type:               which bash      I get:               /usr/bin/bash      Can anyone please explain this discrepancy?


title: Strange difference between pwd and /bin/pwd

text: I added a symlink to the current directory with `ln -s . aa`. If I execute `cd aa`, and after that I executed `pwd`, the response is `/home/sim/aa`. But if I execute `/bin/pwd` it prints `/home/sim` (the current directory hasn't changed). Where does this difference come from?


title: Shell script execution on multiple servers

text: Is it possible to run one part of the ksh/sh script on one server then ssh to another server and continue with the rest of the script? or is there a way around? Anyone had experience with this ? **here are some details:** I have a user with which I don't have to authenticate each time I access a server, so I can hop from one server to another without any keyboard interaction I've already tried this, wanted to seperate logic into another script then :               MYSCRIPT="nohup ksh myscript.ksh > mylog.log &"     ssh servername ${MYSCRIPT}      I tried this but it doesn't seem to execute this script on another server **and one more thing** the whole code above is part of the for loop and I basically execute same script for list of servers. For testing purposes, the list has two servers, for some weird and twisted reason only the last/seconds server script works as I expect. **another detail:** all server can see myscript.ksh it is visible and executable to all of them