title: How can I view a reference or cheat sheet of the basic bash syntax, in the linux terminal?

text: Every time I need to do a little bash scripting involving if statements, checking for empty variables and non-existent files et.c. I find myself hitting google for some simple bash manual or guide. Often these are way too long and complicated to quickly answer the question I have at hand. So, I was thinking that there must be some command or man page that covers the basic bash syntax (for things like if-statements, checks for empty variables, non-existent files etc) in a short and accessible manner. I'm sure I just havent found out the command (man bash doesn't seem to be it). Where can I find that?


title: What happens between double-click in file manager and application launch?

text: What is the chain of apps involved in process of opening a file from a file manager? Consider these two moments, say it's Xfce 4 and a simple plain text file set up to open in Mousepad:   1. I hit double-click the file in Thunar or Nautilus etc.,   2. Mousepad is launched with the file The background is that I have a bug which seems to happen even when I use different file manager as well as application. For example, Nautilus/Mousepad or Thunar/Libreoffice Calc scenarios suffer from this bug as well. It's Debian Jessie amd64, FTM.


title: The -cp option to the java command

text: java -cp FILE.jar FILE.Main inputfile       What does the `-cp` option mean? For that matter, what a negative sign in front mean? I've searched everywhere and couldn't find the answer.


title: Unzipping a TAR file, causing an error

text: I am trying to unzip a .tar.gz file using `tar xvzf`, as hhaamu said in his answer to my other question about Installing GCC on SCO. When I type:               bash-3.1$ tar xzf gcc-2.95.2pl1-dist.tar.gz     tar: z: unknown option     Usage: tar -{txruc}[0-9vfbkelmnopwAFLTP] [tapefile] [blocksize] [tapesize] files...         Key     Device            Block   Size(K)    Tape         0       /dev/rfd048ds9    18      360        No         1       /dev/rfd148ds9    18      360        No         2       /dev/rfd096ds15   10      1200       No         3       /dev/rfd196ds15   10      1200       No         4       /dev/rfd0135ds9   18      720        No         5       /dev/rfd1135ds9   18      720        No         6       /dev/rfd0135ds18  18      1440       No         7       /dev/rfd1135ds18  18      1440       No         8       /dev/rct0         20      0          Yes         9       /dev/rctmini      20      0          Yes         10      /dev/rdsk/fp03d   18      720        No         11      /dev/rdsk/fp03h   18      1440       No         12      /dev/rdsk/fp03v21 10      20330      No      Notice the second and third line, where it says: > tar: z: unknown option Usage: tar -{txruc}[0-9vfbkelmnopwAFLTP] [tapefile] > [blocksize] [tapesize] files... **What does that mean, and how can I resolve this?**


title: Display command in xterm titlebar

text: My Bash Prompt is currently setting the xterm titlebar using the following sequence:               PS1='\033]0;\u@\h>\w\007'      Is there an easy way to display the current command in the titlebar. For example, if I am tailing a file using `tail -f foo.log`, I want my titlebar to say `tail -f foo.log`.


title: Change title on xterm

text: > **Possible Duplicate:**   >  Display command in xterm titlebar Like `konsole`'s tabs on KDE I want the title on `xterm` do the same thing (automatically changes). ¿Can anyone teach me? Thanks!


title: How can I format a flat file using awk?

text: Below is the format of some table data contained within a single file:               ;NULL;ABCD;ABHJARS;;ABCD;ABCD;Y;;;;;;;;;A;     ;NULL;XEU-ANKD;XEU-AJKD;;ABCD;ABCD;Y;;;;;;;;;A;     .     .     ;11744;AMKDIONSKH;AMKDJ AN DJ JAHF AS CPFVH MTM;;QWERDF;QWERDF;Y;;;;;;;;;A;          (5436rowsaffected)     (returnstatus=0)          Returnparameters:          ;;     ;5436;               (1rowaffected)     ;;;     ;-------;-----------;     ;grepkey;5436;          (1rowaffected)      **NOTE:** Above `grepkey=5436` (Count of the records present in table). Below is the expected output:               1;NULL;ABCD;ABHJARS;;ABCD;ABCD;Y;;;;;;;;;A;     2;NULL;XEU-ANKD;XEU-AJKD;;ABCD;ABCD;Y;;;;;;;;;A;     .     .     5436;11744;AMKDIONSKH;AMKDJ AN DJ JAHF AS CPFVH MTM;;QWERDF;QWERDF;Y;;;;;;;;;A;      I need the data in the above format. I'd like to prefix the row number and exclude the additional data that is present at the end of the file, like count of records in the table etc. Additionally I'd like to accomplish the above using `awk`.


title: Does Debian have any kind of virtual environment for make install?

text: If someone used a Python virtualenv he knows we can run scripts in its own environment installing all necessary libraries which won't impact main python distribution. Do we have something similar in a Linux (Debian) world for `make` utility?   1. Case 1: I downloaded sources and I know what dependencies I need. I put libraries somewhere in home directory and I explicitly say to `make` utility where to search them.   2. Case 2: I run some kind of virtualenv for `make` utility and I call there `apt-get install lib-required-dev` so downloaded libraries would be placed in this virtual environment and won't pollute my OS. And then I run `make`.


title: How to recover from desktop freeze without losing running windows?

text: Sometimes VirtualBox causes random freeze of my Mint 16 Cinnamon Desktop 64bit. I am not able to pinpoint what is actually wrong and even where to fill the bug report. But the life goes on and I need some means of re-initializing the windowing subsystem without losing the work I've done with existing applications.   * When I run `sudo service mdm restart` all the already running applications got killed brutally.   * The `cinnamon --replace -d :0` spell doesn't do anything; it just hangs. I guess it is because it need some form of co-operation with the already running cinnamon, which I guess doesn't respond to that.   * Commands entered with Alt+F2 are ignored, as well as the "r" command used to restart the Cinnamon. The screen is not updated, and it seems that the very keystrokes are ignored. What are my other options? * * * Symptoms of the freeze: The bug manifests by just freezing the screen update of the graphic terminal; the mouse moves alright, it even changes the icon when hovering over different parts of the screen. The problem is that I can't do anything with it; besides the screen doesn't update, and the keyboard don't do anything as well. But I can switch to the text console and I can see, that the windows' processes run well. I can event interact with the applications, that supply some form of cli interactions (like VBoxManage). To reproduce:   1. Install the Linux Mint 16 with Cinnamon 2.0 64 bit   2. Install a program that changes wallpaper (tested on variety, and wallch) and set it to start changing wallpaper as the background task.   3. Wait for background to change several times. The bug doesn't kick in on the first background change, you need to wait a moment.    4. On the .xsession.errors you will see something like that. * * * Edit: I've updated the symptoms. The time went by and I was able to triage the problem a lot better. It is NOT related to VirtualBox activity in any way.


title: mkfs.xfs /dev/custom_dev

text: I try to format a custom block device with `mkfs.xfs` in Ubuntu Server 12.04 LTS. In the end terminal prints:               cache_node_put: node put on refcount 0 (node=0x1cd7810)       cache_node_put:node put on node (0x1cd7810) in MRU list      and fails. I do not have any problem with the other filesystems such as `ext2`. Only `xfs` returns that. `dmesg` prints               segfault at 10 ip ........ sp ..... error 4 in libc-2.15.so[...]      The full command is `sudo mkfs.xfs /dev/custom_dev`. When I use the same command with the `-f` flag, the terminal prints at the end:               *** glibc detected *** mkfs.xfs: free(): invalid pointer: 0x0000000002431600 ***     *** glibc detected *** mkfs.xfs: malloc(): memory corruption: 0x000000000243170 ***      I use Ubuntu Server 12.04 LTS. The full command is "sudo mkfs.xfs /dev/custom_dev". When i use the same command with flag -f (sudo mkfs.xfs -f /dev/custom_dev) the terminal prints in the end "* glibc detected mkfs.xfs: free(): invalid pointer: 0x0000000002431600 glibc detected mkfs.xfs: malloc(): memory corruption: 0x000000000243170 * and does not return(unless i hit ^C) I tested mkfs.xfs in another device and i have no problem. The problem remains in custom_dev only in which i use a simple device driver i wrote on my own. The custom_dev does not seem to have any problem with ext2. Only with xfs. Any ideas?


title: Remove multiple possible suffixes

text: Example: I want to create a quick command to shrink images (for my filebrowser).               ...     FN="/tmp/some-image.jpg"     gm convert "$FN" -resize 50% "$(dirname $FN)/$(basename $FN .jpg/png/gif).jpg"     ...      How can I specify that more than one suffix should be stripped?


title: objdump Vs sh4-linux-objdump

text: I need this command (sh4-linux-objcopy) in RHEL 6. I could not find the package by `yum install` , neither there is a corresponding rpm. Here is how I want to use it:               sh4-linux-objdump -h vmlinux | grep .empty_zero_page | awk '{print $4}'      But `objdump` is installed and works fine. So is there any difference between `objdump` and `sh4-linux-objdump` and what is `sh4-linux-`


title: RHEL - not able to write in /opt as root

text: I am trying to copy a virtual box image inside **/opt** folder in _RHEL 5.6_. I am logged in as the _root_ and I strangely see that I am not able to write anything into **/opt** folder. I checked the permissions from other machines in the lab and see that the permissions are set correctly. However, in the **/etc/fstab** file in all the remaining machines (where everything is correct and working fine), I see the below entry.               LABEL = /home1 /opt ext3 defaults 1 2      In the faulty machine where **/opt** directory is not writable, I see the **/etc/fstab** file entry as,               LABEL = /home /opt ext3 defaults 1 2      I am quite new to system administration and I believe it has to do something with the improper mounting of the file system as read only. I checked the **dmesg** for any errors but was not able to understand it. I think I have to remount the **/opt** with the proper settings. But I don't want to do anything in the lab to disturb the current setup. I just wanted to know if my understanding is correct and, is it the missing " **1** " in **/etc/fstab** file causing the **/opt** to be read only? **EDIT:** After I run the mount command, The output from the faulty machine,               /dev/sda2 on / type ext3 (rw)     proc on /proc type proc (rw)     sysfs on /sys type sysfs (rw)     devpts on /dev/pts type devpts (rw,gid=5,mode=620)     /dev/sda5 on /opt type ext3 (rw)     /dev/sda1 on /boot type ext3 (rw)     tmpfs on /dev/shm type tmpfs (rw)     none on /proc/sys/fs/binfmt_misc type binfmt_misc (rw)     sunrpc on /var/lib/nfs/rpc_pipefs type rpc_pipefs (rw)     XXXserver.XXX.XXX:/opt/vbox_image on /opt/vbox_image type nfs (rw,addr=192.168.1.10)     nfsd on /proc/fs/nfsd type nfsd (rw)      The output from the correct machine               /dev/sda2 on / type ext3 (rw)     proc on /proc type proc (rw)     sysfs on /sys type sysfs (rw)     devpts on /dev/pts type devpts (rw,gid=5,mode=620)     /dev/sda5 on /opt type ext3 (rw)     /dev/sda1 on /boot type ext3 (rw)     tmpfs on /dev/shm type tmpfs (rw)     none on /proc/sys/fs/binfmt_misc type binfmt_misc (rw)     sunrpc on /var/lib/nfs/rpc_pipefs type rpc_pipefs (rw)     ascentserver.uta.edu:/opt/vbox_image on /opt/vbox_image type nfs (rw,addr=192.168.1.10)     **none on /proc/fs/vmblock/mountPoint type vmblock (rw)**     nfsd on /proc/fs/nfsd type nfsd (rw)      **EDIT 2:** If I run the command, `for i in $( cat /proc/partitions | awk '{ print $4 }' ) ; do e2label /dev/$i ; done`, I get the below output. I am not able to debug this output.               e2label: No such file or directory while trying to open /dev/name     Couldn't find valid filesystem superblock.     e2label: Bad magic number in super-block while trying to open /dev/sda     Couldn't find valid filesystem superblock.     /boot1     /1     e2label: Bad magic number in super-block while trying to open /dev/sda3     Couldn't find valid filesystem superblock.     e2label: Attempt to read block from filesystem resulted in short read while trying to open /dev/sda4     Couldn't find valid filesystem superblock.     /home      **EDIT 3:** The `ls-l` command on /opt directory shows I have rwx permission on all the files inside it. However, I tried creating a simple text file and it was not allowing me to create the file.


title: Where is <libraryname>.pc?

text: 1. When installing a library with `configure`, `make` and `make install`, does `make install` copy `<libraryname>.pc` to some place?     * If yes: Where is it?     * If no: Should we copy it somewhere rather than leave them where they are?    2. I am asking that, because on an old notebook of mine, I saw: > add the directory containing `libraryname.pc` to the PKG_CONFIG_PATH > environment variable, so that `pkg-config --clags libraryname` and `pkg- > config --libs libraryname` can find them.   3. Will `dpkg -l` be able to track the installed library depending on whether it's path was added to `PKG_CONFIG_PATH`?   4. Once I copy `<libraryname>.pc` to some place, will `dpkg -l` be able to track the installed packages?


title: Why does `tmux` copy operation always output temporary gibberish to the terminal?

text: If I complete a copy operation using `tmux`, I always get one or more lines of gibberish written to my screen, which goes away when I change windows or do a paste. Why does this happen, and can it be disabled?


title: Focusrite Scarlett 8i6 With linux mint

text: I have a focusrite scarlett 8i6 soundcard and I would like to make many sounds with it. Currently it's deadly silent and I want to crack on with some programming whilst listening to music! I usually go for a very standard Ubuntu install, but thought I would give Linux Mint a try, but the soundcard doesn't seem to work currently. After some fiddling with Linux Mint I've actually made it recognise the soundcard. `cat /proc/asound/cards`:                1 [USB            ]: USB-Audio - Scarlett 8i6 USB                       Focusrite Scarlett 8i6 USB at usb-0000:00:14.0-1, high speed      I've blacklisted the onboard soundcard, but now I'm not sure how to use this one. It isn't picked up in sound preferences, by default that just has a dummy output now. I've got `pulseaudio`, `alsa` and `jack` installed, but have no idea how to actually get any or all of those working together. Some other info:               # /sbin/lsmod | grep snd     snd_usb_audio         149200  0        snd_usbmidi_lib        25070  1 snd_usb_audio     snd_hwdep              13602  1 snd_usb_audio     snd_seq_midi           13324  0      snd_seq_midi_event     14899  1 snd_seq_midi     snd_rawmidi            30095  2 snd_usbmidi_lib,snd_seq_midi     snd_seq                61560  2 snd_seq_midi_event,snd_seq_midi     snd_pcm               102033  1 snd_usb_audio     snd_seq_device         14497  3 snd_seq,snd_rawmidi,snd_seq_midi     snd_page_alloc         18710  1 snd_pcm     snd_timer              29433  2 snd_pcm,snd_seq     snd                    69141  9                         snd_usb_audio,snd_hwdep,snd_timer,snd_pcm,snd_seq,sn     d_rawmidi,snd_usbmidi_lib,snd_seq_device,snd_seq_midi     soundcore              12680  1 snd      I've also updated `/etc/modprobe.d/alsa-base.conf`:               options snd-usb-audio index=0      `aplay --list-devices`:                **** List of PLAYBACK Hardware Devices ****      card 1: USB [Scarlett 8i6 USB], device 0: USB Audio [USB Audio]       Subdevices: 1/1       Subdevice #0: subdevice #0      * * * I don't really know much about pulseaudio, other than the basic of what it does. But the soundcard doesn't seem to be picked up by it.               pacmd list-cards     Welcome to PulseAudio! Use "help" for usage information.     >>> 0 card(s) available.      For completeness the output of speaker test               speaker-test 1.0.27.1          Playback device is default     Stream parameters are 48000Hz, S16_LE, 1 channels     Using 16 octaves of pink noise     Rate set to 48000Hz (requested 48000Hz)     Buffer size range from 192 to 2097152     Period size range from 64 to 699051     Using max buffer size 2097152     Periods = 4     was set period_size = 524288     was set buffer_size = 2097152     0 - Front Left     Time per period = 12.425529      But still no sound. Any suggestions? *********UPDATE************* Command: amixer -c 0 contents               numid=1,iface=MIXER,name='Scarlett 8i6 USB-Sync'       ; type=ENUMERATED,access=rw------,values=1,items=2       ; Item #0 'Internal'       ; Item #1 'S/PDIF'       : values=0


title: How to apply a patch correctly?

text: I am trying to patch a linux 3.13.7 source tree to 3.13.8 using the `patch-3.13.8.xz` file. Since the patch file is in `xz` format, I used the following command to apply it while in the source tree:               unxz -cd ../patch-3.13.8.xz | patch -p1      But I receive:               Reversed (or previously applied) patch detected!  Assume -R? [n]      I have checked `man patch` for the `-R` flag and the description makes no sense to me. Can someone please explain what is going on and what I need to do to fix this?


title: How do I copy multiple files by wildcard?

text: I have a folder with a number of files in it ABC.* (there are roughly 100 such files). I want to duplicate them all to new files with names starting with DEF.* So, I want               ABC.Page1     ABC.Page2     ABC.Topic12     ...etc      copied to               DEF.Page1     DEF.Page2     DEF.Topic12     ...etc      What is the simplest way to do this with a batch command (in BASH or similar)? I am thinking something involving sed or awk or xargs, but I'm having difficulty figuring out the syntax. I could write a Python script, but I'm thinking there is probably a command line solution that is not too complicated.


title: mv on a glob pattern does not work without sudo

text: I am using **MySQL** database on **Ubuntu** machine. My **MySQL** data directory is `/var/lib/mysql/` , since I have a database named " **db_test** " , so, I have a directory named `db_test/` under `/var/lib/mysql/` . And all the table info are under `/var/lib/mysql/db_test/`               /var/lib/mysql# ls     db_test          /var/lib/mysql# cd db_test     /var/lib/mysql/db_test# ls     cars.frm     cars.MYD     cars.MYI     customers.frm     customers.MYD     ...      What I want to achieve is very simple, just make a new directory named " **backup** ", and **move all files under** `/var/lib/mysql/db_test/` to the `/var/lib/mysql/backup/` directory. So, I run the following commands under **a sub-directory of my home directory** :               ~/tmp$ sudo mkdir /var/lib/mysql/backup     ~/tmp$ sudo mv /var/lib/mysql/db_test/* /var/lib/mysql/backup      The 1st `mkdir` command run successfully, I did get a new directory named "backup/" under `/var/lib/mysql/` **But the 2nd command get failed** , with the following error message:               mv: cannot stat `/var/lib/mysql/db_test/*': No such file or directory      Why?? I have `db_test/` directory under `/var/lib/mysql/` and many table files inside, why it raise the error message? **P.S.** I know only root user can access `/var/lib/mysql/`. Could it be the reason? (but I used `sudo`), I am not sure though... and how to get rid of it?


title: Grep alias - line numbers unless it's in a pipeline

text: I want to create a bash alias for grep that adds line numbers:               alias grep='grep -n'      But that, of course, adds line numbers to pipelines as well. Most of the time (and no exceptions come to mind) I don't want line numbers within a pipeline (at least internally, probably OK if it's last), and I don't really want to add a sed/awk/cut to the pipeline just to take them out. Perhaps my requirements could be simplified to "only add line numbers if grep is the only command on the line." Is there any way to do this without a particularly ugly alias?


title: Add/update a file to an existing tar.gz archive?

text: Is there a way to add/update a file in a tar.gz archive? Basically, I have an archive which contains a file at `/data/data/com.myapp.backup/./files/settings.txt` and I'd like to pull that file from the archive (already done) and push it back into the archive once the edit has been done. How can I accomplish this? Is it problematic because of the `.` in the path?


title: Has anyone got any performance numbers comparing IIS and .NET to Cherokee and Mono?

text: I am setting up a development server and want to set it up to serve ASP.NET pages using Mono. I am planning on using Cherokee and Mono (http://www.cherokee-project.com/doc/cookbook_mono.html) and wondered if anyone had done any performance testing comparing the Unix based stack to the Windows based.


title: How do I set the default ftp root folder for an Ubuntu user connecting to VSFTPD?

text: How do I set/change the default ftp root folder for a specific user? I want to be able to create a developer account that homes to different sites on a development box depending on what is currently being worked on. EDIT: The server is running Ubuntu and vsftpd.


title: I have downloaded and un-tarred zsh, what do I do next

text: I am running Linux Fedora 20, and have downloaded and un-tarred `tar -jvxf zshell/zsh-5.0.5.tar.bz2`, and now have what looks like the correct directory, as in the following listing which also shows what happens when I try `make`.               [1156][root@localhost:/home/Harry/zsh-5.0.5]# ls     aclocal.m4  config.guess  Doc        install-sh   Misc           Src     aczsh.m4    config.h.in   Etc        LICENCE      mkinstalldirs  stamp-h.in     ChangeLog   config.sub    FEATURES   MACHINES     NEWS          StartupFiles     Completion  configure     Functions  Makefile.in  README         Test     Config      configure.ac  INSTALL    META-FAQ     Scripts        Util     [1156][root@localhost:/home/Harry/zsh-5.0.5]# make     make: *** No targets specified and no makefile found.  Stop.      So, please what do I do to complete the installation of zshell?


title: Find the files algorithm

text: I'm using Linux (Ubuntu 12.04). I'm trying to know how 'find' command works. My question is, how can I run and test the C files for 'find' which I downloaded from the GNU findutils ?


title: xmodmap causes incorrect keyboard shortcuts

text: I used `xmodmap` to switch the Caps Lock and Ctrl keys on my Thinkpad X120e. The keys are swapped but this has caused keyboard shortcuts in several applications to stop working correctly. In Libre Office `Ctrl+Shift+s` no longer works (but `Ctrl+s` and `Ctrl+Shift+v` do). `Ctrl+Shift+S` is also broken in `emacs` (where I have it mapped to save as) and `Ctrl+N` and `Ctrl+Shift+N` have swapped purposes (new buffer and new frame). My `.xmodmap` file looks as follows:               remove Lock = Caps_Lock     remove Control = Control_L     keysym Control_L = Caps_Lock     keysym Caps_Lock = Control_L     add Lock = Caps_Lock     add Control = Control_L      I used the same file on my desktop (also running Debian Wheezy) and did not experience these problems.


title: Why is 'df' hanging?

text: I have recently been having problems running `df`, where it just _hangs_. Here's `strace` output, and in it, you'll see that I killed since it was just sitting there:               $ strace /bin/df     execve("/bin/df", ["/bin/df"], [/* 35 vars */]) = 0     brk(0)                                  = 0x8d03000     access("/etc/ld.so.nohwcap", F_OK)      = -1 ENOENT (No such file or directory)     mmap2(NULL, 8192, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_ANONYMOUS, -1, 0) = 0xb7840000     access("/etc/ld.so.preload", R_OK)      = -1 ENOENT (No such file or directory)     open("/etc/ld.so.cache", O_RDONLY)      = 3     fstat64(3, {st_mode=S_IFREG|0644, st_size=90781, ...}) = 0     mmap2(NULL, 90781, PROT_READ, MAP_PRIVATE, 3, 0) = 0xb7829000     close(3)                                = 0     access("/etc/ld.so.nohwcap", F_OK)      = -1 ENOENT (No such file or directory)     open("/lib/i386-linux-gnu/i686/cmov/libc.so.6", O_RDONLY) = 3     read(3, "\177ELF\1\1\1\0\0\0\0\0\0\0\0\0\3\0\3\0\1\0\0\0\240o\1\0004\0\0\0"..., 512) = 512     fstat64(3, {st_mode=S_IFREG|0755, st_size=1401000, ...}) = 0     mmap2(NULL, 1415544, PROT_READ|PROT_EXEC, MAP_PRIVATE|MAP_DENYWRITE, 3, 0) = 0xb76cf000     mprotect(0xb7822000, 4096, PROT_NONE)   = 0     mmap2(0xb7823000, 12288, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_FIXED|MAP_DENYWRITE, 3, 0x153) = 0xb7823000     mmap2(0xb7826000, 10616, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_FIXED|MAP_ANONYMOUS, -1, 0) = 0xb7826000     close(3)                                = 0     mmap2(NULL, 4096, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_ANONYMOUS, -1, 0) = 0xb76ce000     set_thread_area({entry_number:-1 -> 6, base_addr:0xb76ce8d0, limit:1048575, seg_32bit:1, contents:0, read_exec_only:0, limit_in_pages:1, seg_not_present:0, useable:1}) = 0     mprotect(0xb7823000, 8192, PROT_READ)   = 0     mprotect(0xb785e000, 4096, PROT_READ)   = 0     munmap(0xb7829000, 90781)               = 0     brk(0)                                  = 0x8d03000     brk(0x8d24000)                          = 0x8d24000     open("/usr/lib/locale/locale-archive", O_RDONLY|O_LARGEFILE) = 3     fstat64(3, {st_mode=S_IFREG|0644, st_size=1534656, ...}) = 0     mmap2(NULL, 1534656, PROT_READ, MAP_PRIVATE, 3, 0) = 0xb7557000     close(3)                                = 0     open("/etc/mtab", O_RDONLY)             = 3     fstat64(3, {st_mode=S_IFREG|0644, st_size=708, ...}) = 0     mmap2(NULL, 4096, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_ANONYMOUS, -1, 0) = 0xb783f000     read(3, "/dev/sda6 / ext4 rw,errors=remou"..., 4096) = 708     read(3, "", 4096)                       = 0     close(3)                                = 0     munmap(0xb783f000, 4096)                = 0     statfs64("/", 84, {f_type="EXT2_SUPER_MAGIC", f_bsize=4096, f_blocks=4805813, f_bfree=3325193, f_bavail=3081072, f_files=1220608, f_ffree=1007617, f_fsid={-1624337824, -871214780}, f_namelen=255, f_frsize=4096}) = 0     open("/usr/share/locale/locale.alias", O_RDONLY) = 3     fstat64(3, {st_mode=S_IFREG|0644, st_size=2570, ...}) = 0     mmap2(NULL, 4096, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_ANONYMOUS, -1, 0) = 0xb783f000     read(3, "# Locale name alias data base.\n#"..., 4096) = 2570     read(3, "", 4096)                       = 0     close(3)                                = 0     munmap(0xb783f000, 4096)                = 0     open("/usr/share/locale/en_ZA.utf8/LC_MESSAGES/coreutils.mo", O_RDONLY) = -1 ENOENT (No such file or directory)     open("/usr/share/locale/en_ZA/LC_MESSAGES/coreutils.mo", O_RDONLY) = -1 ENOENT (No such file or directory)     open("/usr/share/locale/en.utf8/LC_MESSAGES/coreutils.mo", O_RDONLY) = -1 ENOENT (No such file or directory)     open("/usr/share/locale/en/LC_MESSAGES/coreutils.mo", O_RDONLY) = -1 ENOENT (No such file or directory)     statfs64("/lib/init/rw", 84, {f_type=0x1021994, f_bsize=4096, f_blocks=1280, f_bfree=1280, f_bavail=1280, f_files=215959, f_ffree=215956, f_fsid={0, 0}, f_namelen=255, f_frsize=4096}) = 0     statfs64("/run", 84, {f_type=0x1021994, f_bsize=4096, f_blocks=102000, f_bfree=101823, f_bavail=101823, f_files=215959, f_ffree=215559, f_fsid={0, 0}, f_namelen=255, f_frsize=4096}) = 0     statfs64("/sys", 84, {f_type="SYSFS_MAGIC", f_bsize=4096, f_blocks=0, f_bfree=0, f_bavail=0, f_files=0, f_ffree=0, f_fsid={0, 0}, f_namelen=255, f_frsize=4096}) = 0     statfs64("/dev", 84, {f_type=0x1021994, f_bsize=4096, f_blocks=508762, f_bfree=508762, f_bavail=508762, f_files=213490, f_ffree=213031, f_fsid={0, 0}, f_namelen=255, f_frsize=4096}) = 0     statfs64("/run/shm", 84, {f_type=0x1021994, f_bsize=4096, f_blocks=203999, f_bfree=203816, f_bavail=203816, f_files=215959, f_ffree=215955, f_fsid={0, 0}, f_namelen=255, f_frsize=4096}) = 0     statfs64("/dev/pts", 84, {f_type="DEVPTS_SUPER_MAGIC", f_bsize=4096, f_blocks=0, f_bfree=0, f_bavail=0, f_files=0, f_ffree=0, f_fsid={0, 0}, f_namelen=255, f_frsize=4096}) = 0     statfs64("/boot", 84, {f_type="EXT2_SUPER_MAGIC", f_bsize=1024, f_blocks=188403, f_bfree=150550, f_bavail=140822, f_files=48768, f_ffree=48525, f_fsid={-655942775, 1382872797}, f_namelen=255, f_frsize=1024}) = 0     statfs64("/home", 84, {f_type="EXT2_SUPER_MAGIC", f_bsize=4096, f_blocks=66535124, f_bfree=6683145, f_bavail=3303357, f_files=16900096, f_ffree=16633097, f_fsid={-515912651, 307591087}, f_namelen=255, f_frsize=4096}) = 0     statfs64("/sys/fs/fuse/connections", 84, {f_type=0x65735543, f_bsize=4096, f_blocks=0, f_bfree=0, f_bavail=0, f_files=0, f_ffree=0, f_fsid={0, 0}, f_namelen=255, f_frsize=4096}) = 0     statfs64("/home/wena/temp/mount", 84, ^C <unfinished ...>      Another tool that fails is `gnome-system-monitor`, which also seems to hang immediately after being launched.


title: Proper way to distribute shell scripts

text: What is the most proper way to distribute shell scripts, if behaviours of shells can be modified by `set` and thus are unpredictable? For example, `rm *.txt` wouldn't be executed as expected on the environments in which `set -f` has been run. How should I make sure that `rm *.txt` removes all text files in a current directory in any environments? How should I make that sure that shell scripts will run as expected before distributing them in general?


title: How to update MOTD regularly?

text: Every week there's a new work log/to-do list at work. There's a `todo` script which can be used to extract my own to-do items from that. Currently this is called in `~/.bash_aliases_local`, which is sourced from `~/.bash_aliases`. Rather than parsing the log every time I start another shell, I'd like to use the standard MOTD (message of the day) functionality. This would involve updating a static file with the to-do list on a weekly basis:               @weekly update-motd      The resulting static text file should be printed every time I start an interactive Bash shell. What's the standard way to do this?


title: Functional shell scripting

text: I found out that when I want to create some shell script or advanced command it always made me trouble to remember the names of the commands and their switches. e.g.               tr -d '\n' < file | wc -c      Though in programming languages I could write something like > len(replace(str(file), "\n", "")) Which is more memorable and there is less probability to search in man pages and it's more understandable for others. So, why shell scripting is for so many years in this cryptic form? Is their an effort to change the syntax to be clear what the code does without a lot of man pages studying? Are there some advantages of this form? How can we cope with the disadvantages to get most from the shell scripting?


title: How to print the next crontab tasks to be executed?

text: Is there some way to display a list of the approaching task executions? That is, translate this crontab:               # m h  dom mon dow   command       * *  *   *   *     imapfilter       4 20 *   *   Sun   fgit gc -- ~/*/ ~/.*/ ~/dev/*/      into this:               2012-04-12 14:40 imapfilter     2012-04-12 14:41 imapfilter     ...     2012-04-15 20:03 imapfilter     2012-04-15 20:04 fgit gc -- ~/*/ ~/.*/ ~/dev/*/     2012-04-15 20:04 imapfilter     2012-04-15 20:05 imapfilter     ...      It would be useful for verifying the saved schedules.


title: logging session with 'script' - how later read it?

text: I log my terminal session with `script`. As we know, it contains all characters that were send to terminal, including control ones, like backspaces etc. This makes output file a kind of unreadable, therefore: What's the best way to later read output of `script`? (so it looks more like terminal after finished session)


title: Tilde (~) inside working unix directory

text: So, Im working in a UNIX environment and I noticed that inside my working directory, which is miles miles away from my UNIX home, there is a `~`. Now, once in the past, I did `rm -rf ~` from my working directory and ended up erasing my home directory completely and had to involve IT. I do not want to do it again. At the same time, I want to know   1. Why is `~` created in my working directory? Is it a faulty finger slip while saving (`:w!` but what happens is `:w~` ?!!)   2. Before checking in, there is a script that looks for extra files or folders that p4 is not aware so def this `~` might cause an issue. So how can I remove the `~` from my working directory and at the same time not erase my home? I do have a backup command called `del` that I use instead of `rm -rf`. It just places stuff in a temporary location. I could use that and get rid of the `~`. But I'm more interested in knowing why this happens, and how I can remove it?


title: Flash Player on Linux

text: I'm going to switch to Linux with my new computer. I've read something weird about Firefox not supporting Flash on Linux (Chrome seems to support it, but I wouldn't want to switch if possible). The only sites I remember that I visit that use Flash are Youtube (with which I have no problem because I suppose it'll work fine with HTML5 (it'll work even better, because now with flash player I can't use the HTML5-only half speed configuration) and minigame sites (which I suppose it won't work anymore, but that's no big deal). However, will this affect other sites I can't remember now? Just to be sure, is there any good alternative? (I've heard about Lightspark and Gnash, but they say that they aren't very good).


title: Why do I need to insert the passphrase for an RSA key on a remote host after SSH?

text: From host **B** I can SSH various other hosts ( **C, D** ) without using any password as I put the public key in the correspondent authorized_keys files (in hosts C and D). From host **A** I can SSH host **B** (via _password_ authentication). However, once I am logged into host **B** I _need to authenticate my key each time_ when I connect to C and D (even if in principle this should not be the case). To summarize, if I connect directly to host B (e.g office) I do not need to type any password to connect to C or D. If I connect to A (e.g. home) and then from A I connect to B, once I am in B I need passwords to connect to D or C. I can partially solve the problem by adding the password to an ssh-agent (using ssh-add), but every time I open a new shell in B I need to do this again. **Update** Thanks to the useful comments, it turned out that the problem is the following. When I connect directly to B there is a keyring program running (in my specific case this is seahorse). Therefore the passwords of all encrypted private keys can be used automatically. When I connect to B from A this does not happen. For a mysterious reason even if I start a remote session (vnc / remmina) from A to B the program seahorse is not active in B and hence I have to manually insert the passwords over and over. I installed **keychain** and the problem has been solved. However, I am not sure if it is worth to encrypt a private key which is only used for SSH connection to a specific server. **Is there any concrete security risk by not encrypting the private keys?** In principle if one is able to access the private key he/she is also able to use the passwords stored in the keychain...so it seems that there might not be a big advantage in encrypting the private keys.


title: How to investigate a random reset on TCP client port connected via loopback interface to a server

text: I have a test suite which initializes a server on the localhost and then runs thousands of stress tests which include starting and stopping clients connecting to this local server on same machine. I am trying to find the reason for a RST sent by client to the server. This is the sequence of events:   1. client initializes SYN    2. Server sends back SYN,ACK    3. client sends RST (instead of ACK and establishing connection) One observation is on many occasions servers runs around 99 percent CPU although it returns back to normal in few seconds/minutes. Initially I thought this could be because client is using a port from previously closed connection which is in TIME_WAIT state and so when server sends a SYN,ACK on that connection client issues RST. Although I was skeptical as to why client should use a port in TIME_WAIT state but then I am using old fedora core 4 and thought may be it doesn't have proper implementation of TCP/IP :-). Now I don't believe that is the reason because all the tuning done around fixing above issue did not help alleviate the problem. FYI following are the changes I tried in `/etc/sysctl.conf`:               net.ipv4.ip_local_port_range = 1024     65535     net.ipv4.tcp_fin_timeout = 15     net.ipv4.tcp_rfc1337 = 1     net.ipv4.tcp_tw_reuse = 1      One more point, this issue isn't consistent. In fact I can reproduce this problem only after I go thru 15 to 35 cycles of Re-starting the server and running all client tests. I ran out of all the reasons I can think of why this could be happening so let me know if anyone has any ideas on what might be happening. Packet details               Date & Time                No.     Time        Source                Destination           Protocol Length Source port Dest port Info     2014-06-25 14:49:45.378209 1032719 1858.494749 ::1                   ::1                   TCP      94     netview-aix-5 navisphere netview-aix-5 > navisphere [SYN] Seq=0 Win=32752 Len=0 MSS=16376 SACK_PERM=1 TSval=1587252 TSecr=0 WS=128          Frame 1032719: 94 bytes on wire (752 bits), 94 bytes captured (752 bits)         Arrival Time: Jun 25, 2014 14:49:45.378209000 EDT         Epoch Time: 1403722185.378209000 seconds         [Time delta from previous captured frame: 0.005893000 seconds]         [Time delta from previous displayed frame: 0.000000000 seconds]         [Time since reference or first frame: 1858.494749000 seconds]         Frame Number: 1032719         Frame Length: 94 bytes (752 bits)         Capture Length: 94 bytes (752 bits)         [Frame is marked: False]         [Frame is ignored: False]         [Protocols in frame: eth:ipv6:tcp]         [Coloring Rule Name: TCP SYN/FIN]         [Coloring Rule String: tcp.flags & 0x02 || tcp.flags.fin == 1]     Ethernet II, Src: 00:00:00_00:00:00 (00:00:00:00:00:00), Dst: 00:00:00_00:00:00 (00:00:00:00:00:00)         Destination: 00:00:00_00:00:00 (00:00:00:00:00:00)             Address: 00:00:00_00:00:00 (00:00:00:00:00:00)             .... ...0 .... .... .... .... = IG bit: Individual address (unicast)             .... ..0. .... .... .... .... = LG bit: Globally unique address (factory default)         Source: 00:00:00_00:00:00 (00:00:00:00:00:00)             Address: 00:00:00_00:00:00 (00:00:00:00:00:00)             .... ...0 .... .... .... .... = IG bit: Individual address (unicast)             .... ..0. .... .... .... .... = LG bit: Globally unique address (factory default)         Type: IPv6 (0x86dd)     Internet Protocol Version 6, Src: ::1 (::1), Dst: ::1 (::1)         0110 .... = Version: 6             [0110 .... = This field makes the filter "ip.version == 6" possible: 6]         .... 0000 0000 .... .... .... .... .... = Traffic class: 0x00000000             .... 0000 00.. .... .... .... .... .... = Differentiated Services Field: Default (0x00000000)             .... .... ..0. .... .... .... .... .... = ECN-Capable Transport (ECT): Not set             .... .... ...0 .... .... .... .... .... = ECN-CE: Not set         .... .... .... 0000 0000 0000 0000 0000 = Flowlabel: 0x00000000         Payload length: 40         Next header: TCP (0x06)         Hop limit: 64         Source: ::1 (::1)         Destination: ::1 (::1)     Transmission Control Protocol, Src Port: netview-aix-5 (1665), Dst Port: navisphere (2162), Seq: 0, Len: 0         Source port: netview-aix-5 (1665)         Destination port: navisphere (2162)         [Stream index: 3374]         Sequence number: 0    (relative sequence number)         Header length: 40 bytes         Flags: 0x02 (SYN)             000. .... .... = Reserved: Not set             ...0 .... .... = Nonce: Not set             .... 0... .... = Congestion Window Reduced (CWR): Not set             .... .0.. .... = ECN-Echo: Not set             .... ..0. .... = Urgent: Not set             .... ...0 .... = Acknowledgement: Not set             .... .... 0... = Push: Not set             .... .... .0.. = Reset: Not set             .... .... ..1. = Syn: Set                 [Expert Info (Chat/Sequence): Connection establish request (SYN): server port navisphere]             .... .... ...0 = Fin: Not set         Window size value: 32752         [Calculated window size: 32752]         Checksum: 0xf489 [validation disabled]             [Good Checksum: False]             [Bad Checksum: False]         Options: (20 bytes)             Maximum segment size: 16376 bytes             TCP SACK Permitted Option: True             Timestamps: TSval 1587252, TSecr 0             No-Operation (NOP)             Window scale: 7 (multiply by 128)          Date & Time                No.     Time        Source                Destination           Protocol Length Source port Dest port Info     2014-06-25 14:49:45.378222 1032720 1858.494762 ::1                   ::1                   TCP      94     navisphere  netview-aix-5 navisphere > netview-aix-5 [SYN, ACK] Seq=0 Ack=1 Win=32728 Len=0 MSS=16376 SACK_PERM=1 TSval=1587252 TSecr=1587252 WS=128          Frame 1032720: 94 bytes on wire (752 bits), 94 bytes captured (752 bits)         Arrival Time: Jun 25, 2014 14:49:45.378222000 EDT         Epoch Time: 1403722185.378222000 seconds         [Time delta from previous captured frame: 0.000013000 seconds]         [Time delta from previous displayed frame: 0.000013000 seconds]         [Time since reference or first frame: 1858.494762000 seconds]         Frame Number: 1032720         Frame Length: 94 bytes (752 bits)         Capture Length: 94 bytes (752 bits)         [Frame is marked: False]         [Frame is ignored: False]         [Protocols in frame: eth:ipv6:tcp]         [Coloring Rule Name: TCP SYN/FIN]         [Coloring Rule String: tcp.flags & 0x02 || tcp.flags.fin == 1]     Ethernet II, Src: 00:00:00_00:00:00 (00:00:00:00:00:00), Dst: 00:00:00_00:00:00 (00:00:00:00:00:00)         Destination: 00:00:00_00:00:00 (00:00:00:00:00:00)             Address: 00:00:00_00:00:00 (00:00:00:00:00:00)             .... ...0 .... .... .... .... = IG bit: Individual address (unicast)             .... ..0. .... .... .... .... = LG bit: Globally unique address (factory default)         Source: 00:00:00_00:00:00 (00:00:00:00:00:00)             Address: 00:00:00_00:00:00 (00:00:00:00:00:00)             .... ...0 .... .... .... .... = IG bit: Individual address (unicast)             .... ..0. .... .... .... .... = LG bit: Globally unique address (factory default)         Type: IPv6 (0x86dd)     Internet Protocol Version 6, Src: ::1 (::1), Dst: ::1 (::1)         0110 .... = Version: 6             [0110 .... = This field makes the filter "ip.version == 6" possible: 6]         .... 0000 0000 .... .... .... .... .... = Traffic class: 0x00000000             .... 0000 00.. .... .... .... .... .... = Differentiated Services Field: Default (0x00000000)             .... .... ..0. .... .... .... .... .... = ECN-Capable Transport (ECT): Not set             .... .... ...0 .... .... .... .... .... = ECN-CE: Not set         .... .... .... 0000 0000 0000 0000 0000 = Flowlabel: 0x00000000         Payload length: 40         Next header: TCP (0x06)         Hop limit: 64         Source: ::1 (::1)         Destination: ::1 (::1)     Transmission Control Protocol, Src Port: navisphere (2162), Dst Port: netview-aix-5 (1665), Seq: 0, Ack: 1, Len: 0         Source port: navisphere (2162)         Destination port: netview-aix-5 (1665)         [Stream index: 3374]         Sequence number: 0    (relative sequence number)         Acknowledgement number: 1    (relative ack number)         Header length: 40 bytes         Flags: 0x12 (SYN, ACK)             000. .... .... = Reserved: Not set             ...0 .... .... = Nonce: Not set             .... 0... .... = Congestion Window Reduced (CWR): Not set             .... .0.. .... = ECN-Echo: Not set             .... ..0. .... = Urgent: Not set             .... ...1 .... = Acknowledgement: Set             .... .... 0... = Push: Not set             .... .... .0.. = Reset: Not set             .... .... ..1. = Syn: Set                 [Expert Info (Chat/Sequence): Connection establish acknowledge (SYN+ACK): server port navisphere]             .... .... ...0 = Fin: Not set         Window size value: 32728         [Calculated window size: 32728]         Checksum: 0xf7fa [validation disabled]             [Good Checksum: False]             [Bad Checksum: False]         Options: (20 bytes)             Maximum segment size: 16376 bytes             TCP SACK Permitted Option: True             Timestamps: TSval 1587252, TSecr 1587252             No-Operation (NOP)             Window scale: 7 (multiply by 128)         [SEQ/ACK analysis]             [This is an ACK to the segment in frame: 1032719]             [The RTT to ACK the segment was: 0.000013000 seconds]          Date & Time                No.     Time        Source                Destination           Protocol Length Source port Dest port Info     2014-06-25 14:49:45.378228 1032721 1858.494768 ::1                   ::1                   TCP      74     netview-aix-5 navisphere netview-aix-5 > navisphere [RST] Seq=1 Win=0 Len=0          Frame 1032721: 74 bytes on wire (592 bits), 74 bytes captured (592 bits)         Arrival Time: Jun 25, 2014 14:49:45.378228000 EDT         Epoch Time: 1403722185.378228000 seconds         [Time delta from previous captured frame: 0.000006000 seconds]         [Time delta from previous displayed frame: 0.000006000 seconds]         [Time since reference or first frame: 1858.494768000 seconds]         Frame Number: 1032721         Frame Length: 74 bytes (592 bits)         Capture Length: 74 bytes (592 bits)         [Frame is marked: False]         [Frame is ignored: False]         [Protocols in frame: eth:ipv6:tcp]         [Coloring Rule Name: TCP RST]         [Coloring Rule String: tcp.flags.reset eq 1]     Ethernet II, Src: 00:00:00_00:00:00 (00:00:00:00:00:00), Dst: 00:00:00_00:00:00 (00:00:00:00:00:00)         Destination: 00:00:00_00:00:00 (00:00:00:00:00:00)             Address: 00:00:00_00:00:00 (00:00:00:00:00:00)             .... ...0 .... .... .... .... = IG bit: Individual address (unicast)             .... ..0. .... .... .... .... = LG bit: Globally unique address (factory default)         Source: 00:00:00_00:00:00 (00:00:00:00:00:00)             Address: 00:00:00_00:00:00 (00:00:00:00:00:00)             .... ...0 .... .... .... .... = IG bit: Individual address (unicast)             .... ..0. .... .... .... .... = LG bit: Globally unique address (factory default)         Type: IPv6 (0x86dd)     Internet Protocol Version 6, Src: ::1 (::1), Dst: ::1 (::1)         0110 .... = Version: 6             [0110 .... = This field makes the filter "ip.version == 6" possible: 6]         .... 0000 0000 .... .... .... .... .... = Traffic class: 0x00000000             .... 0000 00.. .... .... .... .... .... = Differentiated Services Field: Default (0x00000000)             .... .... ..0. .... .... .... .... .... = ECN-Capable Transport (ECT): Not set             .... .... ...0 .... .... .... .... .... = ECN-CE: Not set         .... .... .... 0000 0000 0000 0000 0000 = Flowlabel: 0x00000000         Payload length: 20         Next header: TCP (0x06)         Hop limit: 64         Source: ::1 (::1)         Destination: ::1 (::1)     Transmission Control Protocol, Src Port: netview-aix-5 (1665), Dst Port: navisphere (2162), Seq: 1, Len: 0         Source port: netview-aix-5 (1665)         Destination port: navisphere (2162)         [Stream index: 3374]         Sequence number: 1    (relative sequence number)         Header length: 20 bytes         Flags: 0x04 (RST)             000. .... .... = Reserved: Not set             ...0 .... .... = Nonce: Not set             .... 0... .... = Congestion Window Reduced (CWR): Not set             .... .0.. .... = ECN-Echo: Not set             .... ..0. .... = Urgent: Not set             .... ...0 .... = Acknowledgement: Not set             .... .... 0... = Push: Not set             .... .... .1.. = Reset: Set                 [Expert Info (Chat/Sequence): Connection reset (RST)]             .... .... ..0. = Syn: Not set             .... .... ...0 = Fin: Not set         Window size value: 0         [Calculated window size: 0]         [Window size scaling factor: 128]         Checksum: 0x4eea [validation disabled]             [Good Checksum: False]             [Bad Checksum: False]          Date & Time                No.     Time        Source                Destination           Protocol Length Source port Dest port Info     2014-06-25 14:49:48.375927 1032722 1861.492467 ::1                   ::1                   TCP      94     netview-aix-5 navisphere netview-aix-5 > navisphere [SYN] Seq=0 Win=32752 Len=0 MSS=16376 SACK_PERM=1 TSval=1588002 TSecr=0 WS=128          Frame 1032722: 94 bytes on wire (752 bits), 94 bytes captured (752 bits)         Arrival Time: Jun 25, 2014 14:49:48.375927000 EDT         Epoch Time: 1403722188.375927000 seconds         [Time delta from previous captured frame: 2.997699000 seconds]         [Time delta from previous displayed frame: 2.997699000 seconds]         [Time since reference or first frame: 1861.492467000 seconds]         Frame Number: 1032722         Frame Length: 94 bytes (752 bits)         Capture Length: 94 bytes (752 bits)         [Frame is marked: False]         [Frame is ignored: False]         [Protocols in frame: eth:ipv6:tcp]         [Coloring Rule Name: TCP SYN/FIN]         [Coloring Rule String: tcp.flags & 0x02 || tcp.flags.fin == 1]     Ethernet II, Src: 00:00:00_00:00:00 (00:00:00:00:00:00), Dst: 00:00:00_00:00:00 (00:00:00:00:00:00)         Destination: 00:00:00_00:00:00 (00:00:00:00:00:00)             Address: 00:00:00_00:00:00 (00:00:00:00:00:00)             .... ...0 .... .... .... .... = IG bit: Individual address (unicast)             .... ..0. .... .... .... .... = LG bit: Globally unique address (factory default)         Source: 00:00:00_00:00:00 (00:00:00:00:00:00)             Address: 00:00:00_00:00:00 (00:00:00:00:00:00)             .... ...0 .... .... .... .... = IG bit: Individual address (unicast)             .... ..0. .... .... .... .... = LG bit: Globally unique address (factory default)         Type: IPv6 (0x86dd)     Internet Protocol Version 6, Src: ::1 (::1), Dst: ::1 (::1)         0110 .... = Version: 6             [0110 .... = This field makes the filter "ip.version == 6" possible: 6]         .... 0000 0000 .... .... .... .... .... = Traffic class: 0x00000000             .... 0000 00.. .... .... .... .... .... = Differentiated Services Field: Default (0x00000000)             .... .... ..0. .... .... .... .... .... = ECN-Capable Transport (ECT): Not set             .... .... ...0 .... .... .... .... .... = ECN-CE: Not set         .... .... .... 0000 0000 0000 0000 0000 = Flowlabel: 0x00000000         Payload length: 40         Next header: TCP (0x06)         Hop limit: 64         Source: ::1 (::1)         Destination: ::1 (::1)     Transmission Control Protocol, Src Port: netview-aix-5 (1665), Dst Port: navisphere (2162), Seq: 0, Len: 0         Source port: netview-aix-5 (1665)         Destination port: navisphere (2162)         [Stream index: 3374]         Sequence number: 0    (relative sequence number)         Header length: 40 bytes         Flags: 0x02 (SYN)             000. .... .... = Reserved: Not set             ...0 .... .... = Nonce: Not set             .... 0... .... = Congestion Window Reduced (CWR): Not set             .... .0.. .... = ECN-Echo: Not set             .... ..0. .... = Urgent: Not set             .... ...0 .... = Acknowledgement: Not set             .... .... 0... = Push: Not set             .... .... .0.. = Reset: Not set             .... .... ..1. = Syn: Set                 [Expert Info (Chat/Sequence): Connection establish request (SYN): server port navisphere]             .... .... ...0 = Fin: Not set         Window size value: 32752         [Calculated window size: 32752]         Checksum: 0xf19b [validation disabled]             [Good Checksum: False]             [Bad Checksum: False]         Options: (20 bytes)             Maximum segment size: 16376 bytes             TCP SACK Permitted Option: True             Timestamps: TSval 1588002, TSecr 0             No-Operation (NOP)             Window scale: 7 (multiply by 128)          Date & Time                No.     Time        Source                Destination           Protocol Length Source port Dest port Info     2014-06-25 14:49:48.375950 1032723 1861.492490 ::1                   ::1                   TCP      94     navisphere  netview-aix-5 [TCP Previous segment lost] navisphere > netview-aix-5 [SYN, ACK] Seq=2997725 Ack=1 Win=32728 Len=0 MSS=16376 SACK_PERM=1 TSval=1588002 TSecr=1588002 WS=128          Frame 1032723: 94 bytes on wire (752 bits), 94 bytes captured (752 bits)         Arrival Time: Jun 25, 2014 14:49:48.375950000 EDT         Epoch Time: 1403722188.375950000 seconds         [Time delta from previous captured frame: 0.000023000 seconds]         [Time delta from previous displayed frame: 0.000023000 seconds]         [Time since reference or first frame: 1861.492490000 seconds]         Frame Number: 1032723         Frame Length: 94 bytes (752 bits)         Capture Length: 94 bytes (752 bits)         [Frame is marked: False]         [Frame is ignored: False]         [Protocols in frame: eth:ipv6:tcp]         [Coloring Rule Name: Bad TCP]         [Coloring Rule String: tcp.analysis.flags]     Ethernet II, Src: 00:00:00_00:00:00 (00:00:00:00:00:00), Dst: 00:00:00_00:00:00 (00:00:00:00:00:00)         Destination: 00:00:00_00:00:00 (00:00:00:00:00:00)             Address: 00:00:00_00:00:00 (00:00:00:00:00:00)             .... ...0 .... .... .... .... = IG bit: Individual address (unicast)             .... ..0. .... .... .... .... = LG bit: Globally unique address (factory default)         Source: 00:00:00_00:00:00 (00:00:00:00:00:00)             Address: 00:00:00_00:00:00 (00:00:00:00:00:00)             .... ...0 .... .... .... .... = IG bit: Individual address (unicast)             .... ..0. .... .... .... .... = LG bit: Globally unique address (factory default)         Type: IPv6 (0x86dd)     Internet Protocol Version 6, Src: ::1 (::1), Dst: ::1 (::1)         0110 .... = Version: 6             [0110 .... = This field makes the filter "ip.version == 6" possible: 6]         .... 0000 0000 .... .... .... .... .... = Traffic class: 0x00000000             .... 0000 00.. .... .... .... .... .... = Differentiated Services Field: Default (0x00000000)             .... .... ..0. .... .... .... .... .... = ECN-Capable Transport (ECT): Not set             .... .... ...0 .... .... .... .... .... = ECN-CE: Not set         .... .... .... 0000 0000 0000 0000 0000 = Flowlabel: 0x00000000         Payload length: 40         Next header: TCP (0x06)         Hop limit: 64         Source: ::1 (::1)         Destination: ::1 (::1)     Transmission Control Protocol, Src Port: navisphere (2162), Dst Port: netview-aix-5 (1665), Seq: 2997725, Ack: 1, Len: 0         Source port: navisphere (2162)         Destination port: netview-aix-5 (1665)         [Stream index: 3374]         Sequence number: 2997725    (relative sequence number)         Acknowledgement number: 1    (relative ack number)         Header length: 40 bytes         Flags: 0x12 (SYN, ACK)             000. .... .... = Reserved: Not set             ...0 .... .... = Nonce: Not set             .... 0... .... = Congestion Window Reduced (CWR): Not set             .... .0.. .... = ECN-Echo: Not set             .... ..0. .... = Urgent: Not set             .... ...1 .... = Acknowledgement: Set             .... .... 0... = Push: Not set             .... .... .0.. = Reset: Not set             .... .... ..1. = Syn: Set                 [Expert Info (Chat/Sequence): Connection establish acknowledge (SYN+ACK): server port navisphere]             .... .... ...0 = Fin: Not set         Window size value: 32728         [Calculated window size: 32728]         Checksum: 0x3414 [validation disabled]             [Good Checksum: False]             [Bad Checksum: False]         Options: (20 bytes)             Maximum segment size: 16376 bytes             TCP SACK Permitted Option: True             Timestamps: TSval 1588002, TSecr 1588002             No-Operation (NOP)             Window scale: 7 (multiply by 128)         [SEQ/ACK analysis]             [This is an ACK to the segment in frame: 1032722]             [The RTT to ACK the segment was: 0.000023000 seconds]             [TCP Analysis Flags]                 [A segment before this frame was lost]                     [Expert Info (Warn/Sequence): Previous segment lost (common at capture start)]          Date & Time                No.     Time        Source                Destination           Protocol Length Source port Dest port Info     2014-06-25 14:49:48.375958 1032724 1861.492498 ::1                   ::1                   TCP      74     netview-aix-5 navisphere netview-aix-5 > navisphere [RST] Seq=1 Win=0 Len=0          Frame 1032724: 74 bytes on wire (592 bits), 74 bytes captured (592 bits)         Arrival Time: Jun 25, 2014 14:49:48.375958000 EDT         Epoch Time: 1403722188.375958000 seconds         [Time delta from previous captured frame: 0.000008000 seconds]         [Time delta from previous displayed frame: 0.000008000 seconds]         [Time since reference or first frame: 1861.492498000 seconds]         Frame Number: 1032724         Frame Length: 74 bytes (592 bits)         Capture Length: 74 bytes (592 bits)         [Frame is marked: False]         [Frame is ignored: False]         [Protocols in frame: eth:ipv6:tcp]         [Coloring Rule Name: TCP RST]         [Coloring Rule String: tcp.flags.reset eq 1]     Ethernet II, Src: 00:00:00_00:00:00 (00:00:00:00:00:00), Dst: 00:00:00_00:00:00 (00:00:00:00:00:00)         Destination: 00:00:00_00:00:00 (00:00:00:00:00:00)             Address: 00:00:00_00:00:00 (00:00:00:00:00:00)             .... ...0 .... .... .... .... = IG bit: Individual address (unicast)             .... ..0. .... .... .... .... = LG bit: Globally unique address (factory default)         Source: 00:00:00_00:00:00 (00:00:00:00:00:00)             Address: 00:00:00_00:00:00 (00:00:00:00:00:00)             .... ...0 .... .... .... .... = IG bit: Individual address (unicast)             .... ..0. .... .... .... .... = LG bit: Globally unique address (factory default)         Type: IPv6 (0x86dd)     Internet Protocol Version 6, Src: ::1 (::1), Dst: ::1 (::1)         0110 .... = Version: 6             [0110 .... = This field makes the filter "ip.version == 6" possible: 6]         .... 0000 0000 .... .... .... .... .... = Traffic class: 0x00000000             .... 0000 00.. .... .... .... .... .... = Differentiated Services Field: Default (0x00000000)             .... .... ..0. .... .... .... .... .... = ECN-Capable Transport (ECT): Not set             .... .... ...0 .... .... .... .... .... = ECN-CE: Not set         .... .... .... 0000 0000 0000 0000 0000 = Flowlabel: 0x00000000         Payload length: 20         Next header: TCP (0x06)         Hop limit: 64         Source: ::1 (::1)         Destination: ::1 (::1)     Transmission Control Protocol, Src Port: netview-aix-5 (1665), Dst Port: navisphere (2162), Seq: 1, Len: 0         Source port: netview-aix-5 (1665)         Destination port: navisphere (2162)         [Stream index: 3374]         Sequence number: 1    (relative sequence number)         Header length: 20 bytes         Flags: 0x04 (RST)             000. .... .... = Reserved: Not set             ...0 .... .... = Nonce: Not set             .... 0... .... = Congestion Window Reduced (CWR): Not set             .... .0.. .... = ECN-Echo: Not set             .... ..0. .... = Urgent: Not set             .... ...0 .... = Acknowledgement: Not set             .... .... 0... = Push: Not set             .... .... .1.. = Reset: Set                 [Expert Info (Chat/Sequence): Connection reset (RST)]             .... .... ..0. = Syn: Not set             .... .... ...0 = Fin: Not set         Window size value: 0         [Calculated window size: 0]         [Window size scaling factor: 128]         Checksum: 0x4eea [validation disabled]             [Good Checksum: False]             [Bad Checksum: False]          Date & Time                No.     Time        Source                Destination           Protocol Length Source port Dest port Info     2014-06-25 14:49:54.376072 1032725 1867.492612 ::1                   ::1                   TCP      94     netview-aix-5 navisphere netview-aix-5 > navisphere [SYN] Seq=0 Win=32752 Len=0 MSS=16376 SACK_PERM=1 TSval=1589502 TSecr=0 WS=128          Frame 1032725: 94 bytes on wire (752 bits), 94 bytes captured (752 bits)         Arrival Time: Jun 25, 2014 14:49:54.376072000 EDT         Epoch Time: 1403722194.376072000 seconds         [Time delta from previous captured frame: 6.000114000 seconds]         [Time delta from previous displayed frame: 6.000114000 seconds]         [Time since reference or first frame: 1867.492612000 seconds]         Frame Number: 1032725         Frame Length: 94 bytes (752 bits)         Capture Length: 94 bytes (752 bits)         [Frame is marked: False]         [Frame is ignored: False]         [Protocols in frame: eth:ipv6:tcp]         [Coloring Rule Name: TCP SYN/FIN]         [Coloring Rule String: tcp.flags & 0x02 || tcp.flags.fin == 1]     Ethernet II, Src: 00:00:00_00:00:00 (00:00:00:00:00:00), Dst: 00:00:00_00:00:00 (00:00:00:00:00:00)         Destination: 00:00:00_00:00:00 (00:00:00:00:00:00)             Address: 00:00:00_00:00:00 (00:00:00:00:00:00)             .... ...0 .... .... .... .... = IG bit: Individual address (unicast)             .... ..0. .... .... .... .... = LG bit: Globally unique address (factory default)         Source: 00:00:00_00:00:00 (00:00:00:00:00:00)             Address: 00:00:00_00:00:00 (00:00:00:00:00:00)             .... ...0 .... .... .... .... = IG bit: Individual address (unicast)             .... ..0. .... .... .... .... = LG bit: Globally unique address (factory default)         Type: IPv6 (0x86dd)     Internet Protocol Version 6, Src: ::1 (::1), Dst: ::1 (::1)         0110 .... = Version: 6             [0110 .... = This field makes the filter "ip.version == 6" possible: 6]         .... 0000 0000 .... .... .... .... .... = Traffic class: 0x00000000             .... 0000 00.. .... .... .... .... .... = Differentiated Services Field: Default (0x00000000)             .... .... ..0. .... .... .... .... .... = ECN-Capable Transport (ECT): Not set             .... .... ...0 .... .... .... .... .... = ECN-CE: Not set         .... .... .... 0000 0000 0000 0000 0000 = Flowlabel: 0x00000000         Payload length: 40         Next header: TCP (0x06)         Hop limit: 64         Source: ::1 (::1)         Destination: ::1 (::1)     Transmission Control Protocol, Src Port: netview-aix-5 (1665), Dst Port: navisphere (2162), Seq: 0, Len: 0         Source port: netview-aix-5 (1665)         Destination port: navisphere (2162)         [Stream index: 3374]         Sequence number: 0    (relative sequence number)         Header length: 40 bytes         Flags: 0x02 (SYN)             000. .... .... = Reserved: Not set             ...0 .... .... = Nonce: Not set             .... 0... .... = Congestion Window Reduced (CWR): Not set             .... .0.. .... = ECN-Echo: Not set             .... ..0. .... = Urgent: Not set             .... ...0 .... = Acknowledgement: Not set             .... .... 0... = Push: Not set             .... .... .0.. = Reset: Not set             .... .... ..1. = Syn: Set                 [Expert Info (Chat/Sequence): Connection establish request (SYN): server port navisphere]             .... .... ...0 = Fin: Not set         Window size value: 32752         [Calculated window size: 32752]         Checksum: 0xebbf [validation disabled]             [Good Checksum: False]             [Bad Checksum: False]         Options: (20 bytes)             Maximum segment size: 16376 bytes             TCP SACK Permitted Option: True             Timestamps: TSval 1589502, TSecr 0             No-Operation (NOP)             Window scale: 7 (multiply by 128)      `iptables-save` output:               # Generated by iptables-save v1.3.0 on Thu Jun 26 10:15:33 2014     *filter     :FORWARD ACCEPT [0:0]     :INPUT ACCEPT [675:236200]     :OUTPUT ACCEPT [241:21540]     COMMIT     # Completed on Thu Jun 26 10:15:33 2014


title: keep aliases when I use sudo bash

text: I have a Centos 5.5 server that has my own alias commands for my account. When I do "sudo bash" I can still use those aliases, I didn't have to add the aliases to the root bashrc. I have another server that is Centos 6.5. But when I sudo bash it will not use my aliases of the user that I'm logged in as. Does anyone know where I configure it to include the aliases of the user I am logged into when I use sudo bash?


title: How to discard/TRIM a range in an open file ?

text: For an SSD, I can open the row device and discard a range of pages using `ioctl()` with `BLKDISCARD` command. My question is for an open file, how to discard a range of data? and Is that depends on the implementation of the underlying filesystem?


title: Can I create a 2 TB RAID-1 array out of one 2 TB disk and two 1 TB disks while preserving 1 TB of data?

text: I currently have 1 TB of data on a RAID-1 mdadm array. This array consists of one 1 TB disk and a 1 TB partition on a 2 TB disk. I have now bought a second 1 TB disk, and I would like to use this to create a 2 TB RAID-1 array. The data on this array will be encrypted with dm-crypt, so I want to overwrite each disk with data from `/dev/urandom` before putting data on it. The question is if I can create this 2 TB RAID-1 array, and securely overwrite each disk with random data while preserving the 1 TB of data I have on my current 1 TB RAID-1 array. So to recap: I have 2 x 1 TB disks and 1 x 2 TB disk. I want to create a 2 TB RAID-1 array where one side of the mirror consists of two 1 TB disks pooled together, and the other side of the mirror is the whole 2 TB disk. Also, I want to preserve 1 TB of data using only these disks, while still being able to overwrite each disk with random data.


title: What is a good way of layering zfs filsystems to manage unpredictable future workload that doesn't severely compromise performance?

text: I've been playing around with ZFS and using sparse files as virtual devices to learn how to use the zfs tools. It seems that there isn't much of a hit in performance by creating a raid pool out of sparse files which are on top of JBOD filesystems that are located on different devices. So I'm wondering if this is a good way to have a flexible system going forward seen as it's not possible to shrink zfs filesystems. So for example I have four disks. Each one has a single device filesystem on it. I create 4 sparse files, one on each filesystem therefore disk. The load is spread across the devices and they are also providing redundancy. Until the raid array fills, I still have all the rest of the disk space for some things which may not need raid such as temporary bulky files. I expect that there would be a major performance penalty when both types of filesystem would be busy at the same time. Are there some more pros and cons of such an approach?


title: How to use `cat` or `less` depending on the line count?

text: When looking at the content of files, I'd like to automatically `cat` short files but `less` those that exceed the screen size. I could use something with `wc -l`, but is there a better way that maybe also considers the window size / current amount of lines available?


title: Easily unpack DEB, edit postinst, and repack DEB

text: I'm attempting to install Intel's OpenCL SDK but the DEB files are buggy conversions from RPM (see https://software.intel.com/en-us/forums/topic/515680 for the curious). I need to edit the `postinst` script in the DEB they provide. How can I take an existing DEB, extract the contents (including the control information), then later repackage the contents to make a new DEB? I will only edit files, no files will be added or removed.


title: What is the most correct way to pass an array to a function?

text: Consider I have a very large array `$large_list`, is there a way to write a function that will take the array as an argument? For example:               echo_idx_array () {         arr="$1"         idx="$2"              echo "${arr[$idx]}"     }      What is the usual strategy to do something like that? I tried giving the variable `$large_list` but it was empty. I am willing to modify the function to adapt it to any change in the argument list. For the record, I am using ksh88, and I am looking for answers as portable as can be. * * * **EDIT** : So far the best I could come up with is to loop through the array and send each element as an argument to the function. This seems incredibly ugly and error-prone, not to mention that it is bound to hit some limit quickly. Here's what I did:               foo () {         echo $*     }          cmd="foo "     while [[ $i -lt $MAX_ARR_SIZE ]]; do         cmd="$cmd ${large_list[$i]}"         ((i=i+1))     done          eval $cmd      Isn't there something better to do?


title: Table align in two column page style in IEEEtran latex

text: I am writing a paper using the IEEEtran class. I need to insert a 3 tables in the top of the 3rd page in the two column page style. my table having 15 columns and 4 rows..... can anybody tell how to do this..... thanks in advance


title: dpkg: warning: 'ldconfig' not found in PATH or not executable - Ubuntu 12 - Vagrant

text: I am working on setting up a Vagrant / Puppet install so that new developers can have a clean development environment for our Rails project. The basic Vagrant configure commands are:                 config.vm.box      = 'precise32'       config.vm.box_url  = 'http://files.vagrantup.com/precise32.box'      Overall, the install seems to be going well. I've got RVM, Postgres, and Ruby installed and running. However, whenever I try to install the "Heroku Toolbelt" using this command:               su -l vagrant -c 'wget -qO- https://toolbelt.heroku.com/install-ubuntu.sh | sh'      I run into this problem:               ... Lots of Hits and downloads...     The following extra packages will be installed:       foreman heroku libruby1.9.1 ruby1.9.1     Suggested packages:       ruby1.9.1-examples ri1.9.1 graphviz ruby1.9.1-dev     The following NEW packages will be installed:       foreman heroku heroku-toolbelt libruby1.9.1 ruby1.9.1     0 upgraded, 5 newly installed, 0 to remove and 132 not upgraded.     Need to get 0 B/4,997 kB of archives.     After this operation, 13.1 MB of additional disk space will be used.     dpkg: warning: 'ldconfig' not found in PATH or not executable.     dpkg: warning: 'start-stop-daemon' not found in PATH or not executable.     dpkg: error: 2 expected programs not found in PATH or not executable.     Note: root's PATH should usually contain /usr/local/sbin, /usr/sbin and /sbin.     E: Sub-process /usr/bin/dpkg returned an error code (2)      ( _Note_ ) This happens if I run the command manually after vagrant ssh. Also, the actual shell configuration gets the error when it initially runs. Since this is a vagrant box, it is easy to 'vagrant destroy' and then try again but I get the same issue consistently. The strange thing is, my PATH does definitely include those folders:               echo $PATH     /home/vagrant/.rvm/gems/ruby-1.9.3-p194/bin:/home/vagrant/.rvm/gems/ruby-1.9.3-p194@global/bin:/home/vagrant/.rvm/rubies/ruby-1.9.3-p194/bin:/home/vagrant/.rvm/bin:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/usr/games:/opt/vagrant_ruby/bin      the file 'ldconfig' is in /sbin and is an executable:               cd /sbin     ls -l l*     -rwxr-xr-x 1 root root    465 Apr 20  2012 ldconfig      Same with start-stop-daemon:               -rwxr-xr-x 1 root root 26752 Apr 12  2012 start-stop-daemon      So, not sure what it is really complaining about... Any suggestions? Some permissions issue with Vagrant?


title: I ran fdisk on a wrong drive. How can I recover

text: I ran **fdisk** on the wrong HD. I basically cleared partition table, pressed **w** and quited fdisk and only then realized that that was my main harddrive... I got this message: > WARNING: Re-reading the partition table failed with error 16: Device or > resource busy. The kernel still uses the old table. The new table will be > used at the next reboot or after you run partprobe(8) or kpartx(8) Syncing > disks. I looked through /sys/class/block/sdb/sdb* start and size files - I knew that that's were kernel kept old partition offsets and sizes until restart... And here's my table reconstruction.               name  |  startsector  | size, sectors  | type?                     ------------------------------------------------------------          sdb1  |  2048         | 2048           |        sdb2  |  195510270    | 2              |        sdb3  |  4096         | 195504128      | /       sdb5  |  195510272    | 761716736      | /home       sdb6  |  957229056    | 19542016       | swap partition         Here's testing for what type of partition there were:               cr1tter@cr1tterhost:~$ sudo file -s /dev/sdb{1,2,3,5,6}     /dev/sdb1: data     /dev/sdb2: x86 boot sector; partition 1: ID=0x83, starthead 254, startsector 2, 761716736 sectors; partition 2: ID=0x5, starthead 254, startsector 761716738, 19544064 sectors, code offset 0x97     /dev/sdb3: Linux rev 1.0 ext4 filesystem data, UUID=b6d939b9-c197-4513-a1fe-9c614574afb0 (needs journal recovery) (extents) (large files) (huge files)     /dev/sdb5: Linux rev 1.0 ext4 filesystem data, UUID=96f97705-f292-49db-b31d-249fab87d3d7 (needs journal recovery) (extents) (large files) (huge files)     /dev/sdb6: Linux/i386 swap file (new style), version 1 (4K pages), size 2442751 pages, no label, UUID=a5744b72-248c-4ceb-8009-db6351cdc231      I guess I'm confused what **sdb1** and **sdb2** are? I honestly cannot recall what they are.... When I was installing os - I had to specify paths, as in /home, or root path: / - fdisk doesn't seem to allow to do that... P.S> RESOLVED. Thank you Jim Paris! HERE's the transcript of what I've done. I've already rebooted and system is working just as well..!               sudo fdisk /dev/sdb     Command (m for help): p          Disk /dev/sdb: 500.1 GB, 500107862016 bytes     255 heads, 63 sectors/track, 60801 cylinders, total 976773168 sectors     Units = sectors of 1 * 512 = 512 bytes     Sector size (logical/physical): 512 bytes / 512 bytes     I/O size (minimum/optimal): 512 bytes / 512 bytes     Disk identifier: 0x000cd649             Device Boot      Start         End      Blocks   Id  System          Command (m for help): n     Partition type:        p   primary (0 primary, 0 extended, 4 free)        e   extended     Select (default p): p     Partition number (1-4, default 1): 1     First sector (2048-976773167, default 2048):      Using default value 2048     Last sector, +sectors or +size{K,M,G} (2048-976773167, default 976773167): +1M          Command (m for help): p          Disk /dev/sdb: 500.1 GB, 500107862016 bytes     255 heads, 63 sectors/track, 60801 cylinders, total 976773168 sectors     Units = sectors of 1 * 512 = 512 bytes     Sector size (logical/physical): 512 bytes / 512 bytes     I/O size (minimum/optimal): 512 bytes / 512 bytes     Disk identifier: 0x000cd649             Device Boot      Start         End      Blocks   Id  System     /dev/sdb1            2048        4095        1024   83  Linux          Command (m for help): n     Partition type:        p   primary (1 primary, 0 extended, 3 free)        e   extended     Select (default p): p     Partition number (1-4, default 2): 3     First sector (4096-976773167, default 4096):      Using default value 4096     Last sector, +sectors or +size{K,M,G} (4096-976773167, default 976773167): +95461M          Command (m for help): t     Partition number (1-4): 3     Hex code (type L to list codes): 83          Command (m for help): n     Partition type:        p   primary (2 primary, 0 extended, 2 free)        e   extended     Select (default p): e     Partition number (1-4, default 2):      Using default value 2     First sector (195508224-976773167, default 195508224):      Using default value 195508224     Last sector, +sectors or +size{K,M,G} (195508224-976773167, default 976773167):      Using default value 976773167          Command (m for help): n     Partition type:        p   primary (2 primary, 1 extended, 1 free)        l   logical (numbered from 5)     Select (default p): l     Adding logical partition 5     First sector (195510272-976773167, default 195510272):      Using default value 195510272     Last sector, +sectors or +size{K,M,G} (195510272-976773167, default 976773167): +371932M          Command (m for help): t     Partition number (1-5): 5     Hex code (type L to list codes): 83          Command (m for help): n     Partition type:        p   primary (2 primary, 1 extended, 1 free)        l   logical (numbered from 5)     Select (default p): l     Adding logical partition 6     First sector (957229056-976773167, default 957229056):      Using default value 957229056     Last sector, +sectors or +size{K,M,G} (957229056-976773167, default 976773167): +9542M          Command (m for help): t     Partition number (1-6): 6     Hex code (type L to list codes): L           0  Empty           24  NEC DOS         81  Minix / old Lin bf  Solaris              1  FAT12           27  Hidden NTFS Win 82  Linux swap / So c1  DRDOS/sec (FAT-      2  XENIX root      39  Plan 9          83  Linux           c4  DRDOS/sec (FAT-      3  XENIX usr       3c  PartitionMagic  84  OS/2 hidden C:  c6  DRDOS/sec (FAT-      4  FAT16 <32M      40  Venix 80286     85  Linux extended  c7  Syrinx               5  Extended        41  PPC PReP Boot   86  NTFS volume set da  Non-FS data          6  FAT16           42  SFS             87  NTFS volume set db  CP/M / CTOS / .      7  HPFS/NTFS/exFAT 4d  QNX4.x          88  Linux plaintext de  Dell Utility         8  AIX             4e  QNX4.x 2nd part 8e  Linux LVM       df  BootIt               9  AIX bootable    4f  QNX4.x 3rd part 93  Amoeba          e1  DOS access           a  OS/2 Boot Manag 50  OnTrack DM      94  Amoeba BBT      e3  DOS R/O              b  W95 FAT32       51  OnTrack DM6 Aux 9f  BSD/OS          e4  SpeedStor            c  W95 FAT32 (LBA) 52  CP/M            a0  IBM Thinkpad hi eb  BeOS fs              e  W95 FAT16 (LBA) 53  OnTrack DM6 Aux a5  FreeBSD         ee  GPT                  f  W95 Ext'd (LBA) 54  OnTrackDM6      a6  OpenBSD         ef  EFI (FAT-12/16/     10  OPUS            55  EZ-Drive        a7  NeXTSTEP        f0  Linux/PA-RISC b     11  Hidden FAT12    56  Golden Bow      a8  Darwin UFS      f1  SpeedStor           12  Compaq diagnost 5c  Priam Edisk     a9  NetBSD          f4  SpeedStor           14  Hidden FAT16 <3 61  SpeedStor       ab  Darwin boot     f2  DOS secondary       16  Hidden FAT16    63  GNU HURD or Sys af  HFS / HFS+      fb  VMware VMFS         17  Hidden HPFS/NTF 64  Novell Netware  b7  BSDI fs         fc  VMware VMKCORE      18  AST SmartSleep  65  Novell Netware  b8  BSDI swap       fd  Linux raid auto     1b  Hidden W95 FAT3 70  DiskSecure Mult bb  Boot Wizard hid fe  LANstep             1c  Hidden W95 FAT3 75  PC/IX           be  Solaris boot    ff  BBT                 1e  Hidden W95 FAT1 80  Old Minix           Hex code (type L to list codes): 82      Changed system type of partition 6 to 82 (Linux swap / Solaris)               Command (m for help): a     Partition number (1-6): 1               Command (m for help): p          Disk /dev/sdb: 500.1 GB, 500107862016 bytes     255 heads, 63 sectors/track, 60801 cylinders, total 976773168 sectors     Units = sectors of 1 * 512 = 512 bytes     Sector size (logical/physical): 512 bytes / 512 bytes     I/O size (minimum/optimal): 512 bytes / 512 bytes     Disk identifier: 0x000cd649             Device Boot      Start         End      Blocks   Id  System     /dev/sdb1   *        2048        4095        1024   83  Linux     /dev/sdb2       195508224   976773167   390632472    5  Extended     /dev/sdb3            4096   195508223    97752064   83  Linux     /dev/sdb5       195510272   957227007   380858368   83  Linux     /dev/sdb6       957229056   976771071     9771008   82  Linux swap / Solaris          Partition table entries are not in disk order          Command (m for help): w     The partition table has been altered!          Calling ioctl() to re-read partition table.          WARNING: Re-reading the partition table failed with error 16: Device or resource busy.     The kernel still uses the old table. The new table will be used at     the next reboot or after you run partprobe(8) or kpartx(8)     Syncing disks.


title: place the aliased version of an existing command in /usr/bin/

text: I use **Vim** a lot, and I know how I can start vim in insert mode. So I have an alias named `vii` in my `.bash_aliases` file. On other hand I use **Git** a lot too, and I have this line in my `.gitconfig`:               [core]         editor = vi      To write a commit message the vi editor is opened every time and I have to go in insert mode. So I thought of replacing `vi` with `vii`, and did. But the problem is when I do `git commit`, instead of opening the vim in insert mode, it gives this error:               error: cannot run vii: No such file or directory     error: There was a problem with the editor 'vii'.     Please supply the message using either -m or -F option.      This makes clear that git does not looks to `.bash_aliases` file, even it isn't related to bash in any way. It does directly looks if there is `/usr/bin/vii` or not. And executes it if it is. ### The Question Can I place the aliased version of vi as `vii` in `/usr/bin/`? _(and please don't suggest me to use`git commit -m "<commit message>"`. There are other situation where I need vim in insert mode.)_


title: Merge multiple flv files?

text: What tool in Linux can I use to merge multiple flv files ? Files are already in order, just put them altogether seamlessly


title: How to chmod without /usr/bin/chmod?

text: Today I was told a tale by a Unix trainer, a tale where the root password got leaked to the students, and one of the fellas removed the execute permission from /usr/bin/chmod itself. How do you recover chmod in this case and make it executable again? Let's say getting it from an external source or recompiling it is not a preferable option, is there some smart hack that can recover this chmod itself? Note that this happened a long time ago and I'm not looking for a solution for some current problem, just curious about what ways Unix provides us around such an issue.


title: is squid 2.x configuration still roughly the same as for squid 3.x?

text: I have the o'reilly squid book which covers squid 2.x - will this book still be useful for me to configure squid 3.x, or has too much changed between the versions? Is there any documentation describing the configuration differences between 2.x and 3.x?


title: Multiple SSH tunnels (local and remote forwarding) over one master OpenSSH connection? Good idea?

text: The question Using an already established SSH channel has an answer that intrigued me. It suggests that I can reuse an existing SSH connection. However, after further reading, I see that this solution may not work in my case (multiple tunnels at the same time). I'm using OpenSSH_5.9p1 Debian-5ubuntu1.1, OpenSSL 1.0.1 14 Mar 2012 (on Kubuntu 12.04). Here is what I'm currently doing in a bash script:               echo "establishing SSH tunnel for SFTP && opening Dolpin with SFTP connection to remote computer..."     ssh -i "$ID_RSA" "$MIDDLEMAN_USER@$MIDDLEMAN_SERVER" -fL $PORT_NUMBER:localhost:$PORT_NUMBER sleep 20; dolphin sftp://HostSftp:$PORT_NUMBER &          echo "establishing SSH tunnel for VNC && connecting to VNC server for remote desktop support..."     sudo ssh -fL 5901:localhost:$VNC_PORT_NUMBER -i "$ID_RSA" "$MIDDLEMAN_USER@$MIDDLEMAN_SERVER" sleep 20; vncviewer localhost:5901      My concerns (why I think this might not work for me) include things like this: > A negative to this is that some uses of ssh may fail to work with your > multiplexed connection. Most notably commands which use tunneling like git, > svn or rsync, or forwarding a port. Source and this: > If you use LocalForward or RemoteForward in your configuration file, you > might run into a subtle problem. ... SSH1 ( **but not OpenSSH** ) provides a > solution. Source I'm looking for clarification as well as instruction:   1. Can I establish the two tunnels above with one master connection?   2. Will this be as reliable as establishing separate connections?   3. If yes to both the above, how do I do it? Thanks


title: How to load Facebook chat history in KDE Telepathy?

text: I've started using IM client for lower bandwidth usage - no images and other stuff. However, a lot of people writing me refers to context written in older posts. Therefore I've got to go to facebook's site and load all unnecessary stuff... So I would like to load few older messages when I open chat window. Is it somehow possible?


title: Passing values to a parameter in script

text: Following is the script to copy all libraries of a certain command to make my chroot environment. For example: `./cplb.sh /bin/ls` will copy all the libraries of `ls` command (i.e., the files listed by `ldd /bin/ls` command). **cplb.sh**               CHROOT='/var/chroot'     mkdir $CHROOT          for i in $( ldd $* |cut -d " " -f3 |sort |uniq)     do     cp --parents $i $CHROOT     done          echo "Chroot jail is ready. To access it execute: chroot $CHROOT" Now, when I run `./cplb.sh /bin/ls` it works like a charm. But when I run it for multiple commands at the same time, for example: `./cplb.sh /bin/{ls,cat}` it throws an error saying:               cannot stat : '/bin/ls:' file or dir not found     cannot stat : '/bin/cat:' file or dir not found      I can see a colon after the command, i.e., `/bin/ls:` and that colon causes the error. Now, where does it come from and how to resolve this, so that I can run the script for multiple commands at the same time?


title: linux command to check POSIX message queue

text: We can check the details of system V message queue with the help of `ipcs`command. Is there any command to check POSIX message queue in Linux?


title: Transfering files using ssh

text: I've found the following command pretty convenient for transferring files to servers I have ssh access to:               cat myfile.txt | ssh my.host.edu "cat > myfile.txt"      Is there a similarly convenient command for bringing files to my local computer? If it would make it any easier, I don't mind installing command line utilities from the standard Ubuntu repos.


title: Cups configuration does not consider my new PPD driver (Debian Wheezy)

text: My Brother HL-4040CN is very unpredictible when trying to print images or PDFs. Searching around, I found an accurate driver description file at openprinting.org: http://www.openprinting.org/printer/Brother/Brother- HL-4040CN I downloaded it to /usr/lib/cups/driver and, using cups admin console, I tried to change the driver of my printer. Unfortunately, even when deleting/recreating the printer, cups is putting back the default driver: Brother HL-4040CN Foomatic/pxlcolor (recommended) (color, 2-sided printing) Do you have any suggestion to solve my printing issue ?


title: how to execute lines coming from a grep result?

text: I've got a text file with certain installation instructions, and I know I can grep for a unique occurrence in the file. For example, the text file has something like:               MYDIR=`find /home/user -name somedir`     export PERL5LIB=$PERL5LIB:$MYDIR      In bash, how can I execute the lines after a grep in the file? Something like:               execute result from "grep somedir INSTALLFILE"     execute result from "grep 'export PERL5LIB' INSTALLFILE"


title: iptables port-mirroring

text: I need to be able to get a copy of packets received on port 8001 to port 8002. I have tried the following but I get an error that --tee is undefined.               sudo iptables -t nat -A PREROUTING -p TCP -s 127.0.0.1 --sport 8001 -j DNAT --to-destination 127.0.0.1:8002 --tee


title: Howto create a permanent client connection with netcat?

text: I'm writing a bash script that constantly read a folder in a loop to send data to a server at a defined time interval. I'm using netcat as the tool to connect to the server and send the data. My pseudo code would look like:               while true     do         read_folder()         process_data() > result.txt         cat result.txt > netcat ip port         wait 10 sec     done      My only problem is that in the scenario the client connects and disconnects the TCP/IP connection to the server every time. I would prefer to establish the connection at the start of the script and close it at the end. Is there any way this could be done with command line tools in a bash script?


title: Forcing the system to allow me to insert any character in the file name

text: I had an exam this week, and one of the questions was (with one correct answer): > The file name can contain the character: > > a) `\` > > b) `/` > > c) `?` > > d) `!` I chose `c) ?` because it looked OK to me. When I came home I tested it on my machine (Ubuntu 14.04) and the file was created successfully. In the ready reckoner the correct answer is marked to be `d) !`. I knew that the exam was Windows specific, but on the test paper the platform was not specified. * * * It's clear that `\` and `/` characters are not supported in a file name, **BUT** is there any way to force the operating system to allow them? It would be really cool to proove that even `\` and `/` characters are supported.


title: Gnome3-like alternatives

text: Since I discovered gnome3-shell I really appreciated the different Dekstop- type to work with, and I'm still using it. But, I'm battery-addict (using a laptop) and I'm feeling poor performances and less support with Gnome3, consuming too resources, such as long loadings of little programs and some laggy animations, the Arandr that resets to default everytime the layout for the dual-monitor, and the plug-ins that are no more developed. So my question is: is there a Gnome3-like DE solution? or what would you suggest for me? I am using the Gnome-shell because I like the multiple and dynamic multi- desktop creation and easy managing of multiple monitors without any configuration-writing. Also, I tried KDE once, but it is pretty hard to understand the usage, and I had some graphic glithces.


title: What does this "general protection fault" in my console mean, and how do I interpret it?

text: I had a couple of consoles open for other work and when I came back to them they both contained the following:               Message from syslogd@Stacey-Windows at Jun 19 09:43:28 ...          kernel:[ 4375.127165] general protection fault: 0000 [#1] SMP           Message from syslogd@Stacey-Windows at Jun 19 09:43:28 ...     kernel:[ 4375.127311] Stack:          Message from syslogd@Stacey-Windows at Jun 19 09:43:28 ...     kernel:[ 4375.127330] Call Trace:          Message from syslogd@Stacey-Windows at Jun 19 09:43:28 ...     kernel:[ 4375.127423] Code: 00 00 89 44 24 24 c7 44 24 30 04 00 00 00 c7 44 24 34 6c 00 00 00 48 89 4c 24 38 e8 e1 fa ff ff 85 c0 78 03 8b 04 24 48 83 c4 48 <c3> 48 83 ec 38 8b 07 48 8b 7f 08 48 89 54 24 24 ba 30 00 00 00       This looks like an exception has been thrown somewhere in my os, I gather it's a stacktrace of some kind. The code looks like a hexdump of something. What exactly is this and is there anything I can do with this information to know exactly what went wrong/where? What is it used for? EDIT: I just took a look at `/var/log/messages` and got this:               Jun 19 09:43:28 Stacey-Windows kernel: [ 4375.127227]      Jun 19 09:43:28 Stacey-Windows kernel: [ 4375.127241] Pid: 4462, comm: vivado Tainted: G           O 3.2.0-4-amd64 #1 Debian 3.2.51-1 innotek GmbH VirtualBox/VirtualBox     Jun 19 09:43:28 Stacey-Windows kernel: [ 4375.127247] RIP: 0010:[<ffffffffa02a0876>]  [<ffffffffa02a0876>] vboxCallCreate+0x7e/0x7f [vboxsf]     Jun 19 09:43:28 Stacey-Windows kernel: [ 4375.127259] RSP: 0018:ffff88019ab47be0  EFLAGS: 00010292     Jun 19 09:43:28 Stacey-Windows kernel: [ 4375.127263] RAX: 0000000000000000 RBX: ffff88019ab47c7c RCX: 00000000000018fb     Jun 19 09:43:28 Stacey-Windows kernel: [ 4375.127267] RDX: 0000000000000041 RSI: ffff88007131f540 RDI: 0000000000000000     Jun 19 09:43:28 Stacey-Windows kernel: [ 4375.127271] RBP: ffff88019a974000 R08: 00000000ffffffff R09: 00000000ffffffff     Jun 19 09:43:28 Stacey-Windows kernel: [ 4375.127275] R10: ffffffff81600000 R11: ffffffff81600000 R12: ffff88019ab47e78     Jun 19 09:43:28 Stacey-Windows kernel: [ 4375.127279] R13: ffff88012c06c500 R14: ffff88019b84a180 R15: ffff88012c06f300     Jun 19 09:43:28 Stacey-Windows kernel: [ 4375.127283] FS:  00007f76b998d700(0000) GS:ffff8801a2c00000(0000) knlGS:0000000000000000     Jun 19 09:43:28 Stacey-Windows kernel: [ 4375.127288] CS:  0010 DS: 0000 ES: 0000 CR0: 000000008005003b     Jun 19 09:43:28 Stacey-Windows kernel: [ 4375.127291] CR2: 0000000731c95000 CR3: 000000019860a000 CR4: 00000000000006f0     Jun 19 09:43:28 Stacey-Windows kernel: [ 4375.127298] DR0: 0000000000000000 DR1: 0000000000000000 DR2: 0000000000000000     Jun 19 09:43:28 Stacey-Windows kernel: [ 4375.127303] DR3: 0000000000000000 DR6: 00000000ffff0ff0 DR7: 0000000000000400     Jun 19 09:43:28 Stacey-Windows kernel: [ 4375.127307] Process vivado (pid: 4462, threadinfo ffff88019ab46000, task ffff880198dd0930)     Jun 19 09:43:28 Stacey-Windows kernel: [ 4375.127314]  33d59c00137905a4 33d59c00137905a5 33d59c00137905a5 001041ed137905a5     Jun 19 09:43:28 Stacey-Windows kernel: [ 4375.127320]  000003e800000002 00000002000003e8 00e6017800000801 0000000000000000     Jun 19 09:43:28 Stacey-Windows kernel: [ 4375.127325]  0000000000000000 0000000000000000 0000000000000000 0000000000000000     Jun 19 09:43:28 Stacey-Windows kernel: [ 4375.127338]  [<ffffffffa029f009>] ? sf_inode_revalidate+0x78/0xae [vboxsf]     Jun 19 09:43:28 Stacey-Windows kernel: [ 4375.127346]  [<ffffffff8110a5c7>] ? dput+0x27/0xee     Jun 19 09:43:28 Stacey-Windows kernel: [ 4375.127352]  [<ffffffff8110b5ac>] ? __d_lookup+0x3e/0xce     Jun 19 09:43:28 Stacey-Windows kernel: [ 4375.127358]  [<ffffffff8110252c>] ? path_to_nameidata+0x19/0x3a     Jun 19 09:43:28 Stacey-Windows kernel: [ 4375.127364]  [<ffffffffa029f055>] ? sf_dentry_revalidate+0x16/0x20 [vboxsf]     Jun 19 09:43:28 Stacey-Windows kernel: [ 4375.127370]  [<ffffffff81103223>] ? walk_component+0x28f/0x406     Jun 19 09:43:28 Stacey-Windows kernel: [ 4375.127376]  [<ffffffff81104fe2>] ? do_last+0x108/0x58d     Jun 19 09:43:28 Stacey-Windows kernel: [ 4375.127381]  [<ffffffff81105a5f>] ? path_openat+0xce/0x33a     Jun 19 09:43:28 Stacey-Windows kernel: [ 4375.127386]  [<ffffffff81105d8d>] ? do_filp_open+0x2a/0x6e     Jun 19 09:43:28 Stacey-Windows kernel: [ 4375.127393]  [<ffffffff8134deec>] ? _cond_resched+0x7/0x1c     Jun 19 09:43:28 Stacey-Windows kernel: [ 4375.127400]  [<ffffffff811b41f9>] ? __strncpy_from_user+0x18/0x48     Jun 19 09:43:28 Stacey-Windows kernel: [ 4375.127407]  [<ffffffff8110eb13>] ? alloc_fd+0x64/0x109     Jun 19 09:43:28 Stacey-Windows kernel: [ 4375.127413]  [<ffffffff810f9d59>] ? do_sys_open+0x5e/0xe5     Jun 19 09:43:28 Stacey-Windows kernel: [ 4375.127419]  [<ffffffff81354212>] ? system_call_fastpath+0x16/0x1b     Jun 19 09:43:28 Stacey-Windows kernel: [ 4375.127455]  RSP <ffff88019ab47be0>     Jun 19 09:43:28 Stacey-Windows kernel: [ 4375.127551] ---[ end trace 7aaadecc7e737e8f ]---      So there's a vivado in there - it's one of the applications I use, and there's a vbox in there. I'm running debian (and vivado) in virtualbox. Is this something I should be worried about? Is this something I can fix? Linux details: Debian Wheezy 7.0 64-bit


title: Can "find" command preserve access-time

text: I'm running the following command which is supposed to find specific directories according to their Access-Time metadata detail however for some reason the find command changes the access time of these directories.               find /my/directory/ -mindepth 3 -maxdepth 3 -atime +2 -type d      Every time the above command runs it changes the access-time of the directories to the time in which it was executed. I couldn't find any option for the "find" command that speaks of preserving metadata. Any ideas here would be greatly appreciated. Thanks!


title: Create a user that can only connect to a specific directory

text: I've created a SSH folder for some friends. I've created the users to log in via SSH, but they connect to `~` how can I set to which folder they can connect? I have a directory called /usbdrv/ which point to my usb Drive. PS: They can't go then in the parent directory.


title: Boot 32-bit OS from 64-bit GRUB2

text: I can't believe nobody has asked this already, but... If I've installed a 64-bit version of GRUB v2, is it supposed to be possible to load a 32-bit Linux kernel? Or will it only load a 64-bit one? Is this something that's supposed to work? Or is this effort doomed to failure?


title: How to change default syntax-highlighting for header-file in Kate

text: Often I have to open header-files (with ending .h) in **Kate**. The default syntax-highlighting with which these files will be opened is always `C++`. How could this be changed to `Fortran` so that I don't have to switch manually? **Edit1:** I already added a `*.h;` to the list of extensions in fortran.xml under               ~/.kde/share/apps/katepart/syntax/      but this doesn't help. `*.h;` is also included in several other `XML`-files in the upper directory. By the way: The priority in both files `cpp.xml` and `fortran.xml` is `9`. **Edit2:** I tested the modifications on the `XML`-files always by restarting **Kate** with the same files. Here, I see no changes. But, if I close an re-open the same files, it works.