title: A unix command to truncate each line of a file

text: I have a CSV file and I want to truncate it from the third semicolon. For example, if I have this file:               1;foo;bar;baz;x;y;z     2;foo;bar;baz;x;y;z     3;foo;bar;baz;x;y;z      I want to get the following output:               1;foo;bar     2;foo;bar     3;foo;bar      I don't know what kind of Unix command I can use for that. What do you suggest? Note that this manipulation will be done on a KSH script.


title: Limit stdout from a continuously running process

text: I haven't had much luck finding an answer to my problem, but maybe I'm not asking for it correctly. I have a process I startup like the following: `nohup ping 127.0.0.1 > log.txt >2>&1 &` Pretty simple command, send all the stdout to log.txt. Only problem is that the command I'm running sends data every nth second to log.txt. I'd like to output just one line to my log.txt file instead of appending it and running the risk of filling my drive up. Is there a way to just output one line to log.txt that continuously gets overwritten?


title: How simulate a Windows like admin password prompt in Linux?

text: I use `mint install` application a lot but don't think it is safe if I allow the normal user I use to have full privileges over it. I was wondering if there is a way to gain access to this application only when root password is entered. Basically be able to use something like the admin password prompt of windows when installing a new application in terminal. I know I can log into root with su but I know that's definitely not safe. Any Ideas? Edit: Again, I don't want to give privileges to the normal user using sudo or chmod or anything else.


title: Flattening a nested directory

text: This is probably very simple, but I can't figure it out. I have a directory structure like this (dir2 is inside dir1):               /dir1         /dir2             |             --- file1            |             --- file2      What is the best way to 'flatten' this director structure in such a way to get file1 and file2 in dir1 not dir2.


title: What is the effect of deleting utility manufacturer partitions?

text: I am about to erase everything off of my hard drive and install Linux Mint I'm doing this on a Dell laptop, there is a Dell utility partition that I have never used... I have seen these on other laptops by other manufacturers as well. What are they used for and what are the consequences for overwriting them?


title: what is awk '{print $1+0.45 " " $2 " " $3 }' file1> file2?

text: What does `awk '{print $1+0.45 " " $2 " " $3 }' positionXYZ > positionX0.45YZ` mean? Does it mean changing a row in the first file and put the new data into the second one?


title: Deleted /tmp accidently

text: Accidently, I ran `sudo rm -r /tmp`, is that a problem ?   I recreated it using `sudo mkdir /tmp`, does that fix the problem ? After I recreated the directory, In the **places** section in the sidebar in nautilus in Ubuntu 14.04 I can see /tmp , which wasn't there before .. Is that a problem ? One last thing, do I have to run `sudo chown $USER:$USER /tmp` to make it accessible as it was before .. Would there be any side-effects after this ? By the way, I get this seemingly-related error whenI try to use bash autocompletion > bash: cannot create temp file for here-document: Permission denied


title: How to delete the oldest directory in a given directory?

text: > **Possible Duplicate:**   >  Shell script for moving oldest files? I have a backup directory that stores `x` other directories that require backuping. I need something that will run before another directory is moved to the backup, that will check if the number of directories reached `x` and if it has, it will delete the oldest directory. It should be done in a `bash` script.


title: Passing escape sequences to shells within ansi-term in Emacs

text: In a regular terminal (e.g. iTerm2 on OS X) I can connect to a database, e.g.               > psql ....      and then, as I type my command in `psql`, e.g.               $ select foo from bar      I can move around (as I type psql commands) using the standard `Alt+b` and `Alt+f`. However, if I try to do this in a shell within Emacs (`ansi-term`), it doesn't work. More specifically, if I start a shell (e.g. Bash) within `ansi-term`, the keystrokes `Alt+b` and `Alt+f` work fine in the Unix shell (in this case, Bash), **BUT** if I then drop into `psql` from within the shell, the keystrokes `Alt+b` nor `Alt+f` stop working (the keystrokes won't move the cursor, and I can't keep typing commands properly anymore) Why is this? And how can fix this behavior? ## Update 1: I narrowed the problem and the line in my `.zshrc` that causes this behavior is the following one:               TERM=xterm-256color      I have this line because its's the best solution that I found to fix the problem that I report in this thread: Emacs multi-term not displaying special characters correctly ## Update 2 (solution, but why?): I found the solution in this thread: Weird character zsh in emacs terminal. As the top answer says, I had to create `eterm-color` `terminfo` by using following command: (note that the `terminfo` path may be different from your system)               # If you use Cocoa Emacs or Carbon Emacs     tic -o ~/.terminfo /Applications/Emacs.app/Contents/Resources/etc/e/eterm-color.ti


title: Xvfb ignores bitdepth

text: I'm tryging to obtain screen captures form application that runs on Xvfb but all the captures came in 8bppx I run Xvfb like this as some other post stipulates.               /bin/Xvfb :1 -screen 1 1600x1200x24+32      If I use a real X server they come ok at 32bppx. Any idea or this is a limitation of Xvfb?


title: Changing system volume also changes Spotify volume (Arch Linux)

text: This is something that has been bugging me for awhile and I haven't been able to find a fix yet. Whenever I change the system volume using the hardware volume keys on my laptop, it also changes the Spotify volume (it moves the Spotify volume slider as well as the system volume slider). Is there a way to prevent this from occurring? I've searched around for awhile and haven't found anything. I have looked at Arch's awesome wiki, but I haven't found anything that helped the problem. A similar issue is described here on the wiki, but it didn't solve the problem. This issue has occurred on all the desktop environments I've used on Arch so far. XFCE, Gnome, and Cinnamon (what I'm currently using) all suffer from this. I believe I am using pulseaudio for my audio server. I am also using the Linux Preview of Spotify which I installed from the AUR. If someone posts a solution that works, I will be sure to add it to the Arch Wiki for others to reference.


title: Text processing using unix tools

text: I have a file in the following format.               abc|xyz|mno       x up x       up up x       x x up            abc|xyz|mno       x x x       up x x            ....       ....      Basically the first line of the file are device names `(|ed)` and following lines are states of the devices. I would like the output to be in the following format:               abc,x|xyz,up|mno,x       abc,up|xyz,up|mno,x       abc,x|xyz,x|mno,up            abc,x|xyz,x|mno,x       abc,up|xyz,x|mno,x            ....       ....        Do you have any pointers?


title: Mysql query resultset in bash script

text: I am using the bash script to connect to the mysql database and execute a query. I use the below script to connect to the database and execute the query.               #!/bin/bash     Total_Results=$(mysql -h server-name -P 3306 -u username-ppassword -D dbname<<<"select URL  from Experiment where URL_Exists = 1");     for URL in "$Total_Results";     do     echo $URL     var=$(curl -s --head $URL | head -n 1 | grep "HTTP/1.[01] [23]..")     echo "$var"     if [ -z "$var" ]     then     echo "Ok we do not have a valid link and the value needs to be updated as -1 here"     else     echo "we will update the value as 1 from here"     fi     done      The problem is the result set is considered as a one whole result and I am getting inside the else loop only once (we will update the value as 1 from here is printed only once). I have 2500 valid URLs and I expect 2500 echoes of `we will update the value as 1 from here`. How can I process each and every row as a single result from mySQL query?


title: Cloned Linux system and /etc/udev/rules.d/70-persistent-net.rules

text: I set up an Ubuntu system and configured it properly, including defining `eth0` in `/etc/network/interfaces`. I then imaged that system and cloned it on a new system. When I booted up the system the first time all was good, but a few reboots later I was greeted with the network config timing out. When I logged in I found that `eth0` was not available. My initial research let me to try `ifdown -a` and `ifup -a` which I did a few times to no apparent effect. Research eventually pointed me to `/etc/udev/rules.d/70-persistent-net.rules`, where I discovered that the MAC address for the new system had created eth1. Good idea, but not what I wanted to happen. When I booted up just now, I found that `/etc/udev/rules.d/70-persistent- net.rules` now has six entries for six different HW Addresses, which I find strange as there is only one interface. My question is: did my use of `ifup -a` somehow create new MAC addresses to be created? If not, are there any thoughts on how this happened? I altered `/etc/udev/rules.d/70-persistent-net.rules` to name the current HW Address `eth0` and it seems to be working, but can I be assured that the address won't change again on a reboot?


title: Recover formatted ext3 partition

text: Suppose you have an ext3 partition which was unfortunately formated as ext4 partition (and where now are some but not a lot new files on it). Is there any way to recover (some) files from the old ext3 partition?


title: Create my own disk server

text: I have been wondering how all these small nas boxes that run linux can share over network and usb. The network part is totally under control, but I am completely at a loss on how I could hook up a computer to my server through USB cable, and get a share. Is this done with some specific hardware or is this done through software ?


title: Deleting files by age

text: Is there a command to delete all the files in a directory that haven't been modified in _N_ days? I need to clean up some old logs.


title: How to FILTER the files with filename and then DELETE the OLDEST file from there?

text: I create and keep the following automated backup files e.g.:               fruits_29-12-2013.gz     fruits_30-12-2013.gz     fruits_31-12-2013.gz     sweets_01-12-2013.gz     sweets_02-12-2013.gz     sweets_03-12-2013.gz      .. actually many of them in the same folder. _(But then it's a problem to house keeping them manually but I still have to. Because after a month, all are taken up the disk space. So I need to clean up the latest files, accordingly.)_ How to automatically `DELETE` the `OLDEST` file with name starts with `fruits`? _(Then I'll put that script/command in the daily crons.)_


title: put tab before every output line on AIX/ksh

text: 0:root@SERVER:/root # echo "something" | sed -e 's/^/\t/g'     tsomething     0:root@SERVER:/root #       AIX/ksh .. why doesn't it works? I just want to put a "tab" before every line!


title: Alt+tab on Fluxbox

text: I've been using fluxbox on my netbook, and have been very pleased. That is, with everything but one feature. I would really like it if I could use fluxbox with the added functionality that when I use alt+tab it will show me the windows I am switching between. (As it does in Windows/Mac/GNOME/KDE/Xfce/...). Is there some app I can install that would do that? Or is the only resort to use a different GUI?


title: "unknown partition table" - misconfigured kernel

text: I was compiling a custom linux kernel for a newly installed machine, and after booting into the new kernel (3.12), the init process fails to find a root device, which I traced to the system getting an `unknown partition table` error on the device in question (`/dev/sda`). The generic kernel boots up and mounts the root partition just fine. I cannot seem to find anything that looks relevant in the kernel config, what could it be missing?


title: Strange error with ccsm (fedora 16) 32 - bit

text: I don't know if anyone else has experienced this, and I'm not sure what information you need (please ask if there is anything), but ccsm keep crashing because > /usr/bin/python keeps getting killed by signal 11 (sigsegv). Is this a known issue, can I do anything to fix this? I have researched other bugs, and none seem to match this one               [...@localhost ~]$ ccsm     Backend     : ini     Integration : true     Profile     : default     Adding plugins     Initializing core options...done     /usr/lib/python2.7/site-packages/ccm/Window.py:92: Warning: g_object_set_qdata: assertion `G_IS_OBJECT (object)' failed       self.LeftPane.pack_start(page.LeftWidget,   True, True)     /usr/lib/python2.7/site-packages/ccm/Window.py:95: Warning: g_object_set_qdata: assertion `G_IS_OBJECT (object)' failed       self.show_all()     /usr/lib/python2.7/site-packages/ccm/Widgets.py:1570: Warning: g_object_set_qdata: assertion `G_IS_OBJECT (object)' failed       self._table.attach (button, col, col+1, row, row+1, 0, xpadding=TableX, ypadding=TableY)     Loading icons...     /usr/lib/python2.7/site-packages/ccm/Widgets.py:1575: Warning: g_object_set_qdata: assertion `G_IS_OBJECT (object)' failed       self.show_all ()     Initializing compiztoolbox options...done     Segmentation fault (core dumped)


title: Output the changes to a log file

text: If I use > >     tail -f *filename* >   I get a real nice display of whatever is changing in a given file. However, sometimes I want to be able to search this text or otherwise look it over slowly. Is there any way I can output just the changes to a log file between now and, say, whenever I hit `Ctrl`-`C`?


title: Getting non-stored password from Icedove

text: I've recently changed my mail password (because of Heartbleed), but I've forgotten the new one. When entering the new password in Icedove, I didn't think of clicking "remember password", but the instance of Icedove is still running, and still knows how to connect to the server, so the password must be stored _somewhere_ in the process. Of course, it cannot be found in the stored passwords list because I didn't tell Icedove to store it. My question therefore is: > Is there any way to recover the password from the running process? Since this running Icedove process is the only place that has the new password, anything involving closing that process naturally won't work. I'm using Icedove 17.0.10


title: How to create infinite pipe of strings in bash

text: I have about 10 links in file links.txt. I download them through               cat links.txt | xargs -i --max-procs=4 bash -c "wget {}"      I whould like do it repeatedly like               while :     do        cat links.txt | xargs -i --max-procs=4 bash -c "wget {}"     done      Before the next iteration of while loop it waits all subprocesses to be finished. But I would like to continue downloading (take url from beginning of the file) when there is an available thread. How to do that? May be I can make infinite pipe of strings?


title: Is the double dash still the posix standard for long switches?

text: I've read several question about double dash: Single dashes `-` for single-character options, but double dashes `\--` for words?   What does `\--` (double-dash) mean? (also known as “bare double dash”) However I remember about a teacher 4 years ago telling me that `\--` was the posix way of dealing with long switches like `\--help` or `\--color=`.   Today, I'm using a lot of command where this rule is not respected at all and the best example I can came up with is `find` where no long switches takes a double-dash even with the very annoying `AIX find`. Was my teacher wrong? or does the rule changes since (which seems unlikely)?   And finally, is there any `posix` rules about the length of option and `-` or `\--` ?


title: Cisco VPNC + get time out on target machine

text: I am running VPNC on linux red-hat machine ( version 6.3 ) , And my VPN connection seems to be timing out after 10-20 min . If it goes unused for more than a few minutes, I have to kill VPNC and run it again. The half solution was to do a ping to a computer that's behind the VPN, in order to keep the connection open. ( but this hold the connection only for 10 min I also add the line " DPD idle timeout (our side) 0" in /etc/vpnc.conf as said in some forums , But this hold the connection only for 20 min -:( Is there a way to extend the idle timeout for VPNC? I was try to disable the time out by the following ideas , but still after 15-20 min I lose connection on the target machine


title: Tools to manage a custom installation prefix for software compiled from source?

text: What package managers exist which can handle compiling and installation development version (git head) into a configurable installation prefix? I.e. by typing a command, I want to be able to:   * update to the last development version of the software I am installing (using http direct download, Git, Mercurial or any other SCM)   * launch the compilation with the "right options" passed to `configure` or CMake   * install the software in a specific installation prefix   * update the environment variables in an appropriate way (i.e. modify `PATH` or `LD_LIBRARY_PATH`, etc.) Basically, it boils down to a distribution independent tool that would behave like `emerge` from Gentoo or `pacman`/`yaourt` from Arch on a particular subset of software (installed in a separate, customizable, installation prefix). So far I am aware of:   * RobotPkg   * LinuxBrew (experimental)   * Gentoo Prefix Is there any other tools like these ones out there?


title: Which distributions maintain a kernel package with grsecurity support

text: I know that I can apply the grsecurity patches by compiling my own kernel. This is not a big deal to do it once, but too complex to have regular and easy kernel image updates. So I am looking for linux distributions which supports gsecurity as a kernel-package which I can easily update via a package manager. For Ubuntu there was a repository http://kernelsec.cr0.org/ which was probably trustable because it was linked by the gsecurity page. But it seems to end with kernel version 2.6.32.15. Since I am currently using ubuntu, it would be great to find something based on ubuntu or just on debian.


title: How would I extract the user agent strings from a log file?

text: Currently I am running a command like this, to get the most requested content:               grep "17\/Jul\/2011" other_vhosts_access.log | awk '{print $8}' | sort | uniq -c | sort -nr      I want to now see the user agent strings, but the problem is they include several spaces. Here is a typical log file line. The UA is the last section delimited by quotation marks:               example.com:80 [ip] - - [17/Jul/2011:23:59:59 +0100] "GET [url] HTTP/1.1" 200 6449 "[referer]" "Mozilla/5.0 (Windows NT 6.1) AppleWebKit/534.30 (KHTML, like Gecko) Chrome/12.0.742.122 Safari/534.30"      Is there a better tool than awk for this?


title: Linux/GParted can see partition table but dd bs=512 count=1 can't

text: I have an MBR formatted sd card and when connect to a Linux machine (xubuntu 12.04) it can mount a partition and parse the file system (as can GParted). However, when I try to read the MBR from the device using dd it gives me a bunch of spurious data. Could anyone shed any light into how Linux/GParted is able to read and make sense of the MBR when dd isn't able to read the MBR. **Do they use different methods to get at the data?** I.E not open(), read() DD command is:               dd if=/dev/sdb of=mbr.bin bs=512 count=1      DD output is:               1+0 records in     1+0 records out     512 bytes transferred in 0.000786 secs (651345 bytes/sec)      mbr.bin dump with `hexdump -C mbr.bin` is:               00000000  04 16 41 53 4d 49 2d 53  44 03 00 00 00 00 16 f1  |..ASMI-SD.......|     00000010  00 7f 00 32 1f 5b 80 00  36 db bf bf 96 c0 00 01  |...2.[..6.......|     00000020  00 00 00 00 00 00 00 00  00 00 00 00 00 00 00 00  |................|     00000030  6f 00 00 10 00 00 02 2e  00 00 00 00 00 00 00 00  |o...............|     00000040  00 00 00 00 00 00 00 00  00 00 00 00 00 00 00 00  |................|     *     00000200


title: Unable to connect INTEX 3.5G (aka 普创E003) Wireless USB modem in Ubuntu 12.04 LTS

text: Can anyone help me out on connecting INTEX 3.5G 7.2 Mbps (aka 普创E003) Wireless USB modem in Ubuntu? Initially it is recognized as a storage device and the `modprobe` cmd does not create any impact on it. Here are the steps I have followed:               tech@tech-Inspiron-N5010:~$ sudo usb_modeswitch -H -v 20a6 -p f00e.          Looking for default devices ….     found matching product ID.     adding device     Found device in default mode, class or configuration (1).     Accessing device 007 on bus 002 ….     Getting the current device configuration ….     OK, got current device configuration (1).     Using first interface: 0×00.     Using endpoints 0×01 (out) and 0×81 (in).     Inquiring device details; driver will be detached ….     Looking for active driver ….     No driver found. Either detached before or never attached.          SCSI inquiry data (for identification).     ————————-     Vendor String: Modem.     Model String: Disk.     Revision String: 2.31.     ————————-          USB description data (for identification).     ————————-     Manufacturer: Modem     Product: Modem Device.     Serial No.: 000000000002.     ————————-     Sending Huawei control message ….     OK, Huawei control message sent.     -> Run lsusb to note any changes. Bye.          tech@tech-Inspiron-N5010:~$ sudo modprobe usbserial vendor=0x20a6 product=0xf00e.      `usb-devices`:               T: Bus=02 Lev=02 Prnt=02 Port=01 Cnt=01 Dev#= 7 Spd=480 MxCh= 0.     D: Ver= 2.00 Cls=00(>ifc ) Sub=00 Prot=00 MxPS=64 #Cfgs= 1.     P: Vendor=20a6 ProdID=f00e Rev=00.00.     S: Manufacturer=Modem     S: Product=Modem Device.     S: SerialNumber=000000000002     C: #Ifs= 1 Cfg#= 1 Atr=e0 MxPwr=500mA.     I: If#= 0 Alt= 0 #EPs= 2 Cls=08(stor.) Sub=06 Prot=50 Driver=(none).      I have tried this all. I am using the INTEX 3.5G 7.2 Mbps (aka 普创E003) Wireless USB Datacard modem and have tried to configure rules and modules also but nothing has worked.   Can anyone tell me what is the real problem?


title: Disable repository updating in fedora

text: Fedora checks all repository for updating when every time i want to install some packages from yum. this is waste of time because i know they are updated! how could i disable this checking?


title: How to process these DHCP logs to be human readable?

text: I have this input:               Sep 23 13:43 192.168.6.200     Sep 23 13:44 192.168.6.166     Sep 23 13:45 192.168.6.200     Sep 23 13:46 192.168.6.166     Sep 23 13:47 192.168.6.200     Sep 23 13:48 192.168.6.166     Sep 23 13:49 192.168.6.176     Sep 23 13:49 192.168.6.200     Sep 23 13:50 192.168.6.166     Sep 23 13:51 192.168.6.176     Sep 23 13:51 192.168.6.200     Sep 23 13:52 192.168.6.166     Sep 23 13:54 192.168.6.166     Sep 23 13:54 192.168.6.176     Sep 23 13:56 192.168.6.176     Sep 23 13:57 192.168.6.166      I need this output:               Sep 23 13:43 192.168.6.200     Sep 23 13:51 192.168.6.200          Sep 23 13:44 192.168.6.166     Sep 23 13:57 192.168.6.166          Sep 23 13:49 192.168.6.176     Sep 23 13:56 192.168.6.176      So I have DHCP logs from an OpenWrt router that I generate with (I configured the dhcp server to dhcp lease to "5m"):               logread | fgrep DHCPACK | awk '{print $1" "$2" "$3" "$8}' | sed 's/:[0-9][0-9] / /g' | sort -u      But I need the mentioned input to be the mentioned output, how? are there any perl masters? :\ :D


title: How to install manually from live CD?

text: I got a live CD and I tried to install it manually because it doesn't support installing. So I booted from live cd and did:               mkfs.ext4 /dev/sda5     mount /dev/sda5 /mnt     cd /mnt     unsqaushfs /cdrom/casper/filesystem.squashfs     mv squashfs-root/* ./     rm -r squashfs-root     mount --bind /dev /mnt/dev     mount --bind /sys /mnt/sys     mount --bind /proc /mnt/proc     chroot /mnt     grub-install /dev/sda     update-grub      So I restarted and it said that it can't mount the filesystem. So I tried the same with ext2 because in the grub config stood `insmod=ext2` and when I tried to boot with `insmod=ext4` it said file not found. But still even with ext2 it said that it can't mount the filesystem.


title: Why is the keyboard assigned the specific IRQ of 1?

text: Why are specific IRQ values assigned to certain devices? For example, why is the system timer assigned the value of 0 and not 10?


title: sed + how to remove character/s that start or ended on each number

text: How do I remove the `.` character(s) that start in the beginning of each number or end on each number? Remark – `perl` one liner also good alternative for `sed`. Example input:                .23.12.44.5.      .233.3.3.3      23.4.5.3.2..      ....33.2.3.45.5      .3.3.2.....      Expected output:                23.12.44.5      233.3.3.3      23.4.5.3.2      33.2.3.45.5      3.3.2      (note that the lines may end and/or begin with blanks (spaces or tabs) which should be preserved).


title: Inconsistent redirection behavior ssh interactive vs commands

text: These work,               ssh remote 'echo hi > hi.txt'     echo hi | ssh remote 'cat > hi.txt'      but this does not work               ssh remote sh -c 'echo hi > hi.txt'      I expected to produce a file on remote named hi.txt containing "hi". Instead I get an _empty_ file named hi.txt. The following gives the expected behavior if executed from an interactive ssh session.               sh -c 'echo hi > hi.txt'      What do I miscomprehend about ssh and redirection?


title: exit a script if an ls line did not find any match

text: I am writing this script that have this line: `ls -lrt /dir1/dir2/filename*.txt | tail -1 | awk '{print $9}' | read variable` What I wanted is to exit the script (without using if-statement) if it does not find any match.


title: SSI problem with http in centos

text: My httpd.conf is as below.               - - -          AddType text/html .shtml .html     Options +Includes     AddOutputFilter INCLUDES .shtml .html          DirectoryIndex index.shtml index.html index.php index.html.var          - - -      And still showing in the debug log Options +Includes wasn't set.               [Thu Aug 14 01:14:26 2014] [warn] [client xxx.xxx.xxx.xxx] mod_include:      Options +Includes (or IncludesNoExec) wasn't set, INCLUDES filter removed.      My apache version is 2.2 & running on Centos 6. Any advice how to solve this issue.


title: Getting a list of users by grepping /etc/passwd

text: For a homework assignment, I need to use `grep` to parse `/etc/passwd` and get a list of all users (their usernames only, nothing else). It should use a pipe, and the results should end up in the `allusers` file. This is what I have so far:               grep -i etc/password | .... >allusers       What am I missing?


title: How to check how many lanes are used by the PCIe card?

text: PCI Express slots on the motherboard can be wider then the number of lanes connected. For example a motherboard can have x8 slot with only x1 lane connected. On the other hand, you can insert a card using only for ex. 4 lanes to a x16 slot on the motherboard, and they will negotiate to use only those x4 lanes. How to check from the running system how many lanes are used by the inserted PCIe cards?


title: What to use to backup files, preserving ACLs?

text: When using the tar utility to store files in backups one loses the extended ACLs. Is there some commonly used and not hackish solution (like: create a script that will recrate the ACLs from scratch) to preserve the ACLs?


title: cron: bash syntax not working

text: I am trying to add following command to crontab:               I=1; for X in $(/bin/ls -r /var/tmp/*); do [ $((I++)) -le 28 ] && echo "lower" || echo "higher"; done      When executed on the command line (in bash), the command works fine. But when I add the line into crontab and when executed, cron complains:               /bin/sh: 1: arithmetic expression: expecting primary: "I++"      Do I need to use different syntax in cron ? **EDIT1:** I have replaced `sh` with `bash` in my `/etc/crontab`:               SHELL=/bin/bash      I have restarted `cron`, but following cron line still does not execute:               (I=1; for X in $(/bin/ls -r /var/tmp/*); do [ $((I++)) -le 28 ] && echo "lower" || echo "higher"; done)      the error suggests, that it is still being interpreted with `/bin/sh` instead of `/bin/bash`:               /bin/sh: 1: arithmetic expression: expecting primary: "I++"


title: how to create a data file with a column of date from day1 to dayN?

text: I was wondering if I could generate a hourly or daily time step date in a column starting from some year in the past to some day in the near past or today. to be more clear, I want to create one column of data from 2000-10-10 100 to 2012-12-31 2400. The output file will look like               Date           2000-01-01 100     2000-01-01 200     2000-01-01 300     .     .     .     .     .     2012-12-31 2400


title: Unix equivalent of powershell?

text: I've always found it awkward when complex shell commands involve parsing text output with `awk`. Basically we're converting structured data into text, then parsing the text again to get back at the structured data. `Powershell` is a Windows shell which avoids that problem by allowing you to pipe typed objects between shell commands instead of just text. **Are there any Unix shells which are object-based instead of text-based, like Powershell?**


title: Two ways to lock a password but only one to unlock

text: CentOS 6 Linux has two ways to lock a password:   1. `passwd -l`   2. `usermod -L` Today I found out, that they do something different. `passwd` writes two exclamation marks into the shadow file.               # passwd -d test1     Removing password for user test1.     passwd: Success     # passwd -l test1     Locking password for user test1.     passwd: Success     # passwd -S test1     test1 LK 2014-01-14 0 99999 7 -1 (Password locked.)     # grep test1 /etc/shadow     test1:!!:16084:0:99999:7:::      But `usermod` writes only one.               # passwd -d test1     Removing password for user test1.     passwd: Success     # usermod -L test1     # passwd -S test1     test1 LK 2014-01-14 0 99999 7 -1 (Password locked.)     # grep test1 /etc/shadow     test1:!:16084:0:99999:7:::      Is this only a cosmetic inconsistency or is there a meaning for the different lock indicators? Funny things happen, if you mix the two commands: Lock an account with `passwd`:               # passwd -l test1     Locking password for user test1.     passwd: Success      Unlock it with `usermod`:               # usermod -U test1      And surprise it is still locked:               # passwd -S test1     test1 LK 2014-01-14 0 99999 7 -1 (Password locked.)      Bug or feature?


title: A program that runs in a shell (e.g. pine) vs. a shell script

text: Having a bit of trouble finding the answer to my question, perhaps because I may be asking the wrong question. I understand bash scripts. I write them all the time to do little helpful things repeatedly. However I would like to know the difference between a shell script, and a program that runs in a shell. For example, what is pine? What language is it written in? It runs in a shell, but as far as I know it's not a shell script, it's a self-contained program that you can navigate around in, and when you exit, you return to the shell exactly where you were when you launched it. If I wanted to write a program that functions similar to pine, in that it runs in the shell as a program with various functionality, where would I begin? Where can I find some examples of programs written in this way?


title: How to tell sudo to repeat lecture once?

text: I'm letting one of my coding buddies have root access to my Raspberry Pi, and as I was getting everything set up, I tested sudo as him. It gave me "the speech": > We trust you have received the usual lecture from the local System   >  Administrator. It usually boils down to these three things: > > #1) Respect the privacy of others.   >  #2) Think before you type.   >  #3) With great power comes great responsibility. What I'm wondering is how to tell sudo to repeat that once. I can't find where it stores the "warned users" list, and I don't want to go overkill and tell it to give The Speech every time.


title: Dual booting windows 8.1 and fedora 19

text: I am trying to dual boot windows 8.1 and fedora 19. I am in UEFI mode and using USB. I installed windows 8.1 and left some free unpartitioned space.. Now when fedora installation is going on I am stuck at installation source. The auto detect media option detects sda1 but verification says bad image.


title: Screen create/resume session, run command an detatch

text: I am trying to make a startup script for my Minecraft severs but I can't figure out how to: If the session "Server1" exists, run a command in it, if it doesn't, create the session and then run the command. I have read something about a `-dRR` switch but haven't been able to use it. The script is `java -Xmx 128M spigot.jar -o true` BTW. EDIT: This is te command I've been using (can only run it once otherwise it will create news seesions) `screen -dmS Server3 bash -c '/home/server/Minecraft/BungeeCord/Server3/start.sh; exec bash'` The start.sh file contains the above code. Of course I tried to change the switch from `-dmS` to `-dRR`, but that didn't work.


title: Launch a command at the end of Linux startup

text: I have a Raspberry without screen/keyboard/mouse that does nothing else than launching a radio stream at startup :               mplayer http://95.81.146.2/fip/all/fiphautdebit.mp3      I have put this command at the end of `/etc/rc.local`. Unfortunately, 50% of the time, the playing doesn't start (maybe because the WIFI wasn't properly connected yet?) and I have to reboot to make the sound playing start. **How can I check what happened during`rc.local` startup, later, with a SSH connexion ?** _I tried with`dmesg`, but couldn't see the result of `mplayer`._ **Which is the most appropriated script to put such a command ?** (`rc.local`, `/etc/profiles` ?)


title: All occurrences of a regex get removed without using the "global" modifier

text: I have the following text in the file sentence.txt > Linux refers to the family of Unix-like computer operating systems that use > the Linux kernel.   >  Linux can be installed on a wide variety of computer hardware, ranging from > mobile phones, tablet computers and video game consoles, to mainframes and > supercomputers. Linux is predominantly known for its use in servers.   >  It has a server market share ranging between 20–40%.   >  Most desktop computers run either Microsoft Windows or Mac OS X, with Linux > having anywhere from a low of an estimated 1–2% of the desktop market to a > high of an estimated 4. 8%.   >  However, desktop use of Linux has become increasingly popular in recent > years, partly owing to the popular Ubuntu, Fedora, Mint, and openSUSE > distributions and the emergence of netbooks and smart phones running an > embedded Linux.   >  Linux can be installed on a wide variety of computer hardware, ranging from > mobile phones, tablet computers and video game consoles, to mainframes and > supercomputers. In this text 2 sentences repeat. It is the last sentence. Actually I just copy-pasted the 2nd sentence to the end of the text so that I have 2 occurrences of the `mobile phones`               ~$ grep mobile sentence.txt        Linux can be installed on a wide variety of computer hardware, ranging from mobile   phones, tablet computers and video game consoles, to mainframes and supercomputers.       Linux can be installed on a wide variety of computer hardware, ranging from mobile   phones, tablet computers and video game consoles, to mainframes and supercomputers.        Then I was wondering which occurrence would be deleted by the following regex:   `[^.]*mobile phones[^.]*\\.`   I believe that the last occurrence should be removed due to the back tracking. To verify this assumption and my understanding I applied the following:               :~$ sed  's/[^.]*mobile phones[^.]*\.//' sentence.txt > sentence2.txt          Notice that I did not use `g` so that it would replace the first occurrence found (I think it would be the last sentence).   But I see that both are removed!               ~$ grep mobile sentence2.txt         ~$        What am I doing wrong here? 1) Is my understanding of the regex that the last sentence would match first wrong? 2) Why are both sentences removed without `g`?


title: Why can't I do ls *.txt in a subshell?

text: ~$ echo $(ls)       arguments.txt cecho.sh Desktop Documents Downloads example.txt Music Pictures Public          ~$ echo $(ls "*.txt")       ls: cannot access *.txt: No such file or directory        Why does the 2nd subshell command fails?


title: Cannot configure Postfix to receive mail

text: I try to configure Postfix on CentOs 6. I can send mails from the server just fine, but cannot receive. The Delivery Status Notification that I get is:               The error that the other server returned was:     550 5.1.1 <user@mydomain.com>: Recipient address rejected:     User unknown in virtual alias table      I have used this tutorial to setup postfix.   The content of `/etc/postfix/main.cf` file is:               soft_bounce             = no     queue_directory         = /var/spool/postfix     command_directory       = /usr/sbin     daemon_directory        = /usr/libexec/postfix     mail_owner              = postfix          # The default_privs parameter specifies the default rights used by     # the local delivery agent for delivery to external file or command.     # These rights are used in the absence of a recipient user context.     # DO NOT SPECIFY A PRIVILEGED USER OR THE POSTFIX OWNER.     #     #default_privs = nobody          myhostname              = mail.mydomain.com      mydomain                = mydomain.com          mydestination           = $myhostname, localhost     unknown_local_recipient_reject_code = 550          mynetworks_style        = host     mailbox_transport       = lmtp:unix:/var/lib/imap/socket/lmtp     local_destination_recipient_limit       = 300     local_destination_concurrency_limit     = 5     recipient_delimiter=+          virtual_alias_maps      = hash:/etc/postfix/virtual          header_checks           = regexp:/etc/postfix/header_checks     mime_header_checks      = pcre:/etc/postfix/body_checks     smtpd_banner            = $myhostname          debug_peer_level        = 2     debugger_command =              PATH=/bin:/usr/bin:/usr/bin:/usr/X11R6/bin              xxgdb $daemon_directory/$process_name $process_id & sleep 5          sendmail_path           = /usr/sbin/sendmail.postfix     newaliases_path         = /usr/bin/newaliases.postfix     mailq_path              = /usr/bin/mailq.postfix     setgid_group            = postdrop     html_directory          = no     manpage_directory       = /usr/share/man     sample_directory        = /usr/share/doc/postfix-2.3.3/samples     readme_directory        = /usr/share/doc/postfix-2.3.3/README_FILES          smtpd_sasl_auth_enable          = yes     smtpd_sasl_application_name     = smtpd     smtpd_recipient_restrictions    = permit_sasl_authenticated,                                       permit_mynetworks,                                       reject_unauth_destination,                                       reject_invalid_hostname,                                       reject_non_fqdn_hostname,                                       reject_non_fqdn_sender,                                       reject_non_fqdn_recipient,                                       reject_unknown_sender_domain,                                       reject_unknown_recipient_domain,                                       reject_unauth_pipelining,                                       reject_rbl_client zen.spamhaus.org,                                       reject_rbl_client bl.spamcop.net,                                       reject_rbl_client dnsbl.njabl.org,                                       reject_rbl_client dnsbl.sorbs.net,                                       permit          smtpd_sasl_security_options     = noanonymous     smtpd_sasl_local_domain         =      broken_sasl_auth_clients        = yes          smtpd_helo_required             = yes       The content of `/etc/postfix/virtual` file is:               user@mydomain.com   mydomain.com/user      In `/var/log/maillog` I don't see any information about this problem.   I am new to Linux, and I would like to know how to debug or how can I fix this issue.   Any help will be appreciated


title: Chaining mysqldumps commands to output a single gzipped file

text: Let's say I have these series of commands               mysqldump --opt --databases $dbname1 --host=$dbhost1 --user=$dbuser1 --password=$dbpass1     mysqldump --opt --databases $dbname2 --host=$dbhost1 --user=$dbuser1 --password=$dbpass1     mysqldump --opt --databases $dbname3 --host=$dbhost2 --user=$dbuser2 --password=$dbpass2     mysqldump --opt --databases $dbname4 --host=$dbhost2 --user=$dbuser2 --password=$dbpass2      How do put all their outputs(assuming that the output name is $dbhost.$dbname.sql) and put it inside one file named backupfile.sql.gz using only one line of code? **Edit** : From comments to answers below, @arvinsim actually wants a compressed **archive** file containing the SQL dumps in separate files, not _one_ compressed SQL file.


title: Enabling a Display Manager in Ubuntu 13.10

text: I was wondering if anyone knew how to enable/set-up a display manager which prompts for username and password when the screen boots. Whenever I start Ubuntu, it goes to the desktop and then a small window pops up a few minutes later prompting me for my password. I would much prefer a separate screen for logging in, as the home screen can be accessed and interacted with before entering a password, leaving a big security hole on my computer. I run a dual-boot laptop with windows 7 and ubuntu 13.10; not sure if this is relevant, but figured I'd include it anyways.


title: Can I zip an entire folder using gzip?

text: I'm trying to zip a folder in unix. Can that be done using the gzip command?


title: How can I make variables "exported" in a bash script stick around?

text: I have multiple Amazon EC2 accounts and want to quickly be able to switch variables, such as `$EC2_HOME`, using a script. I have have a shell script set up like this:               #!/bin/sh     export EC2_HOME=/home/me/.ec2     echo $EC2_HOME      When I run the script I know that `EC2_HOME` is set, but I thought that using `export` would make the variable stick around after the script completed. It does not, as running `echo $EC_HOME` does not show anything. I know this must be very rudimentary Linux scripting knowledge, but I don't know it. I tried looking for related questions without luck - so my apologies if this is a duplicate.


title: how to set environment variables from a shell script?

text: I'm trying to set environment variable through a shell script. Here is the script with various techniques:               #!/bin/sh     echo "export SOMEPATH=/root/some" >> /root/.bash_profile     echo "export PATH=$PATH:$SOMEPATH/bin" >> /root/.bash_profile     SOMEPATH=/root/some     export SOMEPATH     source /root/.bash_profile      I run the script `a.sh` with `sh a.sh` Then if I check the `env` variable it doesn't show up. `echo $SOMEPATH` returns nothing. I expected to get `SOMEPATH` returned


title: Vim Window in Tmux

text: In Tmux, how do I assign a particular program to a particular window, so that all calls to that program from a shell in another window in Tmux will go to that program? One example would be a window that just keeps Vim open. So in this example, whenever I type `vim myfile.txt` in my shell window in Tmux, I will see `myfile.txt` in the vim window of Tmux.


title: iptables: The "script" way or the "*filter, rules, COMMIT" way?

text: I'm trying to figure out how NAT and iptables work. While I'm in the trial- and-error phase of learning about it, I found two somewhat conflicting howtos. One howto uses a script to call `iptables` rules one after another. The script seems to be named and stored such that it is executed early during system boot, and I think a problem may be that other scripts may be called after it and undo its intentions. I even think I did this once by accident when I saved and renamed the original script (00-firewall) using a backup (00-firewall- old). The example script form the howto is:               #!/bin/sh          PATH=/usr/sbin:/sbin:/bin:/usr/bin          #     # delete all existing rules.     #     iptables -F     iptables -t nat -F     iptables -t mangle -F     iptables -X          # Always accept loopback traffic     iptables -A INPUT -i lo -j ACCEPT               # Allow established connections, and those not coming from the outside     iptables -A INPUT -m state --state ESTABLISHED,RELATED -j ACCEPT     iptables -A INPUT -m state --state NEW -i ! eth1 -j ACCEPT     iptables -A FORWARD -i eth1 -o eth0 -m state --state ESTABLISHED,RELATED -j ACCEPT          # Allow outgoing connections from the LAN side.     iptables -A FORWARD -i eth0 -o eth1 -j ACCEPT          # Masquerade.     iptables -t nat -A POSTROUTING -o eth1 -j MASQUERADE          # Don't forward from the outside to the inside.     iptables -A FORWARD -i eth1 -o eth1 -j REJECT          # Enable routing.     echo 1 > /proc/sys/net/ipv4/ip_forward      Another howto does not use a script but a file where some filter rules are defined. It looks like this:               *filter          # Allows all loopback (lo0) traffic and drop all traffic to 127/8 that doesn't use lo0     -A INPUT -i lo -j ACCEPT     -A INPUT ! -i lo -d 127.0.0.0/8 -j REJECT          # Accepts all established inbound connections     -A INPUT -m state --state ESTABLISHED,RELATED -j ACCEPT          # Allows all outbound traffic     # You could modify this to only allow certain traffic     -A OUTPUT -j ACCEPT          # Allows HTTP and HTTPS connections from anywhere (the normal ports for websites)     -A INPUT -p tcp --dport 80 -j ACCEPT     -A INPUT -p tcp --dport 443 -j ACCEPT          # Allows SSH connections      # THE -dport NUMBER IS THE SAME ONE YOU SET UP IN THE SSHD_CONFIG FILE     -A INPUT -p tcp -m state --state NEW --dport 30000 -j ACCEPT          # Now you should read up on iptables rules and consider whether ssh access      # for everyone is really desired. Most likely you will only allow access from certain IPs.          # Allow ping     -A INPUT -p icmp -m icmp --icmp-type 8 -j ACCEPT          # log iptables denied calls (access via 'dmesg' command)     -A INPUT -m limit --limit 5/min -j LOG --log-prefix "iptables denied: " --log-level 7          # Reject all other inbound - default deny unless explicitly allowed policy:     -A INPUT -j REJECT     -A FORWARD -j REJECT          COMMIT      What are the pros and cons of both ways of setting up iptables? Background info is much appreciated because I'm quite new to the whole thing. For example, I don't get who is reading the file from the latter howto, and how it is processed. My feeling tells me the second howto suggests a better solution, but why exactly?


title: How to detect network connection failure?

text: I have a direct Ethernet connection between a Windows box and a Linux box. If I disable the connection on the Windows side Linux still seems to believe the link is up. Is this normal behaviour? I would like Linux to run `if down` if the link fails and `ifup` when it returns. Is that possible?


title: Keep private key for remote reprepro package archive local

text: Currently I am using _reprepro_ and _inoticoming_ to maintain a Debian package archive on a remote machine. The repo is configured with this distributions file:               Origin: ...     Label: ...     Codename: squeeze     Architectures: i386 amd64 armhf source     Components: main     Description: ...     Log: /home/apt/log/reprepro.log      The daemon is running with:               inoticoming \       --logfile /home/apt/log/upload.log \       /home/apt/incoming \       --stdout-to-log \       --stderr-to-log \       --suffix .changes \       reprepro -Vb /home/apt --waitforlock 1000 processincoming default {} \;      I am building and signing my packages locally and then upload with _dupload_. However when I try to install a package from that archive I get:               WARNING: The following packages cannot be authenticated!      Is there a way to make the signatures work? I absolutely don't want to share my private GPG key with the remote machine. Are there other tools or a better suited workflow?


title: Ubuntu 13.04 Mouse settings don't affect my mouse?

text: I have a Razer Deathadder mouse. I haven't installed any drivers for it or anything yet. Do I need to? The mouse sensitivity settings don't have any effect on my mouse. The `xinput` settings do however. The whole reason I'm looking into this is I want to turn off mouse acceleration, which I've seen many answers for. Also the mouse sensitivity settings in StarCraft II (I'm using wine) don't work either. I have used:               xinput set-prop 11 265 -1 #acceleration profile. Default is 0     xinput set-prop 11 266 1 #constant deceleration, I have tried settings between 1 and 2, higher is slower     xinput set-prop 11 268 1 #velocity scaling, this doesn't seem to do anything noticable. Default is 10     xset m 0 0 #not sure what this is...      in several combinations. I have used the `razercfg` tool before with Ubuntu 12.04. It slowed down my mouse when I was having the problem of it being super fast (I don't have that issue in 13.04). Other than that it didn't do a whole lot, other than let me configure LEDs.


title: Pruning the package tree with apt-get and yum

text: I love the Macports and Arch package managers, because I can generate a listing of all of the packages that I have manually installed, and "prune" the package tree every once in a while to keep my distribution lean. I would like to know how I can do this using `apt-get` and `yum`. For example, with Macports, I can type `port echo requested` and get a nice listing of all of the packages that I have explicitly installed. If I see a package I installed a few weeks ago that I no longer need, I can immediately uninstall it. To get rid of unused dependencies, I can repeatedly execute `port uninstall leaves`. Analogous commands are available using `pacman`. It is not clear to me how I can achieve similar functionality using `apt-get` and `yum` after reading the relevant man pages and doing a fair amount of Googling. One of the most important functions of a good package manager should be to let the administrator easily manage the list of explicitly installed packages. Certainly I am missing something. Thanks for your help!


title: How do I enable sound in this fresh Arch install?

text: I'm following the Arch Beginner's Guide. I have Arch running. Now I'm working on the post-installation instructions, one of the first parts of which is to unmute the speakers. This is where my problem is. First, I installed alsamixer               pacman -S alsa-utils      Then this               amixer sset Master unmute      I get this error:               amixer: Unable to find simple control 'Master',0      I don't know how to proceed. **EDIT** :               # cat/proc/asound/cards     0 [MID]: Hda-Intel - HDA Intel MID              HDA Intel MID at 0xf7e14000 irq 63     1 [PCH]: Hda-Intel - HDA Intel PCH              HDA Intel PCH at 0xf7e10000 irq 59           # amixer -c1 sset Master unmute     Simple mixer control 'Master',0     Capabilities: pvolume pvolume-joined pswitch pswitch-joined     Playback channels: Mono     Limits: Playback 0 - 87     Mono: Playback 60 [69%] [-20.25dB] [on]          # speaker-test -c 2          speaker-test 1.9.27.2          Playback device is default     Stream parameters are 48000Hz, S16_LE, 2 channels     Using 16 octaves of pink noise     ALSA lib pcm_dmix.c:1022:(snd_pcm_dmix_open) unable to open slave     Playback open error: -2, No such file or directory


title: gvim on RHEL (Red Hat Enterprise Linux) install in home directory

text: How to install **gvim** on a RHEL server that doesn't have it (for use with SSH with X11 forwarding*)? No sudo access is available, so it has to be in the user's home directory. *Getting all the convenience of having the remote Vim in a window that's separate from the shell.


title: Command to reread partitions from media

text: When I insert media (e.g. an SD card) the system (Ubuntu 12.04) reads the partition table and creates all the /dev/*[1234] links to each partition. If I repartition the media I have to physically remove and reinsert it to update these links. Is there a command to force this to happen without me having to remove and reinsert the disk?


title: Open man page and search for string in a single command

text: Instead of doing `man chmod` and then `/a+x` to jump to the first section in the chmod man page that mentions `a+x`, I would like to know if there is a way to open the man page to a specific search string, similar to how you can do `vi +string filename.txt` in vi(m).


title: `test` and `[` - different binaries, any difference?

text: I noticed while answering another question that `test` and `[` are different binaries, but the `[` manpage pulls up `test`'s. Besides the requirement for an ending `]`, is there any difference? If not, why are they separate binaries instead of being symlinked? (They are also `bash` builtins, and `bash` doesn't show a difference either.)


title: Removing Clock screenlet in Linux Mint

text: I admit the question is kind of stupid, but I honestly can't do anything about this weird issue. I've added a Clock screenlet (with a custom theme) on my desktop and the thing is that I can't remove it. What I can do is to add another clock, click on it and "Quit all clocks" which removes them from the screen, but I can't remove the first one individually. The problem is that usually you can click on it and it shows the menu. But in this case wherever I click it shows ordinary desktop options, so I can't select it in any way. How can I do it, maybe there is some way of interacting with them through command line?


title: why is ! character used in shell scripts

text: I recently encountered a situation where I tried to use `!` as a record separator for my string array in shell script. When I used it in my shell script, the script got expanded automatically. An example to reproduce the situation can be as below.               check_variable="Hello"     echo "$check_variable"     Output: Hello     ###For multiple strings, I tried to concatenate with ! as a record separator.      echo "$check_variable !"     Output: echo "$check " > Results.txt      Then after some research, I had figured out `!` is in fact a special character and should not be used as record separators. So, exactly why is `!` used? Is there any way I can turn off the `!` character and use it in my shell script?


title: What does !$ mean exactly?

text: `echo !$` outputs different strings depending on my previous command line call. For example:               mrdumbdumb-redhat:~ mrdumbdumb$ ls     mrdumbdumb-redhat:~ mrdumbdumb$ echo !$     echo ls     ls          mrdumbdumb-redhat:Documents mrdumbdumb$ cd -     /     mrdumbdumb-redhat:~ mrdumbdumb$ echo !$     echo -     -      `!$` seems to expand to the last argument of my last command or the command itself if the command lacked arguments. What exactly is `!$`?


title: What does !$ mean?

text: I'm following through a tutorial and it mentions to run this command:               sudo chmod 700 !$      I'm not familiar with `!$`. What does it mean?


title: Using find to find symlinks that point to a certain pattern of files

text: I have several directories that all have various symlinks in them. I want find (or another program) to find based on where the symlinks point to. For example this is how it currently works:               └─(11:05:%)── ll slink     lrwxrwxrwx 1 dialout 9 2010-11-03 11:05 slink -> /opt/file     └─(11:05:%)── find / -name 'file' This is what I'd like to be able to do               └─(11:05:%)── find . -name 'file'     /slink -> /opt/file


title: Forcing emacs to run with `-nw` when called from terminal

text: **note** : This question might have been asked before ( I think I saw it somewhere), but a quick search did not reveal anything. I would like to tell the difference when a command is run from a shell. Emacs can be initialized with the `-nw` flag to disable the **gui** window, and I want this to be the default behaviour. However if `emacs` is run from a non-shell environment, ( e.g. from the `Open With` in your **filemanager** , a **desktop configured hotkey** , or even from **bashrun** ), it should not be called with the `-nw` flag. **update** : This should be a global change, running `sudo emacs` in Terminal should'nt suddenly open a gui. Where do I make these changes?


title: Ambiguously named executables

text: It appears that in `tcsh` if I have ambiguously named executables in two separate folders in the `$PATH` it directs to the one in the most recently created folder. Am I correct? And is this always true?


title: Why hard links not allowed to directories in UNIX/Linux

text: I read in text books that UNIX/Linux doesn't allows hard links to directories but soft links do. Is it because, when we have cycles and if we create hardlinks, and after some time we delete the original file, it will point to some garbage values? If cycles were the sole reason behind not allowing hardlinks, then why softlinks are allowed to directories?


title: How do I know why NetworkManager failed to initiate the VPN connection?

text: I'm running Arch Linux, and recently updated the whole system. Now I every time I connects to VPN with `nmcli` command, if it fails, I couldn't figure out the reason:               NetworkManager[15967]: <info> VPN plugin state changed: starting (3)     NetworkManager[15967]: <info> VPN connection 'XXX' (Connect) reply received.     NetworkManager[15967]: <warn> /sys/devices/virtual/net/ppp0: couldn't determine device driver; ignoring...     NetworkManager[15967]: <warn> VPN plugin failed: 1     NetworkManager[15967]: <warn> VPN plugin failed: 1     NetworkManager[15967]: <warn> VPN plugin failed: 1     NetworkManager[15967]: <info> VPN plugin state changed: stopped (6)     NetworkManager[15967]: <info> VPN plugin state change reason: 0     NetworkManager[15967]: <warn> error disconnecting VPN: Could not process the request because no VPN connection was active.      Prior to the upgrade, I can see error messages from pppd, e.g "You're already logged in bla bla", now every helpful message is gone. Any ideas? Why is the connection failed?


title: Bash script doesn't work as cronjob

text: I'm trying to get this simple bash script to work within a cronjob. It's used to generate static nginx webserver statistic pages using GoAccess. I tried everything I know to resolve this issue, it just won't work as a cronjob. It's executed perfectly in console. It's even working as cronjob when I remove the call to goaccess (e.g. put an echo there to see if the call is built correctly). Any help on this? The script runs for every file but the resulting files only contain the "how to use" instructions from goaccess which appear when you call it without arguments. System is a vServer running Debian 6.0. I use GoAccess 0.5 and nginx 1.2.1 Here's the script:               #!/bin/bash     PATH=/bin:/sbin:/usr/bin:/usr/sbin:/home/          _logdir="/srv/www/logs"     _logfiles="${_logdir}/access_*.log"          for logfile in $_logfiles; do             _curfilename="${logfile##*/}"             # All these commands work flawless             #echo "$logfile" >> /home/debug.log             #echo "$_curfilename" >> /home/debug.log             #echo "goaccess -a -f $logfile > /srv/www/stats/${_curfilename}.html" >> /home/debug.log;                  # This one fails             goaccess -a -f "${logfile}" > "/srv/www/stats/${_curfilename}.html";     done      Here's the crontab line for once an hour (i used * * * * * for debugging):               0 * * * * /bin/bash /home/run_webstats_update.sh      Error output in cron.log:               /USR/SBIN/CRON[26099]: (root) CMD (/bin/bash /home/update_webstats.sh)     /USR/SBIN/CRON[26098]: (CRON) error (grandchild #26099 failed with exit status 1)


title: TAR not excluding directories with date pattern

text: I've written this small script:               #!/bin/bash     TODAY=`date --rfc-3339=date`     CHECKDATE=`date --date "2 days ago" --rfc-3339=date`     FILENAME=$TODAY-package.tar          tar cvf $FILENAME --no-recursion --after-date $CHECKDATE *     tar uvf $FILENAME --after-date $CHECKDATE require plugin img      This should (at least in my intentions) create a .tar file with both files _and_ directories modified _after_ given date (which is 2 days before the script execution date) for what concerns root directory, and act recursively in case of _require_ , _plugin_ and _img_ directories. Problem is, it looks like to be correctly excluding older files, while it's adding _every single directory_ to the .tar, even the oldest ones. I've tried adding */* after the *, without success. Any hints?


title: Any utility to find source of system load / load average for a certain period?

text: By running top, htop, uptime, etc. we can see the load average as three values indicating the average load for the last 1/5/15 minutes (well not really, but that isn't the question here). Sometimes I'll notice that I have a fairly high load average for the last 15 minutes, but the current load is very low. Is there a utility/program that can list the processes (even if they no longer exist) that consumed the most CPU- time for the last 1/5/15 minutes (or some other similar period)? I am aware that load average can also be caused by processes waiting for I/O, but I am mostly interested in seeing the most CPU-hungry applications (though being able to see historic I/O would also be nice). As far as I know running htop and sorting by time cannot help me here, since if the computer has been on for a while the top values will not necessarily have anything to do with the recent past.


title: How to set tz and date without restart in Debian Squeeze?

text: I've tried `tzselect` and all it appears to do is tell me what region I want to pick. I'm trying to change tz without a restart and for all users, then sync the time accordingly.


title: Why can't I kill a timeout called from a Bash script with a keystroke?

text: [Edit: This looks similar to some other questions asking how to kill all spawned processes – the answers all seem to be to use pkill. So the core of my question may be: Is there a way to propagate Ctrl-C/Z to all processes spawned by a script?] When calling a SoX `rec` with the `timeout` command from coreutils (discussed here), there doesn't seem to be any way to kill it with a keystroke once it's been invoked from within a Bash script. Examples:               timeout 10 rec test.wav      ...can be killed with `Ctrl`+`C` or `Ctrl`+`Z` from bash, but not when it's been called from inside a script.               timeout 10 ping nowhere      ...can be killed with `Ctrl`+`C` or `Ctrl`+`Z` from bash, and with `Ctrl`+`Z` when it's run from inside a script. I can find the process ID and kill it that way, but why can't I use a standard break keystroke? And is there any way to structure my script so that I can?


title: How much space would be freed by removing a btrfs subvolume?

text: Is there any way to calculate how much space I would free if I would remove one (or several) subvolumes on a Btrfs disk (without actually removing them)? I know that there is "currently no code that will do the calculation for you", but how would you do it? I also wonder why they are saying that it would be so slow? Both actually removing a subvolume and asking about free space is very fast in my experience, why would doing the same thing hypothetically be so much slower?


title: How to compress with bzip2 and gzip using xar?

text: In the "Why Xar" page of the Xar Google Code page it says: > Additionally, this means xar can use different compression methods for each > file in the archive. For instance, it might not be a good idea to try to try > to compress an already compressed file, but a large file might benefit > greatly from using bzip2, whereas a small text file would be better served > to use gzip. I read the man page and it does not indicates how to do this. So, does anyone know how?


title: Installing PostgreSQL 9.0 on RHEL 6.4 (How to get Yum to Include a version of OpenSSL I built from source)

text: I receive the following errors from **yum install postgresql90-server** :               Error: Package: postgresql90-9.0.15-1PGDG.rhel6.x86_64 (pgdg90)            Requires: libssl.so.10(libssl.so.10)(64bit)     Error: Package: postgresql90-server-9.0.15-1PGDG.rhel6.x86_64 (pgdg90)            Requires: libssl.so.10(libssl.so.10)(64bit)     Error: Package: postgresql90-libs-9.0.15-1PGDG.rhel6.x86_64 (pgdg90)            Requires: libcrypto.so.10(libcrypto.so.10)(64bit)     Error: Package: postgresql90-server-9.0.15-1PGDG.rhel6.x86_64 (pgdg90)            Requires: libcrypto.so.10(libcrypto.so.10)(64bit)     Error: Package: postgresql90-libs-9.0.15-1PGDG.rhel6.x86_64 (pgdg90)            Requires: libssl.so.10(libssl.so.10)(64bit)      The first result on google indicated that postgresql 9+ requires `openssl 1.0.1`. A `yum info openssl` revelaed that I had openssl 1.0.0. A `yum update openssl` told me that I had the latest upgrade. So I figured I would build 1.0.1:               wget http://www.openssl.org/source/openssl-1.0.1e.tar.gz     tar -xvf openssl-1.0.1e.tar.gz     cd openssl-1.0.1e     ./config     make     make test     make install      But now I am at a loss on how I would get yum to realize that I have the right openssl. The `yum install postgresql90-server` results in the same error message above. I figure if I could sync up yum with my new version of openssl, I would be good. But I am a Linux noob.


title: Resume last print job from command line

text: To resume a job from command line I can call `lpq` which gives me the job number for example 211 and then `lp -i 211 -H resume`. However is there a way   * to resume the _last_ job without figuring out its job id first   * to resume just all holded jobs with one command


title: Text processing - join lines with commas

text: I have more than 1000 lines in a file. The file starts as follows (line numbers added):               1. Station Name     2. Station Code     3. A N DEV NAGAR     4. ACND     5. ABHAIPUR     6. AHA     7. ABOHAR     8. ABS     9. ABU ROAD     10. ABR      I need to convert this to a file, with comma separated entries by joining every two lines. The final data should look like               Station Name,Station Code     A N DEV NAGAR,ACND     ABHAIPUR,AHA     ABOHAR,ABS     ABU ROAD,ABR     ...      What I was trying was - trying to write a shell script and then `echo` them with comma in between. But I guess a simpler effective one-liner would do the job here may be in `sed`/`awk`. Any ideas?


title: Manually generate password for /etc/shadow

text: I need to manually edit /etc/shadow to change the root password inside of a virtual machine image. Is there a command-line tool that takes a password and generates an /etc/shadow compatiable password hash on standard out?


title: How to call a KSH script from another KSH script

text: I want to call a KSH script a KSH script. Script 1 performs the following:   1. Loops thru a list of database server   2. Perfroms a query   3. Appends output from query from each database server to a txtfile Script 2 performs the following:   1. Creates an HTML file that displays the each row in the text file in an HTML File   2. Emails the HTML file with the query results to a list of receipeints Usage: KSH backup_report.ksh qry_rslt_textfile.txt   (txtfile contains results of query from each server) Is the following syntax correct?               #! /bin/ksh     < Start of Script 1 Code>     .     .     .     < End of Script 1 Code>          < Start of Script 2 Code - Call Script 2>     /sybase/dba/backup_report.ksh qry_rslt_textfile.txt     <End of Script 2 Code>


title: Keyboard layout panel applet in MATE 1.6

text: I'm on a system with MATE 1.6.1. I didn't find the `Keyboard Indicator Applet` in `Add to Panel` list. How can I add this applet to a panel?


title: How do you find what keys the "erase" and "line-kill" characters are in Ubuntu?

text: I'm new to Unix and have bought today a copy of "The Unix Programming Environment". I'm trying out the stuff from the book. But some of them are not working as expected like : To kill a line and re-type it again, **@** character should be used : **book**               $ ddtae@     date     Thu Nov 28 18:12:47 IST 2013      **my terminal**               $ ddtae@     ddtae@: command not found      Another example is to use **#** to erase last character **book**               $ dd#att#e#e      which comes out as date and print it. **my terminal**               $ dd#att#e#e     dd#att#e#e: command not found      _in my system # is used for commment_ Although they have mentioned that these characters are system dependent. How can i find the characters for my system to perform above two tasks.


title: How can I allow a user to prioritize a process to negative niceness?

text: I want a user to run a specific process on the system with a negative nice value. I can't simply fork the process to background as this specific program is a minecraft server and I rely on the command line to control the server. My current bash script looks like this (the important part):               sleep 10 && \     sudo renice -n $NICENESS $(ps -u $(id -u) -o "%p:%c" | sed -n "s/:java$//p") & \     java -Xmx8G -Xms2G -jar minecraft_server.jar nogui          `sleep` simply delays execution of `renice`. `renice` itself uses `ps` to check for a java process using the users own ID. There might be other instances of java spawning under different users, but the minecraft server runs under its own user _minecraft_. I obviously don't want to enter a password every time I start the server.   from _/etc/sudoers_ :               minecraft ALL = NOPASSWD: /etc/renice      Is there a more elegant way to do this? Simply using `nice` is not an option, `sudo nice bash` in combination with the _NOPASSWD:_ option would be a great security issue.


title: Is there a quick way to download a directory in a repo?

text: I'm actually working from a _windows_ machine, attempting to retrieve **centOS 5.4** from their vault. I don't have unpacking software, so I don't want to use the iso's. I was wondering if there's an easy way to grab all of the contents of this directory inside a browser.


title: Where in the linux kernel sources can I find a list of the different keyboard scancodes?

text: I was looking for a list of keyboard scancodes in the linux kernel sources, but I did not find anything. Does someone know where to find these? Especially the USB scancodes would be interesting.


title: How to debug a device that changes from /dev/ttyUSB0 to /dev/ttyUSB1 at will?

text: I have a device plugged to a CentOS server that changes randomly from /dev/ttyUSB0 to /dev/ttyUSB1 and vice versa. The device I'm trying to connect is this one. How can I debug this?


title: Unable to compile simple Less file using node-less

text: I'm trying to compile a _very_ simple less file which simply includes Bootstrap:               /* application.less: The most awesomely complicated file in the whole world. */     @import "bootstrap/bootstrap.less";      I'm on an Ubuntu 12.04 derivative and I've tried using the `lessc` compiler found in the `node-less` package:               $ sudo apt-get install node-less     ...done!     $ ( cd /path/of/less/file/ && lessc application.less )     TypeError: Cannot call method 'charAt' of undefined         at getLocation (/usr/lib/nodejs/less/parser.js:204:34)         at new LessError (/usr/lib/nodejs/less/parser.js:213:19)         at Object.toCSS (/usr/lib/nodejs/less/parser.js:379:31)         at /usr/bin/lessc:103:28         at /usr/lib/nodejs/less/parser.js:428:40         at /usr/lib/nodejs/less/parser.js:94:48         at /usr/lib/nodejs/less/index.js:113:15         at /usr/lib/nodejs/less/parser.js:428:40         at /usr/lib/nodejs/less/parser.js:94:48         at /usr/lib/nodejs/less/index.js:113:15      Not easily deterred, I then tried using the Ruby version of lessc.               $ sudo apt-get remove --purge node-less     $ sudo gem install less     ...done!     [WARNING] Please install gem 'therubyracer' to use Less.     /usr/lib/ruby/vendor_ruby/1.8/rubygems/custom_require.rb:36:in `gem_original_require': no such file to load -- v8 (LoadError)         from /usr/lib/ruby/vendor_ruby/1.8/rubygems/custom_require.rb:36:in `require'         from /var/lib/gems/1.8/gems/less-2.2.2/lib/less/java_script/v8_context.rb:2         from /usr/lib/ruby/vendor_ruby/1.8/rubygems/custom_require.rb:36:in `gem_original_require'         from /usr/lib/ruby/vendor_ruby/1.8/rubygems/custom_require.rb:36:in `require'         from /var/lib/gems/1.8/gems/less-2.2.2/lib/less/java_script.rb:9:in `default_context_wrapper'         from /var/lib/gems/1.8/gems/less-2.2.2/lib/less/java_script.rb:17:in `context_wrapper'         from /var/lib/gems/1.8/gems/less-2.2.2/lib/less/loader.rb:10:in `initialize'         from /var/lib/gems/1.8/gems/less-2.2.2/lib/less.rb:14:in `new'         from /var/lib/gems/1.8/gems/less-2.2.2/lib/less.rb:14         from /usr/lib/ruby/vendor_ruby/1.8/rubygems/custom_require.rb:36:in `gem_original_require'         from /usr/lib/ruby/vendor_ruby/1.8/rubygems/custom_require.rb:36:in `require'         from /var/lib/gems/1.8/gems/less-2.2.2/bin/lessc:3         from /usr/local/bin/lessc:19:in `load'         from /usr/local/bin/lessc:19      Come on! Ruby doesn't know how to manage dependencies?! Whatever. Fine.               $ sudo gem install therubyracer     /usr/bin/ruby1.8 extconf.rb     checking for main() in -lpthread... yes     checking for v8.h... no     *** extconf.rb failed ***     Could not create Makefile due to some reason, probably lack of     necessary libraries and/or headers.  Check the mkmf.log file for more     details.  You may need configuration options.          Provided configuration options:         --with-opt-dir         --without-opt-dir         --with-opt-include         --without-opt-include=${opt-dir}/include         --with-opt-lib         --without-opt-lib=${opt-dir}/lib         --with-make-prog         --without-make-prog         --srcdir=.         --curdir         --ruby=/usr/bin/ruby1.8         --with-pthreadlib         --without-pthreadlib         --enable-debug         --disable-debug         --with-v8-dir         --without-v8-dir         --with-v8-include         --without-v8-include=${v8-dir}/include         --with-v8-lib         --without-v8-lib=${v8-dir}/lib     /var/lib/gems/1.8/gems/therubyracer-0.11.0/ext/v8/build.rb:42:in `build_with_system_libv8': unable to locate libv8. Please see output for details (RuntimeError)         from extconf.rb:22         The Ruby Racer requires libv8 ~> 3.11.8         to be present on your system in order to compile         and link, but it could not be found.              In order to resolve this, you will either need to manually         install an appropriate libv8 and make sure that this         build process can find it. If you install it into the         standard system path, then it should just be picked up         automatically. Otherwise, you'll have to pass some extra         flags to the build process as a hint.              If you don't want to bother with all that, there is a         rubygem that will do all this for you. You can add         following line to your Gemfile:             gem 'libv8', '~> 3.11.8'              We hope that helps, and we apologize, but now we have         to push the eject button on this install.              thanks,         The Mgmt.      And I'm done. Is there any _easy_ way to get a _working_ less compiler installed on my distribution? This is getting ridiculous.


title: Running Linux from pendrive on Windows natively

text: I am trying to find a program that allows me to run some linux distribution directly from pendrive, in windows, without the need to access the bios or to have administrator permissions. I need something like colinux or ubuntu portable. But I need a solution that is portable and don't need administrator permissions to execute the linux distribution. Someone knows a program like this?


title: What happens if I delete dmraid?

text: I am new to Linux and am trying to install Ubuntu 12.04.3 LTS from a live-USB and have it run alongside my Windows 7 installation. On the installation screen for Ubuntu, at the partition page, I get this error:               No root file system is defined.          Please correct this from the partitioning menu.      However on this page, nothing is clickable and it doesn't show any partitions. I looked it up and I found a possible solution is to type in the Linux terminal:               sudo apt-get remove dmraid      I am wondering what the repercussions are of deleting dmraid and if it will do anything disastrous to my Windows boot. And if deleting dmraid isn't a smart idea, are there any other suggestions on what I should do? BTW I am on an Acer S5-391 and I think it has a RAID 0 SSD configuration.


title: Process history in Unix/Linux systems

text: I know that `ps -efl` shows running processes on *nix systems. I would like to check history of the (past) processes that have been run on a particular machine, preferably with all the information `ps` provides (i.e. `%CPU`, `%MEM`). What command line utilities can I use, is this information stored somewhere similarly to `.bash_history` file?


title: how do I recursivley grep (or otherwise search for) hex strings

text: Long and short I'm trying to track down some files left by evil scum on a server. > fgrep -r "STRING" /path/here has been working well for finding general stuff. However, how do I search for hex patterns (you know... \xNN type strings). Probably an easy question to answer but I've been spending too long starting at a bash screen !


title: In Ubuntu, what is the folder in which MySQL's UDF should be installed?

text: I am using Ubuntu 14.04. I wonder where should I install binary UDF for MySQL. Is there any way to discover the path of the UDF directory? Is there a standard for this in Ubuntu?


title: Last failed command in bash

text: The `$?` variable holds the exit status of last run command. Is there a variable that holds last run command itself?


title: Inderect references aka value of a value in awk

text: I'm searching for a way to solve this problem in `awk`. Input:               X 1     Y 2     Z 3     X 4     Y 5      The output should look like this:               X 5     Y 7     Z 3      I see two problems here: the first one is the indirect reference in `awk`. Is it even possible?   It would work this way: if `$$1 (X) exists add $2 else declare $$1 (X) then add $2`   Even if I would figure out how to do it I would still need to know the name of all the declared variables i.e. X,Y,Z. I'm guessing there is a simpler way to handle this task but I can't figure it out...


title: Do you know any campaign manager running on linux?

text: I'm searching for a RPG (roleplaying game) campaign manager running on Linux. The main features are mapping capabilities and intuative layout. Does any of you know one?


title: regarding shared memory behaviour

text: Noticing a strange performance behaviour while using shared memory that are file backed (i.e open user defined file and mmap() the same into process space). While doing a memcpy() into the shared memory section, sometimes a delay is observed in the order of milliseconds. To be specific, in normal scenarios 2048 bytes are copied in 0.4us but sometimes the same number of bytes takes about 10 - 20 milliseconds to copy. This happens randomly any time. The next 2048 frame of data goes back to the normal time. Kernel version is 2.6.27.23-0.1-preempt. Appreciate any clues from anyone, about what is happening and why the delay is seen. I have even tried by using shm_open() and then mmap(), with no difference The `mmap` calls look like this:               int fd = ::open("somefile", flags, 0666);     if(fd != -1) {       myBasePointer = ::mmap(0, sizeInBytes,                              PROT_READ|PROT_WRITE, MAP_SHARED,                              fd, offsetInBytes);     }       One process creates the file and `mmap`s, the other processes opens the file and `mmap`s itinto their address space. The file is a normal file on an ordinary filesystem.


title: apt-get without installing recommendations for a certain package

text: I can edit               /etc/apt/apt.conf      and add the line:               apt::install-recommends "false";      But that will always skip recommendations. How can I do this only once for the installation to a certain package without changing the config of apt?


title: Setting console font in vconsole.conf does not work (systemd)

text: I am trying to set a different default console font for my new Arch Linux installation (using systemd). I set up my `vconsole.conf` in `/etc` as so:               KEYMAP=us     FONT=Lat2-Terminus16      I rebooted and saw my newly set console font appear, only for it to reset just before the login prompt. Things to note:   * running `/usr/lib/systemd/systemd-vconsole-setup` manually works fine   * `systemctl status systemd-vconsole-setup.service` tells me that it has loaded and is "active (exited)"   * I have indeed included the `consolefont` hook in `mkinitcpio.conf`


title: How can I tell if a kernel has some "new" config?

text: I'm making a simple kernel auto build script, right now I need to detect if there's a new config that need to ask the user (I don't want to use the default value), if so, it launches `make menuconfig` first, otherwise skip that part. Normally it just ask me to pick between `N`, `Y`, `M`. Is it possible?


title: How to start linpus linux on an Acer Gateway NE56R?

text: I just purchased a laptop and the pre-installed OS is Linpus Linux. It only shows:               [root@localhost /]#      What do I do? How can I tell if X is running? Do I need to install it?


title: Is there any way to play gpu accelerated video without X?

text: You can play use mplayer on fbdev, but not with the gpu. That's as close as I can find.


title: Fedora 15 screensaver won't wake up after about 10 hours

text: I can switch to another Terminal via `CTRL`+`ALT`+`F2`, but the screen remains black and won't wake up. Sometimes, it wakes up after several retries. Any ideas to resolve it?


title: What does this netcat output mean?

text: I want to telnet into my locally running VM which has a dictd service running on port 2628, when I issue my nc -v command though I get the following:               $ nc -v localhost 2628     nc: connectx to localhost port 2628 (tcp) failed: Connection refused     found 0 associations     found 1 connections:          1: flags=82<CONNECTED,PREFERRED>         outif lo0         src 127.0.0.1 port 63929         dst 127.0.0.1 port 2628         rank info not available         TCP aux info available          Connection to localhost port 2628 [tcp/dict] succeeded!      Why is there a connection refused and then a connection succeeded later on? What does this mean and why won't it accept my connection when I just do: `telnet localhost 2628`?


title: why ls reports a huge file and du does not?

text: When I run `arm-none-eabi-objcopy -O binary add.elf add.bin` everything seems to be ok. But, later when I run `ls -lh add.bin add.elf` this is the output I received:               -rw-r--r-- 1 david david 2,6G nov 23 22:49 add.bin     -rwxr-xr-x 1 david david 65K nov 23 22:40 add.elf      this is a huge file. But when I run `du -h add.bin` the output is:               8,0K    add.bin      What's happening here? Edit: Output of `arm-none-eabi -A -t -x add.bin`:                Warning: could not locate 'add.bin'.  reason: Value too large for defined data type      Output of `arm-none-eabi -A -t -x add.elf`:               section           size         addr     .text             0x2c          0x0     .data              0xc   0xa0000000     .ARM.attributes   0x14          0x0     Total             0x4c      Output of `du -bh add.bin`:               2,6G    add.bin      This is how I fixed it: Initially when I link the program with the command `arm-none-eabi-ld -Tld_script.lds -o add.elf add.o` the ld script file `ld_script.lds` contains this:               SECTIONS {             . = 0x00000000;             .text : {                      * (.text);              }                  . = 0xA0000000;  /* RAM starting address */             .data :{                      * (.data);              }     }      The above code fills from 0x00000000 to 0xA0000000 with 0s. This error can be solved the following way:               SECTIONS {             . = 0x00000000;             .text : {                      * (.text);              }             flash_sdata = .; /* Start data in flash right after the text */                  . = 0xA0000000;  /* RAM starting address */             ram_sdata = .;                  /* AT specifies the load addr. of .data section */             .data : AT (flash_sdata) {                      * (.data);              }             ram_edata = .;   /* Address of end of data in RAM */             data_size = ram_edata - ram_sdata;     }      And then in the source I added a piece to copy the data from Flash to RAM. Something like this:                       @ Copy data to RAM.     start:             ldr   r0, =flash_sdata             ldr   r1, =ram_sdata             ldr   r2, =data_size          copy:             ldrb  r4, [r0], #1             strb  r4, [r1], #1             subs  r2, r2, #1             bne   copy      If my English is not too precise, this is the link which helps me to fix the problem. (And a good site for learning ARM embedded programming).


title: Bridged network with different subnets

text: I want to virtualize my webserver with lxc/virsh for this reason, I want to pass a IP to the lxc container. But my IPs are from different subnets, what I tried (but not successfully): Virsh network:               <interface type='bridge'>         <source bridge='br0'/>         <model type='virtio'/>     </interface>      IP 1: xxx.xxx.184.96 (Dedicated Server IP) xxx.xxx.37.220 (For LXC) /etc/network/interfaces:               auto lo     iface lo inet loopback          # The primary network interface     auto eth0               iface eth0 inet static             address xxx.xxx.184.96             netmask 255.255.255.128             network xxx.xxx.184.0             broadcast xxx.xxx.184.127             gateway xxx.xxx.184.1             # dns-* options are implemented by the resolvconf package, if installed             dns-nameservers 8.8.8.8 8.8.4.4          iface br0 inet static             bridge_ports eth0             bridge_stp on             address xxx.xxx.37.220             netmask 255.255.255.255


title: How to do restorecon -f recursively?

text: I have tried both with a file and using standard input, and it seems it is impossible to get `restorecon -r -f [file|-]` to do anything at all. Is this possible?


title: gtk-color-scheme = "bg_color: red\ results in red bg + red scroll bar bg + red scroll bar ? where is the logic?

text: Let's edit this theme's gtkrc file:               vi vi /usr/share/themes/industrial/gtk-2.0/gtkrc          gtk-color-scheme = "bg_color: #000000000000\     nfg_color: #ffffff\nbase_color: #000000000000\     ntext_color: #ffffff\nselected_bg_color: #ffffff\     nselected_fg_color: #000000000000\     ntooltip_bg_color: #000000000000\     ntooltip_fg_color: #ffffff      Let's change the bg_color to "red" and apply the theme to the desktop. But the problem is this, the background of every scroll bar, and the foreground of the scroll bar, both become red, this makes it impossible to see the scroll bar due to the background being same color as the scroll bar. By scroll bar I am referring to the scroll bar in firefox web browser for example that you'd use to scroll up and down. I am currently using my mouse's wheel button because the scroll bar does not look visible. Why are colors being applied this way? Why isn't there a distinction between the foreground and the background of the scroll bars?


title: Gawk: Passing arrays to functions

text: Stuck with GNU awk 3.1.6 and think I've worked around its array bugs but still have what looks like a scope problem in a 600-line awk program. Need to verify understanding of array scope in awk to find my bug. Given this illustrative awk code...               function foo(ga) {       ga[1] = "global result"     }          garray[1] = "global"     foo(garray)          print garray[1]      will print...               global result      Since arrays are always passed to functions by reference, then all arrays are always global. There is no way to create a local array. Is this correct? Have been unable to find docs that explicitly say that. Since I'm debugging, and 3.1.6 itself has known bugs in this area, am trying to determine where awk's bugs leave off and mine begin. **Supplemental: Why does ga[] work inside the function then?** First of all, passing the array to the function with `foo(ga)` is actually unnecessary. Just access it as `garray[]` inside the function. There's no measurable performance penalty in doing it however, and it helps in debugging and error reporting. In using `foo(ga)`, `ga[]` is a synonym for the global array `garray[]`. Instead of being a local copy of `garray[]`, it is simply a pointer to `garray[]`, rather like a symbolic link is a pointer to a file and thus the same file (or array) can be accessed under more than one name. **Supplemental: Clarification of Glenn Jackman's answer** While arrays created _outside_ a function are global to the function and may be passed to it or just referenced within it, arrays created _inside_ a function do indeed remain local to the function and not visible outside it. Modifying Mr. Jackman's example illustrates this...               awk '         function bar(x,y) {           split("hello world", y)           print "x[1] inside: " x[1]           print "y[1] inside: " y[1]         }         BEGIN {           x[1]="goodbye"           print "x[1] before: " x[1]           print "y[1] before: " y[1]           bar(x)           print "x[1] after: " x[1]           print "y[1] after: " y[1]         }     '     x[1] before: goodbye     y[1] before:      x[1] inside: goodbye     y[1] inside: hello     x[1] after: goodbye     y[1] after:       Note that we are only passing the `x[]` array (actually, just a pointer to it) to `bar()`. The `y[]` array doesn't even exist until we get inside the function. However, if we declare `y[]` by including it in the `bar()` argument list without assigning anything to it outside the function, it becomes visible after calling `bar(x,y)`...               awk '         function bar(x,y) {           split("hello world", y)           print "x[1] inside: " x[1]           print "y[1] inside: " y[1]         }         BEGIN {           x[1]="goodbye"           print "x[1] before: " x[1]           print "y[1] before: " y[1]           bar(x,y)           print "x[1] after: " x[1]           print "y[1] after: " y[1]         }     '     x[1] before: goodbye     y[1] before:      x[1] inside: goodbye     y[1] inside: hello     x[1] after: goodbye     y[1] after: hello      Finally, if we create the `y[]` array outside the function and pass it with `bar(x,y)`, the `split()` assignment inside the function replaces that array's elements...               awk '         function bar(x,y) {           split("hello world", y)           print "x[1] inside: " x[1]           print "y[1] inside: " y[1]         }         BEGIN {           x[1]="goodbye"           y[1]="howdy"           print "x[1] before: " x[1]           print "y[1] before: " y[1]           bar(x,y)           print "x[1] after: " x[1]           print "y[1] after: " y[1]         }     '     x[1] before: goodbye     y[1] before: howdy     x[1] inside: goodbye     y[1] inside: hello     x[1] after: goodbye     y[1] after: hello


title: How do I turn on http compression?

text: I'm running a CentOS server and I want to save bandwidth, make pages faster, all that. How can I turn on http compression? Is it a module I enable for all sites? Can it be that simple?


title: Console tool to test internet bandwidth

text: I'm looking for a tool that will test my internet connection bandwidth and create an simple report like speedtest does. Do you know some program/tool that do this? Something with CentOS packages would be nice.


title: Find incoming symlinks

text: In Linux, what is the best way to find all symbolic links that point to a given file (regardless of whether the symlink is relative or absolute)? I realize this will require scanning the whole filesystem.


title: I use : gtk-chtheme & obconf , each one has 1 theme selected, for gtk-2.0 and non-gtk-2.0 areas, but when I delete all other themes.. stuff breaks

text: Based on my `obconf` I have "DiceBox" theme selected. Based on my `gtk- chtheme`, I have "Shiki-JetBlack" selected. Which means I can go into               /usr/share/themes/      and just delete everything except these two right? I did just that and suddenly my scroll bar's color changed when I re-loaded Firefox and other programs. Why? What other theme am I making use of besides these 2 that I don't know about?


title: Finding an earlier version to downgrade to

text: On my Debian server, I upgraded the SQLite package to version `3.7.7` but discovered that it contains a critical bug that breaks several things including my Subversion repository. So, I would like to downgrade back to the previous version I was using. But:   * I have no idea what that version was (I assume it was `3.7.6.3`, but I'm not certain).    * The only other version I find available for the SQLite package in `aptitude` is `3.5.9.6` which is too early for the Subversion package I'm using (it requires at least `3.6`).  How can I identify and downgrade to the version of SQLite I was using, and which might still be in a cache on my computer? Or, failing that, how can I tell `aptitude` where to download intermediate versions of that package?


title: Hibernate and security considerations

text: How do Linux and OSX handle sensitive memory pages (e.g. cryptographic keys) when running OS is suspended to disk? If the memory image written is encrypted, how are its keys handled?


title: Are all system call error numbers unique?

text: I'm writing a program for Systems Programming in Unix, and one of the requirements is to process all possible error returns from system calls. So, rather than having a function tailored to each system call, I'd like to have one function take care of that responsibility. So, are all error number returns unique? If not, what areas of overlap exist?


title: Debian: keep custom changes in initscript

text: I had to modify the initscript for Postfix `/etc/init.d/postfix` to customize it for my special needs. Now I want to ensure, that in case of the `postfix` package being updated in the future (I am running Debian Wheezy Stable, but there could still be a security update) my modified initscript will not be overwritten. As I understand, packages ask before overwriting `config` files, but not initscripts. What is the recommended way to do it (cleanly) ?


title: How do I copy and paste seperately?

text: I know for the `cp` command you have to specify the source(s) and destination. But what if I have to copy say all folders under `src` folder, **do some other operations** , and then `paste` later on? In short, can I separately copy and paste in a bash shell or a terminal?


title: How to follow and seek in a file being piped through a filter, in less

text: I basically wish to seek, search and follow a growing log file _after passing it through a`sed` filter_. I figured I need to follow a file with `tail -f` pipe it to `sed` and then pipe that to `less`. For testing, I first tried combining `tail -f` and `less +F` to no avail:   * `tail -f file | less +F` -- less doesn't run before one presses `Ctrl`+`C` to stop tail's following. `less` options `-B -b 1` do not help.   * `less +F -f <(tail -f file)` exhibits the same behavior. If anyone knows a better/simpler solution than what I figured out in the end, I'd appreciate it.


title: Avoiding "BASH-isms" in shell scripts

text: Does there exist a tool similar to Perl::Critic that will inspect your shell scripts and point out flaws, portability issues, uses of non-standard programs without fallbacks, depreciated program uses, etc? I realize that `set -o posix` will disable non-POSIX usage, but that won't tell me things I want to know, such as zsh indexing shell arrays starting at 1, and bash, from 0, and ash not supporting arrays at all.


title: Can I write control characters to someone else's terminal?

text: A lot of people log into the same AIX 6.1 server as I do with a terminal emulator that automatically interprets and runs code encapsulated by certain control characters as VBA script instead of writing it to the display. So as a prank, I have a file that contains a sequence of characters that displays a message in a popup box that I want to write to their terminals.               $ cat msgbox.txt       *message box pops up*      But when I write it to someone, the effect is lost: `$ cat msgbox.txt | write *my other sesssion*` On the other session:   `Message from *myself* [*datetime*] \o 33 *code to show a msgbox* \o 33\<EOT>` Where the "\o 33" replaces ASCII character 27. Is it possible to send control characters through write, or do I need to do something different?


title: How can same fd in different processes point to the same file?

text: Say I have _process 1_ and _process 2_. Both have a file descriptor corresponding to the integer 4. In each process however the file descriptor 4 points to a totally different file in the Open File Table of the kernel: ![enter image description here](http://i.stack.imgur.com/il1YV.png) How is that possible? Isn't a file descriptor supposed to be the index to a record in the Open File Table?