title: Specify partition data in sfdisk and parted

text: With this line:               (echo o; echo n; echo p; echo 1; echo ; echo +24G; echo a; echo t; echo 7; echo w) | fdisk /dev/sda      I can create a new active primary partition for NTFS, 24 Giga large. The syntax is ugly but effective. How can I do the same with `parted` or `sfdisk`?


title: Is it safe to just copy shared libraries onto embedded Linux device?

text: The following is contained in the vendor user manual for its embedded Linux distro on the hardward board they supply > Developers can put their program onto X-Linux device via FTP or NFS. Before > running it, use ldd command on development workstation to check dependency > files. Also put relative files onto X-Linux to ensure program can run > properly. Here is an example when we put “syslinux” onto X-Linux:                 [root@X-Linux]:/sbin # ldd syslinux                linux-gate.so.1 => (0xb80a0000)               libc.so.6 => /lib/libc.so.6 (0xb7f60000)                /lib/ld-linux.so.2 (0xb80a1000)        [root@X-Linux]:/sbin #       > From above messages, **/lib/libc.so.6** and **/lib/ld-linux.so.2** are > needed by syslinux. Put those two files onto X-Linux to ensure syslinux can > work properly. I will have to write software to run on this device and a lot of advice I have received on stack exchange points me in directions that contradict this advice (suggesting setting up specific embedded development environment, linking to older versions of libc, static linking etc). Is the above information given by the vendor a safe and reliable way to do things???


title: Kernel compilation of version 2.4 on a system running 3.2.0

text: My current kernel version on with my OS running on is 3.2.0. Can I compile a kernel of version 2.4.0 on it? Is there any perfect kernel documentation available? (As I see different ways of compiling kernel, expecting a unified documentation which lists all possible ways)


title: The netcat command can't access an open port

text: I have two servers over which I am trying to install some software. One is server1(IP 10.1.2.205) and the other is server2(IP 10.1.2.206). Both are able to ping each other by name and by IP address (ie. from server2 i can `ping server1` or `ping 10.1.2.205`) I have the following output when I type in `netstat -lnt` on server1                   Proto Recv-Q Send-Q Local Address ForeignAddress State           tcp        0      0 0.0.0.0:111    0.0.0.0:*     LISTEN          tcp        0      0 0.0.0.0:22     0.0.0.0:*     LISTEN          tcp        0      0 127.0.0.1:631  0.0.0.0:*     LISTEN          tcp        0      0 127.0.0.1:25   0.0.0.0:*     LISTEN          tcp        0      0 0.0.0.0:52666  0.0.0.0:*     LISTEN          tcp        0      0 0.0.0.0:6817   0.0.0.0:*     LISTEN          tcp        0      0 0.0.0.0:6818   0.0.0.0:*     LISTEN          tcp        0      0 0.0.0.0:5672   0.0.0.0:*     LISTEN          tcp        0      0 :::111         :::*          LISTEN          tcp        0      0 :::22          :::*          LISTEN          tcp        0      0 ::1:631        :::*          LISTEN          tcp        0      0 :::36483       :::*          LISTEN          tcp        0      0 :::5989        :::*          LISTEN        Now when I try using the netcat command from server2, I get the following results : `nc -v 10.1.2.205 22`   `Connection to server1 22 port [tcp/ssh] succeeded! SSH-2.0-OpenSSH_5.3` `nc -v server1 22`   `Connection to server1 22 port [tcp/ssh] succeeded! SSH-2.0-OpenSSH_5.3` The problem is with the following outputs though :   `nc -v server1 5989`   `nc: connect to server1 port 5989(tcp) failed: No route to host`   I get the same response on every other port.   No other port on server1 responds. My ports of interest are the 6817 and 6818 ports. I have an application that needs to listen and respond on these ports between these two machines. Output of : `iptables -L`                   Chain INPUT (policy ACCEPT)         target  prot opt source   destination                  ACCEPT  all  --  anywhere anywhere  state RELATED,ESTABLISHED                    ACCEPT  icmp --  anywhere anywhere                     ACCEPT  all  --  anywhere anywhere                     ACCEPT  tcp  --  anywhere anywhere  state NEW tcp dpt:ssh          REJECT  all  --  anywhere anywhere  reject-with icmp-host-prohibited               Chain FORWARD (policy ACCEPT)         target  prot opt source   destination                  REJECT  all  --  anywhere anywhere    reject-with icmp-host-prohibited               Chain OUTPUT (policy ACCEPT)         target  prot opt source   destination          What could be wrong ?


title: Force installation of doc packages

text: I often find myself missing documentation when I happen to be offline. For this reason, I would like to force `aptitude` to install the corresponding doc packages whenever I install a package. Is there a way of doing that more elegant than putting an alias that goes through arguments and add the `*-doc` that exist before forwarding the arguments to `aptitude`?


title: How to obtain current user environment in pam_script?

text: I'm running `pam_script` after `pam_krb5` with a session open script. In my script, I need to use the ticket cache generated by krb5 to do something. Well, the script was actually run as root, and `KRB5CCNAME` or `PAM_KRB5CCNAME` is all empty. What should I do?


title: smbmount cifs share through alias source ip

text: On a box having samba 3.6.x and a IPv4 number plus an alias IPv4 number, is it possible to force smblient (mount.cifs) to **use the second (alias) IP** for mounting a windows share. Something comparable to ping's -I option:               ping -I my_alias_ip destination_ip      I didn't find anything related in _man mount.cifs_.


title: change terminal window default location

text: How do I change the default `gnome-terminal` location on **screen**. I checked out the preferences but they only have option to change default size. I also checked out `.gconf/apps/gnome-terminal/` but didnt find any thing out.   All in all my `gnome-terminal` should normally be `gnome-terminal --geometry=80x24+200+200`   I dont want to do it through launcher because I will always have to start the terminal from launcher to get that location.


title: incorrect/overwritten margins when using vim in GNU screen

text: When ssh'd into a work server via PuTTY I'm seeing strange behavior with the left margins when using GNU screen and vim. For example, I'll open up a Python script and all indentations will be gone i.e.               def __init__(self):     self.name = str(self.__class__.__name__)     self.nestables = None     self.attributes = {}      and not               def __init__(self):         self.name = str(self.__class__.__name__)         self.nestables = None         self.attributes = {}      However if I scroll down one line at a time newly appearing lines on screen will have proper indentation. I see similar behavior in htop, with the left margin getting overwritten or being indented incorrectly. I figure there's a termcap/terminfo setting I can put in my .screenrc but everything I've tried so far has not worked. I see this both in Debian 7 and CentOS 6. Anyone else encountered this before? **Edit:** I am indenting with spaces, not tabs, and am using PuTTY from my Windows 7 workstation. I tried to reproduce the issue at a normal Windows cmd window using Cygwin/SSH and the margins are just fine, so it does appear to be PuTTY specific. ... and it turns out that I had "Implicit CR in every LF" checked by default in PuTTY and that was the culprit. Screen was a red herring.


title: Reinstall gnome 3

text: I have Kali linux and lately I had some problems with my ATI Radeon GPU overheating. I had to reinstall the drivers. Since I'm a newbie, obviously, something gone wrong and my beautiful Gnome 3 desktop has turn into beastly- gnome-2[actually a fallback session]. Now the GPU fan works just fine but I also want to get back my old desktop. I already tried this and it's not working. I've tried googling my problem but I didn't find anything useful. Are there any chances to "reinstall/reset" it?


title: regex to match identifiers without double _

text: I want a regex to match identifiers consisting of letters, digits and `_`, without double underscores. My current attempt:               ^(?!_)(?!.*?_$)[a-zA-Z][a-zA-Z0-9_]+$      Example:               Abdfsdfsdf__      1B2345_     v1__23456     __23456789b     12345-6789     123456789     1_fsdfdfsdf     v_fsdfsdf_fsdfd     v_123     v__123     v134234_fsdfsd     123456     a1b2c3d4e5      Matched:               v1__23456     v_fsdfsdf_fsdfd     v_123     v__123     v134234_fsdfsd     a1b2c3d4e5      How can I remove the rows `v1__23456` and `v__123` from the matches?


title: Is it better to set rules in ip6tables or disable ipv6?

text: I have the following network configuration:               # ifconfig -a     eth0      Link encap:Ethernet  HWaddr 00:e0:1c:73:02:09               inet addr:10.1.4.41  Bcast:10.1.255.255  Mask:255.255.0.0               inet6 addr: fe80::2e0:4cff:fe75:309/64 Scope:Link               UP BROADCAST RUNNING MULTICAST  MTU:1500  Metric:1               RX packets:858600 errors:0 dropped:0 overruns:0 frame:0               TX packets:1069549 errors:0 dropped:0 overruns:5 carrier:0               collisions:0 txqueuelen:1000               RX bytes:142871181 (136.2 MiB)  TX bytes:717982640 (684.7 MiB)          lo        Link encap:Local Loopback               inet addr:127.0.0.1  Mask:255.0.0.0               inet6 addr: ::1/128 Scope:Host               UP LOOPBACK RUNNING  MTU:65536  Metric:1               RX packets:37952 errors:0 dropped:0 overruns:0 frame:0               TX packets:37952 errors:0 dropped:0 overruns:0 carrier:0               collisions:0 txqueuelen:0               RX bytes:3396918 (3.2 MiB)  TX bytes:3396918 (3.2 MiB)      I have DHCP server in my network and I can get the following lease:               lease {       interface "eth0";       fixed-address 10.1.4.41;       option subnet-mask 255.255.0.0;       option routers 10.1.255.253;       option dhcp-lease-time 120;       option dhcp-message-type 5;       option domain-name-servers 82.160.125.52,213.199.198.248,82.160.1.1;       option dhcp-server-identifier 192.168.22.22;       renew 3 2014/01/01 18:34:41;       rebind 3 2014/01/01 18:35:30;       expire 3 2014/01/01 18:35:45;     }      I can ping `127.0.0.1`, `::1`, `10.1.4.41`:               $ ping 10.1.4.41     PING 10.1.4.41 (10.1.4.41) 56(84) bytes of data.     64 bytes from 10.1.4.41: icmp_seq=1 ttl=64 time=0.065 ms     64 bytes from 10.1.4.41: icmp_seq=2 ttl=64 time=0.075 ms     64 bytes from 10.1.4.41: icmp_seq=3 ttl=64 time=0.085 ms     ^C     --- 10.1.4.41 ping statistics ---     3 packets transmitted, 3 received, 0% packet loss, time 2000ms     rtt min/avg/max/mdev = 0.065/0.075/0.085/0.008 ms          $ ping 127.0.0.1     PING 127.0.0.1 (127.0.0.1) 56(84) bytes of data.     64 bytes from 127.0.0.1: icmp_seq=1 ttl=64 time=0.066 ms     64 bytes from 127.0.0.1: icmp_seq=2 ttl=64 time=0.056 ms     64 bytes from 127.0.0.1: icmp_seq=3 ttl=64 time=0.055 ms     ^C     --- 127.0.0.1 ping statistics ---     3 packets transmitted, 3 received, 0% packet loss, time 1999ms     rtt min/avg/max/mdev = 0.055/0.059/0.066/0.005 ms          $ ping6 ::1     PING ::1(::1) 56 data bytes     64 bytes from ::1: icmp_seq=1 ttl=64 time=0.052 ms     64 bytes from ::1: icmp_seq=2 ttl=64 time=0.049 ms     64 bytes from ::1: icmp_seq=3 ttl=64 time=0.037 ms     ^C     --- ::1 ping statistics ---     3 packets transmitted, 3 received, 0% packet loss, time 1998ms     rtt min/avg/max/mdev = 0.037/0.046/0.052/0.006 ms      I can't ping the ipv6 address `fe80::2e0:4cff:fe75:309`:               $ ping6 fe80::2e0:4cff:fe75:309     connect: Invalid argument      I have set some iptables rules (ipv4):               # iptables -S     -P INPUT DROP     -P FORWARD DROP     -P OUTPUT ACCEPT     -N TCP     -N UDP     -A INPUT -i eth0 -m conntrack --ctstate RELATED,ESTABLISHED -j ACCEPT     -A INPUT -i lo -j ACCEPT     -A INPUT -i tun0 -m conntrack --ctstate RELATED,ESTABLISHED -j ACCEPT     -A INPUT -m conntrack --ctstate INVALID -j DROP     -A INPUT -p udp -m conntrack --ctstate NEW -j UDP     -A INPUT -p tcp -m tcp --tcp-flags FIN,SYN,RST,ACK SYN -m conntrack --ctstate NEW -j TCP     -A INPUT -p tcp -j REJECT --reject-with tcp-reset     -A INPUT -p udp -j REJECT --reject-with icmp-port-unreachable     -A INPUT -j REJECT --reject-with icmp-proto-unreachable     -A OUTPUT -m conntrack --ctstate INVALID -j DROP      And it works as expected for ipv4. But when I check ip6tables, I can see some packets go there:               # ip6tables -nvL     Chain INPUT (policy ACCEPT 381 packets, 27624 bytes)      pkts bytes target     prot opt in     out     source               destination          Chain FORWARD (policy ACCEPT 0 packets, 0 bytes)      pkts bytes target     prot opt in     out     source               destination          Chain OUTPUT (policy ACCEPT 390 packets, 26296 bytes)      pkts bytes target     prot opt in     out     source               destination      I followed this guide, and they say that I should copy the iptables (ipv4) configuration and paste it in ip6tables (ipv6). But when I do this, no packet can go through the rule `RELATED,ESTABLISHED` in the ipv6 table. All of them are dropped because of INPUT chain policy (`DROP`).               # ip6tables -nvL     Chain INPUT (policy DROP 5 packets, 360 bytes)      pkts bytes target     prot opt in     out     source               destination         0     0 ACCEPT     all      eth0   *       ::/0                 ::/0                 ctstate RELATED,ESTABLISHED         0     0 ACCEPT     all      lo     *       ::/0                 ::/0         0     0 ACCEPT     all      tun0   *       ::/0                 ::/0                 ctstate RELATED,ESTABLISHED         0     0 DROP       all      *      *       ::/0                 ::/0                 ctstate INVALID         0     0 UDP        udp      *      *       ::/0                 ::/0                 ctstate NEW         0     0 TCP        tcp      *      *       ::/0                 ::/0                 tcp flags:0x17/0x02 ctstate NEW         0     0 REJECT     tcp      *      *       ::/0                 ::/0                 reject-with tcp-reset         0     0 REJECT     udp      *      *       ::/0                 ::/0                 reject-with icmp6-port-unreachable          Chain FORWARD (policy DROP 0 packets, 0 bytes)      pkts bytes target     prot opt in     out     source               destination          Chain OUTPUT (policy ACCEPT 0 packets, 0 bytes)      pkts bytes target     prot opt in     out     source               destination         0     0 DROP       all      *      *       ::/0                 ::/0                 ctstate INVALID          Chain TCP (1 references)      pkts bytes target     prot opt in     out     source               destination          Chain UDP (1 references)      pkts bytes target     prot opt in     out     source               destination      As you can see there's no output packets, so why google and stack exchange try to connect to my machine? And how do they do it because even I can't ping my ipv6 address? They also say if my ISP doesn't have ipv6 (in the lease, there's no ipv6 entry) I should disable ipv6 and had done this before by using `ipv6.disable=1`. I asked similar question at `meta.stackoverflow.com`, and I got an answer that I shouldn't disable ipv6. I have no idea what to do. I have some connection problems, I mean sometimes I can't access pages at stack exchange, or google, I have also problems with pastebin.com. In each case there are the same symptoms -- after typing an address in my browser, I have to wait sometimes several minutes in order to access the site and after reloading it 2-3 times, I can browse it freely, at least for a certain period of time.


title: No installation steps when Installing CentOS 6.4 on VMware Fusion

text: This is my first real day on using linux. I'm following a book guide. I installed CentOS 6.4 on my mac using VMWare Fusion. However, during the installation, it did not guide me through the installation steps (e.g., choosing software selection like Server, Server-GUI, Desktop-KDE, or choosing `/home`, `/tmp`, `/var` and other stuff). I just directly, got my CentOS up and running. Any one know how can I get this installation steps?


title: What makes OSX programs not runnable on Linux?

text: I know there are many differences between OSX and Linux, but what makes them so totally different, that makes them fundamentally incompatible?


title: How do free software companies make money?

text: How do companies that provide free (as in beer) software make money? I'm thinking of things like Linux distros, as some even provide free overseas shipping!


title: Ubuntu Desktop lost

text: On my Ubuntu 10.10 system, after configuring an external CRT to clone my desktop over S-Video, I've lost my desktop icon and right clicking on it does not show the menu or the menu bar. I've tried to resolve this with following commands:               sudo apt-get install ubuntu-desktop     sudo apt-get install gnome-panel     sudo chown -R $ USER: $ USER /Scrivania      Using the following sequence of commands I've gotten the main menu back, but nothing I have found so far will get back my desktop:               mkdir ~/.oldpanel     mv ~/.gconf/apps/panel ~/.oldpanel     gconftool-2 --shutdown     pkill gnome-panel     sudo apt-get install --reinstall ubuntu-desktop      Have you any idea how to resolve my problem?


title: How to run a command inside screen such that you can get back to the command's parent shell?

text: What's the best way to run a command inside a screen session such that its parent shell can be accessed? I want to be able to restart it from within the same screen session. The best I've managed to come up with is the following:               $ cat mr-t.sh      #!/bin/bash          top     exec /bin/bash      and then:               screen -e'^\\\' -S top-in-screen ./mr-t.sh      Then, if top stops running, I'll at least get a new shell within the same screen session I can work with. This isn't very elegant, though, and I can't quite convince myself that the signal will reliably be sent to the right process if I hit C-c. Moreover, C-z doesn't work at all. I'm using bash 3.2.48 on OSX and 3.2.39 on Linux. Both are probably patched by OS vendors. There's nothing special about the `top` command here, of course. [As an aside, `-e'^\\\\\'` reassigns the Magick Screen Key from C-a (a bad default if there ever was one) to C-\.]


I'm running Arch with 3.6.10 kernel, When vboxpci module is loaded, it tells me `vboxpci: IOMMU not found (not registered)`, But I checked my kernel config, I have the INTEL_IOMMU set already (I uses a Thinkpad X220)               CONFIG_GART_IOMMU=y     # CONFIG_CALGARY_IOMMU is not set     CONFIG_IOMMU_HELPER=y     CONFIG_IOMMU_API=y     CONFIG_IOMMU_SUPPORT=y     # CONFIG_AMD_IOMMU is not set     CONFIG_INTEL_IOMMU=y     CONFIG_INTEL_IOMMU_DEFAULT_ON=y     CONFIG_INTEL_IOMMU_FLOPPY_WA=y     # CONFIG_IOMMU_STRESS is not set      Kernel command: > BOOT_IMAGE=/boot/vmlinuz-linux root=/XX processor.ignore_ppc=1 apparmor=1 > security=apparmor intel_iommu=on Any suggestions? Althrough VBox starts, but still wondering why.


title: High availibility setup with NFS

text: ### Web hosting HA setup I have 5 servers:               Server-1:     Webhosting Controlpanel (192.168.1.1)     Server-2:     Load balancer [Haproxy] (Public IP:192.168.1.2 and                    Virtual IP:192.168.1.3)     Server-3 & 4: Data Servers Mounted data from NFS so data is same on                    each server i.e /home (192.168.1.4, 192.168.1.5)     Server-5 :    NFS Server (192.168.1.6) shared directory /home      My problem is I'm not able to mount `/home` from virtual IP of "load balancer". I don't know how to configure HAproxy to access shared folders from servers. I can access the mounted directories `/home` from servers directly but I want to mount the `/home` by load balancer so that I have some HA setup. **NOTE** Load balancer is working for Apache I can see the Apache default page loading from virtual IP of the load balancer. Here is a model image of setup:           ![ss of image](http://i.stack.imgur.com/ozQcx.png)


title: Adding a file to /etc of initramfs in Debian Wheezy

text: I have added the file `/etc/initramfs-tools/etc/motd` so that it would be available in /etc of the initramfs environment. However, it does not turn up. This is my second try where I gave the file all permissions available (I've also used 600):               root@cow:~# ls -l /etc/initramfs-tools/etc/     total 8     drwx------ 2 root root 4096 Sep 19 00:57 dropbear     -rwxrwxrwx 1 root root  117 Sep 29 15:32 motd      After that I `sudo update-initramfs -u`, boot into the initramfs environment and log in through SSH via Dropbear, and the file is still not there:               ~ # ls -l /etc     total 20     -rw-------    1 root     0             4077 Sep 29 13:44 boottime.kmap.gz     drwx------    2 root     0                0 Sep 29 13:44 dropbear     -rw-r--r--    1 root     0             1991 Sep 29 13:44 ld.so.cache     -rw-r--r--    1 root     0               34 Sep 18 17:24 ld.so.conf     drwxr-xr-x    2 root     0                0 Sep 18 17:25 ld.so.conf.d     drwx------    2 root     0                0 Sep 29 13:44 lvm     drwx------    2 root     0                0 Sep 29 13:44 mdadm     drwx------    2 root     0                0 Sep 29 13:44 modprobe.d     -rw-------    1 root     0               15 Sep 29 13:44 nsswitch.conf     -rw-------    1 root     0               30 Sep 29 13:44 passwd     drwx------    2 root     0                0 Sep 29 13:44 udev      How should I add it? Why didn't the above way work?


title: How to find which Process is causing High CPU usage

text: Is there any way to find out from terminal which process is causing high CPU Usage ? It would also be useful to order processes in descending order of cpu Usage


title: PPPD hangs, running over console port

text: I am trying to run the PPP daemon on the console port of my board which has p2020 processor with Linux kernel 2.6.32. After running ppp interface ppp0 is not coming up and I get an error `pppd blocked for more than 120 sec`. I am not able to debug this. How can I prevent this error from occurring? syslog output given below.               INFO: task pppd:2957 blocked for more than 120 seconds.     "echo 0 > /proc/sys/kernel/hung_task_timeout_secs" disables this message.     pppd D 0fe61c98 0 2957 2953 0x00000002     Call Trace:     [eec93d10] [c021ace4] n_tty_set_termios+0x3f8/0x59c (unreliable)     [eec93dd0] [c0007920] __switch_to+0x54/0xb0     [eec93de0] [c0381e8c] schedule+0x1f0/0x2f8     [eec93e20] [c021f308] tty_ldisc_ref_wait+0x6c/0xb0     [eec93e60] [c0218888] tty_ioctl+0x13c/0x9dc     [eec93e90] [c00b0aa4] vfs_ioctl+0x34/0x8c     [eec93ea0] [c00b0cc8] do_vfs_ioctl+0x88/0x72c     [eec93f10] [c00b13ac] sys_ioctl+0x40/0x74     [eec93f40] [c000f998] ret_from_syscall+0x0/0x3c     INFO: task pppd:2957 blocked for more than 120 seconds.     "echo 0 > /proc/sys/kernel/hung_task_timeout_secs" disables this message.     pppd D 0fe61c98 0 2957 2953 0x00000002


title: Alsaaudio module, recording for specific amount of time

text: The below code records the audio for some time (I don't know how much) How to calculate the total time of its recording? For example, if I want to record for just one minute then how would I limit its time?               #!/usr/bin/env python          ## recordtest.py     ##     ## This is an example of a simple sound capture script.     ##     ## The script opens an ALSA pcm forsound capture. Set     ## various attributes of the capture, and reads in a loop,     ## writing the data to standard out.     ##     ## To test it out do the following:     ## python recordtest.py out.raw # talk to the microphone     ## aplay -r 8000 -f S16_LE -c 1 out.raw               # Footnote: I'd normally use print instead of sys.std(out|err).write,     # but we're in the middle of the conversion between python 2 and 3     # and this code runs on both versions without conversion          import sys     import time     import getopt     import alsaaudio          def usage():         sys.stderr.write('usage: recordtest.py [-c <card>] <file>\n')         sys.exit(2)          if __name__ == '__main__':              card = 'sysdefault:CARD=Device'              opts, args = getopt.getopt(sys.argv[1:], 'c:')         for o, a in opts:             if o == '-c':                 card = a              if not args:             usage()              f = open(args[0], 'wb')              # Open the device in nonblocking capture mode. The last argument could         # just as well have been zero for blocking mode. Then we could have         # left out the sleep call in the bottom of the loop         inp = alsaaudio.PCM(alsaaudio.PCM_CAPTURE, alsaaudio.PCM_NONBLOCK, card)              # Set attributes: Mono, 44100 Hz, 16 bit little endian samples         inp.setchannels(1)         inp.setrate(44100)         inp.setformat(alsaaudio.PCM_FORMAT_S16_LE)              # The period size controls the internal number of frames per period.         # The significance of this parameter is documented in the ALSA api.         # For our purposes, it is suficcient to know that reads from the device         # will return this many frames. Each frame being 2 bytes long.         # This means that the reads below will return either 320 bytes of data         # or 0 bytes of data. The latter is possible because we are in nonblocking         # mode.         inp.setperiodsize(160)              loops = 1000000         while loops > 0:             loops -= 1             # Read data from device             l, data = inp.read()                  if l:                 f.write(data)                 time.sleep(.001)


title: How do I get the DISTRIB_CODENAME?

text: Which is the shortest way to get the variable `$DISTRIB_CODENAME` from `/etc/lsb-release`? I want to make this somewhat shorter:               $ sudo add-apt-repository \       "deb http://some-repo/ubuntu $(grep CODENAME lsb-release |sed s/^.*=//g) main"


title: understanding ps -ef output

text: root@he:/home/he# ps -ef|grep init     root         1     0  0 08:40 ?        00:00:02 /sbin/init     root      3557  3545  0 10:09 pts/0    00:00:00 grep --color=auto init      What are various columns representing here?


title: Track down process that has notty

text: I have a Linux server (Red Hat 2.6 kernel) which had a spike in load due to an Rsync process which seems to have forked many times, but the process was run by rsyncuser@notty I didnt see any cron job scheduled for that time with an rsync that is run under that name, and I assume if there were it would have a tty. How do I track down what the actual command which caused these processes was?


title: I just want to install a package!

text: I spent a few hours trying to install a package and didn't succeed; it seems like that just happens sometimes in a Linux environment. Background: The package I want to install is available as 1) a `.deb` for x86 instead of x64, 2) a `.Run`, 3) source, and 4) an OSX installer. The OSX installer just works. On a fresh install of Debian 7, I have tried the `.deb`, the `.Run`, and compiling from source. All three led me through a series of hoops. The most basic problems appear to be that via any of these routes Debian 7 gave me too old a version of `LibC` and too old a version of `Ocaml`. Most of my time was spent executing one apt-get command after another trying to resolve dependencies. Question: What are some tools that make it easier to install packages by automating as much of the process as possible? All packages, even building from source, make it clear which versions of which dependencies they require, right? So why can't all the dependencies just be resolved automatically? I would be happy to even just make a directory on my system that contains a copy of every single dependency that my package requires so that it can run in its own little environment without modifying the versions of other packages on my system; I'm not sure if that's possible. I'm positive there must be SOME way to just say "give me the package called Foo, version 4.2.3" and have everything else done for me.


title: iptables rule to allow access to internet

text: I made default policy of my machine-               iptables -A INPUT -j REJECT #DROP ALL PACKETS TO INPUT CHANNEL      INPUT channel has been blocked. Now I want to allow only some specific services like I should be able to access the internet. So what rule should I add? Port 80 is for HTTP so I tried allowing that port by               iptables -A INPUT -p tcp --dport 80 ACCEPT      But it didn't work. Let me know how can I do this?


title: How Do I Block Read Access to a Symbolic Link?

text: I have this file structure:               > APPLICATION 1     >> CONTROLLER (@JuniorProgrammers)     >> MODELS (symlink to SHARED/MODELS)     >> VIEWS (@Designers)     > APPLICATION 2     >> CONTROLLER (@JuniorProgrammers)     >> MODELS (symlink to SHARED/MODELS)     >> VIEWS (@Designers)     > SHARED     >> MODELS (@SeniorProgrammers)      I need php to be able to read Folder 1.1 contents, but programmers who FTP into Folder 1 won't be able to read the symlink (they CAN see the symlink, but not FOLLOW it including all reads, and writes). The @ is the groups of users that have read/write access of each layer.


title: Why shouldn't someone use passwords in the command line?

text: Why do people fear writing passwords in the command line? The history file is located in `~/.history`, so it's available only to the user who executed the commands (and root).


title: enable IST timezone in puppet

text: I'm trying to run below Puppet manifest to set 'IST' timezone.               class { 'timezone':       timezone => 'IST',     }      When I run Puppet apply `timezone.pp`, it installs properly. But when I check the system date, It's the same as before. I don't see any change in timezone. Also when I change IST to PST or some other timezone, it works properly. Only IST is not working for me. I had installed timezone Puppet module and kept it in `/etc/puppet/module` directory. What am I missing?


title: CentOS(6.3) Gnome Desktop Environment does not respond!

text: After starting the Gnome desktop on CentOS (version 6.3), I was able to see everything (the desktop icons, time and date, the upper titles for Applications, system, and so on). But, when I try to click on any of them, there is no response! The mouse pointer just blinks and changes as if something is going to open, but nothing happens--everything remains as it is. Any Suggestions?


title: Using `kill -s 0 $pid` vs `[[ -e /proc/$pid ]]` to detect if PID is running

text: One of the idioms often used to check if process is running is to use `kill -s 0 $pid`. My question is, does it have any upsides over using `[[ -e /proc/$pid ]]` construct? The script I'm writing is both Linux and bash specific.


title: Unable to log into Heroku: syntax error, unexpected

text: I'm new to Heroku. After downloading the script and installing I get an error when I try to login:               $ wget -qO- https://toolbelt.heroku.com/install.sh | sh      This script requires superuser access to install software. You will be prompted for your password by sudo.               [sudo] password for <user>:     Add the Heroku CLI to your PATH using:     $ echo 'PATH="/usr/local/heroku/bin:$PATH"' >> ~/.profile     Installation complete     $ echo 'PATH="/usr/local/heroku/bin:$PATH"' >> ~/.bash_profile     $ export PATH     $ /usr/local/heroku/bin/heroku login          /usr/local/heroku/lib/heroku/command/addons.rb:2:in `require': /usr/local/heroku/lib/heroku/helpers/heroku_postgresql.rb:136: syntax error, unexpected '.', expecting kEND (SyntaxError)         .detect{ |k,v| k != 'DATABASE_URL' && v == primary_db_url }          ^         from /usr/local/heroku/lib/heroku/command/addons.rb:2         from /usr/local/heroku/lib/heroku/command.rb:14:in `require'         from /usr/local/heroku/lib/heroku/command.rb:14:in `load'         from /usr/local/heroku/lib/heroku/command.rb:13:in `each'         from /usr/local/heroku/lib/heroku/command.rb:13:in `load'         from /usr/local/heroku/lib/heroku/cli.rb:36:in `start'         from /usr/local/heroku/bin/heroku:24      I think either a library or ruby gem is missing but I'm not sure which one. Any pointing in the right direction is welcome.


title: Recover my history of past commands?

text: Always when I turn on my Fedora 18, my history command disappear. How can I recovery all my history since I installed my OS? In my ./bash_history show olny the command of the day when I turn off my PC disappear all my past command in ./bash_history.


title: Why is yum trying to go through a proxy and other strange behaviors?

text: I occasionally setup an SSH tunnel proxy to make it seem like I'm using the internet from another location. I set it up with:               ssh -D 8080 <remote host>      and the use the gnome shell Network settings dialog to set the proxy to `http://localhost:8080`. Currently the proxy is set to None, and my `ssh` connection is disconnected. My internet browsing is working fine. However **I cannot use`yum`**:               [root@Eiger yum.repos.d]# yum update     Loaded plugins: langpacks, refresh-packagekit     http://linuxdownload.adobe.com/linux/x86_64/repodata/repomd.xml: [Errno 14] curl     #7 - "Failed connect to localhost:8080; Connection refused"     Trying other mirror.        <repeated 9 more times>           One of the configured repositories failed (Adobe Systems Incorporated),      and yum doesn't have enough cached data to continue. At this point the only      safe thing yum can do is fail. There are a few ways to work "fix" this:               1. Contact the upstream for the repository and get them to fix the problem.               2. Reconfigure the baseurl/etc. for the repository, to point to a working             upstream. This is most often useful if you are using a newer             distribution release than is supported by the repository (and the             packages for the previous distribution release still work).               3. Disable the repository, so yum won't use it by default. Yum will then             just ignore the repository until you permanently enable it again or use             --enablerepo for temporary usage:                      yum-config-manager --disable adobe-linux-x86_64               4. Configure the failing repository to be skipped, if it is unavailable.             Note that yum will try to contact the repo. when it runs most commands,             so will have to try and fail each time (and thus. yum will be be much             slower). If it is a very temporary problem though, this is often a nice             compromise:                      yum-config-manager --save --setopt=adobe-linux-x86_64.skip_if_unavailable=true          failure: repodata/repomd.xml from adobe-linux-x86_64: [Errno 256] No more mirrors to try.     http://linuxdownload.adobe.com/linux/x86_64/repodata/repomd.xml: [Errno 14] curl     #7 - "Failed connect to localhost:8080; Connection refused"        <repeated 9 more times>      If I disable the `adobe-linux` repo, then it simply says:               [root@Eiger yum.repos.d]# yum update     Loaded plugins: langpacks, refresh-packagekit                One of the configured repositories failed (Unknown),      and yum doesn't have enough cached data to continue. At this point the only      safe thing yum can do is fail. There are a few ways to work "fix" this:               1. Contact the upstream for the repository and get them to fix the problem.               2. Reconfigure the baseurl/etc. for the repository, to point to a working             upstream. This is most often useful if you are using a newer             distribution release than is supported by the repository (and the             packages for the previous distribution release still work).               3. Disable the repository, so yum won't use it by default. Yum will then             just ignore the repository until you permanently enable it again or use             --enablerepo for temporary usage:                      yum-config-manager --disable <repoid>               4. Configure the failing repository to be skipped, if it is unavailable.             Note that yum will try to contact the repo. when it runs most commands,             so will have to try and fail each time (and thus. yum will be be much             slower). If it is a very temporary problem though, this is often a nice             compromise:                      yum-config-manager --save --setopt=<repoid>.skip_if_unavailable=true          Cannot retrieve metalink for repository: fedora/19/x86_64. Please verify its path and try again      It's weird that **it doesn't know the name of the repository that is failing** the second time. It's also weird that **it doesn't try any of the other repositories that I have configured** (fedora, fedora-updates, google-chrome, google-talkplugin, insync, intellinuxgraphics, rpmfusion-free, rpmfusion-free- updates, rpmfusion-nonfree, rpmfusion-nonfree-updates). This has been working for over a year and I haven't touched `/etc/yum*`. * * * I put my computer to sleep and woke it up a day later. **Now everything is working as normal.** I have no explanation for the behavior seen yesterday but I can no longer reproduce it.


title: Find out what 'apt-get install' did

text: This might be a really newbie question but here we go: How can I find out what commands a package ran to install the software with `apt-get install <package>`? For example, if I install a package that creates a user, how can I find out how it created that user?


title: Ubuntu server cannot access the Internet: appears DNS related

text: This is a Drupal website running Ubuntu 12.04 LTS on Linode. The server is just a website. It is not a DNS server or anything else. Here are my issues. It seems they are all related to DNS issues. (I've been troubleshooting this with Linode for a couple days and I also got help here regarding iptables. Now I can focus on the issues in this question.)   1. Our Mollom spam protection is not working on the Drupal site because the server cannot reach the external service. (more details below)   2. Drupal reports, "Your system or network configuration does not allow Drupal to access web pages, resulting in reduced functionality." (more details below - our Drupal config did not change)   3. the server cannot ping the Internet  ping google.com   ping: unknown host google.com   4. Other network services fail. For example: $ sudo ntpdate ntp.ubuntu.com Exiting, name server cannot be used: Temporary failure in name resolution (-3) 1 Jun 16:42:34 ntpdate[7420]: name server cannot be used: Temporary failure in name resolution (-3)   apt-get update Err http://us.archive.ubuntu.com precise Release.gpg   Temporary failure resolving 'us.archive.ubuntu.com' Err http://security.ubuntu.com precise-security Release.gpg   Temporary failure resolving 'security.ubuntu.com'   5. The server is running very poorly. Could errors like the following one be related to inability to access the Internet? Out of memory: Kill process 2300 (mysqld) score 129 or sacrifice child Killed process 2300 (mysqld) total-vm:354780kB, anon-rss:53180kB, file-rss:0kB Out of memory: Kill process 5937 (mysqld) score 60 or sacrifice child Killed process 5937 (mysqld) total-vm:344040kB, anon-rss:78988kB, file-rss:0kB Here are the Drupal errors in more detail. Drupal configuration was not changed before these errors started (afaik). 1. HTTP request status Fails Your system or network configuration does not allow Drupal to access web pages, resulting in reduced functionality. This could be due to your webserver configuration or PHP settings, and should be resolved in order to download information about available updates, fetch aggregator feeds, sign in via OpenID, or use other network-dependent services. If you are certain that Drupal can access web pages but you are still seeing this message, you may add $conf['drupal_http_request_fails'] = FALSE; to the bottom of your settings.php file. 2. Mollom API keys Service error The Mollom API keys could not be verified. Please try again later. This issue prevents members from registering for our site or posting comments. Here is the information I think may be relevant:               root@example1:/etc# cat /etc/resolv.conf     # Dynamic resolv.conf(5) file for glibc resolver(3) generated by resolvconf(8)     #     DO NOT EDIT THIS FILE BY HAND -- YOUR CHANGES WILL BE OVERWRITTEN     nameserver 789.456.123.6     nameserver 789.456.123.7          root@example1:/etc# cat /etc/hosts     #127.0.0.1      localhost     127.0.1.1       example1.local          example1     192.168.150.8   example1                example1     123.456.789.55  example1.example.com    example1        www.example.com          root@example1:/etc# cat /etc/nsswitch.conf     # /etc/nsswitch.conf     #     # Example configuration of GNU Name Service Switch functionality.     # If you have the `glibc-doc-reference' and `info' packages installed, try:     # `info libc "Name Service Switch"' for information about this file.          passwd:         compat     group:          compat     shadow:         compat          hosts:          files dns     networks:       files          protocols:      db files     services:       db files     ethers:         db files     rpc:            db files          netgroup:       nis               root@example1:/etc# route -n     Kernel IP routing table     Destination     Gateway         Genmask         Flags Metric Ref    Use Iface     0.0.0.0         123.456.789.1   0.0.0.0         UG    100    0        0 eth0     123.456.789.0   0.0.0.0         255.255.255.0   U     0      0        0 eth0     192.168.100.0   0.0.0.0         255.255.128.0   U     0      0        0 eth0               root@example1:/etc# cat /etc/network/interfaces     # The loopback network interface     auto lo     iface lo inet loopback     # This line ensures that the interface will be brought up during boot.     auto eth0 eth0:0          iface eth0 inet static      address 123.456.789.55      netmask 255.255.255.0      gateway 123.456.789.1      dns-nameservers 789.456.123.6 789.456.123.7          # eth0:0 - Private IPs have no gateway (they are not publicly routable) so all you need to specify is the address and netmask.     iface eth0:0 inet static      address 192.168.150.8      netmask 255.255.128.0          root@example1:/etc# ip addr     1: lo: <LOOPBACK,UP,LOWER_UP> mtu 65536 qdisc noqueue state UNKNOWN          link/loopback 00:00:00:00:00:00 brd 00:00:00:00:00:00         inet 127.0.0.1/8 scope host lo            valid_lft forever preferred_lft forever         inet6 ::1/128 scope host             valid_lft forever preferred_lft forever     2: dummy0: <BROADCAST,NOARP> mtu 1500 qdisc noop state DOWN          link/ether 76:49:bf:95:98:68 brd ff:ff:ff:ff:ff:ff     3: eth0: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc pfifo_fast state UP qlen 1000         link/ether xx:xx:xx:xx:xx:xx brd ff:ff:ff:ff:ff:ff         inet 192.168.150.8/17 brd 192.168.255.255 scope global eth0:0            valid_lft forever preferred_lft forever         inet 123.456.789.55/24 brd 123.456.789.255 scope global eth0            valid_lft forever preferred_lft forever         inet6 1000:aaaa::aaaa:aaaa:aaaa:aaa/64 scope global dynamic             valid_lft 2591730sec preferred_lft 604530sec         inet6 fe80::aaaa:aaa:fffff:ffff/64 scope link             valid_lft forever preferred_lft forever     4: teql0: <NOARP> mtu 1500 qdisc noop state DOWN qlen 100         link/void      5: tunl0: <NOARP> mtu 1480 qdisc noop state DOWN          link/ipip 0.0.0.0 brd 0.0.0.0     6: gre0: <NOARP> mtu 1476 qdisc noop state DOWN          link/gre 0.0.0.0 brd 0.0.0.0     7: sit0: <NOARP> mtu 1480 qdisc noop state DOWN          link/sit 0.0.0.0 brd 0.0.0.0     8: ip6tnl0: <NOARP> mtu 1452 qdisc noop state DOWN          link/tunnel6 :: brd ::     9: ip6gre0: <NOARP> mtu 1448 qdisc noop state DOWN          link/[823] 00:00:00:00:00:00:00:00:00:00:00:00:00:00:00:00 brd 00:00:00:00:00:00:00:00:00:00:00:00:00:00:00:00               root@example1:/etc# ifconfig     eth0      Link encap:Ethernet  HWaddr xx:xx:xx:xx:xx:xx                 inet addr:123.456.789.55  Bcast:123.456.789.255  Mask:255.255.255.0               inet6 addr: 1000:aaaa::aaaa:aaaa:aaaa:aaa/64 Scope:Global               inet6 addr: fe80::aaaa:aaa:fffff:ffff/64 Scope:Link               UP BROADCAST RUNNING MULTICAST  MTU:1500  Metric:1               RX packets:66713 errors:0 dropped:0 overruns:0 frame:0               TX packets:54198 errors:0 dropped:0 overruns:0 carrier:0               collisions:0 txqueuelen:1000                RX bytes:7588512 (7.5 MB)  TX bytes:67678447 (67.6 MB)               Interrupt:77           eth0:0    Link encap:Ethernet  HWaddr xx:xx:xx:xx:xx:xx                 inet addr:192.168.150.8  Bcast:192.168.255.255  Mask:255.255.128.0               UP BROADCAST RUNNING MULTICAST  MTU:1500  Metric:1               Interrupt:77           lo        Link encap:Local Loopback                 inet addr:127.0.0.1  Mask:255.0.0.0               inet6 addr: ::1/128 Scope:Host               UP LOOPBACK RUNNING  MTU:65536  Metric:1               RX packets:13579 errors:0 dropped:0 overruns:0 frame:0               TX packets:13579 errors:0 dropped:0 overruns:0 carrier:0               collisions:0 txqueuelen:0                RX bytes:852371 (852.3 KB)  TX bytes:852371 (852.3 KB)          root@example1:/etc#       Here's more info:               # ping -n 789.456.123.7     PING 789.456.123.7 (789.456.123.7) 56(84) bytes of data.     64 bytes from 789.456.123.7: icmp_req=1 ttl=63 time=2.46 ms     64 bytes from 789.456.123.7: icmp_req=2 ttl=63 time=1.80 ms     ^C     --- 789.456.123.7 ping statistics ---     2 packets transmitted, 2 received, 0% packet loss, time 1001ms     rtt min/avg/max/mdev = 1.802/2.132/2.462/0.330 ms          ping -n 173.194.37.100 (NOTE: this is google.com)     PING 173.194.37.100 (173.194.37.100) 56(84) bytes of data.     64 bytes from 173.194.37.100: icmp_req=1 ttl=55 time=14.2 ms     64 bytes from 173.194.37.100: icmp_req=2 ttl=55 time=14.1 ms     64 bytes from 173.194.37.100: icmp_req=3 ttl=55 time=14.5 ms     ^C     --- 173.194.37.100 ping statistics ---     3 packets transmitted, 3 received, 0% packet loss, time 2002ms     rtt min/avg/max/mdev = 14.188/14.325/14.513/0.168 ms      And more info:               root@example1:/etc# dig google.com     ; <<>> DiG 9.8.1-P1 <<>> google.com     ;; global options: +cmd     ;; connection timed out; no servers could be reached          root@example1:/etc# dig www.google.com @8.8.8.8     ; <<>> DiG 9.8.1-P1 <<>> www.google.com @8.8.8.8     ;; global options: +cmd     ;; connection timed out; no servers could be reached          root@example1:/etc# ping 8.8.8.8     PING 8.8.8.8 (8.8.8.8) 56(84) bytes of data.     64 bytes from 8.8.8.8: icmp_req=1 ttl=51 time=1.05 ms     64 bytes from 8.8.8.8: icmp_req=2 ttl=51 time=1.08 ms     --- 8.8.8.8 ping statistics ---     2 packets transmitted, 2 received, 0% packet loss, time 1001ms     rtt min/avg/max/mdev = 1.058/1.073/1.089/0.036 ms          root@example1:/etc# traceroute google.com     google.com: Temporary failure in name resolution     Cannot handle "host" cmdline arg `google.com' on position 1 (argc 1)          # The following lines are desirable for IPv6 capable hosts     ::1     ip6-localhost ip6-loopback     fe00::0 ip6-localnet     ff00::0 ip6-mcastprefix     ff02::1 ip6-allnodes     ff02::2 ip6-allrouters      Although I cannot reach the Ubuntu repos to install software the usual way, I downloaded nmap locally and then copied the deb package to the server using SCP. Here are the results of `nmap -sS -sU -p 53`:               Host is up (0.00085s latency).     PORT   STATE SERVICE     53/tcp open  domain     53/udp open  domain


I am using RHEL 6.0 and when i type the given command in terminal               telnet 127.0.0.1 6000      I am getting output as:               Trying 127.0.0.1...     telnet: connect to address 127.0.0.1: Connection refused      Why is this connection refusing?


title: What is the difference between Kali Linux minimal and normal?

text: Generally the minimal versions of distros come with a fewer selection of packages. Is this the same for Kali Linux minimal? What packages will be missing from the minimal installation? Is there a site where the packages are listed?


title: How do I disable a keyboard shortcut in gnome-shell?

text: There are tutorials all over the web on how to set various functionalities to activate on a keyboard shortcut, but so far I'm unable to figure out how to _un-set_ a keyboard shortcut. That is, how do I set a keyboard shortcut to _disabled_ once I've already set it to something else? For example, say I want to change the keyboard shortcut for "Launch Terminal". I go into _System Settings_ , select _Keyboard > Shortcuts_ and under _Launchers_ , next to _Launch Terminal_ I click on the word `Disabled` which then changes to `New shortcut`. I hit `Ctrl+t` or something like that and now the shortcut is set. How now do I change it back to `Disabled`?


title: Pass a Function to another user in Bash?

text: Is there any way that I can pass a Function from one user to another user? For example, I have a small Bash script that I execute as Root:               #!/bin/bash     user_func(){       whoami       exit     }     su vagrant -c 'user_func'      However, the user_func Function isn't defined for the Vagrant user, only for Root, and can't be executed. My other option would be to have multiple lines of               su vagrant -c 'cmd1'      su vagrant -c 'cmd2'     , etc       Or, execute multiple commands ex: `su vagrant -c 'cmd1; cmd2; cmd3;'`, but I'd prefer to not have the excess, especially when attempting to execute more than 5 commands as the Vagrant user. Is it possible to pass a Function to another user from within the same script (ex. not creating a script on disk as a different user and then executing that generated script)? Or is there another option that I am overlooking?


title: Benefits of rpm over deb in the context of a server?

text: This related question What are the pros/cons of deb vs. rpm? seems to be more focused on personal computers, but in the context of a server, why do most of the servers run either RedHat / CentOS or SUSE? Is there any notable improvement of rpm over deb? Or is it just because they are products provided by a company rather than a community?


title: How to backup (make a copy of) LiveCD changes?

text: Many LiveCD distributions (for example Lubuntu 12.10 I use) allow making changes, for example updating timezone, logging in to Google Chrome, updating and installing additional packages such as OpenVPN. They do that by overlaying read-write filesystem, in my case RAM-based tmpfs (or ramdisk, or ramfs, or USB pendrive), over CD-ROM based filesystem, in my case system image via squashfs but might be iso9660 or udf directly, using some union filesystem, in my case overlayfs (or unionfs, or aufs). I'd like to make copy of changes (e.g. using `dd`) and only changes of an existing running LiveCD (e.g. Lubuntu 12.10) and I don't want to make copy of whole '/' mountpoint, including both changes and original CD-ROM. How can I find device or mountpoint which I can point e.g. `dd` to? `mount` shows the following (excerpt):               /cow on / type overlayfs (rw)     tmpfs on /run type tmpfs (rw,noexec,nosuid,size=10%,mode=0755)     /dev/sr0 on /cdrom type iso9660 (ro,noatime)     /dev/loop0 on /rofs type squashfs (ro,noatime)     tmpfs on /tmp type tmpfs (rw,nosuid,nodev)     none on /run/lock type tmpfs (rw,noexec,nosuid,nodev,size=5242880)     none on /run/shm type tmpfs (rw,nosuid,nodev)     none on /run/user type tmpfs (rw,noexec,nosuid,nodev,size=104857600,mode=0755)      * * * _Original question_ : Persisting changes on Lubuntu 12.10 run from LiveCD on _Ask Ubuntu_ (no answers as of posting this one).


title: Writing a Kernel from scratch

text: I'm not sure whether it's the right place for this question. I am writing a kernel from scratch and want links or tutorials where I can get a few pointers.


title: Keeping the number of files in the folder constant by deleting old files

text: I'm trying to create a script and run it in crontab every 5 min, so that the number of files in a folder always remain 50000. If there are more, I want the script to delete the old files.               #!/bin/bash     LIMIT=500000     NO=0     #Get the number of files, that has `*.pcap` in its name, with last modified time 5 days     ago          NUMBER=$(find /mnt/md0/capture/DCN/ -maxdepth 1 -name "*.pcap" |wc -l)     if [[ $NUMBER -gt $LIMIT ]]  #if number greater than limit      then       del=$(($NUMBER-$LIMIT))        if [ "$del" -lt "$NO" ]         then          del=$(($del*-1))        fi        echo $del        FILES=$(          find /mnt/md0/capture/DCN/ -maxdepth 1 -type f -name "*.pcap" -print0 |            xargs -0 ls -lt |            tail -$del |            awk '{print $8}'        )       rm -f ${FILES[@]}       #delete the originals           fi      It doesn't really work, it doesn't run as the number of files are too large. Is there any other method to get this done?


title: Integrating LDAP and Kerberos V to add users via a useradd-like interface

text: I'm currently trying to set up an integrated Kerberos V/LDAP system for authentication/authorization. From what I have managed to gather, there are at least two ways to integrate Kerberos V with LDAP:   1. Use LDAP as a backend to store Kerberos principals   2. User Kerberos and SASL authentication via GSSAPI to authenticate to the LDAP server (to be able to query and modify the LDAP entries using a Kerberos ticket) The two options aren't mutually exclusive. The thing is, I would like to make a hybrid of the two: not just use LDAP to store Kerberos principals, but also make sure that when I add a Kerberos principal, it's created with `objectClass=posixAccount` in order for it to appear as a Unix user entry to NSS for authorization purposes. To paraphrase, I would like to have to add new user accounts in only one place ( _viz._ , the `kadmin` server) instead of two. Is this possible? If so, how? If it's any help, I'm using OpenLDAP and MIT Kerberos on Debian Wheezy.


title: Set global environment variables at boot in Solaris 11

text: I am wanting to create a file in Solaris, so that I can export a few "items" whenever the machine is started up. i.e. I want to export ORACLE_HOME and ORACLE_SID and some other directories, of my own, when the machine has started up. These are the 2 Oracle folders I need to export:               export ORACLE_HOME=/oracle/product/11.1.0/db_1/     export ORACLE_SID=orcl      This is the other folder I need to export of my own:               export TESTFOLDER_DIR=/test/testfolder/bin/      It is highly irritating that I have to do it every time the machine has started up. I have tried Googling it, but I have not seen anything yet (still searching). It is easy to make the file with the export commands, but to put it somewhere that the machine will know to use them in startup, is the issue. Is there a way I could do it?


title: Disable RAID auto detect at runtime

text: In Linux, I'm partitioning two disks for RAID1 with fdisk. The first disk partitioning succedes, but the second fail because the raid starts automatically and occupy also the second disk (why? it should have a different UUID). How to temporary disable RAID autodetect? I guess there's a switch under `/proc/sys` filesystem. I know it's possible to solve the problem in other ways, like removing RAID information from the disks with `mdadm --zero-superblock` but I want to know if it's possible to disable RAID autodetect without rebooting the system with `raid=noautodetect nomdadm` in kernel parameters.


title: Moving Same files from different folders using shell script on AIX 5.4

text: There are two folders named Folder1 and Folder2. Folder1 has files with name:For example S-080001-0-0.xml with its corresponding same files in Folder2 named S-080001-0-0.xml The change in Folder2 is that,for same file in Folder1 which is S-080001-0-0.xml,Folder 2 contains multiple files with different value after hyphen,like -080001-0-0.xml,-080001-0-1.xml,-080001-0-2.xml,-080001-0-3.xml. My challenge is to move all the files of same name from these two folders.


title: Xen: Migrating LVM-based machines from Xen Opensource to Xen Cloud Platform

text: we have several LVM-based VMs running on a Xen Opensource host. "LVM-based", in our case, means that there's a LVM volume for the root partition and another volume for the swap partition. The kernel and the initrd for the VM are outside of these volumes, as files in the Xen host. These VMs were created with xen-create-image, part of the xen-tools suite for Debian. We want to migrate these VMs to a XCP host, and we've found a script to do it (http://www.xen.org/files/xva/xva.py). But this script assumes that the disks listed in the configuration file are "virtual disks", ie., with their own partition table and stuff. This is not the case, obviously, and it doesn't work. What would you recommend to do this? Any homebrewn method? In the end, we could have to migrate the VMs by overwriting new ones with a big tar file from the old ones, but I'd like it to be our last resort. I thought that maybe we could create a disk like the one this script expects by using something that does the reverse of kpartx: instead of splitting a virtual disk into devices for each partition, bundle several partitions (or in our case, LVM volumes) in a virtual disk. But I don't know anything like that. Thanks in advance!


title: Extract a column from whitespace-separated fields that are not aligned

text: How can we extract a column from output in which whitespace is not in a regular format? For example, when we type `ps -ef`, it shows all the process, process id's.... etc. How can we get only the last column or any specific column?


title: How to install Linux on the Lego Mindstorms NXT

text: Has anybody ever successfully installed Linux on the Lego Mindstorms NXT Intelligent Brick? I've found plenty of things on Google, but none of them worked. I can't find the download for legOS, and the gcc I was told to download never actually built (although it spent over 5 minutes in an install script). There was no download page for NXC (Not Exactly C). NOTE: I have an Ubuntu Linux system, a Mac OSX Lion system, and access to Windows (although I would prefer to avoid Windows).


title: Vim unnamed register + or *

text: Im using Vim 7.3 in Ubuntu and I'm having a little problem copying to the system clipboard with the following command `"+y` but I'm getting the following error: `E354: Invalid register name: '+'` In my `vim --version`, I see `-xterm_clipboard`. The option to copy is from mouse right click is also grayed out. What steps do I need to take to enable the copying of text from my vim to the system clipboard?


title: Reduce eclipse tab size with GTK theming

text: In Eclipse on Fedora, these controls/widgets take up too much space: ![Eclipse Fedora screenshot](http://i.stack.imgur.com/qeFdT.png) How can I make those bars thinner with a `gtk-rc` file or GTK3 CSS theming? `UPDATED` : I found https://github.com/jeeeyul/eclipse-themes this plugin have some builtin configurations and options makes eclipse 4.2/4.3 much more nicer.


title: Linux: Kill process based on arguments

text: How can I kill a process based on its command line arguments? `killall`, `pgrep`, and `pkill` seem to only work based on the process name. I need this to be able to differentiate between a number of applications running inside Java virtual machines, where `java` is the process name for all of them and the actual application name can be found by looking at the command line arguments. This can be done manually with `ps aux | grep myapp.jar` and then manually killing the pid from the output, but I'd like a command to do something equivalent automatically.


title: How do I shut down a system through a ConsoleKit DBus message as user?

text: I found the following command line to shut down a Debian/GNU Linux system               dbus-send \       --system \       --dest=org.freedesktop.ConsoleKit \       --type=method_call \       --print-reply \       --reply-timeout=2000 \       /org/freedesktop/ConsoleKit/Manager \       org.freedesktop.ConsoleKit.Manager.Stop      It works if I execute the command as superuser, but as a non-privileged user it says:               Error org.freedesktop.ConsoleKit.Manager.NotPrivileged: Not Authorized      I would like to know if it is possible to modify such a command in such a way that, interacting with PolicyKit, it can grant the privilege to shut down the system to a normal user.


title: Finding a specific file in several sub-directories

text: I've the following problem : I have to write something to copy a file contained in directory A. The file is unique, and has a specific extension (.jil). Only problem, directory A can contains a sub-directory B (which can contain a sub-directory C, ...) and then my file won't be located in the directory A, but in one of his sub- directories. What command can I use to find this file without exploring all my directoties ?


title: Failed to get access to the Internet after disabling networkmanager on ArchLinux

text: How can I get access to the Internet after `networkmanager` is down? I disabled the `networkmanager` and uncommented the static IP settings I used to use and reboot, but I'm still unable to get access to the Internet. (Failed to `ping 8.8.8.8`, which means the problem isn't DNS.) Here's how this happened: I used to get access to the Internet on my ArchLinux machine by setting up a static IP address in `/etc/rc.conf`. This worked fine. Then one day I needed to do something difficult without a `networkmanager`, so I installed the `network-manager-applet` via `pacman`, which worked fine as well, until one day after I ran `pacman -Syu` and rebooted, many programs, including the `network-manager-applet` are unable to work, saying the system is missing `libpng14.so`. My workstation was connected to a wireless connection at that time (the same one before my last `pacman -Syu` and reboot), and I tried to run `pacman -Syu` again and the network seemed to still be working. So I didn't take it as a big problem at that time. But now, after I brought it to work (where I connect to the Internet via a wired network and a static IP), I found myself unable to get access again to the Internet, even after I removed `networkmanager` from the `DAEMONS` in `rc.conf`, and uncommented the static IP settings that used to work. And It's not DNS problems since I'm unable to `ping 8.8.8.8` or any other known IPs directly (it says `destination host is unreachable`). Here's my `rc.conf` files, the IP address and gateway stuff couldn't be wrong so hope you don't mind I use something like XX.XX.XX.XX instead:               LOCALE="en-US.UTF-8"     DAEMON-LOCALE="no"     HARDWARECLOCK="localtime"     TIMEZONE="Asia/Shanghai"     KEYMAP="us"     CONSOLEFONT=     CONSOLEMAP=     USECOLOR="yes"          MODULES=(wl)     UDEV_TIMEOUT=30     USEDMRAID="no"     USEBTRFS="no"     USELVM="no"          HOSTNAME="lastland"     interface=eth0     address=XX.XX.XX.XX     netmask=255.255.255.0     broadcast=XX.XX.XX.255     gateway=XX.XX.XX.XX          NETWORK_PERSIST="no"          DAEMONS = (syslog-ng network crond dbus kdm alsa)


title: Do I need acpid in a virtual machine?

text: I'm always wondering if power management facilities in a virtual machine is necessary? i.e acpid. And I'm not sure if they still function in a virtual machine.


title: Firefox error message when adding client certificate signed by CA

text: I'm getting this message when I'm trying to add a certificate to Firefox's "your certificate tab". I generated and signed it before by a server which also is a CA. > Failed to decode the file. Either it is not in PKCS #12 format, has been > corrupted, or the password you entered was incorrect. It asks me to enter a password and then this message is alerted. what's wrong? I'm following this tutorial. ### UPDATE #1 commands I used :                openssl genrsa -out rootCA.key 2048      openssl req -x509 -new -nodes -key rootCA.key -days 1024 -out rootCA.pem             openssl genrsa -out device.key 2048           openssl req -new -key device.key -out device.csr             openssl x509 -req -in device.csr -CA rootCA.pem \             -CAkey rootCA.key -CAcreateserial -out device.crt -days 500      The added certificate is device.crt, there's PKS12 which Firefox request on your certificates tab. Should I change its format?


title: Virtualbox kernel modules not loading at boot

text: I have been running virtualbox on an Ubuntu 12.04 laptop for a while and it has all worked smooth, but suddenly, probably after a kernel upgrade, the vbox* modules are not loading at boot, if I manually modprobe them, it all works fine, but that should not be needed ... Looking at the `/etc/init.d/virtualbox`, it seems as I should add `LOAD_VBOXDRV_MODULE=1` to `/etc/default/virtualbox`, but for other machines it works without that line... Any clues?


title: Blacklisting websites for certain users

text: This question is two part. First, If I had a list of websites that I would've liked to block. How do I tell my computer do to block those and any relevant subdomains? Secondly, How do I get this right on a per-user basis. For Example, telling the computer to block userA from accessing facebook should not block userB from facebook. Bonus points if the answer is a command-line one.


title: Does the Fedora installer not include default URLs for installation mirrors?

text: I installed Fedora 14 using a slightly non-standard method, i.e. loading the install media vmlinuz/initrd.img files via an existing grub2 instance. (I fetched them from a mirror). The installer works fine, but I was a little bit surprised that after selecting the network install route I had to manually enter the URL of a FC14 mirror. Luckily, I am having a secondary computer with network access available for looking up mirror URLs. Does the FC14 not include any default install mirror urls? Or am I missing something?


title: Are packages cryptographically signed in Fedora 14?

text: I am installing Fedora 14 and I am wondering if   1. the Fedora packages are cryptographically signed   2. package signatures are checked by the installer by default   3. package signatures are checked by yum when installing additional packages or doing upgrades


title: Wine cdrom mount locations on Linux Mint 10 (Ubuntu 10.10) -- problems post install/switching discs

text: I've been trying to install a few windows games with wine on Linux Mint 10 (based on ubuntu 10.10), but I am finding that my cd-rom mount points aren't standard. ie: rather than /media/cdrom I get /media/disc_name [ a la /media/Warcraft\ III] This seems to cause problems during the installation of multi-disc games, and games which require the disc to be in the drive after installation. In both cases the target disc cannot be found, even when the mount point is verified to match the original installation source, or updated in the installer to match the location of the second disc due to autonaming. Any ideas what I could do here? Near all cases result in a file not found error.


title: Function to evaluate variables in BASH

text: Given a variable name is there a function that will print its value? Often times I pass the name of a variable to a bash function and instead of doing the expansion while passing it I would like to expand it inside the function. Of course when I do this I end up having to create the string with the variable name then running exec. It would be much more succinct if I could just run a command that echoed the output!


title: How can I make custom key bindings work even while SSH-ed into another machine?

text: I've added               "\eOD": backward-word     "\eOC": forward-word      to my `.inputrc` to get ctrl-arrow key mappings sorted out in Cygwin allowing me to move forward and back fine. When I SSH to any other Linux system, I lose this binding. Can anyone help? I'm using PuTTYcyg 20101029, my terminal type is xterm, and I'm using Cygwin 1.7.9.


title: How to generate grub.conf from scratch in Fedora 14?

text: It seems that I hit following bug in Fedora 14 - I deselected installing grub into the MBR while using the graphical installer, because I want to use an existing grub instance. Now, I want to look up the grub.conf or menu.lst in the new installed Fedora 14 system to adjust my existing grub config - but I cannot find them anywhere. I just information about how grub-install and gruppy are not able to create a grub.conf from scratch. Thus my question: How to generate a grub.conf from scratch in Fedora 14, if it is missing? **Update:** The point is to get the set of default kernel options a grub.conf includes, when created by the Fedora installer. I have booted the fedora installation via grub and only setting the 'ro root=' options which worked. However, it would be great if someone could post a standard generated grub stanza from his/her Fedora 14 system to see the kernel parameter differences.


title: Running piped bash script in background

text: I'm attempting to build a monitoring script to watch localhost communication using netcat. I have two scripts that I've built, one to start the monitoring loop and one for the loop itself. They are as follows : **start.sh**               #!/bin/bash     netcat localhost 1099  | bash loop.sh &      **loop.sh**               #!/bin/bash     while read sInput; do          ...do something with $sInput     done      Simply running this application without in the foreground works fine but as soon as I try to run this script in the background it goes from running to stopped instantly. Could someone please educate me as to why this is happening and how to alleviate the problem. My end goal is to have a bash script that I can create an arch linux daemon script with and have everything work perfectly. Your help is appreciated.


title: unrecognized inateck hdd enclosure with linux Mint

text: I have put in a Hitachi 2.5 inch hdd inside a Inateck hdd enclosure. I have connected the enclosure to a Toshiba R630-156 using a usb2 cable on a usb3 enclosure port. I can hear and feel the hard drive is powered but I cannot see any messages in dmesg. i cannot see any related output in lsusb. I have enabled usb_storage kernel module but it does not seem to make any difference. I am not experienced with trouble shooting hardware issues so please refer to some documentation if you are using very specific terms in your explanation. please ask if you need anymore debug information. thanks.               $ cat /etc/lsb-release     DISTRIB_ID=LinuxMint     DISTRIB_RELEASE=17     DISTRIB_CODENAME=qiana     DISTRIB_DESCRIPTION="Linux Mint 17 Qiana"          $ uname -a     Linux rag-tos-laptop 3.13.0-24-generic #46-Ubuntu SMP Thu Apr 10 19:11:08 UTC 2014 x86_64 x86_64 x86_64 GNU/Linux          $ lsmod | grep usb     usb_storage            62209  0      btusb                  32412  0      bluetooth             395423  12 bnep,btusb,rfcomm     usbhid                 52616  0      hid                   106148  2 hid_generic,usbhid          $ lsusb     Bus 002 Device 004: ID 0930:0214 Toshiba Corp.      Bus 002 Device 002: ID 8087:0020 Intel Corp. Integrated Rate Matching Hub     Bus 002 Device 001: ID 1d6b:0002 Linux Foundation 2.0 root hub     Bus 001 Device 003: ID 0bda:58f5 Realtek Semiconductor Corp.      Bus 001 Device 004: ID 046d:c52e Logitech, Inc.     Bus 001 Device 002: ID 8087:0020 Intel Corp. Integrated Rate Matching Hub     Bus 001 Device 001: ID 1d6b:0002 Linux Foundation 2.0 root hub          BIOS Information             Vendor: TOSHIBA             Version: Version 1.90               Release Date: 02/24/2011             ROM Size: 2048 kB             Characteristics:                     ISA is supported                     PCI is supported                     PNP is supported                     BIOS is upgradeable                     BIOS shadowing is allowed                     VLB is supported                     Boot from CD is supported                     Selectable boot is supported                     EDD is supported                     Japanese floppy for Toshiba 1.2 MB is supported (int 13h)                     3.5"/720 kB floppy services are supported (int 13h)                     Print screen service is supported (int 5h)                     8042 keyboard services are supported (int 9h)                     Serial services are supported (int 14h)                     Printer services are supported (int 17h)                     ACPI is supported                     USB legacy is supported                     BIOS boot specification is supported                     Function key-initiated network boot is supported                     Targeted content distribution is supported             BIOS Revision: 1.90             Firmware Revision: 1.40


title: How do i get screen to execute/load .zprofile when starting a new window?

text: How do i get screen to execute/load `.zprofile` when starting a new window?


title: Compiling and running linux test project

text: I'm trying to install _Linux Test Project (LTP)_ on Debian 6.0.2, kernel 2.6.33.20. Compilation and installation went fine and without errors, but when I try to run basic tests               $ ./runltp      I get following error:               FATAL: LTP not installed correctly     INFO:  Follow directions in INSTALL!      After inspecting `runltp` script I realised that I'm missing all `bin` directories in LTP (./bin, ./testcases/bin, ...). I followed all instructions in INSTALL and installed all dependencies. How can I fix that?


title: Is there a better way to unlock a file than move and copy?

text: My organisation uses Debian Linux running Samba for office file servers. Users run Outlook for their email, which crashes fairly regularly and leaves the outlook.pst file locked. Currently, our procedure for removing the lock (which allows the user to use Outlook again) is:   1. Manually open a terminal session   2. Go to the users dir holding the outlook.pst file   3. Remove the ~outlook.pst.tmp file (or similar name)   4. Rename the pst file (eg mv outlook.pst outlook.pstoff)   5. Copy the file back to outlook.pst (ie cp outlook.pstoff outlook.pst)   6. Remove the old file (ie rm outlook.pstoff)   7. chown outlook.pst to the user This could be scripted reasonably easier, but to be done properly it would need checking for available disk space before doing the copy. Is there some easier way to remove the lock on the file without copying it?


title: Increasing serial baud rate within Ubuntu under VirtualBox

text: I'm debugging a kernel module under VirtualBox with a guest and host OS as Ubuntu 10.10. I'm using the virtualbox serial port but I'm maxing out at the baudrate 115200. My grub config looks like this... console=ttyS0,115200 Is there a way for me to change that setting in the guest OS so that the virtual serial port works at a faster baudrate? I've tried to use setserial. That didn't give me an error, but when I recompiled with a faster baudrate for the console I didn't see a change. Thanks!


title: Can you create a volumegroup in LVM that all the Logical volumes created under it will be thin provisioned?

text: I would like to know if it is possible to create a volumegroup in LVM that all the Logical volumes created under it will be thin provisioned? This will be used on RHEL 6 which does include thin provisioning in LVM. I am open to alternatives as well.


title: Can you think of a way to stop the generation of a core file WHILE it is happening?

text: I was just wondering if you can think of a clever way to stop the creation of a `core` file while it is being produced. I understand that there are several way to disable the creation like setting `ulimits` or setting the directory read only, but is there any way to stop it while the creation has already started? Any way to simulate a disk full/permission denied to force the process to quit?


title: Copyed mysql files from previous system now error while connect, what to do?

text: Fist of all I have the files but the old system is gone. I took the folders in `/var/lib/mysql/` and gave then the permissions the mysql folder that was in there had. user mysql group root only accessible my user. Now when I want to access my localhost sites I get a mysql database error. But I think everything is as it was before. What do I need to do to make this work?               Cannot find or open table blabla/wp_options from     the internal data dictionary of InnoDB though the .frm file for the     table exists. Maybe you have deleted and recreated InnoDB data     files but have forgotten to delete the corresponding .frm files     of InnoDB tables, or you have moved .frm files to another database?     or, the table contains indexes that this version of the engine     doesn't support.     See http://dev.mysql.com/doc/refman/5.5/en/innodb-troubleshooting.html     how you can resolve the problem.      the logfile shows me a hell of a lot errors like this. Should I delete this .frm files now?


title: copying from a remote server to my hdd with alias or reducing long file paths

text: I want to copy files from a remote server to my desktop and vice versa. However, the issue is, my files to be copied from the server have quite long file paths with at least 7-8 subfolders which are more or less constant. It's hectic to use the entire file path all the time to perform simple copy actions. for eg, if I wanted to copy `filex` from the remote server I would have to type in:               scp -r username@remotesrvr.com:/fldr1/fldr2/fldr3/fldr4/..../myfile ./mydesktop      Is there a way to overcome this?


title: Using Linux text editor to prepare content for Microsoft Word

text: I need to prepare a long manuscript that must be submitted in a Microsoft Word document in order to meet the submission criteria. (Please no "Don't use Word" comments.) I want to use a text editor on my Linux computer (Ubuntu). I will eventually paste the content into a Word document when it is finished. I don't have access to Word just now and I cannot test this. I will probably use a mixture of different text editors as is usual. Is there anything I need to watch out for, such as line endings and text encoding, so that I don't need to rework the text when I paste it into the new format and OS?


title: Linux / JVM - OutOfMemoryError: unable to create new native thread

text: I have a memory problem with a Linux server (CentOS). It is a VM. Below is the context. It has 70Gb of RAM. There are 2 tomcat running on it. One tomcat is given a heap of 13Gb and the other one a heap of 20Gb. The one with 20Gb has the JVM option -Xss160k set (to try to solve my problem). These 2 tomcat can be using up to 48Gb of RAM (virt.) Linux is going to use the 70Gb and there will be about 35Gb of cached memory. The swap is 1Gb and it uses pretty much none of it (8Mb). Now the problem is that I get the following error from the tomcat every so often:               OutOfMemoryError: unable to create new native thread      If I am not mistaken, this happens if the OS itself runs out of memory and is therefore unable to create new threads. Now the question is: how is that possible when it has 35Gb of cached memory? Shouldn't it re-allocate it and use it as needed. Is there maybe some kernel option I can set to avoid this? For example it could use up to 65Gb, cache 30Gb and keep 5Gb free.


title: Cron job not running / not successful?

text: I have a couple of `cron` jobs set up to maintain a local copy of a remote database. The first one downloads the latest version of the database from the remote machine, which runs every day and is working fine. The second one imports the downloaded data, however it is not working. The job is just a simple shell script:               #!/bin/bash     mysql -u root -mypass -h localhost my_db < my_db.sql      The cron task is set up like this:               0 8 * * * bash /home/lampadmin/cron/my_db.sh      If I run the shell script manually, it works OK. What can I do to find out why it is not working through cron?


title: Linux 'mail' command: Can't open display

text: I've just installed the 'mail' command in Ubuntu (mailutils package) in order to view feedback from cron jobs. I type 'mail' at the prompt and see something like this:               "/var/mail/*$USER*": 1 message 1 unread     >U 1 *Name* *Date* Output from your job       I type `1` at the `?` prompt and get a lot of output about the message (From, Date, Subject...) but on the last line it says               Error: Can't open display:     ?      and I'm returned to the prompt. Does anyone have any idea what the problem might be?


title: PHP mail() and Debian Wheezy Not Working

text: I am currently running my on debian wheezy with php5 installed. I was trying use the mail() function, and I realised that I will require a MTA/exim installed before it will be possible because the default installation does not come with any. I was looking at a solution at: https://wiki.debian.org/GmailAndExim4 However, it says that This setting is for a typical desktop PC which has no resolvable host name. Are there any good references for the settings I can use for a hosting server?


title: Regex that would grep numbers after specific string

text: So I have a line:               ID: 54376      Can you help me make a regex that would only return numbers without "ID:"? **NOTE:** This string is in a file.


title: Transparent Ethernet over GRE not forwarding traffic

text: I am running on Linux 2.6.30.9 and have been trying to setup a transparent ethernet over GRE tunnel. The network topology used is as follows: ![enter image description here](http://i.stack.imgur.com/anJep.png) I want to bridge PC1 and PC2 using Transparent Ethernet over GRE. RouterA is connected to internet via ppp0 as RouterB. Both internet connections are PPPOE (PPPoEoA PVCs). So i do: In RouterA (linux 2.6.30.9):               ip link add testgre type gretap remote 193.152.243.206 local 95.121.205.77 ttl 255     brctl addif br0 testgre     ip link set testgre up      In RouterB (linux 2.6.30.9):               ip link add testgre type gretap remote 95.121.205.77 local 193.152.243.206 ttl 255     brctl addif br0 testgre     ip link set testgre up      Some commands output: In RouterA (similar output in RouterB):               # ip link show testgre     36: testgre: <BROADCAST,MULTICAST,PROMISC,UP,LOWER_UP> mtu 1442 qdisc pfifo_fast state UNKNOWN qlen 1000     link/ether 5f:79:cd:4d:c6:57 brd c1:98:f3:ce:ff:ff          # brctl show     bridge name     bridge id               STP enabled     interfaces     br0             8000.5f79cd4dc657       no              eth0.5                                                             eth0.4                                                             eth0.3                                                             eth0.2                                                             wlan0                                                             testgre      Then i do PING request from PC1 to PC2:               ping 192.168.1.33      I run tcpdump in RouterA and I see the ARP Request frame over ppp0 (pcap file opened with Wirehark): ![enter image description here](http://i.stack.imgur.com/8O5QY.png) I run tcpdump in RouterB attached to ppp1 and i see that the ARP Request has arrived, but its not forwarded at L2 to PC2. I dont see the ARP request in PC2. I try with statics ARP entries but the ICMP Request has the same problem, it is not forwarded to PC2. There are not ebtables rules. Nor iptables rules (Default action is ACCEPT for ebtables and iptables). Should i add ppp0 to bridge interface or something like that? Any suggestions are welcomed.


title: Bash Auto-Completion feature for SSHing into Different Hosts

text: I have big list of servers which I normally `ssh` to all the time. Is there any way using `bash` or `zsh` so that I can keep the list of hostname and bash auto-completion goes through the file and gives me suggestion for the boxes starting with those letters whenever I type the first few letters of the hostname.


title: which shell will sudo use to execute a shell script without the shebang line

text: My environment is Ubuntu 12.04 LTS, and the `sudo` version is 1.8.3p1. First I login as a normal user:               $ whoami     fin          $ cat /etc/passwd | grep -i "root\|fin"     root:x:0:0:root:/root:/bin/bash     fin:x:1000:1000:This is a normal user:/home/fin:/bin/bash          $ ls -l /bin/sh     lrwxrwxrwx 1 root root 4 Mar 30  2012 /bin/sh -> dash          $ ls -l /bin/bash     -rwxr-xr-x 1 root root 920788 Apr  3  2012 /bin/bash          $ echo $SHELL     /bin/bash          $ ps | grep "$$" | awk '{ print $4 }'     bash          $ ls -l ./test.sh     -rwxr-xr-x 1 fin fin 37 Sep 27 16:46 test.sh          $ cat ./test.sh     ps | grep "$$" | awk '{ print $4 }'          $ ./test.sh     bash          $ sudo ./test.sh     sh      I suppose the last output should also be `bash` because `/etc/passwd` shows that root uses `bash`, am I missing any points about `sudo`?


title: Cannot send mail to top domain

text: I have a webserver with the domain name server1.mydomain.com, mydomain.com is currently directed to another server. If a mail is send to an e-mail address with my top domain, eg me@mydomain.com, I get an error in the exim/mainlog 'T="Mail delivery failed: returning message to sender" from <>'. Other mail addresses work fine. My hosts file currently looks like this:               Do not remove the following line, or various programs     # that require network functionality will fail.     127.0.0.1       localhost     120.113.245.121          server1.mydomain.com   server1      Anyone an idea what the problem could be?


title: io redirection to "cross" 2 programs

text: How to "cross" `stdin` and `stdout` of two programs? Specifically, I have 2 programs call `pgm1` and `pgm2`, they are interactive tic-tac-toe games. They both output a number (0to8) indicating position where it wants to mark and expect another number (0to8) indicating where the user wants to mark. The difference between the two is `pgm1` makes first move and `pgm2` makes second move. They both work fine via interactive user. Can they be made to play against each other using io redirection? I tried the following things in vain:     1. Open `pgm2` in a separate terminal (it waits for input), find it's pid. Then run `pgm1` in another terminal `./pgm1 < /proc/pid_pgm2/fd/1 > /proc/pid_pgm2/fd/0 `      2. Made 2 pipes using mkfifo, say `pipe1` and `pipe2` and ran the following in two different terminals: ` ./pgm1 < pipe1 > pipe2 ` and ` ./pgm2 < pipe2 > pipe1 `     3. tried the above two, running pgm1 before pgm2, running pgm2 before pgm1   I made sure to use `fflush(stdout)` in both the programs, immediately after using `printf()`. Could anyone tell me what i am missing / or going wrong / or is this even possible?


title: What is the point of the `cd` external command?

text: As referenced in this fine answer, POSIX systems have an external binary `cd` in addition to the shell builtin. On OS X 10.8 it's `/usr/bin/cd`. You can't use it like the builtin `cd` since it exits immediately after changing its own working directory. What purpose does it serve?


title: Fujitsu Life book Debian Weezy 64-bit

text: Has anyone managed to get a 64 bit Linux installation on the Fujitsu Lifebook A3130 Currently have 32-bit Debian Wheezy but having troubles with building/Compiling Android and CyanogenMod. Having consulted with xda-developers, it is suggested that I upgrade to 64-bit. There is just very little info I've been able to find so far about this laptop and 64-bit Linux, although the documentation for the processor says it is compatible.


title: The receiving of returns by Nagios from script through NRPE

text: I am using nagios3 and want to collect some information from nrpe_server. Next script is at nrpe_server:               #!/bin/sh     #set -x     # script for checking disk usage on ZFS     # requires min zpool version 13 or zfs version 4     # example, it's posible to have zfs ver 1 on zpool ver 15 (script support this)     # http://www.googlux.com/nagios.plugin.zfs.usage.html     # ------------ Variables     PROGNAME=`/usr/bin/basename $0`          # ------ Nagios plugin return values     STATE_OK=0     STATE_WARNING=1     STATE_CRITICAL=2     STATE_UNKNOWN=3     STATE_DEPENDENT=4          # ------------ Subroutines          # Program usage     usage() {     echo " \     Usage             ${PROGNAME} /zfs warn crit          Note:     1. ZFS filesystem must start with /     2. warn is warning free space in %     3. crit is critical free space in %     example: /tank 20 10     "     }          # End script with output, with performance data for NagiosGraph     endscript () {             echo "${RESULT}"             exit ${EXIT_STATUS}     }          # ------------ check if there are 3 arguments     if [ $# != 3 ]; then             usage             exit 3     fi          # --------- check if warning is bigger than critical size     if [ $3 -ge $2 ]; then             echo "Warning[%] must be bigger than Critical[%]"             exit 3     fi          # ----------- check if first argument is a filesystem     FS=`df -T $1 | tail -n 1`     if [ $? != 0 ]; then             echo "The $1 is not valid filesystem"             exit 3     fi          # ----------- check if filesystem is ZFS     # /var : zfs     # /export/atlant-dbbackup: zfs     # note - comment out: ZFS=`echo ${FS} | awk '{print $3}'`     ZFS=`echo ${FS} | awk '{print $2}'`          if [ "${ZFS}" != "zfs" ]; then             echo "The $1 is not ZFS"             exit 3     fi          # -------- get dataset of filesystem     DATASET=`df -h $1 | grep -v Filesystem | awk '{print $1}'`          # ----------- check if ZFS is min required version 4 or ZPOOL min required ver 13     ZFSVER=`zfs get -H version ${DATASET} | awk '{print $3}'`     if [ $? -ne 0 ]; then             echo "The ZFS version can't be determined, it's probably less then 4"             exit 3     fi     if [ ${ZFSVER} -lt 4 ]; then             #echo "The $1 is indeed ZFS, but version ${ZFSVER} which is less than 4 and not supported by this script"             #exit 3             # ---------- check if ZPOOL is min required version 13, or higher             ZPOOLVER=`zpool upgrade | head -1 | awk '{print $NF}' | awk -F. '{print $1}'`             if [ ${ZPOOLVER} -lt 13 ]; then                     echo "The script can't support zpool ver ${ZPOOLVER} (<13) and ZFS ver ${ZFSVER} (<4)"                     exit 3             fi     fi               # size in bytes     QUOTA=`zfs get -Hp quota ${DATASET} | awk '{print $3}'`     DIV=1024/1024     # --- check if there is quota at all     if [ ${QUOTA} -eq 0 ]; then     #        echo "There is no quota on zfs dataset ${DATASET}"         QUOTA=`df $1 | tail -n 1 | awk '{print $4}'`         DIV=1024     #        exit 3     fi          # --- check if zfs properties can be determined     # --- sometimes even zfs ver =4 this is not posible     for i in usedbydataset usedbychildren usedbysnapshots     do             if [ "`zfs get -Hp ${i} ${DATASET} | awk '{print $3}'`" = "-" ]; then                     echo "Somehow zfs property ${i} cannot be determined"                     exit 3             fi     done          # --- check if usedbydataset is not 0     # --- can happens with export/import zpools     if [ `zfs get -Hp usedbydataset ${DATASET} | awk '{print $3}'` -eq 0 ]; then             echo "Somehow zfs property usedbydataset=0, probably zpool exported/imported and script can't support it"             exit 3     fi          CHILDRENUSE=`zfs get -Hp usedbychildren ${DATASET} | awk '{print $3}'`     DATA=`zfs get -Hp usedbydataset ${DATASET} | awk '{print $3}'`     SNAPSHOT=`zfs get -Hp usedbysnapshots ${DATASET} | awk '{print $3}'`     #echo QUOTA=${QUOTA}     # size in Mbytes     QUOTA=`(echo "scale=2; ${QUOTA}/${DIV}" | bc -l)`     CHILDRENUSE=`(echo "scale=2; ${CHILDRENUSE}/1024/1024" | bc -l)`     DATA=`(echo "scale=2; ${DATA}/1024/1024" | bc -l)`     SNAPSHOT=`(echo "scale=2; ${SNAPSHOT}/1024/1024" | bc -l)`     #echo QUOTA=${QUOTA}     # real quota is actually quota-usedbychildren     QUOTA=`(echo "scale=2; ${QUOTA}-${CHILDRENUSE}" | bc -l)`          FREE=`(echo "${QUOTA}-${DATA}-${SNAPSHOT}" | bc -l)`          #echo "FREE=${QUOTA}-${DATA}-${SNAPSHOT}"          FREEPERC=`bc -l << E     scale=0     ${FREE}*100/${QUOTA}     E`          WARNING=$2     CRITICAL=$3          if [ ${FREEPERC} -gt ${WARNING} ]     then             RESULT="ZFS ver${ZFSVER} $1 OK Free space ${FREE}MB ${FREEPERC}% : ${QUOTA}, ${SNAPSHOT}, ${DATA}, ${FREE}"             EXIT_STATUS=${STATE_OK}     elif [ ${FREEPERC} -le ${WARNING} ] && [ ${FREEPERC} -gt ${CRITICAL} ]     then             RESULT="ZFS ver${ZFSVER} $1 WARNING Free space ${FREE}MB ${FREEPERC}% : ${QUOTA}, ${SNAPSHOT}, ${DATA}, ${FREE}"             EXIT_STATUS=${STATE_WARNING}     else             RESULT="ZFS ver${ZFSVER} $1 CRITICAL Free space ${FREE}MB ${FREEPERC}% : ${QUOTA}, ${SNAPSHOT}, ${DATA}, ${FREE}"             EXIT_STATUS=${STATE_CRITICAL}     fi          # ------- provide output and nagios return value     endscript      It receives thee argument from nagios3 correctly. When I running this script manually at nrpe_server from command line it returns correct information, for example:               # /usr/lib/nagios/plugins/check_zfs_usage.sh /tank/share 20 10     ZFS ver5 /tank/share OK Free space 2175113.43MB 73% : 2954615.25, 1053.55, 778448.27, 2175113.43      But when nagios3 running this script remotely through nrpe_server with the same arguments it receives back incorrect information:               ZFS ver /tank/share CRITICAL Free space MB % : , , ,      So what is wrong with the script, how to fix it?


title: Excluding a file in bash loop

text: In the following script, How do I exclude a directory in the loop? I want to do this because all files are symlinks pointing to this directory that exists in the same level, so I don't want to add it.                    cd /var/www     for dir in */     do             base=$(basename "$dir")             tar -czfh "${base}.tar.gz" "$dir"     done


title: Replace string containing newline in huge file

text: **Anyone know of a non-line-based tool to "binary" search/replace strings in a somewhat memory-efficient way?** See this question too. I have a +2GB text file that I would like to process similar to what this appears to do:               sed -e 's/>\n/>/g'      That means, I want to remove all newlines that occur after a `>`, but not anywhere else, so that rules out `tr -d`. This command (that I got from the answer of a similar question) fails with `couldn't re-allocate memory` :               sed --unbuffered ':a;N;$!ba;s/>\n/>/g'      So, are there any other methods without resorting to C? I hate perl, but am willing to make an exception in this case :-) I don't know for sure of any character that does not occur in the data, so temporary replacing `\n` with another character is something I'd like to avoid if possible. Any good ideas, anyone?


title: grep piping into sed, replacing inline; but I want sed to print the filename and changed line. Is it possible?

text: Here's my command (break intentional):               grep FOO "/Users/gjtorikian/blah" -l | xargs sed -i '' '/FOO/{s/FOO/BAR/g; w /dev/stdout     }'      At the high-level: `grep` for FOO in the `blah` directory; pipe in just the filename (because of `-l`) to `sed`; `sed` performs an inline replace (`-i ''`) and prints _only the changed term_ to `/dev/stdout`. If I were to omit the `-l` and pipe, I get this back from `grep`:               /Users/gjtorikian/blah/baz.cs:1:FOO     /Users/gjtorikian/blah/bar.js:1:FOO      What I want is `sed` to perform the inline replace, and then show me the file and term replaced; for example:               /Users/gjtorikian/blah/baz.cs:1:BAR     /Users/gjtorikian/blah/bar.js:1:BAR      Is such a thing possible? If it matters, I would prefer to keep it with only `grep`/`sed`. Do I have to do a second `grep` after the `sed` ?


title: How to operate USE flags? Is there a master class on Portage or Gentoo?

text: What man pages I need to read first?


title: Installing FreeBSD without removable media from CentOS 6

text: I've been tasked with installing FreeBSD 8 alongside CentOS 6, without the luxury of removable media. CentOS 6 is already on the machine, and running quite nicely. However, I cannot figure out how to get FreeBSD running. I've spent a good chunk of time trying various things, but I keep running into walls. Here are the two attempts that yielded the most success:   1. UNetBootIn: after a little bit of tweaking, it gave me a GRUB menu item to boot into sysinstall for FBSD 8. However, when I went to install it, I got a "Disks not found" error, which I have not been able to resolve. I've tried switching my hard disk from IDE to ACHI and back with no luck. I think this is likely the best way to do this, but I'm blocked.   2. Copying the contents of the installation ISO to my hard drive: I made a FAT32 partition for the ISO, and a GRUB entry that runs /boot/loader, but I get an error saying that the kernel cannot be loaded. When I use lsdev, I can see the partition that it's on, but I cannot seem to load the kernel. Using ls tells me that / does not exist.   3. Like #2 but using /boot/kernel/kernel instead of /boot/loader in my GRUB entry: This will successfully load the kernel, but gets messed up when it asks me to mount a root partition. Unfortunately, no matter which partition I tell it to use, the kernel rejects all of my attempted mount points. If anyone has any ideas about how to make any of these work, or can point me in the right direction, I'd be extremely grateful!


title: Sony runs which operating system? Oracle Linux or Crestron Extron or Minix or OS X?

text: Sony has TV, PlayStation, Camera random hardware's. Where many of those have GUI available too. I want to run my BASH script there with ncurses. But how do they drive there devices? Which operating system is used inside? Or they just use micro-controllers or is it open-solaris?   * Xperia by Sony Ericsson http://developer.sonymobile.com/wportal/devworld/search- downloads/opensource?cc=gb&lc=en