Replaced matched text in Vim with pattern

Here's a minimal example of what I'm trying to do. Start with:               "this")     "that")     [hundreds of lines like this] End with:               "this",&this;)     "that",&that;)     [hundreds of lines like this] I have gotten this far:               g/"\p*"/s/)/[what to put here?]      So it correctly identifies the string that I want to copy. What I'm not sure is how to tell it that I want it to paste that string at the end. I've tried using `&`, but that matches the `)`, not the `"\p*"`.


Inkscape not opening after installed?

I just installed 14.04 on my laptop. The first thing I did was to install `inkscape` by using the instructions on this website. However, after installation, it does not appear if I search for it in the Unity dash. If I try running it from the command line, it says that it is not installed. But if I try to to install again, it says that the newest version is already installed. Additionally, Ubuntu Software Center says that it is installed. See the terminal output below. What should I do?                   mark@kitchencomputer:~$ inkscape         The program 'inkscape' is currently not installed. You can install it by typing:         sudo apt-get install inkscape         mark@kitchencomputer:~$ sudo apt-get install inkscape         Reading package lists... Done         Building dependency tree                Reading state information... Done         inkscape is already the newest version.         0 upgraded, 0 newly installed, 0 to remove and 9 not upgraded.      ![enter image description here](http://i.stack.imgur.com/nvhUS.png)


Keyboard map in remote connection without X

I'm connected to a remote machine. I'd like to switch to keyboard layout. If the X server is running I can do:               setxkbmap us -variant colemak      But what can I do, if this is a connection without a X server? I don't have root access and ideally don't want to edit files on the remote.


Using external hard disk to boot 2 different computers with different hardware

I'm a CS student at my university, so I typically run a version of linux at my home computer when I do programming in C or other linux specific stuff. I really hate grub (it never seems to work for me), so I installed ubuntu on an external hard disk, and it boots and runs fine with only a few grub issues. My desktop has and AMD processor and an AMD graphics card. I want to take my laptop to school sometimes (I take my chromebook right now as its much lighter and easier to bike with) when I really need to crank out some work and would like to use ubuntu as well. I guess I am wondering what the best solution here would be: A) Is it possible to dual boot with these different graphics drivers/hardware? I built a vanilla linux kernel [an assignment for one of my classes] and it inserted its own drivers for each kernel version. Would it be possible to build another ubuntu kernel, make it in my grub file, and install only nvidia drivers, then boot that kernel when I use my laptop? (I don't even know if this is possible?) B) Just dual boot 2 ubuntu installations on the external disk? Would rather have one install if possible. Thanks, Mgamerz


Undestanding the output of route -n

Can someone explain me what the out put of `route -n`?               # route -n      Kernel IP routing table      Destination     Gateway         Genmask         Flags Metric Ref    Use Iface     0.0.0.0         192.168.0.1     0.0.0.0         UG    0      0        0 eth1     127.0.0.0       0.0.0.0         255.0.0.0       U     0      0        0 lo     169.254.0.0     0.0.0.0         255.255.0.0     U     0      0        0 eth1     192.168.0.0     0.0.0.0         255.255.255.0   U     0      0        0 eth1


How to recover data lost during aborted local drag and drop?

I have dragged and dropped a large amount of data between two tabs of Thunar (XFCE 4.10) but accidentally clicked cancel during the process. The data have been removed from the source folder and are of course incomplete on the destination folder. The source and the destination folder are on the same partition (ext4) of the same disk (so a bit different from File damaged/lost during transfer? Recovery possible?). I haven't touched anything since. The Thunar "free space" indicator still acts like the data are here. What can I try ? Why did it even move the data on the first place ?


Flash drive in OpenBSD: "specified device does not match mounted device"

I'm a relative BSD newb. I have a small server running OpenBSD 4.4. I'm trying to plug in a 16GB USB flash drive to move some files. I followed the guidance of the Disk Setup documentation, and found the label and filesystem of the desired partition. But when trying to mount the partition, I get the following:               # mount -t ext2fs /dev/sd1i /mnt/flash      mount_ext2fs: /dev/sd1i on /mnt/flash: specified device does not match mounted device      I googled a bit, but nothing I found was particularly helpful. Can anyone shed some light on this message? **Edit:** _Additional Info_               # disklabel sd1     disklabel: warning, DOS partition table with no valid OpenBSD partition     # /dev/rsd1c:     type: SCSI     disk: SCSI disk     label: SanDisk Ultra      flags:     bytes/sector: 512     sectors/track: 63     tracks/cylinder: 255     sectors/cylinder: 16065     cylinders: 1946     total sectors: 31266816     rpm: 3600     interleave: 1     trackskew: 0     cylinderskew: 0     headswitch: 0           # microseconds     track-to-track seek: 0  # microseconds     drivedata: 0           16 partitions:     #                size           offset  fstype [fsize bsize  cpg]       c:         31266816                0  unused      0     0             i:         31262427               63  ext2fs


What are the advantages of Btrfs for end users?

Btrfs has begun to gain some momentum in replacing ext4 as the default filesystem of choice for a few distributions such as Fedora Core 16. It is experimentally available in a number of other distributions (From Wikipedia: openSUSE 11.3, SLES 11 SP1, Ubuntu 10.10, Sabayon Linux, RHEL6,MeeGo, Debian 6.0, and Slackware 13.37). I'm certainly not ready to convert all my workplace servers over (my file system choice is generally conservative), I'm considering using it at home and on select non-mission critical production machines at work. Btrfs brings a feature set that is similar to ZFS in many ways. I can understand why this would be desirable in an "enterprise" environment, especially with systems that focus on storage delivery. But how is this same feature set useful for end users? What advantages does Btrfs' feature list give me on machines whose primary function is not the presentation of storage? What advantages does it give me on my laptop? Outside of enterprise storage, why should I bother switching to Btrfs from the tried and true Ext filesystem?


stopping harddisk spin-down on Asus EEE 1015PX (and other eee's as well)

I have an Asus EEE 1015PX netbook. It runs Linux (debian) without any powersavings enabled. E.g. no harddisk idle/spin-down tooling is running. Now constantly the harddisk spins down after it has been idle for half a minute or so. I can disable this with `hdparm -B 255 /dev/sda` but this only works up to the next reboot. I tried using `hdparm -K 1 /dev/sda` to make this setting permanent but this gives an input/output error. This seems to be an issue with other EEE systems as well: my mother has an EEE Shell (a pink one) running windows 7 and that one has a down-spinning drive as well. My question now is: how can I make it stop doing this? It makes the system very unresponsive and opening terminal/su to root/hdparm/exit shell every time I reboot the laptop (or had it suspend for a while by closing the lid) is annoying as hell.


error while using apt-get install for any package

I have tried to install texlive-full with `apt-get` and the installation stopped due to some errors. Later I removed all folders and files related to texlive, texmf manually. Since then I get the following error while trying to use apt-get install for any package. I have tried `apt-get clean`, `aptitude clean` etc. Can someone please help me. I think it is the `dpkg` which is giving the errors. I'm using Linux Mint and am new to using Linux. I have pasted the error message below:               Setting up tex-common (3.13) ...     find: `/etc/texmf/texmf.d': No such file or directory     update-language-dat: cannot read /etc/texmf/hyphen.d/00tex.cnf     update-language-dat: if it was removed by accident, it has to be reinstalled with     update-language-dat:   t=$(mktemp -d); cd $t; apt-get download tex-common ; dpkg -i --force-confmiss tex-common*.deb     dpkg: error processing tex-common (--configure):      subprocess installed post-installation script returned error exit status 1     dpkg: dependency problems prevent configuration of latex-sanskrit:      latex-sanskrit depends on tex-common (>= 3); however:       Package tex-common is not configured yet.          dpkg: error processing latex-sanskrit (--configure):      dependency problems - leaving unconfigured     dpkg: dependency problems prevent configuration of tex-gyre:      tex-gyre depends on tex-common (>= 3); however:       Package tex-common is not configured yet.          dpkg: error processing tex-gyre (--configure):      dependency problems - leaving unconfigured     dpkg: dependency problems prevent configuration of texlive-latex-base:      texlive-latex-base depends on tex-common (>= 3); however:       Package tex-common is not configured yet.          dpkg: error processing texlive-latex-base (--configure):      dependency problems - leaving unconfigured     dpkg: dependency problems prevent configuration of asymptote:      asymptote depends on texlive-latex-base; however:       Package texlive-latex-base is not configured yet.      asymptote depends on tex-common (>= 3); however:       Package tex-common is not configured yet.          dpkg: error processing asymptote (--configure):      dependency problems - leaving unconfigured     dpkg: dependency problems prevent configuration of context:      context depends on tex-gyre; however:       Package tex-gyre is not configured yet.      context depends on tex-common (>= 3); however:       Package tex-common is not configured yet.          dpkg: error processing context (--configure):      dependency problems - leaving unconfigured     dpkg: dependency problems prevent configuration of context-modules:      context-modules depends on context (>> 2011); however:       Package context is not configured yet.      context-modules depends on tex-common (>= 3); however:       Package tex-common is not configured yet.          dpkg: error processing context-modules (--configure):      dependency problems - leaving unconfigured     dpkg: dependency problems prevent configuration of ipe:      ipe depends on texlive-latex-base; however:       Package texlive-latex-base is not configured yet.          dpkg: error processing ipe (--configure):      dependency problems - leaving unconfigured     dpkg: dependency problems prevent configuration of texlive-latex-recommended:      texlive-latex-recommended depends on texlive-latex-base (>= 2012.20120516); however:       Package texlive-latex-base is not configured yet.      texlive-latex-recommended depends on tex-common (>= 3); however:       Package tex-common is not configured yet.          dpkg: error processing texlive-latex-recommended (--configure):      dependency problems - leaving unconfigured     dpkg: dependency problems prevent configuration of latex-xcolor:      latex-xcolor depends on texlive-latex-recommended; however:       Package texlive-latex-recommended is not configured yet.      latex-xcolor depends on tex-common (>= 3); however:       Package tex-common is not configured yet.          dpkg: error processing latex-xcolor (--configure):      dependency problems - leaving unconfigured     dpkg: dependency problems prevent configuration of pgf:      pgf depends on tex-common (>= 2.00); however:       Package tex-common is not configured yet.      pgf depends on texlive-latex-recommended; however:       Package texlive-latex-recommended is not configured yet.      pgf depends on latex-xcolor (>= 2.00-1); however:       Package latex-xcolor is not configured yet.          dpkg: error processing pgf (--configure):      dependency problems - leaving unconfigured     dpkg: dependency problems prevent configuration of latex-beamer:      latex-beamer depends on tex-common (>= 3); however:       Package tex-common is not configured yet.      latex-beamer depends on pgf (>= 1.00-1); however:       Package pgf is not configured yet.      latex-beamer depends on latex-xcolor (>= 2.00-1); however:       Package latex-xcolor is not configured yet.      latex-beamer depends on texlive-latex-base; however:       Package texlive-latex-base is not configured yet.          dpkg: error processing latex-beamer (--configure):      dependency problems - leaving unconfigured     dpkg: dependency problems prevent configuration of latex-cjk-chinese-arphic-bkai00mp:      latex-cjk-chinese-arphic-bkai00mp depends on tex-common (>= 3); however:       Package tex-common is not configured yet.          dpkg: error processing latex-cjk-chinese-arphic-bkai00mp (--configure):      dependency problems - leaving unconfigured     dpkg: dependency problems prevent configuration of latex-cjk-chinese-arphic-bsmi00lp:      latex-cjk-chinese-arphic-bsmi00lp depends on tex-common (>= 3); however:       Package tex-common is not configured yet.          dpkg: error processing latex-cjk-chinese-arphic-bsmi00lp (--configure):      dependency problems - leaving unconfigured     dpkg: dependency problems prevent configuration of latex-cjk-chinese-arphic-gbsn00lp:      latex-cjk-chinese-arphic-gbsn00lp depends on tex-common (>= 3); however:       Package tex-common is not configured yet.          dpkg: error processing latex-cjk-chinese-arphic-gbsn00lp (--configure):      dependency problems - leaving unconfigured     dpkg: dependency problems prevent configuration of latex-cjk-chinese-arphic-gkai00mp:      latex-cjk-chinese-arphic-gkai00mp depends on tex-common (>= 3); however:       Package tex-common is not configured yet.          dpkg: error processing latex-cjk-chinese-arphic-gkai00mp (--configure):      dependency problems - leaving unconfigured     dpkg: dependency problems prevent configuration of latex-cjk-japanese-wadalab:      latex-cjk-japanese-wadalab depends on tex-common (>= 3); however:       Package tex-common is not configured yet.          dpkg: error processing latex-cjk-japanese-wadalab (--configure):      dependency problems - leaving unconfigured     Setting up m-tx (0.60d-5) ...     warning: kpathsea: configuration file texmf.cnf not found in these directories: /etc/texmf/web2c:/usr/share/texlive/texmf/web2c:/usr/share/texlive/texmf-dist/web2c:/usr/local/share/texmf/web2c.     /var/lib/dpkg/info/m-tx.postinst: 17: /var/lib/dpkg/info/m-tx.postinst: $TEXMFMAIN/web2c/mktexupd: not found     dpkg: error processing m-tx (--configure):      subprocess installed post-installation script returned error exit status 127     dpkg: dependency problems prevent configuration of musixtex:      musixtex depends on tex-common (>= 3); however:       Package tex-common is not configured yet.          dpkg: error processing musixtex (--configure):      dependency problems - leaving unconfigured     dpkg: dependency problems prevent configuration of prosper:      prosper depends on texlive-latex-base; however:       Package texlive-latex-base is not configured yet.      prosper depends on texlive-latex-recommended; however:       Package texlive-latex-recommended is not configured yet.      prosper depends on tex-common (>= 1.10); however:       Package tex-common is not configured yet.          dpkg: error processing prosper (--configure):      dependency problems - leaving unconfigured     dpkg: dependency problems prevent configuration of texlive-doc-ar:      texlive-doc-ar depends on tex-common (>= 3); however:       Package tex-common is not configured yet.          dpkg: error processing texlive-doc-ar (--configure):      dependency problems - leaving unconfigured     dpkg: dependency problems prevent configuration of texlive-doc-bg:      texlive-doc-bg depends on tex-common (>= 3); however:       Package tex-common is not configured yet.          dpkg: error processing texlive-doc-bg (--configure):      dependency problems - leaving unconfigured     dpkg: dependency problems prevent configuration of texlive-doc-cs+sk:      texlive-doc-cs+sk depends on tex-common (>= 3); however:       Package tex-common is not configured yet.          dpkg: error processing texlive-doc-cs+sk (--configure):      dependency problems - leaving unconfigured     dpkg: dependency problems prevent configuration of texlive-doc-de:      texlive-doc-de depends on tex-common (>= 3); however:       Package tex-common is not configured yet.          dpkg: error processing texlive-doc-de (--configure):      dependency problems - leaving unconfigured     dpkg: dependency problems prevent configuration of texlive-doc-en:      texlive-doc-en depends on tex-common (>= 3); however:       Package tex-common is not configured yet.          dpkg: error processing texlive-doc-en (--configure):      dependency problems - leaving unconfigured     dpkg: dependency problems prevent configuration of texlive-doc-es:      texlive-doc-es depends on tex-common (>= 3); however:       Package tex-common is not configured yet.          dpkg: error processing texlive-doc-es (--configure):      dependency problems - leaving unconfigured     dpkg: dependency problems prevent configuration of texlive-doc-fi:      texlive-doc-fi depends on tex-common (>= 3); however:       Package tex-common is not configured yet.          dpkg: error processing texlive-doc-fi (--configure):      dependency problems - leaving unconfigured     dpkg: dependency problems prevent configuration of texlive-doc-fr:      texlive-doc-fr depends on tex-common (>= 3); however:       Package tex-common is not configured yet.          dpkg: error processing texlive-doc-fr (--configure):      dependency problems - leaving unconfigured     dpkg: dependency problems prevent configuration of texlive-doc-it:      texlive-doc-it depends on tex-common (>= 3); however:       Package tex-common is not configured yet.          dpkg: error processing texlive-doc-it (--configure):      dependency problems - leaving unconfigured     dpkg: dependency problems prevent configuration of texlive-doc-ja:      texlive-doc-ja depends on tex-common (>= 3); however:       Package tex-common is not configured yet.          dpkg: error processing texlive-doc-ja (--configure):      dependency problems - leaving unconfigured     dpkg: dependency problems prevent configuration of texlive-doc-ko:      texlive-doc-ko depends on tex-common (>= 3); however:       Package tex-common is not configured yet.          dpkg: error processing texlive-doc-ko (--configure):      dependency problems - leaving unconfigured     dpkg: dependency problems prevent configuration of texlive-doc-mn:      texlive-doc-mn depends on tex-common (>= 3); however:       Package tex-common is not configured yet.          dpkg: error processing texlive-doc-mn (--configure):      dependency problems - leaving unconfigured     dpkg: dependency problems prevent configuration of texlive-doc-nl:      texlive-doc-nl depends on tex-common (>= 3); however:       Package tex-common is not configured yet.          dpkg: error processing texlive-doc-nl (--configure):      dependency problems - leaving unconfigured     dpkg: dependency problems prevent configuration of texlive-doc-pl:      texlive-doc-pl depends on tex-common (>= 3); however:       Package tex-common is not configured yet.          dpkg: error processing texlive-doc-pl (--configure):      dependency problems - leaving unconfigured     dpkg: dependency problems prevent configuration of texlive-doc-pt:      texlive-doc-pt depends on tex-common (>= 3); however:       Package tex-common is not configured yet.          dpkg: error processing texlive-doc-pt (--configure):      dependency problems - leaving unconfigured     dpkg: dependency problems prevent configuration of texlive-doc-rs:      texlive-doc-rs depends on tex-common (>= 3); however:       Package tex-common is not configured yet.          dpkg: error processing texlive-doc-rs (--configure):      dependency problems - leaving unconfigured     dpkg: dependency problems prevent configuration of texlive-doc-ru:      texlive-doc-ru depends on tex-common (>= 3); however:       Package tex-common is not configured yet.          dpkg: error processing texlive-doc-ru (--configure):      dependency problems - leaving unconfigured     dpkg: dependency problems prevent configuration of texlive-doc-si:      texlive-doc-si depends on tex-common (>= 3); however:       Package tex-common is not configured yet.          dpkg: error processing texlive-doc-si (--configure):      dependency problems - leaving unconfigured     dpkg: dependency problems prevent configuration of texlive-doc-th:      texlive-doc-th depends on tex-common (>= 3); however:       Package tex-common is not configured yet.          dpkg: error processing texlive-doc-th (--configure):      dependency problems - leaving unconfigured     dpkg: dependency problems prevent configuration of texlive-doc-tr:      texlive-doc-tr depends on tex-common (>= 3); however:       Package tex-common is not configured yet.          dpkg: error processing texlive-doc-tr (--configure):      dependency problems - leaving unconfigured     dpkg: dependency problems prevent configuration of texlive-doc-uk:      texlive-doc-uk depends on tex-common (>= 3); however:       Package tex-common is not configured yet.          dpkg: error processing texlive-doc-uk (--configure):      dependency problems - leaving unconfigured     dpkg: dependency problems prevent configuration of texlive-doc-vi:      texlive-doc-vi depends on tex-common (>= 3); however:       Package tex-common is not configured yet.          dpkg: error processing texlive-doc-vi (--configure):      dependency problems - leaving unconfigured     dpkg: dependency problems prevent configuration of texlive-doc-zh:      texlive-doc-zh depends on tex-common (>= 3); however:       Package tex-common is not configured yet.          dpkg: error processing texlive-doc-zh (--configure):      dependency problems - leaving unconfigured     dpkg: dependency problems prevent configuration of texlive-fonts-extra:      texlive-fonts-extra depends on tex-common (>= 3); however:       Package tex-common is not configured yet.          dpkg: error processing texlive-fonts-extra (--configure):      dependency problems - leaving unconfigured     dpkg: dependency problems prevent configuration of texlive-fonts-extra-doc:      texlive-fonts-extra-doc depends on tex-common (>= 3); however:       Package tex-common is not configured yet.          dpkg: error processing texlive-fonts-extra-doc (--configure):      dependency problems - leaving unconfigured     dpkg: dependency problems prevent configuration of texlive-fonts-recommended:      texlive-fonts-recommended depends on tex-common (>= 3); however:       Package tex-common is not configured yet.          dpkg: error processing texlive-fonts-recommended (--configure):      dependency problems - leaving unconfigured     dpkg: dependency problems prevent configuration of texlive-fonts-recommended-doc:      texlive-fonts-recommended-doc depends on tex-common (>= 3); however:       Package tex-common is not configured yet.          dpkg: error processing texlive-fonts-recommended-doc (--configure):      dependency problems - leaving unconfigured     dpkg: dependency problems prevent configuration of texlive-generic-extra:      texlive-generic-extra depends on tex-common (>= 3); however:       Package tex-common is not configured yet.          dpkg: error processing texlive-generic-extra (--configure):      dependency problems - leaving unconfigured     dpkg: dependency problems prevent configuration of texlive-humanities-doc:      texlive-humanities-doc depends on tex-common (>= 3); however:       Package tex-common is not configured yet.          dpkg: error processing texlive-humanities-doc (--configure):      dependency problems - leaving unconfigured     dpkg: dependency problems prevent configuration of texlive-lang-african:      texlive-lang-african depends on tex-common (>= 3); however:       Package tex-common is not configured yet.          dpkg: error processing texlive-lang-african (--configure):      dependency problems - leaving unconfigured     dpkg: dependency problems prevent configuration of texlive-lang-arabic:      texlive-lang-arabic depends on tex-common (>= 3); however:       Package tex-common is not configured yet.          dpkg: error processing texlive-lang-arabic (--configure):      dependency problems - leaving unconfigured     dpkg: too many errors, stopping     Errors were encountered while processing:      tex-common      latex-sanskrit      tex-gyre      texlive-latex-base      asymptote      context      context-modules      ipe      texlive-latex-recommended      latex-xcolor      pgf      latex-beamer      latex-cjk-chinese-arphic-bkai00mp      latex-cjk-chinese-arphic-bsmi00lp      latex-cjk-chinese-arphic-gbsn00lp      latex-cjk-chinese-arphic-gkai00mp      latex-cjk-japanese-wadalab      m-tx      musixtex      prosper      texlive-doc-ar      texlive-doc-bg      texlive-doc-cs+sk      texlive-doc-de      texlive-doc-en      texlive-doc-es      texlive-doc-fi      texlive-doc-fr      texlive-doc-it      texlive-doc-ja      texlive-doc-ko      texlive-doc-mn      texlive-doc-nl      texlive-doc-pl      texlive-doc-pt      texlive-doc-rs      texlive-doc-ru      texlive-doc-si      texlive-doc-th      texlive-doc-tr      texlive-doc-uk      texlive-doc-vi      texlive-doc-zh      texlive-fonts-extra      texlive-fonts-extra-doc      texlive-fonts-recommended      texlive-fonts-recommended-doc      texlive-generic-extra      texlive-humanities-doc      texlive-lang-african      texlive-lang-arabic     Processing was halted because there were too many errors.     E: Sub-process /usr/bin/dpkg returned an error code (1)


How to properly set up 2 network interfaces in CentOS (running in VirtualBox)?

I have a VirtualBox machine running CentOS 6.5. I've created 2 network adapters for it in VirtualBox's networking settings for the machine. The first is NAT which I want the guest to use to connect to the Internet and the second I set to Host-only which I will use to SSH and access web server from the host computer. This tutorial over at the VirtualBox forums is what I want to achieve but I can't seem to find the `/etc/network/interfaces` file on CentOS 6.5 so I presume configuration is done differently. Having setup both NAT and Host-only adapters, I started the VM and did an `ip addr show` and I have 2 interfaces, `eth0` and `eth2` (I don't know why `eth1` was somehow skipped). So I configure both `ifcfg-ethX` files in `/etc/sysconfig/network-scripts`, setting `eth0` to be DHCP (for NAT) and `eth2` to be static IP (for Host-only). For `eth0`, `ONBOOT=yes` while for `eth2`, `ONBOOT=no`. With this setup I can `ping` the Internet i.e. `ping -c 3 www.google.com` and it gets a response so I know I can connect to the Internet (while `eth2` is down). Next, I `ifup eth2`. From the host machine, I SSH using the static IP I've set and I can connect without issue. But when I do `ping -c www.google.com` this time around, it fails and I know I've lost my connection to the Internet even if `eth0` is still up. Doing a `route -n` shows me a tabular output with `eth2` taking up the first and last rows while `eth0` is in between (sorry I can't post the actual output because I deleted the VM out of frustration...). I've created a new CentOS VM and would like to proceed with the same set-up. My networking-fu is close to non-existent so I'm a n00b at it. I would like some tips on how to do it properly (i.e. how to set the NAT adapter to use `eth0` and set the Host-only adapter to use `eth1` and not `eth2`, how to make `eth0` still usable even if `eth1`/`eth2` is up and running). **Update** So I've got the new VM up and running and it seems to work now if I have the first adapter set to host-only and the second adapter set to NAT. It's set up like so: _VirtualBox network settings_   * Network adapter 1: Host-only (`vboxnet0` IP address is set to `10.3.0.1`, network mask `255.255.255.0` and DHCP is off)   * Network adapter 2: NAT (DHCP) _CentOS VM`/etc/sysconfig/network-scripts/ifcfg-ethX` settings_               # ifcfg-eth0     DEVICE=eth0     HWADDR=08:00:27:EC:6C:B9     TYPE=Ethernet     UUID=1339bc30-...     ONBOOT=yes     NM_CONTROLLED=yes     BOOTPROTO=static     DHCPCLASS=     IPADDR=10.3.0.100     NETMASK=255.255.255.0     GATEWAY=10.3.0.1          # ifcfg-eth2     DEVICE=eth2     HWADDR=08:00:27:EB:73:BA     TYPE=Ethernet     UUID=1339bc30-...     ONBOOT=yes     NM_CONTROLLED=yes     BOOTPROTO=dhcp      _Result of`ip route`_               10.0.3.0/24  dev  eth2  proto  kernel  scope  link  src  10.0.3.15     10.3.0.0/24  dev  eth0  proto  kernel  scope  link  src  10.3.0.100     169.254.0.0/16  dev  eth0  scope  link  metric  1002     169.254.0.0/16  dev  eth2  scope  link  metric  1003     default via 10.0.3.2 dev eth2      _Result of`ip addr`_               1:  lo: <LOOPBACK,UP,LOWER_UP> mtu 16436 qdisc noqueue state UNKNOWN          link/loopback 00:00:00:00:00:00 brd 00:00:00:00:00:00:00          inet 127.0.0.1/8 scope host lo          inet6 ::1/128 scope host             valid_lft forever preferred_lft forever     2:  eth0: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc pfifo_fast state UP qlen 1000          link/ether 08:00:27:ec:6c:b9 brd ff:ff:ff:ff:ff:ff          inet 10.3.0.100/24 brd 10.3.0.255 scope global eth0          inet6 fe80::a00:27ff:feec:6cb9/64 scope link             valid_lft forever preferred_lft forever     3:  eth2: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc pfifo_fast state UP qlen 1000          link/ether 08:00:27:eb:73:ba brd ff:ff:ff:ff:ff:ff          inet 10.0.0.15/24 brd 10.0.3.255 scope global eth2          inet6 fe80::a00:27ff:feeb:73ba/64 scope link             valid_lft forever preferred_lft forever


Getting "Bad file descriptor" error during tar

I'm trying to tar a dir with this command "tar -cpSWf myfile.tar workdir; gzip myfile.tar", but I get this error for some of the files in workdir dir.                tar: my/sub/dir/file1.oa: Cannot seek to 1536: Bad file descriptor      I run the same command on other dir and there's no such error. Is it because the .oa files are corrupted, or the disk is failing? Is this a common issue when using tar? Is there any way to repair this error?


Attaching two network cards two different drivers

I have an Ubuntu 12.04 server that has two 10 Gb ethernet cards that are using the `ixgbe` driver. I'm installing the PF_RING DNA drivers for these cards (what that is isn't important). I want interface `eth0` to use the original Linux `ixgbe` driver and I want interface `eth1` to use the new PF_RING `ixgbe` driver. The first issue is that both drivers have the same name. I need to load both of them with `insmod ixgbe.ko`, but I can't since they have the same name. Can I load one of them under a different name, like `ixgbe-dna`? I can recompile the kernel modules if that's the only option. Once I have two drivers `ixgbe` and `ixgbe-dna` loaded, how can I specify that `eth0` will use `ixgbe` and `eth1` will use `ixgbe-dna`?


Variable scope in while-read-loop on Solaris

Could someone please explain to me why my while loop seems to have an internal scope? I've seen multiple explanations online but they all have to do with pipes. My code has none. The code:                 #!/bin/sh     while read line     do     echo "File contents: $line"     echo;     if [ 1=1 ]; then       test1=bob;     fi     echo "While scope:"     echo "  test1: $test1"     done < test.txt     if [ 1=1 ]; then       test2=test2;     fi     echo;     echo "Script scope: ";     echo "  test1: $test1";     echo "  test2: $test2";      The output:                 File contents: In the file          While scope:       test1: bob          Script scope:       test1:        test2: test2


RAID 1 in linux

I'd like to setup RAID 1 with two drives in linux. I don't have a hardware RAID controller and don't want to buy one, so what is the best software RAID option for linux? Note: If it makes a difference, I'm running Gentoo.


How do I set the mysql server character set in FreeBSD 8.2?

My mysql server's current server character set is `latin1`. My server is started on startup via rc.conf setting `mysql_enable="YES"`. How to set my server to use `utf8` as the server character set?


In what sense does SATA "talk" SCSI? How much is shared between SCSI and ATA?

This is nothing new to me at least, that SATA actually "talks" SCSI, hence why these SATA devices show up as SCSI devices in Linux. A related question has been asked before, e.g. Why do my SATA devices show up under /proc/scsi/scsi? However what fails to be mentioned where I've seen this discussed before is exactly in what sense SATA relates to SCSI, and how they differ. I assume it is taken for granted that they differ on the physical layer, as they do not share compatible cables. However what about higher up on the stack? I am aware of how Linux represents SATA and even IDE disks on modern kernels as just SCSI to the SCSI subsystem. But what about the actual protocol that is used on the bus? I also know that ATAPI is an encapsulation for SCSI, but what about regular ATA? I've noticed that features from SCSI such as NCQ, FUA, DPO, etc (if I don't remember incorrectly) have been adopted from SCSI. But it is unclear how "much" of the SCSI command set is actually shared or similar. Do modern SATA devices with their ATA specification implement a subset of the SCSI command set, but encapsulated (as in ATAPI)? An identical set? A superset? Or perhaps only selected features are implemented as variants that are not directly identical? Where can I find some clear information on this, and especially how it relates to the Linux kernel? Some kind of tutorial for driver development would be nice, but even just an overview that doesn't completely skip over all the details would suffice. I am aware I can just read the actual specification, but that is again much too detailed, hard to find what you're really looking for, and just not realistic for me and probably most other users in the temporal sense.


Frozen Linux Recovery Without SysReq

RHEL system has run out of memory and is now frozen. The SysReq commands are not working, so I am not even sure that /proc/sys/kernel/sysrq is set to 1. Is there any other "safe" way I can reboot w/out power cycling?


How to map Caps Lock as the compose key using Xmodmap portably and idempotently?

I can't seem to find a way to use `Caps Lock` as the compose key properly. Some methods are not portable since they require that you detect the key number using something like `xev` on every host. Other methods result in a `~/.Xmodmap` which cannot be passed to `xmodmap` more than once without `bad keysym` and similar errors. This makes it difficult to test changes to the file. Is there some way to do this in `~/.Xmodmap`?


Should "invoke-rc.d" or "service" be used to restart services?

I'm confused as to which is best and in which circumstances:               invoke-rc.d apache2 restart      or               service apache2 restart      Is there a real difference? `man service` has the following interesting bit: > service runs a System V init script in as predictable environment as > possible, removing most environment variables and with current working > directory set to /. I'm interested mainly in Debian, but also Mint (also based on Debian).


xdg-open default applications behavior

When I have no `defaults.list` and `mimeapps.list`, `xdg-open` opens `text/plain` with `gvim`. But when I create `defaults.list` in `/usr/share/applications/` and add the following lines :               [Default Applications]     text/plain=emacs.desktop      it opens text files with firefox. However, if I move `/usr/share/applications/defaults.list` to `~/.local/share/applications/mimeapps.list`, it opens text files with `emacs` as expected. My questions:   1. How does `xdg-open` determine which application to launch when there is no `defaults.list` and `mimeapps.list`?   2. Why is `xdg-open` using firefox when I simply write `/usr/share/applications/defaults.list`? I am using Arch linux.


How to config the Mate src in Freebsd

a favor is asked on the so-called "babystep" of the Mate configuration in Freebsd. I understand that here is the place for Mate install for Freebsd. But I should admit that I am a newer and I can't make sense of the "baby step" of editing the " SRCDIR=" in the `matemerge.sh`. Could anyone help me by letting me know what to input of the SRCDIR section? Is there a list to choose from?


Unable to winscp png files

I have a few PNG files that need to be `scp`'d to a Linux box. I'm using `winscp` and when I copy for some reason the number of bytes transferred is zero and in turn the file is empty.. What option needs to be changed in `winscp` to copy these PNG files?


Rsync without login over port 873

We backup our production servers to an office server, to have an extra offline backup, just in case. This backup is done using rsync over port 873, and doesn't require a login like when using rsync over ssh. I've tried to do this from a private server to see if that would work, but it doesn't. I haven't set this up, the admin is gone, and I would like to know how this works. How secure is this?


External Cache not socketed

When I check my CPU Cache with command `dmidecode`, I get Cache configuration to be `Not Socketed`. What does that mean?               prayag@prayag:~/hacker_/draobkcalb$ sudo dmidecode -t cache     # dmidecode 2.11     SMBIOS 2.5 present.          Handle 0x000A, DMI type 7, 19 bytes     Cache Information         Socket Designation: Internal Cache         Configuration: Enabled, Not Socketed, Level 1         Operational Mode: Write Back         Location: Internal         Installed Size: 32 kB         Maximum Size: 32 kB         Supported SRAM Types:             Synchronous         Installed SRAM Type: Synchronous         Speed: Unknown         Error Correction Type: Unknown         System Type: Unknown         Associativity: Unknown          Handle 0x000B, DMI type 7, 19 bytes     Cache Information         Socket Designation: External Cache         Configuration: Enabled, Not Socketed, Level 2         Operational Mode: Write Back         Location: External         Installed Size: 2048 kB         Maximum Size: 2048 kB         Supported SRAM Types:             Synchronous         Installed SRAM Type: Synchronous         Speed: Unknown         Error Correction Type: Unknown         System Type: Unknown         Associativity: Unknown


How to maximize a window programmably in X Window?

I'm wondering if there is any commands or programs to make some window maximized in X Window? For example, what I imagine is something like this               xmaximize -window *window_id*


X Driver for underlying hardware

I am following LFS and BLFS. I want to run the resultant filesystem onto many different hardware, with "native" graphics driver. If the underlying hardware's graphic card is intel then it must start X with `intel` driver. My question is, how do I find out which Xorg driver is appropriate for underlying graphic card. e.g. If Intel supports following chipset.               i810     i810-dc100     i810e     i815     i830M     845G     854     852GM/855GM     865G     915G      and if underlying graphic card is one of them, then I can use Intel to start X. But I have no idea, how do I list out this chipset name before calling X


How to calculate Linux Network RX, TX total stats - not just between reboots?

Is there any way to calculate the Linux network interfaces RX , TX for all times? The suggested method mentioned in this Cyberciti article titled: Linux See Ethernet Statistics only returns the stats of the machine currently, from the the time the system booted until now. Data from previous reboots about network usage does not show up when looking at the `ifconfig` device, as discussed in the article. I need to know the life time network usage for the entire life of the machine, since Linux was installed.   * Where does the network usage log get stored?    * Does it get stored anywhere?


How to set variables from find+exec?

I am trying to write a bash script where I am trying to find if some location has empty files or not and send an email if found. I first thought about combining "find" and "mail" together, but if the location has multiple empty files, it would send multiple mails, which I do not want, so I thought of setting a flag variable to zero before find and setting it to 1 inside find if an empty file is found. This is what I tried:               FLAG=0     find $LOCATION -size 0 -type f -exec sh -c 'export FLAG=1' \;     echo $FLAG      but the problem is , even if the location has empty files, the flag value is not changing to 1. What am I doing wrong ?


Copying the full path of a file to text file

I want to get the full path of all files in a directory and and the entire path has to be saved in one text file. Can you give me the script for that?


Need general guide on how to build Linux Stream (LiS) under RedHat 6.2

# Day 1 I have hit into some error, and the build simply fail, saying that there is some conflict. Thus I believe a .o file cannot be made and then result fatal error during linking, anyone have steps by steps trouble shooting tips ? I have been successful do it on a clean install of red hat 6, so i suspect someone have update the kernel but didn't update the kernel library. Need some hints on where should i check I have type `rpm -qa` and shows there is 2 kernel, tried to boot to old kernel and compile the LiS but didn't help. I have break down my question as below:   1. How to check if the kernel libraries are matching with the kernel version ?   idea: the dlevel, kernel, gcc, glib, glibc ...   2. It there a general steps in trouble shoot build issues, like a check list? So you can tick it one by one. The LiS installation did provide several libraries minimum level requirement, I am sure that i meet with them all, right now i suspect that i am over patch.    3. Can i just go down the file version ? so i just have every library just meet the requirement? and 100% compatible.  # Progress on Day 2 with some tips from @schaiba, i have researched how to do logging in the compile process. while after break into the build package, trace into build strconf in a second folder, added --verbose to the cc compiling, got the following message:   ignore conflicting library `/usr/lib64/libc.so` , it is a small file, so i try to open it wwith vi, thus discover it is a text file instead, for which a statement like `OUTPUT FORMAT (elf32-i386)`, which is obviously incorrect to me, since lib64 should be x86_64 instead.   Then, I have determine to check the where do the libc.so comes from, by:               rpm -qf libc.so        from which is discover it is in glibc-devel-...., i have get a red hat 6.4 repository, doing               yum update glibc-devel      then, the naughty libc.so became `OUTPUT FORMAT(elf64-x86-64)` and that strconf module compile. and i got the build complete. but then, i got any other problems now. I still got the ignore conflict libc.so warning, and the LiS I build is actually used by another application, and that one seems to have some problems. any suggestions ? For another study around internet, that the LiS package is something native to 32-bit, thus i guess it may have part of the code require to be compile under 32-bit, Therefore arise 2 new question,   1. How can you modified a build file so that it can use two version of same libraries ?   2. Is there a way to let 2 version of devel co-exist on a linux system ? and more precise, 2 version of /usr/lib64/libc.so


Commands to access a SATA drive

I've damaged the drive I had in my Windows laptop and now I want to try to recover as many files as possible. I know very little about Linux though. I have Ubuntu 10.04 on another machine. I have a docking station for the drive and it is connected to my Linux machine. The drive appears in disk utility. Unfortunately, this is where I have no idea where to proceed. Any help is appreciated and I can provide more info if needed.


How do I suppress dd output?

I have a bash script that creates some file using `dd`. The problem is dd throws a great amount of output that is going to mess with the output of my script. Searching around I've found a solution:               dd if=boot1h of="/dev/r$temp1" >& /dev/null      Is there an alternative, or is redirecting to `/dev/null` the only way?


Run Python script on startup

Running on Ubuntu Karmic. I need to execute the following (updated) script at boot time               #!/bin/sh     # /etc/init.d/scripts     # Description: Starts Python scripts     # ————————————————–     #     ### BEGIN INIT INFO     # Provides: Scripts     # Required-Start: $network $local_fs $syslog     # Required-Stop: $local_fs $syslog     # Default-Start: 2 3 4 5     # Default-Stop: 0 1 6     # Description: Start Python scripts to provide mapping services     ### END INIT INFO          case $1 in       start)         # echo -n ¨Starting Mapping service: ¨     /usr/local/bin/liteserv.py /home/myUN/bin/mapnik/my_osm.xml --caching --debug=False     ;;       stop)     # echo -n ¨Stoping Mapping service: ¨     /usr/local/bin/liteserv.py /home/myUN/bin/mapnik/my_osm.xml --caching --debug=False     ;;       restart)     # echo -n ¨Retarting Mapping service: ¨     /usr/local/bin/liteserv.py /home/myUN/bin/mapnik/my_osm.xml --caching --debug=False     ;;       *)     # echo ¨Usage: scripts {start|stop|restart}¨     exit 1     esac      Have placed it into /etc/init.d Registered it with               sudo update-rc.d scripts defaults      But nothing happens on boot. I have tried looking in the logs but I cant find anything. Both scripts and liteserv.py are marked as executable. As per Andy Smith's response, When I run:               /etc/init.d/scripts start        I now get the program running correctly (after correcting the bad quotes).   However, it still does not run the program on bootup.


How to make gksudo or gksu sessions last longer in Linux

Every time I want to open a GUI program that needs root permissions, I have to put my password. For example, I open synaptic and put my password then close it and a second later decide to reopen it it asks for the password again. Ubuntu 9.04 wasn't like that, it had a timeout of around 1 minute between sessions. I would like that again on the newer version of Linux. I know how to make `sudo` sessions last longer in Linux. All I have to do is type:               sudo visudo      then change:               Defaults        env_reset      to (3 minutes):               Defaults        env_reset,timestamp_timeout=3      Is there a similar way to change the `gksu` session's timemouts?


How to get list of computers similar to what is shown under "Network" in Windows

In Windows 7 when I click on _Network_ I get a list of computers with the same workgroup of mine. But in Fedora when I click on _Network_ I just get a single item _Windows Network_ and I can't see the computers that are shown in Windows. How can I see them in Linux?


Music player with random song command

I recently migrated from Windows, where I've been using Foobar2000 for a long time. I've been looking for a music player that replaces a feature I considered basic. What I need is a player that has a play random song command (which can be sent from the command line). Note, that this is different from shuffle, which most players have. In shuffle, the order of the songs is mixed, and the playback is random. What I am looking for is something where playback is ordered, but when a certain command is issued a song is randomly picked and the playback jumps to it; playback then continues on in the normal sorted order. The closest I found was gmusicbrowser, which has a random album command. This is close, but I'd prefer an actual random song. I don't care about things like looking up lyrics or fancy library interfaces, just a simple playlist that can handle 30k+ songs. I'd prefer something with a gui, but I could do command line only if need be. Edit: To clarify what I consider a normal ordered playback. It should play back in order of band, then year, then album, then track (or something similar, this should probably be configurable somewhere anyway). The only time it should deviate from this, and jump to a random song, is when it receives the random song command.


What platform to use for programmatically editing text files?

I just volunteered at work for a project that involves creating a program to edit log files on a server. By edit I mean extract useful information to another location and remove lines of text that is searched for to have certain text identifiers. My problem is that I am a linux beginner and I don't know the most efficient way to do this. Is it best to use a scripting language like python? or should I create shell files? I plan to have cron run the job every night.


Any implementations of unix with "flat", tag-based file systems?

As I understand, files in Unix are all stored in a "flat" structure in the hard drive -- the file system is merely links from directories to other directories and eventually to leaves/nodes/files. Many hard links may point to the same file (but not the same directory/branch) Has there been any approaches to this where there are essentially no folders at all -- all of the files are in one giant folder, and instead of folders you have tags? Your home directory might then not be files in folders but instead merely lists of tags/folders, where a file may be found in more than one? And also some sort of software faculty to do more complicated tag queries, like filtering.


IPTABLES is slow after adding '-A INPUT -j DROP' to rule list

I am just getting started with iptables and stumbled across something I don't really understand. FYI, I followed the instructions of Ubuntu wiki's IptablesHowTo. The nat and mangle tables are empty, I'm only working with the filter table right now. ### The problem If I add the following iptables rules:               iptables -A INPUT -p tcp --dport ssh -j ACCEPT     iptables -A INPUT -j DROP      ... then I still have access to my machine via ssh, however all iptables commands take about a minute or two to run. It's not a DNS problem, `-n` doesn't change it. ### The solution If I flush the table and add these three rules instead, everything is working fine:               sudo iptables -A INPUT -m conntrack --ctstate ESTABLISHED,RELATED -j ACCEPT     iptables -A INPUT -p tcp --dport ssh -j ACCEPT     iptables -A INPUT -j DROP      Can someone explain to me, why the first rule has such a great impact on iptables? I understand that it allows established sessions to receive traffic, but why do I need it if ssh is open?


Attaching a screen to a name

Okay for me to load a screen I have to do screen -r server Is there a way I can set it up so that can just be shown by the command: screen -x name


Strip spaces after single capital letters with sed

I am writing a bash script to automatically generate some other files, and I have to format some strings a certain way. Specifically, the last problem I'm having is formatting a string that has individual capital letters and a word that starts with a capital letter. For example: `O S D Settings` needs to become `OSD Settings` I have a sed command that strips the first space, but it also deletes the "D" (i.e. `O S D Settings` -> `OS Settings`). This command is:               O S D Settings | sed 's/ \([A-Z]\)* \(A-Za-z]*\)/\1/g'      Does anyone know how to delete the spaces in between individual capital letters without losing any letters?


Make bluetooth device invisible / disable incoming pairing

I am using the bluez package for my bluetooth usb dongle on ubuntu server. I want to be able to initiate bluetooth connection from the dongle to a device, however a device itself shall not be able to find by bluetooth dongle or initiate a connection / pairing. In the /etc/bluetooth files I could only find options to set the time my bluetooth dongle will be visible to 1 second, but I want to disable the visibility at all, like it can be done in any mobile phone! Any hint on this? Thanks :-)


Apache2 virtual hosts with mod_wsgi settings question

I'm running a VPS on DigitalOcean (Ubuntu 12.04). I'm using a single instance to run multiple (currently 2) websites. Originally I had one website (say, flaskwebsite.com) which uses `flask` and `mod_wsgi`. The config looked originally like this:               <VirtualHost *:80>                     ServerName flaskwebsite.com                     ServerAlias www.flaskwebsite.com                     ServerAdmin my-email-address                          WSGIScriptAlias / /var/www/flaskwebsite/flaskwebsite.wsgi                     <Directory /var/www/flaskwebsite/flaskwebsite/>                             Order allow,deny                             Allow from all                     </Directory>                     Alias /static /var/www/flaskwebsite/flaskwebsite/static                     <Directory /var/www/flaskwebsite/flaskwebsite/static/>                             Order allow,deny                             Allow from all                     </Directory>                     ErrorLog ${APACHE_LOG_DIR}/error.log                     LogLevel warn                     CustomLog ${APACHE_LOG_DIR}/access.log combined     </VirtualHost>      And everything was fine. I then added a second website (mystaticpage.com), which is currently just a static placeholder page. I run it using AWS Route53, and the config looks like this:               <VirtualHost *:80>                     ServerName mystaticpage.com                     ServerAlias www.mystaticpage.com                     ServerAdmin my-email-address                     DocumentRoot /var/www/mystaticpage                          ErrorLog ${APACHE_LOG_DIR}/error_sp.log                     LogLevel warn                     CustomLog ${APACHE_LOG_DIR}/access_sp.log combined     </VirtualHost>      After I got it up and running, I noticed that when I access the original flask website, it goes to the static page I created. When I disabled the static website, the flask website would work fine. Couldn't find anything on the internet concerning this. In the end, I tried adding a `DocumentRoot` setting to the flask website config file, and everything started working correctly. My question is – I thought that a `DocumentRoot` setting is not necessary for `mod_wsgi` websites? Or have I something wrong in my configs?


How to disable certain system calls for a given user?

I am creating a web app similar to codepad and for each run-action my app copies a directory (`/home/radeks/voidptr/private/chroot-root`) to `/tmp/voidptr/[random-id]/chroot-root`. This chroot directory has a user that compiles and runs the code entered by the web app user. The problem is that I don't want the user to shut down the machine or use sockets for example. Do I need to write a supervisor or can I simply set these permissions per user?


Install the roboform lite extension in Debian Wheezy Iceweezel

How do I install the roboform lite extension in Debian Wheezy Iceweezel browser? All I have is an XPI file.


Possible to limit number of cups printers?

The way I have configured CUPS on my workstation is by               echo 'CUPS_SERVER=cups.example.com' >> ~/.profile     echo 'export CUPS_SERVER' >> ~/.profile      When I open the print menu in any program I see ~50 CUPS printers, where I am only interested in 2-3 of them. **Question** Is it possible to only show those 2-3 printers I am interested in?


Some people told me FreeBSD is NOT Unix, is that right? Confused

Some people told me FreeBSD is NOT Unix, is that right? I'm confused. I checked some articles, but the expressions are pretty vague, and I need some clarification.


How to pass lines from a file to a bash script, so that each line remains undivided, even if there are spaces?

Given:               $ cat lines.txt     a/b     'c/d e/f'          $ cat 1.sh     #!/bin/sh     ./2.sh `cat lines.txt`          $ cat 2.sh     #!/bin/sh     echo p1=$1     echo p2=$2     echo p3=$3          $ ./1.sh     p1=a/b     p2='c/d     p3=e/f'      How do I change `lines.txt` or `1.sh`, so that `2.sh` receives only two arguments:   * **`a/b`**   * **`c/d e/f`** ?


Trying to print up down arrow keys

I have this: I read down arrow key               abc@abc-ubuntu:~/bashpratice$ read -n 3 key     ^[[Babc@abc-ubuntu:~/bashpratice$       I am able to grep for it               abc@abc-ubuntu:~/bashpratice$ echo $key | grep '\['     [B     abc@abc-ubuntu:~/bashpratice$ echo $key | grep '\[B'     [B      But echoing the key just prints spaces               abc@abc-ubuntu:~/bashpratice$ echo $key          abc@abc-ubuntu:~/bashpratice$       Why does echoing the key just give spaces?


Yum can find a package, but can not install it

How is it possible?               [root@server1 ~]# yum search diy     Loaded plugins: product-id, rhnplugin, security, subscription-manager     This system is not registered to Red Hat Subscription Management. You can use subscription-manager to register.     This system is receiving updates from RHN Classic or RHN Satellite.     ======================================= N/S Matched: diy =======================================     openshift-origin-cartridge-diy-0.1.noarch : Provides diy support            Name and summary matches only, use "search all" for everything.     [root@server1 ~]# yum install openshift-origin-cartridge-diy     Loaded plugins: product-id, rhnplugin, security, subscription-manager     This system is not registered to Red Hat Subscription Management. You can use subscription-manager to register.     This system is receiving updates from RHN Classic or RHN Satellite.     Setting up Install Process     No package openshift-origin-cartridge-diy available.     Error: Nothing to do     [root@server1 ~]#


Is it possible to search text within text-files using Catfish?

I want to find a line in system files - that is I need to scan a lot of files for that. I learned that I can use                grep -r <word> *      replacing with the needed expression. Can Catfish do that kind of search? (I am in Linux Mint 15 Xfce)


Mate desktop breaks with no panels and tens of caja windows on user switching?

I'm using Sabayon GNU/Linux with Mate-Desktop. I have my computer set up for multiple users so my girlfriend and the kids can use it too.                ~ $ uname -a     Linux 3.9.0-sabayon #1 SMP Thu Jun 27 07:53:45 UTC 2013 x86_64 Intel(R) Core(TM) i7-3930K CPU @ 3.20GHz GenuineIntel GNU/Linux      ~ $ equo search mate-desktop     >>      @@ Package: mate-base/mate-desktop-1.6.0 branch: 5, [sabayonlinux.org]      >>         Available:     version: 1.6.0 ~ tag: NoTag ~ revision: 0     >>         Installed:     version: 1.6.0 ~ tag: NoTag ~ revision: 0      Each time i switch user, logging out and logging in as another user I end up in a completly messed up desktop environment.   * The `mate-panel`s are missing.   * Errors pop up that no system tray is available.   * Tens of `caja` instances pop up. The only way to fix this is to switch to TTY and reboot the machine. After reboot everything works as desired. But switching users does not work at all. In addition, both `mate-panel` and `mate-settings-d` use around 100% CPU.                 PID USER      PR  NI    VIRT    RES    SHR S  %CPU %MEM     TIME+ COMMAND      8691 afri      20   0 6735900 5.384g  21176 R 100.3 17.2  70:03.75 mate-settings-d      8716 afri      20   0 1789004 1.070g  21744 R  96.4  3.4  64:12.03 mate-panel      Someone on IRC of #mate told me this could be a `dconf` error. The `.xsession- error` log says `dconf` has some issues with permissions:               (mate-panel:8716): dconf-CRITICAL **: unable to create directory '/run/user/1001/dconf': Permission denied.  dconf will not work properly.      Checking out the directory `/run/user/1001/dconf` tells it's owned by another user. It's a mess. How to avoid this permission conflict for the dconf directory? * * * ### Update Finally, this thread suggests to play around with `$XDG_RUNTIME_DIR`:                $ echo $XDG_RUNTIME_DIR     /run/user/1001      Now, the issue is obvious: all users are using the same directory for `dconf` which results in the described permission issues. So I tried to adjust the `$XDG_RUNTIME_DIR`. I added the following line to my `~/.bash_profile` settings:               export XDG_RUNTIME_DIR=/run/user/$(id -u username)      Now, `dconf` should be able to access the custom directory. But this still does not work. I'm still getting the same error as above:               (mate-panel:8716): dconf-CRITICAL **: unable to create directory '/run/user/1001/dconf': Permission denied.  dconf will not work properly.      But I double-checked the settings of the directory:   1. it's existing.   2. permissions are set correctly.   3. environment variables are set correctly. What else can I try to fix this? I'm really lost.


Not allowed to read a file with correct group permissions? ACL?

I just set up a basic nginx server on my Debian 7.0 server. The config file `/etc/nginx/nginx.conf` is barely modified, and begings with:               user www-data; # nginx shall run as user `www-data`      I then set up a server configuration (file `/etc/nginx/sites- available/filenamehere`), which includes the following directives:               root /home/diti/www     access_log /home/diti/logs/access.log;      I executed `setfacl` so that nginx can read all data in /home/ directories, and created the file `/home/diti/logs/access.log` as a regular user (username is `diti`). * * *               $ whoami     diti          $ groups diti     diti : diti          $ ls -lh /home/diti/logs/access.log     total 12K     -rw-r-x---+ 1 www-data diti 8.9K Mar 13 16:47 access.log          $ tail /home/diti/logs/access.log     tail: cannot open `access.log' for reading: Permission denied          $ getfacl /home/diti/logs/access.log     getfacl: Removing leading '/' from absolute path names     # file: home/diti/logs/access.log     # owner: www-data     # group: diti     user::rw-     user:www-data:r-x     group::---     mask::r-x     other::---      **How comes I am not able to read the log file** , owned by `www-data:diti`? I should be able to, since I (`diti`) belong to group `diti`, and group permissions for the log file are set to `r-x`. Is it because of ACL? My filesystem is ext4.


bash script error: source: not found

I must be missing a fundamental understanding about sourcing files in bash. I've tried the different approaches that seem like they should work, but I still get this error `source: not found`. In my script I tried to cd to the directory where the file that I want to source is located before sourcing it. That didn't work.               cd /home/user/path/to/     source myfile      Neither did providing the full absolute path to the file to be sourced:               source /home/user/path/to/myfile      The error is "source: not found" with the line number of the above statement. Is there something else, something basic, I could be overlooking? I have checked the paths I'm using and I don't see any errors. This problem is repeatable. I'm running Ubuntu on a Linode server and my scripts all start with:               #!/bin/bash


Getty instances in init process

Init typically will start multiple instances of "getty" which waits for console logins which spawn one's user shell process. Upon shutdown, init controls the sequence and processes for shutdown. The init process is never shut down. It is a user process and not a kernel system process although it does run as root. If the init process are user process and not kernel process, how I can modify the behavior or see the log the the process remotely?


Where can I find sources for

1. Emacs lisp source code for `.elc` files? e.g. `cal-mayan.elc`   2. Files in the `/bin` directory? e.g. `cat`, `split`, and `echo`


initramfs image compression other than gzip

can the initramfs image be compressed by a method other than gzip, such as lzma?


Lm_sensors not reading gfx card temperature right

I have ran sensors-detect and lm_sensors still returns the following.               radeon-pci-0100     Adapter: PCI adapter     temp1:       +511.0°C  (crit = +120.0°C, hyst = +90.0°C)          coretemp-isa-0000     Adapter: ISA adapter     Physical id 0:  +47.0°C  (high = +87.0°C, crit = +105.0°C)     Core 0:         +46.0°C  (high = +87.0°C, crit = +105.0°C)     Core 1:         +47.0°C  (high = +87.0°C, crit = +105.0°C)


bbswitch & bumblebee, card starting one every two call

I'm trying to set up bumblebee for using my Nvidia card (GT 750M) for running opengl 4 applications. I installed intel-dri, xf86-video-intel, nvidia, bumblebee and bbswitch. I set up /etc/modprobe.d/bbswitch.conf               options bbswitch load_state=0 unload_state=1      Yet I have a stange issue, at first call my program doesn't start :               $ cat /proc/acpi/bbswitch     0000:02:00.0 OFF     $ optirun glxgears     [ 1500.270330] [ERROR]Cannot access secondary GPU - error: [XORG] (EE) Server terminated successfully (0). Closing log file.     [ 1500.270357] [ERROR]Aborting because fallback start is disabled.     $ cat /proc/acpi/bbswitch     0000:02:00.0 ON     $ optirun glxgears     >> WORKS !!!     $ cat /proc/acpi/bbswitch     0000:02:00.0 OFF      when looking at /var/log/Xorg.8.log I have               [  1491.638] (EE) Failed to load module "mouse" (module does not exist, 0)     [  1491.639] (EE) Failed to load module "kbd" (module does not exist, 0)     [  1500.268] (EE) NVIDIA(GPU-0): Failed to initialize the NVIDIA GPU at PCI:2:0:0.  Please     [  1500.268] (EE) NVIDIA(GPU-0):     check your system's kernel log for additional error     [  1500.268] (EE) NVIDIA(GPU-0):     messages and refer to Chapter 8: Common Problems in the     [  1500.268] (EE) NVIDIA(GPU-0):     README for additional information.      Any idea how to solve this ?


Cheapest linux devices?

I'm getting interested in ultra-cheap linux devices lately. So far I've been playing with some no-name "3G/4G router" devices from amazon (such as this $10 job http://www.amazon.com/BrainyTrade-Mobile-Wireless- Hotspot-1800mAh/dp/B0093IPJKQ), which runs OpenWRT and gives me USB and Wifi connectivity, and a battery, which charges off USB. I'm curious what other ultra-cheap linux devices people are playing with? Define ultra-cheap as <30USD.


View blocked address from sshguard

How can I view all the addresses that sshguard has blocked to iptables?


Is there any way in BTRFS to set compression permanently?

I have a USB HDD. I want to mount it with compression enabled. I can do in the fstab of my system or even using udev rules. The problem is that I won't mount my USB HDD on my computer only. Up to now, I used to trigger a terminal each time I mounted it. Then, I discovered `chattr +c`. This is working very well **but** I want to use LZO instead of ZLIB. Is there any way to be more specific and define the compression algorithm once for all?


Script for testing SFTP login status?

I need to perform an automated backup task that connects to an SFTP server. The first stage involves testing the server connection by connecting to it. To be absolutely sure that it is connecting to the correct server, I am setting the `StrictHostKeyChecking` in ssh_config to yes. So, when the connection to the SFTP server is made, how do I script the response from the server. The pseudo code is as follows:               If connection success       disconnect       initiate backup procedure          Else       log error       exit script      **Additional Info:** I am using `ForceCommand internal-sftp` in the backup server's sshd_config, so running `ssh` command is out of the question.


How does the kernel know how much user addressable memory to set aside?

I was reading up on a rather-dated article on the kernel managing memory and had this question on where the Page Table Entries (PTE) would go into. For this example, the author assumes we are on a 32-bit machine with 4GB memory without PAE. The article assumes 3GB to be addressable as virtual memory (4KB pages of 3GB == 786,432 pages). But if there was a PTE of 4 bytes for each page, that in itself would account for ~3.1MB of memory which should be set aside by the kernel. Is this going to be a part of kernel memory? ie. kernel reserved memory apart from the user addressable 3GB? So, does the kernel first calculate and arrive at how much kernel (system) memory would be needed and how much it can mark as user-addressable memory at boot? What other stuff would reside in kernel/system-reserved memory?


Map a symbol to a specific key

I have the following problem: I use the `intl` variant of `gb` keyboard layout, i.e., what you get with:               setxkbmap -layout gb -variant intl      I use gmail in Firefox, and for some reason, the gmail shortcut to move between tabs in the inbox, which is trigged with the key `~`, does not work. The problem comes from having to press `~` and `Space` afterwards, so 2 keys, to get the symbol (that is the intl variant, which allows me to write `ñ`, the Spanish letter). I've tried the `us` layout with the `intl` variant, and in that case the shortcut works, because the `~` symbol can be triggered with `AltGr` \+ `~`. So, what I want is to have the same behaviour with the `gb` layout. Or, generally, to map `~` to any other combination (not involving more than one key).


How to open the clonezilla initrd.img?

I am not understand why I get the error about **initrd.img** ( this **initrd.img** is the original file from clonezilla ISO file               cp initrd.img /tmp     zcat /tmp/initrd.img | cpio -idm     zcat: initrd.img: not in gzip format     cpio: premature end of archive      the full steps that I did are as the following: I download the **clonezilla-live-2.1.2-43-i686-pae.zip** file from the site: http://clonezilla.org/livepxe.php Then I Performed the following in order to get the **initrd.img** file as the following:               unzip -j clonezilla-live-2.1.2-43-i686-pae.zip live/vmlinuz live/initrd.img live/filesystem.squashfs -d /tftpboot/nbi_img      Then I copied the               cp /tftpboot/nbi_img/initrd.img   /tmp      All the last steps are according to the site. Please advice what wrong here? I also tried this but not successfully with that -:( Link: http://www.thegeekstuff.com/2009/07/how-to-view-modify-and-recreate- initrd-img/               mv initrd.img.gz  initrd.gz     gunzip initrd.gz           gunzip: initrd.gz: not in gzip format


Drive keeps rebooting and wait for manual fsck

This is what my datacenter says > I've connected monitor to your server and it looks like it was rebooting and > is waiting for manual fschk again. Have you rebooted your server? Then fdcservers would do the manual fschk. Server is online again. But the next day, same thing happen again. What should I do I suspected it's hardware. How do I know which SSD need to be replaced? If I got to check logs, which logs I should see.


DocBook DSSSL test failure

So I followed these (Linux From Scratch) instructions to test my build of DocBook DSSSL, and I get this:               $ onsgmls -sv test.sgm     onsgmls:I: "OpenSP" version "1.5.2"     onsgmls:test.sgm:1:61:W: cannot generate system identifier for public text "-//Davenport//DTD DocBook V3.0//EN"     onsgmls:test.sgm:1:61:E: reference to entity "CHAPTER" for which no system identifier could be generated     onsgmls:test.sgm:1:0: entity was defined here     onsgmls:test.sgm:1:61:E: DTD did not contain element declaration for document type name     onsgmls:test.sgm:2:8:E: element "CHAPTER" undefined     onsgmls:test.sgm:2:15:E: element "TITLE" undefined     onsgmls:test.sgm:3:5:E: element "PARA" undefined      I have tried to retrace my steps by uninstalling and reinstalling the dependencies... without success.


How can I de-fragment a drive using Ubuntu?

Is it necessary to defrag drives in Ubuntu? If so, how do I do it and how often should it be done?


Delete last line from the file

I use `sed` to quickly delete lines with specific position as               sed '1d'     sed '5d'      But, what if I want to delete the last line of the file and I don't know the count of lines (I know I can get that using `wc` and several other tricks). Currently, using a workaround with `head` and `tail`combined with `wc` to do so. Any quick twists here?


Debian dpkg broken after apt-get upgrade

I have been running Debian Wheezy for a long time. Today I ran a `dpkg upgrade`, which has somehow broken things badly. The upgrade aborted, and now `apt-get` and `dpkg` are not running.               # dpkg     dpkg: error while loading shared libraries: libselinux.so.1: cannot open shared object file: No such file or directory      I can download the .deb files that contain the missing files, but I cannot install them without working tools. How do I get out of this catch 22?


Automatically acquire new IP address in new network

I'm running a Centos virtual machine on a laptop using a bridged network connection to avoid double-NAT issues, with the address assigned via DHCP. This works fine until I move the laptop to another network, at which point the VM doesn't notice that it's on a different network and continues to use the old IP address, resulting in a loss of connectivity. Currently I manage this by manually running `ifdown` and `ifup` to reset the network connection, but I'd prefer an automatic way to do this. Suggestions? Notes:   * All networks have DHCP servers.   * The VM correctly obtains an IP address lease on each network when bringing up the interface.   * I cannot change settings on the DHCP servers.   * The networks are in different IP address ranges.


Smart way to perform a similar replacement (not simple enough for diff) in multiple files?

I have a bunch of files (45, so too many to edit them manually without going crazy) which all require the same changes (as seen in the three diffs at the end of this question). Most tools used for search-and-replace on the commandline only support line- by-line replacements so they won't work. Is there some commandline tool available which can do the job? Basically performing a multi-line regex search&replace with backreferences without shoving the whole regex into a single line (i.e. it should be read from a file or stdin) should be enough, but maybe there's an even better solution to do this... * * *               --- a/editfile.html     +++ b/editfile.html     @@ -60,7 +60,5 @@           <script type="text/javascript">     -    $(document).ready(function() {     -        editFileInit(opts);     -    });     +    initPage('editFile', opts);      </script>      {% endblock %}                    diff --git a/gallery.html b/gallery.html     index 4a07f70..81084ad 100644     --- a/exodus/templates/gallery.html     +++ b/exodus/templates/gallery.html     @@ -87,9 +87,7 @@               <script type="text/javascript">     -        $(document).ready(function() {     -            galleryInit({     -                editTitleUrl: {{ csrf_url_for('gallery_editpictitle')|tojson|safe }},     -                delPicUrl: {{ csrf_url_for('gallery_delpic')|tojson|safe }}     -            });     +        initPage('gallery', {     +            editTitleUrl: {{ csrf_url_for('gallery_editpictitle')|tojson|safe }},     +            delPicUrl: {{ csrf_url_for('gallery_delpic')|tojson|safe }}              });          </script>                    diff --git a/stream_history.html b/stream_history.html     index 783fea4..ea837fa 100644     --- a/exodus/templates/stream_history.html     +++ b/exodus/templates/stream_history.html     @@ -25,8 +25,6 @@               <script type="text/javascript">     -        $(document).ready(function() {     -            songHistoryInit({     -                dataURL: {{ url_for('stream_history_json')|tojson|safe }}     -            });     +        initPage('songHistory', {     +            dataURL: {{ url_for('stream_history_json')|tojson|safe }}              });          </script>      If the indentation is not preserved it's not a big issue.


Stop aria2c from parsing torrent file

When I download a torrent file with aria2c, it always try to parse it and add a torrent task, but all I want is get that file. Is it possible to stop aria2c from doing so? I didn't seem to find an option in manual


kernel patches - knowing when to do them

I've never done a kernel patch before, and I've just recently started looking into how it's done. I notice that for a patch's filename, it tells us the kernel version (i.e dm-raid45-2.6.25-rc2_20080221.patch.bz2). So, I know that definitely for kernel 2.6.25, I'd need to apply this patch. But, I just want to make sure: If I've got a kernel that is more recent than the one mentioned - say, 2.6.26 - does this mean that this patch has already moved its way to the 2.6.26 kernel version and that I won't need to apply it at all? Thanks for clarifying!


Configuring cron.hourly

I am unable to configure a cron job to run by placing it in /etc/cron.hourly folder.               SHELL=/bin/bash     PATH=/sbin:/bin:/usr/sbin:/usr/bin     MAILTO=root     HOME=/          # run-parts     01 * * * * root run-parts /etc/cron.hourly     02 4 * * * root run-parts /etc/cron.daily     22 4 * * 0 root run-parts /etc/cron.weekly     42 4 1 * * root run-parts /etc/cron.monthly      The file under cron.hourly is :               lrwxrwxrwx 1 root root   40 2010-07-26 14:52 check -> /usr/local/xxxx/check-interface.bash      Permissions on the file :               -rwxr-xr-x 1 root root 1.6K 2010-09-13 11:22 /usr/local/xxxx/check-interface.bash      There seems to be no errors reported in the var/log/cron logfile. No mention of the script is done. :(


What does ${1+"$@"} mean in a shell script, and how does it differ from "$@"?

In the Perl documentation, perlrun(1) suggests launching Perl scripts using a bilingual shell/Perl header:               #!/bin/sh     #! -*-perl-*-     eval 'exec perl -x -wS $0 ${1+"$@"}'         if 0;      What does `${1+"$@"}` mean? I tried using `"$@"` instead (using Bash as /bin/sh), and it seems to work just as well. * * * ### Edit Two answers below say that it's supposed to be `${1:+"$@"}`. I am aware of the `${parameter:+word}` ("Use Alternate Value") syntax documented in bash(1). However, I am unconvinced, because   1. Both `${1+"$@"}` and `"$@"` work just fine, even when there are no parameters. If I create simple.sh as              #!/bin/sh     eval 'exec /usr/bin/perl -x -S -- $0 "$@"'         if 0;     #!perl     use Data::Dumper;     print Dumper(\@ARGV);      and question.sh as              #!/bin/sh     eval 'exec /usr/bin/perl -x -S -- $0 ${1+"$@"}'         if 0;     #!perl     use Data::Dumper;     print Dumper(\@ARGV);      I can get both to work identically:              $ ./question.sh      $VAR1 = [];     $ ./question.sh a     $VAR1 = [               'a'             ];     $ ./question.sh a 'b c'     $VAR1 = [               'a',               'b c'             ];     $ ./question.sh ""     $VAR1 = [               ''             ];     $ ./simple.sh      $VAR1 = [];     $ ./simple.sh a     $VAR1 = [               'a'             ];     $ ./simple.sh a 'b c'     $VAR1 = [               'a',               'b c'             ];     $ ./simple.sh ""     $VAR1 = [               ''             ];        2. Other sources on the Internet also use `${1+"$@"}`, including one hacker who seems to know what he's doing. Perhaps `${parameter+word}` is an undocumented alternate (or deprecated) syntax for `${parameter:+word}`? Could someone confirm that hypothesis?


Can't boot into single user mode

I hosed my login (bad script /etc/profile.d) and I can't SSH into my system or boot it into single. I append " single" to the end of the kernel boot parameters and it just keeps booting like normal. I've also tried " s" with no avail. However, " emergency" does work. I'm running RHEL 6.3. Any ideas on what I'm doing wrong?


Explicit range beween values

Is there any clean way of calculating the range between elements of the second column of a text file using some bash magic? (I'm currently doing this using Python). Input: File 1               A   1-5     A   17-19     B   1-5     B   4-6      Expected output: File 2               A   1,2,3,4,5,17,18,19     B   1,2,3,4,5,6          _EDIT_ @Anthon: to cumulate elements I'm using something like this (then calculate the ranges using a for loop)               d_pos= {}      for row in open('File.txt'):          x, y = [ value.strip() for value in row.split('\t')]          if x in d_pos:                     d_pos[x].append(y)             else:                     d_pos[x] = [y]


How do I run this C program after starting X server?

The source for a program that automatically scales my laptop's keyboard brightness to its screen's brightness is given on the Arch wiki page for my laptop. I can compile it and when I run the program as root it works fine. Unfortunately, I do not know how to run this program every time I start my computer, and further the wiki states that I have to run it after I start the X server. Since I'm using Arch, I imagine I have to do something with `systemd`, but I have no idea what. Any help would be greatly appreciated. If it's relevant, the source is posted here.


Disable Ctrl+Alt Hotkeys in certain programs

I am using Sublime Text 3 which uses `Ctrl``Alt``$key` hotkeys for a few important functionalities, but `Ctrl``Alt``Left` (for example) switches workspaces. Is there a way I can disable the OS functions of these hotkeys while I'm using Sublime Text 3? I'm running Linux Mint 16 Petra with Cinnamon desktop, and the latest version of Sublime Text 3


parted not recognizing my current partition on external disk. How to fix without losing data?

I have an external (USB) disk, which has been working OK for some time and shows no errors whatsoever in /var/log/$relevantfiles (no errors on reading/writing, for example). Here's the thing: if I ask for sudo fdisk -l /dev/sda this returns:               Disk /dev/sda: 1000.2 GB, 1000204886016 bytes     255 heads, 63 sectors/track, 121601 cylinders, total 1953525168 sectors     Units = sectors of 1 * 512 = 512 bytes     Sector size (logical/physical): 512 bytes / 512 bytes     I/O size (minimum/optimal): 512 bytes / 512 bytes     Disk identifier: 0x24796452          Device Boot      Start         End      Blocks   Id  System     /dev/sda1              63  1953520064   976760001   83  Linux      which is exactly how I did it. Now, I want to recover a partition in this disk to use for some other purposes, which require hfs, instead of ext{2,3,4}. So I turned myself to the old dear parted to resize the partition and create a new one. Asking parted this returns:               (parted) print                                                                 Model: ST310005 28AS (scsi)     Disk /dev/sda: 1000GB     Sector size (logical/physical): 512B/512B     Partition Table: mac          Number  Start  End    Size    File system  Name            Flags     1      512B   1535B  1024B                partition map     2      368MB  371MB  2982kB               OneClick-Ready      and if I run gparted I see all the empty space, and I cannot resize my partition, since it's not there. Any pointers how to fix this things? I've never seen anything like it. The whole thing's running on a raspberry pi, using raspbian. Thanks!


How to show and modify user info in Ubuntu server?

If I want to put some personal information (like Full Name) to an account, how can I check it again? And how can I modify it? On Ubuntu server. With command line only.


How to limit ftp speed

I have multiple users on a server. They upload and download their files through FTP. Sometimes some heavy transfer causes high load on the server. I am wondering, if there is any way to limit the ftp speed to avoid high load. Any help would be much appreciated.


How to limit the total resources (memory) of a process and its children

There are plenty of questions and answers about constraining the resources of a single process, e.g. RLIMIT_AS can be used to constrain the maximum memory allocated by a process that can be seen as VIRT in the likes of `top`. More on the topic e.g. here Is there a way to limit the amount of memory a particular process can use in Unix? `setrlimit(2)` documentation says: > A child process created via fork(2) inherits its parent's resource limits. > Resource limits are preserved across execve(2). It should be understood in the following way: If a process has a RLIMIT_AS of e.g. 2GB, then it cannot allocate more memory than 2GB. When it spawns a child, the address space limit of 2GB will be passed on to the child, but counting starts from 0. The 2 processes together can take up to 4GB of memory. But what would be the useful way to constrain the sum total of memory allocated by a whole tree of processes?


Resume from hibernate fails after image restoration

I've been trying to get hibernation to work, and am having problems. The system seems to go into hibernation just fine, but when I try to restore from disk, the process stops just after a message saying "Image restoration successful". This is before I'm able to switch to a new tty. `Ctrl-alt-del` works. SysRq commands seem to work, although I'm not sure what to do with them. Suspend (to RAM) works fine when I close the lid or use `s2ram` or `pm- suspend`. If I use `s2both` or `s2disk`, I see the messages about the image being written to disk; if I treat `s2both` (or `pm-suspend-hybrid`) as a suspend (eg, restore without cutting power), it works. But if I cut power and do a cold boot, after the progress indicator seems to say the image is done loading, the process just stops. Does anyone know how I can fix this? Or at least what my next debugging/troubleshooting steps should be?       I'm using (K)Ubuntu 12.04, kernel 3.2.0-38-generic. I have 2GB of RAM and 4GB of swap. This (month-old unanswered forum post) looks very similar to my situation (except for the message about user id - which he gets but I don't) http://forum.linuxmint.com/viewtopic.php?p=708058&sid=e8bd8eba8fad0b25597209e365d6edf4 -Thanks    Edit: Update So, this is now kinda 'half-solved'. Gilles' answer got me past the place where I was stuck, but I still don't know what caused the problem. I am now having further problems, so I will need to keep debugging this, in case they are related - and would very much welcome further tips on what might have caused this problem in the first place. (New problem seems to be a more severe lock-up (that 'magic SysRq' doesn't help) when I try to hibernate/s2disk with more than ~500MB of memory used. Didn't think to test w/ a high memory load, ouch ...)


How to make a cifs/smb mount ignore umask?

I have a cifs mount that is mounted from `/etc/fstab`. But I would quite like creation of files/dirs on that share to ignore my umask. Is that possible? It seems that cifs does not support the `umask=000` option (source: `man mount.cifs`). My current best option is to set my system-wide umask to 000, but I'd rather not do this as I'd like to keep the local machine a bit more locked down. The silly thing is that my previous NAS did this fine, so maybe it's a server-side change that's required?


Multiline regex blank line delimiters,

I have a program which prints out data in blocks. Each block is delimited by blank lines. I would like to discard most blocks and only keep those blocks that contain something that matches a regex. I can of course do it with a scripting language or a prgram, but that seems rather crude. Is there a better way to do it?


PC BSD Warden network interface

The documentation for PC BSD's Warden mentions that the configuration of the right network interface is crucial. However, it doesn't say what the "right" interface is. This may sound like a stupid question, but what interface can I use there? The existing physical NIC one? Should I create a virtual one and use that? The aim is to have network access in the jails, i.e. be able to access the internet as well as access services running within the jail from the internet.


Omitting extension with find?

I need to create thumbnails from multiple .png files and would like to do this using ImageMagicks `convert` utility. To recursively find all files that are not thumbnails themselves, I am using the following call (split into two lines to make it readable):               find . -type f -name "*.png" -not -name "*thumb.png*" \       -exec convert {} -thumbnail 200x200 {}.thumb.png \;`      But this would of course create a file named `a.png.thumb.png` when running it on a file called `a.png`. How could I remove the `.png` extension from the second `{}` parameter passed to convert?


External disk doesn’t appear in /dev/

I have an external (USB-2.0) hard drive. Today I couldn’t mount it after plugging to my computer. When I look in /dev/               $ ls /dev/sd*      There is no new disk, only sda and sdb with their partitions, which are two local 3.5" hard drives. However, when I took a look at dmesg, there were lines telling that disk appeared as /dev/sdc.               [542880.810341] usb 7-1.1: new high-speed USB device number 15 using ehci-pci     [542880.896004] usb 7-1.1: New USB device found, idVendor=152d, idProduct=2329     [542880.896007] usb 7-1.1: New USB device strings: Mfr=1, Product=11, SerialNumber=5     [542880.896008] usb 7-1.1: Product: StoreJet Transcend     [542880.896010] usb 7-1.1: Manufacturer: JMicron     [542880.896011] usb 7-1.1: SerialNumber: 322549CB7013     [542880.896391] usb-storage 7-1.1:1.0: USB Mass Storage device detected     [542880.896422] scsi21 : usb-storage 7-1.1:1.0     [542881.917895] scsi 21:0:0:0: Direct-Access     StoreJet Transcend        2AJ1 PQ: 0 ANSI: 2 CCS     [542881.917995] sd 21:0:0:0: Attached scsi generic sg3 type 0     [542881.918635] sd 21:0:0:0: [sdc] 1250263727 512-byte logical blocks: (640 GB/596 GiB)     [542881.919636] sd 21:0:0:0: [sdc] Write Protect is off     [542881.919639] sd 21:0:0:0: [sdc] Mode Sense: 28 00 00 00     [542881.920633] sd 21:0:0:0: [sdc] No Caching mode page found     [542881.920634] sd 21:0:0:0: [sdc] Assuming drive cache: write through     [542881.923253] sd 21:0:0:0: [sdc] No Caching mode page found     [542881.923254] sd 21:0:0:0: [sdc] Assuming drive cache: write through     [542881.966710]  sdc: sdc1 sdc2 sdc3 < sdc5 sdc6 > sdc4     [542881.970736] sd 21:0:0:0: [sdc] No Caching mode page found     [542881.970739] sd 21:0:0:0: [sdc] Assuming drive cache: write through     [542881.970742] sd 21:0:0:0: [sdc] Attached SCSI disk      It cannot be other disk or a flash card because I compared dmesg output right before plugging in external drive and after that. How can that be? My system is Gentoo amd64 with eudev. * * * cat /proc/partitions udevd --debug


Problem reading mouse from /dev/input/events

I'm using Fedora 17 LXDE with kernel 3.6.10 and am trying to read raw mouse relative movements from `/dev/input/mouseX` and/or `/dev/input/eventX`. I get data showing mouse clicks (mouse up, mouse down) and `rel_*` events but all the relative movement data have identical `rel_x` and `rel_y` values. i.e., if I move the mouse left, I get `rel_x = rel_y = +1`. If I move the mouse to the right, I get `rel_x = rel_y = +1`. Same values when moving the mouse up/down. The values are not always = +1, sometimes they are +2. Any ideas?               #include <stdio.h>     #include <stdlib.h>     #include <fcntl.h>     #include <istream>     #include <unistd.h>     #include <linux/input.h>          #define MOUSEFILE "/dev/input/event2"          int main()     {     int fd;     struct input_event ie;          if((fd = open(MOUSEFILE, O_RDONLY)) == -1) {         perror("opening device");         exit(EXIT_FAILURE);     }          while(read(fd, &ie, sizeof(struct input_event))) {         unsigned char *ptr = (unsigned char*)&ie;         for(int i=0; i<sizeof(ie); i++)             printf("%02X ", *ptr++);         printf("\n");     }          return 0;     }      Typical output:               29 EB F7 50 00 00 00 00 27 6A 0C 00 00 00 00 00 02 00 01 00 01 00 00 00      29 EB F7 50 00 00 00 00 33 6A 0C 00 00 00 00 00 00 00 00 00 00 00 00 00      29 EB F7 50 00 00 00 00 F5 90 0C 00 00 00 00 00 02 00 00 00 01 00 00 00      29 EB F7 50 00 00 00 00 F6 90 0C 00 00 00 00 00 02 00 01 00 01 00 00 00      29 EB F7 50 00 00 00 00 00 91 0C 00 00 00 00 00 00 00 00 00 00 00 00 00      29 EB F7 50 00 00 00 00 BF B7 0C 00 00 00 00 00 02 00 00 00 02 00 00 00      29 EB F7 50 00 00 00 00 C0 B7 0C 00 00 00 00 00 02 00 01 00 02 00 00 00      29 EB F7 50 00 00 00 00 CA B7 0C 00 00 00 00 00 00 00 00 00 00 00 00 00      29 EB F7 50 00 00 00 00 1C D7 0C 00 00 00 00 00 02 00 00 00 01 00 00 00      29 EB F7 50 00 00 00 00 1D D7 0C 00 00 00 00 00 02 00 01 00 01 00 00 00      29 EB F7 50 00 00 00 00 24 D7 0C 00 00 00 00 00 00 00 00 00 00 00 00 00      29 EB F7 50 00 00 00 00 F0 3F 0D 00 00 00 00 00 02 00 00 00 01 00 00 00      29 EB F7 50 00 00 00 00 F1 3F 0D 00 00 00 00 00 02 00 01 00 01 00 00 00      29 EB F7 50 00 00 00 00 FA 3F 0D 00 00 00 00 00 00 00 00 00 00 00 00 00      29 EB F7 50 00 00 00 00 51 6A 0D 00 00 00 00 00 02 00 00 00 03 00 00 00      29 EB F7 50 00 00 00 00 52 6A 0D 00 00 00 00 00 02 00 01 00 03 00 00 00      29 EB F7 50 00 00 00 00 5A 6A 0D 00 00 00 00 00 00 00 00 00 00 00 00 00           and some output when clicking a button     72 EE F7 50 00 00 00 00 10 DF 00 00 00 00 00 00 01 00 10 01 01 00 00 00      72 EE F7 50 00 00 00 00 13 DF 00 00 00 00 00 00 02 00 00 00 01 00 00 00      72 EE F7 50 00 00 00 00 13 DF 00 00 00 00 00 00 02 00 01 00 01 00 00 00      72 EE F7 50 00 00 00 00 2B DF 00 00 00 00 00 00 00 00 00 00 00 00 00 00      72 EE F7 50 00 00 00 00 C0 AE 02 00 00 00 00 00 01 00 10 01 00 00 00 00      72 EE F7 50 00 00 00 00 C5 AE 02 00 00 00 00 00 02 00 00 00 01 00 00 00      72 EE F7 50 00 00 00 00 C6 AE 02 00 00 00 00 00 02 00 01 00 01 00 00 00      72 EE F7 50 00 00 00 00 E0 AE 02 00 00 00 00 00 00 00 00 00 00 00 00 00


Create bash script for wine cmd script

I have installed FIFA09 through wine & it runs great...however i have to manually go to installation directory each time & open the terminal there. Then have to write in two steps: `wine cmd` while cmd is operating in terminal `FIFA09.exe -Windowed` how can i chain these commands in a bash script which can then be invoked by a simple .desktop launcher


How to check if an application is running with a bash script

I have the gnome-run application in my home folder. I have now added the application to run when I press `Meta`+`R` (i added it in in ccsm). The problem is that if I have the gnome-run program open and I press the key combination I want the application to close. Is there some way to create a bash file that checks if the applications is running, if it is then close it, else launch it. I run the application like ./gnome-run in my home folder.   I can't find the application process in ps -A or anything. Thanks


ZSH host name completion behaviour change?

I have been using ZSH to do host name completion, and want to change the default behaviour. When I have multiple hosts with similar names, the completion does stuff that I don't care for. An example is best: Let's say I have these hosts:               host01.stage.example.com     host02.stage.example.com     host01.prod.example.com     host02.prod.example.com      now, in my prompt, I will type:               $ ssh hos<tab>      zsh will show me:               $ ssh host..example.com       with the cursor right after "host" and shows me a menu with the host names in it. I like the menu showing me hostnames, I just don't want it to complete everything. Weird things happen. Most of the time I tab through and either have to delete host names or have extra stuff on the line i have to delete. A preferred way would be to not complete the rest of the hostname. something like:               $ ssh hos<tab>      zsh would hopefully show me:               $ ssh host     host01.stage.example.com  host01.prod.example.com     host02.stage.example.com  host02.prod.example.com      Any thoughts?


convert djvu to pdf

How to convert djvu2pdf ? My current approach is :               djvups x.djvu > x.ps     ps2pdf x.ps      Is there more efficient and better (in terms of output quality, data/metadata loss) way to handle that ?


how to check OS and version using Linux commmand

what is the Linux command to check the server OS and its version? Connected the server using shell.


Making a simple PHP script process text in a pipe

Last week I wanted to convert some simplified Chinese characters into traditional ones. I found a deceptively nice looking shell one-liner, which today I found out was 20% error prone. So I did some research. The mediawiki codebase contains conversion tables that take the idiosyncratic nature of simplified orthography into account, and someone already wrote a nice helper library full of dummy classes and functions, called mediawiki-zhconverter. So it appeared I could have my one- liner, which I would prefer looked something like this, stconvert being the name of the script I'm writing:               $cat simplifiedstory | stconvert > traditionalstory      However, mediawiki is entirely PHP, and I have never written any PHP, so I don't know how it deals with shell variables. As you can see below, simply putting '$argv' where a string would go does not achieve my goal.               #!/usr/bin/php     <?php          define("MEDIAWIKI_PATH", "/home/a1/mediawiki-1.13.0/");     require_once "mediawiki-zhconverter.inc.php";     echo MediaWikiZhConverter::convert($argv, "zh-tw") , ",";          ?>


How to install kernel on debian with no internet connection

I'm trying to install a newer kernel version on my Debian (squeeze) machine as I need it to get my wireless card working. I have Debian on one partition of my hard drive, Fedora on the other. I'm looking for SIMPLE instructions on how to do this which I cannot find anywhere on the net. Any help would be greatly appreciated! I'm even wondering if it is possible to copy the kernel across from one partition to the next?


Display current pane's current directory in status

Is there a way to update `pwd` in tmux status, instead of showing it in PS1?               set -g status-left "#(pwd)"     set -g status-interval 1      doesn't work.