title: Cat write text with "$" inside

text: I want to write configuration information to a specific file which has dollar signs (`$`) inside. That seems to be a problem. Here's what I did:               $ cat >> /etc/nginx/nginx.conf <<EOF     # For more information on configuration, see:     #   * Official English Documentation: http://nginx.org/en/docs/     #   * Official Russian Documentation: http://nginx.org/ru/docs/          user              nginx;     worker_processes  1;          error_log  /var/log/nginx/error.log;     #error_log  /var/log/nginx/error.log  notice;     #error_log  /var/log/nginx/error.log  info;          pid        /var/run/nginx.pid;               events {         worker_connections  1024;     }               http {         ## Detect when HTTPS is used         map $scheme $https {           default off;           https on;         }         include       /etc/nginx/mime.types;         default_type  application/octet-stream;              log_format  main  '$remote_addr - $remote_user [$time_local] "$request" '                           '$status $body_bytes_sent "$http_referer" '                           '"$http_user_agent" "$http_x_forwarded_for"';              access_log  /var/log/nginx/access.log  main;              sendfile        on;         #tcp_nopush     on;              #keepalive_timeout  0;         keepalive_timeout  65;              #gzip  on;              # Load config files from the /etc/nginx/conf.d directory         # The default server is in conf.d/default.conf         include /etc/nginx/conf.d/*.conf;          }     EOF      How can I solve this?


title: How can I replace text after a specific word using sed?

text: I have a file named `.ignore`. In need to replace the `projdir`. For example:               ignore \..*     ignore README     projdir Snake      I need to replace Snake with, for example, "PacMan". I read the man page, but I have no idea what to do.


title: What keeps one side of an rsync so busy?

text: I've got a Debian machine on my LAN serving as a backup server for the others. It has four HDDs combined into a software RAID 5 md device, on that an LVM, and on that btrfs. Backups are made using rsync, and for a large filesystem take over an hour. For a long time I had thought there would be little I could do about this. Recently, however, I noticed that the HDD activity was _very_ different on both ends of the transfer. While the sending side, running Gentoo and mostly using ext4, had hardly any disk IO at all, the receiving side was constantly busy. As most data wouldn't change between transfers, I believe that metadata reads should make up the bulk of the data. But I'd be really surprised if reading inodes in btrfs is so much work than doing the same in ext4. `iotop` confirmed disk reads of about 1-4 MB/s on the receiving side, whereas the sending side had only the occasional 0.5 MB/s burst. My question is, can anyone explain what's going on here? Preferably with some indication how to work around the problem if possible. Perhaps there is some btrfs tuning flag I could use, or something similar. I need a FS with snapshot capabilities on the backup server, and my attempt to use FreeBSD and ZFS quickly lead to an inconsistent FS, so I see little alternative to btrfs at the moment. Therefore answers telling me to use ext4 or zfs might receive upvotes but no check mark. * * * Rsync options in use, as requested by cjm:                   --rsync-path='rsync --fake-super'         --archive               # -rlptgoD         --hard-links            # detect and preserve these         --acls         --xattrs         --sparse         --noatime               # based on patch from samba #7249c1         --delete         --delete-delay         --fuzzy         --human-readable        # size suffixes, base 1000         --stats      As well as a bunch of `-f` rules to omit some files. * * * The mount options of the btrfs are reported by `mount` as               rw,nosuid,noexec,noatime,nospace_cache      In particular, this includes the `noatime` flag, so there shouldn't be any writing involved unless there actually were differences in some files. I added this information in response to the answer by Kyle Jones.


title: How to change Power button shutdown action

text: I use Mageia ver 4 Linux as server, without X started and without any user login-in during normal operation. This PC has a special card for measuring and control of other devices. This card has its own SH4 Linux on-board, and needs to be shutdown first, before PC shutdown. There is a set of commands supplied by the card vendor and they works properly. To shutdown the card it is necessary to execute `/usr/sbin/io_card stop`, wait for proper card shutdown and then execute "ordinary" PC shutdown. I wrote a special shutdown script and it works properly. But the problem is when I press "Power" button on PC, it executes "ordinary" PC shutdown instead of my script. I try to change /etc/acpi/events/power and systemd scripts to include my own shutdown script, but it does not work. At this moment /etc/acpi/events/power file contains only entry :               action=/home/serwer/Pobrane/shut      where "shut" is my shutdown script, working good when running manually. So how can I change default power-off action associated with depressing "Power" button?


I installed the Python bindings of VTK 5.1 correctly. In Python, `import vtk` worked, but `import itk` did not work yet. So I wanted to install the Python bindings of ITK 4.2. I needed to install SWIG 2.0.7, and from the error message which arose during `./configure` in the SWIG source directory, I understood I needed to install `pcre`. So I chose the version 8.31 of pcre. Here is a summary of the process: > (VTK + Python) ---> This works. > > (ITK + Python) ---> SWIG needed ---> pcre needed **Now that pcre is installed, my problem is yum has stopped working:**               [root@wok build]# yum     There was a problem importing one of the Python modules     required to run yum. The error leading to this problem was:             libvtkIOPythonD.so.5.10: cannot open shared object file: No such file or directory          Please install a package which provides this module, or     verify that the module is installed correctly.          It's possible that the above module doesn't match the     current version of Python, which is:     2.7 (r27:82500, Sep 16 2010, 18:02:00)      [GCC 4.5.1 20100907 (Red Hat 4.5.1-3)]          If you cannot solve this problem yourself, please go to      the yum faq at:       http://yum.baseurl.org/wiki/Faq      * * * **I wonder if I should add variables to the PATH.** Maybe it is related to a problem I had with SWIG: it worked as a user but not as root.               wok ~ $ swig -swiglib     /usr/local/share/swig/2.0.7          [root@wok home]# swig -swiglib     swig: error while loading shared libraries: libpcre.so.1: cannot open shared object file: No such file or directory      I had to add one line to .bashrc of the root user to make swig work with both the user and the root:               export LD_LIBRARY_PATH=$LD_LIBRARY_PATH:/usr/local/lib/      * * * **There could be something with the Python path.** In Python, I noticed I could `import vtk` as a user, but not as root.               wok ~ $ python     Python 2.7 (r27:82500, Sep 16 2010, 18:02:00)      [GCC 4.5.1 20100907 (Red Hat 4.5.1-3)] on linux2     Type "help", "copyright", "credits" or "license" for more information.     >>> import vtk     >>>       but:               [root@wok ~]# python     Python 2.7 (r27:82500, Sep 16 2010, 18:02:00)      [GCC 4.5.1 20100907 (Red Hat 4.5.1-3)] on linux2     Type "help", "copyright", "credits" or "license" for more information.     >>> import vtk     Traceback (most recent call last):       File "<stdin>", line 1, in <module>       File "/user/wok/home/Softwares/VTK_5.1/build/Wrapping/Python/vtk/__init__.py", line 41, in <module>         from vtkCommonPython import *     ImportError: libvtkCommonPythonD.so.5.10: cannot open shared object file: No such file or directory      * * * PCRE seems to me to be installed correctly:               [root@wok build]# pcretest -C     PCRE version 8.31 2012-07-06     Compiled with       8-bit support only       No UTF-8 support       No Unicode properties support       No just-in-time compiler support       Newline sequence is LF       \R matches all Unicode newlines       Internal link size = 2       POSIX malloc threshold = 10       Default match limit = 10000000       Default recursion depth limit = 10000000       Match recursion uses stack      and               [root@wok build]# locate libpcre     /lib64/libpcre.so.0     /lib64/libpcre.so.0.0.1     /usr/lib64/libpcrecpp.so.0     /usr/lib64/libpcrecpp.so.0.0.0     /usr/lib64/libpcreposix.so.0     /usr/lib64/libpcreposix.so.0.0.0


title: How can I pipe stdout to another program?

text: I'm trying to setup a linter for my code and I only want to lint the coffeescript files that have changed in the current branch. So, I generate the list of files using `git`:               git diff --name-only develop | grep coffee$      That gives me a nice list of the files I'd like to process but I can't remember how to pipe this to the linting program to actually do the work. Basically I'd like something similar to `find`'s `-exec`:               find . -name \*.coffee -exec ./node_modules/.bin/coffeelint '{}' \;      Thanks!


title: Kernel does not skip bad blocks when mounting filesystem

text: I am developing for an embedded Linux application using friendlyARM's micro2440. It runs on a Samsung s3c2440 ARM processor and uses squashfs in its NAND flash. Recently, some flash blocks went bad. u-Boot correctly finds them and creates a bad block table with the offsets given by the nand bad command:               Device 0 bad blocks:     01340000     0abc0000     0f080000     0ff80000     0ffa0000     0ffc0000     0ffe0000      When I try to boot the kernel, it correctly scans the bad blocks and creates its bad block table, as seen in the following messages:               Scanning device for bad blocks     Bad eraseblock 154 at 0x000001340000     Bad eraseblock 1374 at 0x00000abc0000     Bad eraseblock 1924 at 0x00000f080000      But when it comes the time for the kernel to mount the filesystem in the partition where the bad block at 0x000001340000 happens, it seems unable to skip the bad blocks and then it panics. The error messages given were:               SQUASHFS error: squashfs_read_data failed to read block 0xd0e24b     SQUASHFS error: Unable to read metadata cache entry [d0e24b]     SQUASHFS error: Unable to read inode 0x3d1d0f68     ------------[ cut here ]------------     WARNING: at fs/inode.c:712 unlock_new_inode+0x20/0x3c()     Modules linked in:     [<c0037750>] (unwind_backtrace+0x0/0xcc) from [<c0044994>]                             (warn_slowpath_null+0x34/0x4c)     [<c0044994>] (warn_slowpath_null+0x34/0x4c) from [<c00a42c8>] (unlock_new_inode+0x20/0x3c)     [<c00a42c8>] (unlock_new_inode+0x20/0x3c) from [<c00a61b8>] (iget_failed+0x14/0x20)     [<c00a61b8>] (iget_failed+0x14/0x20) from [<c00f75cc>] (squashfs_fill_super+0x3c8/0x508)     [<c00f75cc>] (squashfs_fill_super+0x3c8/0x508) from [<c0095990>] (get_sb_bdev+0x110/0x16c)     [<c0095990>] (get_sb_bdev+0x110/0x16c) from [<c00f7164>] (squashfs_get_sb+0x18/0x20)     [<c00f7164>] (squashfs_get_sb+0x18/0x20) from [<c0095008>] (vfs_kern_mount+0x44/0xd8)     [<c0095008>] (vfs_kern_mount+0x44/0xd8) from [<c00950e0>] (do_kern_mount+0x34/0xe0)     [<c00950e0>] (do_kern_mount+0x34/0xe0) from [<c00a9084>] (do_mount+0x5d8/0x658)     [<c00a9084>] (do_mount+0x5d8/0x658) from [<c00a9330>] (sys_mount+0x84/0xc4)     [<c00a9330>] (sys_mount+0x84/0xc4) from [<c0008c60>] (mount_block_root+0xe4/0x20c)     [<c0008c60>] (mount_block_root+0xe4/0x20c) from [<c00090fc>] (prepare_namespace+0x160/0x1c0)     [<c00090fc>] (prepare_namespace+0x160/0x1c0) from [<c00089c8>] (kernel_init+0xd8/0x104)     [<c00089c8>] (kernel_init+0xd8/0x104) from [<c0033738>] (kernel_thread_exit+0x0/0x8)     ---[ end trace c21b44698de8995c ]---     VFS: Cannot open root device "mtdblock5" or unknown-block(31,5)     Please append a correct "root=" boot option; here are the available         partitions:     1f00             256 mtdblock0 (driver?)     1f01             128 mtdblock1 (driver?)     1f02             640 mtdblock2 (driver?)     1f03            5120 mtdblock3 (driver?)     1f04            5120 mtdblock4 (driver?)     1f05           40960 mtdblock5 (driver?)     1f06           40960 mtdblock6 (driver?)     1f07          167936 mtdblock7 (driver?)     1f08            1024 mtdblock8 (driver?)     Kernel panic - not syncing: VFS: Unable to mount root fs on unknown-block(31,5)     [<c0037750>] (unwind_backtrace+0x0/0xcc) from [<c02fdd40>] (panic+0x3c/0x114)     [<c02fdd40>] (panic+0x3c/0x114) from [<c0008d44>] (mount_block_root+0x1c8/0x20c)     [<c0008d44>] (mount_block_root+0x1c8/0x20c) from [<c00090fc>] (prepare_namespace+0x160/0x1c0)     [<c00090fc>] (prepare_namespace+0x160/0x1c0) from [<c00089c8>] (kernel_init+0xd8/0x104)     [<c00089c8>] (kernel_init+0xd8/0x104) from [<c0033738>] (kernel_thread_exit+0x0/0x8)      I tried mounting the filesystem in mtdblock6 partition and everywhing worked as expected, as there are no badblocks in that part of the memory. I investigated the mtd source files responsible for the bad block management, but I couldn't find something useful about how the kernel skips the bad blocks.


title: Scientific Linux 6.3 run evince in SELinux sandbox

text: I'm trying to run evince in the SELinux sandbox:               sandbox -X /usr/bin/evince Unixforpoets.pdf      but after waiting for minutes nothing happens, console doesn't outputs anything. So I collected the logs (/var/log/messages):               Sep 30 12:32:14 HOSTNAME kernel: type=1400 audit(1349001134.585:23466): avc:  denied  { name_bind } for  pid=22229 comm="Xephyr" src=6081 scontext=unconfined_u:unconfined_r:sandbox_xserver_t:s0:c310,c1018 tcontext=system_u:object_r:varnishd_port_t:s0 tclass=tcp_socket      packages installed:               rpm -qa | egrep -i "policycoreutils-python|policycoreutils-sandbox|Xephyr|selinux"     selinux-policy-targeted-3.7.19-155.el6_3.4.noarch     libselinux-utils-2.0.94-5.3.el6.x86_64     selinux-policy-3.7.19-155.el6_3.4.noarch     xorg-x11-server-Xephyr-1.10.6-1.sl6.x86_64     libselinux-2.0.94-5.3.el6.i686     libselinux-python-2.0.94-5.3.el6.x86_64     policycoreutils-python-2.0.83-19.24.el6.x86_64     policycoreutils-sandbox-2.0.83-19.24.el6.x86_64     libselinux-2.0.94-5.3.el6.x86_64      ..I'm thinking about the bug I found when googling:               https://bugzilla.redhat.com/show_bug.cgi?id=798916      It states that this bug has been fixed in:               selinux-policy-3.10.0-80.fc16      ..so..I'm using: **selinux-policy-3.7.19-155.el6_3.4.noarch** ... I have to wait until SL delivers a newer version of selinux-policy?


title: How can I track who SSH'es into my linux machine?

text: I'm running Ubuntu 10.04. Is there a way I can get a daily report of who has logged onto the box, what time, and even - this may be asking too much - a report of the commands they used? This is a low-usage box and so I think this would be a nice way to see what activity is happening on it. Along these same lines, I heard it was not possible to track when things are done on the box via non-interactive shells, such as rsync or just remotely executing single commands via ssh. Is that true, or is there a way to log and track this as well?


title: Remove all packages in a text file via apt-get

text: I have a text file with a package on each line. How can I remove all the packages in that text file from the system? Also, if one package cannot be removes/wasn't installed in the first place can I make is continue. What I would ideally like is an `sudo apt-get remove packages.txt` type solution.


title: tar: exclude gzip file, and don't try to gunzip it

text: I would like to skip a large gzip file when I extract a tar file, but everytime tar starts to gunzip it to look inside it seems. Even when I just try to peek inside tar seems to start gunzipping it, for example:               tar -tvf my.tar.gz --exclude="huge_mysql_file.gz"      Any tips how to skip entirely that file? I see gzip running when tar gets to that gz file.


title: Generate time as expression of 1/1000ths of the day

text: Completely new to bash and having trouble working out how to make the arithmetic work. I think this should be easy, it's just.. argh. I want to express the time of day in terms of 1/1000ths (ie, midday = 500, etc.) I figured the script would need to find the number of seconds elapsed so far and then divide that number by 86.4, then return the resulting DDD Any help? thanks so much


title: How to create a md5-file for every folder in a drive recursivley?

text: I'm searching for a script which creates a md5 chechsum file for every single folder inside drive recursivley? I do have a copy of md5deep on my machine but I'm not that good in scripting bash.


title: Unable to uninstall libglib2.0-0 from Software Center

text: I have a fresh install of Debian 6.0.5 (i386) on VMware Player. I was trying to install libglib2.0-0 using this command:               sudo aptitude install libglib2.0-0      Unfortunately, I don't remember the exact output from the terminal but I remember there were 0 bytes installed or something. I'm guessing it didn't install correctly, so I want to remove it and try installing from the Software Center instead. However, when I click on remove, it just "greys out" and nothing happens. How do I uninstall it? Is there a command that could remove it from the terminal? EDIT: The output of:               dpkg -l 'libglib2.0-0'          root@vmware:/home/mohamed# dpkg -l 'libglib2.0-0'     Desired=Unknown/Install/Remove/Purge/Hold     | Status=Not/Inst/Conf-files/Unpacked/halF-conf/Half-inst/trig-aWait/Trig-pend     |/ Err?=(none)/Reinst-required (Status,Err: uppercase=bad)     ||/ Name           Version        Description     +++-==============-==============-============================================     ii  libglib2.0-0   2.24.2-1       The GLib library of C routines     root@vmware:/home/mohamed#


title: Flush 'tail -f' buffer?

text: I'm using the following statement (simplified version):               tail -f -c+1 <filename>      in order to pipe a file to a process. What I've found, though, is that there is a number of lines at the end which are not piped. A specific example is piping a mysql file, and stopping when the end is reached:               tail -f -c+1 mysqdump.sql | sed '/^-- Dump completed/ q0'      This doesn't work - the last line of the dump `\-- Dump completed [...]` is not piped to sed. My guess is that the `tail -f` buffer, in this case, is flushed only when it's full. Does anybody know how can I workaround this? ================= I've found the cause - the description is not complete (and the code doesn't exhibit the behavior). The problem happens when piping from a compressed (lzma) file:               tail -f -c+1 <filename.lzma> | lzma -d | sed '/^-- Dump completed/ q0'      Most likely, `tail` is not sending the last compressed block, because it doesn't detect any new line, as the input is binary.


title: Why are there so many log files in a typical Linux system? Why don't they use one consolidated logs db/file and an api?

text: I just wonder why are there so many log files in a typical Linux system? Wouldn't it be a better idea to have one system api function for logging and one consolidated table to save all the log entries from all the applications?


title: Generate “item tag” pairs from “item,item,...|tag” lists

text: The characteristics of the input data:   * Each line consists of two fields, separated by a pipe '|', where   * the first field is a comma-separated list of items, and   * the second field is a tag. Input               100,210,354,462|acct     331,746,50|mis     90,263,47,14|sales      Output               100acct     210acct     354acct     462acct     331mis     746mis     50mis     90sales     263sales     47sales     14sales


title: How to prevent xbindkeys from consuming keyboard messages?

text: I thought I can get `xbindkeys` run this command:               espeak -v en "a"      whenever the key `a` is pressed. But `xbindkeys` expropriates ( _consumes_ ) the keyboard message `a`. I thought this may fix:               espeak -v en "a"     killall xbindkeys     xdotool key a     xbindkeys      This fixes that problem. But it creates new ones: Slowing down everything, inappropriate place for `a`, etc Is there a better solution?


title: Debian 6.0 system with 2.6.39 kernel dropping packets, sandy bridge hardware

text: I recently migrated an existing Debian system to new hardware, a core i3 chip running on an intel sandy bridge motherboard. I’m experiencing a very strange problem; when I ping my router, about 50% of the packets are getting dropped. I spent some time testing, and can verify it’s not the router. It works fine with multiple different machines, even when connected to the same Ethernet port on the router. The pings that do come back have very low latency, less than 1 ms, as you’d expect from the router sitting across the room. I am using kernel 2.6.39, on Debian stable (I got the kernel from backports). Other than the kernel and a few related packages needed to get it going, the system is 100% Debian 6.0. The kernel detects the network hardware and loads the e1000e driver on boot. There is nothing strange in the logs. One other thing: in spite of the problem, the networking "works" if you can call it that. What I mean is I can also ping yahoo and google successfully. Of course I also lose ~ 50% of the packets in these cases too, but some packets _are_ coming back. The other devices connected to this router are all working fine. I am typing this on a machine connected to the same router. I am relatively experienced in Linux, but not sure where to even start with this issue. The only other thing I can think of is that the router is 10/100, not gigabit. Obviously that shouldn’t cause this issue, but maybe it’s related? OTOH, I’m pretty sure the last machine had gigabit Ethernet too. It was plugged into the same port on the same router. Yes, I’ve tried rebooting the router, and the machine, multiple times. I’m hoping someone here will have an idea. * * * UPDATE: @bdk makes some some good suggestions... wish I had good news! :( I tried a bunch more things, and got nowhere. I also grabbed some output from the system to include here. sometimes when I try to ping it can't find the host at all. if I try it again, it can connect. I assume this is just the first ping(s) failing. @bdk, the failures seem intermittent, at least I cannot see a pattern. Here are the relevant lines from dmesg, am I missing some red flag?               [    1.171187] e1000e: Intel(R) PRO/1000 Network Driver - 1.3.10-k2     [    1.171190] e1000e: Copyright(c) 1999 - 2011 Intel Corporation.     [    1.171225] e1000e 0000:00:19.0: PCI INT A -> GSI 20 (level, low) -> IRQ 20     [    1.171236] e1000e 0000:00:19.0: setting latency timer to 64     [    1.171339] e1000e 0000:00:19.0: irq 42 for MSI/MSI-X     [    1.460976] e1000e 0000:00:19.0: eth0: (PCI Express:2.5GB/s:Width x1) e0:69:95:dd:5d:d9     [    1.460979] e1000e 0000:00:19.0: eth0: Intel(R) PRO/1000 Network Connection     [    1.461015] e1000e 0000:00:19.0: eth0: MAC: 10, PHY: 11, PBA No: FFFFFF-0FF     [   48.475222] e1000e 0000:00:19.0: irq 42 for MSI/MSI-X     [   48.530979] e1000e 0000:00:19.0: irq 42 for MSI/MSI-X     [   50.120859] e1000e: eth0 NIC Link is Up 100 Mbps Full Duplex, Flow Control: Rx/Tx     [   50.120863] e1000e 0000:00:19.0: eth0: 10/100 speed: disabling TSO      things I tried that did not help: installed `linux-firmware-free`, `linux-firmware-nonfree`, in case there was a better firmware available (there wasn't, or at least the kernel didn't find it) played with aspm in the BIOS, others have reported aspm causing problems for e1000e ethernet (didn't help) completely disabled `pcie_aspm` in the kernel, in case that was causing the problem (it wasn't, but disabling it did introduce new problems) `mii-tool` is apparently not supported by this chip? is there a special intel tool to use instead? when I took a look at `tcpdump`, things started looking more grim. not only are some of the packets not making it back, some aren't even making it _out!_               14:25:01.162331 IP debian.local > 74.125.224.80: ICMP echo request, id 2334, seq 1, length 64     14:25:02.168630 IP debian.local > 74.125.224.80: ICMP echo request, id 2334, seq 2, length 64     14:25:02.228192 IP 74.125.224.80 > debian.local: ICMP echo reply, id 2334, seq 2, length 64     14:25:07.236359 IP debian.local > 74.125.224.80: ICMP echo request, id 2334, seq 3, length 64     14:25:07.259431 IP 74.125.224.80 > debian.local: ICMP echo reply, id 2334, seq 3, length 64     14:25:31.307707 IP debian.local > 74.125.224.80: ICMP echo request, id 2334, seq 9, length 64     14:25:32.316628 IP debian.local > 74.125.224.80: ICMP echo request, id 2334, seq 10, length 64     14:25:33.324623 IP debian.local > 74.125.224.80: ICMP echo request, id 2334, seq 11, length 64     14:25:33.349896 IP 74.125.224.80 > debian.local: ICMP echo reply, id 2334, seq 11, length 64     14:25:43.368625 IP debian.local > 74.125.224.80: ICMP echo request, id 2334, seq 17, length 64     14:25:43.394590 IP 74.125.224.80 > debian.local: ICMP echo reply, id 2334, seq 17, length 64     14:26:18.518391 IP debian.local > 74.125.224.80: ICMP echo request, id 2334, seq 30, length 64     14:26:18.537866 IP 74.125.224.80 > debian.local: ICMP echo reply, id 2334, seq 30, length 64     14:26:19.519554 IP debian.local > 74.125.224.80: ICMP echo request, id 2334, seq 31, length 64     14:26:20.518588 IP debian.local > 74.125.224.80: ICMP echo request, id 2334, seq 32, length 64     14:26:21.518559 IP debian.local > 74.125.224.80: ICMP echo request, id 2334, seq 33, length 64     14:26:21.538623 IP 74.125.224.80 > debian.local: ICMP echo reply, id 2334, seq 33, length 64     14:26:37.573641 IP debian.local > 74.125.224.80: ICMP echo request, id 2334, seq 35, length 64     14:26:38.580648 IP debian.local > 74.125.224.80: ICMP echo request, id 2334, seq 36, length 64     14:26:38.602195 IP 74.125.224.80 > debian.local: ICMP echo reply, id 2334, seq 36, length 64      notice the request sequence, how it goes 1, 2, 3... 9??! that can't be good. I know Sandy Bridge is still relatively new, but Linux does work... right? Could this be bad hardware? No way... right? _sigh...._ maybe I should just go back to the old system.


title: Find files without a number

text: I am trying to write a simple script that will iterate through all drives except sda. Right now I have this               for i in $(find /dev/ -name "sd*" ! -name "sda*")     do             echo $i     done      However this includes partitions like `/dev/sdb1`, whereas I only want the root drive like `/dev/sdb`. How do I modify the find statement to guarantee I don't get any of the numbered files?


title: Understanding behavior of subshell and stdout with pipe

text: Let us say I have `.c` file and corresponding executable (let us say foo) that takes in some input from stdin and then makes a sys call to `/bin/sh`. Feeding input to this executable like following:               python -c "<some script to feed input>" | ./foo      I observed that the shell invoked by foo closes immediately and foo terminates. However, someone on IRC recommended that executing like this:               (python -c "<some script to feed input>"; cat) | ./foo      keeps the subshell invoked by `./foo` still running. I would like to know what is going on here. My Speculation: For the first case, Does the stdout of the python script close as soon as it's done thus sending EOF to the stdin of the process `./foo` terminating `./foo`? But that does not make sense to me as the sys call should be a blocking one leading to `./foo` not terminating. I would appreciate help and a pointer to resources to fix erroneous understanding. Thanks!


title: ArchLinux how to setup English Language with german keyboardlayout

text: Can anyone explain me how to setup up ArchLinux to be completely in English except for the KeyboardLayout? (it should be de-latin1-nodeadkeys)


title: cron midnight 00 24 or 00 00?

text: My current crontab looks like this: 00 00 * * 1-5 "/home/user/script.sh" But it seems like it is not being triggered, all others are triggering fine except the one running at midnight. What is the proper format for midnight? 00 00 or 00 24?


title: How to query RIPE database on the command line?

text: Using the stock `whois` (on Fedora) I can easily get information for an IP adress:               $ whois SOME_IP     % This is the RIPE Database query service.     % The objects are in RPSL format.     %     % The RIPE Database is subject to Terms and Conditions.     [..]     % Information related to 'SOME_IP/SOME_AS'     route:     SOME_ROUTE     mnt-by:    SOME_STRING     [..]      Now I want to inverse lookup entries that have the SOME_STRING in 'mnt-by'. I've done that successfully via the RIPE web interface. But how to do that via the command line? (e.g. for easier post-processing/scripting) RIPE documents the `-i` option, but:               $ whois.md -h riswhois.ripe.net -i mnt-by SOME_STRING     Warning: RIPE flags used with a traditional server.     [just options listing without -i]     $ jwhois -h riswhois.ripe.net -i mnt-by SOME_STRING     [Querying riswhois.ripe.net]     [riswhois.ripe.net]     % This is RIPE NCC's Routing Information Service     % whois gateway to collected BGP Routing Tables     % IPv4 or IPv6 address to origin prefix match     %     % For more information visit http://www.ripe.net/ris/riswhois.html          % ERROR: Invalid search key      Am I supposed to use another whois client for such queries?


title: Are there any non-GPL linux package managers?

text: I'm looking for a linux package manager for personal project. The main criterium is non-GPL (and it's variants) license. So far I've managed to find that only Slackware's pkgtools meet this rule, but there surely must be others! I like pkgtools, but I like choice even more ;p What other - non-GPL - linux package management systems are there? ( _I assume the list to be short so it's not an open ended question)_


title: How to upgrade Redhat 5.5 to 5.6

text: We have two server running on RHEL 5.5. Now we have to upgrade it to 5.6 What are the steps to upgrade it and also the prerequisites


title: How do I scan grayscale with simple-scan?

text: I really like `simple-scan` because:   1. It's really simple   2. It has an interface that fits with GNOME setup on Debian (unlike Skanlite)  However, I can't seem to be able to set it to scan in grayscale. How can I do this? The two options, `photo` and `text` seem to serve as _colour_ and _B &W_ respectively, which is a problem when I want to scan documents with a high level of detail but without colour (I scan a lot of documents and storage becomes an issue). Anyway, I realise that the ideal solution would be to use a proper scanning tool, but since I'm really just after exactly what `simple-scan` offers with one tiny extra feature I thought I'd ask in case someone knew how to set this up (maybe I can add a "grayscale" profile to the list?)


title: How to say which process slows down boot (bootchart)

text: So my computer boots up for 150s and I can clearly see that it does nothing between 40-105s. Can You help me determine which process is responsible for this waste of time? ![bootchart](http://i.stack.imgur.com/PMi3X.png)


title: Undo `mv` command?

text: > **Possible Duplicate:**   >  Moved bin and other folders! How to get them back? Hi I'm in desperate need of help. I'm quite new to linux so please bear with my stupidity! I entered the following command, which I know is not correct and I think I've moved everything to "../", can I do anything to recover from this:               mv /* ../


title: Windowing system strictly for code editing?

text: I'm a usability obsessive and I can't help dreaming about how nice it would be to have a windowing system configured for nothing but editing code... mostly it would be ultra minimalist, with just window frames for text, find/replace, window management commands, buffer processing commands, and the most simple file management Can you think of any windowing systems that are really just about editing code/text? Note: as much as you would like it to, console doesn't count because that's not a windowing system!


title: MEncoder install issue

text: I'm looking for a simple install guide for `mencoder` on a linux server via SSH. Every guide I've come to so far links me to out of date versions.


title: Can I install PHP on a Chumby One?

text: I'm enjoying hacking my Chumby One. However, I'd prefer if I could run PHP on it. I have `perl` and `python` installed. Does anyone know if I can compile PHP for it or if there is a ready made distro for Chumby that includes PHP?


title: dual boot solaris with ubuntu?

text: I have installed Solaris on my x86 machine (taking 100gb of 500gb). Now I have installed Ubuntu on the system (in another 100gb). I want to make primary OS as Solaris. I know setting have to be done in `/boot/grub/menu.lst`, but what is the actual command to be updated? When I restart the system after updating the menu file it shows only Solaris menu and no Ubuntu options.


title: NAT (Internet connection sharing) switching between multiple public interfaces

text: My Ubuntu 12.04 (precise) laptop has three network interfaces:   1. `eth0`: wired interface sometimes connected to the Internet   2. `wlan0`: wireless interface sometimes connected to the Internet   3. `vboxnet0`: wired interface (actually a VirtualBox virtual interface) connected to another computer (actually a VirtualBox virtual machine with networking in host-only mode) I'd like to use `iptables` to set up NAT/IP masquerading to share whichever Internet connection is up (preferring the wired if both are up) with the other computer. The following works when `eth0` is plugged in:               echo 1 | sudo tee /proc/sys/net/ipv4/ip_forward &&     sudo iptables -t nat -A POSTROUTING -o eth0 -j MASQUERADE &&     sudo iptables -A FORWARD -i eth0 -o vboxnet0 -m conntrack --ctstate RELATED,ESTABLISHED -j ACCEPT &&     sudo iptables -A FORWARD -i vboxnet0 -o eth0 -j ACCEPT      If I switch from wired to wireless, this obviously stops working. I tried:               echo 1 | sudo tee /proc/sys/net/ipv4/ip_forward &&     sudo iptables -t nat -A POSTROUTING -o '!vboxnet0' -j MASQUERADE &&     sudo iptables -A FORWARD -i '!vboxnet0' -o vboxnet0 -m conntrack --ctstate RELATED,ESTABLISHED -j ACCEPT &&     sudo iptables -A FORWARD -i vboxnet0 -o '!vboxnet0' -j ACCEPT      but it did not work. I could try to do some Network Manager scripts to change the `iptables` rules whenever an interfaces goes up or down, but I figured it would be possible without jumping through such hoops. Any suggestions?


title: Multiple path environment variable setup lines with bash

text: I have very long `export PATH=A:B:C ...`. Can I make a multiple lines to have more organized one as follows?               export PATH = A:                   B:                   C:


title: in zsh, how do I hide the backslashes in the completion menu

text: On Mac OS X 10.6, zsh. I have set in .zshrc:               setopt automenu      …to get a completion menu below the prompt. When I type:               cd <TAB>      I see a completion menu with all directories that have spaces in their names having those spaces escaped with a backslash. I would like them to be displayed without the escaping backslash for better readability. This works in bash and in tcsh and when I do run `ls` from zsh. I don't see the ugly slashes. The actual line on the prompt of course needs those escaped spaces for the command to work, but the list of directories below shouldn't show them escaped. Can anyone demonstrate how to achieve this? I have not found a setting to change the output in the completion menu


title: SSH authentication using gssapi-keyex or gssapi-with-mic (publickey not permitted)

text: My company has disabled SSH public key authentication, therefore I have to manually enter each time my password (I am not suppose to change `/etc/ssh/sshd_config`). However `gssapi-keyex` and `gssapi-with-mic` authentications are enabled (please see below `ssh` debug output). **How could I use automatic login in this case?**   **Can I exploit`gssapi-keyex` and/or `gssapi-with-mic` authentications?**               > ssh -v -o PreferredAuthentications=publickey hostxx.domainxx     OpenSSH_5.3p1, OpenSSL 1.0.0-fips 29 Mar 2010     debug1: Reading configuration data /etc/ssh/ssh_config     debug1: Applying options for *     debug1: Connecting to hostxx.domainxx [11.22.33.44] port 22.     debug1: Connection established.     debug1: identity file /home/me/.ssh/identity type -1     debug1: identity file /home/me/.ssh/id_rsa type -1     debug1: identity file /home/me/.ssh/id_dsa type 2     debug1: Remote protocol version 2.0, remote software version OpenSSH_5.3     debug1: match: OpenSSH_5.3 pat OpenSSH*     debug1: Enabling compatibility mode for protocol 2.0     debug1: Local version string SSH-2.0-OpenSSH_5.3     debug1: SSH2_MSG_KEXINIT sent     debug1: SSH2_MSG_KEXINIT received     debug1: kex: server->client aes128-ctr hmac-md5 none     debug1: kex: client->server aes128-ctr hmac-md5 none     debug1: SSH2_MSG_KEX_DH_GEX_REQUEST(1024<1024<8192) sent     debug1: expecting SSH2_MSG_KEX_DH_GEX_GROUP     debug1: SSH2_MSG_KEX_DH_GEX_INIT sent     debug1: expecting SSH2_MSG_KEX_DH_GEX_REPLY     debug1: Host 'hostxx.domainxx' is known and matches the RSA host key.     debug1: Found key in /home/me/.ssh/known_hosts:2     debug1: ssh_rsa_verify: signature correct     debug1: SSH2_MSG_NEWKEYS sent     debug1: expecting SSH2_MSG_NEWKEYS     debug1: SSH2_MSG_NEWKEYS received     debug1: SSH2_MSG_SERVICE_REQUEST sent     debug1: SSH2_MSG_SERVICE_ACCEPT received     debug1: Authentications that can continue: gssapi-keyex,gssapi-with-mic,password     debug1: No more authentication methods to try.     Permission denied (gssapi-keyex,gssapi-with-mic,password).


title: How to enable quotas in the fstab file?

text: I want to enable quotas. My fstab currently has:               # <file system> <mount point>   <type>  <options>       <dump>  <pass>     proc            /proc           proc    nodev,noexec,nosuid 0       0     # / was on /dev/sda1 during installation     UUID=97439827-cdb6-4406-8403-76ab1de7a3b0 /               ext4    errors=remount-ro 0       1     # swap was on /dev/sda5 during installation     UUID=194bd177-cba0-415d-b45d-bd87b7bf446e none            swap    sw              0       0     durrantm:~/Dropbox/96_2013/work/code     $       If I want to add `usrquota,grpquota` to enable user and group quotas, do I put them after `errors=remount-rov`, e.g. `errors=remount-rov,usrquota,grpquota`


title: Remote for-loop over SSH

text: I have the following in a script               for server in ${servers[@]}; do      echo ${server}      ssh user@${server} "for i in /tmp/foo* ; do echo ${i}; done"     done      But it doesn't work. Weird thing, I see $I amount of return lines. So if I have ten files, I see ten blank lines.


title: How to keep upstart installed-always, don't be replaced by sysvinit?

text: Each time I do `apt-get dist-upgrade`, the package `sysvinit` comes back and replaced `upstart`. Well, I have some scripts written for upstart, and I need to reinstall it every time (typing the annoying confirmation `Yes, do as I say!`) How can I flag it as a solid rock choice, so it won't be replaced forever?


title: How do I backup a non-empty directory and preserve metadata like permissions/user-group ownership/time file was modified?

text: I used `rsync` for creating a backup copy:               bash-3.2$ rsync -tvrog /export/home/kent/Scripts /export/home/kent/TEST_Scripts_rsync      With these options:               Options:           -v, --verbose               increase verbosity           -r, --recursive             recurse into directories           -o, --owner                 preserve owner (super-user only)           -g, --group                 preserve group      Observe the Source directory contents:               bash-3.2$ cd /export/home/kent/Scripts     bash-3.2$ ls -l     total 170     -rw-r--r--   1 kent   kent        74 Feb  5 07:10 1.sh     drwxr-xr-x   2 kent   kent         2 Jun 17 06:21 456     -rwxrwxrwx   1 kent   kent       355 Feb  5 07:10 App_recreate.msh     ...      Destination:               bash-3.2$ cd TEST_Scripts_rsync/Scripts/     bash-3.2$ ls -l     total 168     -rw-r--r--   1 kent   kent        74 Feb  5 07:10 1.sh     drwxr-xr-x   2 kent   kent         2 Jun 17 06:21 456     -rwxr-xr-x   1 kent   kent       355 Feb  5 07:10 App_recreate.msh     ...      Note that the permissions have changed for `App_recreate.msh`. So is there a way to preserve the permissions at the least if not also preserve the last modified date? Note that I traversed all the directories from `/` to `/export/home/kent/` but couldn't find a sticky bit that might be responsible for masking the permissions. * * * **Note:**   * Once done, I may have to do an incremental backup using rsync - so I guess simply tar-ing the files wouldn't be of much help.


title: Generate File of a certain size?

text: I'd like to generate a file with the name `example.file`. I could use               touch example.file      but I want the file to be exactly 24MB in size. I already checked the manpage of touch, but there is no parameter like this. Is there an easy way to generate files of a certain size?


title: Error while Converting Excel to CSV using xls2csv

text: I am using xls2csv to convert a xls file into a regular .csv file. However, while using the command as               xls2csv -c\, fromfile.xls > tofile.csv      .I am getting the following error. Do not know what is it that I am doing wrong. Need help...               fromfile.xls is not OLE file or Error


title: What is the maximum length of an ssh-banner message?

text: It seems that if the banner message is longer than a certain limit, no banner at all will be displayed to the client. What is either the character or file size limit?


title: Does Lenovo builtin 3g modem work with debian (network-manager)

text: I'm going to buy laptop similar to this one: link (Lenovo W530), I'm considering buying internal 3G modem: (link, part no: 0A36319). Since I had some trouble with 3G modems previously I'd like to know whether it'll work well with linux (preferably debian, without doing any magic). I tried to google it but to no avail.


title: Why can't I use public/private key authentication with ssh on Arch Linux?

text: I have the following setup on an Ubuntu machine:               ~/dotfiles/authorized_keys2     ~/.ssh/authorized_keys2 -> /home/wayne/dotfiles/authorized_keys2      I had the same setup on my Arch machine, but when I connect with -v,               debug1: Authentications that can continue: publickey,password     debug1: Next authentication method: publickey     debug1: Offering RSA public key: /home/wayne/.ssh/id_rsa     debug1: Authentications that can continue: publickey,password      I found this page on the Arch Wiki, which has this line: > $ chmod 600 ~/.ssh/authorized_keys So I added another symlink: `authorized_keys -> /home/wayne/dotfiles/authorized_keys2` And yet still, no dice. And yes, I _have_ ensured that the correct key is present in `authorized_keys`. Why can I not connect using my keys? **Edit:** My permissions are set correctly on my home and ssh folders (and key file):               drwxr-x--x 150 wayne       family  13k Aug 27 07:38 wayne/     drwx------   2 wayne       family 4.1k Aug 27 07:24 .ssh/     -rw-------   1 wayne       family 6.4k Aug 20 07:01 authorized_keys2


title: Remove only the commas present within the double quotes

text: In a text file, I want to remove `,` (commas) and also the `"` (quotes) (only if the double quotes contains numbers seperated by commas).               56,72,"12,34,54",x,y,"foo,a,b,bar"      Expected ouput               56,72,123454,x,y,"foo,a,b,bar"      **Note:** I show the above line just as an example. My text file contains many lines like above and the numbers seperated by commas present within the double quotes should vary. That is,               56,72,"12,34,54",x,y,"foo,a,b,bar"     56,92,"12,34",x,y,"foo,a,b,bar"     56,72,"12,34,54,78,76,54,67",x,y,"foo,a,b,bar"     56,72,x,y,"foo,a,b,bar","12,34,54"     56,72,x,y,"foo,a,b,bar","12,34,54","45,57,84,92","bar,foo"      **Expected output:**               56,72,123454,x,y,"foo,a,b,bar"     56,92,1234,x,y,"foo,a,b,bar"     56,72,12345478765467,x,y,"foo,a,b,bar"     56,72,x,y,"foo,a,b,bar",123454     56,72,x,y,"foo,a,b,bar",123454,45578492,"bar,foo"      There a `n` number of numbers present within the double quotes seperated by commas.And also leave the double quotes which contains characters as it is. I love `sed` text processing tool. I'm happy if you post any `sed` solution for this.


title: Clobber everything to do with a package

text: I'm looking for a way to just remove every last trace of NodeJS and NPM anywhere on my system -- everything! I'm not concerned about losing data... I just want my system to be exactly as if I had never installed or downloaded NodeJS and NPM. Is there any way to do that? Assuming I've installed multiple versions by multiple means including building from source... ...FYI this is not a question about NodeJS or NPM.


title: Give me any package!

text: I'm running an older LTS version of Ubuntu and I cannot upgrade due to my VPS. Given that, is there any way I can force apt-get to let me have access to all the newest packages from any repository anywhere? ...such that if I just type `apt-get install anyPackageIveEverHeardOf` it won't complain? Note: this isn't asking to install all the packages, just to install any packages!


title: Raspberry Pi, serial console, minicom, and gnome-terminal

text: I'm trying to access my raspberry pi via its serial console on the gpio pins. It's working fine through a USB-3.3v serial dongle. However, there's a problem with long lines and long screens not displaying correctly. I'm running minicom in a gnome-terminal which is not set to 24x80 columns (and gnome-terminal's Terminal/1 (24x80) option) doesn't help. It's as if minicom completely ignores the sigwinch it must be getting, and/or has no way to send that over the serial line to change the terminal type.


title: One-liner to execute a process in a current directory with no output and disown it?

text: I'm trying to do something fairly simple:               $ ( cd /opt/myprogram && ./myprocess.sh >/dev/null 2>&1 & ; disown $! )     -bash: syntax error near unexpected token `;'      How can I bust out a one-liner to, in a sub-shell, execute a given script from a given folder, nulling the output, and sending it to the background?


title: Securely delete files on btrfs filesystem

text: Sometimes, there's the need to delete a file in a filesystem, and make sure that the file is truly gone. A file that contains sensitive passwords, for example, should be throughly wiped from the disk. Issuing a simple `rm` on a typical file system deletes the inode ("pointer") to the file, but it doesn't delete the file's content in the physical disk - these are left there until they are overwriten when the filesystem needs the free space. On many file systems, the shred program enables such secure deletion. However, on a CoW filesystem such as btrfs, this approach is useless. The problem is exacerbated by the fact that the file may be present on volume snapshots. Is there a way to securely delete **a file** on a btrfs filesystem? Is it sufficient to delete all pointers (on all volumes) and fill the free space with zeros?


title: Arch GRUB asking for /run/lvm/lvmetad.socket on a non lvm disk

text: I am running this script based on the ArchWiki setup procedure. It fails on the GRUB configuration step I am using the archlinux-2013.12.01-dual.iso inside VMware Player with 1 GB ram, `sda` is 810 MB. I have also mounted a CIFS share on the host machine.               # DEV=sda     # PART=sda1     # echo "1,,L,*" | sfdisk /dev/$DEV     # mkfs.ext3 /dev/$PART     # mount /dev/$PART /mnt     # pacstrap -i /mnt base      # genfstab -U -p /mnt >> /mnt/etc/fstab     # arch-chroot /mnt      # pacman -S grub     # pacman -S os-prober     # grub-mkconfig -o /boot/grub/grub.cfg      I get:               Generating grub configuration file ...     Found linux image: /boot/vmlinuz-linux     Found initrd image: /boot/initramfs-linux.img       /run/lvm/lvmetad.socket: connect failed: No such file or directory       WARNING: Failed to connect to lvmetad: No such file or directory. Falling back to internal scanning.       /run/lvm/lvmetad.socket: connect failed: No such file or directory       /run/lvm/lvmetad.socket: connect failed: No such file or directory       No volume groups found     error: out of memory.     error: syntax error.     error: Incorrect command.     error: syntax error.     Syntax error at line 164     Syntax errors are detected in generated GRUB config file.     Ensure that there are no errors in /etc/default/grub     and /etc/grub.d/* files or please file a bug report with     /boot/grub/grub.cfg.new file attached.done      I didn't install LVM partitions/drives.               # fdisk -l /dev/sda          Disk /dev/sda: 819 MiB, 858783744 bytes, 1677312 sectors     Units: sectors of 1 * 512 = 512 bytes     Sector size (logical/physical): 512 bytes / 512 bytes     I/O size (minimum/optimal): 512 bytes / 512 bytes     Disklabel type: dos     Disk identifier: 0x000d5a2a          Device    Boot Start       End Blocks  Id System     /dev/sda1       2048   1677311 837632  83 Linux               # lsblk           NAME              MAJ:MIN RM   SIZE RO TYPE MOUNTPOINT     fd0                 2:0    1     4K  0 disk      sda                 8:0    0   819M  0 disk      └─sda1              8:1    0   818M  0 part /mnt     sr0                11:0    1   522M  0 rom  /run/archiso/bootmnt     sr1                11:1    1    10M  0 rom       loop0               7:0    0 224.2M  1 loop /run/archiso/sfs/root-image     loop1               7:1    0   1.4G  1 loop      └─arch_root-image 254:0    0   1.4G  0 dm   /     loop2               7:2    0   1.4G  0 loop      └─arch_root-image 254:0    0   1.4G  0 dm   /      `/boot/grub/grub.cfg.new` is:               #     # DO NOT EDIT THIS FILE     #     # It is automatically generated by grub-mkconfig using templates     # from /etc/grub.d and settings from /etc/default/grub     #          ### BEGIN /etc/grub.d/00_header ###     insmod part_gpt     insmod part_msdos     if [ -s $prefix/grubenv ]; then       load_env     fi     if [ "${next_entry}" ] ; then        set default="${next_entry}"        set next_entry=        save_env next_entry        set boot_once=true     else        set default="0"     fi          if [ x"${feature_menuentry_id}" = xy ]; then       menuentry_id_option="--id"     else       menuentry_id_option=""     fi          export menuentry_id_option          if [ "${prev_saved_entry}" ]; then       set saved_entry="${prev_saved_entry}"       save_env saved_entry       set prev_saved_entry=       save_env prev_saved_entry       set boot_once=true     fi          function savedefault {       if [ -z "${boot_once}" ]; then         saved_entry="${chosen}"         save_env saved_entry       fi     }          function load_video {       if [ x$feature_all_video_module = xy ]; then         insmod all_video       else         insmod efi_gop         insmod efi_uga         insmod ieee1275_fb         insmod vbe         insmod vga         insmod video_bochs         insmod video_cirrus       fi     }          if [ x$feature_default_font_path = xy ] ; then        font=unicode     else     insmod part_msdos      insmod ext2     set root='hd0,msdos1'     if [ x$feature_platform_search_hint = xy ]; then       search --no-floppy --fs-uuid --set=root --hint-bios=hd0,msdos1 --hint-efi=hd0,msdos1 --hint-baremetal=ahci0,msdos1  9d1d349e-d061-4e0f-9312-be19ca2dcb74     else       search --no-floppy --fs-uuid --set=root 9d1d349e-d061-4e0f-9312-be19ca2dcb74     fi         font="/usr/share/grub/unicode.pf2"     fi          if loadfont $font ; then       set gfxmode=auto       load_video       insmod gfxterm       set locale_dir=$prefix/locale       set lang=en_US       insmod gettext     fi     terminal_input console     terminal_output gfxterm     set timeout=5     ### END /etc/grub.d/00_header ###          ### BEGIN /etc/grub.d/10_linux ###     menuentry 'Arch Linux, with Linux core repo kernel' --class arch --class gnu-linux --class gnu --class os $menuentry_id_option 'gnulinux-core repo kernel-true-9d1d349e-d061-4e0f-9312-be19ca2dcb74' {         load_video         set gfxpayload=keep         insmod gzio         insmod part_msdos          insmod ext2         set root='hd0,msdos1'         if [ x$feature_platform_search_hint = xy ]; then           search --no-floppy --fs-uuid --set=root --hint-bios=hd0,msdos1 --hint-efi=hd0,msdos1 --hint-baremetal=ahci0,msdos1  9d1d349e-d061-4e0f-9312-be19ca2dcb74         else           search --no-floppy --fs-uuid --set=root 9d1d349e-d061-4e0f-9312-be19ca2dcb74         fi         echo    'Loading Linux core repo kernel ...'         linux   /boot/vmlinuz-linux root=UUID=9d1d349e-d061-4e0f-9312-be19ca2dcb74 rw  quiet         echo    'Loading initial ramdisk ...'         initrd  /boot/initramfs-linux.img     }     menuentry 'Arch Linux, with Linux core repo kernel (Fallback initramfs)' --class arch --class gnu-linux --class gnu --class os $menuentry_id_option 'gnulinux-core repo kernel-fallback-9d1d349e-d061-4e0f-9312-be19ca2dcb74' {         load_video         set gfxpayload=keep         insmod gzio         insmod part_msdos          insmod ext2         set root='hd0,msdos1'         if [ x$feature_platform_search_hint = xy ]; then           search --no-floppy --fs-uuid --set=root --hint-bios=hd0,msdos1 --hint-efi=hd0,msdos1 --hint-baremetal=ahci0,msdos1  9d1d349e-d061-4e0f-9312-be19ca2dcb74         else           search --no-floppy --fs-uuid --set=root 9d1d349e-d061-4e0f-9312-be19ca2dcb74         fi         echo    'Loading Linux core repo kernel ...'         linux   /boot/vmlinuz-linux root=UUID=9d1d349e-d061-4e0f-9312-be19ca2dcb74 rw  quiet         echo    'Loading initial ramdisk ...'         initrd  /boot/initramfs-linux-fallback.img     }     menuentry 'Arch Linux' --class arch --class gnu-linux --class gnu --class os $menuentry_id_option 'gnulinux-simple-9d1d349e-d061-4e0f-9312-be19ca2dcb74' {         load_video         set gfxpayload=keep         insmod gzio         insmod part_msdos          insmod ext2         set root='hd0,msdos1'         if [ x$feature_platform_search_hint = xy ]; then           search --no-floppy --fs-uuid --set=root --hint-bios=hd0,msdos1 --hint-efi=hd0,msdos1 --hint-baremetal=ahci0,msdos1  9d1d349e-d061-4e0f-9312-be19ca2dcb74         else           search --no-floppy --fs-uuid --set=root 9d1d349e-d061-4e0f-9312-be19ca2dcb74         fi         echo    'Loading Linux core repo kernel ...'         linux   /boot/vmlinuz-linux root=UUID=9d1d349e-d061-4e0f-9312-be19ca2dcb74 rw  quiet         echo    'Loading initial ramdisk ...'         initrd  /boot/initramfs-linux-fallback.img     }     submenu 'Advanced options for Arch Linux' $menuentry_id_option 'gnulinux-advanced-9d1d349e-d061-4e0f-9312-be19ca2dcb74' {          ### END /etc/grub.d/10_linux ###          ### BEGIN /etc/grub.d/20_linux_xen ###     ### END /etc/grub.d/20_linux_xen ###          ### BEGIN /etc/grub.d/30_os-prober ###     ### END /etc/grub.d/30_os-prober ###          ### BEGIN /etc/grub.d/40_custom ###     # This file provides an easy way to add custom menu entries.  Simply type the     # menu entries you want to add after this comment.  Be careful not to change     # the 'exec tail' line above.     ### END /etc/grub.d/40_custom ###          ### BEGIN /etc/grub.d/41_custom ###     if [ -f  ${config_directory}/custom.cfg ]; then       source ${config_directory}/custom.cfg     elif [ -z "${config_directory}" -a -f  $prefix/custom.cfg ]; then       source $prefix/custom.cfg;     fi     ### END /etc/grub.d/41_custom ###          ### BEGIN /etc/grub.d/60_memtest86+ ###     ### END /etc/grub.d/60_memtest86+ ###


title: Zsh ssh tab completion not working as expected on OS X

text: I use Zsh on two different machines (OS X and Ubuntu) and the tab completion for ssh does not work the same way. More specifically hosts specified in the file `~/.ssh/config` is **NOT** used on OS X but it is used under Ubuntu. The exact same `zshrc`/`zshenv` and `~/.ssh/config` file is used on both systems (global configuration files are also ignored) so i have no idea why it does not work. Anyone got any ideas of what the problem can be? The only difference is the version number, on OS X i got Zsh 5.0.5 and under Ubuntu i got Zsh 5.0.2. **Update:** I tried Zsh 5.0.5 on Ubuntu and that still works so the different versions are not the problem. I've also downloaded and compiled Zsh on OS X and that still does not work so i know that Homebrew is also not the problem here.


title: Speed up copying 1000000 small files

text: I have 1000000 4-20 kb files in a dir. I need to copy that dir. But it seems I have to do a seek for each files so this takes quite a while. Is there a way in which I can speed this up? I am currently thinking that if I could get the disk blocks that these files occupy, I could sort those, merge the blocks that were close (given that sequential read is often faster than seeking) and read these blocks, so that they were in RAM cache (I have 32 GB RAM) before doing the copy. But for that to work I need a way to identify which blocks the files are on. I am using EXT4 on a magnetic device (i.e. not SSD). Edit: This ought to work but it does not:               ls |     parallel -IOO --pipe "sudo parallel -j100 hdparm --fibmap {}'|tail -n +5'" |     sort -nk 2 |      perl -ane 'if($u+10000 < $F[1]) { print "$l ",($u-$l),"\n"; $l=$F[1] } $u=$F[2]' |     sudo parallel --colsep ' ' dd if=/dev/sda1 skip={1} bs=512 count={2} '| cat >/dev/null'      When testing it on a big file it does not cache the file. Edit2: Here are some benchmarks. Cache was flushed (`echo 3 >/proc/sys/vm/drop_caches`) between each run. Measurements done with `iostats -dkx 5`.               rsync -Hav foo/ bar/: 1800 KB/s     cp -a foo/ bar/: 3600 KB/s     cat sort-by-inode | parallel -j1 -X cp foo/{} bar/: 5000 KB/s     cat sort-by-inode | shuf | parallel -j1 -X cp foo/{} bar/: 3000 KB/s     cat sort-by-inode | shuf | parallel -j10 -X cp foo/{} bar/: 7000 KB/s     cat sort-by-inode | parallel -j10 -X cp foo/{} bar/: 8000 KB/s     cat sort-by-inode | parallel -j100 -X cp foo/{} bar/: 9000 KB/s     cat sort-by-inode | parallel -j500 -X cp foo/{} bar/: 10000 KB/s      So what can we learn from that? It seems sorting by inode is a good idea. But it seems parallelizing multiple `cp` boosts performance even further. It is worth stressing that the source `foo/` is a magnetic disk, so this attacks the myth that parallelizing I/O to a single spindle will not speed up I/O: Parallelizing clearly and consistently speeds up the copying here.


title: dual-monitor bugs during resolution setting

text: My OS is Slackware 13.37 64-bit. I have two monitors. Primary one supports 1920x1200 and the secondary one 1280x1024. I use this line to enable dual monitors in "non-clone" mode:               xrandr --output HDMI1 --primary --output VGA1 --left-of HDMI1      After I do this, the secondary monitor stops cloning the primary one and acquires its own virtual desktop. However, the primary gets the resolution 1280x1024. After I explicitly set it back to 1920x1200, the secondary monitor gets false info about its boundaries. The bottom part gets a bit longer such that the cursor disappears if I move too much to the bottom (as if there is still space below the monitor edge). How can I solve this issue? **EDIT:**               user@pc:~$ xrandr -q     Screen 0: minimum 320 x 200, current 3200 x 1200, maximum 8192 x 8192     VGA1 connected 1280x1024+0+176 (normal left inverted right x axis y axis) 376mm x 301mm        1280x1024      60.0*+   75.0          1152x864       75.0          1024x768       75.1     60.0          800x600        75.0     60.3          640x480        75.0     60.0          720x400        70.1       HDMI1 connected 1920x1200+1280+0 (normal left inverted right x axis y axis) 518mm x 324mm        1920x1200      60.0*+        1920x1080      50.0     60.0          1600x1200      60.0          1680x1050      60.0          1280x1024      60.0          1440x900       59.9          1280x960       60.0          1280x800       59.8          1280x720       50.0     60.0          1024x768       60.0          800x600        60.3     56.2          720x576        50.0          720x480        59.9          640x480        60.0       DP1 disconnected (normal left inverted right x axis y axis)


title: How to send output to both screen and mail?

text: I use the following to send an email at the end of a script.               echo "Script finished on `date`" | /usr/bin/Mail -s "Script complete" "myaccount@myserver.com".      However, I want to echo the same message onto the screen as well. How do I do that in the same statement?


title: Which Scheduling algorithm is used in Linux?

text: Recently in an interview I was asked about the Scheduling algorithm used by Linux Operating system. What is the algorithm used any why? Also, what algorithm is used in in real-time operating systems and why?


title: What Windows-related files are valueless to *nix users?

text: I have accumulated, from my time using Windows a good quantity of held-over filesystem copies and archives of system and data drives. I am trying to distill them down to the usable parts while discarding everything that is likely to be valueless. From watching a bunch of said files scroll by while copying, once again, from a holding drive to a work drive I think I've got a starter list of "good" and "useless" files started, but I was wondering if there is any authoritative kind of list of files (coming from a previously Windows environment) that should be discarded immediately as unuseful? **Winners:** (I know this list would likely turn into a mess if any effort were made to make it comprehensive, so these aren't what I'm looking for, unless they would likely be surrounded by crap that might get them destroyed inadvertently) ( _edit: If the ONLY way is a super-comprehensive white-list- based method, so be it. I'd prefer if that weren't the case, but beggars can't be choosers... most of the time._ )               *.tar.*, *.rar, *.zip     *.mp(e)g, *.avi, *.mkv, *.wmv, *.asf      **Losers:** (These are what I'm really looking for)               *.exe, *.bat, *.dll, *.com, *.lnk      I also know there will be exceptions. Like installer .exe files, used to install something in Wine. For purposes of this question, this concern isn't one. All the files in question are copies (of copies, possibly of even more copies), so the installers I really want to keep are somewhere nice, safe, and probably write-protected.


title: Mouse skips in Mint

text: I've just installed Linux Mint 13 (Cinnamon, 64big) and am enjoying it. However, my mouse (which has been reliable for years on Windows) is no longer accurate. It will skip around while I move it (Not a problem in normal usage, but irritating as all get out for small buttons or delicate copy/pastes) I've played with the mouse settings (sensitivity/acceleration), but that didn't change anything. I'm using a Logitech G5 mouse.


title: Limited SSH user on Ubuntu 12

text: I'm running Minecraft on a server. How can I give my friend SSH access just to the minecraft folder (a root folder), the `screen` command, and some ports?


title: Install of Gentoo: Can't find root device (boot of LiveCD from HardDrive)

text: I am attempting to install Gentoo on my PowerPC Mac. I have reached the point where I can boot the LiveCD (I have no CD Drive, so it is from my Hard Drive), but after the kernel is loaded, I get a message `"No root found at ultra1:,\boot\ppc32` or something to that effect. It then gives me the options: `shell to get into a shell, q to skip, enter to try the same again`. `q` to skip doesn't work, but it prints a nice warning `>> Skipping. This will likely cause a boot error.` Then it `can't find /newroot in /etc/SOMETHING` (I can't remember). The shell won't really help me, if I try: `dev/hda` (the only thing I can find in /dev that looks like the second internal harddrive I am booting from), I only get the nice warning `No mountable filesystems!`. Any advice for what to set the root to? I'd just use the `root=foo` from yaboot, but I don't know what to set foo to. Thanks!


title: How to select packages start with "mate-" but not end with "-dev"?

text: I want to install all MATE packages,               $ sudo apt-get install '^mate'      However, it selects too many packages, and some packages are conflicted with some installed ones. Now, I want to exclude them. Any idea? No surprise, this won't work:               $ sudo apt-get install '^mate && !-dev'      Or, can I simply let apt-get ignore those conflicted packages?


title: What's kind of "secure delete" built-in installation

text: Just curious while waiting installation process complete. What's kind of "secure delete" that distros like Debain, Ubuntu and Linux Mint using when users would like to create encrypted volume?


title: Making a RPM package without the source

text: Say, I have a certain program that I need to convert to an RPM package. The source is not available to me, for various reasons. However, it seems that RPM packages cannot be made if one doesn't have the source (unlike other packages, especially Debian packages, which can even be constructed without `dpkg-deb`, by using the standard Linux tools). Is there some way I could make the package?


title: firefox + html5 + .asoundrc = No sound

text: Here's the problem: Manjaro Xfce/3.15.4, Alsa (No Pulse), Firefox 30 and 31, Gmusicbrowser, mplayer/smplayer   1. Firefox with youtube html5 player - no problems   2. Firefox with youtube html5 player and a basic .asoundrc - no audio   3. Firefox with standard flash player no problems   4. All other applications work with .asoundrc I've tried various settings in .asoundrc, this is the current version.               pcm.!default {     type hw     card 0     device 0     }          ctl.!default {     type hw                card 0     device 0     }      The reason I'm using the .asoundrc is to stop alsa resampling my 96000 tracks to 48000 and it works correctly.               card 0: SB [HDA ATI SB], device 0: ALC889 Analog [ALC889 Analog]     Subdevices: 1/1     Subdevice #0: subdevice #0     card 0: SB [HDA ATI SB], device 1: ALC889 Digital [ALC889 Digital]     Subdevices: 1/1     Subdevice #0: subdevice #0      Any ideas? Edit: I should mention, it's not just youtube. I have no sound with firefox/html5/.asoundrc anywhere.


title: How to enable Control key combinations for GNU screen on putty?

text: I am accessing a linux box via `ssh` using `putty`. Key combinations work fine when I'm not running `screen`. However, Ctrl key combinations do not work under a `screen` session. In fact, a `Ctrl`-`any key` is registered the same as the same key without the `Ctrl` combination. I know this by typing `Ctrl`-`V` and then a `Ctrl`-`key` combination to figure out what characters are sent to my terminal. For example, `Ctrl`-`◄` (left arrow) gives me `^[[D` on `screen` (screen256-color term). `◄` gives me the same result. Weird thing is that `Alt`-`key` combinations work fine. In particular, I would like to get the 'forward-word' and 'backward-word' key bindings working under `screen`. I have tried modifying `.inputrc` to work with various terminals. As such, my `.inputrc` looks something like this:               $if term=xterm         'xxx' : forward-word # xxx key gotten from Ctrl-V         'xxx' : backward-word     $endif     $if term=screen-256color     ...     ...      I have also tried various terminals by setting the `TERM` of my `bash` profile, setting `TERM` on `.screenrc`, and setting the `Putty` keyboard terminal mappings. The obvious ones, `linux` and `xterm`, don't work. However, I haven't tried every permutation of settings for obvious reasons. Additional info: I stand corrected, arrow key combinations are the only combinations that do not work. The distro is RHEL 6. .screenrc:               term xterm # tried other terms as well     shell -$SHELL # login shell to reload configs     caption string "%w"     hardstatus alwayslastline "%{b kw}%H %{r}%1` %{w}| %{g}%c %{w}| %{y}%d.%m.%Y %{w}| %{g}%l %{w}| %{-b kw}%u %-Lw%{= rW}%50> %n%f %t %{-}%+Lw%<"     vbell off     defscrollback 5000      Putty's default keyboard mode `ESC [n~`. Taken from the putty manual: "In the default mode, labelled ESC [n~, the function keys generate sequences like ESC [11~, ESC [12~ and so on. This matches the general behaviour of Digital's terminals." Interestingly, what's actually sent by `Putty` (by following the first answer on http://superuser.com/questions/342848/cant-get-keyboard-to-work-correctly- in-putty), is               ^[0D : left-arrow     ^[[D : Ctrl-{left-arrow}      Since the they are different, I guess `putty` isn't the issue then? FWIW, I tried changing the Application Cursor key mode settings on Putty, but to no avail. I also tried using `tmux`, only to encounter the same issue.


title: Script to toggle setxkbmap

text: I would like a bash script that toggles between: `setxkbmap se` and `setxkbmap us`. Then my intentions are to map that script to `Ctrl``Esc` through the Keyboard > custom shortcuts. The point is that I want to switch keyboard layout with `Ctrl``Escape`. How can I implement that?


title: Why "reverse-i-search" does not work on my centos sytem?

text: When i press `CTRL`+`r`, the "reaverse-i-search" works well: ![enter image description here](http://i.stack.imgur.com/9HpUR.jpg) but then when i press "arrow up" key, none history commands show, just nothing happens! Any configuration not compare?


title: Network icons showing not connected when my wired network cable shows that I am

text: One day the power just went off when was using my desktop computer running Ubuntu 11.04. When later the power came back, I couldn't access the internet. When I open any browser, it tells me I have no connection. Even my desktop network icon shows that I am offline. But when I check the wired connection behind my desktop computer, it shows that I connected with a green blinking LED. What is going on with my desktop? All the computers in our lab are fine. Only mine which I use to administer our computer lab has this problem.   1. When I run the iconfig command this is what I get:              eth0      Link encap:Ethernet  HWaddr b8:ac:6f:37:0d:58                 inet6 addr: fe80::baac:6fff:fe37:d58/64 Scope:Link               UP BROADCAST RUNNING MULTICAST  MTU:1500  Metric:1               RX packets:2759 errors:0 dropped:0 overruns:0 frame:0               TX packets:27 errors:0 dropped:0 overruns:0 carrier:0               collisions:0 txqueuelen:1000                RX bytes:479931 (479.9 KB)  TX bytes:6608 (6.6 KB)               Interrupt:16           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:16436  Metric:1               RX packets:118 errors:0 dropped:0 overruns:0 frame:0               TX packets:118 errors:0 dropped:0 overruns:0 carrier:0               collisions:0 txqueuelen:0                RX bytes:13086 (13.0 KB)  TX bytes:13086 (13.0 KB)        2. And when I run the route -n command, this is what I get:              Kernel IP routing table     Destination     Gateway         Genmask         Flags Metric Ref    Use Iface


title: Allowing a domain name in my IP Tables

text: I have a Linux server that gets a time offset for some strange reason. I set up cron job to run and update the time using the following command:               /usr/sbin/ntpdate pool.ntp.org      The problem is the command would not run because I have a firewall (iptables). I have always used IP to allow traffic in my network:               iptables -A INPUT -p tcp -m tcp -i eth0 -s 11.11.11.11 --dport 5060 -j ACCEPT      I would like to know how to do it using a domain name in this case would be `pool.ntp.org`, or maybe someone could tell me a better way to keep the clocks in sync.


title: Expand placeholders with same-named environment vars in text file?

text: There are a lot of variations on this question, but I wanted to ask it here anyways because I am so close (!) to finding a solution on this one - I just need a little nudge. ## Scenario I have several text SQL files that I use to run reports on a Postgres database hosted with Heroku. One of the SQL files currently looks like this:               SELECT       (SELECT COUNT(*) FROM metrics WHERE(organization_id = o.id AND year = ${sql_year})) AS metrics,       (SELECT COUNT(*) FROM my_metrics WHERE(organization_id = o.id)) AS quarterly_metrics,       (SELECT COUNT(*) FROM quarterly_metrics WHERE(organization_id = o.id AND year = ${sql_year})) AS quarterly_metrics,       (SELECT COUNT(*) FROM quarterly_text_metrics WHERE(organization_id = o.id AND year = ${sql_year})) AS quarterly_text_metrics,       (SELECT COUNT(*) FROM budgets WHERE(organization_id = o.id AND year = ${sql_year})) AS budgets,       (SELECT COUNT(*) FROM goals WHERE(goalable_type = 'Organization' AND goalable_id = o.id AND year = ${sql_year})) AS goals     FROM       organizations AS o     WHERE       o.id = ${sql_org_id}     ;      I would **like** to use a process like this:               export sql_org_id=1; export sql_year=2013     cat reports/my_report.sql | sed -e "s/\(\${[a-zA-Z_]*}\)/`eval "echo '\1'"`/" | heroku pg:psql      So that I can just pipe the SQL to Heroku for the report, replacing all the variables with their corresponding ENV vars that were exported just before running the script (so that I can simply change the variables on the fly and run additional reports instead of editing the SQL file). ## My Problem So the issue is that I am **almost** there, but I can't quite get it. The `sed` expression I have works when I use `echo` like this:               export sql_year=2013     echo "SELECT ${sql_year} AS year" | sed -e "s/\(\${[a-zA-Z_]*}\)/`eval "echo '\1'"`/"      But I can't get it to work with `cat` on the entire file contents:               export sql_org_id=1; export sql_year=2013     cat reports/my_report.sql | sed -e "s/\(\${[a-zA-Z_]*}\)/`eval "echo '\1'"`/"      Am I missing something when using `sed` with `cat`? Please help! **UPDATE:** I am on Mac OS X 10.8


title: how do you sort du output by size?

text: How do you sort `du -sh /dir/*` by size? I read one site that said use `| sort -n` but that's obviously not right. Here's an example that is wrong.               [~]# du -sh /var/* | sort -n     0       /var/mail     1.2M    /var/www     1.8M    /var/tmp     1.9G    /var/named     2.9M    /var/run     4.1G    /var/log     8.0K    /var/account     8.0K    /var/crash     8.0K    /var/cvs     8.0K    /var/games     8.0K    /var/local     8.0K    /var/nis     8.0K    /var/opt     8.0K    /var/preserve     8.0K    /var/racoon     12K     /var/aquota.user     12K     /var/portsentry     16K     /var/ftp     16K     /var/quota.user     20K     /var/yp     24K     /var/db     28K     /var/empty     32K     /var/lock     84K     /var/profiles     224M    /var/netenberg     235M    /var/cpanel     245M    /var/cache     620M    /var/lib     748K    /var/spool


title: Show human readable file size in du

text: I'm using this command to determine which directory is eating my disk.               du -sk * | sort -n      How can I get human readable result form `du` for file sizes? I've checked `man` and all it have is `-k` flag which turns byte results to kilobyte results. I need results in gigabytes


title: Graphical boot ModeLine

text: Bit of a weird requirement. I have an arcade machine running Linux. The arcade monitor requires the video signal to be at 15khz, so I achieve this with a modeline in `xorg.conf`, it works great. There is a small PCB in the machine that will only let the correct video signal pass through to the monitor to prevent damage. This system works, but if I ever want to see messages as the system boots, I need to plug in an external monitor that can display at a higher refresh rate. Once the X server starts then things become visible on the arcade monitor. I'm OK with being unable to see message from the motherboard's BIOS, but what I would like to know is if there is any way to modify how the kernel outputs its messages. I know it's possible to have a graphical boot, but is it possible to run a custom modeline?


title: Alternative Window Manager

text: Is there a window manager, easy to install on Debian, that uses very little resources? I only need bash and Firefox/Chrome, java and flash. And maybe something like notepad++ for Linux. Though I'm rather quick with Vi. My Samsung NC10 is running far too slow with Ubuntu/Gnome.


title: Permissions in Ext4 Truecrypt Drive

text: I just used the Truecrypt GUI to encrypt my entire USB hard drive (currently /dev/sdb). I formatted it to ext4. Now, I can mount it in my home directory with the command > truecrypt --mount /dev/sdb USB-Device For some reason I don't have read/write permission. So my question is: How do I get read/write permission? Is it a drive-specific issue, or a system issue? It wouldn't surprise me if there was just a group I had to add my user account to. Additionally, I'm running Arch Linux, but I'm pretty sure that's not entirely relevant.


title: /etc/init.d permissions issue

text: We are trying to harden our Linux Redhat 5 servers and one of the findings is for the `/etc/init.d`. The security finding is requiring that we `chmod` it to _700_ or more restrictive. Please see the detail below. > incorrect permissions=rwxr-xr-x (0755) > > directory=/etc/init.d -> /etc/rc.d/init.d What's the best way to resolve this issue? I am aware that I can `chmod 700 /etc/init.d` but that reverses for some reason.


title: How to re-size virtual disk with installed Linux system?

text: I've got hard system configuration there and I don't want to re-install it again but I need more space now. Current system space is 30GB. Seems like it's not possible to re-size disk so what I need is to re-init my system on new disk and here I have some questions.   * I will copy all the data to host machine first (windows), is it safe, can I lost data (break symlinks) by doing this?   * I just make same partitions with same filesystems and move data there - is it enough?   * grub:2 is installed on special partition (EF02 GPT code) - is it movable?   * Is there another ways to make such transfer or virtual drive re-size?


title: Encrypting and compressing

text: Is there a better way to compress and then encrypt files other than `tar` followed by `openssl` or `gpg`?


title: Is it possible to use comments in virsh / libvirt xml files?

text: I am using.               virsh -c qemu:///system edit VM-Name      And adding comments.               <!-- test comment here -->      It won't complain.* But the comment is removed. *Usually if you make a syntax error (for example add an extra `>`) somewhere), it says something like this.               error: (domain_definition):75: Extra content at the end of the document     >     ^      Failed. Try again? [y,n,f,?]:      Is there any way to preserve comments in `virsh` / `libvirt` `xml` files?


title: copy mp3 to a target directory maintaining directory structure and deleting files when copy complete

text: Found this answer here for copying files and keeping directory structure. copy files               find . -name '*.xxx' -exec cp -iv --parents -t /path/to/target_dir {} +      Is there an easy way to maintain the list of copied files and delete the files from the source directory?


title: apt-get error: trying to overwrite shared 'filename', which is different from other instances of package 'package'

text: I tried installing several Ubuntu packages on Debian Wheezy, but it failed and now I have broken packages. The problem is, running `apt-get -f install` fails as well, with this error:               Preparing to replace libqtwebkit4:amd64 2.2.1-1ubuntu4 (using .../libqtwebkit4_2.2.1-5_amd64.deb) ...     Unpacking replacement libqtwebkit4:amd64 ...     dpkg: error processing /var/cache/apt/archives/libqtwebkit4_2.2.1-5_amd64.deb (--unpack):      trying to overwrite shared '/usr/share/doc/libqtwebkit4/changelog.Debian.gz', which is different from other instances of package libqtwebkit4:amd64     dpkg-deb: error: subprocess paste was killed by signal (Broken pipe)      It seems to be complaining about overwriting some files. Should I try deleting or moving those files?


title: Print currently pressed keys to stdout and read them line by line

text: I want to know which keys are pressed on my keyboard and print the information to stdout. A tool that can do this is `showkey`. However, if I want to pass the data of `showkey` to `read`:               while read line; do       echo "$line" | otherprog     done <`showkey -a`      OR               showkey -a | while read line; do       echo "$line" | otherprog     done      Then `showkey` waits until a sum of 140 characters is typed in and then sends the buffered information to `read`. `showkey -a` prints the pressed keys line by line, without any buffering.   1. Why does it buffer?   2. How do I avoid this buffering, so that I can read `showkey`'s output truly line by line?   3. Is there an alternative to `showkey`?   4. Is there a file I can read the pressed keys directly from?   5. What is the correct way to pass data to `read`? * * * ### Solution: I've used lornix's solution and included it into my simple keyboard keyboard :D!               stdbuf -o0 showkey -a | while read line; do       perl -e 'print sprintf "%030s\n",shift' "$line" | aplay &> /dev/null &     done      * * * Lasership version:               #!/bin/bash     MP3=(); for i in mp3/*.mp3; do MP3+=("$i"); done     NMP3=${#MP3[@]}     stdbuf -o0 showkey -a 2>/dev/null | while read line; do         [ -z "$line" ] || ! [[ $line =~ ^[0-9] ]] && continue         NUM="$(echo "$line" | awk '{print $2}')"         mplayer "${MP3[$(($NUM % $NMP3))]}" &>/dev/null &     done      In the same folder, download some laser mp3 files into a folder called `mp3`.


title: How to tell xfce (or an application) where to put the window when starting?

text: I have a number of different boxes, all running debian and xfce. When I launch multiple applications (specifically xterm windows) on one machine, they end up all in the center of the desktop, and they are laid out next to each other on some other machines. I prefer them to be put next to each other when I launch them. ... but I haven't been able to figure out if and where I can configure what happens. Reading this makes me think I should be able to set an appropriate option - but what is it? Note: On the particular box that annoys me by launching each xterm window right in the center of the desktop, mouspad (the editor) gets launched in all four corners of the screen (better than center, but not as good as the windows being next to each other).


title: Unable to remove openmediavault package due to postrm script error

text: I'm a Unix noob so struggling a bit with the commands. Managed to set up SABnzb, Sickbeard and Couch Potato and all working nicely I have a problem with Ubuntu 12.04 server. When trying to upgrade or install any package it errors and fails as below               Now updating apache2-utils ..     Installing package(s) with command apt-get -y install apache2-utils ..     Reading package lists...     Building dependency tree...     Reading state information...          The following packages will be REMOVED:       openmediavault-omvextrasorg          The following packages will be upgraded:       apache2-utils     1 upgraded, 0 newly installed, 1 to remove and 12 not upgraded.     1 not fully installed or removed.     Need to get 0 B/91.4 kB of archives.     After this operation, 337 kB disk space will be freed.     (Reading database ... 120507 files and directories currently installed.)     Removing openmediavault-omvextrasorg ...     /var/lib/dpkg/info/openmediavault-omvextrasorg.postrm: 23: .: Can't open /etc/default/openmediavault     dpkg: error processing openmediavault-omvextrasorg (--remove):      subprocess installed post-removal script returned error exit status 2     Errors were encountered while processing:      openmediavault-omvextrasorg     E: Sub-process /usr/bin/dpkg returned an error code (1)     .. install failed!          No packages were installed. Check the messages above for the cause of the error.     <-  Return to package list       (This is from Webmin but same result if using Putty or direct on machine) I have an HP Microserver N54L with 8Gig RAM


title: "Screen Energy Saving" (in KDE) - how to trigger command when entering and exiting such mode?

text: I have two commands:   * one I'd like to execute when computer enters "Screen Energy Saving" mode,   * another when it exists this state. How to trigger those commands depending on "Screen Energy Saving" ? (I use KDE 4.13.0, and above is feature of KDE's "Power Management")


title: COW and fork - how many frames

text: Consider process P that owns 10 physical frames. Suppose process P calls fork() and creates a child process Q. How many physical frames does the child initially own, without copy-on-write? 10 How many frames does the child initially own, with copy-on-write? 0 not sure if this is a correct answer. Thank you!


title: Replacing default initramfs with my own

text: I followed this article to develop my own sample intramfs.cpio Now I have to put this in my kernel and compile. The procedure that I follw for petlinux is that I first run `petalinux-config` (and petalinux-config -c kernel & petalinux-config -c rootfs) which open GUI where I select various parameters for subsystem, kerenel and rootfs. then I would do `petalinux-build` Which will build uboot bootable image; image.ub This file includes initramfs also. And its overall size comes out around 4.5 MB. This will boot fine and reach command prompt. Now I have my own initrmafs.cpio file, and I want that the kernel should pickup this instead of default one. My difficulty is where do I put this initramfs.cpio file? By default I can see many cpio files and directories such as this:               find  Xilinx-ZC702-14.7/ . -name *cpio      Xilinx-ZC702-14.7/build/linux/rootfs/targetroot/var/lib/opkg/alternatives/cpio     Xilinx-ZC702-14.7/build/linux/rootfs/targetroot/bin/cpio     Xilinx-ZC702-14.7/build/linux/rootfs/packages-repo/targetroot/var/lib/opkg/alternatives/cpio     Xilinx-ZC702-14.7/build/linux/rootfs/packages-repo/targetroot/bin/cpio     Xilinx-ZC702-14.7/build/linux/rootfs/stage/var/lib/opkg/alternatives/cpio     Xilinx-ZC702-14.7/build/linux/rootfs/stage/bin/cpio     Xilinx-ZC702-14.7/build/linux/kernel/xlnx-3.8/usr/gen_init_cpio     Xilinx-ZC702-14.7/build/linux/kernel/xlnx-3.8/usr/initramfs_data.cpio      ./Xilinx-ZC702-14.7/build/linux/rootfs/targetroot/var/lib/opkg/alternatives/cpio     ./Xilinx-ZC702-14.7/build/linux/rootfs/targetroot/bin/cpio     ./Xilinx-ZC702-14.7/build/linux/rootfs/packages-repo/targetroot/var/lib/opkg/alternatives/cpio     ./Xilinx-ZC702-14.7/build/linux/rootfs/packages-repo/targetroot/bin/cpio     ./Xilinx-ZC702-14.7/build/linux/rootfs/stage/var/lib/opkg/alternatives/cpio     ./Xilinx-ZC702-14.7/build/linux/rootfs/stage/bin/cpio     ./Xilinx-ZC702-14.7/build/linux/kernel/xlnx-3.8/usr/gen_init_cpio     ./Xilinx-ZC702-14.7/build/linux/kernel/xlnx-3.8/usr/initramfs_data.cpio      This time my initramfs.cpio file has very limited functionality so I am pretty sure, my over all image.ub (containing initramfs) would be much smaller in size. The only problem is where do I put my own initramfs.cpio file and is there any instruction I have to give in kerenl configuration for this?                    BTW I notice;          Xilinx-ZC702-14.7/build/linux/kernel/xlnx-3.8/usr/initramfs_data.cpio      Is this the file that I have to replace?


title: Set a VFAT volume name non-destructively?

text: The only way I know to set VFAT volume name under Linux is `mkfs.vfat -n desired_name ...`, which obviously destroys volume's contents. Is there a way to change the volume name non-destructively, as Windows does? This name is conveniently used to name the volume on auto-mount. (I'd gladly use a better FS, but all my cameras want only VFAT-formatted flash media.)


title: How to know which commands are executed when I do something in GUI

text: This is for academic purpose. I want to know which commands are executed when we do something in GUI, for example creating a folder. I want to show that both the `mkdir` shell command and `create folder` option from GUI does the same thing.


title: Fail2ban showing error Unable to contact server. Is it running?

text: We start fail2ban in centos using this command service fail2ban start but when we run service fail2ban status we get as below? What could be the mistake ya? Fail2ban (pid 2810 2813) is running... ERROR Unable to contact server. Is it running?


title: Making CodeBlocks work with Terminator?

text: I want to make the programs compiled by Codeblocks, run the shell program 'Terminator'. So I went into Environment Settings > Terminal to launch console programs, the default value is `xterm -T $TITLE -e` so I replaced it with `/usr/bin/terminator -T $TITLE -e` but when I compile the program doesn't run... How can I do it?


title: Mount a folder on a drive in fstab. Move?

text: I'd like to make a temporary change to my `fstab` file so that my `/home` is on another drive. However, I don't want the whole partition to be mounted, but just a folder ("home") on that partition. I'm OK with the rest of the data being unavailable. What's the canonical way of expressing this in `fstab`? I can't think of a way to do it in one command (as I can't reference a folder on a filesystem I haven't mounted). I think I should do a first mount and then move the folder to `/home`. But I don't know if I can do a move in `fstab`, haven't found it in `man` (and I don't feel like trying blindly because I only have ssh access to the machine right now). For now I have a bind mount in `fstab`:               /dev/sdd1 /mnt/temphome ntfs defaults,errors=remount-ro 0 2     /mnt/temphome/home /home none bind      However this leaves `/dev/sdd1` mounted in both points. To summarize:   * can I do a move mount operation in `fstab` and if yes, then how?   * is that the right approach and if not, what is? Thanks in advance.


title: if an exploit is affecting MS office does it affect also LibreOffice?

text: This question is really annoying me a lot and I want a reasonable, certain, logical... response for it


title: How can I make all my processes start with niceness 5

text: I know that niceness values are inherited from the niceness value of the parent process, but can I globally change the default niceness value for a particular user (myself). In this case I have a small convenience server in mind, which is exclusively accessed via `ssh`. So, I think I could change my default shell from `/bin/bash` to `/etc/bash5` while `/etc/bash5` is this script:               #!/bin/sh     nice -n 5 /bin/bash          #file privileges: root:root 755      This strikes me as a terrible hack and error prone. There must be a better way. I'm mostly interested in general solutions, that would also apply to a desktop/laptop system. * * * ## Edit: I tried the suggested `limits.conf` change, but it doesn't work as expected:               root@server# addgroup nice     root@server# adduser myself nice     root@server# echo '@nice soft nice 5' >> /etc/security/limits.conf      Then, from my client machine, I say               myself@client$ ssh server     myself@server$ sleep 1h &     myself@server$ htop      Now, the `sleep` process has an **initial niceness value of`0`**, but if I change the value with `F8` to 19 and then try to reduce it again with `F7` **it stops at`5`**. ## Edit2: Solution Instead of using the `nice` item in `limits.conf`, you actually have to use `priority` although it is counter-intuitive.               @nice soft priority 5


title: dovecot mysql-connection error because of special charater in config

text: I successful set up my Server with froxlor, etc. but now I get errros with my mail delivery Agent because I use a '#' in my mysql-pw. I tried to escape it with a '\' but it doens't seem to work. :( How can I change the /etc/dovecot/covecot-sql.conf.ext to make it working with my password with the special character (lets take as example pw "test#this)? Mycurrent config:               driver = mysql     connect = host=127.0.0.1 dbname=froxlor user=froxlor password=test#test     default_pass_scheme = CRYPT      This is the error message:               dovecot: auth: Warning: Configuration file /etc/dovecot/dovecot-sql.conf.ext line 2: Ambiguous '#' character in line, treating it as comment. Add a space before it to remove this warning.


title: Extremely loud crack and mangled sound over S/PDIF using ALSA

text: Sometimes it seems ALSA on my machine goes completely haywire:   * Flash audio on Spotify doesn't produce any sound.   * SMplayer plays audio just fine, or doesn't play at all (I've observed the latter today).   * When I start a video in VLC it plays an extremely loud crack, **so loud I'm afraid I'll lose hearing permanently and/or break a speaker**. For comparison, I usually set the receiver volume to 25 when playing music, and 30-35 when watching movies. After detecting the previous two issues, I turned the volume to 6 before playing a video, and even then the crack was painfully loud.   * After the crack, the VLC audio stream is barely audible behind a wall of noise.   * I don't detect any extreme loudness, cracks or other distortion from `speaker-test --device plughw:1,0 --channels 2`. How can this issue affect only Flash and VLC, but not SMplayer? They all use ALSA and the same sound card, after all. And these symptoms are relatively rare - only detected once every couple weeks or so. A reboot seems to solve them every time, but I would rather have some sort of guarantee that my ears will continue working. The machine is set up from bare bones Arch Linux, and had as far as I can tell only the ALSA sound server installed when the problems were encountered. The S/PDIF cable is connected to an Onkyo receiver, which is connected to a 5.1 speaker system.


title: Need to boot Windows 7 from Grub rescue command prompt

text: I booted my computer today and found the Grub rescue command prompt. I have been given this computer and it has Linux and windows 7 on it, but I have only ever used the windows section. I have no idea about Linux at all, and was startled by this "Grub" thing. It won't let me do anything in the command prompt, and i can't boot windows. I have a netbook, so there's no CD drive on the computer. I need a way to get into windows 7 from this command prompt. With a little bit of searching (on my phone) I found a couple things to enter that are supposed to let me into windows. I tried this: 1) rootnoverify (hd0,0) 2) chainloader +1 3) makeactive 4) boot That was the first sequence of things that didn't give me an error. But when I got to typing "boot" it told me the Bootmgr cannot be found...? I have no idea what this means. All I want to do is to be able to boot windows again, I don't care how, I just want access. Like I said, my computer doesn't have a CD drive, so I can't use a disk. Is there a way to fix this through the Grub command prompt? Any answers would be appreciated. Thanks.


title: Make daemon start up with Linux

text: I'm writing a simple daemon application using C/C++ and I want it to start when Linux starts up. I am a beginner on Linux systems. I have tried to modify `/etc/init.d/skeleton` to add a script into the init.d directory as follows   1. added my daemon application in `/usr/sbin/` directory and changed `NAME=myDaemon`   2. write `update-rc.d myDaemon default` in Terminal    3. and it added symbolic links to `rc#.d` directories  But it didn't work. My second try was to modify `rc.local` as               /usr/sbin/myDaemon start       But this didn't work either. How can I make my daemon start with the OS? I want to do everything programmatically. I use Ubuntu 10.10 but if there exists a general solution for all distributions, that would be great!


title: Find and Replace Recursive

text: I want to modify every file in a directory recursively. I want to replace:               <?php      with                <?php      /**       *       * Copyright (C) MyCompany, Ltd. - All Rights Reserved       * Unauthorized copying of this file, via any medium is strictly prohibited       * Proprietary and Confidential       * Written by Justin E <justin@domain.tld>, March 2014       *       */      What would be the best solution? I know some sed, but I am looking to keep the spacing and newlines as well so that it looks professional.


title: Which linux distro is good as a VPS in parallels?

text: I will use Parallels Virtuozzo Containers for virtualization and have a good server machine. Which linux distro is good to use? I am new at parallels and vps. I have CentOS 5, Debian 5.0 Lenny and Ubuntu 10.04 LTS Lucid Lynx.


title: Kill all descendant processes

text: I'm writing an application. It has the ability to spawn various external processes. When the application closes, I want any processes it has spawned to be killed. Sounds easy enough, right? Look up my PID, and recursively walk the process tree, killing everything in sight, bottom-up style. Except that this doesn't _work_. In one specific case, I spawn `foo`, but `foo` just spawns `bar` and then immediately exits, leaving `bar` running. There is now _no record_ of the fact that `bar` was once part of the application's process tree. And hence, the application has no way of knowing that it should kill `bar`. I'm pretty sure I can't be the first person on Earth to try to do this. So what's the standard solution? I guess really I'm looking for some way to "tag" a process in such a way that any process it spawns will unconditionally inherit the same tag. (So far, the best I can come up with is running the application as a different user. That way, you can just indescriminently kill all processes beloning to that user. But this has all sorts of access permission problems...)