How to insert text after the last configuration line?

I have to insert a line into a configuration files automatically, but with the added caveat that it should be inserted _before_ a multi-line footer comment and any preceding empty or whitespace-only lines _if the footer exists_. That is, **the new line should be inserted right after the last configuration line** , making for a single-line diff from the original file. In pseudo-code:   1. Go to the end of the file.   2. Go backwards to the first (that is, last in the file) configuration line (that is, a line which is not empty, whitespace-only, comment only or whitespace followed by a comment).   3. Insert text after the current line. Extended regular expression for configuration line: `^\s*[^[:space:]#]` Any common *nix tools such as `sed`, `awk`, `ed` or `ex` should work. * * * Possible solutions and their problems:   * Use `tac` twice to make this into a forward-searching problem rather than backward-searching. This means I'll have to store the result in a temporary file then replace the original, rather than doing this in a single command.   * Use `sed -i` with the reversal trick. This means storing the entire file in memory.   * `ex -c '1' -c '?^\s*[^[:space:]#]?' -c $'a\nmy new line\n.' -c 'wq' /path`, which I'm also given to understand stores the full file in memory. Is there a solution which circumvents both of these issues? Example starting file:               # Universe configuration     #          pi = 3 # A good #     e = mc**2 # To within a hair          [cut 200 trillion lines]          #      # END     #      Example input:               sol { mass = 42, start = 9.2 }      Expected output:               # Universe configuration     #          pi = 3 # A good #     e = mc**2 # To within a hair          [cut 200 trillion lines]     sol { mass = 42, start = 9.2 }          #      # END     #      General-purpose function based on @StephaneChazelas's solution


Hide all open windows on Ubuntu 12.04 LTS

Is it possible to have a button on the side bar to hide every open window on Ubuntu 12.04 LTS?


apache not starting in vagrant vm

I used Puphpet.com to create a Vagrant VM to be used for web development. The problem I am having is that the VM cannot start apache on boot.               $ sudo /etc/init.d/apache2 start     * Starting web server apache2                                                   *     * The apache2 configtest failed.     Output of config test was:     apache2: Syntax error on line 36 of /etc/apache2/apache2.conf: Syntax error on line 1 of /etc/apache2/mods-enabled/authz_default.load: Cannot load /usr/lib/apache2/modules/mod_authz_default.so into server: /usr/lib/apache2/modules/mod_authz_default.so: cannot open shared object file: No such file or directory     Action 'configtest' failed.     The Apache error log may have more information.      the system is ubuntu 12, not sure what modifications I have to make to the puppet config to fix the problem.


Prevent linux from auto scan and mapping partitions on some disk

TL;DR Linux scan disk (for example /dev/sdc) and add files to address partitions on that disk (for example /dev/sdc1) - how can I tell Linux to not do that for some disk? Long story: I used VM (QEMU+KVM) to install other OS on physical HDD - "/dev/sdc" (different from host, of course). Before installation disk was cleared (all partitions removed). First installation has failed. I have stop VM and launched GParted on host and it showed warning about corrupted file-systems on that disk. I noticed that in "/dev/" appeared "sdc1" and etc. Next installation succeed, and I noticed that there was no "sdc1" and etc. Host side GParted showed warning that partitions on "/dev/sdc" is not mapped. So I came to conclusion that linux partition mapping may be reason for corrupted file-system in this case. How can I temporary disable that feature?


Separate .muttrc into parts

My `.muttrc` file is starting to get quite large. What I would prefer is to create a `~/.mutt/config` directory to store various config files for the account, status bar, composition,... etc and then source them all into my main `.muttrc` file. How do you do this?


Debian Log In Failure With Correct Password

So I have a Debian distro at home (considering getting ubuntu), and I can't login. When I use the correct password is does this thing where it makes it look like it's going to login, and then it redirects to the login screen, but when I use an incorrect password it says "authentication failure". Does anyone know what could be causing this?


How to install xfontsel on Fedora 13? Any alternative?

I need xfontsel to select right font for xterm. But its not installed. I tried `yum` but it returned > Warning: No matches found for: xfontsel   >  No Matches found I googled for xfontsel source code to compile myself but didn't get any link for that.   1. How can I install xfontsel on Fedora 13?   2. Its not installed by default and neither it is available in `yum` repo. So does this mean Fedora will not include it anymore? Why?   3. Any alternative to xfontsel? I tried `xlsfonts` but it does not give preview of fonts. Thanks for your time and help. ## Edit               $ su -c "yum install xorg-x11-apps.i686"      This did the trick on my Fedora 13.


Save complete GNU screen session state

Is it possible to persist the "state" of a GNU screen window (or just a standard shell) so that I can reload everything after a reboot:   * The number of opened shells   * The name of each shell   * The current directory of each shell   * The history of each shell   * If possible, their environment variables


Move every file that is not a directory

I have a directory that I am trying to clean out that contains both files and subdirectories. What I am trying to do is simple: move all the files into another directory, but leave all the sub-directories as they are. I am thinking something like:               mv [*_but_no_dirs] ./other_directory      It seems like there should be a simple way to do this with wildcards `*` and regex... Anyone have ideas?


How to have multiple/several lines of window list in the GNOME 2panel?

How can I have several lines for the window list? I have to keep open many- many applications, and I need to know their name. E.g. on Windows: ![enter image description here](http://i.stack.imgur.com/1MK3F.png)


How to echo a bang!

I tried to create a script by `echo`'ing the contents into a file, instead of opening it with a editor               echo -e "#!/bin/bash \n /usr/bin/command args"  > .scripts/command      The **output** : > bash: !/bin/bash: event not found I've isolated this strange behavior to the bang.               $ echo !     !            $ echo "!"     bash: !: event not found          $ echo \#!     #!          $ echo \#!/bin/bash     bash: !/bin/bash: event not found        * Why is bang causing this?    * What are these "events" that bash refers to?    * How do I get past this problem and print "#!/bin/bash" to the screen or my file?


Fonts in chromium

(no, it isn't this) My bold fonts are completely deformed in some sites (mostly SE) in chromium. I have had this issue for a while on two Arch systems, but not in Ubuntu. Here is an example from a question I was viewing (getting carried away again ...): ![enter image description here](http://i.stack.imgur.com/8FR1b.png) As you can see, some letters are bigger than others, and it generally looks a mess. I tried messing with the chromium fonts, but it seems the problematic SE sites have their own fonts they want, which overrides chromium's settings. What is going wrong? Is this some kind of extreme hinting that totally malforms the letters? Or is there something I ought to install? Come to think of it, what font is it? The only fitting fonts I have installed are Helvatica (Neue) and Nimbus Sans.


Virtualbox under Proxmox

On a Jenkins Master-Slave configuration and need to run on the slaves Kitchen tests on several jobs. Kitchen for those who do not know it, runs infrastructure on demand using Vagrant and VirtualBox (in my case). Master and slave are both under Proxmox, so my questions is: is there a sane way to get running VirtualBox inside an OpenVZ container?, is there any workaround I can do to achieve this? I just don't want to create a physical node to run this kind of jobs.


VAAPI or VDPAU which one is a newer Tech?

I wanted to compile a variant of mplayer and came across these options: `VAAPI` `VDPAU`. I once read somewhere that one of these is for the newer graphic cards (like new gforce GT) and overlaps the other. Or I am totally wrong and they are different technologies for different hardware?


trying to open console on LCD using fbcon and USB keyboard

I'm trying to bring up virtual terminal on our embedded system's LCD using USB keyboard which is also connected to the system. I have UART connection to my PC so I've been using UART for console till now but I want to switch to framebuffer console on LCD during the boot at some point.. The USB host controller seems to work fine because I've seen USB memory is attached, read and written ok. And when I connect a keyboard and print the events at keyboard_event function, it prints events that seem normal and corresponding to my action(type of key, press or release..) I have a feeling that it's a configuration problem. In init/main.c, there is   `run_init_process(ramdisk_execute_command);`   (In my case, ramdisk_execute_command = "/sbin/init") And this immediately calls   `kernel_execve(init_filename, argv_init, envp_init);`   // above, init_filename and argv_init are "/sbin/init" same. I expect busybox to run after this (ramdisk had been installed before by a bootloader-like part). But I cannot see any prints on the LCD after this point. But I can see printks on the LCD until just before calling kernel_execve above. I'm using Linux 3.3. I understand I have to open a frame buffer console on LCD and connect it to a tty but I don't know how. Below are printed the current relevant settings. (In serial UART connection case, Linux boots ok up to the final busybox shell prompt printing things in busybox initialization after kernel_execve call. And `#cat /proc/fb0` returns 0 for your info. Only LCD/framebuffer console mode stops after kernel_execve.)               #### arch/sparc/boot/ourprocessor/prom_stage.c : #####     // "console=ttyS,mmio,0xff003000,115200n8 "        <== serial port case     "console=tty "                        <= frame buffer console case (below line too)     "fbcon=font:SUN8x16,map:0000 "               <= Is this boot argment correct?..          #### sbin/init: #####     #!/bin/busybox sh     export LD_LIBRARY_PATH=/lib     export LD_LIBRARY_PATH=$LD_LIBRARY_PATH:/mnt/nand/lib          exec /bin/busybox init     ### rcS #####     mknod /dev/tty0 c 4 0 <== Do I need to explicitly make tty0 and tty1 like this?     mknod /dev/tty1 c 4 1     mknod /dev/tty2 c 4 2     mknod /dev/tty3 c 4 3     mknod /dev/tty4 c 4 4          ### .config #####     CONFIG_FRAMEBUFFER_CONSOLE=y <= LCD/framebuffer console case. Otherwise none.     CONFIG_FONT_SUN8x16=y     CONFIG_LOGO=y      By the way, I'm not using /etc/inittab.(so use default init). The busybox init/init.c code says if there isn't the inittab file and console is not the serial port, it runs   `tty2::askfirst:/bin/sh`   `tty3::askfirst:/bin/sh`   `tty4::askfirst:/bin/sh`   (starting shell on tty 2, 3 and 4) then How do make tty2's shell appear on the LCD/framebuffer/framebuffer console? It's confusing and books are not so kind.


Is it possible to control window management in Gnome Shell using D-Bus?

I would like to programmatically be able to communicate with the Window Manager in Gnome 3, using D-Bus. The tasks I would like to accomplish are:   * listening for new windows    * get window flags (e.g. skip pager flag)   * get X window IDs    * maximise, minimise windows   * raise, lower windows   * hide windows The aim is to create an task-bar-like application.  I know of tools such as xdotools or wmctrl, but those are very thorough tools: there are no listeners to find out if new windows have been instantiated / mapped, the latte works with window title strings. I also tried using python-xlib, but lack of documentation or too technical documentation have made it very difficult to achieve anything. It seems D-Bus would be appropriate for such actions. Can I use D-Bus to do this, is there a way to do this using Python? Could you provide examples?


Poorly performing java application vs poorly performing server

This is a very generic question, but it has been coming up more and more often for me. I would like to try and determine an appropriate course of action for this generic case, as I think it could benefit me and other sysadmins in the future. The commonality in all cases though is java. The reason I am asking this question here rather than stack overflow is that this is a sysadmin question. I think it is very appropriate here. A user comes up to me and says "My application is very slow. The server you gave me has poor performance." This server could be bare metal, OpenVZ, or KVM. In all cases, OS is CentOS 6. When the user tells me this, they are referring to page load time (JIRA) or benchmark numbers. (Selenium or proprietary app) Now, I have a sneaking suspicion that the server itself is fine. I ssh onto the server, and notice that the load is less than 1. Memory usage is fine as well, ranging anywhere from 2-20 gigs of ram free. Finally, I check iowait with vmstat, and notice that it is 0. cpu idle is 99. Looking at java with top, I can see that cpu percentage is around 200% or so for that process. This is on systems with anywhere from 4 to 24 cores. (Of course, openvz does processor allocation different from KVM or bare metal.) In the cases that this occurs on an openvz or kvm guest, I hop onto the host as well, and see similar things. cpu idle is 99%. iowait is 0. memory is sometimes hundreds of gigs free. I have looked at these java processes and threads with strace, and strace -f. There are tons of futex, clock, and epoll. If I reverse grep those, I'm left with mostly ioctl, stat, sendto. Applications where this has happened: Selenium, JIRA, and misc proprietary java applications. Always java though. I have considered tuning the niceness of the java processes, but AFAIK niceness will only affect how processes are scheduled. If the load is low, it won't help to speed things up. Sometimes the application uses mysql, but looking at mysql in top shows almost no cpu usage there. I'm guessing that if that was the bottleneck, we would see higher cpu usage. Bottom line: How do I prove to the user that the server works just fine, but their application sucks? Theoretically, the application could be slow because it encountered a while loop that will never exit. Which leads me to believe that this task is impossible, analogous to solving the halting problem. o_O But perhaps I can tune java to behave a bit better, or perhaps there is a way to profile the running application, point to a chunk of code and say "There's your problem". Thanks!!


How can I know when a cron job was killed or it crashed?

Usually when a cron job crash, it will leave some error messages in the log. We run shell script and some java program with cron job. Recently we found some weird thing out from the log. Obviously the program was either crashed or killed because there is a program lock we set when the program was initialed, which was not released. We guess the program was killed because the log of the program didn't show the finish message. Who can possibly killed the job and how can I get notified through email when a cron job is dead? EDIT: I don't want the crontab way to receive email because it just push every standard output to the email. In my case there are a lot of other system output from different program because some of them ain't using log4j or they are echo by shell script. Because there are many users in the system, we can't require all the users to manage their program's standard output.


Default settings for VirtualBox machines?

How can I change the default settings of virtual machines that are created by VirtualBox? I don't need any floppy devices or sound enabled by default.


How to get the name of the user who executed a bash script as sudo?

I want to create a bash script that must be executed with sudo but should take into account the name of the non sudo user who executed it. So if user `bob` runs `sudo ./myscript.sh` I would like `myscript.sh` to know `bob` was the one who executed it. Let's look inside `myscript.sh`:               USER=$('woami')     # do something that takes into account user name      How can I know the name of the user who spawned the process? More specifically, what should I use instead of `whoami` to get `bob` and not `root`?


State/Toggling variables in tmux

I was wondering if there is a way of defining a state variable in ./tmux.conf, such that depending on this variable, the keyboard binding would invoke a different command. For example, I would like to use `M-F` to toggle the maximization of a pane in tmux (if the pane is not maximized, M-F would maximize it, otherwise it will unmaximize it) Here is the pseudo-code that I have so far:               # Maximize pane: -------     # IF PANE_MAXIMIZED=False:      # THEN: PANE_MAXIMIZED=True, and:     bind -n M-F new-window -d -n tmux-zoom  \; swap-pane -s tmux-zoom.0 \; select-window -t tmux-zoom          # Unmaximize pane -------     # IF PANE_MAXIMIZED=True:      # THEN: PANE_MAXIMIZED=False, and:     bind -n M-F last-window \; swap-pane -s tmux-zoom.0 \; kill-window -t tmux-zoom


How to scp with regular expressions

I'm trying to copy all files that do not begin with the letter "a", in ksh. Copying from the source machine to destination machine is _working fine_ : `scp -p !(a*) user@machine:/path/directory/.` But, if I am on the destination server and want to copy from the source server, is failing: `scp -p user@machine:/path/!(a*) .` Any ideas?


How to benchmark RAM memory with a Linux Distro?

I' ve just bought new RAM and I'd like to benchmark and compare with my old. How can I do that?


Bash script; optimization of processing speed

I was wondering if there are general guidelines for optimizing bash script. a) For example, it is more _convenient_ to write loops than lines of commands, but is it also _faster to process_ for the system? Example:               for i in a b c; do echo $i; done          echo a     echo b     echo c      b) Sometimes people present different solutions for the same problem. For example, sed, cut, awk, and echo are all able to strip digits from a string. I was wondering if you can say that the less digits a code has, the faster it is if you use: i) the same command, e.g.               STRING=abc.def     echo ${STRING} | sed 's/.def//g'     echo ${STRING} | sed '$s/....$//'      ii) different commands, e.g.               STRING=abc.def     echo ${STRING} | cut -d . -f 1     echo ${STRING} | sed 's/.def//g'


Can one move a relpath in one command?

This question is similar to one I asked recently, but the answers to that question, for the most part, do not extend to this one, AFAICT. The main difference between the two questions is that the earlier one was about copying while this one is about moving. Also, that earlier question was unnecessarily specific by referring to the relative path to a _file_. In this question I've removed this overspecificity. I find myself doing this often enough that I wonder if there's a standard Unix way to do it:               % mkdir -p /TARGETDIR/relative/path/to     % mv ./relative/path/to/x /TARGETDIR/relative/path/to      In other words, I don't want to just move `somefile` to `/TARGETDIR`, but actually I want to "move" (so-to-speak) its entire _relative path_. I know that I can write a shell function or a script to achieve the same effect, but I'd like to know if there already exists a way to do this with a single command?


How rename directories tree entry by entry

I have text file contain two columns:               current directory name                               the new name of the last entry          d_7154/d_7161/                                       'Main Integration'     d_7154/d_7161/d_9247/                                'Flows & Methodologies'     d_7154/d_7161/d_9247/d_8986/                         'General Guidelines'     d_7154/d_457/d_691/d_705/                            'Projects T to Z'     d_7154/d_457/d_691/d_6056/d_11253/d_11254/           'Templates'     d_7154/d_457/d_691/d_6056/d_11253/d_11254/d_11255/   'General Templates'     d_7154/d_457/d_691/d_6056/d_11253/d_11254/d_11256/   'Team Template'     ...     ...      Is there a recipe to rename the tree? The main problem that if I change name of directory on middle of the tree the rest of list become not relevant.


Slow sudo because of socket connections

Some time ago sudo started to behave very slow on our server. Some times we have to wait even a few minutes until it executes. I've checked all hostname and dns causes that forums all full of, but the problem still persists. I can confirm, that server names are resolved properly on this server. Debugging sudo with strace gives this interesting results:                0.000080 open("/etc/passwd", O_RDONLY|O_CLOEXEC) = 3      0.000153 lseek(3, 0, SEEK_CUR)     = 0      0.000044 fstat(3, {st_mode=S_IFREG|0644, st_size=1809, ...}) = 0      0.000060 mmap(NULL, 1809, PROT_READ, MAP_SHARED, 3, 0) = 0x7f91b3dd3000      0.000042 lseek(3, 1809, SEEK_SET)  = 1809      0.000057 munmap(0x7f91b3dd3000, 1809) = 0      0.000038 close(3)                  = 0      0.000077 getgroups(0, NULL)        = 1      0.000039 getgroups(1, [0])         = 1      0.000045 getcwd("/home/myself", 4096) = 12      0.000053 ioctl(0, SNDCTL_TMR_TIMEBASE or TCGETS, {B38400 opost isig icanon echo ...}) = 0      0.000184 fstat(0, {st_mode=S_IFCHR|0620, st_rdev=makedev(136, 6), ...}) = 0      0.000111 readlink("/proc/self/fd/0", "/dev/pts/6", 4095) = 10      0.000095 stat("/dev/pts/6", {st_mode=S_IFCHR|0620, st_rdev=makedev(136, 6), ...}) = 0      0.000079 uname({sys="Linux", node="OUR-SERVER", ...}) = 0      0.000072 ioctl(2, TIOCGWINSZ, {ws_row=65, ws_col=205, ws_xpixel=0, ws_ypixel=0}) = 0      0.000055 socket(PF_NETLINK, SOCK_RAW, 0) = 3      0.000044 bind(3, {sa_family=AF_NETLINK, pid=0, groups=00000000}, 12) = 0      0.000042 getsockname(3, {sa_family=AF_NETLINK, pid=43381, groups=00000000}, [12]) = 0      0.000042 sendto(3, "\24\0\0\0\22\0\1\3T\373\206S\0\0\0\0\0\0\0\0", 20, 0, {sa_family=AF_NETLINK, pid=0, groups=00000000}, 12) = 20      0.418298 recvmsg(3, {msg_name(12)={sa_family=AF_NETLINK, pid=0, groups=00000000}, msg_iov(1)=[{"$\2\0\0\20\0\2\0T\373\206Su\251\0\0\0\0\0\3\0\3339\0\321\0\1\0\0\0\0\0"..., 4096}], msg_controllen=0, ms      0.000160 recvmsg(3, {msg_name(12)={sa_family=AF_NETLINK, pid=0, groups=00000000}, msg_iov(1)=[{"\340\3\0\0\20\0\2\0T\373\206Su\251\0\0\0\0\376\377\0\2639\0\321\20\1\0\0\0\0\0"..., 4096}], msg_controll      ...      And the last 2 recvmsg lines a repeated about 4000 times!!! This 4000 socket receives are responsible for this slow down (notice the time on the first call - and these are only the first 2...). Our server is ubuntu 12.04 with sudo 1.8.3p1. I've even examined the sources of this sudo version, and these socket calls are not there... Please help :)


Run SSH SOCKS5 proxy on system startup

I want to setup a linux server (Ubuntu Server 14.04 in this case) to be used as a SOCKS5 proxy by software on another client. Now this is pretty easy by running `ssh -f -N -D 0.0.0.0:1080 localhost` as explained by this guide. This works perfectly. Now what the guide isn't telling me is how do I automatically start the proxy on system startup? Just entering this command into `rc.local` isn't working because I have to provide a passphrase. Generating a ssh key with `ssh-keygen` and putting it into `/root/.ssh/` doesn't work either. Be noted that I don't really understand how the whole ssh public key thing works, so my error might lie there. Anything special I have to do when my public key is supposed be used for the local client and not a remote client?


Configuring setcifsacl to use local posix user instead of SID for CIFS share on Linux

I have a CIFS filesystem (from a NetAPP) mounted on a Red Hat 6 server using cifs_utils, and am sharing some directories from the CIFS filesystem out over HTTPS via WebDAV. I need to set some ACLs on the directories so that the local Apache user can access the files on behalf of the users who are accessing the share via WebDAV, but when trying to use setcifsacl from the cifs_utils package, it seems to expect an SID, and doesn't recognize the user apache, or the apache user UID (48). The man page doesn't give much information. Any suggestions? I am mounting the CIFS mount RW already. Mounting with the cifsacl option actually makes things worse, as files are stripped of all permissions (ls -la shows --------- for a file).


How to use grep to find all instances of one .txt file in another?

How would I use grep to compare if any line from one .txt document occurred in another? Further how would I use grep to find out the opposite? Would it be `grep -v`?


How to add a progress bar to cryptsetup luksFormat?

Example command.               cryptsetup --hash sha512 -c aes-xts-plain64 --key-size 512 luksFormat /dev/loop0      This can take quite a while for big files / on slow disks. How to add a progress bar?


execute shell script options

I typically use `cd Directory/Directory/` to point to the shell directory and then type `bash shell.sh`, but I was wondering if there is an easier way to execute my shell & the location with one line? I do bounce to different folders often. Example: unix folder with a shell script named alpha               cd Desktop/unix     bash alpha.sh


Changed to Nvidia xorg driver - now I have less temperature sensors?

I've just installed Debian Wheezy 7.5 on a Toshiba Satellite P100 laptop. By default, X was using the nouveau graphics driver. While this was still installed, I was getting 6 different temperature readings from lm-sensors. Here's an example of the output, I had:               acpitz-virtual-0     Adapter: Virtual device     temp1:        +50.0°C  (crit = +104.0°C)          coretemp-isa-0000     Adapter: ISA adapter     Core 0:       +52.0°C  (high = +100.0°C, crit = +100.0°C)     Core 1:       +52.0°C  (high = +100.0°C, crit = +100.0°C)          lm99-i2c-2-4c     Adapter: nouveau-0000:01:00.0-2     temp1:        +49.0°C  (low  =  +0.0°C, high = +85.0°C)                            (crit = +85.0°C, hyst = +75.0°C)     temp2:        +64.9°C  (low  = +16.0°C, high = +101.2°C)                            (crit = +101.0°C, hyst = +91.0°C)          nouveau-pci-0100     Adapter: PCI adapter     temp1:        +39.0°C  (high = +100.0°C, crit = +110.0°C)      However, the temperatures were much higher than above. The lm99/nouveau temp2 was hitting 95c while the computer was idle. And some others were in the 60c-70c range. The laptop felt quite hot. So I then installed the binary nvidia drivers hoping this might lower the temperature of the system. However, now when I look at lm-sensors, I only get three readings:               acpitz-virtual-0     Adapter: Virtual device     temp1:        +49.0°C  (crit = +104.0°C)          coretemp-isa-0000     Adapter: ISA adapter     Core 0:       +51.0°C  (high = +100.0°C, crit = +100.0°C)     Core 1:       +51.0°C  (high = +100.0°C, crit = +100.0°C)      I'm concerned that I can't see the extra readings I had before, so I can't be sure the system still isn't running hot. Anybody got any ideas how I can check, or anything I can look at? I've tried running the sensors-detect script, it added a couple of modules, but I still only get the three readings. Thanks.


Battery low custom rule (hibernation)

I love to abuse my laptop battery by using my laptop for quite some time (up to 25 minutes) even after the battery meter hits 0%. However, sometimes I forget about that or I am just away. This causes hard shutdown, which holds the potential to corrupt the filesystem. What is the best way to tell the computer to automatically hibernate 15 minutes after the battery reports it's empty? My idea is to write a Ruby or Bash script that would periodically poll the appropriate `/proc/` subystem, but I'm wondering whether there is anything in-built.


ARP request with wrong IP address

I have a strange problem with a Linux router. The setup is like this:               host1   ===  Linux router   ===   host2     a.b.c.d --- a.b.c.e/g.h.i.j --- g.i.h.k      Every five minutes host1 tries to reach host2. If host2 is down, the Linux router makes an ARP request for a.b.c.d on the left network with address g.h.i.j (i.e. from network on the right side). After receiving the MAC address from host1 the router sends an ICMP-unreachable packet with g.h.i.j as sender address. If host2 is up, everything is fine. The router makes the ARP request with its address a.b.c.e. On the router I have               $ uname -a     Linux pfc 3.6.9-voyage #1 SMP Tue Dec 11 09:53:27 HKT 2012 i586 GNU/Linux      There is no proxy_arp involved. The problem is: in my eyes the route should not use the IP address from the right hand network for the ARP request. Or am I missing something here?


What exactly is an environment variable?

I know that `VARIABLE=value` creates an environment variable, and `export VARIABLE=value` makes it available to processes created by the current shell. `env` shows the current environment variables, but where do they live? What comprises an environment variable (or an _environment_ , for that matter)?


xargs loop with input variable for use in multi-command

I have a text file with various IP addresses. I would like to cycle through each, and issue a command:               cat ips.txt | xargs -L 1 `ssh me@__IP__ echo "text" > file; reboot;`      But I'm unsure how to pass the xargs value to **_ _IP_ _**. Could someone explain how this could be accomplished?


"wpa supplicant: No network configuration found for current AP" - carl9170-driven wifi adapter glitching on Debian 7

I've got a Debian 7 machine with Linux3.2 kernel and a USB wifi adapter with Atheros chipset (D-Link DWA-16 Xtreme N Dual Band), which in theory should work. Indeed, I managed to establish a wifi communication with NetworkManager and it worked more or less fine for ~30 minutes, but then disconnected and failed to reestablish the connection. I failed to reestablish the connection with NetworkManager, it successfully associates and authenticates, starts 4-way handshake, but then deauthenticates due to reason 15 (4-way handshake timeout). Then I tried to do the same via the good old `ifupdown` by creating an entry in `/etc/network/interfaces`:               allow-hotplug wlan1     iface wlan1 inet static            wpa-ssid MyNet            wpa-psk <My key hash generated by `wpa_passphrase MyNet key`>            address 192.168.1.2            netmask 255.255.255.0            broadcast 192.168.1.255            gateway 192.168.1.1            dns-nameservers a.b.c.d      When I `sudo ifup wlan1`, it behaves reasonably, until:               wpa_supplicant[8258]: wlan1: Associated with <router's MAC>     wpa_supplicant[3402]: wlan1: No network configuration found for the current AP      (from `/var/log/syslog`). `Wireshark` sees ARP packages going from my wifi adapter to the router, but the router doesn't reply. Do you have any ideas about what could that mean and how to troubleshoot this? **SOLUTION:** Thanks to suggestion by peterph, I tried to create `wpa_supplicant.conf` and run `wpa_supplicant` as a standalone program both in foreground and background and then used `wpa-conf wpa_supplicant.conf` in `/etc/network/interfaces`.               sudo wpa_supplicant -iwlan1 -c/etc/wpa_supplicant/wpa_supplicant.conf -d     sudo wpa_supplicant -iwlan1 -c/etc/wpa_supplicant/wpa_supplicant.conf -B      I had the first part of troubles (with spontaneous disconnect after "status: associated") disappear, when I killed a running instance of `NetworkManager`. It seems to have interfered. Second part of trouble was with the 4-way handshake failing. It passed ok, when I disabled MAC address filtration on the Access Point. My wifi interface's MAC was in the list of available MACs, but for some reason it still was failing to connect with MAC filtering on the router. **UPDATE 2:** The problems are back. 4-way handshake is failing again. Reload of the driver won't help.


Arch DVD colours

On my Arch machine, I wanted to play the DVD Skyfall. It opened with VLC, and everything worked, except that everything was a bit greenish. Why is that happening? Dragon player isn't better either. The odd thing is that, when I tested other DVDs, it worked. Skyfall also had no problems on my PowerBook, with Mac OS 10.5. This is a bit of an odd question, but I don't understand why that should happen.


Why my dconf-editor has fewer options in Elementary OS Luna than supposed to?

I am giving Elementary OS a try but trying to configure it a bit I see lesser options than supposed in dconf-editor. Following this source, they should look like this: ![enter image description here](http://i.stack.imgur.com/tJ0OM.png) Mine look like this: ![enter image description here](http://i.stack.imgur.com/ESOxb.png) So, I can neither follow the instructions from here. Why is that? Is this related to the latest release? A remedy?


Simulating READLINE_LINE in Bash < 4.0

I am trying to make some of my code bash 3.X compatible and I have a key- binding that utilizes READLINE_LINE inside its callback function. 3.0 versions of Bash don't supply the READLINE_LINE, so I need an alternative way to get at the currently typed, but unexecuted line. I think I need some simple code (C hopefully) to grab the currently typed but unexecuted command from a Bash terminal and print it out to stdout (I'll capture it from there). My function will then manipulate it and then put it back (I can do this already) I've explored Readline, and looked at command completion neither of those seem to be what I need. I've spent many hours reading about tty and readline and am at my whits end, the command is on the terminal so it must exist somewhere, right?


How does system know where the first logical disk starts?

I'm trying to understand the ms-dos partition table, and there's the following diagram: ![screen](http://i.stack.imgur.com/wm7Fo.png) It comes from this site. Almost everything is pretty clear to me, but there's one thing I don't get. As you can see, the third partition is an extended partition, and it has several logical disks. The extended and primary entries in MBR look the same. Both have partition type, starting sector and number of sectors which describe the partitions.   * Where is the info that would link to the first EBR on the extended partition?   * How does the system know what to look for on the extended partition? Let's say that we've lost the extended entry in MBR. How to restore it? If I create a new extended entry via fdisk, it won't see the logical disks. How to connect the first EBR to the extended entry in MBR?


Migrate Ubuntu to bigger HDD

I have a multi-boot system and want to push my Ubuntu installation to a bigger partition on the **same** hdd, because I want the system to have more memory available. What I know so far is I can clone with `ddrescue` using following command.               sudo ddrescue -v --force /dev/sda_old /dev/sda_new      Is that all I have to consider? Does `ddrescue` do the filesystem formatting or do I have to do it manually? Of course after the whole process I have to set my bootloader with               sudo grub-mkconfig    # for creating the grub config file     sudo update-grub      # for saving the new config file


Editing a Java properties file with Bash

I have the following Java properties file that is maintained by humans.               # file.input = /very/old/name     # file.input = /old/name     file.input = /current/name     file.input.default = /default/name     other.file.input = /current/other/name     # Other comments     other.properties = must stay the same      I must create a script that will edit this file without touching at all at the rest of the files. Therefore I cannot dump new properties in the config file. Humans will often copy/paste a line and comment it for further use. My application must edit exclusively config file without touching any of the comments. In this particular case, I want to edit the line `file.input` to set the value to `/new/name` without any commented line being touched and without any other properties being touched as well (`file.input.default`, `other.file.input`). My script will not keep the current line for history purpose like humans usually do. Also, I don't know the current value set to the key `file.input`. Where am I stuck? At the very beginning. I'm not a Bash expert, I rarely use it except to call commands in sequence and I use some ifs sometimes. But that's all. I could use `perl` to use regular expressions, but perl is apparently not installed on this system. So I turned to `sed`, in turn, but I don't get any of this: it seems I can only replace a specific value to another. I could wrap that in the reading of the file, and rewrite it except for the expected line that I could change. Also, I would barely be able to handle human-added spaces in front of the property I want to change. So if you have an alternative please share it, because I start to become alienated.


Xorg: multiple keyboards, one configuration

On my laptop, I tweak some keybindings and keyboard preferences with `xmodmap` and `xset`. When I plug an external USB keyboard, the configuration for that new keyboard is the default, i.e., without my tweaks. If I `xmodmap` and `xset` again, then these preferences are applied to the newly plugged keyboard too, but on pluging/unpluging, they are again reseted to the default. Note that the pluging/unpluging never affects the configuration of the laptop keyboard, which stay tuned during the whole process. **Question:** How can I have _one_ xmodmap and xset preference set, which applies to any keyboard (plugged now and in the future). _Configuration_ : Arch Linux on 3.1.1 kernel, Xorg 1.11.2 with no homemade configuration, window manager: awesome 3.4.11, no kde or gnome stuff Thanks!


Using umask to set group permissions

A long time ago an old friend showed me a way to use an octal or hex umask with a group I think using `/etc/profile`. I'm not sure. I'm trying to create group on Debian so that every member of that group when creating a file will produce a file with default permissions `665`. And when creating a directory it will have default permissions `775`. What are some ways to do this for a group setting? Thanks


How to install aMSN on Scientific Linux?

I can't find aMSN in the Scientific Linux 6 repositories.. How can I install it?


Difference between UUID from blkid and mdadm?

Can someone explain the difference between the UUID's reported by `blkid` and `mdadm`? On one of our CentOS systems, for example:               [root@server ~]# blkid | grep /dev/md1     /dev/md1: UUID="32cb0a6e-8148-44e9-909d-5b23df045bd1" TYPE="ext4"          [root@server ~]# mdadm --detail /dev/md1 | grep UUID     UUID : f204c558:babf732d:85bd7296:bbfebeea      Why are they different and how would we change the UUID used by `mdadm`? I understand we would use `tune2fs` to change the UUID for the partition (which would change what is returned by `blkid`) but not sure how to change what `mdadm` uses.


Stream audio from Linux to Raspbmc

I'd like to stream audio (mainly Spotify) to my Raspberry Pi. I am running Fedora 19 and Raspbmc is running on the Raspberry Pi. I'd like to stream wireless. My first thought was to use AirPlay, as XBMC already supports it. However, they are using v2 which does not seem to work with Shairport, which seems to be the only solution to stream from my Linux laptop. I am open to use another protocol than AirPlay. However, I would very much like it to be integrated with XBMC. Is there some solution to achieve this? Bonus would be if I also could stream video.


reasons for a dd image of an almost-empty drive not be small after gzip

i just cleaned a 50GB partition with `dd if=/dev/zero of=/dev/sda1` then added some data to it (actually installed a linux distro) some 3Gb on ext4. and decided to make a image. `dd if=/dev/sda1 | gzip -9 > sda1.dd.gz` and to my surprise, that file has 45GB! my thinking would be that the this file would have some 4GB as most of the size would be tailing zeros that `gzip` would take care of. where am I wrong? anyway to check how back the fragmentation is after the add- data step? Also, if it is fragmentation, any way to fix it? i'm now writing /dev/zero to a file until the drive is full...


Read non-bash variables from a file into bash script

My bash script needs to read the variables from a text file that contains hundreds of variables, most of which conform to standard bash variable sytax (e.g., `VAR1=VALUE1`). However, a few lines in this file can be problematic and I hope to find a simple solution to reading them into bash. Here's what the file looks like:               #comment     VAR1=VALUE1     VAR_2=VALUE_2     ...     VAR5=VALUE 5 (ASDF)     VAR6=VALUE 6 #a comment     VAR7=/path/with/slashes/and,commas     VAR8=2.1     VAR9=a name with spaces     VAR_10=true     ...     VAR_N=VALUE_N      The rules about the file structure include :   * one variable (with value) per line   * the assignment (=) has no spaces around it   * the variable name is in the first column (unless it is a comment line)   * comments can follow the value (after #)   * the values can include spaces, parens, slashes, commas and other chars   * the values can be floating point numbers (2.1) or integers or true/false or strings.   * string values are not quoted, and they can be a thousand chars long or longer   * the variable name contains only letters and underscores UPDATE: **and numbers**. Most of the variables are of a type that would just allow me to source the file into my bash script. But those few problematic ones dictate a different solution. I'm not sure how to read them.


Possible problems in moving linux disks from one hardware to another

I currently have a server collocated in a datacenter. The hardware is a HP dual quad core xeon with 16 Gb DDR2 and 2 1Gb disks in raid1. I want to order another similar server to have as a replacement, if the first server has a hardware issue I can just move the disks to the replacement and not lose time debugging the hardware problem while the server is down. The problem in this situation is that I can't find the exact same hardware to buy as a replacement so I will have to buy something similar. My question is, what problems can I face when moving the disks to the new hardware, can I encounter any driver issues or something similar or it should work without a problem as long as the cpu architecture is the same (intel xeon x64) ? Thank you.


How to list all present optical drivers?

How can I list all the installed optical drivers with _udev_ or any other core-based tool (perl is also very good) ? P.S.: I know about the `wodim --devices` command, but it's an undesirable dependence.


Is a command's stdout to the terminal being logged?

I am interested in learning whether a command's output to the terminal is logged somewhere. Since that can be a bit too generic, what about `cat` (and `ccat`) in specific? If I use `cat` on a file, will the output that I get on the terminal be logged somewhere?


Is there any mail list frontend that provides forum like interface?

I would like to have my mail lists presented like a forum (let's say phpBB), instead of having to browse through this unorganized pile of data: http://lists.nongnu.org/archive/html/ranger-users/ Is there any app that can do that? Google Groups is a good example of such an interface, but it's only available for internal mailing lists.


Looking for "Camera Mouse" for Linux

I have come across a cool piece of software called Camera Mouse. It lets you control your mouse cursor with just a webcam. Is there software like that for Linux based operating systems? (I would prefer something from the Debian repository, but compiling from source is cool too)


# of reads/writes for LVM vs. "regular" partitioning?

I am going to be installing linux to a USB flash drive (an actual install, not a "live usb"). I need it to be completely portable, so I can't realistically have the high-access partitions (swap, var, etc.) located on a HDD instead. I've read a lot about the limited life of flash memory, as well as the advantages + disadvantages of LVM, but have not found any information that addresses my question. Assuming a reasonable amount of RAM (to minimize swappiness), can using or not using an LVM affect the number of reads/writes done and therefore prolong or shorten the drive's lifespan?


What package has GNU sed for Solaris?

I need to use the features of GNU sed, instead of the built-in version under Solaris 10. Which GNU package contains it? I don't see it listed in the coreutils, and my Google searches haven't helped pinpoint it.


What program will save a fillable PDF?

There are several nice fillable PDFs available for the RPG hobby. These have boxes that number values can be entered and simple formulas are calculated throughout the sheet. I'm finding that the programs I've tried cannot save this data. I've tried PDFEdit, XPDF, and Evince. Is there a Linux program that will save fillable PDFs? Or perhaps I'm not using the above correctly?


passing passwords to a script

I want to `scp` a file to a remote host, and from there, run a command on the file, and exit the remote session. If I write a usual script, call `scp` and then `ssh`, I am prompted to enter two passwords. Is there a way to copy, `ssh`, and run a command on a remote machine with one password? Also how to write scripts which need to interact with user to enter passwords? I do not want to use "read" as it's not safe. I do not want to use passwordless `ssh`, since my private key file may be compromised, which is even worse. I read something about "expect" but not sure if it's the right tool.


format / rewrite old ide flash module

I have an old PC where the disk is a 32mb IDE flash module. BIOS boots the Flash, works good.   But if I am in a Linux distro (tinycore/arch/puppy) the flash module is not recognized nor mountable. On the flash module there is a custom Windows MCE powered by Gio. I want to replace that with a Linux kernel but I failed trying to access that memory so far. I already tried setting the jumper in every variation.   Could it be that the Manufacturer prevent access to it in BIOS? Below is a picture of the flash ide module. Maybe someone has an idea how to format this? ![ide flash module](http://i.stack.imgur.com/J37zg.jpg)


Linux kernel headers' organization

While I was doing some reading on system calls, I did a search for "syscalls.h" to find the header file in LXR. The search results puzzled me. There is a dozen of "syscalls.h" files coming from directories under "arch/_arch_name_/include/asm". These are ok, they are architecture specific definitions or something else needed. The question is why do we have two different "syscalls.h" headers under both /include/linux and /include/asm- generic? Also, I want to find out that what /include/linux headers are for and what /include/asm-generic headers are for. How do they differentiate between each other? What is the logic behind having two separate header folders? How do they relate to each other? Thanks


How to disable shutdown so that an important process cannot be interrupted?

What is the simplest way to disable or temporarily suspend reboot/shutdown when an important process is running? The process takes too long to finish and cannot be paused/resumed so I like to avoid shutting down the pc while it is running. It is run from cron so unless I manually check for running processes, I wouldn't know that it is running. Thanks.


Understanding boolean operators in bash script

phone_missing=false     echo "missing $phone_missing"          if [ ! $phone_missing ]     then             echo "Lost phone at $readabletime"             $phone_missing=true     fi      I just can't wrap my head around this, as stupid it may sound. The line               echo "missing $phone_missing"      echos `missing false`, I would very much expected the statement               if [ ! $phone_missing ]      to be true and enter the `if` clause, but it doesn't? What am I missing here!?


Odd Inode/Ram cache drops happening in CentOS

I run a CentOS 5.7 machine (64bit) with 24GB ram and 4x SAS drives in RAID10 setup. This machine runs nginx/1.0.10, php-fpm & xcache. About a month back the RAM usage of this machine has changed. About every few hours the 'CACHE' is flushed from the RAM, this happens exactly when the 'Inode table usage' drops. I'm pretty sure these drops are related. (see the 2 attached images). ![enter image description here](http://i.stack.imgur.com/xCHT9.png) ![enter image description here](http://i.stack.imgur.com/d0o2x.png) This server hosts quite a lot of small files (20M all a few KB big). Not many files are deleted (maybe 100 per hour (total size a few MB max)), not enough to account for the huge Inode table drops. I also have no crons running which could cause these drops. `Sar -r` output: http://pastebin.com/C4D0B79i **My question:** Why are these huge RAM/Inode usage drops happening? How can I get Nginx/PHP to use all of my servers RAM?


Problem with mount namespaces under Fedora

I've run into an odd problem regarding mount namespaces on Linux. I have two systems, both X86_64 running kernel 3.2.3-2 under Fedora 16. I am attempting to mount a `tmpfs` filesystem in a child namespace created using the `unshare` command:               unshare -m /bin/bash      From the man page:                  mount namespace               mounting and unmounting filesystems will not affect rest of  the               system (CLONE_NEWNS flag),      On one system, this works as expected. That is, if I start with this:               # ls /mnt     file1 file2 file3      And then mount a `tmpfs` filesystem over `/mnt` in a child namespace:               # PS1="child# ' unshare -m /bin/bash     child# mount -t tmpfs tmpfs /mnt      The contents of `/mnt` are masked in the child namespace:               child# ls /mnt     child#      But continue to be visible in the parent:               # ls /mnt     file1 file2 file3      On the second system, the exact same sequence of commands will result in a mount that is visible in the parent namespace as well as in the child namespace. In other words, it appears that the `unshare` command is not actually resulting in a separate mount namespace. I am not aware of any substantial differences between the two systems. One is running a desktop environment, the other is not. SELinux is disabled on both systems. I'm looking for any suggestions as to what could be causing this difference in behavior.


What is the STATE column of the TOP command on Solaris?

I'm running a very large, memory intensive program on my new UNIX server and trying to fully understand the output of the "top" command. Here is what I see right now (showing only the first process):               load averages:  1.51,  1.48,  1.45;               up 59+12:23:36                              08:57:47     194 processes: 191 sleeping, 1 zombie, 2 on cpu     CPU states: 99.5% idle,  0.4% user,  0.1% kernel,  0.0% iowait,  0.0% swap     Kernel: 2045 ctxsw, 73 trap, 2891 intr, 1797 syscall, 23 flt, 48 pgout     Memory: 256G phys mem, 214G free mem, 22G total swap, 22G free swap             PID USERNAME LWP PRI NICE  SIZE   RES STATE    TIME    CPU COMMAND      15382 bd9439    22   1    4 7799M 7787M cpu/147  21.9H  0.39% sas      What is the meaning of the number in the "STATE" column following "cpu" (in this case 147)? The `man` page only says:                STATE           Current state (typically one of "sleep", "run",  "idl",           "zomb", or "stop").      This is a new Oracle T4-4 server running Solaris 10 not yet in "production", meaning this is the only thing running right now. Solaris 10 and top version 3.7:               bd9439@bsprd697 $ uname -a     SunOS bsprd697 5.10 Generic_148888-01 sun4v sparc sun4v     bd9439@bsprd697 $ top --version     top: version 3.7


How to log all domains accessed?

Maybe I could use `tcpdump`, filter out all non-HTTP packets to reduce disk consumption, and then parse the output looking for domain names. Maybe there is a better solution. Do you know one?


grep *stringA*[number]

I was wondering how can I grep an expression of the type               *stringA*[number]      In other words, I want to target lines that have the following pattern:                anything + stringA + anything + [number]      For example these strings would match:               stringA[3]     this is a test stringA because_[4]     nothing really stringA[5]      these strings would not match:               stringA     something else [7]      How can I do this with grep? (or grep -e)?


Logrotate doesnt start proftpd triggerd by cronjob

Im currently running of ideas. The proftpd doesn't restart, if logrotate is triggered by the cron task. Logrotate rotates all logfiles stops proftpd but does not start proftpd again. If i force the rotation with `logrotate -f /etc/logrotate.d/proftpd-basic` everything works fine.. Any kind of ideas are welcome. I got the following setup. **cat /etc/cron.daily/logrotate**               #!/bin/sh          test -x /usr/sbin/logrotate || exit 0     /usr/sbin/logrotate /etc/logrotate.conf       **cat /etc/logrotate.conf**               # see "man logrotate" for details     # rotate log files weekly     weekly          # keep 4 weeks worth of backlogs     rotate 4          # create new (empty) log files after rotating old ones     create          # uncomment this if you want your log files compressed     #compress          # packages drop log rotation information into this directory     include /etc/logrotate.d          # no packages own wtmp, or btmp -- we'll rotate them here     /var/log/wtmp {         missingok         monthly         create 0664 root utmp         rotate 1     }          /var/log/btmp {         missingok         monthly         create 0660 root utmp         rotate 1     }          # system-specific logs may be configured here      **cat /etc/logrotate.d/proftpd-basic**               /var/log/proftpd/proftpd.log     /var/log/proftpd/controls.log     {             weekly             missingok             rotate 7             compress             delaycompress             notifempty             create 640 root adm             sharedscripts             postrotate                     # reload could be not sufficient for all logs, a restart is safer                     invoke-rc.d proftpd restart 2>/dev/null >/dev/null || true                     #invoke-rc.d proftpd reload 2>/dev/null >/dev/null || true             endscript     }          /var/log/proftpd/xferlog     /var/log/proftpd/xferreport     {             monthly             missingok             rotate 7             compress             delaycompress             notifempty             create 640 root adm             sharedscripts             prerotate             endscript             postrotate                     # reload could be not sufficient for all logs, a restart is safer                     invoke-rc.d proftpd restart 2>/dev/null >/dev/null || true                     #invoke-rc.d proftpd reload 2>/dev/null >/dev/null || true                     # run ftpstats on past transfer log                     ftpstats -a -r -l 2 -d -h -f /var/log/proftpd/xferlog.0 2>/dev/null >/var/log/proftpd/xferreport || true             endscript     }


Ubuntu Linux 12.04 - Load Non-MBR grub from the old grub in MBR

I have installed Ubuntu linux 12.04 on sda10, and grub2 in sda5 . Actually I had a legacy grub installed in MBR, I want to load Ubuntu linux from the old grub. How could I do this? This question arise, because before I installed Ubuntu linux 12, I already have a grub installed in my pc, and working well with three other OS, after I installed Ubuntu linux 12 with grub in MBR, I can't load other system. So I have to install Ubuntu Linux grub in non-MBR, and want to find a way to load it from the old grub. Thanks.


How to restore kde plasma desktop

I was tried chrome remote desktop app with a friend. He has a Mac. By mistake he clicked cmd + s, I do not know if that is super + s combination, the thing is it killed all my kde plasma widgets. Is there a short way to restore it?


How can I prevent smartd from reporting that it cannot find a disk?

I have smartd monitoring my hard drives. It works fine generally, but the following error window has been consistently popping up every 24 hours.               This email was generated by the smartd daemon running on:       host name: sparhawk-XPS-17       DNS domain: [Unknown]       NIS domain: (none)     The following warning/error was logged by the smartd daemon:     Device: /dev/sdc [SAT], unable to open device     For details see host's SYSLOG.     You can also use the smartctl utility for further investigation.     Another email message will be sent in 24 hours if the problem persists.      There is no sdc connected, but nevertheless I try `sudo smartctl -a /dev/sdc`. The result is               smartctl 5.43 2012-06-30 r3573 [x86_64-linux-3.5.0-26-generic] (local build)     Copyright (C) 2002-12 by Bruce Allen, http://smartmontools.sourceforge.net     Smartctl open device: /dev/sdc failed: No such device      The only non–commented-out line in `/etc/smartd.conf` is               DEVICESCAN -m root -M exec /usr/share/smartmontools/smartd-runner      Is there a way to make smartd correctly identify the removal of this disk, and not complain about it? If this is not possible, then is there a way to make smartd only monitor sda and sdb?


Install Shutter on Centos

I'm trying to figure out a way to install shutter on Centos. Are there any repos somewhere?


pixelview bt878 card not being recognized

I'm having huge difficulties with using Pixelview pv-bt878p+ rev.9d with Linux. I'm using a stock Debian kernel, version 3.2.0-1-686-pae #1 SMP. When I load bttv module for that card I get this:               [  683.700105] bttv: 0: unloading     [  690.772928] bttv: driver version 0.9.19 loaded     [  690.772941] bttv: using 8 buffers with 2080k (520 pages) each for capture     [  690.773719] bttv: Bt8xx card found (0)     [  690.773767] bttv: 0: Bt878 (rev 17) at 0000:00:0f.0, irq: 12, latency: 64, mmio: 0xcfdfe000     [  690.773817] bttv: 0: using:  *** UNKNOWN/GENERIC ***  [card=0,autodetected]     [  690.775504] tveeprom 0-0050: Huh, no eeprom present (err=-6)?     [  690.775516] bttv: 0: tuner type unset     [  690.777636] bttv: 0: registered device video0     [  690.779489] bttv: 0: registered device vbi0      I know I can add some options to the module, so I've been trying with such:               modprobe bttv  card=72 tuner=38 radio=1 gpiomask=0x3F audiomux=33,32,35,35,40      and               modprobe bttv  card=70 tuner=38 radio=1 gpiomask=0x3F audiomux=33,32,35,35,40      Which I've found somewhere on the internet, and it fixed one's problems with similar card. For me it was unsuccessful. lspci for that card gives me this:               00:0f.0 Multimedia video controller: Brooktree Corporation Bt878 Video Capture (rev 11)             Flags: bus master, medium devsel, latency 64, IRQ 12             Memory at cfdfe000 (32-bit, prefetchable) [size=4K]             Capabilities: [44] Vital Product Data             Capabilities: [4c] Power Management version 2             Kernel driver in use: bttv          00:0f.1 Multimedia controller: Brooktree Corporation Bt878 Audio Capture (rev 11)             Flags: bus master, medium devsel, latency 64, IRQ 12             Memory at cfdff000 (32-bit, prefetchable) [size=4K]             Capabilities: [44] Vital Product Data             Capabilities: [4c] Power Management version 2      Perhaps some of you know how could I progress in my endeavour to start using this card under linux?


Problem when I use the webdings font in firefox or inkscape

I installed the `webdings font` in my computer, and it works well with `LibreOffice`.   But when I use the `webdings font` in a local html page : it doesn't work, the following unicode character is diplayed instead of the wanted character ``.   But if I export my local web page to PDF (with the `wkhtmltopdf` tool) I get the wanted character in the PDF.   So I don't understand why it doesn't work on my local web page (I tried with `firefox` and `chromium`). If someone has an idea? I also tried in `inkscape` but I was unable to display my character in it. A bit of code to clarify it :               /* the font in my css file */     @font-face {         font-family:'webdings';         font-weight: normal;         font-style: normal;         src: local('Webdings'), url('webdings.ttf') format('truetype'); }          .icone { font-family: webdings; }               &#xF0FC


Which virtual terminal is a given X process running on?

When X starts, it searches for the lowest unused VT, and attaches to it. My problem is that when there are several running X processes, I need to be able to identify which one is the currently active one. This is a *BSD question, because on linux it's easy: X sets its controlling terminal to be `ttyN`, or, on very old distributions, it's specified on the commandline as `vtN`. So, I'm running a service and I see that the currently active VT is `tty7`, and there are two X servers running, it's easy to tell which one corresponds to the current terminal. (This is a reasonable case: perhaps the user used GNOME/KDE's 'switch user' functionality or ran two servers using `startx`.) An example application that might want to follow the active X server is `x11vnc` (which is forked from the software I'm developing). On FreeBSD though, the controlling terminal does not tell you anything. When X is started from ttyv1, that remains the controlling terminal. ### Update I've done due diligence and read the X code. After some hunting around, it's now clearer to me what's going on. In lnx_init.c, the X server does `setsid` to make a fresh session for itself, then opens an fd to `ttyN` straight after to do a `VT_ACTIVATE` ioctl on it. Pretty standard; opening the fd to a terminal with no controlling process from a process with no controlling terminal associates the two, and the server keeps the fd open, so it's guaranteed that the terminal will remaining the controlling terminal for the X server. Now, in bsd_init.c, opening the fd to the tty to be used as the framebuffer doesn't make it a controlling terminal (and in fact, with no `setsid`, BSD Xserver started from `xinit` on ttyv2 will keep ttyv2 as its ctty!). ### Question further updated and cleaned up on 2012-04-09.


Disable tab autocompletion in interactive mode

I have `set disable-completion on` in my `~/.inputrc`, however this doesn't affect php in interactive mode (`php -a`). I would like to copy some code from another editor to the php interactive shell which uses tab characters as indention.


Adding a populated existing disk device to a QEMU raw image

I have a raw QEMU image (vda.raw), and I would like to resize it and add an existing partition, using data I have in a file that contains a raw ext3 file system populated with data (vdb.raw). The two files look like this:               $ file vda.raw     vda.raw: x86 boot sector; partition 1: ID=0x83, active, starthead 0, startsector 16065, 20948760 sectors, code offset 0x63     $ file vdb.raw     vdb.raw: Linux rev 1.0 ext3 filesystem data, UUID=14555b9c-4837-4b43-a8e8-fe4e19194e88, volume name "ephemeral0" (large files)      Is there a simple way I can create a new image by combining these two: where the contents of vdb.raw appear as a new disk partition in vda.raw? I'd like to avoid having to:   1. Resize vda.raw   2. Create a new partition in vda.raw   3. Mount vda.raw   4. Mount vdb.raw   5. Copy the contents of vdb.raw into vda.raw Is there a way I could, say, concatenate them with dd, and then fix the partition table to make it aware that there's a new partition in the image?


Writing data on particular sectors or blocks

Not sure if it's better suited for _superuser_ of _serverfault_ boards, let me know. I have a drive which I repartitioned with `fdisk`. Initially there was only one big partition, now there are a number of partitions. Now the new partition table won't be taken into account by the kernel until the next reboot. The point is that there are some data on this drive which are shared through NFS, and which should be present on the drive when rebooting. Also, I want to avoid modifying configuration files, even temporarily. So I would like to ensure these data are on the first partition, `/dev/sdb1`, corresponding to the previous single partition, so that they are immediately available at next boot. So is there a (simple) way to write data on particular sectors or blocks on the drive ? Is it the purpose of the `dd` "seek" option ? If I manage to do that the data will still be readable at next reboot once the new partition has been taken into account, right ? FWIW, the amount of data is not so large, 2.1 MB, but `/dev/sdb1` is only 82 MB and the drive is 160 GB. Thanks. Edit : For the whole history and why I cannot reload the partition table (which would be the best solution), see this question on _serverfault_. Edit2 : Ok, I may have found a workaround, which would be to copy files from elsewhere as soon as the machine is rebooted, before NFS is set up. Edit3 : Nevermind Edit2, the new `/dev/sdb1` wouldn't be formatted yet… Edit4 : Actually, this last edit probably discards the whole question, as it applies in any case. Should have think of that earlier…


linux launch script /etc/init with a specific user

I've created a script in /etc/init/mms-agent.conf :               start on runlevel [2345]     stop on runlevel [06]          exec /usr/bin/env python /home/mms/mms-agent/agent.py >> /home/mms/agent.log 2>&1      service mms-agent start/stop work fine, but i'd like to start this service with the user "mms" When I try to change the script as following :               exec su mms -c "/usr/bin/env python /home/mms/mms-agent/agent.py >> /home/mms/agent.log 2>&1"      I get 3 process running instead of 1 expected (su, bash + my python script):               mms       8864  0.0  0.2  37816  1332 ?        Ss   22:30   0:00 su mms -c /usr/bin/env python /home/mms/mms-agent/agent.py >> /home/mms/agent.log 2>&1     mms       8865  0.0  0.2  11452  1196 ?        S    22:30   0:00 bash -c /usr/bin/env python /home/mms/mms-agent/agent.py >> /home/mms/agent.log 2>&1     mms       8866  4.0  1.8  54672 10640 ?        Sl   22:30   0:00 python /home/mms/mms-agent/agent.py      What does that mean ? What is the best way to start a script with a user different than root ? Thanks PS :               exec start-stop-daemon --start -u mms --exec "/usr/bin/env python /home/mms/mms-agent/agent.py"      doesn't work, I got no error but the process isn't started.


How to fix unreliable Realtek Wireless card on Ubuntu 13.04

I have a Realtek RTL8188CE wireless card and it works fine when I have a strong signal, but if I get even slightly away from the wifi I lose connectivity even though there is a strong Rx signal. I suspect that the Tx power from my laptop is not strong enough, but running: `sudo iwconfig wlan0 txpower 23` was ineffective. The card would not let me set it above 20 dBm. How can I either fix the flakiness or increase the Tx power?


SFTP server on RHEL6 disconnects on ls

I've followed the steps outlined here to create a chrooted sftp environment. Everything works great EXCEPT for the command ls. When I do an ls, with any of the flags, I get disconnected immediately. When I do an strace on the PID, I get this (couldn't get it looking better than this. Any ideas? I'm at wits ends. >     `Process 7071 attached - interrupt to quit      select(5, [3], [], NULL, NULL)          = 1 (in [3])      read(3, "\0\0\0\n\v\0\0\0\2\0\0\0\1/", 16384) = 14      open("/", O_RDONLY|O_NONBLOCK|O_DIRECTORY|O_CLOEXEC) = 5      select(5, [3], [4], NULL, NULL)         = 1 (out [4])      write(4, "\0\0\0\rf\0\0\0\2\0\0\0\4\0\0\0\0", 17) = 17      select(5, [3], [], NULL, NULL)          = 1 (in [3])      read(3, "\0\0\0\r\f\0\0\0\3\0\0\0\4\0\0\0\0", 16384) = 17      getdents(5, /* 3 entries */, 32768)     = 80      lstat("/.", {st_mode=S_IFDIR|0750, st_size=4096, ...}) = 0      stat("/etc/localtime", 0x7fff44193d90)  = -1 ENOENT (No such file or directory)      open("/etc/localtime", O_RDONLY)        = -1 ENOENT (No such file or directory)      open("/etc/passwd", O_RDONLY|O_CLOEXEC) = -1 ENOENT (No such file or directory)      close(4)                                = 0      socket(PF_FILE, SOCK_STREAM, 0)         = 4      fcntl(4, F_SETFD, FD_CLOEXEC)           = 0      fcntl(4, F_GETFL)                       = 0x2 (flags O_RDWR)      fcntl(4, F_SETFL, O_RDWR)               = 0      connect(4, {sa_family=AF_FILE, path="/var/lib/pbis/.lsassd"}, 110) = -1 ENOENT (No such file or directory)      close(4)                                = 0      open("/etc/group", O_RDONLY|O_CLOEXEC)  = -1 ENOENT (No such file or directory)      socket(PF_FILE, SOCK_STREAM, 0)         = 4      fcntl(4, F_SETFD, FD_CLOEXEC)           = 0      fcntl(4, F_GETFL)                       = 0x2 (flags O_RDWR)      fcntl(4, F_SETFL, O_RDWR)               = 0      connect(4, {sa_family=AF_FILE, path="/var/lib/pbis/.lsassd"}, 110) = -1 ENOENT (No such file or directory)      close(4)                                = 0      lstat("/..", {st_mode=S_IFDIR|0750, st_size=4096, ...}) = 0      open("/etc/localtime", O_RDONLY)        = -1 ENOENT (No such file or directory)      open("/etc/passwd", O_RDONLY|O_CLOEXEC) = -1 ENOENT (No such file or directory)      socket(PF_FILE, SOCK_STREAM, 0)         = 4      fcntl(4, F_SETFD, FD_CLOEXEC)           = 0      fcntl(4, F_GETFL)                       = 0x2 (flags O_RDWR)      fcntl(4, F_SETFL, O_RDWR)               = 0      connect(4, {sa_family=AF_FILE, path="/var/lib/pbis/.lsassd"}, 110) = -1 ENOENT (No such file or directory)      close(4)                                = 0      open("/etc/group", O_RDONLY|O_CLOEXEC)  = -1 ENOENT (No such file or directory)      socket(PF_FILE, SOCK_STREAM, 0)         = 4      fcntl(4, F_SETFD, FD_CLOEXEC)           = 0      fcntl(4, F_GETFL)                       = 0x2 (flags O_RDWR)      fcntl(4, F_SETFL, O_RDWR)               = 0      connect(4, {sa_family=AF_FILE, path="/var/lib/pbis/.lsassd"}, 110) = -1 ENOENT (No such file or directory)      close(4)                                = 0      lstat("/attreport", {st_mode=S_IFDIR|0755, st_size=4096, ...}) = 0      open("/etc/localtime", O_RDONLY)        = -1 ENOENT (No such file or directory)      open("/etc/passwd", O_RDONLY|O_CLOEXEC) = -1 ENOENT (No such file or directory)      socket(PF_FILE, SOCK_STREAM, 0)         = 4      fcntl(4, F_SETFD, FD_CLOEXEC)           = 0      fcntl(4, F_GETFL)                       = 0x2 (flags O_RDWR)      fcntl(4, F_SETFL, O_RDWR)               = 0      connect(4, {sa_family=AF_FILE, path="/var/lib/pbis/.lsassd"}, 110) = -1 ENOENT (No such file or directory)      close(4)                                = 0      open("/etc/group", O_RDONLY|O_CLOEXEC)  = -1 ENOENT (No such file or directory)      socket(PF_FILE, SOCK_STREAM, 0)         = 4      fcntl(4, F_SETFD, FD_CLOEXEC)           = 0      fcntl(4, F_GETFL)                       = 0x2 (flags O_RDWR)      fcntl(4, F_SETFL, O_RDWR)               = 0      connect(4, {sa_family=AF_FILE, path="/var/lib/pbis/.lsassd"}, 110) = -1 ENOENT (No such file or directory)      close(4)                                = 0      getdents(5, /* 0 entries */, 32768)     = 0      select(5, [3], [4], NULL, NULL)         = -1 EBADF (Bad file descriptor)      sendto(7, "<83>Feb 27 22:02:23 sshd[7071]: "..., 66, MSG_NOSIGNAL, NULL, 0) = -1 EBADF (Bad file descriptor)      close(7)                                = -1 EBADF (Bad file descriptor)      socket(PF_FILE, SOCK_DGRAM|SOCK_CLOEXEC, 0) = 4      connect(4, {sa_family=AF_FILE, path="/dev/log"}, 110) = -1 ENOENT (No such file or directory)      close(4)                                = 0      exit_group(2)                           = ?      Process 7071 detached      `


Easiest way to duplicate directory over FTP

I want to duplicate a directory on an FTP server I'm connected to from my Mac via the command-line Let's say I have `file`. I want to have `files2` with all of `file`'s subdirectories and files, in the same directory as the original. What would be the simplest way to achieve this? (I´m a complete newbie to the UNIX command line, so sorry if the question is not clear enough; please ask for any clarification needed.) EDIT: With `mget` and `mput` you could download all files and upload them again into a different folder but this is definitely NOT what i want/need (I started this question trying to avoid duplicating with this download upload method from the dektop client)


Extending swap on Centos

I recently created a swap file on my centos 6 based VPS using this guide. Now I wanted to extend this swap and I was reading through this guide. However, I think I've created a swap file than a partition. How do I go about extending this swapfile? The current size is 512M and I need to extend it by another 1G. Any help would be appreciated since I'm a linux newbie.


Thunderbird: Override colors in received HTML emails

I need to override default colors in received HTML emails. I have followed this Howto, and modified my `userContent.css` accordingly. Basically, I need white text on dark background:               $ cat userContent.css     body {       color: white !important;        background-color: #303030 !important;     }          td {       color: white !important;       background-color: black !important;     }      This works OK for the background color, but the my desired font color (white) is being ignored, even when I use `!important`. How can I make sure, that all received HTML emails have white font on dark bacckground?


iPod Nano 6G on Linux

I see that Apple no longer supports `libgpod` for the iPhone4/iPod Touch 4 and Nano 6G. I see also that the system of databases for those new device has to be the same. I found many videos where you can see `libimobiledevice` works well with iPhone but none about the "new" Nano 6G and I couldn't get it to work - unlike my old Nano 1G that does. It's normal that the Nano 6G doesn't work? Is there a way, including with commercial programs, to sync my iPod Nano 6G under Linux (without dualboot or VM)? I'm running Fedora 16 x64.


Counting comma separated characters in a row

How can I count how many elements are separated with comma in a given column of a file (tab_delimited), using awk or sed? Exemple:               AC    1,23,5     DC    2,8,89      Would return:               AC    3     DC    3


Get input from editor (vim/nano/emacs/textmate?)

I was just curious if there's a way to get input not from `StdIn` but from `$EDITOR` - be it vim, nano, emacs or even a non-command-line-editor (MacVim/TextMate). What are the options/workarounds/bestpractices? Basically I'd wish for a workflow as with `heredoc` - but from the $editor instead.               $ sort -nr << FOO | uniq -c      pipe heredoc> foo      pipe heredoc> bar     pipe heredoc> baz     pipe heredoc> foo     pipe heredoc> FOO        2 foo        1 baz        1 bar


Is it possible to reference the most recently modified file in a command line argument?

I frequently download PDF files with heinous numeric file names from my browser. These automatically go into `~/Downloads`. Ideally I would like to just be able to open these files with:               evince "the most recently modified file"      without having to open `~/Downloads` to find the file name. Is there a simple way to specify "the most recently modified file" in `bash`? NOTE: I know that it is _possible_ to do this, but ideally I am looking for a solution that would be simpler than `ls -t`'ing `~/Downloads` to check the name.


How to multiply a data file with another index data file?

I want your help in multiplying my data file with another index data file. Both data files have the same number of rows. But the data file have more than 1000 columns while the index data has only one column. The index file is the factor by which I want to multiply the whole columns of the my data. Here is my sample data and the required output below Data.txt:               10  20  30  40  50     20  30  40  50  60     30  40  50  60  70     40  50  60  70  80     50  60  70  80  90     60  70  80  90  100     70  80  90  100 110     80  90  100 110 120      index.txt:               0.1     0.2     0.3     0.4     0.5     0.6     0.7     0.8     .     .     .     .      Required output file will be out.txt               1   2   3   4   5     4   6   8   10  12     9   12  15  18  21     16  20  24  28  32     25  30  35  40  45     36  42  48  54  60     49  56  63  70  77     64  72  80  88  96


How to check if `wget` supports a certain feature programatically?

Is there a way to programatically detect if the currently installed wget supports a given feature, for example, IRI support? I’m asking because I’d like to add these lines to my `.wgetrc`:               # Use UTF-8 as the default system encoding     local_encoding = UTF-8      But this makes wget unusable if it doesn’t support the `local_encoding` setting. So, I’d like to conditionally configure this setting, only if wget supports the feature. In Vim (`.vimrc` files) you can do this using `has()` and `exists()`:               if has("autocmd")       " Define autocommands here     endif      How can I do something similar for wget in `.wgetrc`?


How to search in PDF files recursively?

> **Possible Duplicate:**   >  grep pdf files? With a Linux machine, ex.: an Ubuntu, how can I search for a given word recursively in several PDFs?


sysrq won't reboot with a keystroke, but will with echo "b" > /proc/sysrq-trigger

CentOS 6.2, 2.6.32-220.el6.x86_64 laptop. SysRQ is enabled for keyboard input, as is witnessed by:               $ cat /proc/sys/kernel/sysrq      1      Common Magic SysRQ Keys are working such as `alt`-`sysrq`-`h`. However, other keystrokes do not appear to be working. Most notably, `alt`-`sysrq`-`b` for rebooting. However, I can get the reboot SysRQ option to work via `echo "b" > /proc/sysrq-trigger` I realize that `/proc/sys/kernel/sysrq` does not need to be enabled in order for echoing options to `sysrq-trigger` to work, so I'm assuming that there's some problem with the Magic SysRQ key combination actually being signaled. What would be causing the inability for some SysRQ keystrokes to work, but others not? And yet manually sending the option to `sysrq-triggers` _will_ work? # EDIT 1 Shamefully, I left out some information in the above question. Yes, I'm using a laptop, but I'm also using an external keyboard. I don't think I've used the built-in keyboard on my Dell XPS 1530 for years so it didn't even register in my mind that the keyboard situation could be part of the issue. On the Dell XPS 1530's built-in keyboard, the SysRQ key is technically a function key. "SysRQ" is printed in blue to signal that a person, theoretically, should press the `Fn` key to access it. However, when using the built-in keyboard, you merely have to press the standard `alt`-`sysrq`-`b` combination to cause a reboot! No function key required. My external keyboard is a Logitech Illuminated Keyboard, and it has its own `FN` key on it. However, SysRQ is not apparently mapped as an alternate key. I say "apparently" because `SysRQ` isn't actually printed on **_any_** of the keys. Instead, I assumed that `Print Screen` was the SysRQ key because that's what SysRQ has shared a key with in recent years. That seems to have been a fair assumption because, as I tested things out, most Magic SysRQ key combinations work using that key as `SysRQ`. Nevertheless, I've tried a plethora of combinations using the external keyboard, and none of them seem to work with the re[B]oot Magic SysRQ key. I know `alt` works and I know `print screen` works as the SysRQ key without need for the function key on the external keyboard. It just appears, at this moment anyway, that the `b` key is not being sent as be. Is there any way that I can see what key code is being sent to my terminal as I type on a keyboard?


/usr/bin/ptx: Can you provide a use case or two?

I was going through the list of files included in coreutils and I was able to come up with an example of how I could personally use all of the commands provided except for ptx. Can you give one or two (or three) examples of using ptx? The more varied the use case the better.               $ apropos ptx     ptx(1)         - produce a permuted index of file contents


Rename the last 8 characters in filename

I am receiving video files with different names but the final 8 characters of all are numbers (also different every time). This is the pattern of the file name:               custom text 00030402.avi      I have to make file name looks like this:               00\:03\:04\:02      So my question is how to rename the last 8 characters and preserve them to achieve this pattern.


Path syntax rules

I'm writing a library for manipulation Unix path strings. That being the case, I need to understand a few obscure corners of the syntax that most people wouldn't worry about. For example, as best as I can tell, it seems that `foo/bar` and `foo//bar` both point to the same place. Also, `~` usually stands for the user's home directory, but what if it appears in the _middle_ of a path? What happens then? These and several dozen other obscure questions need answering if I'm going to write code which handles every possible case correctly. Does anybody know of a definitive reference which explains the _exact_ syntax rules for this stuff? (Unfortunately, searching for terms like "Unix path syntax" just turns up a million pages discussing the `$PATH` variable... Heck, I'm even struggling to find suitable tags for this question!)


How to install Picasa on Scientific Linux 6.3?

I can install/use Picasa with wine, but how can I natively install it from RPM (are there any offical sources to get the installer?)


Linux's man alternatives

Are there any alternatives to linux's man? I know many users used to man and for them it's useful and best way to find what they want, but i'm looking for something which is focused on examples. Is there any offline soft like man or maybe site where most popular commands have manual in convention "examples first" or "most used examples first" and all switches at the end? Often if i don't remember arguments etc. it's better way to look at any common example and short info about what it does instead of searching proper option on man


How to modify linux console prompt line ( for a while )

For example I typed such commands:               user@my-machine:~$ cd ABC     user@my-machine:~/ABC$ cd long-name     user@my-machine:~/ABC/long-name$ cd another-long-name     user@my-machine:~/ABC/long-name/another-long-name$ ls      So, I've chosen directory I need, and I need to work in it ( lots of commands ). But half of my console line is the prompt line. It's not very comfortable. Can I shorten it for a while? For example I'll make it `user@my-machine:~foo$` and when I finish working in this directory - I'll turn this shortness off. Is there a way to do this?


Kernel panic when passing noatime in bootargs

I have an embedded system using jffs2 and want to pass `rootflags=noatime` in the kernel `bootargs` parameter. This results in a kernel panic:               jffs2: Error: unrecognized mount option 'noatime' or missing value     [...]     No filesystem could mount root, tried:  jffs2     Kernel panic - not syncing: VFS: Unable to mount root fs on unknown-block(31,3)      However, if I boot normally and then remount the jffs2 filesystem with noatime, it works fine:               $ mount -o remount,noatime /      I am puzzled by this as according to the documentation, the rootflags argument "allows you to give options pertaining to the mounting of the root filesystem just as you would to the mount program". Looks like a kernel bug to me, but on the other hand it seems so obvious that perhaps I am overlooking something. I have tested this with kernel versions 3.7 and 3.14. Can someone shed some light?


Best location and permissions for socket files

I will have a couple of WSGI applications. They will communicate with `nginx` using sockets. For that purpose I've created the directory `/run/wsgi` in which I will place all the socket files that are needed. My problem is that `nginx` is not able to access the socket file. I've given ownership of `/run/wsgi` to `www-data` to no avail. What would be the correct permissions for the directory?. I chose the `/run` directory because the commonly used `/tmp` does not guarantee persistence of the files (according to the FHS). I'm open to discussion about this decision, though. My applications will run under Ubuntu Server 3.0.0-30 with SElinux disabled. `nginx` was installed using `apt-get`.


Convert Ogv -video to Gif -animation?

I created Ogv -videos with gtk-recordMyDesktop -screecasting program, trying to tackle this problem here with bruteforce over X. You can view the videos with VLC. Now the puzzle is to find some ways to convert Ogv -videos into Gif -animations so I can display them in SE. How can I do that?


bash merge 2 lists removing duplicated

I have an embedded linux system using Busybox (OpenWRT) - so commands are limited. I have two files that look like: first file               aaaaaa     bbbbbb     cccccc     mmmmmm     nnnnnn      second file               mmmmmm     nnnnnn     yyyyyy     zzzzzz      **I need to merge these 2 lists into 1 file, and remove the duplicates.** I don't have diff (space is limited) so we get to use the great `awk`, `sed`, and `grep` (or other tools that might be included in a standard Busybox instance). Going to a merge file like:               command1 > mylist.merge      command2 mylist.merge > originallist      is totally ok. It doesn't have to be a single-line command. Currently defined functions in the instance of Busybox that I am using (default OpenWRT): [, [[, arping, ash, awk, basename, brctl, bunzip2, bzcat, cat, chgrp, chmod, chown, chroot, clear, cmp, cp, crond, crontab, cut, date, dd, df, dirname, dmesg, du, echo, egrep, env, expr, false, fgrep, find, free, fsync, grep, gunzip, gzip, halt, head, hexdump, hostid, hwclock, id, ifconfig, init, insmod, kill, killall, klogd, less, ln, lock, logger, logread, ls, lsmod, md5sum, mkdir, mkfifo, mknod, mktemp, mount, mv, nc, netmsg, netstat, nice, nslookup, ntpd, passwd, pgrep, pidof, ping, ping6, pivot_root, pkill, poweroff, printf, ps, pwd, reboot, reset, rm, rmdir, rmmod, route, sed, seq, sh, sleep, sort, start-stop-daemon, strings, switch_root, sync, sysctl, syslogd, tail, tar, tee, telnet, telnetd, test, time, top, touch, tr, traceroute, true, udhcpc, umount, uname, uniq, uptime, vconfig, vi, watchdog, wc, wget, which, xargs, yes, zcat


How to create a snapshot of a physical disk?

I have Windows 7 installed on one of my disks. I want to boot this Windows system in my Xen HVM, but I do not want the changes to be permanent. So I want to create a snapshot of my Windows 7 partition. I checked with LVM, but it seems LVM can only create snapshot for LV it created. I am looking for a more general snapshot method.


Is there a clipboard on non-GUI Ubuntu / Linux systems? Can I synchronize it with my local (OS X) clipboard?

I spend a lot of time on Mac OS X as a desktop system, and on the Mac there are two nice little utilities for the command line, `pbcopy` and `pbpaste` which can accept `stdin` and write to `stdout`. **Is there a similar utility or non-GUI pasteboard in linux? How does that work?** I read over this blog post http://blog.roseman.org.uk/tag/iterm2.html in which a guy who works for Google says that he can use `XQuartz`, `iTerm2`, and `vim` and have things he `yanks` in `vim` copied to the system pasteboard, which syncs with his local clipboard. I've installed `XQuartz`, changed preferences and checked the boxes to sync the pasteboards, and connected to ssh remotely with X forwarding (`ssh -X`) but when I yank things in `vim` to the system pasteboard (`"+yy`) on a remote system, my local clipboard does not change. **What am I doing wrong? Do I need to be using`tmux` to have the pasteboards sync?** I'm going into this a little blind having not used the pasteboard in command- line linux before. Can someone help me understand a little more on this subject?


Gnome Shell Integration in Chrome not working

Just upgraded to Ubuntu 14.04, which seems to also make a full reinstall of Chromium (as all my plugins were removed). Now, trying to access `https://extensions.gnome.org/` to enable Gnome Shell extensions, but the message: > We cannot detect a running copy of GNOME on this system, so some parts of > the interface may be disabled. See our troubleshooting entry for more > information. keeps appearing. There is nothing in my `chrome://plugins` page, but the site still seems to be whitelisted in my "click to play" settings. Has anyone found out how to force `Chrome` to get this plugin?


What's the difference between "equery depends" and "equery depgraph"?

xi@localhost /usr/src $ equery depgraph gcc | wc -l     872     xi@localhost /usr/src $ equery depends gcc      * These packages depend on gcc:     app-admin/eselect-python-20100321 (>=sys-devel/gcc-3.4)     sys-devel/llvm-3.0-r2 (>=sys-devel/gcc-3.0)     sys-libs/glibc-2.15-r3 (>=sys-devel/gcc-3.4.4)                            (arm ? >=sys-devel/gcc-4.1.0)                            (x86 ? >=sys-devel/gcc-4.3)                            (amd64 ? >=sys-devel/gcc-4.3)                            (ppc ? >=sys-devel/gcc-4.1.0)                            (ppc64 ? >=sys-devel/gcc-4.1.0)     xi@localhost /usr/src $ equery depgraph     Display a direct dependency graph for a given package          xi@localhost /usr/src $ equery depends     List all packages that depend on a atom given query


How can I kill and wait for background processes to finish in a shell script when I Ctrl+C it?

I'm trying to set up a shell script so that it runs background processes, and when I `Ctrl``c` the shell script, it kills the children, then exits. The best that I've managed to come up with is this. It appears that the `kill 0 -INT` also kills the script before the wait happens, so the shell script dies before the children complete. Any ideas on how I can make this shell script wait for the children to die after sending `INT`?               #!/bin/bash     trap 'killall' INT          killall() {         echo **** Shutting down... ****         kill 0 -INT         wait # Why doesn't this wait??         echo DONE     }          process1 &     process2 &     process3 &          cat # wait forever


A minimal POSIX conformant operating system

For educational purposes, I'd like to start with a POSIX compliant base, including a shell, basic utilities, and an ANSI C compiler, then see what kind of environments I can build by putting packages together. However, most minimal POSIX conformant operating systems I've come across seem to be embedded and/or proprietary. Are there any such open source systems I can easily run under Virtualbox? I have searched around a little about building such an environment from scratch, but it seems like it's a lot of work to simply get a bootable/usable environment, much less a a POSIX compliant one. I might try my hands at building a POSIX OS someday, but I'd first like to be a bit more computer savvy beforehand. Note: I think I have heard somewhere that Linux is not completely POSIX conformant, but as long as I can compile and build some of the more common and essential open source tools (like wget and w3m), I would be pretty happy, whether or not it used the Linux kernel. Same goes for the other basic components I would imagine might come with the operating system (e.g. glibc)


Running NFS server as ver 3

As NFS docu stands it is possible to run NFS serwer ver 4 as ver 3 from the boot. Just it is necessery to add such entries in /etc/defaults/nfs file:               NFS_SERVER_VERSMAX=3     NFS_SERVER_VERSMIN=3      I created such file but NFS server sill starts as ver 4. What is wrong in my config?


unmount pendrive discarding changes

Is it possible to unmount a (FAT32-formatted) pendrive without committing changes? Use case: easy recovery of accidentally deleted files


Use rsync with closed files only

I am interested in using rsync with the --remove-source-files option. I am planning on pointing it to a directory, with a command like:               rsync -avm --remove-source-files --include='*.dat' -f 'hide,! */' . /destination_dir      If I have a file open for writing in the directory, will rsync be smart enough to not transfer that file until it is closed?


Using tar on a file with an @ (at symbol)

I'm trying to extract a tarball using `tar -xvf` that's in the format (where * is any word character) *@*@*@*.tar.gz but I think tar is trying to find the file at a remote location. The error I get is for the command `tar -xzvf tasf423@2012-02-22\@00:03:04\@ja41nf.tar.gz`:               tar (child): Cannot connect to 2012-02-22@00: resolve failed      I tried using back slashes to escape it and even tried replacing the @ symbols with %40 but none of this seemed to work. Is there any way to extract a tarball using the tar command with an @ in its name?


bash globstar matching

I have this directory structure:               ~/tmp/globstar ɀ  find dir -type f     dir/file.ext     dir/subdir1/file.ext     dir/subdir2/file.ext      and, with the `globstar` option enabled in Bash, I can say:               ~/tmp/globstar ɀ  ls -1 dir/**/*.ext     dir/subdir1/file.ext     dir/subdir2/file.ext      My question is: why is `dir/file.ext` excluded from this list? Bash manual says this about `globstar`: > If set, the pattern ‘**’ used in a filename expansion context will match all > files and zero or more directories and subdirectories. If the pattern is > followed by a ‘/’, only directories and subdirectories match. “ **zero** ” in this paragraph let me with the impression that `dir/file.ext` should have been included; unless I’m hopefully missing something.


Apply iptable to ongoing communication

I have 3 hosts running, all in the same network. Host A and C are continuously communicating and host B poisoned both host A and C ARP caches so the traffic goes through it. However, if I apply this `iptables -t nat -A PREROUTING -i eth1 -p tcp --dport <Port> -m state --state ESTABLISHED -j DNAT --to <host_B_IP>` I have to stop the communication in host A and then run it again for the iptable to have effect. I think the problem is that conntrack (which is required to track the state of the communication and allow the traversal through the firewall tables) is not working because it "didnt see" the initial 3-way-handshake that took place when host A fist connected to host C. Any way to make the iptable rule above work for the ongoing communication?


What other distributions provide the option to install inside Windows?

I mean installing with something like wubi? Can Fedora do this?


Left control key not working in virtualbox

I'm having an issue. I'm trying to install Gentoo in virtualbox. I can't use `nano` because when I press `Ctrl` + `x`, I see, I have written `x` letter. Something's wrong with `Ctrl` key in virtualbox. I've seen similar question, but the answer doesn't work to me. Any ideas?


Linux disk I/O performance issue -- what config options to look at?

We discovered an I/O related performance problem when using the default SLES11 SP2 kernel. Our same application on the same hardware had no issue with (the admittedly ancient SLES9 SP3). We had a feeling it has something to do with the kernel and have done the following experiment so far:   1. Downloaded and unpacked the kernel.org `3.0.13` source tree.   2. Installed Novell's `kernel-source-3.0.13-0.27.1` package. This is the `3.0.13` source with all of Novell's patches/tweaks already applied.   3. In the `3.0.13` tree did a `make x86_64_defconfig` to generate a default config file, then used `make menuconfig` to turn on the drive controller and network card drivers our hardware needed and built the kernel. This kernel had `no` performance problem.   4. In the `3.0.13-0.27.1` tree we got the config file that Novell ships with their compiled kernel, built with it, and had the same performance problem we had with the Novell-compiled kernel.   5. In the `3.0.13-0.27.1` tree, took the config file used in (3), built with it (accepting the additional config defaults that Novell's version of the configurator wanted to add). There was **no** performance problem.   6. In the `3.0.13` tree, took the config file used in (4), built with it (losing the Novell-only config options in the file). There was **no** performance problem.   7. In the `3.0.13-0.27.1` tree, took the config file used in (4), and made the device drivers (but nothing else) match the config file in (3) (i.e. turned off lots and lots of device drivers that weren't being used anyways). There was **no** performance problem. So the kernel.org `3.0.13` tree had no performance problem either way. Novell's `3.0.13-0.27.1` tree only had the problem when we built with Novell's config file or a file that was identical to Novell's but with most of the device drivers de-configured. Given that, it would seem to be that there's either some Novell-only config option (and implicitly the Novell code it activates) causing the problem, or some bad interaction between a Novell patch and some standard option (given that the as-close-as-possible-to-Novell's-config did **not** have the problem when built against the virgin kernel.org source). While we continue to investigate, since I am no kernel hacker (I know how to build the kernel but that's about it) I was wondering what "families" of config options would be the best ones to focus attention on. The idea would be to change some options from the "Novell" setting to the "kernel.org" setting and see if the problem goes away, then set them back and try another set, and so on. But I'd like to narrow that down -- hence the question about which config options would be good bets to play with first.


Highlighting text in bash when using reverse history search using Ctrl-R

Using `Ctrl-R`, I can search the history in bash. But what to do, If I want to highlight the relevant word which has been typed upon by me. Example:               (reverse-i-search)`mount': sudo mount /dev/sda2 /mnt      In the above reverse search, I want to highlight the world `mount` from the entire command `sudo mount /dev/sda2 /mnt`. How to achieve this in bash ?