How to count number of instance of a word starting at another word

I need to `grep` the MySQL-error log starting at today's date formatted like:               `date +"%y%m%d"` (140710)       And look for all instances of the word `partitioned`. I've tried various things to no avail. This seemed to work:               more +/"`date +"%y%m%d"`" mysql-error.log | grep -c partitioned      However, if the log file doesn't contain any entries from today, then instead of returning zero, it searches the entire file and returns a number for the entire file. I need it to return zero, if there are no entries from today, not `grep` the entire file and count the results. Is there some better way of doing this, using `sed` or `awk` or something? * * * Technically, what I suppose I need to count is `} partitioned {` followed by a string of alpha numberic characters, }) because portioned { (without any string) } could occur and shouldn't be counted. That's not a strict requirement though. I'd be happy just counting instances of the word `partitioned`. Here is an example of the log file:               140109 12:25:07 [Note] WSREP: view(view_id(PRIM,c4819ddf-7952-11e3-89fc-4f9f1bfa267f,3) memb {         c4819ddf-7952-11e3-89fc-4f9f1bfa267f,     } joined {     } left {     } partitioned {         f85c2e70-7952-11e3-a759-aa8332246e85,     })     140109 12:25:07 [Note] WSREP: Shifting JOINED -> SYNCED (TO: 85)


Apply recursive chmod to files or folders only

I'd like to apply chmods to files and folders in one line, Basically:               chmod 700 ./* -R # but only apply to folders     chmod 600 ./* -R # but only apply to files      Of course I searched google and read manpages. So the question is, does the following have any drawbacks, risks or is this safe?               find . -type f -print0 | xargs -0 chmod 600 && find . -type d -print0 | xargs -0 chmod 700


Any Linux Distros that may work well with intel 965gm gpu?

My mom's laptop had ubuntu 12.04 32bit and now 13.10. But they both are extremely slow. makes windows xp look super fast. (which was on it before) on askubuntu they said the gpu is the issue. Lenovo ThinkPad R61e: CPU - Pentium Dual Core t2370 1.73ghz x 2 Ram - 1GB DDR2 667mhz GPU - intel 965gm x86/mmx/sse2 HDD - 80gb sata


Why are these xrandr commands not working?

I wonder what I am doing wrong. It seems that the video card toggles it through the monitors and resolutions by itself so I want to eliminate the options and leave just the ones I use. As you can see, it hasn't worked.               rt@mach:~$ xrandr --rmmode HDMI1 1280x1024     usage: xrandr [options]       where options are:       -display <display> or -d <display>       -help       -o <normal,inverted,left,right,0,1,2,3>                 or --orientation <normal,inverted,left,right,0,1,2,3>       -q        or --query       -s <size>/<width>x<height> or --size <size>/<width>x<height>       -r <rate> or --rate <rate> or --refresh <rate>       -v        or --version       -x        (reflect in x)       -y        (reflect in y)       --screen <screen>       --verbose       --current       --dryrun       --nograb       --prop or --properties       --fb <width>x<height>       --fbmm <width>x<height>       --dpi <dpi>/<output>       --output <output>       --auto       --mode <mode>       --preferred       --pos <x>x<y>       --rate <rate> or --refresh <rate>       --reflect normal,x,y,xy       --rotate normal,inverted,left,right       --left-of <output>       --right-of <output>       --above <output>       --below <output>       --same-as <output>       --set <property> <value>       --scale <x>x<y>       --transform <a>,<b>,<c>,<d>,<e>,<f>,<g>,<h>,<i>       --off       --crtc <crtc>       --panning <w>x<h>[+<x>+<y>[/<track:w>x<h>+<x>+<y>[/<border:l>/<t>/<r>/<b>]]]       --gamma <r>:<g>:<b>       --primary       --noprimary       --newmode <name> <clock MHz>             <hdisp> <hsync-start> <hsync-end> <htotal>             <vdisp> <vsync-start> <vsync-end> <vtotal>             [+HSync] [-HSync] [+VSync] [-VSync]       --rmmode <name>       --addmode <output> <name>       --delmode <output> <name>      .               rt@mach:~$ xrandr --delmode HDMI1 1280x1024     X Error of failed request:  BadAccess (attempt to access private resource denied)       Major opcode of failed request:  150 (RANDR)       Minor opcode of failed request:  19 (RRDeleteOutputMode)       Serial number of failed request:  29       Current serial number in output stream:  30      .               root@mach:/home/rt# xrandr --delmode HDMI1 1280x1024     X Error of failed request:  BadAccess (attempt to access private resource denied)       Major opcode of failed request:  150 (RANDR)       Minor opcode of failed request:  19 (RRDeleteOutputMode)       Serial number of failed request:  29       Current serial number in output stream:  30      .               root@mach:/home/rt# xrandr --rmmode HDMI1 1280x1024     usage: xrandr [options]       where options are:       -display <display> or -d <display>       -help       -o <normal,inverted,left,right,0,1,2,3>                 or --orientation <normal,inverted,left,right,0,1,2,3>       -q        or --query       -s <size>/<width>x<height> or --size <size>/<width>x<height>       -r <rate> or --rate <rate> or --refresh <rate>       -v        or --version       -x        (reflect in x)       -y        (reflect in y)       --screen <screen>       --verbose       --current       --dryrun       --nograb       --prop or --properties       --fb <width>x<height>       --fbmm <width>x<height>       --dpi <dpi>/<output>       --output <output>       --auto       --mode <mode>       --preferred       --pos <x>x<y>       --rate <rate> or --refresh <rate>       --reflect normal,x,y,xy       --rotate normal,inverted,left,right       --left-of <output>       --right-of <output>       --above <output>       --below <output>       --same-as <output>       --set <property> <value>       --scale <x>x<y>       --transform <a>,<b>,<c>,<d>,<e>,<f>,<g>,<h>,<i>       --off       --crtc <crtc>       --panning <w>x<h>[+<x>+<y>[/<track:w>x<h>+<x>+<y>[/<border:l>/<t>/<r>/<b>]]]       --gamma <r>:<g>:<b>       --primary       --noprimary       --newmode <name> <clock MHz>             <hdisp> <hsync-start> <hsync-end> <htotal>             <vdisp> <vsync-start> <vsync-end> <vtotal>             [+HSync] [-HSync] [+VSync] [-VSync]       --rmmode <name>       --addmode <output> <name>       --delmode <output> <name>


How do I install directx on Debian?

How do I install directx on Debian-Gnome-Chromium? Is it possible to do it without wine?


Monitor via SSH and execute local script upon change detection

I have an environment where I can SSH into a Linux machine via Cygwin, but not the other way around due to a security policy out of my control. I need to automate tasks on the Windows machine but dictate these things to do from scripts or parameters PULL'd from the Linux machine (ie, a watched folder or web service). How can I structure this so that I can keep an SSH connection open and upon detecting this remote variable change, trigger another Cygwin command on the Windows machine? An example use case would be browser automation with parameters. While I could do this via a git repo and a recurring script that first syncs with latest code each time before running, I'd like to have more control, such as to force kill the executing thread via passing another variable or shell script down the line. **UPDATE:** After all that, there was another method to change the Windows firewall which allowed port 22 connections, so this complicated case will thankfully not be required, but I like the suggestions listed below. **UPDATE:** Seems the scenario still exists. Though getting direct access to the system via SSH allowed execution of tasks, these were sandboxed within the SSH user, not the network domain user that I wanted to run GUI tasks in (local Cygwin instance does not have the problems to execute within the domain user's GUI). See my answer below.


User systemd PulseAudio service

Not much else to this question: I would like to know what I need to create a PulseAudio systemd service to be run with `systemd --user`. I've tried a few different things, including various user services from Google, but I can't get it set up just right between dbus and everything else required for it. **Update:** It seems to work ok with graphical sessions, but I'm still having some inconsistancy with dbus when logging in through console. But PulseAudio is starting rather reliably, so I'm not overly concerned.


Bulk rename and resize with Imagemagick

I need to convert a very large number of images that are called 1a.jpg, 2a.jpg, 3a.jpg using Imagemagick to be processed and renamed 1.jpg, 2.jpg, 3.jpg (in the same directory). The Imagemagick command is this, where n is the 1, 2, 3... etc.               convert -shave 200x200 -resize 30% na.jpg n.jpg      Please help with a script.


Counting the numbers of lines of data as it comes in?

I am currently connected to the Twitter Stream, and I would like to count the number of lines of data as they come in. I know I can do `wc-l` to just count the lines, but I want it to be auto-updating. Kind of like how `tail -F` works, but instead, I want a running tally of how many records I've received. Is there a simple command to do this in UNIX?


typeset -A is giving error in script

I was using associative arrays in my script, hence I used to declare them by the `typeset -A <array_name>` command, and it worked fine in the bash prompt But when I use it in my script, I get the following error ` typeset: -A: invalid option typeset: usage: typeset [-afFirtx] [-p] name[=value] ...` An alternative solution will also be acceptable for me. SIDENOTE: I tried typeset -a but it declares an indexed array. But I want an associative array.


case + how to implement equal or less or greater in case syntax

My target is to verify a range of number with (only with `case` + `esac`), and print the range. So for example:   * If the number is between 0 and 80, print `>=0<=80`   * If the number is between 81 and 100 then print `>=81<=100`   * etc. The problem with my script below print only `>=0<=90` only if the number between 0 and 9. How to fix my script, so that it will print correct output according to the number range?               #!/bin/ksh     read number      case $number in       [0-80])  echo ">=0<=80";;       [81-100]) echo ">=81<=100";;       [101-120]) echo ">=101<=120";;      [121-300]) echo ">=121<=300";;     esac


x11grab from another display server

I have ffmpeg with x11grab on my local machine, but I want to capture the screen of an X server on 12.34.56.78. How can I do that? The following doesn't work:                ffmpeg -f x11grab -r 25 -s 800x600 -i 12.34.56.78:0.0 screen.avi


How can I add an additional framebuffer device in Linux?

I'm running a Ubuntu 12.04 LTS as a home NAS server, without X. Recently I got into tuning it to serve as a video playing media device too. It might've been easier at this point to install X, but I decided to try mplayer with framebuffer playback. It worked, and everything was fine and good. However, for curiosity and maybe for practical consequences too, I can't stop thinking about framebuffers. There seems to be only one framebuffer device, `/dev/fb0`. (Btw. I'm using vesafs driver) If I run multiple programs that use framebuffers, chaos ensues. For example, running mplayer from fbterm just crashes it. Curiously, fbi image viewer manages to view images somehow. Obviously the programs can't share the device, there's no windowing system after all. So, is the number of (vesa) fb devices limited to hardware display devices? Or could there be more in principle, like there are multiple ttys? Would adding some more help running simultaneously software that uses them? How could I add more? Also the logic how the framebuffers are connected to ttys isn't quite clear to me... for example, mplayer shows it's video frame on every tty, but fbi doesn't. Furthermore, Ubuntu default console (fbcon?) shows behind the video overlay, which srikes me odd. What is this all about?


Juniper SRX210, how to make DHCP to Static IP?

I am very new to Juniper device. I have a SRX210 router, and i am testing how to setup Static IP. So i did:               set interfaces ge-0/0/0 unit 0 description ISP Link     set interfaces ge-0/0/0 unit 0 family inet address 6x.24x.14x.5x/28      Will this work? (i have no idea, but crossed my finger and hope it works)


How to make front audio jack work again after waking up from suspend?

Sometimes, after I wake up from suspend (using pm-suspend), the front audio jack stops working (no sound) after I wake up my laptop. Only after a full reboot I get it to work again. My laptop is an HP dv6-2030sd and has an Intel sound card. The module loaded is snd_hda_intel, but removing it and adding it again has no effect. I use the ALSA sound system only, so no pulseaudio. My question is, is there a way to get it to work again without a full reboot?


What is the need for rsync server in daemon mode

I don't understand the need for an rsync server in daemon mode. What are the benefits from it if I can use rsync with SSH or telnet?


HTTPS Authentication problem : Polipo

I use internet behind http proxy, and that requires authentication. I tried using polipo to bypass the authenticated proxy to 127.0.0.1:9134. Applying these settings to my browser, works fine for http://examplewebsite.com but for https://examplewebsite.com, it asks for authentication. Also my host proxy authentication does not work in the authentication dialog. Settings I have changed in my `/etc/polipo/config`               proxyPort=9134          parentProxy = "172.31.1.10:8080"          parentAuthCredentials = "username:mypassword"


How do I enable locate and queue the database to be built?

On a new Ubuntu 10.4 instance, I tried to use the `locate` command only to receive the error               locate: can not stat () `/var/lib/mlocate/mlocate.db': No such file or directory      from using this command on other systems I'm guessing that this means the database has not yet been built (it is a fresh install). I believe it is supposed to run daily, but how would I queue it up to run immediately? Also, how is "run daily" determined? If I have a box that I only turn on for an hour at a time will the database ever be built on it's own?


Set executable heap

The `execstack` program can be used to mark ELF-binaries as needing an executable stack. Is there a similar way to mark the heap as executable? Preferably for a single binary but if that's not possible, a system-wide solution would be useful too.


What does this ${@:2} mean in shell scripting

I see this in a shell script.               variable=${@:2}      What is it doing?


How does handling an interrupt affects a multi-threaded user space process?

Say, I put a breakpoint (`int 3` from now on) somewhere in a user space process code. One of the threads hits the breakpoint... And what happens next? My judgement is: this is an interrupt, so it is handled in the kernel. I don't really care about the signals and interrupt handlers and stuff, I just want to know what happens to the other threads of the user space process. Are they stalled until the interrupt handler is executed? How are they scheduled after the interrupt is handled? References on the subject would also be highly appreciated.


kernel: "echo 0 > /proc/sys/kernel/hung_task_timeout_secs"

I got this errors in syslog. Any idea what does it mean? The system is running on Ubuntu 12.04, kernel: `3.8.0-35-generic #52~precise1` It looks to me like failure when trying to write to disk...                [151850.317166] "echo 0 > /proc/sys/kernel/hung_task_timeout_secs" disables this message.      [151850.318428]  ffff8803640f5be8 0000000000000082 0000000034c733da ffff88040e233ec0      [151850.318444]  ffff880408149740 ffff880403c6c5c0 0000000000000001 ffff8803edae80a8      [151850.318468]  [<ffffffff816f41c9>] schedule+0x29/0x70      [151850.318481]  [<ffffffff816f30b7>] __mutex_lock_slowpath+0xd7/0x150      [151850.318497]  [<ffffffff816f2cca>] mutex_lock+0x2a/0x50      [151850.318510]  [<ffffffff811aa006>] path_lookupat+0x236/0x7a0      [151850.318523]  [<ffffffff811aade0>] ? getname_flags.part.31+0x30/0x150      [151850.318537]  [<ffffffff811aaf6e>] ? getname_flags+0x6e/0x80      [151850.318552]  [<ffffffff813141f4>] ? apparmor_inode_getattr+0x54/0x60      [151850.318565]  [<ffffffff811bb929>] ? mntput_no_expire+0x49/0x160      [151850.318578]  [<ffffffff811ab711>] user_path_at+0x11/0x20      [151850.318588]  [<ffffffff811a0c3e>] vfs_lstat+0x1e/0x20      [151850.318602]  [<ffffffff816fdf5d>] system_call_fastpath+0x1a/0x1f      [151850.319634] "echo 0 > /proc/sys/kernel/hung_task_timeout_secs" disables this message.      [151850.376552]  [<ffffffff816f41c9>] schedule+0x29/0x70      [151850.376565]  [<ffffffff816f30b7>] __mutex_lock_slowpath+0xd7/0x150      [151850.376579]  [<ffffffff816f2cca>] mutex_lock+0x2a/0x50      [151850.376590]  [<ffffffff811aa006>] path_lookupat+0x236/0x7a0      [151850.376602]  [<ffffffff811aade0>] ? getname_flags.part.31+0x30/0x150      [151850.376616]  [<ffffffff811aaf6e>] ? getname_flags+0x6e/0x80      [151850.376680]  [<ffffffff813141f4>] ? apparmor_inode_getattr+0x54/0x60      [151850.376691]  [<ffffffff811bb929>] ? mntput_no_expire+0x49/0x160      [151850.376704]  [<ffffffff811ab711>] user_path_at+0x11/0x20      [151850.406554] "echo 0 > /proc/sys/kernel/hung_task_timeout_secs" disables this message.      [151850.465132] sftp-server     D ffff880403bfdf60     0 15199      1 0x00000000      [151850.465158]  ffff8803d2c87fd8 ffff8803d2c87fd8 ffff8803d2c87fd8 0000000000013ec0      [151850.465173]  ffffffff81c15440 ffff88040583ae80 0000000000000001 ffff8803edae80a8      [151850.465263]  [<ffffffff811aa006>] path_lookupat+0x236/0x7a0      [151850.465269]  [<ffffffff81186441>] ? kmem_cache_alloc+0x31/0x140      [151850.465275]  [<ffffffff811aade0>] ? getname_flags.part.31+0x30/0x150      [151850.465283]  [<ffffffff811aa5a4>] filename_lookup+0x34/0xc0      [151850.465289]  [<ffffffff811aaf6e>] ? getname_flags+0x6e/0x80      [151850.465296]  [<ffffffff811ab6b9>] user_path_at_empty+0x59/0xa0      [151850.465303]  [<ffffffff813141f4>] ? apparmor_inode_getattr+0x54/0x60      [151850.465309]  [<ffffffff81087e9a>] ? lg_local_unlock+0x1a/0x20      [151850.465315]  [<ffffffff811bb929>] ? mntput_no_expire+0x49/0x160      [151850.465320]  [<ffffffff811a0946>] ? cp_new_stat+0x116/0x130      [151850.465327]  [<ffffffff811ab711>] user_path_at+0x11/0x20      [151850.465332]  [<ffffffff811a0bc1>] vfs_fstatat+0x51/0xb0      [151850.465337]  [<ffffffff811a0c3e>] vfs_lstat+0x1e/0x20      [151850.465343]  [<ffffffff811a0dea>] sys_newlstat+0x1a/0x40      [151850.465350]  [<ffffffff816fdf5d>] system_call_fastpath+0x1a/0x1f


Provide loop device functionality for a regular file under a unique name

I want to add a few image files with file systems to a LVM volume group. If I make them available as loop devices changes are pretty high that one day the script gets corrupted due to an increasing number of used loop devices. Rather than increasing my number of loop devices, I'd like to make the file available with loop device functionality (like I would have set it up with `losetup`) under a unique name, like `/dev/program/my_unique_name`, so that `mount -t atype /dev/program/my_unique_name /path/to/mount_point` would do the same like `mount -t atype /dev/loopX /path/to/mount_point`. Background: I tried to acchieve the thing I want by increasing the number of loop devices to `X` and started to assgn `/dev/loopX`, `/dev/loopX-1`, etc. which looks promising as long as   * less than `X - number of images I want to use` loop devices are used on the system[1]   * kernel performance doesn't suffer from an increased number of loop devices   * no one needs similar functionality and start to assign loop devices starting with the highest number -> this complicates the script code, increases test necessity and decreases maintainability It would be no problem to use variable loop devices, i.e. simply query the next free block device with `losetup -f`, assign the file and make it available under a unique name. * * * [1] probability to exceed X is low, so it's more a question of elegance to provide a resource under a unique name rather than under a number in inverval [0;X]


What makes the files in my home directory appear, when I log in through SSH then run ecryptfs-mount-private?

I'm a bit of a newbie when it comes to using Linux. I've recently installed Ubuntu 12.04 LTS (minimal virtual machine) on a VPS host. I've encrypted the virtual disk and encrypted the home directory of my main user account, that I'm using to access the install through SSH (using public key authentication). So far, so good. The thing is: I can't figure out what exact action it is that is making my hidden files appear and active (such that I am able to use aliases, such as `ll`). When I sign in initially with SSH and issue `ls -al`, all I see is:               dr-x------ 2 username username 4096 Feb 10 01:10 .     drwxr-xr-x 4 root     root     4096 Feb 10 01:10 ..     lrwxrwxrwx 1 username username   56 Feb 10 01:10 Access-Your-Private-Data.desktop -> /usr/share/ecryptfs-utils/ecryptfs-mount-private.desktop     lrwxrwxrwx 1 username username   34 Feb 10 01:10 .ecryptfs -> /home/.ecryptfs/username/.ecryptfs     lrwxrwxrwx 1 username username   33 Feb 10 01:10 .Private -> /home/.ecryptfs/username/.Private     lrwxrwxrwx 1 username username   52 Feb 10 01:10 README.txt -> /usr/share/ecryptfs-utils/ecryptfs-mount-private.txt      (As an en passant: why are permissions set to `lrwxrwxrwx` for most items here? Isn't that far too tolerant?) Then, when I issue `ecryptfs-mount-private` (as per the `README.txt`) and issue another `ls -al`, I keep seeing the same as above. One time, I believed I was able to use aliases after I issued a `sudo` command, but another time I was not able to. Then, another time I issued `cd /home/username` (which is the same directory as `~` already, is it not?), and all of a sudden all other hidden files appeared and I was able to use aliases. But now, after a few minutes in (but perhaps I've actually imagined this), even though I'm still able to see all the hidden files, I'm not able to use aliases anymore. This makes me believe this behavior is somehow coupled with `sudo`, but I can't seem to figure out what exactly is going on here. Can somebody enlighten me and explain what exact actions I need to undertake to see all hidden files in my home directory and enable aliases, and why this is (is it because of the encryption; is it coupled with `sudo`; or perhaps something completely different)? If possible, preferably, I'd like this to automatically be enabled when I login with SSH. Is that possible? **edit** (clarification for Hauke Laging's comment): When I log in with SSH and immediately issue `ll` in `~`, I get `-bash: ll: command not found`. (Although now, it appears to work immediately after I logged out and logged in again, but perhaps this is because the other time it was the first time after boot up? I have no idea, really. It all appears to behave rather random.) Then, one time, I believe I issued a `sudo ls -al`, or some other inane command, after which `ll` appeared to work. Another time `ll` didn't work, and only after I issued `ecryptfs-mount- private` and did an explicit `cd /home/username`, the hidden `.bashrc` (etc.) files appeared with `ls -al`, after which I was finally able to use an alias such as `ll`. But, you know what? I think I'll have to investigate this a bit more thoroughly, since my vague descriptions are probably getting us nowhere. I was hoping my problem would immediately ring a bell, but it appears I have to be a bit more precise about what actions I undertook. What I am trying to accomplish though, is this: When I log in through SSH (whether it be the first time after boot up, or any other time after that), I want all hidden files, in my home directory, to appear immediately when I issue `ls -al` and that aliases, such as `ll`, are immediately available as well. My analysis of the problem, thus far, is that it appears that I first have to decrypt my home dir, before I am able to see the mentioned hidden files (apart from the ecryptfs-related symbolic links) and use aliases. Is that a correct assessment?


What happened with my SHLVL?

I was messing around with my bashrc, finding better ways to start a newer version of `bash`. Never mind my tests. But this strange thing happened, which I like to understand:               $ bash  ## Probably where the infinite recursion happened             ## terminated by too many access to .bashrc and derived files     $ echo $BASH_VERSION      4.2.0(1)-release     $ echo $SHLVL      362     $ exit     $ echo $SHLVL      2      I think a end up with a infinite recursion (that is already fixed), but how can the shell level go from 362 to 2 with a single `Ctrl`+`D` (produces the `exit`)?


How to rename files and directory with *.~1~ suffix to original name?

I have a directory named `underscore.~1~` and several files inside with names like `main.js.~1~`, `index.js.~1~` etc. How can I rename the directory `underscore` and the files inside to the original names `main.js`, `index.js` etc.


zsh alias being overridden somehow

I'm on a system running OS X 10.8.5. I recently tried to alias `ls` to `ls -G -la` command. I opened up `~/.zshrc`, put in the alias, relaunched the terminal, but the change didn't take effect. Upon performing `which ls`, I found out that it's _already_ being aliased to `ls -G`. This isn't behaviour I ever set up. Is there any way to find out where this alias is being set?


Set ulimit to defaults

I set ulimits to fullfill memory demands of Git. Do we have anyway to reset ulimits to defaults, I mean what they were before I set them. Please keep in mind I am doing it from Python script


List of special characters in the shell

I am not sure what they are called, but where could I find a list of wild cards? I see things like:   * `$f`   * `%s`   * `$1` Is there a definitive list for what each one represents?


Reverse socks5 using SSH

Setup:   * Server is a virtual machine   * Server have a local ip adress   * Server is restricted so that it can't reach the internet (not sure how)   * Client machine have access to both server via SSH    * Client have unrestricted access to the internet   * I have root on both server and client (running Arch Linux on client and Gentoo on server)   * Server can't access the client All of this is probably due to heavily locked down firewalls. Problem: I need to be able to fetch packages and source code from the internet. Is it possible to set up the client so that it can proxy internet bound traffic for the server during updates?


Scoping variables in ksh

In ksh, I have two variables with the same name , one global , other one is local to a function               #!/bin/ksh          LOG_FILE=lf          function exec_script     {        local LOG_FILE=f        print $LOG_FILE     }     exec_script     print $LOG_FILE      If I want to refer the global variable $LOG_FILE within exec_script function, how should I qualify it so that the local does not get referenced ?


How to check if ARP is enabled or not

I have enabled the arp support on my dell based server running linux on it. I wanted to check that if arptables are enabled or not. Could anyone tell me how do I check the same? Is it enough to run `arp` command here?


ssh targetHost &; fg - does not work, but why?

I was trying the following combination in order to get the pid of the ssh session (running in the background displays the pid) and than fg to get back to the ssh session and introduce the password:               ssh targetHost &; fg      I get the following error:               -bash: syntax error near unexpected token `;'      Why does the ";" not work to as expected in this case? My aim is to start a ssh session and know its pid and I need to do this in as few lines as possible. I need to start several ssh sessions, put them in the background and at the end kill them - that's why I need the pids.


why the size of disk image decreased after mkfs.ext2

first, i create a disk image use `dd`:               > dd if=/dev/zero of=disk bs=512 count=2097152     > du -h disk          1.1G   disk      second, `fdisk disk` create a partion:               Command (m for help): p     Disk disk: 1 GiB, 1073741824 bytes, 2097152 sectors     Units: sectors of 1 * 512 = 512 bytes     Sector size (logical/physical): 512 bytes / 512 bytes     I/O size (minimum/optimal): 512 bytes / 512 bytes     Disklabel type: dos     Disk identifier: 0x40c73f2f          Device Boot Start       End  Blocks  Id System     disk1        2048   2097151 1047552  83 Linux      blocks column: 1047552, so sectors is : 1024(can fdisk set sector size?). third, `losetup`:                losetup /dev/loop0 -o 2097152 --sizelimit=1072693248 disk      2048*1024 = 2097152 1047552*1024 = 1072693248. at this time the size of disk is 1G:               > du -h disk       1.1G  disk      forth, `mkfs.ext2`:               > mkfs.ext2 /dev/loop0         mke2fs 1.42.8 (20-Jun-2013)         Discarding device blocks: done                                     Filesystem label=         OS type: Linux         Block size=4096 (log=2)         Fragment size=4096 (log=2)         Stride=0 blocks, Stripe width=0 blocks         65408 inodes, 261632 blocks         13081 blocks (5.00%) reserved for the super user         First data block=0         Maximum filesystem blocks=268435456         8 block groups         32768 blocks per group, 32768 fragments per group         8176 inodes per group         Superblock backups stored on blocks:              32768, 98304, 163840, 229376              Allocating group tables: done                                     Writing inode tables: done                                     Writing superblocks and filesystem accounting information: done      and disk image size is decreased:               > du -h disk         19M disk      You know filesystem block size is 4096, and have 8 block groups, 32768 blocks per group. 4096 * 8 * 32768 = 1G.


Server running but not serving

I have a simple python flask server that is started by start-stop-daemon. It was running well last week, and this monday I see that it is not serving anymore (`curl http://localhost/mypage` takes forever and never returns). Last log is from friday. The strange thing is that `sudo service myService status` is "running" and I see that the process is indeed running (`ps aux | grep $(cat /var/run/myservice.pid)`) Is there a way to know what could have happened? I have no idea where to go next from here.


Battery meter only appears when laptop gets plugged in

The battery meter refuses to show unless I plug the laptop in. If I remove the applet and then re-add it it still won't show. I am using Mint 17 and here is the screen shot of my Power settings and I don't have any battery status option in it: ![enter image description here](http://i.stack.imgur.com/5Tltu.png) Any Ideas?


Stop cron script from destroying my mirrorlist with invalid data

I have to following **cron** script that runs daily. As you should be able to see from the code, it outputs the results from `reflector` to `/etc/pacman.d/mirrorlist`.               $ cat /etc/cron.daily/update-mirrorlist     #!/bin/bash          reflector -l 5 -r -o /etc/pacman.d/mirrorlist      Sometimes, `reflector` outputs a empty file and thus a invalid _mirrorlist_ is created. How can I modify the script above to only write to `/etc/pacman.d/mirrorlist` **IF** there is valid output from `relfector`?


How to change the name of a vim buffer

Is it possible to change the name of a buffer in vim? Specifically, I'm using Conque Shell to open shells in vim (each shell is in a buffer) and with multiple shells, I see:               10: bash - 1     11: bash - 2      in my buffer list. I would like to rename these buffers with more meaningful names (e.g., "mercurial" instead of "bash - 2"). Is it possible?


How can I have activity in a Dropbox folder logged?

I have a folder shared with others through Dropbox. When a file is added to this folder, I get a system tray notification in KDE --- but of course if I'm not at my computer, I wouldn't see the notification. Is there a way to automatically log any changes within a folder (especially file creation), and/or automatically run a bash script to, say, send an email to myself as a more durable "alert"? A google search turned up incron ... It sounds about right. Has anyone used this software?


Home folder unintentionally exposed while using samba shares

**Problem** I have some difficulties with sharing folders in a **local area network** by using **samba**. I have managed everything up to the point that every folder that I share is being detected, can be read and can be written to. My problem however is, that next to the folders that I have explicitly shared, also my `/home/carlos` folder can be accessed. So basically **all my data is exposed unintentionally**. Currently I have my firewall blocking samba, so nothing is exposed at the moment, however I want to use samba though. I would like some assistance in correctly configuring samba. **What have I done so far** Copied default configuration file:               cp /etc/samba/smb.conf.default /etc/samba/smb.conf      Changed workgroup from MYGROUP into Baptista and add these lines to the `[global]` section in `/etc/samba/smb.conf`:               usershare allow guests = Yes     usershare max shares = 100     usershare owner only = False      Changed `[homes]` section configuration to read               [homes]         comment = Home Directories         browseable = No         writable = No      Run these commands in a terminal:               # mkdir /var/lib/samba/usershares     # chgrp users /var/lib/samba/usershares/     # chmod 1775 /var/lib/samba/usershares/     # chmod +t /var/lib/samba/usershares/      (these commands and several settings were taken from section 1.7 of https://wiki.archlinux.org/index.php/Samba/Troubleshooting) Share a folder by launching Dolphin, right-click a folder, select properties, select the share tab, configure settings and press OK. **Question** Let assume I shared the folder `/home/carlos/Music`, then not only is `/home/carlos/Music` available through samba, my entire `/home/carlos` is available. How can I fix this, such that **only** the folders than I **explicitly** share, are shared? **System information**   * Chakra Linux, 64-bit   * Linux kernel 3.12.6-1   * KDE 4.12.0   * Qt 4.8.5   * Samba 4.1.1-1   * Two laptops, same OS, same username


How can I record the sound output with gtk-recordmydesktop?

I am using gtk-recordmydesktop to record the video output to my desktop. However, the videos have no sound. All the tutorials I found regarding this involved getting sound recorded from a microphone, while I am interested in getting the sound output recorded. How can I do this? The official FAQ says "The solution is in your mixer's settings. Keep playing with it ;)." which doesn't clarify anything. How can I get the sound output recorded, while being able to hear it myself also?


how to get IP from DHCP in network in redhat which is installed on VMware

I'm running Red Hat inside a VMware image (on a Windows XP machine). I want to connect the Red Hat VM to our network; do I need to configure something inside VMware or inside Red Hat? I don't have any IPs set to connect to the internet


Problematic build script with quotes

Hi I'm trying to create a build script that executes these commands:               cd libiconv     ../../src/libiconv/configure --prefix=/home/ruben/mingw64/build/gcc-libs \                                  --host=x86_64-w64-mingw32 --build=x86_64-w64-mingw32 \                                  CFLAGS="-mtune=core2 -flto -fomit-frame-pointer -momit-leaf-frame-pointer" LFLAGS="-flto -fwhopr=2"     make -j3 -s     make -s install     cd ..      It looks like this:               #!/bin/sh     HOST=x86_64-w64-mingw32     TARGET=x86_64-w64-mingw32     BUILD=x86_64-w64_mingw32     # options     BUILD_CORES=2 #used as argument for "make -j#"     # directories: SRC_DIR contains full source package.     GCC_LIBS_DIR=$BUILD_DIR/gcc-libs          # optimized for my system.     BUILD_CFLAGS="\"-mtune=core2 -flto -fomit-frame-pointer -momit-leaf-frame-pointer\""     BUILD_LFLAGS="\"-flto -fwhopr="${BUILD_CORES}"\""     CONFIG_OPTS="--prefix="${PREFIX}" --host="${HOST}" --build="${BUILD}" CFLAGS="${BUILD_CFLAGS}" LFLAGS="${BUILD_LFLAGS}       makeopts="-s -j"${BUILD_CORES}          # libiconv     cd libiconv     echo "configuring libiconv: "${CONFIG_OPTS}     ../../src/libiconv/configure "${CONFIG_OPTS}" > configure.log || exit 1     echo "building libiconv"     make $MAKEOPTS > build.log || exit 1     echo "installing libiconv"     make -s install > install.log || exit 1     cd ..      The thing is, the echo command shows the exact configure command I want, but when running configure it doesn't so the right thing. Something goes terribly wrong, after `CFLAGS=-mtunecore2`, when configure tries to use -flto (which is quoted!!) as an argument. What am I doing wrong? Thanks! PS: I'm running MSYS, not _real_ *nix...


Mono book recommendations

Does anyone know if there are any upcoming book releases for Mono/GTK#? The only book I could find on Amazon with a decent rating is over 6 years old.


What is the reconnection policy of "persist" switch on "pon" command from pptp-linux package?

I use to establish a connection to my VPN PPTP server by typing:               pon MyVPN persist      I wanna know the reconnection timing details, but I have not found documentation enough about it. Specifically:   - If there is a disconnection, does the PPTP client attemps to reconnect immediately?   - What is the frequency of reconnection attemps (5 mins, 15 mins, variable... etc)?   - The client stop trying to reconnect after some too long period (give-up time) without succeeding (6 hours, 1 day... etc)?


How to make vertical bar | work in grep?

Here's an example of a grep command line I've tried:               grep '(565172|565173|565175)' /var/log/cups/error_log      It doesn't produce any output, even though all 3 values are in the file multiple times. I tried escaping the bars, and that improved things somewhat - the middle value was detected but not the first or last.               grep '(565172\|565173\|565175)' /var/log/cups/error_log      I also tried double escapes and went back to getting no results.               grep '(565172\\|565173\\|565175)' /var/log/cups/error_log      What am I doing wrong? Thanks.


How to combine dmix with ladspa plugins to default device

A while I have abandoned all sound daemons and lived happily ever since with just the dmix plugin. However, recently I got annoyed by the different volume levels of youtube videos and decided to plug in a compressor and a limiter. IMHO this is an extremely desirable setup. But alas, I had no luck. I got playback to work or capture, but never both. I suppose the underlying problem is my lack of understanding, so my fundamental questions are:   * Where can I find a good documentation of alsa and .asoundrc, which goes beyond mere examples and which would e.g. explain the error messages (see below) I got.   * Has anyobody succeeded in a daemonless sound setup which included ladspa plugins?   * Does anybody know the reasons, or even a solution for my particular problems (described below)? * * * For those of you who have the patience to follow my woes here they are. I got as far as being able to play sound like this               aplay -D ladspaChain /usr/share/skype/sounds/CallBusy.wav      but I cannot play via the default device.                pcm.!default {         type plug         slave.pcm {         type asym         playback.pcm "ladspaChain"         capture.pcm "dsnooper"        }     }      Without -D ladspaChain, I get               aplay: pcm_params.c:170: snd1_pcm_hw_param_get_min: Assertion `!snd_interval_empty(i)' failed.**      Alternatively I tried                pcm.!default {         type route         slave.pcm {         type asym         playback.pcm "ladspaChain"         capture.pcm "dsnooper"        }         ttable {             0.0     1       # left channel             1.1     1       # right channel         }      }       In this case playback works, but arecord gives me               arecord: set_params:1081: Sample format non available     Available formats:     - S32_LE


Error running Virtual Box on Arch Linux

I installed Virtual Box regularly on Arch Linux using pacman:               pacman -S virtualbox      When i run `virtualbox` from the terminal, the GUI of the program is loaded but I can't use a virtual machine and I get this warning:               The vboxdrv kernel module is not loaded. Either there is no module              available for the current kernel (3.12.5-1-ARCH) or it failed to              load. Please reinstall the kernel module virtualbox-host-modules or              if you don't use our stock kernel compile the modules with                     sudo dkms autoinstall      How to solve the problem?


du gives two different results for the same file

I am a graduate student of computational chemistry with access to a Linux cluster. The cluster consists of a very large (25 TB) fileserver, to which several dozen compute nodes are connected. Each compute node consists of 8 to 24 Intel Xeon cores. Each compute node also contains a local disk of about 365 TB. Since the fileserver is routinely accessed by a dozen or so users in the research group, the fileserver is mainly used for long term file storage (it is backed up nightly, whereas the compute nodes' local disks are never backed up). Thus, the system administrator has instructed us to run simulations on the local disks -- which have faster I/O than the fileserver -- so as to not slow down the fileserver for the other users. So, I run simulations on the local disks and then, after they are finished, I copy the trajectory files -- I am running molecular dynamics (MD) simulations -- to the fileserver for storage. Suppose I have a trajectory file called `traj.trr` in a directory on the local disk of a node, `/home/myusername/mysimulation1/traj.trr`. For long term storage, I always copy `traj.trr` to a directory in the fileserver, `~/mysimulation1/traj.trr`, where `~` represents my directory in the fileserver, `/export/home/myusername`. After copying it, then I habitually use `du -h` to verify that `/home/myusername/mysimulation1/traj.trr` has the same file size as `~/mysimulation1/traj.trr`. This way, I can be at least reasonably sure that the transfer to the fileserver was successful. For example:               cd /home/myusername/mysimulation1/     cp -v traj.trr ~/mysimulation1/     du /home/myusername/mysimulation1/traj.trr -h     du ~/mysimulation1/traj.trr -h      If the two calls to `du -h` give the same human-readable file size, then I can be reasonably sure that the transfer/copy was successful. (My typical `traj.trr` files range in size from about 15 to 20 GB, depending on the exact simulation I have run.) If I run `du` (i.e., without the `-h` switch) on the two `traj.trr` files, their sizes in bytes are usually very, very similar -- usually within just a few bytes. I have been using this overall method for the past year and a half, with no problems. _**However,_** recently I have run into the following problem: sometimes `du -h` reports that the two `traj.trr` files are different in size by several GB. Here is an example:               cd /home/myusername/mysimulation1/            # this is the local disk     cp -v traj.trr ~/mysimulation1/     du traj.trr -h     cd ~/mysimulation1/                           # this is the fileserver     du traj.trr -h      The output from the two calls to `du -h` is as follows, respectively:               20G     traj.trr     28G     traj.trr      I believe that the former (i.e., the `traj.trr` in the local disk, `/home/myusername/mysimulation1/`) is the correct file size, since my simulation trajectories are expected to be about 15 to 20 GB each. But then how could the file on the fileserver actually be _larger_? I could see how it could be smaller, if somehow the `cp` transfer failed. But I don't see how it could actually be _larger_. I get similar output when I execute the same commands as above, but without the `-h` switch given to `du`:               20717480        traj.trr     28666688        traj.trr      Can you think of any reason for the difference? If, by some unlikely chance, `du` is somehow malfunctioning, I can be okay with that. But I just really need to make sure that the copy of `traj.trr` on the fileserver is complete and identical to its source version on the local disk. I need to delete the local file so that I have enough local disk space to run new simulations, but I can't afford to have the version of `traj.trr` on the fileserver be corrupted. The .trr file format (from the Gromacs molecular dynamics package) is a binary format, not text. Thus, I am not sure if the files can be reliably compared by a program such as `diff`.


Unable to change backlight level

In Manjaro I can't set the backlight. I've tried to add: `acpi_osi=Linux acpi_backlight=vendor` to the kernel's command line but it didn't work. And I also added `Option "RegistryDwords" "EnableBrightnessControl=1"` to the `xorg.conf`, but it didn't work. Why?


Why Would Spacing Matter in grub.conf?

See my earlier question. GRUB wouldn't recognize the XEN kernel until extra blank lines were added and the title of the GRUB entry matched the version of XEN installed on the server. I've always considered the `title` line to represent a label for the entry, and I never would have thought spacing would have mattered. Is there a code style guideline/wiki for GRUB with CentOS to avoid these types of issues in the future?


Default stack size for pthreads

As I understand the default stack size for a pthread on linux is 16K. I am getting strange sesults on my 64bit ubuntu install.               $ ulimit -s     8192      Also               pthread_attr_init(&attr);     pthread_attr_getstacksize(&attr, &stacksize);     printf("Thread stack size = %d bytes \n", stacksize);          Prints         Thread stack size = 8388608 bytes      I am quiet sure the stack size if not "8388608". What could be wrong ?


Remove rows from tab delimited files based on a common column with another file

I am having trouble processing a tab delimited file based on the common column `Column_4` with another file. One file is likely to be very small (less than 100 rows), the second one, however, will be well over 80,000 (both with approximately 30 columns). `file1.txt`:               Column_1    Column_2    Column_3    Column_4     A1          B1          C1          D1     A2          B2          C2          D2     A3          B3          C3          D3      `file2.txt`:               Column_1    Column_2    Column_3    Column_4     Aa1          Bb1          Cc1          Dd1     Aa2          Bb2          Cc2          D2     Aa3          Bb3          Cc3          Dd3      `desired_output.txt`:               Column_1    Column_2    Column_3    Column_4     Aa2          Bb2         Cc2          D2      I've tried a series of `cut`, `grep`, `awk`, etc., but can't seem to get it right. The ultimate goal is to remove all the non-matching rows from `file2.txt`, then compare the output to `file1.txt`.


Custom hotkeys in dwm

I'm trying to create an array of simple hotkeys on my desktop, running OpenSuse with dwm. Things like:               Ctrl+E    /opt/eclipse/eclipse      Can this be configured from within dwm? If not is there an external application which I can run (in the background) to listen for these hotkeys. Also, is it possible for the hotkeys to only work when I an **not** hovering over a window (so that the windows doesn't grab my input by accident)?


Reinstalling Linux with backup

I'm using Linux (Ubuntu 10.04) for more than a year and I feel often that I need to reinstall it to newest version. I'd like to take most of my configurations and important settings to the new system. I already have in mind some files and directories that I certainly want to backup, but I'm afraid I will forget something. Is there some checklist or guideline (or even software) I can use to help me with backuping the important things? I don't want to backup whole partition (it's not so critical) How do you cleanly update to newer version? thank you


kde install destroys gnome desktop

I recently installed KDE 4.7 on my wife's computer. I did not use the recommended Debian 'install task' method, which emulates the full install- from-.iso process. Instead I just did:               # apt-get install kde-plasma-workspace plasma*      She uses GNOME, and wanted KDE because apparently you can take advantage of some additional features in kdenlive when you are running it from KDE. And so I opted to keep both WMs going. Unfortunately, I was not prepared for the consequences of installing two WMs on the same machine. In this case, installing KDE rendered the GNOME _desktop_ non-functional, though not GNOME itself, as in this question: Debian GNOME 2.30, desktop does not respond anymore. Dolphin also made itself the default file manager in GNOME (gdm3), which was a headache. I removed Dolphin, and I have basically removed KDE, but it has not fixed anything of course.


Moving from Ubuntu 32bit: Mint 64bit or Mint 32bit?

I have decided to try out Linux Mint instead of the horrible Ubuntu Unity experince. I have a separate partition for my `/home` folder, which I'd like to preserve of course. So I'm curious: is it possible for me to install the 64bit version of Mint without user dotfiles making trouble? More specifically, will it matter that the new OS is 64-bit? My instinct tells me - no, a config file is a config file, but I thought it would be better to check here, I simply don't want to lose all the app settings. A more general question would be, will the user dotfiles cause any problem for Mint, regardless of _bit-ness_? Has this been tried by someone?


Modify list of devices mounted at boot on Linux

Where do you configure or what command do I use to mount device at boot? Is it in the file /etc/fstab ?


Gedit: syntax highlighting of echoing self-closing XHTML tags in JavaScript in PHP

Reproduction:   * In Gedit, open a new file and manually select the syntax highlighting language (at the bottom right) to `PHP`.   * Write some javascript in `<script>` tags   * Within the `<script>` tags, echo some XHTML with self-closing tags   * Note that all of the code that follows is no longer syntax highlighted Alternatively, paste this in:               <?php         echo 'hello - this is still syntax highlighted! ';     ?>                    <?php         echo 'syntax highlighting returns after the closing </script> tag';     ?>      It's not a big deal, since I can work around it right now by replacing all self-closing tags with their HTML 4 equivalents (e.g. `<input></input>`), but I was wondering if anybody else dealt with this problem...


Backintime Linux desktop backup to a Synology DiskStation

Backintime doesn't support plain SFTP backends so it does not seem to be easy to setup a remote backup to a Synology Diskstation (in my case a DS214 with DSM 4.3). Backintime supports SSH/rsync based remote backup but the Synology doesn't seem to allow automated SSH logins with trusted entries. What is the best way to backup to a Synology NAS backend with Backintime? So far, I could only manage a backup with mounting the Windows share to the workstation (with CIFS) and configuring Backintime as a local sync to the mounted folder. This works but I would like a solution which doesn't include Samba & Windows shares.


Windows / Unix Share

I have a NFS + SMB share on my Win server called 'media' (same path).   Both shares are read-only for guests - the Win server add files and both protcols can read them. _Now things getting more complex_ I want to use my CentOS(6.5) server to add files to the NFS share and access them via NFS _and_ SMB from Win clients. But here comes the problem that files added via NFS are not visible via SMB because they don't inherit permissions from the share. I tried the whole day a bunch of different things, I always get weird problems. ### My question Is there a well working solution or should I do not mix win/nix shares together? ### UPDATE #1 The `-nolock` parameter within `mount` seems to help. But this question isn't answered. ### UPDATE #2 @skohrs   After your _update_ **The visibility from my windows client**               create file in unix machine:            SMB hidden  NFS visible       create file in SMB from win client:     SMB visible NFS visible       create file in NFS from win client:     SMB hidden  NFS visible       create file in 'media' from win server: SMB hidden  NFS visible          # Solution The way I mounted my NFS share in CentOS               mount -nolock 192.168.178.5:/MEDIA media


How to tail a file over the network?

How can I `tail -f` a file that over the network, say at `\\\192.168.2.130\public\print.log`? I have tried the variations of the following:   * `tail -f //192.168.2.130/Southpaw/Tactic/print.log` which erred saying `tail: cannot open `//192.168.2.130/Southpaw/Tactic/print.log' for reading: No such file or directory`   * Mounted the path using the `mount -t cifs` and then tried `tail -f` but that isn't working either, meaning it doesn't output the updates that are made to the file.


Why does sudo ignore aliases?

I am running Ubuntu 10.04 and I use `upstart` for daemon management. My enterprise application is run as a daemon and must be run as root because of various privileges. E.g.:               sudo start my-application-long-ID     sudo stop my-application-long-ID     etc      I would like to introduce an `alias` to abbreviate these commands as something like:               alias startapp='sudo start my-application-long-ID'      and run it as `>startapp` and that works but I would prefer to not have sudo in the alias.               alias startapp='start my-application-long-ID'      does not when run using `>sudo startapp`, returning `sudo: startapp: command not found`. However, when I added the alias: `alias sudo='sudo '` `>sudo startapp` now works but I am still curious why sudo ignores aliases.


bash - replace space with new line

How can I replace spaces with new lines on an input like: `/path/to/file /path/to/file2 /path/to/file3 /path/to/file4 /path/to/file5` etc... To obtain the following:               /path/to/file     /path/to/file2     /path/to/file3     /path/to/file4     /path/to/file5      ### Note I'm posting this question to help other users, it was not easy to find a useful answer on UNIX SE until I started to type this question. After that I found the following: ### Related question How can I find and replace with a new line?


How can I list the available color names?

I'm trying to add some color to my git configuration and I want to know what color names are available on the terminal.   * I only want to use colors by name so it's easier for others to understand   * I don't want to add any new colors - I just want to select from the predefined names   * I would like a solution that works for all distros, but primarily Debian   * It would be nice to see the color that the name indicates Many online references often talk about color names that are not defined on my system, so I just need a way to see what my default options are.


How can I make my command more susceptible to system slowdowns so as to use it as a visual QoS widget on my desktop?

I had some system slowdown event1 after mistakenly using a command so I thought I could use a desktop "widget" to visually show _quality of service_ or at least show when QoS was degraded and get some timely feedback. We have this natural ability to perceive degradation in the playback of an image sequence so I wanted to leverage this. Therefore I selected an mp4 video sequence2 and made a .gif file out of a segment of it with `ffmpeg`:               ffmpeg -i snf.mp4 -ss 00:01:24.0 -t 00:00:04.03 -s qcif -qscale:v 10 -an output.gif      So this will be a stamp size qcif (176x144) gif image. In this example I extracted some 4.03 seconds starting at 1:24 into the sequence. Makes for a 1,3MiB file. Which I then `animate`:               animate -borderwidth 0 output.gif &      Then I "float" that tiny window in my tiling window manager, and keep that handy. The sequence loops and if you click on the image you get an imagemagick "display"-like menu where you have that (beautiful) _auto-reverse_ option... so the clip plays for its 4 seconds, then plays backwards and back and forth! I thought maybe I could start this with `ionice -c 2 -n 0` (but there can't be i/o here really) or renice it with `renice -n -10` but i can't come to terms with how to "expose" this to "load" so that it would be the first thing impacted if there is a slowdown. From what I understand, if the execution is too nice, it should get impacted all the time but that wouldn't be related to a system slowdown, just to being "bumped". If it's not nice at all, then it wouldn't have to face any slowdowns unless in the most dire of states and that would defeat the purpose. How can I set my command to be impacted _in priority_ (as opposed to having or not having execution priority) to other programs on my desktop so as to serve as a QoS widget? Or is that just misguided and since load balancing is all about _heuristics_ I won't be able to use something like that? * * * `ps aux` spec output for `animate`:               14454  0.3  2.9 228232 118768 pts/5   Sl   05:06   2:36 animate -borderwidth 0 test2.gif      * * * 1. I issued a wrong command using `convert`(ImageMagick) and it eventually exhausted system resources and self-terminated - I thought I was doing something legit so I let it go. During that time, I saw my system slowing down as the load increased; windows not refreshing, htop seemingly freezing, intense disk usage, and jerkiness with the mouse pointer. As the system was coming to a crawl, I noticed that looking at the movement of the pointer gave me a good "feel" of the slowdown so to speak. More so I found than looking at the load indicator reach 7-8 in my status bar(i3). Generally speaking for real time monitoring and information I use `htop` and the `i3 status` bar. But I'm also interested in different kinds of system feedback. 2. To help with my perceptual abilities, I selected a dancing clip. Some time ago I saw on youtube this famous dance sequence from _Saturday Night Fever(Bee Gees - "You should be dancing")_ with _M. John Travolta_ taking on the whole dancefloor. His landmark move is rythmic and the lights beat in a discernable pattern.


Convert linux symlink to osx symlink

I have transferred a folder from a linux machine to a macbook pro with osx 10.9, now I am having trouble with the symlinks in this folder (lots of them). In linux if I do `vi link2file.txt`, it has the same effect as `vi file.txt`, but in osx, it shows something like this:               IntxLNKh�t�m�l�_�t�e�x�.�s�n�i�p�      Why is this happening and is there a fast method to fix this? To recreate all the symlinks by hand would be a PITA.


How to mv and adopt target directory permissions

How do I move a file such that the file adopts the target directory permissions?   Surely this is an incredibly common scenario.... any help appreciated.


Linux - Only first virtual interface can ping external gateway

I created 3 virtual interfaces with different MAC addresses all linked to the same physical interface. I see that they can successfully `arp` for the gateway (gw) and they can `ping` (the request is coming in the packet capture in Wireshark). However the `ping` utility does not count the responses. Does anyone knows the issue? I'm running Ubuntu 14.04 in a VMware. _ip link info_               root@ubuntu:~# ip link sh     1: lo: <LOOPBACK,UP,LOWER_UP> mtu 65536 qdisc noqueue state UNKNOWN mode DEFAULT group default          link/loopback 00:00:00:00:00:00 brd 00:00:00:00:00:00     2: eth0: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc pfifo_fast state UP mode DEFAULT group default qlen 1000         link/ether 00:0c:29:bc:fc:8b brd ff:ff:ff:ff:ff:ff      _ip address info_               root@ubuntu:~# ip addr sh     1: lo: <LOOPBACK,UP,LOWER_UP> mtu 65536 qdisc noqueue state UNKNOWN group default          link/loopback 00:00:00:00:00:00 brd 00:00:00:00:00:00         inet 127.0.0.1/8 scope host lo            valid_lft forever preferred_lft forever         inet6 ::1/128 scope host             valid_lft forever preferred_lft forever     2: eth0: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc pfifo_fast state UP group default qlen 1000         link/ether 00:0c:29:bc:fc:8b brd ff:ff:ff:ff:ff:ff         inet6 fe80::20c:29ff:febc:fc8b/64 scope link             valid_lft forever preferred_lft forever      _ip route info_               root@ubuntu:~# ip route sh      _add virtual interfaces_               root@ubuntu:~# ip link add link eth0 eth0.1 addr 00:00:00:00:00:11 type macvlan     root@ubuntu:~# ip link add link eth0 eth0.2 addr 00:00:00:00:00:22 type macvlan     root@ubuntu:~# ip link add link eth0 eth0.3 addr 00:00:00:00:00:33 type macvlan      _confirm they were added_               root@ubuntu:~# ip -4 link sh     1: lo: <LOOPBACK,UP,LOWER_UP> mtu 65536 qdisc noqueue state UNKNOWN mode DEFAULT group default          link/loopback 00:00:00:00:00:00 brd 00:00:00:00:00:00     2: eth0: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc pfifo_fast state UP mode DEFAULT group default qlen 1000         link/ether 00:0c:29:bc:fc:8b brd ff:ff:ff:ff:ff:ff     18: eth0.1@eth0: <BROADCAST,MULTICAST> mtu 1500 qdisc noop state DOWN mode DEFAULT group default          link/ether 00:00:00:00:00:11 brd ff:ff:ff:ff:ff:ff     19: eth0.2@eth0: <BROADCAST,MULTICAST> mtu 1500 qdisc noop state DOWN mode DEFAULT group default          link/ether 00:00:00:00:00:22 brd ff:ff:ff:ff:ff:ff     20: eth0.3@eth0: <BROADCAST,MULTICAST> mtu 1500 qdisc noop state DOWN mode DEFAULT group default          link/ether 00:00:00:00:00:33 brd ff:ff:ff:ff:ff:ff      _ip IPv4 address & route info_               root@ubuntu:~# ip -4 addr sh     1: lo: <LOOPBACK,UP,LOWER_UP> mtu 65536 qdisc noqueue state UNKNOWN group default          inet 127.0.0.1/8 scope host lo            valid_lft forever preferred_lft forever          root@ubuntu:~# ip -4 route sh      _get DHCP IP for eth0.1_               root@ubuntu:~# dhclient -v eth0.1     Internet Systems Consortium DHCP Client 4.2.4     Copyright 2004-2012 Internet Systems Consortium.     All rights reserved.     For info, please visit https://www.isc.org/software/dhcp/     Listening on LPF/eth0.1/00:00:00:00:00:11     Sending on   LPF/eth0.1/00:00:00:00:00:11     Sending on   Socket/fallback     DHCPDISCOVER on eth0.1 to 255.255.255.255 port 67 interval 3 (xid=0x568eac05)     DHCPREQUEST of 192.168.1.145 on eth0.1 to 255.255.255.255 port 67 (xid=0x568eac05)     DHCPOFFER of 192.168.1.145 from 192.168.1.254     DHCPACK of 192.168.1.145 from 192.168.1.254     bound to 192.168.1.145 -- renewal in 1473 seconds.      _get DHCP IP for eth0.2_               root@ubuntu:~# dhclient -v eth0.2     Internet Systems Consortium DHCP Client 4.2.4     Copyright 2004-2012 Internet Systems Consortium.     All rights reserved.     For info, please visit https://www.isc.org/software/dhcp/     Listening on LPF/eth0.2/00:00:00:00:00:22     Sending on   LPF/eth0.2/00:00:00:00:00:22     Sending on   Socket/fallback     DHCPDISCOVER on eth0.2 to 255.255.255.255 port 67 interval 3 (xid=0x21e3114e)     DHCPREQUEST of 192.168.1.146 on eth0.2 to 255.255.255.255 port 67 (xid=0x21e3114e)     DHCPOFFER of 192.168.1.146 from 192.168.1.254     DHCPACK of 192.168.1.146 from 192.168.1.254     bound to 192.168.1.146 -- renewal in 1366 seconds.      _get DHCP ip for eth0.3_               root@ubuntu:~# dhclient -v eth0.3     Internet Systems Consortium DHCP Client 4.2.4     Copyright 2004-2012 Internet Systems Consortium.     All rights reserved.     For info, please visit https://www.isc.org/software/dhcp/     Listening on LPF/eth0.3/00:00:00:00:00:33     Sending on   LPF/eth0.3/00:00:00:00:00:33     Sending on   Socket/fallback     DHCPDISCOVER on eth0.3 to 255.255.255.255 port 67 interval 3 (xid=0x11dc5f03)     DHCPREQUEST of 192.168.1.147 on eth0.3 to 255.255.255.255 port 67 (xid=0x11dc5f03)     DHCPOFFER of 192.168.1.147 from 192.168.1.254     DHCPACK of 192.168.1.147 from 192.168.1.254     bound to 192.168.1.147 -- renewal in 1657 seconds.      _ip link info for interfaces_               root@ubuntu:~# ip -4 link sh     1: lo: <LOOPBACK,UP,LOWER_UP> mtu 65536 qdisc noqueue state UNKNOWN mode DEFAULT group default          link/loopback 00:00:00:00:00:00 brd 00:00:00:00:00:00     2: eth0: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc pfifo_fast state UP mode DEFAULT group default qlen 1000         link/ether 00:0c:29:bc:fc:8b brd ff:ff:ff:ff:ff:ff     18: eth0.1@eth0: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc noqueue state UNKNOWN mode DEFAULT group default          link/ether 00:00:00:00:00:11 brd ff:ff:ff:ff:ff:ff     19: eth0.2@eth0: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc noqueue state UNKNOWN mode DEFAULT group default          link/ether 00:00:00:00:00:22 brd ff:ff:ff:ff:ff:ff     20: eth0.3@eth0: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc noqueue state UNKNOWN mode DEFAULT group default          link/ether 00:00:00:00:00:33 brd ff:ff:ff:ff:ff:ff      _ip address info for interfaces_               root@ubuntu:~# ip -4 addr sh     1: lo: <LOOPBACK,UP,LOWER_UP> mtu 65536 qdisc noqueue state UNKNOWN group default          inet 127.0.0.1/8 scope host lo            valid_lft forever preferred_lft forever     18: eth0.1@eth0: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc noqueue state UNKNOWN group default          inet 192.168.1.145/24 brd 192.168.1.255 scope global eth0.1            valid_lft forever preferred_lft forever     19: eth0.2@eth0: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc noqueue state UNKNOWN group default          inet 192.168.1.146/24 brd 192.168.1.255 scope global eth0.2            valid_lft forever preferred_lft forever     20: eth0.3@eth0: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc noqueue state UNKNOWN group default          inet 192.168.1.147/24 brd 192.168.1.255 scope global eth0.3            valid_lft forever preferred_lft forever      _ip route info_               root@ubuntu:~# ip -4 route sh     default via 192.168.1.254 dev eth0.1      192.168.1.0/24 dev eth0.1  proto kernel  scope link  src 192.168.1.145      192.168.1.0/24 dev eth0.2  proto kernel  scope link  src 192.168.1.146      192.168.1.0/24 dev eth0.3  proto kernel  scope link  src 192.168.1.147       _arpping test eth0.1_               root@ubuntu:~# arping -c 5 -I eth0.1 192.168.1.254     ARPING 192.168.1.254 from 192.168.1.145 eth0.1     Unicast reply from 192.168.1.254 [58:98:35:57:a0:70]  6.936ms     Unicast reply from 192.168.1.254 [58:98:35:57:a0:70]  2.986ms     Unicast reply from 192.168.1.254 [58:98:35:57:a0:70]  0.654ms     Unicast reply from 192.168.1.254 [58:98:35:57:a0:70]  5.137ms     Unicast reply from 192.168.1.254 [58:98:35:57:a0:70]  2.426ms     Sent 5 probes (1 broadcast(s))     Received 5 response(s)      _arpping test eth0.2_               root@ubuntu:~# arping -c 5 -I eth0.2 192.168.1.254     ARPING 192.168.1.254 from 192.168.1.146 eth0.2     Unicast reply from 192.168.1.254 [58:98:35:57:a0:70]  5.665ms     Unicast reply from 192.168.1.254 [58:98:35:57:a0:70]  3.753ms     Unicast reply from 192.168.1.254 [58:98:35:57:a0:70]  16.500ms     Unicast reply from 192.168.1.254 [58:98:35:57:a0:70]  3.287ms     Unicast reply from 192.168.1.254 [58:98:35:57:a0:70]  32.438ms     Sent 5 probes (1 broadcast(s))     Received 5 response(s)      _arpping test eth0.3_               root@ubuntu:~# arping -c 5 -I eth0.3 192.168.1.254     ARPING 192.168.1.254 from 192.168.1.147 eth0.3     Unicast reply from 192.168.1.254 [58:98:35:57:a0:70]  4.422ms     Unicast reply from 192.168.1.254 [58:98:35:57:a0:70]  2.429ms     Unicast reply from 192.168.1.254 [58:98:35:57:a0:70]  2.321ms     Unicast reply from 192.168.1.254 [58:98:35:57:a0:70]  40.423ms     Unicast reply from 192.168.1.254 [58:98:35:57:a0:70]  2.268ms     Sent 5 probes (1 broadcast(s))     Received 5 response(s)      _tcpdump eth0.1 - test ping_               root@ubuntu:~# tcpdump -n -i eth0.1 -v &     [1] 5317     root@ubuntu:~# ping -c5 -q -I eth0.1 192.168.1.254     PING 192.168.1.254 (192.168.1.254) from 192.168.1.145 eth0.1: 56(84) bytes of data.     tcpdump: listening on eth0.1, link-type EN10MB (Ethernet), capture size 65535 bytes     13:18:37.612558 IP (tos 0x0, ttl 64, id 2595, offset 0, flags [DF], proto ICMP (1), length 84)         192.168.1.145 > 192.168.1.254: ICMP echo request, id 5318, seq 2, length 64     13:18:37.618864 IP (tos 0x68, ttl 64, id 14493, offset 0, flags [none], proto ICMP (1), length 84)         192.168.1.254 > 192.168.1.145: ICMP echo reply, id 5318, seq 2, length 64     13:18:37.743650 ARP, Ethernet (len 6), IPv4 (len 4), Request who-has 192.168.1.87 tell 192.168.1.86, length 46     13:18:38.134997 IP (tos 0x0, ttl 128, id 23547, offset 0, flags [none], proto UDP (17), length 229)         192.168.1.86.138 > 192.168.1.255.138: NBT UDP PACKET(138)     13:18:38.614580 IP (tos 0x0, ttl 64, id 2596, offset 0, flags [DF], proto ICMP (1), length 84)         192.168.1.145 > 192.168.1.254: ICMP echo request, id 5318, seq 3, length 64     13:18:38.793479 IP (tos 0x68, ttl 64, id 14495, offset 0, flags [none], proto ICMP (1), length 84)         192.168.1.254 > 192.168.1.145: ICMP echo reply, id 5318, seq 3, length 64     13:18:39.151282 IP6 (class 0x68, hlim 255, next-header ICMPv6 (58) payload length: 32) fe80::5a98:35ff:fe57:e070 > ff02::1:ff6b:e9b4: [icmp6 sum ok] ICMP6, neighbor solicitation, length 32, who has 2001:818:d812:da00:8ae3:abff:fe6b:e9b4           source link-address option (1), length 8 (1): 58:98:35:57:a0:70     13:18:39.615612 IP (tos 0x0, ttl 64, id 2597, offset 0, flags [DF], proto ICMP (1), length 84)         192.168.1.145 > 192.168.1.254: ICMP echo request, id 5318, seq 4, length 64     13:18:39.746981 IP (tos 0x68, ttl 64, id 14496, offset 0, flags [none], proto ICMP (1), length 84)         192.168.1.254 > 192.168.1.145: ICMP echo reply, id 5318, seq 4, length 64     --- 192.168.1.254 ping statistics ---     5 packets transmitted, 5 received, 0% packet loss, time 4008ms     rtt min/avg/max/mdev = 2.793/67.810/178.934/73.108 ms      _cleanup tcpdump_               root@ubuntu:~# killall tcpdump >> /dev/null 2>&1     9 packets captured     12 packets received by filter     0 packets dropped by kernel     [1]+  Done                    tcpdump -n -i eth0.1 -v      _tcpdump eth0.2 - test ping_               root@ubuntu:~# tcpdump -n -i eth0.2 -v &     [1] 5320     root@ubuntu:~# ping -c5 -q -I eth0.2 192.168.1.254     PING 192.168.1.254 (192.168.1.254) from 192.168.1.146 eth0.2: 56(84) bytes of data.     tcpdump: listening on eth0.2, link-type EN10MB (Ethernet), capture size 65535 bytes     13:18:41.536874 ARP, Ethernet (len 6), IPv4 (len 4), Reply 192.168.1.254 is-at 58:98:35:57:a0:70, length 46     13:18:41.536933 IP (tos 0x0, ttl 64, id 2599, offset 0, flags [DF], proto ICMP (1), length 84)         192.168.1.146 > 192.168.1.254: ICMP echo request, id 5321, seq 1, length 64     13:18:41.539255 IP (tos 0x68, ttl 64, id 14507, offset 0, flags [none], proto ICMP (1), length 84)         192.168.1.254 > 192.168.1.146: ICMP echo reply, id 5321, seq 1, length 64     13:18:42.127715 ARP, Ethernet (len 6), IPv4 (len 4), Request who-has 192.168.1.87 tell 192.168.1.86, length 46     13:18:42.511725 IP (tos 0x0, ttl 64, id 2600, offset 0, flags [DF], proto ICMP (1), length 84)         192.168.1.146 > 192.168.1.254: ICMP echo request, id 5321, seq 2, length 64     13:18:42.514385 IP (tos 0x68, ttl 64, id 14527, offset 0, flags [none], proto ICMP (1), length 84)         192.168.1.254 > 192.168.1.146: ICMP echo reply, id 5321, seq 2, length 64     13:18:42.743856 ARP, Ethernet (len 6), IPv4 (len 4), Request who-has 192.168.1.87 tell 192.168.1.86, length 46     13:18:43.511727 IP (tos 0x0, ttl 64, id 2601, offset 0, flags [DF], proto ICMP (1), length 84)         192.168.1.146 > 192.168.1.254: ICMP echo request, id 5321, seq 3, length 64     13:18:43.513768 IP (tos 0x68, ttl 64, id 14528, offset 0, flags [none], proto ICMP (1), length 84)         192.168.1.254 > 192.168.1.146: ICMP echo reply, id 5321, seq 3, length 64     13:18:43.637598 IP (tos 0x0, ttl 128, id 23551, offset 0, flags [none], proto UDP (17), length 225)         192.168.1.86.17500 > 255.255.255.255.17500: UDP, length 197     13:18:43.641185 IP (tos 0x0, ttl 128, id 23552, offset 0, flags [none], proto UDP (17), length 225)         192.168.1.86.17500 > 192.168.1.255.17500: UDP, length 197     13:18:43.641201 IP (tos 0x0, ttl 128, id 23553, offset 0, flags [none], proto UDP (17), length 225)         192.168.1.86.17500 > 255.255.255.255.17500: UDP, length 197     13:18:43.743890 ARP, Ethernet (len 6), IPv4 (len 4), Request who-has 192.168.1.87 tell 192.168.1.86, length 46     13:18:44.510758 IP (tos 0x0, ttl 64, id 2602, offset 0, flags [DF], proto ICMP (1), length 84)         192.168.1.146 > 192.168.1.254: ICMP echo request, id 5321, seq 4, length 64     13:18:44.512892 IP (tos 0x68, ttl 64, id 14538, offset 0, flags [none], proto ICMP (1), length 84)         192.168.1.254 > 192.168.1.146: ICMP echo reply, id 5321, seq 4, length 64     13:18:45.510794 IP (tos 0x0, ttl 64, id 2603, offset 0, flags [DF], proto ICMP (1), length 84)         192.168.1.146 > 192.168.1.254: ICMP echo request, id 5321, seq 5, length 64     13:18:45.519701 IP (tos 0x68, ttl 64, id 14539, offset 0, flags [none], proto ICMP (1), length 84)         192.168.1.254 > 192.168.1.146: ICMP echo reply, id 5321, seq 5, length 64     13:18:49.287554 IP6 (class 0x68, hlim 255, next-header ICMPv6 (58) payload length: 32) fe80::5a98:35ff:fe57:e070 > ff02::1:ff6b:e9b4: [icmp6 sum ok] ICMP6, neighbor solicitation, length 32, who has 2001:818:d812:da00:8ae3:abff:fe6b:e9b4           source link-address option (1), length 8 (1): 58:98:35:57:a0:70     13:18:50.013463 IP (tos 0x0, ttl 255, id 50737, offset 0, flags [DF], proto UDP (17), length 73)         192.168.1.146.5353 > 224.0.0.251.5353: 0 [2q] PTR (QM)? _ipps._tcp.local. PTR (QM)? _ipp._tcp.local. (45)     13:18:50.218874 IP6 (class 0x68, hlim 255, next-header ICMPv6 (58) payload length: 32) fe80::5a98:35ff:fe57:e070 > ff02::1:ff6b:e9b4: [icmp6 sum ok] ICMP6, neighbor solicitation, length 32, who has 2001:818:d812:da00:8ae3:abff:fe6b:e9b4           source link-address option (1), length 8 (1): 58:98:35:57:a0:70     13:18:51.129961 IP6 (class 0x68, hlim 255, next-header ICMPv6 (58) payload length: 32) fe80::5a98:35ff:fe57:e070 > ff02::1:ff6b:e9b4: [icmp6 sum ok] ICMP6, neighbor solicitation, length 32, who has 2001:818:d812:da00:8ae3:abff:fe6b:e9b4           source link-address option (1), length 8 (1): 58:98:35:57:a0:70     13:18:52.197074 IP6 (hlim 255, next-header UDP (17) payload length: 53) 2001:818:d812:da00:200:ff:fe00:22.5353 > ff02::fb.5353: [udp sum ok] 0 [2q] PTR (QM)? _ipps._tcp.local. PTR (QM)? _ipp._tcp.local. (45)     13:18:54.128240 ARP, Ethernet (len 6), IPv4 (len 4), Request who-has 192.168.1.87 tell 192.168.1.86, length 46     --- 192.168.1.254 ping statistics ---     5 packets transmitted, 0 received, 100% packet loss, time 4000ms      _cleanup tcpdump_               root@ubuntu:~# killall tcpdump >> /dev/null 2>&1     13:18:54.657731 IP6 (class 0x68, hlim 255, next-header ICMPv6 (58) payload length: 32) fe80::5a98:35ff:fe57:e070 > ff02::1:ff6b:e9b4: [icmp6 sum ok] ICMP6, neighbor solicitation, length 32, who has 2001:818:d812:da00:8ae3:abff:fe6b:e9b4           source link-address option (1), length 8 (1): 58:98:35:57:a0:70     13:18:54.743174 ARP, Ethernet (len 6), IPv4 (len 4), Request who-has 192.168.1.87 tell 192.168.1.86, length 46     25 packets captured     26 packets received by filter     0 packets dropped by kernel     [1]+  Done                    tcpdump -n -i eth0.2 -v      _tcpdump eth0.3 - test ping_               root@ubuntu:~# tcpdump -n -i eth0.3  icmp &     [1] 5324     root@ubuntu:~# ping -c5 -q -I eth0.3 192.168.1.254      PING 192.168.1.254 (192.168.1.254) from 192.168.1.147 eth0.3: 56(84) bytes of data.     tcpdump: verbose output suppressed, use -v or -vv for full protocol decode     listening on eth0.3, link-type EN10MB (Ethernet), capture size 65535 bytes     13:18:56.373434 IP 192.168.1.147 > 192.168.1.254: ICMP echo request, id 5325, seq 1, length 64     13:18:57.372116 IP 192.168.1.147 > 192.168.1.254: ICMP echo request, id 5325, seq 2, length 64     13:18:57.381263 IP 192.168.1.254 > 192.168.1.147: ICMP echo reply, id 5325, seq 2, length 64     13:18:58.371141 IP 192.168.1.147 > 192.168.1.254: ICMP echo request, id 5325, seq 3, length 64     13:18:58.373275 IP 192.168.1.254 > 192.168.1.147: ICMP echo reply, id 5325, seq 3, length 64     13:18:59.371165 IP 192.168.1.147 > 192.168.1.254: ICMP echo request, id 5325, seq 4, length 64     13:18:59.373259 IP 192.168.1.254 > 192.168.1.147: ICMP echo reply, id 5325, seq 4, length 64     13:19:00.371211 IP 192.168.1.147 > 192.168.1.254: ICMP echo request, id 5325, seq 5, length 64     13:19:00.373278 IP 192.168.1.254 > 192.168.1.147: ICMP echo reply, id 5325, seq 5, length 64     --- 192.168.1.254 ping statistics ---     5 packets transmitted, 1 received, 80% packet loss, time 4001ms     rtt min/avg/max/mdev = 13.666/13.666/13.666/0.000 ms      _cleanup tcpdump_               root@ubuntu:~# killall tcpdump >> /dev/null 2>&1     9 packets captured     10 packets received by filter     0 packets dropped by kernel     [1]+  Done                    tcpdump -n -i eth0.3 icmp      _check arp cache_               root@ubuntu:~# arp -n     Address                  HWtype  HWaddress           Flags Mask            Iface     192.168.1.254            ether   58:98:35:57:a0:70   C                     eth0.1     192.168.1.254            ether   58:98:35:57:a0:70   C                     eth0.2     192.168.1.254            ether   58:98:35:57:a0:70   C                     eth0.3


How do you route to secondary interface on the same physical port?

INTERNET<->(wan)BRIDGED_DEVICE(lan)<->ETH_ROUTER<->LAN _Problem:_   Need to access web server on BRIDGED_DEVICE's LAN from INTERNET via ROUTER (BRIDGED_DEVICE web server cannot be accessed form INTERNET since it has no Public management IP). _Attempt:_   Create a secondary/alias WAN Interface on ETH_ROUTER (e.g Primary: eth0.1 (for internet access) and Secondary: eth0.2 (for accessing web server on BRIDGED_DEVICE), (No VLANs).   * eth0.1 has a public IP;   * eth0.2 has a static private IP in the BRIDGED_DEVICE's subnet (e.g 10.0.X.Y). Iptables on ETH_ROUTER: Added a port forward (DNAT) from eth0.1 to eth0.2:               iptables -t nat -I PREROUTING -i eth0.1 -p tcp --dport 80 -j DNAT --to-destination 10.0.X.Y     iptables -t nat -I POSTROUTING -o eth0.2 -s 10.0.X.0/24 -j MASQUERADE      Stateful firewall w/ overall drop policy on FORWARD chain, hence:                iptables -I FORWARD -i eth0.1 -d 10.0.X.Y -p tcp --dport 80 -j ACCEPT      Can ping from ETH_ROUTER to BRIDGED_DEVICE but unable to reach the web server from Internet. I see packet cont increasing for the DNAT rule but not sure where it disappears in the ETH_ROUTER after that. ETH_ROUTER is the only device that can be configured to achieve this. If familiar with this scenario, please suggest what I may be missing or doing wrong here or suggest techniques to debug?


How do I see the contents of a drive in Debian command line?

I want to see what is on a drive so I can satisfy myself that it can be disconnected (unmounted?). This is a vm on ESXi with 3 datastores - first is the ESXi local storage, second is a nfs share on a NAS drive (that I want to remove), third is another nfs share on a 2nd NAS drive. I have found that the Debian vm will run fine with the 1st NAS drive disconnected from the network, but will not reboot in that state. I assume I need to unmount the drive concerned then remove datastore2 from the ESXi server. However I don't want to do this to find I have to retrace my steps. I expect to fing that datastore2 contains nothing but redundant data that was copied to datastore3 when it was added, but I would like to be able to 'browse' it first. Cheers, Gordon


How to determine what user was used to start Apache Tomcat last (or last few times)

On a Mac, or a Linux Tomcat install, how do I determine what user was used last to start Tomcat? Is there information in the logs somewhere to that effect? Assume that startup.sh and shutdown.sh are being used to control Tomcat. My best guess is the user(s) who have write access to Catalina.out are the most plausible suspects, but I wanted a hard and fast rule for determining who it is. Also it isn't currently running so don't say `ps -ef|grep -i Tomcat`


securely automating a script which requires a key to do its task

I have a script that downloads bank transactions to store in a database. To get these transactions requires a password for each account. The database is encrypted and requires a key to access it. All these keys and passwords are themselves encrypted and require a master key to retreive. The script prompts for the master key, uses this to retrieve all the necessary passwords and keys, and then does its work. Right now this script is being called manually. Automating it to run periodically is easy, except for the part of securing the master key. Simply storing it in a file in plaintext does not seem very secure, as anybody who manages to get read access to the file now has wide open access to a lot of sensitive information. Storing it in a way that the script has it (for example obfuscating it in a binary called by the script) won't work either, because then anyone who can execute the script has an attack vector there. I have read this question, the answer there appears to be "store it in a file" with added comments suggesting not in plain text. But even if the password is not plain text, it still seems like we have to communicate to the script how to read the file somehow, such as a decryption key or something, and we are back at square one.


Change terminal type for screen over a serial connection

I am connecting to an embedded Linux board using `screen` over a serial link and trying to change the terminal type, as the default `vt100` is pretty restrictive in terms of colours and scrolling etc. The `screen` manual suggests the configuration option `termcapinfo` but using that doesn't fix the issue. On the host machine, `TERM` is set to `xterm-256color` and when I connect to the target, using the `termcapinfo` setting in my `.screenrc`, `TERM` is still set to `vt100`. I am thinking maybe I should set something on the target machine?


Is there a right way to use one VPS backup file to build a clone VPS with it?

I tried many times to restore a tar ball from a different server to a fresh installed VPS with the same Linux Debian version (exactly the same) but every time when I restore the tar ball on a different fresh VPS, that VPS would reboot with no problem (at least if the tar ball from a VPS that uses the same virtualization system as the new one), but once it boots back on, I can't use the ssh terminal and even the site won't show up when I call the IP address. I simply use the following commands for backup and restore (taken from Ubuntu official help page):               sudo tar -cvpzf backup.tar.gz --one-file-system --exclude=/home/user/Backup_Files/backup.tar.gz /     tar -xvpzf backup.tar.gz -C /      The reason I wanna clone vps is that in case something happens to my vps, I'll be able to rebuild the server from scratch quickly without going through 4 hours of installing and configuration and forgetting something or losing configurations that I've built for years **So, can you anyone tell me the right way to fully backup a running vps on openvz?** +mind that no rescue mode in my openvz panel_


How to use the Cinnamon panel when using Awesome Window Manager in Cinnamon?

I am using `cinnamon 2.2.16-1`, `awesome 3.5.5-1` and awesome-cinnamon from the Arch Linux AUR. The `awesome-cinnamon` package basically just creates the `.desktop` and `.session` files to load `cinnamon` with `awesome wm` as the window manager. This is almost perfect for me, but I would like to experiment with using the `cinnamon` panel in addition to or instead of the `awesome` `wibox`, because the `cinnamon` panel has attractive icons for the audio, wifi and power controls. I can't seem to find any way to start the `cinnamon` panel. I am left thinking that the `cinnamon` panel must be part of `cinnamon's` window manager. It seems from googling that there used to be a program `gnome-panel` and `cinnamon-panel`, but these don't seem to exist anymore. Does anyone know of a way to get this working? cat /usr/share/xsessions/awesome-cinnamon.desktop:               [Desktop Entry]     Name=Awesome Cinnamon     Comment=Dynamic window manager     TryExec=/usr/bin/cinnamon     Exec=cinnamon-session-cinnamon --session=awesome     Type=XSession      cat /usr/share/cinnamon-session/sessions/awesome.session:               [Cinnamon Session]     Name=Awesome session     RequiredComponents=cinnamon-settings-daemon;awesome;     RequiredProviders=windowmanager;notifications;     DefaultProvider-windowmanager=awesome     DefaultProvider-notifications=notification-daemon      $ cinnamon-`Tab``Tab`:               cinnamon-desktop-editor           cinnamon-screensaver-lock-dialog     cinnamon-extension-tool           cinnamon-session     cinnamon-json-makepot             cinnamon-session-cinnamon     cinnamon-launcher                 cinnamon-session-cinnamon2d     cinnamon-looking-glass            cinnamon-session-properties     cinnamon-menu-editor              cinnamon-session-quit     cinnamon-screensaver              cinnamon-settings     cinnamon-screensaver-command      cinnamon-settings-users


Ways to organize and access frequently visited directories and files?

In my Ubuntu, I have added some frequented directories to the bookmarks of Nautilus, for visiting them quicker. Nautilus can consume a lot of memory, when it has been kept open for long and there have been many tabs opened in it. Nautilus can also close itself unexpectedly, and makes me lose track of what dirs I was working with. So I am thinking about some alternatives to Nautilus (both GUI and CLI are fine). I guess that command line is the simplest option. But I will miss the bookmark convenience of Nautilus.   1. What are some good practices/ways to remember and organize frequented dirs?   2. What I have thought is to create a dir, and store links to frequented dirs there. Are there better ways?   3. Is it possible to convert the dir bookmarks in Nautilus to links?   4. I am looking for where the dir bookmarks of Nautilus are stored, but to no avail:              $ find ~ -name nautilus | less          ./.config/nautilus     ./.gconf/apps/nautilus     ./.gconf/apps/ubuntuone/nautilus     ./.gnome2/accels/nautilus      I checked the above locations, and content of the files there, but didn't find anything for bookmarks.


Find kernel with specific commit

I have recently bought an Acer Aspire E1-572 with NetXtreme BCM57786 Gigabit Ethernet network card. The problem is that currently I cannot see it in `ifconfig`, but I can see it with `lshw`:                 *-network UNCLAIMED            description: Ethernet controller            product: NetXtreme BCM57786 Gigabit Ethernet PCIe            vendor: Broadcom Corporation            physical id: 0            bus info: pci@0000:01:00.0            version: 01            width: 64 bits            clock: 33MHz            capabilities: pm vpd msi msix pciexpress bus_master cap_list            configuration: latency=0            resources: memory:b0410000-b041ffff memory:b0420000-b042ffff memory:b0430000-b04307ff      Shortly, I have found this bug: https://bugs.launchpad.net/ubuntu/+source/linux/+bug/1242610 and it seems to be exactly my problem. It seems to be solved in this commit http://git.kernel.org/cgit/linux/kernel/git/davem/net- next.git/commit/drivers/net/ethernet/broadcom/tg3.c?id=68273712a19e9107a498a371532b3b3eb6dbb14c I am using Ubuntu 12.04 so there's a probability that (at some point) the patch will be backported, but I would really like to find (if there is any) a [preferably] stable kernel version that would contain this patch so I would be able to use my eth0. **How would I find a kernel binary that contains a specific commit?** Or find whether a specific kernel binary has a given commit? **UPDATE**               # uname -a     Linux laptop 3.8.0-33-generic #48~precise1-Ubuntu SMP Thu Oct 24 16:31:16 UTC 2013 i686 i686 i386 GNU/Linux      I installed it using:               apt-get install linux-generic-lts-raring


get age of given file

How can I get the age of a given file in, at least, days? I'm well aware of `ls -lh` and similar commands. I want something that will work sort of like this:               getfage <FILE> # prints out '12d' (12 days)      Also, this needs to be somewhat cross-platform since I'd also like to use this under Mac OS X, but the primary use-case is on my Linux-box. **NOTE** Since Linux doesn't track creation time, I'm looking for two-fold solution: one for _mtime_ (linux)--that is _the last time said file was modified_ --and one for Mac OS X, which can either deal with _mtime_ or creation time.


How do I download and launch a JNLP file in CentOS?

I'm using Amazon's GPU cluster to experiment with some HPC java code on CentOS. The Java application is in JNLP format and has a GUI. I've followed Amazon's getting started video, but I'm not sure how to use a web browser or otherwise download the file. Secondly I'm not sure how to launch this file since it requires a GUI. Any assistance would be appreciated.


What are the differences between various VM software?

I have only ever used VirtualBox and I would like to know, for example, what could I be missing from other offerings. I have heard of KVM and VMWare and I'm sure there's others. Short of reading Wikipedia articles on each (phew!), how do they differ?


How to iterate through multiple file extension without caring about case sensitivity?

I've seen various topics on how to iterate through multiple file extensions but in most case, the list is defined. example:               for file in ${arg}/**/*.{txt,h,py}     do         ....     done      As can be seen, `.TXT` files would be ignored. And sadly, the guy who answered it says it only works for bash4. but my setup uses bash3.x. Any ideas on how it can be done?


show colors and disable line wrap

Using the `less` paginator, you can use the `-r` option to properly display colored input and the `-S` option to disable line wrap. However, when using `less -rS` or equivalently `less -r -S`, colors are diplayed but lines are wrapped. How can this be achieved?


Trigger a login by plugging in a USB drive

OS: Linux, Mint. I want to have a system where I can insert a flashdrive into a computer, and using UDEV rules, have the system login a user account. I can do the UDEV part, but what command should I run to login? Google has not helped, nor has poking around the computer.


Local, timestamped logging of all ssh commands?

How can I keep a local, timestamped record of all remote commands I use in `ssh` (command-line openssh client started through `bash`)? **Requirements:**   * _Essential:_     * 100% client-side without relying on server logging     * Configured or installed per-user with logs stored in the user's home directory.     * Support for distinguishing between multiple simultaneous sessions with various users and hosts.     * Non-intrusive (no need to activate it each time and does not interfere significantly with using ssh)   * _High priority:_     * Either output is not logged or filtered out as much as possible     * Either password entries are not logged or the file is encrypted     * Indicates the actual commands used (after tab/ history completion, backspaces, `CTRL`+`C`, etc... have been processed)   * _Nice to have:_     * Also logs commands in chained sessions (commands entered during remote `ssh` or `su <user>` sessions)     * Session start and end should be logged     * A simple `bash`-based, non-root solution would be best (perhaps an `alias` or `bash` wrapper script for the `ssh` command?) **My skill level:**   * I am not new to programming, but am still learning `bash` and the "Linux way", so code samples with brief explanations would be most appreciated. **Possible strategies**   * _keylogger_ -- Problem: logs passwords, does not log tab/ history completion (see glenn's answer)   * _`screen` with scrollback dumping once per second and `diff` between them to find new scrollback lines_ -- Problem: how can this be implemented in an useful automated way?   * `ssh "$@" | tee >(some_cleaner_function >> $logfile)` -- Problem: cannot handle multiline commands or history in chained sessions, careful cleanup needed (see my answer)   * A combination of some of the above **An example** The following SSH session:               user@local:~$ ssh user@remote     Last login: Tue Jun 17 16:34:23 2014 from local     user@remote:~$ cd test     user@remote:~/test$ ls     a  b     user@remote:~/test$ exit      Might result in a log at `~/logs/ssh.log` such as:               2014-06-17 16:34:50   [user@remote - start]     2014-06-17 16:34:51   [user@remote] cd test     2014-06-17 16:34:52   [user@remote] ls     2014-06-17 16:34:53   [user@remote] exit     2014-06-17 16:34:53   [user@remote - end]      Or, perhaps a separate log will be created for each session with the command line used to start the session at the top of the file.


Cannot install mysql-server-5.5/the following packages have unmet dependicies

I'm using ubuntu 14.04. I tried entering `mysql` with the following command:               mysql -u root -p      and I got the following message: The program `mysql` can be found on the following packages:   * `mysql-client-core-5.5`   * `mariadb-client-core-5.5`   * `mysql-client-core-5.6`   * `percona-xtrabd-cluster-client-5.5` I then typed in:               sudo apt-get install mysql-client-core-5.6      After this was installed, I tried connecting to `mysql` again using:               mysql -u root -p      I then got the error message:               ERROR 2002 (HY000): Can't connect to local MySQL server through socket '/var/run/mysqld/mysqld.sock' (2)      After searching online, I found out I needed to install `mysql` server and so I wrote in the following command               sudo apt-get install mysql-server      I then got the message ;               Some packages could not be installed. This may mean that you have     requested an impossible situation or if you are using the unstable     distribution that some required packages have not yet been created     or been moved out of Incoming.     The following information may help to resolve the situation:          The following packages have unmet dependencies:      mysql-server : Depends: mysql-server-5.5 but it is not going to be installed      E: Unable to correct problems, you have held broken packages.      I've been looking on line for the past hour for a solution, but other people who had a similar error but had it from upgrading `mysql` and thus there solution were ineffective for me.


SELinux stops Google Chrome from executing

I can no longer start Google Chrome on Fedora 14 (using GNOME). ### strace               strace google-chrome     ...     readlink("/proc/self/exe", "/opt/google/chrome/chrome"..., 4096) = 25     socketpair(PF_FILE, SOCK_SEQPACKET, 0, [11, 12]) = 0     stat64("/opt/google/chrome/chrome-sandbox", {st_mode=S_IFREG|S_ISUID|0755, st_size=14008, ...}) = 0     access("/opt/google/chrome/chrome-sandbox", X_OK) = 0     socket(PF_FILE, SOCK_DGRAM, 0)          = 13     clone(child_stack=0, flags=CLONE_CHILD_CLEARTID|CLONE_CHILD_SETTID|SIGCHLD, child_tidptr=0xb452fae8) = 21093     recvmsg(11, 0xbfc79ac8, 0)              = ? ERESTARTSYS (To be restarted)     --- {si_signo=SIGCHLD, si_code=CLD_EXITED, si_pid=21093, si_status=0, si_utime=0, si_stime=0} (Child exited) ---     sigreturn()                             = ? (mask now [])     recvmsg(11, /opt/google/chrome/chrome: error while loading shared libraries: cannot restore segment prot after reloc: Permission denied      ### logs               fgrep -i chrome /var/log/messages     Sep 17 20:37:08 a kernel: [ 2084.648737] type=1400 audit(1316284628.960:21895): avc:  denied  { execmod } for  pid=20664 comm="chrome" path="/opt/google/chrome/chrome" dev=dm-1 ino=3147775 scontext=unconfined_u:unconfined_r:chrome_sandbox_t:s0-s0:c0.c1023 tcontext=system_u:object_r:execmem_exec_t:s0 tclass=file     Sep 17 20:46:25 a kernel: [ 2641.204736] type=1400 audit(1316285185.516:21896): avc:  denied  { execmod } for  pid=21057 comm="chrome" path="/opt/google/chrome/chrome" dev=dm-1 ino=3147775 scontext=unconfined_u:unconfined_r:chrome_sandbox_t:s0-s0:c0.c1023 tcontext=system_u:object_r:execmem_exec_t:s0 tclass=file     Sep 17 20:46:33 a kernel: [ 2649.438209] type=1400 audit(1316285193.749:21897): avc:  denied  { execmod } for  pid=21069 comm="chrome" path="/opt/google/chrome/chrome" dev=dm-1 ino=3147775 scontext=unconfined_u:unconfined_r:chrome_sandbox_t:s0-s0:c0.c1023 tcontext=system_u:object_r:execmem_exec_t:s0 tclass=file     Sep 17 20:46:39 a kernel: [ 2655.533882] type=1400 audit(1316285199.845:21898): avc:  denied  { execmod } for  pid=21094 comm="chrome" path="/opt/google/chrome/chrome" dev=dm-1 ino=3147775 scontext=unconfined_u:unconfined_r:chrome_sandbox_t:s0-s0:c0.c1023 tcontext=system_u:object_r:execmem_exec_t:s0 tclass=file      ### info about system               # lsb_release -a     LSB Version:    :core-4.0-ia32:core-4.0-noarch     Distributor ID: Fedora     Description:    Fedora release 14 (Laughlin)     Release:    14     Codename:   Laughlin     # uname -a     Linux a 2.6.35.14-96.fc14.i686.PAE #1 SMP Thu Sep 1 12:31:46 UTC 2011 i686 i686 i386 GNU/Linux      ### package info               rpm -qa | fgrep google-chrome-stable     google-chrome-stable-14.0.835.163-101024.i386      I suspect that the issue is being caused by SELinux. How can I make it so that SELinux allows Google Chrome to start without issue?