Store output from one command and process it for another

I am working on Unix command line. I have two files. I want to `cat file1.txt` and `grep` the output in `file2.txt` File1.txt               123A     223A     143A     153A     183A     123J     123P File2.txt:               123A (TYU)     223A (RUT)     143A (EWRW) 4     153A (TGBW) 89 ()     183A (23) YHYT      123J ikik 780     123P haja 123     XRQE haja 123     XRQE haja 909 The last 2 lines of `file2.txt` are not present in `file1.txt` I am trying to do something like: `head file1.txt | **and ??**` `grep file2.txt` I tried with `xargs`, `$variable` to store it, but shell hangs or doesn't work. Expected Output: _Edited_ : `               123A (TYU)     223A (RUT)     143A (EWRW) 4     153A (TGBW) 89 ()     183A (23) YHYT      123J ikik 780     123P haja 123


Practical use for moving file descriptors

According to the bash man page: > The redirection operator >   >   >        [n]<&digit- >   > > moves the file descriptor `digit` to file descriptor `n`, or the standard > input (file descriptor 0) if `n` is not specified. `digit` is closed after > being dupli‐cated to `n`. What does it mean to "move" a file descriptor to another one? What are the typical situations for such practice?


Mass deinterlacing with FFmpeg on Debian

I have about 300 videos, on a Debian server, stored in the following manner:               /mediaroot/1/m32.mp4     /mediaroot/2/m421.mp4     /mediaroot/n/mx.mp4      They all need to be deinterlaced, and I want to do it with FFmpeg. With the assistance of another helpful sole, I have reached a somewhat tolerable result with the following steps:   1. extract audio   2. transcode video, example              ffmpeg -y -i m148.mp4 -pix_fmt yuv420p -an -pass 1 -passlogfile m148.x600.1351896878.log -an -vcodec libx264 -b:v 600k -preset medium -tune film -threads 0 m148.x600.1351896878.mp4     ffmpeg -y -i m148.mp4 -pix_fmt yuv420p -an -pass 2 -passlogfile m148.x600.1351896878.log -an -vcodec libx264 -b:v 600k -preset medium -tune film -threads 0 m148.x600.1351896878.video.mp4        3. mux new video with audio extracted in step 1.    4. use qt-faststart to move the atoms              ffmpeg/qt-faststart m148.x600.1351896878.mp4 m148.x600.1351896878.atom.mp4      My question is then: How do I make it automatically deinterlace and replace all the videos?


Merge folders and replace files using CLI

I want to update some forum software and I'd like to test the upgrade process using CLI as a learning possibility. How do I merge contents of a folder into another folder and replace files?


Rotating logs generated from tcpdump with logrotate

On one production linux box, I am capturing SIP packets using the following configuration: **logrotate.conf:**               # Opensips SIP traces      /var/log/sip.log     {             rotate 31             daily             missingok             notifempty             compress             delaycompress             sharedscripts             postrotate                     pkill tcpdump                     /home/ubuntu/log-sip-messages.sh &             endscript     }      **log-sip-messages.sh:**               #!/bin/sh     tcpdump host 159.63.X.X -s0 -v >> /var/log/sip-159.63.X.X.log      This works great on the Ubuntu 11.04 server, but on the Ubuntu 12.10 boxes, this just produces a file with a timestamp at the time the logs were rotated. It's as if the pkill doesn't complete before running tcpdump again to start writing to the new file. I've tried running this directly from the terminal as an experiment:               pkill tcpdump && tcpdump -s0 -v udp >> /var/log/sip.log      and then when I run `ps aux|grep tcpdump` there's no process running, confirming what I already know... the pkill command runs asynchronously on 12.10 (but either is synchronous on 11.04 or just beats the 2nd command) How can I make this work so I can capture network traffic in a nice, readable log file (I don't need pcaps) without risking filling up my hard drive space?


ssh daemon error: sshd must be own

Running `service sshd restart` and then `service sshd status` on my system as root prints the following error: > Redirecting to /bin/systemctl status sshd.service sshd.service - OpenSSH > server daemon Loaded: loaded (/usr/lib/systemd/system/sshd.service; enabled) > Active: failed (Result: exit-code) since Sat, 16 Feb 2013 21:38:38 +0330; 6s > ago   >  Process: 2207 ExecStart=/usr/sbin/sshd -D $OPTIONS (code=exited, > status=255) Process: 2204 ExecStartPre=/usr/sbin/sshd-keygen (code=exited, > status=0/SUCCESS) CGroup: name=systemd:/system/sshd.service > > Feb 16 21:38:38 localhost.localdomain sshd[2207]: /var/empty/sshd must be > own... How do I find the cause of the problem?


Why does the history command do nothing in a script file?

If I create a file containing                #!/bin/bash       history      and run it, I get no output. Running it manually in a terminal or `source`ing the script file _does_ produce output. Why does `history` not work from a file?


What is logcheck, and why is it consuming 100% CPU out of the blue?

I have a server that's hardly used, basically a fresh linode VPS with Ubuntu 12.04 LTS. It has been running for 14 months with hardly a blip in the CPU graphs (2% max, average over 2 hours). Suddenly, the past 2 hours have been at 100%. The culprit is an `egrep` running by the user `logcheck`. Most references I find to this question on google are from many years ago (2005, 2007, 2010). Any suggestions? Killing the process just spawns another one. I'm not sure what this is: all the docs I find point to gentoo where it appears to be a log filtering program for sending data to sysadmins. If this isn't something that is scheduled by default with `ubuntu`, I'm not sure why it's running at this particular moment. ![enter image description here](http://i.stack.imgur.com/aNoKd.png) ![enter image description here](http://i.stack.imgur.com/gb4KB.png)


`Error: no such device...` after installing Arch

I've seen many threads about this error but I couldn't find a solution. I've installed Arch Linux alongside Windows 8. (Dual Boot). I followed this video exactly but am getting the error below at 20:35. After a reboot I'm getting:               error: no such device: ad4103fa-...     Loading Linux core repo kernel...     error: file `/boot/vmlinuz-linux` not found     Loading initial ramdisk ...     error: you need to load the kernel first.      Any helps would be great.


How to enlarge the edit-box size of the login screen of fedora?

My macbook with retina display runs fedora-20 KDE spin. The annoying issue is: **On the default login screen, the edit-boxes for username and password look too small to input.** Is there a simple way to customize the size of these edit-boxes?


I think somebody tried to hack me

root@host [/var/log]# tail -f secure     Jan  3 20:16:10 host sshd[22670]: pam_unix(sshd:auth): authentication failure; logname= uid=0 euid=0 tty=ssh ruser= rhost=61.142.131.120  user=root     Jan  3 20:16:12 host sshd[22670]: Failed password for root from 61.142.131.120 port 9303 ssh2     Jan  3 20:16:15 host sshd[22670]: Failed password for root from 61.142.131.120 port 9303 ssh2     Jan  3 20:16:18 host sshd[22670]: Failed password for root from 61.142.131.120 port 9303 ssh2     Jan  3 20:16:18 host sshd[22684]: Disconnecting: Too many authentication failures for root     Jan  3 20:16:18 host sshd[22670]: PAM 2 more authentication failures; logname= uid=0 euid=0 tty=ssh ruser= rhost=61.142.131.120  user=root     Jan  3 20:16:26 host sshd[23127]: pam_unix(sshd:auth): authentication failure; logname= uid=0 euid=0 tty=ssh ruser= rhost=61.142.131.120  user=root     Jan  3 20:16:28 host sshd[23127]: Failed password for root from 61.142.131.120 port 33913 ssh2     Jan  3 20:16:29 host sshd[23127]: Failed password for root from 61.142.131.120 port 33913 ssh2     Jan  3 20:16:30 host sshd[23154]: Connection closed by 61.142.131.120      61.142.131.120 is NOT my IP. So I do not know who that guy is. Moreover I can't login as root. I was lucky that I managed to logged in once. Now, even after I passwd to change password I still can't login to either whm or root. Notice report of failed password in secure keeps coming even though I simply do not try to login anymore. Finally things work again but with strange log               Jan  3 20:21:51 host sshd[1252]: reverse mapping checking getaddrinfo for fm-dyn-139-193-157-62.fast.net.id [139.193.157.62] failed - POSSIBLE BREAK-IN ATTEMPT!     Jan  3 20:21:55 host sshd[1252]: Accepted password for root from 139.193.157.62 port 29144 ssh2     Jan  3 20:21:55 host sshd[1252]: pam_unix(sshd:session): session opened for user root by (uid=0)      What does it mean by getaddrinfo doesn't work?


/bin/ and /usr/bin Command Tutorials

Let me first start off by mentioning that I am not a Linux newbie. I have personally been using the GNU\Linux for nearly 5 years now. However, often times I run across the commands under `/bin/` and `/usr/bin` and wonder how many of those commands I have never used, let alone the number of commands I've never heard of. Is there a book or perhaps an online tutorial that will walk me through those commands? I do realize that the `man` pages are always there to help with whatever tool I am using, but `man` pages are pretty dry and can be very boring to read, especially when you're not trying to find a solution to a specific problem. My question may be strange considering it is coming from an experienced GNU\Linux user, but I have figured it won't hurt to learn more about one's favorite OSs.


What does the expression ${MYVAR:+-x} mean in bash?

In a bash script I cannot post here I see the following expression:               ${MYVAR:+-x}      I understand the meaning of expressions like `${MYVAR:+OTHERVAR}` and `${MYVAR:-OTHERVAR}`, but an expression with both a plus-sign and a minus- sign. What does it mean, if anything?


Critical messages from gsm and gtk

After upgrading to Fedora 18, I am seeing the following critical messages on `/var/log/messages` whenever I log on to the computer:               CRITICAL: gsm_manager_set_phase: assertion \`GSM_IS_MANAGER<br>     Gtk-CRITICAL: gtk_main_quit: assertion `main_loops != NULL' failed      Based on my limited knowledge, critical messages and above can affect the usage of my computer if I don't deal with these urgently. Not that they are affecting the current usage of my computer, but I would like to find out more about them (seems to deal with mobile technology and GIMP toolkit?) and how to turn them off if I do not need these services.


Install Gnome on Linux Server and Access it via Remote

I have a remote linux server. I want to access it remote desktop style from windows. I found this tutorial http://wiki.centos.org/HowTos/VNC-Server And a bunch of others All are so complicated. Are there easier tutorial? Something that can explain what is Gnome, what is VNC, what is tiger-vnc, etc?


I am the owner of a file and I have write access: why can't I save?

I am on OSX 10.9.2 I am locked out of postgres and trying to modify pg_hba.conf to get back in. http://stackoverflow.com/questions/11919275/can-not-enter-and-change- postgresql-pg-hba-conf-file I run these commands:               $sudo ls -l /Library/PostgreSQL/9.3/data/pg_hba.conf     -rwx--x--x  1 abramhandler  daemon  4222 Oct  9 20:42 /Library/PostgreSQL/9.3/data/pg_hba.conf     $ whoami     abramhandler     $ sudo subl /Library/PostgreSQL/9.3/data/pg_hba.conf      I make changes and click save and get an error from sublime text 2: Unable to save ~/data/pg_hba.conf The ls -l command shows that I own the file and have write access. Why can't I save? Note: I think I am saving to /Library/PostgreSQL/9.3/data/pg_hba.conf even if I get that error message. Data has a little red circle on it -- which probably indicates a problem. ![enter image description here](http://i.stack.imgur.com/E30Qh.png)


Replace missing fonts in OpenOffice

I have a Word document that uses fonts not available on my system. How can I globally replace these fonts? I've tried both Find/Replace (with formatting) and Tools / Options / OpenOffice / Fonts, but both of these only seem to support replacing one installed font with another -- typing the name of the missing font in manually doesn't work.


What is the equivalent to yum-versionlock for ubuntu?

I need to install `r-base` 3.0.2 because a needed library isn't compatible with 3.0.3 yet (the latest). I can install the older version of R like so:               sudo apt-get install r-base=3.0.2-1precise0      However all the dependencies of r-base try and install with 3.0.3               root@foo:~# apt-get install r-base=3.0.2-1precise0     Reading package lists... Done     Building dependency tree     Reading state information... Done     Some packages could not be installed. This may mean that you have     requested an impossible situation or if you are using the unstable     distribution that some required packages have not yet been created     or been moved out of Incoming.     The following information may help to resolve the situation:          The following packages have unmet dependencies:      r-base : Depends: r-recommended (= 3.0.2-1precise0) but 3.0.3-1precise0 is to be installed     E: Unable to correct problems, you have held broken packages.      I guess I could install every dependency first, however there are a lot of them.                 r-cran-boot r-cran-class r-cran-cluster r-cran-codetools r-cran-foreign r-cran-kernsmooth r-cran-lattice       r-cran-mass r-cran-matrix r-cran-mgcv r-cran-nlme r-cran-nnet r-cran-rpart r-cran-spatial r-cran-survival       r-recommended      I'm mostly familiar with Centos and Yum. Is there a way to 'version lock' r and all it's dependencies to 3.0.2 instead of 3.0.3 ?               root@foo:~# apt-cache policy r-base     r-base:       Installed: (none)       Candidate: 3.0.3-1precise0       Version table:          3.0.3-1precise0 0             500 http://cran.cnr.berkeley.edu/bin/linux/ubuntu/ precise/ Packages          3.0.2-1precise0 0             500 http://cran.cnr.berkeley.edu/bin/linux/ubuntu/ precise/ Packages          3.0.1-6precise0 0             500 http://cran.cnr.berkeley.edu/bin/linux/ubuntu/ precise/ Packages          3.0.1-5precise0 0             500 http://cran.cnr.berkeley.edu/bin/linux/ubuntu/ precise/ Packages          3.0.1-3precise 0             500 http://cran.cnr.berkeley.edu/bin/linux/ubuntu/ precise/ Packages


Mapping Super Keys to Control without Xmodmap

I've been attempting to switch my super and control keys in X on a macbook and have been half successful. I'd like to avoid creating a custom .Xmodmap if possible, as there is a temporary 100% cpu bug that pops up every time the custom map is loaded (not to mention various warnings against using xmodmap generally which I've come across). After some diging, I ended up putting Option "XkbOptions" "altwin:ctrl_win" in my 01-keyboard-layout.conf file which has gotten me halfway there: for eg, left command now maps to 133 Control_L. However, the control keys remain the same. Left control, for eg still maps to 37 Control_L. Looking through evdev.lst (and a bunch of googling) turned up no relevant XkbOption for turning control keys into supers, and now i'm pretty stuck. I'm now looking through the insanity that is Doug Palmer's An Unreliable Guide to XKB Configuration but it is, as he describes, a descent into hell. anyone who's attempted this switchover before and knows the exact rules/symbols/keymaps to get it done, your assistance would be great. Thanks!


Screen command keypress Ctrl+r?

This is example of the command:                screen -S dua -X stuff $'commandhere'      I've searched lots of resources but still not found the command for keypress `Ctrl`+`R`.


Root password keep changing

This is frustrating. I am often able to login with a root password. Then I cannot login again. However, I am still logged in. Hence my password must be correct. I changed the root password with `passwd`. It works again. Then sometimes latter this happens again. It's as if the root password changes all the time automatically. Did someone hack my server?


newsyslog.conf logrotate when file is older than 6 month

I would like to delete following files with newsyslog.conf when the files are older than 6 month:               # logfile    [owner:group]    mode    count    size    when    flags    [/pid_file]     /mnt/usb/access_*.log      Which other options do I have to set?


Data loss prevention ( or recovery) in a MySql db in embedded systems

I have a little ( big ) problem with a MySql application that write on a SD card or a Compact Flash. After a data loss ( a power failure , for example) , if I try to retrieve the data of my db , it fails and the error code is : incorrect format table. If i try to see the files of my DB in filesystem mounted, I obtain: can't stat file or directory (I/O error). Someone have suggestion to overcome this? to prevent or recovery the contents of my db? the scenario is                 a) a filesystem with ext2 filesystem ( to prevent SD card multiple writings)       b) SD cards or DOM or Compact Flash as physical support       c) the OS ( TinyCore Linux Embedded ) it's loaded in RAM       d) the is MySql MyIsam db


Put text in the bash command line buffer

I would like to programmatically put a certain piece of text in the command line buffer of bash, read to be edited and used as a command. What I am looking forward to is something similar to `read -i` but for commands. > `-i text` If readline is being used to read the line, text is placed into > the editing buffer before editing begins. **Edit** : With _programmatically_ I mean that want to **write this in a script** , launch the script and have the command buffer prepared or the command history modified (as some questions have suggested).


Tmux ranger integration: opening text files in new panes

Here we have some amazing tools: tmux, ranger, vim... Would be amazing to configure ranger to open the files (when text editable) in a tmux newpane? Is that easy and how it is done?


How to check umask for all users under Linux?

Under AIX I can check the `umask` for all users with:               cut -d : -f 1 /etc/passwd | while read ONELINE; do lsuser -a umask "$ONELINE"; done      But how can I check the `umask` setting for all users under Linux? (`su` to every user and then `umask` command? Are there any better ways for it?) **UPDATE1:** It's not the best to `su` to all users, because on some RHEL servers the default shell for a few user is halt/shutdown..:               shutdown:x:6:0:shutdown;asdf;asdf;F:/sbin:/sbin/shutdown      so if I `su` to the user... then the server shuts down? **UPDATE2:** I created a bounty for a non-su based answer.


Speed optimize hostapd / wireless backports

I have an ARM9 CPU at 300MHz board with embedded Linux 2.6.32 running hostapd with dnsmasq. For wifi I use the linux-backports with an ath9k_htc usb wifi- dongle. I have tested the wifi-speed from between my embedded system and a client using iperf. My problem is that the speed is maximum 17mbps, and I don't know if this is what to expect. I have tried to set the CPU speed to maximum 434MHz (45% increase), which gave wifi-speed of 24.5mbps (45% increase). So it seems to be CPU dependent. I have tried to set optimization O3, with no luck. Is there any way to get more speed? Or at least analyze where the bottleneck is?


forwarding not working in iptables from 8006 to 443

My dedicated server was bridged to vmbr0 and it has 2 Ethernet cards eth0 and eth1 its bridged. I have enabled forwarding with `net.ipv4.ip_forward=1`. I want to redirect the Port 8006 to 443. Now I'm accessing one of the web applications on port 8006, it want to redirect towards 443 using `iptables`. Currently I'm using this rule to forward and its not working:               iptables -t nat -I PREROUTING -d 192.168.1.100 -p tcp --dport 443 -j DNAT --to-destination 192.168.1.100:8006      If I apply these `iptables` rules, the page cannot be accessed on 192.168.1.100:8006:               # Default filter          iptables -P INPUT DROP     iptables -P OUTPUT ACCEPT     iptables -P FORWARD DROP          # Loopback allows all.          iptables -I INPUT -i lo -j ACCEPT     iptables -I FORWARD -i lo -j ACCEPT          # Null packets are, simply said, recon packets. see how we configured the VPS and find out weaknesses.          iptables -A INPUT -p tcp --tcp-flags ALL NONE -j DROP          # Reject is a syn-flood attack          iptables -A INPUT -p tcp ! --syn -m state --state NEW -j DROP          # XMAS packets, also a recon packet          iptables -A INPUT -p tcp --tcp-flags ALL ALL -j DROP          # Allow all Outgoing connection          iptables -A OUTPUT -j ACCEPT     # Ethernet allows established/related Except invalid.          iptables -A INPUT -i vmbr0 -m state --state ESTABLISHE,RELATED -j ACCEPT     iptables -A INPUT -i vmbr0 -m state --state INVALID -j DROP          # Allow TCP on Port 22 SSH with rate limiting          iptables -A INPUT -i vmbr0 -p tcp --dport 22 -m state --state NEW,ESTABLISHED -j ACCEPT     iptables -I INPUT -i vmbr0 -p tcp -m state --state NEW -m tcp --dport 22 -m recent --set     iptables -I INPUT -i vmbr0 -p tcp -m state --state NEW -m tcp --dport 22 -m recent --update --seconds 10 --hitcount 5 -j DROP          # Allow Ping ICMP echo With Limiting          iptables -A INPUT -i vmbr0 -p icmp -m state --state NEW -m icmp --icmp-type echo-request -j ACCEPT     iptables -I INPUT -i vmbr0 -p icmp -m icmp --icmp-type echo-request -m recent --set     iptables -I INPUT -i vmbr0 -p icmp -m icmp --icmp-type echo-request -m recent --update --seconds 10 --hitcount 10 -j DROP          # Allow HTTP Requests for NON-secured 80          iptables -A INPUT -i vmbr0 -p tcp --dport 80 -m state --state NEW -m tcp -j ACCEPT     iptables -I INPUT -i vmbr0 -p tcp --dport 80 -m state --state NEW -m recent --set     iptables -I INPUT -i vmbr0 -p tcp --dport 80 -m state --state NEW -m recent --update --seconds 5 --hitcount 20 -j DROP          # Allow HTTP Requests for SLL 443          iptables -A INPUT -i vmbr0 -p tcp --dport 443 -m state --state NEW -m tcp -j ACCEPT     iptables -I INPUT -i vmbr0 -p tcp --dport 443 -m state --state NEW -m recent --set     iptables -I INPUT -i vmbr0 -p tcp --dport 443 -m state --state NEW -m recent --update --seconds 5 --hitcount 20 -j DROP          # Enabling Logging          iptables -N LOGGING     iptables -A INPUT -j LOGGING     iptables -A OUTPUT -j LOGGING     iptables -A LOGGING -m limit --limit 10/min -j LOG --log-prefix "IPTables-log:" --log-level 4     iptables -A LOGGING -j DROP          # DROP ALL Except Above Rules          iptables -A INPUT -j DROP


ZSH: Globbing the first N files under a path in lexicographic order

I was wondering if there is a way to specify the first N files under a given a directory in zsh. I am interested in solutions for recursive enumeration (i.e. any file recursively below a path is considered for the enumeration) and non-recursive (only those files strictly under a given folder are considered). Thanks!


Getting PHP fatal errors in vTiger while logging from a normal users

I am getting the error below and notices in Apache logs when I am trying to login with any normal user on vTiger although admin user is working fine and able to see everything as expected. Below are the errors:               [Mon Aug 29 13:49:54 2011] [error] [client 52.165.191.160] PHP Notice:  Undefined index:  search in /var/www/html/crm/include/utils/utils.php on line 996, referer: website://crm.abc.com/crm/index.php?module=Settings&action;=OrgSharingDetailView&parenttab;=Settings     [Mon Aug 29 13:49:54 2011] [error] [client 52.165.191.160] PHP Notice:  Undefined index:  file in /var/www/html/crm/include/utils/utils.php on line 1000, referer: website://crm.abc.com/crm/index.php?module=Settings&action;=OrgSharingDetailView&parenttab;=Settings     [Mon Aug 29 13:49:54 2011] [error] [client 52.165.191.160] PHP Notice:  Undefined index:  search in /var/www/html/crm/include/utils/utils.php on line 996, referer: website://crm.abc.com/crm/index.php?module=Settings&action;=OrgSharingDetailView&parenttab;=Settings     [Mon Aug 29 13:49:54 2011] [error] [client 52.165.191.160] PHP Notice:  Undefined index:  file in /var/www/html/crm/include/utils/utils.php on line 1000, referer: website://crm.abc.com/crm/index.php?module=Settings&action;=OrgSharingDetailView&parenttab;=Settings     [Mon Aug 29 13:49:54 2011] [error] [client 52.165.191.160] PHP Warning:  require(user_privileges/user_privileges_81.php) [function.require]: failed to open stream: No such file or directory in /var/www/html/crm/modules/Users/CreateUserPrivilegeFile.php on line 114, referer: website://crm.abc.com/crm/index.php?module=Settings&action;=OrgSharingDetailView&parenttab;=Settings     [Mon Aug 29 13:49:54 2011] [error] [client 52.165.191.160] PHP Fatal error:  require() [function.require]: Failed opening required 'user_privileges/user_privileges_81.php' (include_path='/var/www/html/crm/include/htmlpurifier/library:.:/usr/share/pear:/usr/share/php') in /var/www/html/crm/modules/Users/CreateUserPrivilegeFile.php on line 114, referer: website://crm.abc.com/crm/index.php?module=Settings&action;=OrgSharingDetailView&parenttab;=Settings     [Mon Aug 29 13:49:54 2011] [error] [client 52.165.191.160] File does not exist: /var/www/html/favicon.ico


Safest HardDrive Format for Archiving/Media Storage Data?

What is the safest hard drive format (NTFS, HFS+, XFS, ZFS, ...) for archiving or/and storing media (data)? I'd prefer to have the data not corrupt and be relatively safe (From corruption, ...) and would like to have the format to be accessible by Windows (Vista) as well. Thanks in advance.


Install over / preserving /home

I currently have Ubuntu 13.04 installed on my Desktop PC. It is 32-bit. I have 3 partitions: one for /, one for /home and another one for swap. Say I want to install another operating system (another distro) over / but **not formatting my /home partition**. Will it be compatible? More specifically: if I install a non Ubuntu-based distro over /, like Arch or Fedora or openSUSE, will my system break or my programs stop working after the installation?


How to make an infinitely executing command kill itself when certain conditions are met?

I'm running a command on command line which infinitely generates a certain data and I'm looking for a particular bit of data, so I used `grep` to find it. As soon as I get the data, I want the command to kill itself. How do I achieve this? **NOTE1:** AND'ing `kill $$` with `grep` is not terminating the command. **NOTE2:** I saw this question, which does not seem to work in my case.


How should I install Fedora or any other Linux in USB hard disk and configure booting?

I want to install Fedora or any other Linux in USB hard disk. I have Windows XP installed in internal HDD. > When USB HDD is attached to my PC, it should ask me to boot from Win XP or > Linux. In any case of boot, I should be able to use both HDDs. > If USB HDD is not attached to my PC, it should boot from Win XP.


Tmux is not able to distinguish between insert and shift-insert

`Insert` when in xterm, gives `^[[2~` and, `Shift`+`Insert` gives `^[[2;1~` All this is good until I start tmux. Note that the `$TERM` variable remains the same, so this issue should not be related to terminfo. Tmux when in xterm is not able to distinguish between `Insert` and `Shift`+`Insert` and both are read as `^[[2~`. Not only xterm, but tmux when started in a virtual console, exhibits the same behaviour. I tried with and without `set -g xterm-keys on` in the tmux conf file, but to no avail. FWIW I am running tmux 1.8 on XTerm(296) and these are the overrides in my `.Xresources`               XTerm*VT100.Translations: #override \     Shift<Key>Insert: string("\033[2;1~") \n\     <Key>Insert: string("\033[2~")      This is really a pain because I want to map `Shift`+`Insert` in vim but can't do it in tmux. Interestingly, when I run GNU screen in the same xterm, it easily distinguishes between `Insert` and `Shift`+`Insert`. I'm starting to believe it's some wickedness in tmux and not my setup. Does anyone know how to make tmux get the keys transparently just like how xterm gets it without mangling it up in the middle or is there something I am doing wrong?


tmux.conf file will not use backslash comma in lines \;

Using tmux both 1.7 and 1.8. I see `\;` in tmux.conf files everywhere, but it fails with an error when I add it to mine. Here is an example:               bind -t vi-copy 'y' copy-selection \; run-shell "tmux save-buffer - | curl -d @- localhost:5482" I get this error: > /Users/user/.tmux.conf:30: usage: bind-key [-cnr] [-t key-table] key command > [arguments] Examples here:   1. How can I bind multiple tmux commands to one keystroke?   2. http://superuser.com/questions/562567/tmux-bind-key-and-running-shell-isnt-working Seems to only happen when using the bind -t option.


Migrating from hardware to software RAID

I have an old PCI-X controller running 8 drives in RAID 5. I'd like to dump the controller and go to software RAID under Ubuntu. Is there a way to do this and retain the data from current array? **EDIT:** (and a slight tangent) The answers below are certainly fine, but here's a bit of added detail in my specific situation. The hardware raid was being done by an old Promise raid card (don't remember the model number). My whole system went down (dead mobo, most likely) and the old controller was a PCI-X card (not to be confused with PCI-e). I asked the question hoping to salvage my data. What I did was buy another Promise (HighPoint) card, and plug all the drives in and install Ubuntu. I was expecting to have to rebuild the array, but surprisingly enough, the HighPoint card saw the old array and brought it up clean. Moral of the story - it looks like at least Promise controllers store their metadata on the arrays themselves, and appear to have some amount of forward compatibility.


Can't mount EXT4 hard drive after mounting it in windows

I have a 2TB Western external HDD.   Its original filesystem was NTFS but I formatted it to EXT4.   I had no problem in Linux; But today after I mounted it using `ext2fsd` in a windows box, I cant mount it in linux anymore!   The drive had no partition but after that windows mount `Disk Utility` Shows it has a 1KB partition and 2TB unallocated space!!!   My Data are not corrupted (I still can view my files using `ext2fsd` in Windows!)   Trying to mount using `mount -t ext4` fails and dmesg says:               EXT4-fs (sdb): VFS: Can't find ext4 filesystem        also `fsck` gives:               e2fsck 1.41.11 (14-Mar-2010)     e2fsck: Bad magic number in super-block while trying to open /dev/sdb          The superblock could not be read or does not describe a correct ext2     filesystem.  If the device is valid and it really contains an ext2     filesystem (and not swap or ufs or something else), then the superblock     is corrupt, and you might try running e2fsck with an alternate superblock:         e2fsck -b 8193 <device>      I think that Western's internal application is started in Windows and corrupted FS by creating a partition for itself. How can I Fix it?   Thanks * * * **Edit:**   I also tried `e2fsck -b 8193 /dev/sdb` and got same result:               e2fsck 1.41.11 (14-Mar-2010)     e2fsck: Bad magic number in super-block while trying to open /dev/sdb          The superblock could not be read or does not describe a correct ext2     filesystem.  If the device is valid and it really contains an ext2     filesystem (and not swap or ufs or something else), then the superblock     is corrupt, and you might try running e2fsck with an alternate superblock:         e2fsck -b 8193 <device>      So I tried to find super backup superblocks using `testdisk`, it gave:               superblock 0, blocksize=4096 [Ariyan2T]     superblock 32768, blocksize=4096 [Ariyan2T]     superblock 98304, blocksize=4096 [Ariyan2T]     superblock 163840, blocksize=4096 [Ariyan2T]     superblock 229376, blocksize=4096 [Ariyan2T]     superblock 294912, blocksize=4096 [Ariyan2T]     superblock 819200, blocksize=4096 [Ariyan2T]     superblock 884736, blocksize=4096 [Ariyan2T]     superblock 1605632, blocksize=4096 [Ariyan2T]     superblock 2654208, blocksize=4096 [Ariyan2T]      I tried to repair it using `fsck.ext4 -b 32768 -B 4096 /dev/sdb` and the result was:               e2fsck 1.41.11 (14-Mar-2010)     fsck.ext4: Bad magic number in super-block while trying to open /dev/sdb          The superblock could not be read or does not describe a correct ext2     filesystem.  If the device is valid and it really contains an ext2     filesystem (and not swap or ufs or something else), then the superblock     is corrupt, and you might try running e2fsck with an alternate superblock:         e2fsck -b 8193 <device>      * * * **EDIT2:** `fdisk -l /dev/sdb` returns:               Warning: invalid flag 0x0000 of partition table 5 will be corrected by w(rite)          Disk /dev/sdb: 2000.4 GB, 2000365289472 bytes     255 heads, 63 sectors/track, 243197 cylinders     Units = cylinders of 16065 * 512 = 8225280 bytes     Sector size (logical/physical): 512 bytes / 512 bytes     I/O size (minimum/optimal): 512 bytes / 512 bytes     Disk identifier: 0x00021365             Device Boot      Start         End      Blocks   Id  System     /dev/sdb1               1      243198  1953480704   85  Linux extended      * * * **Edit3 (as psusi's comment):** `sudo dd if=/dev/sdb bs=512 count=1 skip=262144 | xxd -a`:               1+0 records in     1+0 records out     512 bytes (512 B) copied, 0.42691 s, 1.2 kB/s     0000000: ae61 5cc1 3be6 6d8d ceed 0cc8 293b fa1b  .a\.;.m.....);..     0000010: 5931 fa58 7420 550a b40e 7b1c b0a6 ad60  Y1.Xt U...{....`     0000020: 1f29 dcae af2a a935 7185 f1d9 6b64 7f29  .)...*.5q...kd.)     0000030: fed0 4c79 fc3b 1544 becd bda0 e7a4 836b  ..Ly.;.D.......k     0000040: ea50 1800 0868 89ac 592d 63a2 05e5 116d  .P...h..Y-c....m     0000050: 4654 9870 671a e11d 7ae0 6bdd dd23 bf5a  FT.pg...z.k..#.Z     0000060: 94ac a20d 695b d010 d8f2 4620 5930 561b  ....i[....F Y0V.     0000070: af93 7d8c 06c3 72c7 3757 7815 e955 3278  ..}...r.7Wx..U2x     0000080: 5773 22b3 2908 52b5 f7e9 59ea b618 5830  Ws".).R...Y...X0     0000090: b29f d244 9a72 ead9 5a77 d3ce e83a 8c44  ...D.r..Zw...:.D     00000a0: 96d9 a89f dd82 b72a f624 10a8 0f44 31a5  .......*.$...D1.     00000b0: 29b6 811a f9cd 175a c00b 670a 5051 ce87  )......Z..g.PQ..     00000c0: 5b00 bd80 20d5 c6e5 f0d0 593e f923 005d  [... .....Y>.#.]     00000d0: 1a6f 83ea 7f28 3305 dc72 7d92 4258 cb4e  .o...(3..r}.BX.N     00000e0: 00de 6a6c 4575 d355 3682 28dd f765 e099  ..jlEu.U6.(..e..     00000f0: 1193 d0cc 64ad a841 ecd7 2c24 08e2 96f5  ....d..A..,$....     0000100: 0fb2 e4fd ef04 1914 f63c 30ce 0df9 3470  .........<0...4p     0000110: 166f 080d 7872 dfce a854 ef20 a237 447a  .o..xr...T. .7Dz     0000120: 05b1 653f 109b 52c3 553b 966c 9733 838e  ..e?..R.U;.l.3..     0000130: c2c9 52cd 4b8f 1e85 cd70 abf4 f9b6 c0c5  ..R.K....p......     0000140: 1412 0f2f 8389 9f4b 94af a523 c6c5 6e04  .../...K...#..n.     0000150: 25d4 d049 fde8 cd9d 94bd 608e e08a f6c6  %..I......`.....     0000160: 389a 5571 9182 d642 7680 f905 9fb6 179a  8.Uq...Bv.......     0000170: 9c6c 5290 ec62 a44f 3f05 fa39 f2a1 18c7  .lR..b.O?..9....     0000180: ba96 297f 2d04 a646 8cc8 e50c ee90 76c0  ..).-..F......v.     0000190: f9ae e586 0f89 6227 35bb b390 9477 8720  ......b'5....w.      00001a0: 2a6c c2b1 9f15 ecdd 8216 523c 2b61 731e  *l........R<+as.     00001b0: 1b1f 0d24 5914 7e8a 7c32 957b 4f24 a464  ...$Y.~.|2.{O$.d     00001c0: ccb4 ecd9 7d1e 967d 9d6b ee20 fa02 9e65  ....}..}.k. ...e     00001d0: 593c 640e fbd2 4f6e e0f8 53b8 4b4a b3fa  Y<d...On..S.KJ..     00001e0: a630 30f1 8170 55a4 dd91 805c d522 9412  .00..pU....\."..     00001f0: 7c0f 1afa ff47 ab23 9721 5a3d f87a 181f  |....G.#.!Z=.z..      and `sudo dd if=/dev/sdb bs=512 count=1 skip=2 | xxd -a`:               1+0 records in     1+0 records out     512 bytes (512 B) copied, 0.000880215 s, 582 kB/s     0000000: 0000 0000 0000 0000 0000 0000 0000 0000  ................     *     00001f0: 0000 0000 0000 0000 0000 0000 0000 0000  ................      * * * a question: Can I repair it with `mkfs.ext4 -S /dev/sdb` without loosing data? * * * **EDIT4:** At `skip=2050` there is a `53ef` at position 0x38 (`sudo dd if=/dev/sdb bs=512 count=1 skip=2050 | xxd -a`):               1+0 records in     1+0 records out     512 bytes (512 B) copied, 0.000688801 s, 743 kB/s     0000000: 0000 4707 00f0 1b1d cc98 7401 769e 2a1a  ..G.......t.v.*.     0000010: 9df7 4607 0000 0000 0200 0000 0200 0000  ..F.............     0000020: 0080 0000 0080 0000 0020 0000 ce17 0750  ......... .....P     0000030: ce17 0750 1a00 2600 53ef 0100 0100 0000  ...P..&.S.......     0000040: a26d 9d4f 004e ed00 0000 0000 0100 0000  .m.O.N..........     0000050: 0000 0000 0b00 0000 0001 0000 3c00 0000  ............<...     0000060: 4202 0000 7b00 0000 8160 9a1f f334 4827  B...{....`...4H'     0000070: b6df 00c2 8981 7b36 4172 6979 616e 3254  ......{6Ariyan2T     0000080: 0000 0000 0000 0000 2f6d 6564 6961 2f41  ......../media/A     0000090: 7269 7961 6e32 5400 4bb7 7001 80fd 39e9  riyan2T.K.p...9.     00000a0: 607c e2c0 8098 6ced 94be 7fed 1529 21c0  `|....l......)!.     00000b0: 6026 a0c5 c280 0000 6026 a0c5 2042 b0c5  `&......`&.. B..     00000c0: 0000 0000 2042 b0c5 0000 0000 0000 8b03  .... B..........     00000d0: 0000 0000 0000 0000 0000 0000 0000 0000  ................     00000e0: 0800 0000 0000 0000 0000 0000 b536 a950  .............6.P     00000f0: 02a9 455e 9fa8 b9a3 0f2b 61b1 0101 0000  ..E^.....+a.....     0000100: 0000 0000 0000 0000 a26d 9d4f 0af3 0200  .........m.O....     0000110: 0400 0000 0000 0000 0000 0000 ff7f 0000  ................     0000120: 0080 880e ff7f 0000 0100 0000 ffff 880e  ................     0000130: 0000 0000 0000 0000 0000 0000 0000 0000  ................     0000140: 0000 0000 0000 0000 0000 0000 0000 0008  ................     0000150: 0000 0000 0000 0000 0000 0000 1c00 1c00  ................     0000160: 0100 0000 0000 0000 0000 0000 0000 0000  ................     0000170: 0000 0000 0400 0000 5962 660c 0000 0000  ........Ybf.....     0000180: 0000 0000 0000 0000 0000 0000 0000 0000  ................     *     00001f0: 0000 0000 0000 0000 0000 0000 0000 0000  ................      * * * **EDIT5:**   `mount -t ext4 /dev/sdb1 /media/tmpmp/` returns:               mount: wrong fs type, bad option, bad superblock on /dev/sdb1,            missing codepage or helper program, or other error            In some cases useful info is found in syslog - try            dmesg | tail  or so      `file -s /dev/sdb1` returns:                /dev/sdb1: data


Pipe find into grep -v

I'm trying to find all files that are of a certain type and do not contain a certain string. I am trying to go about it by piping find to grep -v example:               find -type f -name '*.java' | xargs grep -v "something something"      This does not seem to work. It seems to be just returning all the files that the find command found. If it helps, what I am trying to do is basically find all .java files that match a certain filename(e.g. ends with 'Pb' as in SessionPb.java) and that do not have an 'extends SomethingSomething" inside it. My suspicion being a newbie to unix is that I'm doing it wrong. So how should the command look like instead?


Arch Linux: Yaourt/Makepkg Can Not Build Apache

I am using yaourt to automatically compile Apache from source every time there’s an update available from `extra`. I am doing this so that I can have a custom suexec docroot (`/srv/www` rather than the default `/srv/http`). This has worked flawlessly for several updates, until now.               $ yaourt -S apache     ==> Building apache from sources.          ==> Retrieving PKGBUILD and local sources...     receiving file list ... done     ./     PKGBUILD     apache.conf.d     apache.install     apache.tmpfiles.conf     apachectl-confd.patch     arch.layout     httpd     httpd.logrotate     pcre_info.patch          sent 199 bytes  received 10416 bytes  7076.67 bytes/sec     total size is 9809  speedup is 0.92     => removes/replaces '--with-suexec-docroot=\/srv\/http' by '--with-suexec-docroot=\/srv\/www' in global     --- ./PKGBUILD  2012-07-06 00:02:13.000000000 -0400     +++ ./PKGBUILD.custom   2012-07-06 15:49:03.000000000 -0400     @@ -102,7 +102,7 @@                 --enable-so \                 --enable-suexec \                 --with-suexec-caller=http \     -           --with-suexec-docroot=/srv/http \     +           --with-suexec-docroot=/srv/www \                 --with-suexec-logfile=/var/log/httpd/suexec.log \                 --with-suexec-bin=/usr/sbin/suexec \                 --with-suexec-uidmin=99 --with-suexec-gidmin=99 \     ==> Edit PKGBUILD ? [y/N] ("A" to abort)     ==> ------------------------------------     ==> n          ==> apache dependencies:      - openssl (already installed)      - zlib (already installed)      - apr-util (already installed)      - pcre (already installed)               ==> Edit apache.install ? [y/N] ("A" to abort)     ==> ------------------------------------------     ==> n          ==> Continue building apache ? [Y/n]     ==> --------------------------------     ==>      ==> Building and installing package     ==> Making package: apache 2.2.22-4 (Thu Jul  5 14:47:33 EDT 2012)     ==> Checking runtime dependencies...     ==> Checking buildtime dependencies...     ==> Retrieving Sources...       -> Downloading httpd-2.2.22.tar.bz2...       % Total    % Received % Xferd  Average Speed   Time    Time     Time  Current                                      Dload  Upload   Total   Spent    Left  Speed     100 5252k  100 5252k    0     0  93231      0  0:00:57  0:00:57 --:--:-- 93283       -> Downloading httpd-2.2.22.tar.bz2.asc...       % Total    % Received % Xferd  Average Speed   Time    Time     Time  Current                                      Dload  Upload   Total   Spent    Left  Speed     100   835  100   835    0     0   5191      0 --:--:-- --:--:-- --:--:-- 10437       -> Downloading 02-rename-prefork-to-itk.patch...       % Total    % Received % Xferd  Average Speed   Time    Time     Time  Current                                      Dload  Upload   Total   Spent    Left  Speed       0     0    0     0    0     0      0      0 --:--:--  0:01:06 --:--:--     0curl: (7)     couldn't connect to host     ==> ERROR: Failure while downloading 02-rename-prefork-to-itk.patch         Aborting...     ==> ERROR: Makepkg was unable to build apache.     ==> Restart building apache ? [y/N]     ==> -------------------------------     ==>       The problem seems to be that curl can’t find `02-rename-prefork-to-itk.patch`. I don’t know what URL that’s located at, in what file it’s specified, or how I might find an alternate location for it. Any idea what is going on/how to troubleshoot?


How to open the same directory in another panel in Midnight Commander?

In Midnight Commander, how to quickly set the right panel to the same directory as the left panel (and vice versa)?


Change numbers in the Number column to be consecutive from 0 for an mdadm RAID array

I have a RAID 1 array:               # mdadm --detail /dev/md0     /dev/md0:             Version : 1.2       Creation Time : Thu Oct 18 21:52:43 2012          Raid Level : raid1          Array Size : 1048564 (1024.16 MiB 1073.73 MB)       Used Dev Size : 1048564 (1024.16 MiB 1073.73 MB)        Raid Devices : 2       Total Devices : 3         Persistence : Superblock is persistent              Update Time : Fri Oct 19 16:25:32 2012               State : clean      Active Devices : 2     Working Devices : 3      Failed Devices : 0       Spare Devices : 1                     Name : cow:0  (local to host cow)                UUID : 9e691db1:f8fcc7d8:f56d9c11:1c202693              Events : 98              Number   Major   Minor   RaidDevice State            2       8        2        0      active sync   /dev/sda2            3       8       18        1      active sync   /dev/sdb2                 4       8       34        -      spare   /dev/sdc2      Is it possible to change the numbers in the `Number` column to 0, 1, 2 instead of 2, 3, 4? They were 0, 1, 2 until I messed around a bit with the array, removing and adding devices.


Tool to monitor in and out data network traffic w graphs and detailed stats

Is there a tool, that can gather stats on network usage? Requirements:   * Generate HTML (or other format, convertible to HTML)   * Time line graphs for bandwidth usage, also which hosts use the most bandwidth and what port is used by that host.   * Which ports are using most bandwidth  This isn't the full requirements, but things I can think of just now. I am not sure what the name of this kind of tool is called.


When changing distro

I wonder if I have previously installed ubuntu with root, home, and swap partition. And now I want to change distro to arch linux. Is it so that I only need to wipe my root-partition and install arch linux there instead?


Using OGG/Vorbis, is there a way to continue to record to an existing audio file?

I am using Vorbis/ogg to record audio (using arecord and then pipping to oggenc). I have downloaded oggvideotools, which gave me oggCat, which will let me join two previously recorded audio files into one file. But, my problem is this: The device I am working on is known to have the "plug pulled", but it is recording while the power is on (swapping out batteries etc.). Once the device is powered back on, I need to continue to record to the previous file (automated recording). Right now, I can use arecord to record two separate files, and then once the recording is done, I can oggCat the two, but that doesn't get me what I want 100%, I need to be able to continue recording where the first file got cut off. I originally put this on Stackoverflow, trying to solicit a python response, but it was closed by moderators - I hope this is a better place for it. I need python and busybox solutions. Unfortunately, other solutions outside Python and Busybox are not available to me - furthermore, downloading additional packages/programs is also not available, I have oggenc, arecord, and oggvideotools. Any advise on where to look? Can I somehow pipe arecord data from a temp file to oggCat? Like: `oggCat NewFile.ogg File1.ogg (arecord file2.ogg ...)` Where "(arecord file2.ogg ...) is the file currently being recorded and simultaneously being appended to Newfile.ogg? Thanks in advance, (P.S. the audio files will have the exact same parameters - i.e. same channels, rates, etc)


Using UUID's with mdadm

I'm using GPT as my partitioning scheme. I check the UUID's of my partitions:               # ls -l /dev/disk/by-partuuid/     total 0     lrwxrwxrwx 1 root root 10 Oct 18 22:39 0793009a-d460-4f3d-83f6-8103f8ba24e2 -> ../../sdb3     lrwxrwxrwx 1 root root 10 Oct 18 22:39 13f83c47-ad62-4932-8d52-e93626166e7f -> ../../sdc3     lrwxrwxrwx 1 root root 10 Oct 18 22:39 1b247b1f-0b7b-419e-bc3b-0f90cbadb87c -> ../../sdc2     lrwxrwxrwx 1 root root 10 Oct 18 22:39 224d5933-7a23-4833-b785-79a67c9b9306 -> ../../sda1     lrwxrwxrwx 1 root root 10 Oct 18 22:39 2ff625b2-b96b-4ce5-b752-57cdf7092258 -> ../../sda3     lrwxrwxrwx 1 root root 10 Oct 18 22:39 449956f9-7289-49ed-9a37-ed6be9264d1c -> ../../sdb1     lrwxrwxrwx 1 root root 10 Oct 18 22:39 a2a95e45-7e4c-4b20-a2bd-66d96e737590 -> ../../sdb2     lrwxrwxrwx 1 root root 10 Oct 18 22:39 a8c07f74-9d6d-4f45-9453-dd2e6998f100 -> ../../sda2     lrwxrwxrwx 1 root root 10 Oct 18 22:39 c2c9e94c-9c73-4d6e-a4ec-2229f56152e8 -> ../../sdc1      And add `/dev/sdc2` using its UUID:               # mdadm /dev/md0 --add /dev/disk/by-partuuid/1b247b1f-0b7b-419e-bc3b-0f90cbadb87c     mdadm: added /dev/disk/by-partuuid/1b247b1f-0b7b-419e-bc3b-0f90cbadb87c      But when I look at the details of the RAID array it reports `/dev/sdc2` instead of the UUID.               # mdadm --detail /dev/md0     /dev/md0:             Version : 1.2       Creation Time : Thu Oct 18 21:52:43 2012          Raid Level : raid1          Array Size : 1048564 (1024.16 MiB 1073.73 MB)       Used Dev Size : 1048564 (1024.16 MiB 1073.73 MB)        Raid Devices : 2       Total Devices : 2         Persistence : Superblock is persistent              Update Time : Fri Oct 19 15:57:19 2012               State : clean      Active Devices : 2     Working Devices : 2      Failed Devices : 0       Spare Devices : 0                     Name : cow:0  (local to host cow)                UUID : 9e691db1:f8fcc7d8:f56d9c11:1c202693              Events : 47              Number   Major   Minor   RaidDevice State            2       8       34        0      active sync   /dev/sdc2            1       8       18        1      active sync   /dev/sdb2        1. Is it impossible to construct a RAID array using UUID's?   2. Or is it using the UUID but reports the normal name to increase the readability? In that case, how can I tell?   3. I would like to use UUID's so that I may move the disks around freely in the machine without breaking anything. Doesn't that sound like a good idea?


Piping output from a segfaulting program

I have a script that calls a program (specifically, `ttf2afm`, part of tetex 3.0) that sometimes segfaults and sometimes doesn't. The information I need is always printed out _before_ it segfaults, but I'm having a hard time stopping the pipe redirection from failing and not outputting anything to the pipe when the program fails. I've tried redirecting through a FIFO, parenthesizing the process with a `true` at the end, executing from a shell function and encasing in `sh -c`, but the script never seems to let the process output _anything_ , redirected or otherwise-not even to stderr. I know it is capable of output, being that it's perfectly capable of giving it from the command-line, but not from a script for some reason. My question is, is there any way for the script to ignore the fact that the program segfaults and give me the output anyway? I'm running BASH 4.1.10(2)-release.


Simple Shell Script with Arithmetic issue... ** is giving me trouble

When I run this script I get this error: > ./myscript.sh: 16: arithmetic expression: expecting primary: "1 ** 1" When I run this shell script with bash, as in `#! /bin/bash` on the first line, the math works properly; unfortunately I need to use `/bin/sh`. What am I doing wrong? I'm on Linux Mint if that matters.               #! /bin/sh          x=1     while [ $x -le 10 ]     do         y=1         while [ $y -le 10 ]         do             echo $(($y ** $x))"   \c"             y=`expr $y \+ 1`         done         echo         x=`expr $x \+ 1`     done


start-stop-daemon returning always 0 (success)

I have set up `start-stop-daemon` to start my script automatically               case "$1" in        start)           log_begin_msg "starting foo"           start-stop-daemon --start --chuid nobody --user nobody --pidfile \           /tmp/foo.pid --startas /usr/local/bin/foo.sh &           log_end_msg $?      the problem is, it always returns 0 (success),even if the process was not started. How can I capture the return code of `start-stop-daemon` properly ?


Zero-fill numbers to 2 digits with sed

Input:               201103 1 /mnt/hdd/PUB/SOMETHING     201102 7 /mnt/hdd/PUB/SOMETH ING     201103 11 /mnt/hdd/PUB/SO METHING     201104 3 /mnt/hdd/PUB/SOMET HING     201106 1 /mnt/hdd/PUB/SOMETHI NG      Desired output:               201103 01 /mnt/hdd/PUB/SOMETHING     201102 07 /mnt/hdd/PUB/SOMETH ING     201103 11 /mnt/hdd/PUB/SO METHING     201104 03 /mnt/hdd/PUB/SOMET HING     201106 01 /mnt/hdd/PUB/SOMETHI NG      How can I add a `0` if there is only a single digit, e.g. `1` in the "day" part? I need this date format: YYYYMM DD.


How to execute same command "X" multiple times with a time delay of some number of seconds?

I know how to execute multiple commands at same time but now what I need is to run the same command multiple times with some time delay between the command execution. ### Requirements   * I don't want to use a script for this   * A single one line command to accomplish this   * Needs to run on Linux   * Need to control the number of times the command will run


find with user variables

I am trying to call find with a few variables. So far I had this:               DIRECTORY="./ "     FILENAME=-regex" .*test.*"     find $DIRECTORY $FILENAME      Which works fine. If I change the filename to :               FILENAME=-regex" .*"      to list all the files in the directory, I get an error:               find: paths must precede expression: ..      What am I doing wrong?


Difference between /usr/include/sys and /usr/include/linux?

Well, obviously there is a difference, but I'm curious about the rational behind why some things go under /usr/include/sys and others go under /usr/include/linux, and have the same header file name? Does this have something to do with POSIX vx non-POSIX? Also, I've managed to populate /usr/include/linux with headers on my Fedora system by grabbing a the kernel-headers package, is there a standard package name for me to get header files that go under /usr/include/sys? I haven't been able to find it.


How does one find and replace text in all open files with geany?

How does one find and replace text in **all open files** with geany?


Fast tool to generate thumbnail video galleries for command line

I use gframecatcher to generate thumbnail video galleries, i.e. something like this: ![enter image description here](http://i.stack.imgur.com/wPlfF.jpg) However this is a GUI tool and I want to create recursively a gallery for every video in a directory structure, so I am looking for a fast command line tool to do this.


How to setup an audio/sound output monitor/listener?

I am working with an Arduino and am trying to get it to respond to sound when it is played on my computer. I'm communicating with it over a serial port. I need to know if there are any audio/sound monitoring tools that will work from the command line so I could write a shell script to do everything. Something similar to `airmon-ng` for wireless (Although not exactly like this as this monitors external stats. I'm looking for something that can do this internally). I'm not sure if such a tool exists because I couldn't seem to find the right combination of keywords to find it on google. This is for an audio-out listener. I think similar tools exist for line-in.


what does the following command do?

what does the following command do? I have tried to study the linux command but I could not find out what this command does. here is the command:               touch finger ; finger touch


How to cp or rm files based on ownership / permission

After a problem with spam, I stopped `postfix`               postfix stop      and checked through the `mailq` manually to find hundreds of thousands of unsent spam. The spam was sent from one of the sites hosted locally, and I know that user has not tried to send any emails since I stopped outgoing mail. Therefore all the messages in `/var/spool/postfix/maildrop` that originate from that user on my machine are known to be spam, and I'd like to delete or move them to another dir for later investigation. I would like to **move all the files with a given owner** (in this case the user 'web2') **from**               /var/spool/postfix/maildrop      **to**               /var/spool/postfix/temp-spam      How can I do this?


Panasonic printer refuses to print

_I recently switched from Ubuntu to Opensuse because of bloatware (including Unity)._ However, I'm not able to make my LAN printer `Panasonic KX-MB 2010` work. In Ubuntu I set the printer up using this tutorial, but in Opensuse I end up with this error even though `rastertogdi` binary is copied correctly:               /usr/lib/cups/filter/rastertogdi failed      I also tried the official driver for RedHat, but I end up with one of these errors (randomly):               /usr/lib/cups/filter/gstoraster failed      or               Cannot load libgs or libgs version too old then 8.0      Any help would be appreciated.


How to create a shortcut of some folder on Docky?

I am using docky on ubuntu 14.04.I am able to pin shortcut of applications to it. But how can I make a shortcut of a particular folder to it. Like It has home folder icon in docky ..I want to have folder location directed to that particular one.


What are the advantages of using named pipe over unnamed pipe?

I was reviewing a set of interview questions that are asked from a unix admin; I found a topic called "named pipe". I googled the topic; to some extent I have been able to understand it :- named pipes || FIFO But still I feel that I am lacking the knowledge of when to use this particular type of pipe. Are there any special situations where unnamed pipes would fail to work ?


bash prompt - long command circle back to same line after adding color

Note: I am using Putty and my TERM is set to XTERM. I have added the color to my bash prompt as               PS1="\[\033[0;32m\]\d \t \u\e[1;33m@\H /\W $ \[\033[1;37m\]"      just to simplify PS1 in English -               ${GREEN}\d \t \u{YELLOW}@\H \W $ {reset-color}      Now, whenever my command is long and doesn't fit into the line of screen, it should come over to the next line, but it doesn't and the initial character start getting replaced which each character I type. The whole command is present but is not seen completely. It executes normally, so it's just the display that is getting distorted. The situation worsens when I go back to the first character and try to delete the characters, the whole command line moves up and up erasing the previous data that was on screen. After some trial and error removing some-part I found that addition a `@` leads to the above behavior               \e[1;33m      I really don't remember why I had put this and I am not able to trace this back. Can you help me in resolving this issue? The long commands should get on the next line and not on the same line.


What filesystem offers best protection for securing data against corruption due to power loss?

I am running a small `uClibc` and `busybox` based embedded system on an x86 device. I am using an initramfs but I also mounting a custom `ext3` directory on a compact flash device in IDE mode that I am using to store persistent measurement logging data created by a custom written c++ application. I chose the `ext3` file system as it is recommended for safety against power loss when using CF drives in IDE mode in a couple of books I have read ( _Building Embedded Linux Systems_ by Karim Yaghmour and _Embedded Linux Primer_ by Christopher Hallinan). This is particularly important and the data is critical. However, due to some of the comments in my previous question Confusion with how to restore corrupt ext3 files if power outage occurs during a file write it would appear that in fact this file system does not offer the guarantee of safety against data corruption due to power loss. So I would like to know if   1. Is `ext3` actually the best choice for this setup?   2. Does power loss during a disc write operation only corrupt the portion of data I am appending to the file periodically or can it corrupt the **entire** file?   3. Is data that is **not** being written at the point of power loss completely safe? In particular, is there any risk that my `initramfs.cpio` file can become corrupt also?   4. Is there any method I can use in my application code to protect the data (i.e. creating an extra partition and writing my data to mirror images so that there are always 2 copies) - speed is not a real issue for my application so expensive copying operations are acceptable. I have seen and read the answers to this related question: Do journaling filesystems guarantee against corruption after a power failure?, but it doesn't quite cover some of the things that are confusing me. I realise that I am asking a lot of questions but it seems that despite reading a lot of material I have had a fundamental failure to understand the risks to my data in the event of power loss.


redirection failing for CGI program

I'm trying to redirect the contents of command output to a file in a CGI program. The issue for me is that the output file is not getting created. The CGI Code snippet is as follows:               #!/bin/bash          echo "Content-type: text/html"     echo ""          echo ""     echo ""          `mysql -u root -predhat -H  -D mysql -e "select host,db from  db;" > output.txt`           echo ""      echo ""       The CGI script is getting called from an HTML program. Also,I can use `INTO OUTFILE` with a `mysql` command, but I want that output redirection should work for any command. Ownerships are as follows:                 #ls -l /var/www/cgi-bin/example.sh       -rwxr-xr-x 1 root root 839 Apr 11 21:34 /var/www/cgi-bin/example.sh      `# ps -ef | grep httpd root 2442 1 0 19:30 ? 00:00:00 /usr/sbin/httpd apache 2464 2442 0 19:30 ? 00:00:00 /usr/sbin/httpd apache 2465 2442 0 19:30 ? 00:00:00 /usr/sbin/httpd apache 2466 2442 0 19:30 ? 00:00:00 /usr/sbin/httpd apache 2467 2442 0 19:30 ? 00:00:00 /usr/sbin/httpd apache 2468 2442 0 19:30 ? 00:00:00 /usr/sbin/httpd` How can I resolve the issue?


No boot menu with Linux Mint and Windows 7

Currently I have Windows 7 installed on my main hard drive (64gb SSD). I recently installed Linux Mint on a secondary hard disk (1TB HDD). My issue is that when I turn the PC on there is no boot menu to allow me to choose which OS I want to boot into. I know this may be because the two operating systems are on different hard disks but is there any way I can have a choice which OS to run without having to change the hard disk drive boot priority in the BIOS?


Replace data at specific positions in txt file using data from another file

I have a text file in the below format:               $data This is the experimental data         good data     This is good file     datafile     1 4324 3673 6.2e+11 7687 67576     2 3565 8768 8760 5780 8778          "This is line '2'"     3 7656 8793 -3e+11 7099 79909     4 8768 8965 8769 9879 0970     5 5878 9879 7.970e-1 9070 0709799     .     .     .     100000 3655 6868 97879 96879 69899     $.endfile      I want to replace the data of the 3rd and 4th column from row '2' to '100000' with the data from two other text files which have one column of 99999 rows each. How can I do this using `awk`, `sed` or any other unix command? Note that the column delimiter is space. The other two text files have 99999 lines each, and they are both in the following format:               12414     12421     36347     3.4e+3     -3.5e22     987983     .     .     .     87698


What special characters does grep parse by default?

> **Possible Duplicate:**   >  In a regular expression, which characters need escaping? I know there is the `-E` flag which treats the "search term" as a regular expression. However, it seems that even without that, `grep` is treating some characters specially. For example, if I run:               grep "$var" *      Then it lists every line of the file (I assume it's using `$` as the end-of- line regex). The period also seems to look for any character under certain circumstances. So what are the special characters I need to be wary of when using `grep`?


Bash script for logging in ftp

I have seen this question: link I have similar, if not the same request. I'd like to create a script that will log me in ftp server. I do not want to automate the whole exchange, I just want to speed up the login. Security is not an issue, it can be most insecure way of doing it, I don't care, I doubt anyone would try to access the server, and even if someone does, I still don't care. =) I have tried this:               #!/bin/bash     ftp -n ftp.domain.com     quote USER user     quote PASS pass      It seems to log me in successfully, but when I try to issue a new command I get:               530 You aren't logged in     ftp: bind: Address already in use


Oracle 11g R2 on Redhat 6

I have a Solaris background, and I am new in RHEL, and I want to install Oracle 11g on it. I downloaded Oracle documentation, that illustrate how to install it for RHEL 6. The following or later version of packages for Oracle Linux 6, and Red Hat Enterprise Linux 6 must be installed:               binutils-2.20.51.0.2-5.11.el6 (x86_64)     compat-libcap1-1.10-1 (x86_64)     compat-libstdc++-33-3.2.3-69.el6 (x86_64)     compat-libstdc++-33-3.2.3-69.el6.i686     gcc-4.4.4-13.el6 (x86_64)     gcc-c++-4.4.4-13.el6 (x86_64)     glibc-2.12-1.7.el6 (i686)     glibc-2.12-1.7.el6 (x86_64)     glibc-devel-2.12-1.7.el6 (x86_64)     glibc-devel-2.12-1.7.el6.i686     ksh     libgcc-4.4.4-13.el6 (i686)     libgcc-4.4.4-13.el6 (x86_64)     libstdc++-4.4.4-13.el6 (x86_64)     libstdc++-4.4.4-13.el6.i686     11     libstdc++-devel-4.4.4-13.el6 (x86_64)     libstdc++-devel-4.4.4-13.el6.i686     libaio-0.3.107-10.el6 (x86_64)     libaio-0.3.107-10.el6.i686     libaio-devel-0.3.107-10.el6 (x86_64)     libaio-devel-0.3.107-10.el6.i686     make-3.81-19.el6     sysstat-9.0.4-11.el6 (x86_64)      I tried to install each package. I download this package: compat- libcap1-1.10-1.src.rpm               rpm -i compat-libcap1-1.10-1.src.rpm      and I got this output:               warning: compat-libcap1-1.10-1.src.rpm: Header V3 RSA/SHA256 Signature, key ID c105b9de: NOKEY     warning: user mockbuild does not exist - using root     warning: group mockbuild does not exist - using root     warning: user mockbuild does not exist - using root     warning: group mockbuild does not exist - using root     warning: user mockbuild does not exist - using root     warning: group mockbuild does not exist - using root     warning: user mockbuild does not exist - using root     warning: group mockbuild does not exist - using root     warning: user mockbuild does not exist - using root     warning: group mockbuild does not exist - using root     warning: user mockbuild does not exist - using root     warning: group mockbuild does not exist - using root     warning: user mockbuild does not exist - using root     warning: group mockbuild does not exist - using root     warning: user mockbuild does not exist - using root     warning: group mockbuild does not exist - using root     warning: user mockbuild does not exist - using root     warning: group mockbuild does not exist - using root      And someone advice me to solve this problem:                   # yum install mock          and create the ‘mockbuild’ user              # useradd -s /sbin/nologin mockbuild      When I tried to use:               yum install mock      I got this output:               Loaded plugins: product-id, refresh-packagekit, security, subscription-manager     Updating certificate-based repositories.     Unable to read consumer identity     Setting up Install Process     No package mock available.     Error: Nothing to do      I can't use any one of these commands `yum` and `rpm`


How can I make a public variable in Linux that all users would see?

I need to have a variable `$FOO` on the system that contains a string all users could use, but I have no idea how to create one. The Upstart job is obviously not a solution as from this thread - Is it possible to export env variable via Upstart? But I have no idea where else I should look, being Windows developer for a very long time.


Bash script is not working

I wanted to create a script that executes the `ls` command with the provided arguments. Why isn't it working? I tried running it with for example `-R`, then it echoes (I echoed the same thing for comparison):                   ls "-R"      but says that it cannot access "-R": no such file or directory. But when I execute `ls "-R"` in the terminal, it works. The script itself:               text='ls'          while [[ $# -gt 0 ]]     do         text+=' "'         text+=$1         text+='"'              shift          done     echo 'ls "-R"'          echo $text     $text


Problem with OpenSSH

I think I got an OpenSSH-problem with my Ubuntu Server 14.04.1. Let me explain my setup: For development, I use Git and Gitolite. I have 3 server:   * server A ( master-server for git-mirroring)   * server B ( slave-server for git-mirroring)   * server C (new slave-server for git-mirroring - in some months it should replace server a) Every server got the public-key from every other server. The .ssh-directory got the permission 0700 and the authorized_keys-file in .ssh/ got 0600. I follow the instruction of http://gitolite.com/gitolite/mirroring.html for setting up a new slave for the mirroring. I try the command "ssh server ... info" on every mashine: server A:               $ ssh server B info     hello server a, this is git@server b running gitolite ...       (this works fine - I didnt setting up these)               $ ssh server c info:     git@server c´s password:      if I enter the correct password for user git from server C, I got a message like this:               /usr/share/info/dir     File: dir,      Node: Top       This is the top of the INFO tree            This (the Directory node) gives a menu of major topics.       Typing "q" exits, "?" lists all Info commands, "d" returns here,       "h" gives a primer for first-timers,       "mEmacs<Return>" visits the Emacs manual, etc.            In Emacs, you can click mouse button 2 on a menu item or cross reference       to select it.          * Menu:          Basics     * Common options: (coreutils)Common options.     * Coreutils: (coreutils).       Core GNU (file, text, shell) utilities.     * Date input formats: (coreutils)Date input formats.     * Ed: (ed).                     The GNU line editor     * File permissions: (coreutils)File permissions.                                     Access modes.     * Finding files: (find).        Operating on files matching certain criteria.      If I try it on server B ssh server C info, the message appears like on server A. I don´t know why it´s not working with server c. If I try on server C ssh server a/b info, it works fine. **Update:** If I use command from server A "ssh server c info" the auth.log from server C shows:               Aug 26 14:15:22 server C sshd[14785]: Accepted password for git from 192.168.1.60 port 51074 ssh2     Aug 26 14:15:22 server C sshd[14785]: pam_unix(sshd:session): session opened for user git by (uid=0)     Aug 26 14:15:22 server C systemd-logind[958]: Removed session 60.     Aug 26 14:15:22 server C systemd-logind[958]: New session 61 of user git.     Aug 26 14:15:22 server C sshd[14833]: Received disconnect from 192.168.1.60: 11: disconnected by user     Aug 26 14:15:22 server C sshd[14785]: pam_unix(sshd:session): session closed for user git


Error 8000: Bad sectors when installing Centos 6.5 Minimum

I downloaded the ISO Centos 6.5 i386 and burned it onto a disk. When I try to install it on my computer, I get the following with               install or upgrade an existing system          .loading vmlinuz..EDD: Error 8000 reading sector 16929     .EDD: Error 8000 reading sector 17176     .EDD: Error 8000 reading sector 17746     .     Loading initrd.img.......................      Then I allowed it to boot from the local drive. The same thing happened again. It doesn;t seem to be getting anywhere.


How to download Debian package's source code?

I want to read source code of some package in Debian, how can i do that?


Adding a route with time-limited validity?

I have read different routing protocols, each one adds routes with limited time validity to routing table. Is there a method in Linux/Ubuntu, without installing any routing daemon, to add a time limited route? If so how? NOTE: I was looking at man pages of `ip route add ...` and **rto_min** looks important for that, but I don't fully understand its function.


Re-access NFS volume from OS X Mavericks client after server reboot?

My home server, running FreeBSD 10-RELEASE p7, exports NFS volumes to my MacBook Pro, running current OS X Mavericks. The MacBook mounts these via automount as `/net/servername/volume` without any config change from my side. This works fine in general. Now, when the server has rebooted, these volumes become inaccessible. When I try to `cd` into a directory of an NFS volume, I get a `No such file or directory`, although the volume isn't even mounted, so the automounter _should_ be able to just mount it. Some accesses also give me a `Device not configured`. With former versions of OS X, a `SIGHUP` to the `automountd` helped to restore access to the NFS volumes. Now, with Mavericks, the `automountd` does not exist any more, and HUPing the `autofsd` does not help, nor does running `automount -c` to clear the cache. What else, short of a reboot, can help?


Postfix favors non virtual to virtual host

I have a linux user thomas and 2 domain names domain1.com and domain2.com. I have followed steps to have two virtual mail boxes `/var/mail/vhosts/domain[12].com/` When I test and send an email to thomas@domain2.com, it lands in `/var/mail/vhosts/domain2.com/thomas/...` When I send it to thomas@domain1.com, it lands in /var/mail/thomas. However, `dovecot` looks into `/var/mail/vhosts/%d/%n`. How can I fix that ?


Difficulty Installing SSH on Oracle RHEL 5.5

I am having difficulty installing SSH on RHEL 5.5 - I have disabled my Firewall and SELinux. I have gone through: Oracle Docs, to see if SSH is enabled, but I got: To check if SSH is enabled:               # /usr/bin/svcadm ssh     -bash: /usr/bin/svcadm: No such file or directory      If SSH is not enabled, then:               # /usr/sbin/svcadm enable ssh     -bash: /usr/sbin/svcadm: No such file or directory      But that did not work either. I have tried installing SSH Server and Client:               # yum -y install openssh-server openssh-clients     Loaded plugins: security     Setting up Install Process     Nothing to do     # yum install openssh-server.x86_64     Loaded plugins: security     Setting up Install Process     Nothing to do      Not sure what is going on here. All I want to do is to run PuTTy and connect remotely to the server. **Update 1:** I have just run:               # /usr/sbin/serviceconf sshd status      And that showed me the Service Configuration screen (on the GUI). I can see that sshd is running:               OpenSSH server daemon     openssh-daemon (pid 2457) is running...      I just restarted it, but still unable to connect using PuTTy. **Update 2:** I have found out how to check to see if the service is running:               # /sbin/service sshd status     openssh-daemon (pid 2516) is running...      I have 2 VM's running the same OS, except the IP addresses are different. VM 1:               eth0      Link encap:Ethernet  HWaddr 08:00:27:5D:FE:C0                 inet addr:10.0.11.28  Bcast:10.255.255.255  Mask:255.0.0.0      VM 2:               eth0      Link encap:Ethernet  HWaddr 08:00:27:5D:FE:C0                 inet addr:10.0.11.27  Bcast:10.255.255.255  Mask:255.0.0.0      I can connect fine with VM 2.


how install freebsd in minimum size?

I want to install a FreeBSD just to use squid cache server on it. i want to know how can i make this installation to its minimum size? i installed the boot-only ISO file on virtual box, but it took around 600 megabytes installed. by the way there is an old machine so i want it work in this minimum size. is there any script to download just needed files? and which file system is best for squid cache holding partition?


Best mechanism for logging in and uploading backup files

I have a server that I want to regularly backup. I create backups with encrypted tar using OpenSSL, and now I want to connect to my home server and upload my backed up files there. I need a mechanism, with which I can connect to my home server, log in, and be able to only upload and read the files there. If my server gets compromised, I don't want the hacker to have access to my home server. So I want the account only to be able to write/read files into **only one** directory, without even being able to peek on the system files in my home folder. What's the best transfer mechanism to do that? SSH or FTPS or something else?


BC—automatic full precision multiplication

High, I need to test my arbitrary precision calculator, and `bc` seems like a nice yardstick to compare to, however, `bc` does truncate the result of each multiplication to what seems to be the maximum scale of the involved operands each. Is there a quick way to turn this off or to automatically set the scale of each multiplication to the sum of scales of the factors so that it doesn't lose any precision? If you have a more elegant solution to this involving something other than `bc`, I would appreciate your sharing it. Example:               $ bc <<< '1.5 * 1.5'     2.2      The real answer is 2.25.


Can't install Linux Mint on Macbook Pro (2008)?

I have a Macbook Pro that I believe is from 2008. It's harddrive is completely wiped and formatted (FAT32 if I remember correctly) with the only exception of a working installation of rEFIt. Not even an OS. I want to install Linux Mint 17 x64 on it. I've burned two DVDs from the ISO and neither are recognized as bootable media (the CD is spit out every time I try to boot from it). I have two different thumb drives I've been alternating between. They're 16GB and 8GB and I haven't noticed any difference between them. They both seem fully functional. I've spent 20+ hours on this over the weekend and here's what I see and what I know so far. I've tried both USB Universal Installer (UUI) and UNetbootin to image the thumb drives. I've given up on UNetbootin after hearing a few negative things, besides, it didn't work for me. When I plug the UUI drive in, rEFIt adds 3 options: boot with /efi/boot/bootx64.efi, boot with /efi/boot/grubx64.efi, or the generically title "Boot Linux from UUI". If I "Boot Linux from UUI" the screen goes black except for the words "Missing Operating System." I've tried reformatting the thumb drive (a full reformat, not a "quick" one) before reimaging but I get the same error anyway. As for the other two options, they both do the same thing. They present with 3 options (in a black and white terminal style UI). I don't remember the wording exactly but it basically boiled down to "Boot Linux Mint", "Boot Linux Mint (Compatibility Mode)", and "Check storage medium integrity". Selecting "Boot Linux Mint" leads to a never ending black screen. No output, no splash, just an "on" black (there's power to the screen, it didn't turn it off). I've let it sit for 5 or 10 mins with no change. Selecting "Boot Linux Mint (Compatibility Mode)" gets me some output. I'm rather new to linux so I don't recognize much of the output. It looks like some of the normal output from a linux boot. If I understand correctly, the number in brackets at the left hand side of each line of the output is uptime in seconds. This output will go for about 6 seconds before stopping (not always at the same line) and seems to freeze. No blinking cursor, no progress. I've also let this sit for 5 or 10 mins and it never moves on. "Check storage medium integrity" sits at a black screen similar to "Boot Linux Mint". I've tried installing x86 instead of x64, I've tried Mate instead of Cinnamon (didn't have much hope for that one, but I'm desperate), I've tried both USB slots in the laptop. I've tried editing the boot statements and did notice that one of the paths started with `/cdrom/...` but changing it to `usb` or `blk3` (I've learned in the EFI shell that the USB could be accessed by `blk3:`) had no visiable change. I haven't tried a different Linux because I'm really pulling for Mint. What experience I have from trying Linux in VMs is mostly Mint. Installing Ubuntu isn't my end game, but if you'd think it'd help, I'm willing to try it. If I did get Ubuntu installed, I wouldn't know what to do next. For me, it simply isn't as easy as this page makes it sound. I'm learning quite a bit though, and honestly part of me loves it. However it's been long enough. I just want the problem solved. What can I do to help make this installation happen?


Compress a folder with tar?

I'm trying to compress a folder (`/var/www/`) to `~/www_backups/$time.tar` where `$time` is the current date. This is what I have:               cd /var/www && sudo tar -czf ~/www_backups $time"      I am completely lost and I've been at this for hours now. Not sure if `-czf` is correct. I simply want to copy all of the content in `/var/www` into a `$time.tar` file, and I want to maintain the file permissions for all of the files. Can anyone help me out?


How can I make beep sound through speakers(spdif)?

I want to `beep` through speakers. I'm using alsa through S/PDIF of ESI Julia. User is in the audio group.               ls /dev/snd     controlC0  midiC0D0  pcmC0D0c  pcmC0D0p  pcmC0D1c  pcmC0D1p  seq  timer      If I try `beep -e /dev/snd/`* - all devices return this:               ioctl: Inappropriate ioctl for device     ioctl: Inappropriate ioctl for device      I'm shure it's `/dev/snd/pcmC0D1p` that I need, it's the only one busy when music is playing.


Why does Ubuntu store the daemon logs on /var/log/daemon.log.1 instead of /var/log/daemon.log?

Pretty much what the title says. Trying to `cat /var/log/daemon.log` doesn't produce any output, while `cat /var/log/daemon.log.1` does. Why do daemons store logs to the **/var/log/daemon.log.1** file instead of **/var/log/daemon.log**? Is there a specific reason they are storing on the other file? **NOTE:** `ls -l /var/log` shows both of those files have the same permissions and both are owned by a user called `admin`


FreeBSD csh, TAB to show available choices?

I am a newbie to FreeBSD. How can i configure `csh` or `tcsh` to show available choices by pressing TAB twice, just like bash?


Cut colored text ignoring color tags

My problem is similar to this one; I want to use `cut` to simulate a `nowrap` on `tmux`, but my output is colored. I know how many columns I want to keep (50) but I don't know how many color tags will be on the output. Cutting with `cut -c-50` generates all kinds of different output, depending on how many escape characters (color tags) are on each line. So, summing it up: can I cut the text with a fixed width ignoring the colors, so that I always end up with 50 colored characters?


"tar --exclude-backups" does not exclude files with tilde at end

If I have the following directory:               $ ls -a foo     .  ..  a  #a#  a~  b  b.bkp  c  .git  .hg  .svn      and call:               $ tar zcf foo-no-bkp.tar.gz --exclude-backups foo/      The resulting archive still has backup files (even those considered backup files according to the documentation).               $ tar ztf foo-no-bkp.tar.gz      foo/     foo/a~     foo/.svn/     foo/#a#     foo/.hg/     foo/a     foo/.git/     foo/b.bkp     foo/c     foo/b      I am using GNU tar 1.26 on Ubuntu 12.04. What can be wrong? Should it be considered a bug?


How to configure gpg to enter passphrase only once per session

Is it posible to configure `gpg` in a way that I enter passphrase only once, and it will work for the whole session (I'm using `Ubuntu/XFce`)? I'm not sure how `gpg` works, it seems that the default function is that `gpg` asks `gpg-agent` for the passphrase and the agent runs pin-entry to ask for passphrase. I would like to use pinentry-curses only once per session, so I can paste my passphrase (I have `hex` string from a sentence - I use `echo -n <SENTENCE> | str-hex`) and sign email from Claws Mail without putting passphrase (you can't use pinentry-curses with Claws Mail).


Problem with Airprint server for iOS 6

I'm trying to set up Airprint server on Raspberry Pi under CUPS. I have done everything like in this tutorial: Configuring the Raspberry Pi as an AirPrint server. Then I have done this: Linux Airprint Server for iOS6 devices to make it compatible with iOS 6 devices, but iPad with iOS 6 can't see it. It only can be seen by another CUPS server on the local network. Any ideas?


BAMT wireless connection no DHCPOFFERS received

I have managed to get my Edimax EW-7811Un wireless adapter registered and the correct driver installed, but need some help getting it connected to my WPA2 PSK network.               root@bamt-miner:/home/user# lsusb      Bus 001 Device 005: ID 7392:7811 Edimax Technology Co., Ltd EW-7811Un 802.11n Wi  reless Adapter [Realtek RTL8188CUS]          root@bamt-miner:/home/user# lsmod     Module                  Size  Used by     8192cu                542854  0               wlan0     Link encap:Ethernet  HWaddr 80:1f:02:7c:6e:3a               inet6 addr: fe80::821f:2ff:fe7c:6e3a/64 Scope:Link               UP BROADCAST MULTICAST  MTU:1500  Metric:1               RX packets:4 errors:0 dropped:885 overruns:0 frame:0               TX packets:2 errors:0 dropped:245 overruns:0 carrier:0               collisions:0 txqueuelen:1000               RX bytes:198810 (194.1 KiB)  TX bytes:23383 (22.8 KiB)          wlan0:avahi Link encap:Ethernet  HWaddr 80:1f:02:7c:6e:3a               inet addr:169.254.5.114  Bcast:169.254.255.255  Mask:255.255.0.0               UP BROADCAST MULTICAST  MTU:1500  Metric:1      My /etc/network/interfaces looks like this               auto lo     iface lo inet loopback          auto eth0     iface eth0 inet dhcp          auto wlan0     iface wlan0 inet dhcp         wpa-ssid myawesomeinternethotspot         wpa-psk myunbreakablewpa2password     iface default inet dhcp      Is there something that i'm missing?


Equivalent of forward/back buttons for unix shell (when navigating directories)?

I'd like to be able to type in terminal commands of forward/back especially if I went from a directory with a super-long name to home (and want to return back to the directory with the super-long name).


How to create UDF images and burn them to DVD or CDROM?

Writing CDs with `cdrecord` and making images with `genisoimage` is no problem. I want to write DVDs in a similar manner, first creating an image, then burning it to disk. This is quite beneficial, since I can inspect the image before burning it to disk. Now, all I've seen, is how to use the `growisofs` command to burn something to DVD, but all how-to's were using ISO9660 for DVDs. But I want to burn UDF images. Before I can burn them, I need to make them, but how do I create UDF images? Also, If you could explain, or link on how to burn BluRay, that would be great, too. All tools must be command line, as I need to work with it, where GUI is no option.


how to reboot a frozen FreeBSD server from the serial console?

Linux has the "magic sysrq key" to reboot frozen machines remotely, and it works over the serial console, but what about FreeBSD? Is there a way to send a "control-alt-delete" to FreeBSD servers on serial consoles?


Where is/should be created wpa_supplicant.conf on Debian

I want to set my regulatory domain on debian stable but i can't seem to find `wpa_supplicant.conf` wich resided under `/etc/wpa_supplicant/wpa_supplicant.conf` on fedora. Does anyone know where to find it on debian? Just to clarify i use NetworkManager to manage my networks.


Completion of words on the screen as in VIM (Bash or Tmux)

How can I configure Bash, Zsh or Tmux to complete the **last matching identifier on the screen**? Consider this common scenario:               $ git fetch     remote: Counting objects: 16, done.     remote: Compressing objects: 100% (9/9), done.     remote: Total 9 (delta 4), reused 0 (delta 0)     Unpacking objects: 100% (9/9), done.     From /opt/git/thunder      * [new branch]      issue540   -> origin/issue547314        e9204cf..4d42c3f  v2.1       -> origin/v2.1      How can I get Bash / Zsh/ Tmux to complete `issue547` on the CLI easily? When I press `Tab` after `$ git checkout is` Git helpfully completes to `issue`, but I must complete the digits by myself because **all the previous digits do in fact match existent Git branches**. In VIM, pressing `Ctrl`+`P` for omnicomplete will complete as the previous match, so in this case `issue547314` will in fact be completed. **How can I get this behaviour in Bash, in Zsh or in Tmux**? I'm currently using Bash 4.2 and Tmux 1.10 on Ubuntu Server (usually 12.04 LTS). I can update to the latest Ubuntu Server LTS (14.04) if needed. **EDIT** : I would not mind any solution that uses Bash, Zsh, or Tmux as long as it is not difficult to use. So `Tab` or `Ctrl`+`P` or some other such shortcut would be fine, but not `Alt`+`Meta`+`Super`+`Shift`+`א`.


Text editor with split screen option

Is there an editor which has the option to "split the screen" into two or more parts, accessing more than one file (possibly with a file tree) without opening more editor windows at once, and how would one do this (what are the commands). I don't know if I made myself clear, but "split screen" is the only way to describe what I want to achieve. I want to use it to program, having more than one file open for editing. Note that I'm pretty new to both vi and emacs, if these are capable of doing this. Also, if this has to be done through a terminal editor, can it be done in the same terminal, regardless of the screen size?


USB flash drive mounts and unmounts automatically

Whenever I plug my flash drive into the usb, a message like this window appears on the screen:               Error mounting /dev/sdb1 at /media/sajjad/Linux Mint 16 Cinnamon 64-bit: Command-line `mount -t "ntfs" -o "uhelper=udisks2,nodev,nosuid,uid=1000,gid=1000,dmask=0077,fmask=0177" "/dev/sdb1" "/media/sajjad/Linux Mint 16 Cinnamon 64-bit"' exited with non-zero exit status 13: $MFTMirr does not match $MFT (record 0).     Failed to mount '/dev/sdb1': Input/output error     NTFS is either inconsistent, or there is a hardware fault, or it's a     SoftRAID/FakeRAID hardware. In the first case run chkdsk /f on Windows     then reboot into Windows twice. The usage of the /f parameter is very     important! If the device is a SoftRAID/FakeRAID then first activate     it and mount a different device under the /dev/mapper/ directory, (e.g.     /dev/mapper/nvidia_eahaabcc1). Please see the 'dmraid' documentation     for more details.      What can I do about this problem?


AIX 6.1 JFS2 Oracle files system, not using much files system cache

I am running Oracle database on AIX 6.1, Oracle using JFS2 file systems. Maxperm is set to 90%. This is busy database server, but it is not using the file system cache (less then 2%). The system has 40GB free memory. Is there a reason why file system cache is not used?


How to add unique id to file name in cron job?

My cronjob looks like this:               5 3 * * * mysqldump -u root test > /srv/backup/mysql_daily.dump      How can I make filename unique for every time when cronjob writes mysql_daily.dump?


Escape on Control key, Control on Capslock key, Capslock on Escape key

I'm looking for a method that works in both X and the console with console- setup (e.g. xkboptions, no X-exclusive methods like `xmodmap`). With XKBoptions, combining `ctrl:swapcaps` and `caps:swapescape` does not achieve the desired effect - it puts control on capslock (good) and capslock on both the control and escape keys. For the curious / confused, the rationale is to optimize the keyboard layout by putting more frequently used functions on easy to reach keys. Since I never use capslock anyways I would also settle for a solution that puts Control on CapsLock and Escape on Control and leaves the Escape key as is (leaving me with no CapsLock function).


fcron or followup on debian wheezy (stable)

I've been using fcron for a long time on debian linux. In oldstable it is still existing fcron_oldstable. So sad in the actual stable `wheezy` there is no fcron_stable.   Are there suggestions which cron to use?   Why was it removed from debian?   In nabble one can find the suggestion to use anacron as an addition - but that solves my problems only for jobs needing to run in periods of days. For some applications, I used `fcron` to run thins in periods of hours.


'tie' [nonexisting] files to programs

Recently, I just had an idea which turned out to be pretty useful under certain circumstances. But first some simple explanation: In Perl, you have the option to tie variables to some functions which are called when the variable is used. E.g. for: "Write the changes of that variable to HD every time it is changed". This is pretty useful in a lot of situations. See the perldoc for more detailed explanations: http://perldoc.perl.org/functions/tie.html So I had an idea: Is it possible to bind files in Unix/Linux in general (or on any specific file system, just for curiosity, though I use ext4 mainly) to scripts? One example where this would be really useful would be crontab. This file is not quite simple to maintain automatically if you have a lot of cronjobs and a lot of different persons working on it. Everytime it needs to be changed and so on and so forth. Here, a database would come in handy, where all the information needed is stored + a script which turns the information in the Database to something cron can understand. So, my idea basically is, in this example, not to have the crontab file but instead having it linked to a script, lets say `/root/crontab.pl`. In my mind, every time the OS tries to find the crontab itself, it would instead see: "Oh, file doesn't exist, though. It's tied to this and that. I should execute that script and the output of it will be used as if it was the file", so being totally transparent to the programs itself. Of course, there are other ways to achieve this thing: replacing the file, this and that and so on and so forth, but the basic idea should be kind of clear. I actually haven't found anything like that in my research, though, because I mainly program Perl and I'm used to call that thing "tie" and don't know any other words for that, that might be my fault. So: Is there anything? And, if not: Does anything speak against such a feature? I really think there are plenty situations where that would be awesome.


How can I delete a trailing newline in bash?

I'm looking for something that behaves like Perl's `chomp`. I'm looking for a command that simply prints its input, minus the last character if it's a newline:               $ printf "one\ntwo\n" | COMMAND_IM_LOOKING_FOR ; echo " done"     one     two done     $ printf "one\ntwo" | COMMAND_IM_LOOKING_FOR ; echo " done"     one     two done


How to reference a script-local dictionary in a Vim mapping?

Somehow I'm not able to execute the following mapping:               function! s:MySurroundingFunctionIWantToKeep()       let s:Foobar={'foo': 'bar'}       map \42 :echo <sid>Foobar.foo<cr>     endfunction     call s:MySurroundingFunctionIWantToKeep()      I thought it works the same way as it does with a script-local function:               function! s:MySurroundingFunctionIWantToKeep()       function! s:Foobar()         echo 'bar'       endfunction       map \42 :call <sid>Foobar()<cr>     endfunction     call s:MySurroundingFunctionIWantToKeep()      Also freeing `s:Foobar` from `s:MySurroundingFunctionIWantToKeep()` doesn't help, like:               let s:Foobar={'foo': 'bar'}     map \42 :echo <sid>Foobar.foo<cr>      Declaring the `s:Foobar` script-local variable as `g:Foobar` global variable does the trick.


Mouse and keyboard not working in qemu emulation of beagleboard with latest angstrom image

I was trying to emulate an angstrom image for beaglexm in qemu on my Ubuntu 12.04 laptop. In a new window the image boots up and autologins into GNOME shell. But keyboard and mouse remains unresponsive. I gave the following command:               qemu-system-arm -M beaglexm -m 1024 -sd Angstrom-TI-GNOME-image-eglibc-ipk-v2012.01-core-beagleboard-2012.01.11.img -clock unix -serial stdio -device usb-mouse -device usb-kbd -net nic -net user,hostfwd=::2222-:22      As the emulation starts, following log is generated on the parent terminal               Warning: vlan 0 with no nics     Warning: requested NIC (anonymous, model unspecified) was not created (not supported by this machine?)     U-Boot SPL 2011.12-00006-gb1fd369 (Dec 30 2011 - 09:48:45)     OMAP SD/MMC: 0     reading u-boot.img     .     U-Boot 2011.12-00006-gb1fd369 (Dec 30 2011 - 09:48:45)     OMAP36XX/37XX-GP ES1.1, CPU-OPP2, L3-165MHz, Max CPU Clock 1 Ghz     OMAP3 Beagle board + LPDDR/NAND     I2C:   ready     DRAM:  512 MiB     NAND:  256 MiB     MMC:   OMAP SD/MMC: 0     *** Warning - bad CRC, using default environment     .     ERROR : Unsupport USB mode     Check that mini-B USB cable is attached to the device     In:    serial     Out:   serial     Err:   serial     Beagle xM Rev A     No EEPROM on expansion board     No EEPROM on expansion board     Die ID #51454d5551454d555400000051454d55     Net:   Net Initialization Skipped     No ethernet found.     Hit any key to stop autoboot:  0     The user button is currently NOT pressed.     SD/MMC found on device 0     reading uEnv.txt     .     13 bytes read     Loaded environment from uEnv.txt     Importing environment from mmc ...     Loading file "/boot/uImage" from mmc device 0:2 (xxa2)     3372316 bytes read     Booting from mmc ...     ## Booting kernel from Legacy Image at 80200000 ...        Image Name:   Angstrom/3.0.14/beagleboard        Image Type:   ARM Linux Kernel Image (uncompressed)        Data Size:    3372252 Bytes = 3.2 MiB        Load Address: 80008000        Entry Point:  80008000        Verifying Checksum ... OK        Loading Kernel Image ... OK     OK     .     Starting kernel ...     .     Uncompressing Linux... done, booting the kernel.     omap2_inth_read: Bad register 0x000020     omap_i2c_write: Bad register 0x0000d0     omap_i2c_write: Bad register 0x0000d0     omap_i2c_write: Bad register 0x0000d0     omap_i2c_write: Bad register 0x0000d0     omap_i2c_write: Bad register 0x0000d0      After the image completely boots up into shell, the keystroke is not responsive but logs the following in the parent terminal:               usb-kbd: warning: key event queue full      I tried a solution given here by building latest linaro-qemu from scratch but same result. Also I am not able to ssh into this running image. I issued the following command               ssh -p 2222 root@localhost      It is simply refusing the connection


Vi editor behaving randomly while editing

When I open a PuTTY session in full screen I can't scroll down and up properly with the down arrow key. It seem to move down the screen and gets stuck somewhere in the middle. When I open PuTTY in small window it works fine for scrolling down or up. But still when I use l key or right arrow key to move right it seems to delete characters and move with tabs.


basic division using variable and integer

I'm an extreme beginner in bash commands, and am having trouble figuring out a basic division command. `count = redis-cli llen domains;` `echo $count` returns 1000 How can I echo `$count/1000`? I've tried different combinations of:               echo `expr $count / 1000`;     echo $count/1000;     echo ($count / 1000);      Could someone help me craft this command and explain how it should be setup?