title: Sendmail configuration with user mapping on Solaris

text: I have the following:   * `host1.intra.net` which has sendmail and users: `user1`, `user2` & `user3`. It is running SunOS 5.10.   * `host2.intra.net` which has SMTP server. No authentication, no encryption.   * Email addresses john.user1@company.com, ada.user2@company.com, alice.user3@company.com   * mailx 5.0 on host1.intra.net is being used to send emails Please kindly enlighten me how could I:   * Configure sendmail on `host1.intra.net` to use SMTP on `host2.intra.net` with no authentication, no encryption.   * If an email is sent from the shell of `user1`, it should appear as being sent from `john.user1@company.com`.   * If an email is sent from the shell of user2, it should appear as being sent from `ada.user2@company.com`.   * If an email is sent from the shell of user3, it should appear as being sent from `alice.user3@company.com`.


title: Output progess of the scp/sftp command to both standard out and a file on linux server

text: I am writing a release script, which uses scp/sftp to get the the file from a remote server, we want to log the output of this script to a release.log file as well. I am using "tee" to achieve this, which works perfectly fine for everything, i mean standard out and error, but when it comes to progress of the file download(which takes time to copy), it doesn't show up on the console or in the file as well. Output of scp without tee               frrinstd@loneqflocfd0034.uk.db.com:/apps/flowrisk/valservice/release/London/uat2/vs-server-2.1.16-21190-linux-amd64-frod-uat2-London-dist.zip /apps/flowrisk/uatldn/valservice     vs-server-2.1.16-21190-linux-amd64-frod-uat2-London-dist.zip                                                               100%   78MB  39.1MB/s   00:02      Output of scp WITH tee               frrinstd@loneqflocfd0034.uk.db.com:/apps/flowrisk/valservice/release/London/uat2/vs-server-2.1.16-21190-linux-amd64-frod-uat2-London-dist.zip /apps/flowrisk/uatldn/valservice      Can someone please tell me how to make it to output the progress of scp/sftp command on the console with tee as well, so that user know what is happening?


title: Unable to make outbound SNMP connections when IPTables is enabled

text: I have a bunch of windows servers configured with the windows SNMP agent. Each server has four IP addresses and SNMP listens on all of them. There is something very odd with my monitoring server (which is Centos 5.5 32 bit with net-snmp 5.3.2.2). If I have `iptables` **turned off** then I have no problems performing snmp queries on any IP address on any of these servers. If I turn on IPtables then I am only able to query on what appears to be just one specific IP address on each of these servers. The `snmpget` just times out with `Timeout: No Response from x.x.x.x`. There's no pattern to this behaviour with regards to which IP addresses I'm allowed to connect to. But it's one and only one IP address per machine. This is my iptables config:               *filter     :INPUT ACCEPT [0:0]     :FORWARD ACCEPT [0:0]     :OUTPUT ACCEPT [0:0]     :RH-Firewall-1-INPUT - [0:0]     -A INPUT -j RH-Firewall-1-INPUT     -A FORWARD -j RH-Firewall-1-INPUT     -A RH-Firewall-1-INPUT -i lo -j ACCEPT     -A RH-Firewall-1-INPUT -p icmp --icmp-type any -j ACCEPT          -A RH-Firewall-1-INPUT -p udp --dport 5353 -d 224.0.0.251 -j ACCEPT          -A RH-Firewall-1-INPUT -m state --state ESTABLISHED,RELATED -j ACCEPT          -A RH-Firewall-1-INPUT -s 172.16.3.0/24 -m state --state NEW -m tcp -p tcp --dport 22 -j ACCEPT     -A RH-Firewall-1-INPUT -i lo -m state --state NEW -m tcp -p tcp --dport 22 -j ACCEPT          -A RH-Firewall-1-INPUT -s 172.16.3.0/24 -m state --state NEW -m tcp -p tcp --dport 5668 -j ACCEPT     -A RH-Firewall-1-INPUT -i lo -m state --state NEW -m tcp -p tcp --dport 5668 -j ACCEPT          -A RH-Firewall-1-INPUT -s 172.16.3.0/24 -m state --state NEW -m tcp -p tcp --dport 80 -j ACCEPT     -A RH-Firewall-1-INPUT -i lo -m state --state NEW -m tcp -p tcp --dport 80 -j ACCEPT          -A RH-Firewall-1-INPUT -s 172.16.3.0/24 -m state --state NEW -m tcp -p tcp --dport 443 -j ACCEPT     -A RH-Firewall-1-INPUT -i lo -m state --state NEW -m tcp -p tcp --dport 443 -j ACCEPT          -A RH-Firewall-1-INPUT -s 172.16.3.0/24 -m state --state NEW -m tcp -p tcp --dport 3306 -j ACCEPT     -A RH-Firewall-1-INPUT -i lo -m state --state NEW -m tcp -p tcp --dport 3306 -j ACCEPT     -A RH-Firewall-1-INPUT -j REJECT --reject-with icmp-host-prohibited     COMMIT      I have no trouble connecting outbound to any other server, for example using `wget` to grab RPM's. I did try adding this as a last resort, but no joy either:               -A OUTPUT -p udp -s 0/0 --sport 1024:65535 -d 0/0 --dport 161:162 -m state --state NEW,ESTABLISHED -j ACCEPT     -A INPUT -p udp -s 0/0 --sport 161:162 -d 0/0 --dport 1024:65535 -m state --state ESTABLISHED -j ACCEPT      This is the output from `iptables -L`:               Chain INPUT (policy ACCEPT)     target     prot opt source               destination     RH-Firewall-1-INPUT  all  --  anywhere             anywhere     ACCEPT     udp  --  anywhere             anywhere            udp spts:snmp:snmptrap dpts:1024:65535 state ESTABLISHED          Chain FORWARD (policy ACCEPT)     target     prot opt source               destination     RH-Firewall-1-INPUT  all  --  anywhere             anywhere          Chain OUTPUT (policy ACCEPT)     target     prot opt source               destination     ACCEPT     udp  --  anywhere             anywhere            udp spts:1024:65535 dpts:snmp:snmptrap state NEW,ESTABLISHED          Chain RH-Firewall-1-INPUT (2 references)     target     prot opt source               destination     ACCEPT     all  --  anywhere             anywhere     ACCEPT     icmp --  anywhere             anywhere            icmp any     ACCEPT     udp  --  anywhere             224.0.0.251         udp dpt:mdns     ACCEPT     all  --  anywhere             anywhere            state RELATED,ESTABLISHED     ACCEPT     tcp  --  172.16.3.0/24        anywhere            state NEW tcp dpt:ssh     ACCEPT     tcp  --  anywhere             anywhere            state NEW tcp dpt:ssh     ACCEPT     tcp  --  172.16.3.0/24        anywhere            state NEW tcp dpt:5668     ACCEPT     udp  --  172.16.3.0/24        anywhere            state NEW udp dpt:5668     ACCEPT     tcp  --  anywhere             anywhere            state NEW tcp dpt:5668     ACCEPT     udp  --  anywhere             anywhere            state NEW udp dpt:5668     ACCEPT     tcp  --  172.16.3.0/24        anywhere            state NEW tcp dpt:http     ACCEPT     tcp  --  anywhere             anywhere            state NEW tcp dpt:http     ACCEPT     tcp  --  172.16.3.0/24        anywhere            state NEW tcp dpt:https     ACCEPT     tcp  --  anywhere             anywhere            state NEW tcp dpt:https     ACCEPT     tcp  --  172.16.3.0/24        anywhere            state NEW tcp dpt:mysql     ACCEPT     tcp  --  anywhere             anywhere            state NEW tcp dpt:mysql     REJECT     all  --  anywhere             anywhere            reject-with icmp-host-prohibited


title: Why does SCP hang on copying files larger than 1405 bytes?

text: I'm trying to copy a file from one of my local machines to a remote machine. Copying a file with size upto 1405 bytes works fine. When I try to scp a larger file, the file gets copied but the scp process hangs up and doesn't exit. I have to hit Ctrl-C to return back to the shell. I have observed the same behavior with FTP as well. Any ideas about what might be causing this?


title: cd by just typing the directory's name?

text: I either had this somewhere 20 years ago or I dreamed about it. Basically: If if type `blobblob` I get   `blobblob: command not found` Fair enough. I would like it so that when my shell gets those errors - command not found - it checks to see if a directory exists with that name ('blobblob') and if it does it `cd`'s to that directory. I'm sure there are some reasons for not doing this or doing it with caution.   I just think it would be pretty neat though and I would like to give it a try by finding how somewhere (like here!). I have no idea how to do the kinda shell programming this might imply.


title: How to dump a man page?

text: How can I 'cat' a man page like I would 'cat' a file to get just a dump of the contents?


title: can't view images stored on mounted network drive on linux webserver

text: I have a network drive mounted at `/home/lv_admin/uslonsnas001` where I have stored images. The mount point and all sub folders have rwx mod 775 privileges. My PHP script moves the images to this mount but Apache cannot view the images afterwards. My webpage (located in `/var/www/`) has the image path set to:               /home/lv_admin/uslonsnas001/BoardTest/2011/5/29/10/35/17788/Images/E_1-U23.jpg      The `/var/log/apache2/error.log` shows an error of:               [error] [client 128.251.109.244] File does not exist: /var/www/home, referer:      http://uslonsweb003.us.alcatel-lucent.com/AOI/repairtool/repairindex.php      so, it looks like Apache is trying to treat my image path as a relative link but I think it should be a symbolic link. What can I do to fix this?


title: Is there any way to view several days of sysstat logs in kSar?

text: Is there any way to amalgamate days of sysstat logs, so one could view a whole week in kSar for example? Currently I can only see individual days, loaded one at a time, or in separate windows.


title: vnstat not updating

text: I installed vnstat on my Ubuntu 14.04 server to track my internet usage (I have a limited monthly transfer). The database never updates, however. I've tried uninstalling/reinstalling, but that doesn't work. What do I need to do to get vnstat to update and be accurate?


title: Add new user with permissions same as existing user

text: How to create a new user with permission exactly same as an existing user in linux.


title: remove carriage return character from large binary file

text: I have a large binary file ( nearly binary file ! ) which has many _\r\n_ in it _[ gets Generated in windows env and doesnt have controle over generating application ]_. I want to remove _\r_ from this big file [ =~ 1Gb ] to do further processing in another legacy app that shouts at \r s Is there any easy way to do it the unix way ?


title: How to restart python script after one second of going down using UPSTART?

text: I am running my Python script using upstart feature of Ubuntu so that if for whatever reason my Python script dies or gets killed, it can be restarted automatically and everything is working fine - So I decided to use `UPSTART` feature of Ubuntu to restart the Python script automatically. After creating the `testing.conf` file like this in `/etc/init/testing.conf` -               start on runlevel [2345]     stop on runlevel [016]          chdir /tekooz     exec python testing.py     respawn      I ran below sudo command to start it and I can see that process running using `ps ax` and my python script is also running fine.               root@bx13:/tekooz# sudo start testing     testing start/running, process 27794      Now if I kill the PID of the above process, then it get restarted automatically within few milliseconds or microseconds. Is there any possibility of restarting my python script after 1 second if it has gone down or got killed? I don't want to restart immediately.


title: How to figure out memory leaks?

text: I'm running Ubuntu 14.04 on Digitalocean to host my blog. I'm using HHVM + nginx + MySQL. Every few hours (~12h), there's no more RAM left and nginx throws an 502 error. I check the memory usage for the last 10 minutes with `free -m` and that's what I get:                            total       used       free     shared    buffers     cached     Mem:           994        714        279         29         20        235     -/+ buffers/cache:        458        535     Swap:            0          0          0      * * *                            total       used       free     shared    buffers     cached     Mem:           994        715        278         29         20        235     -/+ buffers/cache:        459        534     Swap:            0          0          0      * * *                            total       used       free     shared    buffers     cached     Mem:           994        722        271         29         20        240     -/+ buffers/cache:        461        532     Swap:            0          0          0      * * *                            total       used       free     shared    buffers     cached     Mem:           994        729        264         29         20        240     -/+ buffers/cache:        469        524     Swap:            0          0          0      * * *                            total       used       free     shared    buffers     cached     Mem:           994        725        268         29         20        240     -/+ buffers/cache:        464        529     Swap:            0          0          0      So how can I figure out where the memory leak comes from? If it helps, the `htop` output:                 PID USER      PRI  NI  VIRT   RES   SHR S CPU% MEM%   TIME+  Command      2107 root       20   0 26284  2528  1408 R  0.7  0.2  0:00.47 htop      1002 mysql      20   0  737M 72680  7332 S  0.0  7.1  0:00.99 /usr/sbin/mysqld      1088 redis      20   0 36996  7256   876 S  0.0  0.7  0:06.46 /usr/bin/redis-server 127.0.0.1:6379       925 mysql      20   0  737M 72680  7332 S  0.0  7.1  0:17.87 /usr/sbin/mysqld       949 mysql      20   0  737M 72680  7332 S  0.0  7.1  0:00.21 /usr/sbin/mysqld         1 root       20   0 33492  2768  1400 S  0.0  0.3  0:01.30 /sbin/init       343 root       20   0 19608   648   460 S  0.0  0.1  0:00.12 upstart-udev-bridge --daemon       351 messagebu  20   0 39228  1292   884 S  0.0  0.1  0:00.07 dbus-daemon --system --fork       354 root       20   0 51476  1552   952 S  0.0  0.2  0:00.05 /lib/systemd/systemd-udevd --daemon       399 root       20   0 43452  1756  1396 S  0.0  0.2  0:00.00 /lib/systemd/systemd-logind       427 syslog     20   0  249M  1388   788 S  0.0  0.1  0:00.01 rsyslogd       428 syslog     20   0  249M  1388   788 S  0.0  0.1  0:00.00 rsyslogd       429 syslog     20   0  249M  1388   788 S  0.0  0.1  0:00.02 rsyslogd       426 syslog     20   0  249M  1388   788 S  0.0  0.1  0:00.03 rsyslogd       452 root       20   0 15408   648   320 S  0.0  0.1  0:00.05 upstart-file-bridge --daemon       672 root       20   0 15392   692   332 S  0.0  0.1  0:00.05 upstart-socket-bridge --daemon       810 root       20   0 15820   928   768 S  0.0  0.1  0:00.00 /sbin/getty -8 38400 tty4       816 root       20   0 15820   928   768 S  0.0  0.1  0:00.00 /sbin/getty -8 38400 tty5       821 root       20   0 15820   932   768 S  0.0  0.1  0:00.00 /sbin/getty -8 38400 tty2       822 root       20   0 15820   924   768 S  0.0  0.1  0:00.00 /sbin/getty -8 38400 tty3       825 root       20   0 15820   932   768 S  0.0  0.1  0:00.00 /sbin/getty -8 38400 tty6       855 root       20   0 61364  3008  2328 S  0.0  0.3  0:00.03 /usr/sbin/sshd -D       858 root       20   0  4368   656   512 S  0.0  0.1  0:00.00 acpid -c /etc/acpi/events -s /var/run/acpid.socket       859 root       20   0 23656  1024   768 S  0.0  0.1  0:00.03 cron       861 daemon     20   0 19140   160     0 S  0.0  0.0  0:00.00 atd       894 whoopsie   20   0  327M  3584  2424 S  0.0  0.4  0:00.00 whoopsie       896 whoopsie   20   0  327M  3584  2424 S  0.0  0.4  0:00.00 whoopsie       873 whoopsie   20   0  327M  3584  2424 S  0.0  0.4  0:00.00 whoopsie      1170 www-data   20   0 1541M  390M 91108 S  0.0 39.3  0:00.59 /usr/bin/hhvm --config /etc/hhvm/php.ini --config /etc/hhvm/server.ini --user www-data --mode daemo      1357 www-data   20   0 1541M  390M 91108 S  0.0 39.3  0:23.19 /usr/bin/hhvm --config /etc/hhvm/php.ini --config /etc/hhvm/server.ini --user www-data --mode daemo      1437 www-data   20   0 1541M  390M 91108 S  0.0 39.3  0:12.09 /usr/bin/hhvm --config /etc/hhvm/php.ini --config /etc/hhvm/server.ini --user www-data --mode daemo      1438 www-data   20   0 1541M  390M 91108 S  0.0 39.3  0:19.50 /usr/bin/hhvm --config /etc/hhvm/php.ini --config /etc/hhvm/server.ini --user www-data --mode daemo      1439 www-data   20   0 1541M  390M 91108 S  0.0 39.3  0:14.87 /usr/bin/hhvm --config /etc/hhvm/php.ini --config /etc/hhvm/server.ini --user www-data --mode daemo      1440 www-data   20   0 1541M  390M 91108 S  0.0 39.3  0:14.93 /usr/bin/hhvm --config /etc/hhvm/php.ini --config /etc/hhvm/server.ini --user www-data --mode daemo      1441 www-data   20   0 1541M  390M 91108 S  0.0 39.3  0:13.68 /usr/bin/hhvm --config /etc/hhvm/php.ini --config /etc/hhvm/server.ini --user www-data --mode daemo      1442 www-data   20   0 1541M  390M 91108 S  0.0 39.3  0:11.29 /usr/bin/hhvm --config /etc/hhvm/php.ini --config /etc/hhvm/server.ini --user www-data --mode daemo      1443 www-data   20   0 1541M  390M 91108 S  0.0 39.3  0:16.50 /usr/bin/hhvm --config /etc/hhvm/php.ini --config /etc/hhvm/server.ini --user www-data --mode daemo      1444 www-data   20   0 1541M  390M 91108 S  0.0 39.3  0:17.66 /usr/bin/hhvm --config /etc/hhvm/php.ini --config /etc/hhvm/server.ini --user www-data --mode daemo       916 www-data   20   0 1541M  390M 91108 S  0.0 39.3  2:25.37 /usr/bin/hhvm --config /etc/hhvm/php.ini --config /etc/hhvm/server.ini --user www-data --mode daemo       945 mysql      20   0  737M 72680  7332 S  0.0  7.1  0:00.18 /usr/sbin/mysqld       946 mysql      20   0  737M 72680  7332 S  0.0  7.1  0:00.73 /usr/sbin/mysqld       947 mysql      20   0  737M 72680  7332 S  0.0  7.1  0:00.23 /usr/sbin/mysqld       948 mysql      20   0  737M 72680  7332 S  0.0  7.1  0:00.22 /usr/sbin/mysqld       950 mysql      20   0  737M 66360  7332 S  0.0  6.5  0:00.26 /usr/sbin/mysqld       951 mysql      20   0  737M 66360  7332 S  0.0  6.5  0:00.23 /usr/sbin/mysqld       952 mysql      20   0  737M 66360  7332 S  0.0  6.5  0:00.21 /usr/sbin/mysqld       955 mysql      20   0  737M 66360  7332 S  0.0  6.5  0:00.19 /usr/sbin/mysqld       956 mysql      20   0  737M 66360  7332 S  0.0  6.5  0:00.17 /usr/sbin/mysqld      1003 mysql      20   0  737M 66360  7332 S  0.7  6.5  0:01.61 /usr/sbin/mysqld      1004 mysql      20   0  737M 66360  7332 S  0.0  6.5  0:00.10 /usr/sbin/mysqld      1005 mysql      20   0  737M 66360  7332 S  0.0  6.5  0:00.00 /usr/sbin/mysqld      1168 mysql      20   0  737M 66360  7332 S  0.0  6.5  0:00.00 /usr/sbin/mysqld      1173 mysql      20   0  737M 66360  7332 S  0.0  6.5  0:03.08 /usr/sbin/mysqld      1202 mysql      20   0  737M 66360  7332 S  0.0  6.5  0:03.37 /usr/sbin/mysqld      1445 mysql      20   0  737M 66360  7332 S  0.0  6.5  0:02.37 /usr/sbin/mysqld      1446 mysql      20   0  737M 66360  7332 S  0.0  6.5  0:03.37 /usr/sbin/mysqld       957 memcache   20   0  357M 42368   876 S  0.0  4.2  0:00.96 /usr/bin/memcached -m 64 -p 11211 -u memcache -l 127.0.0.1       958 memcache   20   0  357M 42368   876 S  0.0  4.2  0:00.97 /usr/bin/memcached -m 64 -p 11211 -u memcache -l 127.0.0.1       959 memcache   20   0  357M 42368   876 S  0.0  4.2  0:00.91 /usr/bin/memcached -m 64 -p 11211 -u memcache -l 127.0.0.1       960 memcache   20   0  357M 42368   876 S  0.0  4.2  0:00.94 /usr/bin/memcached -m 64 -p 11211 -u memcache -l 127.0.0.1       961 memcache   20   0  357M 42368   876 S  0.0  4.2  0:00.00 /usr/bin/memcached -m 64 -p 11211 -u memcache -l 127.0.0.1       941 memcache   20   0  357M 42368   876 S  0.0  4.2  0:04.53 /usr/bin/memcached -m 64 -p 11211 -u memcache -l 127.0.0.1       962 root       20   0 90268  1440   228 S  0.0  0.1  0:00.00 nginx: master process /usr/sbin/nginx       963 www-data   20   0 91172  2840  1072 S  0.0  0.3  0:01.47 nginx: worker process      1064 root       20   0 25344  1556  1276 S  0.0  0.2  0:00.04 /usr/lib/postfix/master      1069 postfix    20   0 27460  1516  1232 S  0.0  0.1  0:00.00 qmgr -l -t unix -u      1091 redis      20   0 36996  7256   876 S  0.0  0.7  0:00.00 /usr/bin/redis-server 127.0.0.1:6379      1092 redis      20   0 36996  7256   876 S  0.0  0.7  0:00.00 /usr/bin/redis-server 127.0.0.1:6379      1151 root       20   0 15820   932   768 S  0.0  0.1  0:00.01 /sbin/getty -8 38400 tty1      1859 postfix    20   0 27408  1488  1212 S  0.0  0.1  0:00.00 pickup -l -t unix -u -c      1984 root       20   0  103M  4220  3224 S  0.0  0.4  0:00.11 sshd: root@pts/0      2054 root       20   0 22764  3876  1676 S  0.0  0.4  0:00.05 -bash


title: How to pipe diff into Kompare?

text: I want to quickly compare files in two different directories to see if the files are the same (same content). I want to see the results in Kompare (I'm on KDE - Kubuntu 12.04). Here's my diff command:               diff -EwbBsy /directory/one /directory/two      (That command would suit me even better if it ignored any files in /directory/one that are not already present in /directory/two, but I couldn't figure out how to achieve that.) To use Kompare, I do this:               diff -EwbBsy /directory/one /directory/two | kompare -o -      However, that gives the following error: > **Error:** Could not parse diff output. I also tried:               diff -Ewbus /directory/one /directory/two | kompare -o -      and just               diff /directory/one /directory/two | kompare -o -      and a few other variations without success. What am I doing wrong? Thanks.


title: Set variables in ZSH precmd and reference them in the prompt

text: Is there a way to set variables in the `precmd` function of zsh and then echo them in the prompt? Something like               function precmd {        GREETING='Hi Kevin!';     }          PROMPT="$GREETING";


title: Is grep part of coreutils? (If not, why?)

text: I have read in a few websites that grep comes with coreutils (e.g. https://wiki.archlinux.org/index.php/Core_Utilities) However, after building them, I noticed that grep is missing. I wonder if I built coreutils incorrectly. If grep is not part of coreutils, what is the rationale behind excluding it?


title: FreeBSD Base packages

text: Recently, I've stumbled upon an interesting question about the difference between Linux and FreeBSD (Why would someone choose FreeBSD over Linux?) and found there a link to this site. I've read that the main difference is that Linux is just a kernel and FreeBSD is a complete OS with many integrated packages in it, that work seamlessly.   So my question is: Where can I read about those packages, I mean is there some page which lists all packages built into the system?


title: adding a program on start-up by using LSBInitScripts

text: I use Debian Lenny (I know lenny is old and other bla bla) and would like to place a program on the start-up. I use `update-rc.d` by adding an executable file on `/etc/init.d`. By referring to http://wiki.debian.org/LSBInitScripts , I need to add a LSB on `/etc/init.d/myprogram`               ### BEGIN INIT INFO     # Provides:          myprogram     # Required-Start:    $all     # Required-Stop:     $remote_fs $syslog     # Default-Start:     2 3 4 5     # Default-Stop:      0 1 6     # Short-Description: Start daemon at boot time     # Description:       Enable service provided by daemon.     ### END INIT INFO      then do I need to append any script like:               DAEMON_PATH="/home/myprogram"     DAEMON=node     DAEMONOPTS="-my opts"     NAME=node     DESC="myprogram"     PIDFILE=/var/run/$NAME.pid     SCRIPTNAME=/etc/init.d/$NAME          case "$1" in     start)         printf "%-50s" "Starting $NAME..."         cd $DAEMON_PATH         PID=`$DAEMON $DAEMONOPTS > /dev/null 2>&1 & echo $!`         #echo "Saving PID" $PID " to " $PIDFILE             if [ -z $PID ]; then                 printf "%s\n" "Fail"             else                 echo $PID > $PIDFILE                 printf "%s\n" "Ok"             fi     ;;     status)             printf "%-50s" "Checking $NAME..."             if [ -f $PIDFILE ]; then                 PID=`cat $PIDFILE`                 if [ -z "`ps axf | grep ${PID} | grep -v grep`" ]; then                     printf "%s\n" "Process dead but pidfile exists"                 else                     echo "Running"                 fi             else                 printf "%s\n" "Service not running"             fi     ;;     stop)             printf "%-50s" "Stopping $NAME"                 PID=`cat $PIDFILE`                 cd $DAEMON_PATH             if [ -f $PIDFILE ]; then                 kill -HUP $PID                 printf "%s\n" "Ok"                 rm -f $PIDFILE             else                 printf "%s\n" "pidfile not found"             fi     ;;          restart)         $0 stop         $0 start     ;;          *)             echo "Usage: $0 {status|start|stop|restart}"             exit 1     esac      I felt like LSBInitScripts and the above scripts are different thing, but when I check some files on `/etc/init.d`, they have similar scripts. Could you please clarify if I need the above script or not. If I need the use the script above, do I need to create a .pid file or will it be created automatically?


title: Red Hat and Windows 7 dual boot system

text: I am looking for the best way to create a dual boot on my Red Hat system. This is a Red Hat 5.3 System for scientific use, and we need to run some Windows software on it for visualization purposes. What is the easiest way to implement dual boot if Linux is already installed; formatting the hard drive in not an option. My thoughts were:   1. Partition the HD and give Windows a 200GB logical drive   2. Install Windows 7 I am probably missing the part where I config the boot loader. What is the best way to do this? As a side note, is there a way to virtualize (VMWARE like) Windows 7 on the Red hat machine and is that a BIG lose in performance (how much you think will it be)?


title: Disable action keys

text: I'm running openSUSE on HP Pavilion dm4. I have a bunch of action keys (volume up/down, brightness, wifi etc.) on my function keys. For using standard `Fx` keys I have to hold `Fn` key. The problem is that I more often use `F1` to `F12` than those actions. How can I accomplish reverse this functionality? Holding `Fn` key for triggering actions -- and have normal functionality of function keys.


title: Changing default audio device in Pulseaudio

text: I would like to use HDMI on my graphic card for audio output. ALSA shows it as a card with 4 devices and I can get sound through one of them (the other three are different channels, perhaps? I have only stereo output connected). Although Pulseaudio has the right card set as default, it seems to me that it plays on the wrong device. _Pacmd_ shows that the sink has parameter _alsa.device_ set to the first device listed by ALSA, but I can get sound only from the second one. How can I force Pulseaudio to use another device of the same card as the default output? or How can I force ALSA to switch numbers of the first and the second device on the card?


title: How to echo an escaped string

text: How can I echo an escaped string that contains $ in Bourne Shell?               user@server:~$ cat test.sh      #!/bin/sh     echo $1          user@server:~$ ./test.sh \$sad\$test     $sad$test      I want it to return an escaped version like this:               user@server:~$ ./test.sh \$sad\$test     \$sad\$test      I have tried doing tricks with sed and awk but no luck. Any guidance would be greatly appreciated.


title: Wayland and full-screen apps

text: Will Wayland, unlike X, be able to "know" about a full screen app, and not fire up the screensaver? I remember reading up on this, and X (or present KWin/Compiz) cannot know or be told when to hold off on a screensaver. UPDATE: Apparantly my source was a bit one-sided, and X can be told to hold off the screensaver. This new fact turns my question into this: can Wayland be told there is a full-screen app and do the necessary things, without explicitely telling it to back off on the big red "Start Screensaver" button?


title: How to resize an IMG file's partition info?

text: I made an ISO this way: `sudo partimage save /dev/sdc1 /media/56AE8240AE82191F/Backup/xfcefat.iso` The resulting iso file is very small but when mounted I see that it has correctly preserved the partition information. The problem is my partition was 8gigs and only had like 100mb of data on it. I want to fix the partition information on the iso and tell it to think it is only a 500mb partition. How can I shrink it's partition information? If it was a usb drive I could do this with gparted and shrink it just fine. But this is an iso file raw copy clone of my disk.


title: Does truecrypt leave behind temporary files

text: I've I have some scans of sensitive documents in image format such as jpg png etc. When I open up the folder containing them which is in a truecrypt file, will nautilus create a temporary version of the scan or even a thumbnail of the scan on the computer which the file was opened on?


title: Find files newer than another file within each subdirectory

text: I have a folder structure like this               /Class/Student/Unit/files      Each Unit folder contains a file `MarkSheet*` that I update when I mark a students work. I need a script that tests if the student has uploaded files newer than when I last marked their work. The following is as close as I have been able to get (which doesn't work).               #!/bin/sh     find . -mindepth 3 -maxdepth 3 -type d -name '*' -execdir \     find "{}" -type f -newer "{}"/MarkSheet* \;


title: Chown and the risk of corrupting the backup disk

text: I am about to modify the file ownership recursively in a filesystem that uses ACLs. Because it is my backup disk, I thought I'd solicit comments on the script before I run it.               #!/bin/bash     # Replace Foobar, Bob, and Brand.     PREFIX="/Volumes/Foobar-Time-Machine/Backups.backupdb/Bob’s MacBook"     SUFFIX="/Brand/Users/"     USER="bob"          for dir in "${PREFIX}"/*/     do         chmod -R -a "group:everyone deny chown" "${PREFIX}${dir}${SUFFIX}${USER}"         chown -R $USER "${PREFIX}${dir}${SUFFIX}${USER}"         chmod -R =a# 1 "group:everyone deny add_file,delete,add_subdirectory,delete_child,writeattr,writeextattr,chown" "${PREFIX}${dir}${SUFFIX}${USER}"     done      Do you spot a disaster waiting to happen? The first chmod is meant to remove minimal ACL and the second is meant to restore it. Can the script be made safer? Needless to say, the script would be run as sudo.


title: Vim keybinding to delete up to (but not including) the next period

text: I've noticed a common idiom in my editing is a desire to delete everything up to, but not including, the next period. After a bit of researching online, I found the following command will work (I didn't expect searches to work, but so they do):               d/\.      Then it highlights all periods on the page, so I want to follow this with `:noh`. I tried making my own map:               map <leader>. :normal d/\.<cr>:noh<cr>      I chose to use `:normal` because I'm not sure how it would be able to "tell" where I wanted the search to end. However, this fails spectacularly. It does nothing. It shows in the statusbar that it does run `:noh` fine, so I assume it's getting through the command alright. It just doesn't work. When I tried to run `:normal d/\\.` as a command solely by itself (in Vim), I got the follow message in the statusbar:               YR:Aborting command d/      That's an error message from Yankring.vim, so I disabled it temporarily. Now once I run the command, it does nothing at all. Just happily sits there. To clarify: typing the command manually works with or without yankring. It's just that I can't get any of the various `map`s I've tried to work, with or without yankring. I believe the root of the issue is that when I type `d/` normally, a prompt comes up for me to search (this method works fine). That's fine and everything, but is there any way to automate this action so it can be bound to `<leader>.`? If any other information is needed, I'll gladly provide it.


title: awk: Blank line with date

text: I use the following code to write the online users' process numbers and the date they were checked:               w | tail -n +3 | awk '              { "date +%H:%M:%S" | getline tim}             {if ($1 != "")                     { if (usr != $1)  {printf("%s\t%d\t%s\n",usr, num, tim);                                     usr = $1;                                      num = 1 }                     else {num++}                        }             }             END{              if ($1 != "") if (num !=0) printf("%s\t%d\t%s\n",usr, num, tim);}     ' > test2     echo      I have a problem. After I run the script, it gives me one line + for the first analyse, where it gives me a blank for usr, 1 for process num and the date, after which it gives me the actual users and stuff. Can you help me fix it? Or is there a function already for this?


title: Unzip all non-existing or older files from archive

text: The behaviour I'd like with `unzip` is to extract all files, overwriting any that are older than those in the archive, not touching any that are the same age or newer, and to never prompt. The options available seem to be:   * `-o`: overwrite all files, even if they're the same age or older   * `-f`: extract only files that exist on disk and are older. Is there a way to get this behaviour?


title: NFS: share with all clients except one

text: I want to share a folder with all the network's clients except only one. This is my current `/etc/exports` file:               /opt/resources     *(rw,async)      What should I add to prevent the client `192.168.1.24` without the need to mention all other authorized clients' addresses?


title: Run a vim macro from inside a bash script

text: In a bash script I want to edit a file. Is there a way to write a macro in vim, save it and then call it in bash script?


title: Adjusting Screen Size on Ubuntu Virtualbox

text: When running Ubuntu as a Vitualbox guest, with a Windows 7 64-bit machine as host, how can I maximize the screen so it fills up the whole monitor?


title: Choosing filesystem for a 16TB Raid

text: I'm just putting together a machine with eight 2TB disks. I will be using Raid 6 (12TB of usable capacity) on top of them, but I'm not sure whether I should make LVM on top of the RAID, or what filesystem to use. What filesystems can be resized when used inside LVM?


title: How can I check mnt location?

text: On RedHat I'm able to do this:               $ df     Filesystem           1K-blocks      Used Available Use% Mounted on     /dev/xvda1             8256952   1820752   6352340  23% /     tmpfs                   305624         0    305624   0% /dev/shm     //10.128.41.24/linux-www                          125826044 125826044         0 100% /mnt/inf1/linux-www      but on ubuntu not so:               $ df     Filesystem           1K-blocks      Used Available Use% Mounted on     /dev/sda1             15481840   3958456  10736952  27% /     none                    296028       108    295920   1% /dev     none                    303244         0    303244   0% /dev/shm     none                    303244        64    303180   1% /var/run     none                    303244         0    303244   0% /var/lock          $ df /mnt/inf1/linux-www     Filesystem           1K-blocks      Used Available Use% Mounted on     /dev/sda1             15481840   3958612  10736796  27% /          $ mount     /dev/sda1 on / type ext4 (rw)     proc on /proc type proc (rw,noexec,nosuid,nodev)     none on /sys type sysfs (rw,noexec,nosuid,nodev)     fusectl on /sys/fs/fuse/connections type fusectl (rw)     none on /sys/kernel/debug type debugfs (rw)     none on /sys/kernel/security type securityfs (rw)     none on /dev type devtmpfs (rw,mode=0755)     none on /dev/pts type devpts (rw,noexec,nosuid,gid=5,mode=0620)     none on /dev/shm type tmpfs (rw,nosuid,nodev)     none on /var/run type tmpfs (rw,nosuid,mode=0755)     none on /var/lock type tmpfs (rw,noexec,nosuid,nodev)          $ awk -v needle="$device_path" '$1==needle {print $2}' /proc/mounts     [nothing]          $ grep /dev/sda /etc/mtab     [nothing]          **OH! It's because it's a folder! Sneaky!**      `/mnt/inf1` exists on the ubuntu machine too. I'd like to know what it's pointing too, how do I go about doing that?


title: Proper way to use shebang for bash

text: What is the recommended options in `bash`'s shebang?               #!/bin/bash -e      I currently have it as above. This sources `$HOME/.bashrc`. I don't want to source user's `.bashrc`/`.profile` as it might interfere with the script and it will delay the startup of the script (home directory is usually located in network drive). Is there some command line option that disables this?   And what are the other recommended flags to put in?


title: Can I send auditd logs to another computer?

text: On a Linux (debian) box, I have a NFS server wich seems to be overloaded by requests. In order to identify the problem, I'm trying to monitor with auditd/auditctl accessed files in the partition exported by the NFS server. The problem is that our disk or nfs problem prevents auditd to write logs on /var/log/auditd/auditd.log. What I really need is to send all logs somewhere else than on a local file. Can I simply redirect all logs from 192.168.1.1 to 192.168.1.2 (the network is working correctly) ?


title: How to create a cron which finds/kills/clears old puppet runs?

text: I am a new user of bash/cron, and I was given a task to create a cron which finds/kill/ and clears old puppet runs that were not successfully installed. The more help the better, but I am more or less looking for a starting point. Thanks in advance for your help!


title: Need a little help with --remote-schema option for rdiff-backup

text: I'm running the following command:               rdiff-backup --remote-schema '%s' 'sudo /usr/bin/rdiff-backup --server \         --restrict-read-only /'::/etc /var/backups/hosts/derp      It's backing up `/etc` from `localhost` and putting it in `/var/backups/hosts/derp` just fine. I can scarcely imagine it working better, but I have no idea how to get this to run and pull the files from another host. Maybe I'm just being silly and assuming that the **remote** part in `\--remote-schema` actually means **remote**.


title: When installing libpbc on Linux Mint, configure fails, and there is a shell script for dpkg, but it seems to have no output

text: I am trying to install `libpbc`.I started with the git URL. The `git clone` command installed a new `pbc` directory. The INSTALL file advises using `./configure`. However this command returns,               configure: error: cannot find install-sh, install.sh, or shtool in "." "./.." "./../.."      Further, there is a `makedeb.sh` shell script which reads,               #!/bin/bash     set -e     dpkg-buildpackage -rfakeroot      However, running the above script seems to have no effect.Is the `makedeb.sh` related to the `configure` script?


title: Can't access USB HDD

text: I just bought a WD 1TB Caviar Blue drive, and a Bytecc HD-35SU enclosure for it. Snapped the drive in, went to plug it in on my laptop, nothing happened. I figured that probably meant I needed to format it, so I tried to use `fdisk`. The new drive isn't listed. So I looked at `dmesg`, and I see this:               [  119.764054] usb 1-1: new high speed USB device using ehci_hcd and address 4     [  120.265826] Initializing USB Mass Storage driver...     [  120.265933] usb-storage 1-1:1.0: Quirks match for vid 152d pid 2329: 8020     [  120.265958] scsi6 : usb-storage 1-1:1.0     [  120.266153] usbcore: registered new interface driver usb-storage     [  120.266156] USB Mass Storage support registered.     [  121.306221] scsi 6:0:0:0: Direct-Access                                    PQ: 0 ANSI: 2 CCS     [  121.307330] sd 6:0:0:0: Attached scsi generic sg3 type 0     [  121.390676] sd 6:0:0:0: [sdc] Very big device. Trying to use READ CAPACITY(16).     [  121.391151] sd 6:0:0:0: [sdc] 72057594037927936 512-byte logical blocks: (0 B/0 B)     [  121.391896] sd 6:0:0:0: [sdc] Write Protect is off     [  121.391901] sd 6:0:0:0: [sdc] Mode Sense: 28 00 00 00     [  121.391907] sd 6:0:0:0: [sdc] Assuming drive cache: write through     [  121.393159] sd 6:0:0:0: [sdc] Very big device. Trying to use READ CAPACITY(16).     [  121.394280] sd 6:0:0:0: [sdc] Assuming drive cache: write through     [  121.394290]  sdc: unknown partition table     [  121.395383] sd 6:0:0:0: [sdc] Very big device. Trying to use READ CAPACITY(16).     [  121.396508] sd 6:0:0:0: [sdc] Assuming drive cache: write through     [  121.396513] sd 6:0:0:0: [sdc] Attached SCSI disk      I don't particularly know what that all means, but what concerns me is this line:               [  121.391151] sd 6:0:0:0: [sdc] 72057594037927936 512-byte logical blocks: (0 B/0 B)      That doesn't even make sense, right? Could it be because it is unformatted and had no partition table? However, I can't use `fdisk` to do any of that, because it says that it cannot read /dev/sdc... Is my brand-new drive fried?


title: sed one-liner to replace word-medial capitals

text: I used OCR to turn some scans into plaintext, but unfortunately the letters 'fi' which are commonly joined in some fonts, got read in as capital W's. Now I need to replace all the W's with 'fi', and these can easily be distinguished by the fact that a capital W does not ever occur in the middle of a word in true English. So, I need a sed one-liner that replaces all word-medial capital W's with the letters fi.


title: How to detect whether "find" found any matches?

text: Is there an idiomatic means to detect whether "find" found any matches? I'm currently using               COUNT=`find ... | wc -l`     if [ "$COUNT" -gt 0 ]; then      but this seems a little indirect to me. Also, I'd like find to stop searching once it's found a match, so it doesn't waste time and effort. I just need to know whether or not there are any files that match.


How to enter a tab character in vim with SuperTab plugin enabled?


title: How to install Flash player plugin on Fedora?

text: Anyone have a recommended way to get and install Flash effectively on Fedora?


title: Doing two things with output from a command

text: I have a program `texcount` that outputs the number of words in my LaTeX document. I can also pipe the output of this to `sed` to make the newlines TeX linebreaks and write this to a file which I can then include in my final document. But when I do `texcount foo.tex | sed s/$/'\\\\\\\'/ > wc.tex` the command line output of `texcount` is suppressed. How can I get the output of the first command to be displayed in the terminal _and_ piped to sed?


title: Why is the bash_history always coming up the same and not updating using non-login shells?

text: The last few days I've noticed that whenever I shutdown my system (Debian Testing) and fire up a bash session, then press the up arrow key, I get the commands from the first time I cleared the history cache using `history -c`. I'm not sure how this happened, but even if I clear my history again, then press the up arrow, nice it works, but if I start another shell it doesn't (even less whenever I restart or shutdown or log off). I've tried everything (even deleting the `.bash_history` by hand), so I ran out of ideas.               $ echo $SHELL     /bin/bash     $ /bin/bash --version     GNU bash, version 4.2.45(1)-release (i486-pc-linux-gnu)     $ echo $HISTFILE     /home/braiam/.bash_history      When looking for information to add the question, I ran `ls -l .bash_history` (not to look like a dumb) and found the problem:               $ ls -l .bash_history      -r--------. 1 braiam braiam 59372 Jul 26 20:18 .bash_history      But running `chmod +w .bash_history` didn't save the day. Now I wonder how it could end like that... After deleting the `.bash_history` file now I have no-history. I checked the .bashrc for clues:               cat .bashrc | grep -i hist     # don't put duplicate lines or lines starting with space in the history.     HISTCONTROL=ignoreboth     # append to the history file, don't overwrite it     shopt -s histappend     # for setting history length see HISTSIZE and HISTFILESIZE in bash(1)     HISTSIZE=1000     HISTFILESIZE=2000      * * * Following ash's answer, in a non-login (gnome-terminal) shell:               braiam@bt:~$ echo abacaba; echo $$     abacaba     15372     braiam@bt:~$       Then fired up another non-login shell:               braiam@bt:~$ strace -o e -s 256 -p 15372     Process 15372 attached - interrupt to quit      Went back to the first shell, then type `history -a`:               braiam@bt:~$ echo abacaba; echo $$     abacaba     15372     braiam@bt:~$ history -a     braiam@bt:~$       In the shell with strace, nothing:               braiam@bt:~$ strace -o e -s 256 -p 15372     Process 15372 attached - interrupt to quit           Here I was almost without hope, so I decided to look at strace manual and found that `-o` is to dump the result to a file, so `cat e` resturn this:               cat e     read(0, "\33", 1)                       = 1     read(0, "[", 1)                         = 1     read(0, "A", 1)                         = 1     rt_sigprocmask(SIG_BLOCK, [INT], [], 8) = 0     write(2, "history -w", 10)              = 10     rt_sigprocmask(SIG_SETMASK, [], NULL, 8) = 0     rt_sigprocmask(SIG_BLOCK, NULL, [], 8)  = 0     read(0, "\33", 1)                       = 1     read(0, "[", 1)                         = 1     read(0, "A", 1)                         = 1     rt_sigprocmask(SIG_BLOCK, [INT], [], 8) = 0     write(2, "\10a", 2)                     = 2     rt_sigprocmask(SIG_SETMASK, [], NULL, 8) = 0     rt_sigprocmask(SIG_BLOCK, NULL, [], 8)  = 0     read(0, "\r", 1)                        = 1     write(2, "\n", 1)                       = 1     rt_sigprocmask(SIG_BLOCK, [INT], [], 8) = 0     ioctl(0, SNDCTL_TMR_TIMEBASE or TCGETS, {B38400 opost isig -icanon -echo ...}) = 0     ioctl(0, SNDCTL_TMR_STOP or TCSETSW, {B38400 opost isig icanon echo ...}) = 0     ioctl(0, SNDCTL_TMR_TIMEBASE or TCGETS, {B38400 opost isig icanon echo ...}) = 0     rt_sigprocmask(SIG_SETMASK, [], NULL, 8) = 0     rt_sigaction(SIGINT, {0x80a0e30, [], 0}, {0x80e9d00, [], 0}, 8) = 0     rt_sigaction(SIGTERM, {SIG_IGN, [], 0}, {SIG_IGN, [], 0}, 8) = 0     rt_sigaction(SIGQUIT, {SIG_IGN, [], 0}, {SIG_IGN, [], 0}, 8) = 0     rt_sigaction(SIGALRM, {0x80a1080, [HUP INT ILL TRAP ABRT BUS FPE USR1 SEGV USR2 PIPE ALRM TERM XCPU XFSZ VTALRM SYS], 0}, {0x80e9d00, [], 0}, 8) = 0     rt_sigaction(SIGTSTP, {SIG_IGN, [], 0}, {SIG_IGN, [], 0}, 8) = 0     rt_sigaction(SIGTTOU, {SIG_IGN, [], 0}, {SIG_IGN, [], 0}, 8) = 0     rt_sigaction(SIGTTIN, {SIG_IGN, [], 0}, {SIG_IGN, [], 0}, 8) = 0     rt_sigaction(SIGWINCH, {0x80a09e0, [], 0}, {0x80e9550, [], SA_RESTART}, 8) = 0     rt_sigaction(SIGINT, {0x80a0e30, [], 0}, {0x80a0e30, [], 0}, 8) = 0     time(NULL)                              = 1378047084     stat64("/home/braiam/.bash_history", {st_mode=S_IFREG|0600, st_size=44, ...}) = 0     open("/home/braiam/.bash_history", O_WRONLY|O_APPEND|O_LARGEFILE) = 3     write(3, "history -w\nhistory -a\n", 22) = 22     close(3)                                = 0     rt_sigprocmask(SIG_BLOCK, NULL, [], 8)  = 0     rt_sigaction(SIGINT, {0x80a0e30, [], 0}, {0x80a0e30, [], 0}, 8) = 0     time(NULL)                              = 1378047084     rt_sigprocmask(SIG_BLOCK, [CHLD TSTP TTIN TTOU], [], 8) = 0     ioctl(255, TIOCSPGRP, [15372])          = 0     rt_sigprocmask(SIG_SETMASK, [], NULL, 8) = 0     rt_sigaction(SIGINT, {0x80a0e30, [], 0}, {0x80a0e30, [], 0}, 8) = 0     rt_sigprocmask(SIG_BLOCK, [INT], [], 8) = 0     ioctl(0, TIOCGWINSZ, {ws_row=24, ws_col=80, ws_xpixel=0, ws_ypixel=0}) = 0     ioctl(0, TIOCSWINSZ, {ws_row=24, ws_col=80, ws_xpixel=0, ws_ypixel=0}) = 0     ioctl(0, SNDCTL_TMR_TIMEBASE or TCGETS, {B38400 opost isig icanon echo ...}) = 0     ioctl(0, SNDCTL_TMR_TIMEBASE or TCGETS, {B38400 opost isig icanon echo ...}) = 0     ioctl(0, SNDCTL_TMR_STOP or TCSETSW, {B38400 opost isig -icanon -echo ...}) = 0     ioctl(0, SNDCTL_TMR_TIMEBASE or TCGETS, {B38400 opost isig -icanon -echo ...}) = 0     rt_sigprocmask(SIG_SETMASK, [], NULL, 8) = 0     rt_sigprocmask(SIG_BLOCK, [INT QUIT ALRM TERM TSTP TTIN TTOU], [], 8) = 0     rt_sigaction(SIGINT, {0x80e9d00, [], 0}, {0x80a0e30, [], 0}, 8) = 0     rt_sigaction(SIGTERM, {0x80e9d00, [], 0}, {SIG_IGN, [], 0}, 8) = 0     rt_sigaction(SIGTERM, {SIG_IGN, [], 0}, {0x80e9d00, [], 0}, 8) = 0     rt_sigaction(SIGQUIT, {0x80e9d00, [], 0}, {SIG_IGN, [], 0}, 8) = 0     rt_sigaction(SIGQUIT, {SIG_IGN, [], 0}, {0x80e9d00, [], 0}, 8) = 0     rt_sigaction(SIGALRM, {0x80e9d00, [], 0}, {0x80a1080, [HUP INT ILL TRAP ABRT BUS FPE USR1 SEGV USR2 PIPE ALRM TERM XCPU XFSZ VTALRM SYS], 0}, 8) = 0     rt_sigaction(SIGTSTP, {0x80e9d00, [], 0}, {SIG_IGN, [], 0}, 8) = 0     rt_sigaction(SIGTSTP, {SIG_IGN, [], 0}, {0x80e9d00, [], 0}, 8) = 0     rt_sigaction(SIGTTOU, {0x80e9d00, [], 0}, {SIG_IGN, [], 0}, 8) = 0     rt_sigaction(SIGTTOU, {SIG_IGN, [], 0}, {0x80e9d00, [], 0}, 8) = 0     rt_sigaction(SIGTTIN, {0x80e9d00, [], 0}, {SIG_IGN, [], 0}, 8) = 0     rt_sigaction(SIGTTIN, {SIG_IGN, [], 0}, {0x80e9d00, [], 0}, 8) = 0     rt_sigprocmask(SIG_SETMASK, [], NULL, 8) = 0     rt_sigaction(SIGWINCH, {0x80e9550, [], SA_RESTART}, {0x80a09e0, [], 0}, 8) = 0     rt_sigprocmask(SIG_BLOCK, [INT], [], 8) = 0     write(2, "\33]0;braiam@bt: ~\7\33[01;31mbraiam@bt\33[00m:\33[01;34m~\33[00m$ ", 56) = 56     rt_sigprocmask(SIG_SETMASK, [], NULL, 8) = 0     rt_sigprocmask(SIG_BLOCK, NULL, [], 8)  = 0     read(0,  <unfinished ...>      So, according to this, there is not problem. Then, I open another non-login shell, and no joy. The history isn't loaded. A `cat .bash_history` reveals that the file was indeed filled but the non-login shell doesn't take it. Now, I tried both `strace -o /tmp/e -s 512 bash` here (too long for character limit) and `strace -o /tmp/e -s 512 gnome-terminal` here (both from pastebin.com, sorry). Here with the original settings (minus the -w permission on .bash_history). I tried login next, Ctrl + Alt + F1, logged in, pressed the up arrow, crossed fingers and it worked! But, that still leave me with the interrogant, why doesn't the non-login shell loads the history?


title: Where is the fork() on the fork bomb :(){ :|: & };:?

text: **Warning: Running this command in most shells will result in a broken system that will need a forced shutdown to fix** I understand the recursive function `:(){ :|: & };:` and what it does. But I don't know where is the fork system call. I'm not sure, but I suspect in the pipe `|`.


title: How to disable USB autosuspend in Manjaro Linux?

text: How can I disable USB autosuspend in Manjaro Linux?


title: Change the name of a file that contains spaces in the name

text: I don't know why but when I go to change this file name with `mv` command it comes up with the error stating `not a directory`. `-bash-4.1# mv {{ THEME SANITIZED }}.hacks.css myomega.hacks.css`


title: What does CONFIG_IA32_AOUT do actually?

text: I'm running a 64bit kernel, already have `CONFIG_IA32_EMULATION` set, so do I still need `CONFIG_IA32_AOUT` enabled? From the help in `menuconfig`, I don't quite get it.


title: Are there more advanced LUKS key schemes, e.g. 2 of 3 keys needed?

text: It seems like the two main LUKS encryption options are:   1. USB keyfile (see http://superuser.com/questions/149578/how-can-i-use-a-keyfile-on-a-removable-usb-drive-for-my-encrypted-root-in-debian)   2. Typing in a password These both have weaknesses. The first can be overcome by stealing the USB drive. In the second case, a keylogger could be used, or I could be forced to give over the password. Would it be possible to create an encryption scheme that required both of the options? Then, if I was given an injuction to provide the password, I could destroy the USB drive (e.g. burn it on the stovetop); conversely, if someone stole my USB drive, they would need to get my password as well. It seems the existing LUKS key slot idea is that providing a key for _any_ key slot will unlock the device, not that one has to provide a key for _all_ , or say "2 of 3" key slots (iirc the latter can be accomplished in a cryptographically secure manner using a Galois field). (Also, I happen to be on an OpenSuSE system, so please keep answers distro- agnostic or something that can work on SuSE.)


title: Remove nth frames of a gif (remove a frame every n frames)

text: I've recorded a `.gif` of the screen with ffmpeg. I've used `gifsicle` and `imagemagick` to compress it a bit, but it's still to big. My intent is making it small by removing, say, a frame every 2 frames, so that the total count of frames will be halved. I couldn't find a way to do it, neither with `gifsicle` nor with `imagemagick`. `man` pages didn't help. **How can I remove a frame from a`.gif` animation every `n` frames?**


title: How to view full bounce message in mutt?

text: I got an error when sending email with mutt , some "red" text shows at the bottom of terminal , how should I view the full error message ? Is there a shortcut / macro that I could use / define ?


title: How to install gcc 4.8.1 on debian wheezy

text: I would like to install GCC 4.8.1 on my Debian Wheezy 7.1.0 system. The current version of GCC installed on my system is the 4.7.2. I see gcc-4.8.1 is available on the Debian repository. Can someone show me how to go about performing this update?


title: How to use traceroute command in unix

text: how to determine if the server is slow or not with `traceroute` unix command . Here is the `traceroute` Out put of a host IP .               traceroute 188.165.247.43     traceroute to 188.165.247.43 (188.165.247.43), 30 hops max, 60 byte packets      1  iPhone.local (172.20.10.1)  1.493 ms  2.546 ms  3.287 ms      2  * * *      3  10.52.141.50 (10.52.141.50)  782.228 ms  784.069 ms  786.188 ms      4  10.52.141.54 (10.52.141.54)  786.491 ms  786.510 ms  786.927 ms      5  10.52.92.237 (10.52.92.237)  787.157 ms  788.059 ms  788.001 ms      6  aircel-gprs-177.5.251.27.aircel.co.in (27.251.5.177)  787.140 ms  98.452 ms  100.978 ms      7  114.79.219.41 (114.79.219.41)  158.391 ms  161.252 ms  161.610 ms      8  abs-cn-61.194.148.202.aircel.co.in (202.148.194.61)  178.216 ms  175.575 ms  193.356 ms      9  114.79.196.185 (114.79.196.185)  197.859 ms  218.156 ms  220.694 ms     10  abs-cn-129.198.148.202.aircel.co.in (202.148.198.129)  221.497 ms  238.732 ms  157.212 ms     11  * * *     12  * * *     13  125.17.180.149 (125.17.180.149)  137.955 ms  157.563 ms  139.677 ms     14  AES-Static-137.36.144.59.airtel.in (59.144.36.137)  289.250 ms  310.797 ms  290.745 ms     15  * * *     16  * * *     17  * * *     18  * * *     19  * * *     20  * * *     21  * * *     22  * * *     23  * * *     24  * * *     25  * * *     26  * * *     27  * * *     28  * * *     29  * * *     30  * * *      is it possible to determine whether remote server is responding good or not by looking at the output ?


title: Trying to do arithmetic in Perl rename tool (Debian)

text: Supposed I have five mp3 files:               01-trackfoo.mp3     02-trackbar.mp3     03-trackbaz.mp3     04-trackabc.mp3     05-trackxyz.mp3      Now I give a quick listen to the files (just mplayer on console will do the trick) and I find out that the order is wrong. 05 is actually 02 and the rest will have to be renamed. So first I will do a temp rename:               01-trackfoo.mp3          02-trackbar.mp3     03-trackbaz.mp3     04-trackabc.mp3     00-trackxyz.mp3      Now we need a "shift": 02 should become 03, 03 should become 04 and 04 should become 05. To minimize confusion, ex-05 (now 00) will just be `mv`ed later. My approach was this: (perl `rename`, by Larry Wall, default here on Debian)               rename 's/0([2-4])([\s\S]+)/0($1+1)$2/' * as well as (later, after some more RTFM'ing)               rename 's/0([2-4])([\s\S]+)/0($1+1)$2/e' * None of them worked, especially because the `/e[val]` modifier does not accept anything else _but_ evaluations, and will throw an error once you attempt to combine the evaluations with strings. The `bash` can do it just fine, e. g. `foo$((1+6))` will be evaluated to `foo7`. So how can I do this (one-liner preferred, not intending to write a whole standalone script just for this)?


title: grub2 and cryptsetup

text: My root node is LUKS encrypted, and it uses a key file, instead of user input password to unlock it. I know in Grub2, I can use               insmod cryptodisk     insmod luks     cryptomount -u <uuid>      But I have no idea how to use a key file to unlock the disk.


title: Escaping characters when passing arguments to a command

text: I regularly record audio files using my Android phone to WAV files to the internal storage of my phone. I'd like to write a Bash script to pull the most recent recorded file from my phone and move it to my Desktop. Here's what I've got so far:               adb shell find /storage/sdcard0/Sound\ Recordings/ | tail -1 | while read file ; do         adb pull "$file" ~/Desktop/     done      However, this fails. It seems that ADB doesn't properly escape things and I get the following messages when trying to run the script:               ' does not existstorage/sdcard0/Sound Recordings/20120817T065953.wav      It seems to ignore the double quotes and everything basically breaks when it tries to run, as it presumably sees 3 arguments rather than two, something like this:               adb pull /storage/sdcard0/Sound Recordings/20120817T065953.wav ~/Desktop/      How can I adjust my script to insert backslashes into my `$file` variable where necessary? Is that the proper solution in this case?


title: How to update a content management installation by overwriting existing files via ssh and shell?

text: I have installed a cms (modx) on a webserver running CentOS 5 and Apache 2.2. Now there is a new version and I would like to update it. The instructions in the modx-wiki suggest to overwrite the existing files. I've downloaded a .zip-File and extracted it. The existing installation sits in `html/cms/`. The new files sit in `html/modx-2.1.1-pl/`. I access the server through an ssh connection. How do I move the new files to `html/cms/` while overwriting existing files and preserving files that are not part of the installation files? I already tried the `mv`-command and read that `rsync` or `cp` might be suitable. When I tried `mv -ivt cms/ modx-2.1.1-pl/*` it didn't work out. Subdirectories of `modx-2.1.1-pl/` haven't been moved. How to do it right?


title: How to check if $PWD is a subdirectory of a given path

text: E.g. check if `$PWD` is a subdirectory of /home. In other words I'm searching for a bash string operation to check if one string starts with another.


title: How to "jail" a process without being root?

text: Were I root, I could simply create a dummy user/group, set file permissions accordingly and execute the process as that user. However I am not, so is there any way to achieve this without being root?


title: Why doesn't build-dep work even when I have URIs in my sources list already?

text: So I tried to install a package called RGL for the R statistics language.               sudo apt-get build-dep r-cran-rgl     [sudo] password for user:      Reading package lists... Done     Building dependency tree            Reading state information... Done     E: You must put some 'source' URIs in your sources.list     sh: 0: getcwd() failed: No such file or directory      Now I would have regarded that as a totally valid objection, but I had already added extra deb lines to my sources.list, which looks like this:               cat /etc/apt/sources.list     #/etc/apt/sources.list     deb http://cran.ms.unimelb.edu.au/bin/linux/ubuntu raring/     #deb http://cran.cs.pu.edu.tw/bin/linux/ubuntu raring/      This is not exactly crucial, because I was able to get RGL installed by an alternate command, namely               sudo apt-get install libglu1-mesa-dev      so I don't need build-dep to work right now. But at some point in the future I will probably want to use build-dep syntax with apt-get.


title: Are there versions of Unix that don't have awk in default install?

text: Are there versions of Unix that don't have awk installed by default? I am fine with an answer containing some really old outdated Unix variant which predates awk's creation; but would ideally prefer some specialist niche stripped down embedded modern one which excludes awk by design from core install. (the impetus for asking: someone claimed that an SO answer using nothing but standard unix command line tools sans `awk` is useless, since every Unix has `awk`. I am pretty sure that last part is wrong, but don't recall any specific examples, just the fact that they exist).


title: How to redirect stderr,out to different files and also display in terminal?

text: To make it clear, I want to see the output of a command in the terminal as if there were no redirection. Also stderr need to be redirected to err.log and stdout need to be redirected to stdout.log. It would be also nice to have the exact copy of what is shown in terminal, i.e errors printed as and when it occurs in a seperate file stdouterr.log.


title: Enabling Compiz-Fusion in Fedora 19

text: I'm using Fedora 19 with Gnome Classic, and I have installed `compiz`, `compiz-manager`, `ccsm` and all required packages, but Compiz Fusion just doesn't work, that is it has no effect. I have tried to execute `compiz --replace` but it just destroys my desktop. What should I do in order to enable Compiz Fusion in Fedora 19 - Gnome Classic?


title: How to check corrupt and duplicated fonts on Linux?

text: I need to find software that can detect duplicate fonts out of a folder, and be able to tell if a font file is corrupted. Needs to be command line so I can script it for situations, although if you know of a GUI one that can take scripts or something of the sort that could possibly work as well.


title: Can edit file as root, but not using sudo

text: I just faced a really strange situation. I was trying to edit file `/usr/lib/thunderbird/thunderbird.sh`, which has the following permissions:               $ ll /usr/lib/thunderbird/thunderbird.sh     -rwxr-xr-x 1 root root 2730 Aug 20 12:55 /usr/lib/thunderbird/thunderbird.sh*      and I found that if I issue               sudo vim /usr/lib/thunderbird/thunderbird.sh      When I switch to insert mode I get a warning message:               /usr/lib/thunderbird/thunderbird.sh [RO]     W10: Warning: Changing a readonly file     -- INSERT --      And I actually cannot write any changes. However, if I issue:               user@hostname:~$ sudo su -     root@hostname:~# vim /usr/lib/thunderbird/thunderbird.sh      I can edit the file without problems. The strange thing is that I have edited lots of files with similar permissions, such as the configuration files in `/etc/`, without issues, and that If I create a file inside the same directory I have no problems editing it:               user@hostname:~$ sudo touch /usr/lib/thunderbird/test.sh     user@hostname:~$ sudo chmod 755 /usr/lib/thunderbird/test.sh     user@hostname:~$ ll /usr/lib/thunderbird/test.sh /usr/lib/thunderbird/thunderbird.sh     -rwxr-xr-x 1 root root    0 Aug 20 13:03 /usr/lib/thunderbird/test.sh*     -rwxr-xr-x 1 root root 2730 Aug 20 12:55 /usr/lib/thunderbird/thunderbird.sh*     user@hostname:~$ sudo vim /usr/lib/thunderbird/test.sh      This is my sudoers file:               # Cmnd alias specification     Cmnd_Alias  APT = /usr/bin/apt-get update, /usr/bin/apt-get upgrade          # User privilege specification     root    ALL=(ALL:ALL) ALL           # Members of the admin group may gain root privileges     %admin ALL=(ALL) ALL           # Allow members of group sudo to execute any command     %sudo   ALL=(ALL:ALL) ALL      %sudo   ALL=(ALL:ALL) NOPASSWD: APT      And my user is inside sudo group. Any idea about why this happens?


title: Flash running in Chromium and FF at once, why no sound in the second browser?

text: I work as a student assistant Linux admin and I just packaged up Adobe's "Square" plugin to get 64bit FF running flash pretty well (first time I've seen it work this well), but there's one little problem I've come across thus far: if you open one browser and start using flash the second browser will not be able to output sound. I realize this is probably because of what sound driver is being used but is there any good way to fix this or is this just how it is for Flash being the bane of my existence? Thanks for any help!


title: Limiting a specific shell's internet bandwidth usage

text: I want update my linux in one shell but by default wget or axel in updater use all the bandwidth. How can I limit the speed in this shell? I want other shells to have a fair share, and to limit everything in that shell - something like a proxy! I use Zsh and Arch Linux.


title: Launch terminal in su mode XFCE

text: I want to set up a launcher for my terminal in XFCE that automatically prompts for the su password, in gnome my shortcut was:               gnome-terminal --command="su -" --geometry=180x40+400+80      How do I configure the XFCE shortcut for that? the current properties are:               exo-open --launch TerminalEmulator


title: Qemu doesn't boot kernel after “Uncompressing Linux… done, booting the kernel. ”

text: I've compiled qemu for s5pc110 (it's from http://gitorious.org/samsung-linux- platform/qemu, somebody had added support for s5pc110), version 0.12. But when I load the kernel:               qemu-system-arm -M s5pc110 \      -kernel ../../kernel/android-samsung-2.6.35-gingerbread/arch/arm/boot/zImage \      -initrd arm_root.img -serial stdio -append earlyprintk       the terminal prints "Uncompressing Linux... done, booting the kernel." and nothing. The vlc windows also have nothing. When I debug with gdb, I find it doesn't execute `start_kernel`.   What's the problem? Is qemu for s5pc110 wrong or kernel? And I could't set breakpoints at head.S, decompress_kernel also couldn't. Why? BTW, if I use `-nographic`, I could't interrupt the shell but kill the terminal, the `CTRL+a x` doesn't help. Also I want to know how to let whole kernel start log print in the current terminal with qemu? Which option of qemu can do this? Could anyone please tell me what I'm doing wrong?


title: Library routines in linux kernel

text: In the linux kernel, there is a section "Library routines" with a snippet shown below:               Library routines  --->       <M> CRC-CCITT functions       <M> CRC ITU-T V.41 functions       <M> CRC7 functions       <M> CRC32c (Castagnoli, et al) Cyclic Redundancy-Check       <M> CRC8 function       ...       ...      I have most of the options compiled in as "module", but these modules never get loaded. I'm curious to know what these modules are used for and in which situation I would need them? The Kernel Config help is not very illuminating:               This option is provided for the case where no in-kernel-tree     modules require <XYZ> functions, but a module built outside     the kernel tree does. Such modules that use library  <XYZ>     functions require M here.


title: Webserver-User has no Shell-Access but needs SSH-Keys or Permission change of directory?

text: First of all: English is NOT my mother-tongue, so please bear with me if something is not as clean as it should be. So, regarding my previous question and a possible solution I was advised to ask for another solution in a new question. (Here is the old thread: SSH Agent-Forwarding works, but what about sudo -u username no shell/ permissions? composer) So, for the sake of simplicity let's assume I only have two users on my server (apart from root). One user (let's call him Nal) is a part-time admin, meaning he is in the sudoers list. The other user is used for sftp (as in, ftp over ssh ;)) and managing one site on the webserver located at /srv/web (let's call this user Web). Web has no other work to do than managing this site, so he has no Shell-access (set to bin/false) and no special privileges. Now the directory in /srv/web/websiteA is owned by Web and in there I have a Laravel (PHP Framework) installation that also leverages Composer (PHP dependency manager, basically replaced PEAR). I have some packages in semi-development that are not ready for the masses, hence laying in a private Repository. To access this repository and clone the contents via git (all done automatically with composer!) "Web" needs an SSH- Key. Instead of managing the same set of SSH-Keys on my local machine and the server, I just pass them through by SSH-Agent-Forwarding. This works great for "Nal". He has access to my private repositories. But when I want to do a composer update in /srv/web/websiteA I have to do it with "Web" and he has no shell-access and no ssh-keys, so the update fails. My current workaround is this: Logged in as Nal I do:               cd /srv/web/websiteA          setfacl -R -m u:Web:rwx "${SSH_AUTH_SOCK%/*}"     sudo -u Web SSH_AUTH_SOCK="$SSH_AUTH_SOCK" composer update     setfacl -b "${SSH_AUTH_SOCK%/*}"      So I set the permission of the Socket where the SSH-Keys are given over to Nal so that Web can access them, then I do my update and then I revoke the permissions again. This is working, but probably not the best solution. I don't want to set the permissions of /srv/web/websiteA to 775 or something like that (and add Nal to the www-data group) so I ask here: Is there any better solution you can come up with?


title: SSH public key won't send to server

text: I've been struggling with this for a couple hours so any help is greatly appreciated... I have 2x servers both of which I can `ssh` to with public keys from OSX, no issues at all there so I'm certain everything is good with `sshd_config`. I'm trying to configure a cron job for `rsync` to sync the two servers and need server B (backup) to `ssh` into server A using a public key. I cannot for the life of me work out why it doesn't find my public keys - they are in `~/.ssh/` (ie. `/root/.ssh`) and all file permissions are correct on A & B. This is the output:               debug2: we did not send a packet, disable method     debug3: authmethod_lookup publickey     debug3: remaining preferred: keyboard-interactive,password     debug3: authmethod_is_enabled publickey     debug1: Next authentication method: publickey     debug1: Trying private key: /root/.ssh/identity     debug3: no such identity: /root/.ssh/identity     debug1: Trying private key: /root/.ssh/id_rsa     debug3: no such identity: /root/.ssh/id_rsa     debug1: Trying private key: /root/.ssh/id_dsa     debug3: no such identity: /root/.ssh/id_dsa     debug2: we did not send a packet, disable method     debug3: authmethod_lookup password     debug3: remaining preferred: ,password     debug3: authmethod_is_enabled password     debug1: Next authentication method: password      Also note it is looking for private keys which don't exist...               drwx------. 2 root root 4096 May 25 10:15 .     dr-xr-x---. 4 root root 4096 May 24 18:52 ..     -rw-------. 1 root root  403 May 25 01:37 authorized_keys     -rw-------. 1 root root    0 May 25 01:41 config     -rw-------. 1 root root 1675 May 25 02:35 id_rsa_tm1     -rw-------. 1 root root  405 May 25 02:35 id_rsa_tm1.pub     -rw-------. 1 root root  395 May 25 02:36 known_hosts


title: Library for audio effects and modulation?

text: I'm building a site which will have multiple audio lectures uploaded, as it's mainly a feed for a certain person's lectures. What's annoying is that there are many things which can go wrong during recording, inevitable things.   * Someone slams their fist on the table: giant BANG at +5DB in the recording.   * Microphone placement (ie: an iPhone with a nice Blue mic) isn't great.   * The speaker's volume will change, sometimes dramatically.    * Background noise is found throughout the recording. In audio mixing and mastering, I'd essentially just apply the following effects/modulations on the input files after finding some reasonable settings:   1. A noise gate, which eliminates or lessens background noise which has an amplitude of less than X (ie: -24DB).   2. A compressor, to account for bangs and for changes in volume. While still allowing for some variation in amplitude, it will dramatically smooth out everything in what we determine to be speaking range. This can also be used to account for a bad recording, boosting weak audio.   3. A lo-pass/hi-pass filter, which will effectively remove frequencies not producible by a human. I was wondering if a Linux library for this exists in the form of a command- line client. I know how to use FFMPEG to convert audio/video formats, but I'm not sure that it offers this functionality. Alternatively, though I know that this isn't a programming site, I'd be happy writing something in Python or another language which would give me the result I'm looking for.


title: how to update Records using nsupdate?

text: We know that we can update a record (its IP) by doing this steps:               nsupdate     server ns.bar44.com     zone bar44.com     update delete somehost.bar44.com. A     update add somehost.bar44.com. 86400 A 10.10.10.1     show     send      1. as we can see we know that the somehost.bar44.com. is exist in the DB, this will work if I want to update the IP of an existing Record but what if I want to change the hostname not the IP, for example I want to make 10.10.10.1 the IP of somehost22.bar44.com. what will let me know that IP is already taken by somehost.bar44.com.?   2. Is this a way to delete the whole DB of a certain zone using nsupdate?


title: How to code for non-repeating authentication strings

text: In THC Hydra, when you put the URL, form parameters, and condition (authentication) string: `<URL>:<form parameters>:<condition strings>` If you want Hydra to stop when it's successful you put `S=`   If you want it to stop when it fails, you put `F=` The only explanations/tutorials I can find explain how to code in a repeating condition (authentication) string, i.e. Successful Login `S=Successful Login` What I need to know is how to code for a non-repeating condition (authentication) string, i.e. authlink= my attempt: `S=authlink=-x 6:6:aA1`


title: Why doesn't this unexpand seem to work?

text: It's my understanding that `unexpand` can replace multiple spaces with tabs. I have a file, `x.x` with contents               1  2   3  4 5      and I type `expand x.x` but the output is still               1  2   3  4 5      and doesn't seem to now have tabs. What am I missing? Similarly `expand x.x -t20` still seems to give the same output


title: How to set password for users in AIX using single line command?

text: ![enter image description here](http://i.stack.imgur.com/02NKu.png)Is there any way in which I can set the password for a newly created user account in AIX in a one line command? I don't want to give any prompt to the user. If there is a command, it should set the password to that user without asking anything on the screen. I need to use that command in another technology like Java/.Net. I need to create the accounts with password on a AIX machine at run time by executing one line of code where I can pass parameters. Suppose a user is giving a username in the text box of a Java application and in the background the command needs to be executed which will create the user accounts(with the password) at a remote AIX server. I am successful to add a user account, but setting the password is something where I am stuck.


title: Mapping custom shortcuts in MATE (Gnome)

text: I am used to Ratpoison, but now I have to work with MATE (Gnome) for a while. To make it less painful, I would like to use some keyshortcuts from Ratpoison. Is there any simple way to do it? How exactly should shortcuts work?   * `Alt + [1-9]` to change workspaces   * `SUPER + [a-z]` to exec mapped application (for example `SUPER + f` to run Firefox)   * `SUPER + SUPER` to fast switch of windows I know there is "Keyboard Shortcuts" in "Control center". But with SUPER it doesn't work well (still opening start menu). And I don't like to break my fingers...


title: Number of cores on FreeBSD

text: What would the equivalent of Debian's `nproc` be in FreeBSD? I'm trying to include this in a bash script variable so if it could just print out the number of cores that would be fantastic.


title: Mount an existing RAID 1 Logical Volume after OS upgrade

text: I just upgraded from Ubuntu 10.04 to Mint 16. The installer did not detect my existing RAID 1 array, and I can't access it anymore. My drives are:               SDA - First RAID Disk     SDB - Second RAID Disk     SDC - Non-RAID where the OS is installed.      The disks are full of stuff I want to keep, so I don't want to create a new RAID. On the old machine, the two raid drives became MD0, which was a physical disk for Logical Volume Management. How do I put the two halves together and get it to mount at boot? (I know how to mount single drives and how to add fstab entries for single drives, but the part I don't know is how to mount the two drives as one disk as a RAID.


title: Imagemagick: set IPTC parameters in jpeg image

text: With the Imagemagick command               $ identify -verbose image.jpg      so many properties of the image are shown. For example, in the output I can find               Profiles:     Profile-8bim: 1058 bytes     Profile-iptc: 1017 bytes       Image Name[2,5]: 01-00241624000002h       Credit[2,110]: owner       Caption[2,120]: some description      But how to set those parameters? In particular, I would like to set the `Caption[2,120]` parameters to substitute the text `some description` with other words. Is it possible?


title: Can I disable all man pages?

text: Specifically on a raspberry pi (running Raspbian Wheezy), but also in general, can I disable all man pages? This would mean no stored man pages, no "processing triggers for man-db", and so on and so forth. With the manual pages always available on the internet, I don't really need them installed, and generating and storing them seems unnecessary.


title: Why is my find not recursive?

text: I am running the following command, but it is not performed recursively:               find . -name *.java      I know there are java files further down in the current directory but it is performing the `find` on the current directory only. I am using OS X, 10.9.


title: Segmentation Fault on execution

text: I am getting this segmentation fault (core dumped) error on excecuting my c++ program on Centos. I am compiling my code using g++. Everything was executing fine for hours. Suddenly, on executing the same executable I got the segmentation fault error. I did strace -eopen executable and got this:               open("/usr/local/lib/tls/i686/sse2/libcrafter.so.0", O_RDONLY) = -1 ENOENT (No such file or directory)     open("/usr/local/lib/tls/i686/libcrafter.so.0", O_RDONLY) = -1 ENOENT (No such file or directory)     open("/usr/local/lib/tls/sse2/libcrafter.so.0", O_RDONLY) = -1 ENOENT (No such file or directory)     open("/usr/local/lib/tls/libcrafter.so.0", O_RDONLY) = -1 ENOENT (No such file or directory)     open("/usr/local/lib/i686/sse2/libcrafter.so.0", O_RDONLY) = -1 ENOENT (No such file or directory)     open("/usr/local/lib/i686/libcrafter.so.0", O_RDONLY) = -1 ENOENT (No such file or directory)     open("/usr/local/lib/sse2/libcrafter.so.0", O_RDONLY) = -1 ENOENT (No such file or directory)     open("/usr/local/lib/libcrafter.so.0", O_RDONLY) = 3     open("/usr/local/lib/libstdc++.so.6", O_RDONLY) = 3     open("/usr/local/lib/libm.so.6", O_RDONLY) = -1 ENOENT (No such file or directory)     open("/etc/ld.so.cache", O_RDONLY)      = 3     open("/lib/libm.so.6", O_RDONLY)        = 3     open("/usr/local/lib/libgcc_s.so.1", O_RDONLY) = 3      Please tell me what to do and explain the solution in detail as I am new to Linux


title: SFTP Modification time Permission denied when touching/updating files

text: The file is apache:apache 660 and username is jdoe and he belongs to groups jdoe and apache. He SFTPs into the server with WinSCP but when he goes to perform an edit which includes a set modtime command he gets "sent status permission denied" in the syslog. The file is on an NFS mount (v4) which is mounted rw on this server. How do I deal with this issue in SFTP, RHEL 6?


title: Apply given rsync exclude patterns on given directory

text: I have a setup where I use `rsync` to mirror some _source_ directory to a (remote) _destination_ except for some files and locations defined witch rsync exclude patterns:               # Useless files     - thumbs.db     - *.~     - *.tmp     - /*/.cache     - /*/.local/share/trash     # Already rsynced somewhere     - .dropbox     # Medias files     - *.avi     - *.mkv     - *.wav     - *.mp3     - *.bmp     - *.jpg     # System files     - /hiberfil.sys     - /pagefile.sys      This script runs on Windows and Linux stations and uses the `\--delete` parameter to _delete extraneous files from dest dirs_. The thing is, when I "update" the exclude patterns (eg. add an exclusion pattern for Ogg files: `*.ogg`) I have to re-run the rsync to remove any existing Ogg file from the destination. I was wondering if I could easily apply the exclude rules (some can be complex because it uses wildcards) on a given directory so that I don't have to re-run the rsync from the source to clean my destination directory. So far I've come to the following which deletes files and directories using basename matching:               dirToClean="/var/somedir"     excludeFile="file_to_exclude"          # Delete files and dir of $dirToClean whose basename matches an exclude pattern from $excludeFile     for fileToDelete in $(grep --extended-regexp "^- .*" $excludeFile | sed 's/^- \(.*\)$/\1/'); do         find "$dirToClean" -iname "$fileToDelete" -exec rm {} \;     done      Maybe I could run rsync using the same directory as source and destination?


title: Redirecting Multiple Commands as Input

text: What is the correct way to redirect the output of multiple commands as input for another command? e.g.               $ command < (command2 | grep pattern)


title: Get text-file word occurrence count of all words & print output sorted

text: I had a command which would work through a text file, count all the occurrences of the words and print it out like this:               remy@box $˜ magic-command-i-forgot | with grep | and awk | sort ./textfile.txt     66: the     54: and     32: I     16: unix     12: bash     5:  internet     3:  sh     1: GNU/Linux      So it does not search line-by-line, but word by word, and it does it for all the words, not just for 1 word. I'd found it somewhere on the internets a long time ago, but I cannot find or remember it..


title: Using ip addr instead of ifconfig reports "RTNETLINK answers: File exists" on Debian

text: I have a Debian system working as a wireless router with `eth0` and `wlan0`. Now I added an additional network manually on `eth1` with `ifconfig`:               alix:~# ifconfig eth1 192.168.0.2 netmask 255.255.255.0     alix:~# netstat -rn     Kernel IP routing table     Destination     Gateway         Genmask         Flags   MSS Window  irtt Iface     0.0.0.0         192.168.2.1     0.0.0.0         UG        0 0          0 eth0     192.168.0.0     0.0.0.0         255.255.255.0   U         0 0          0 eth1     192.168.2.0     0.0.0.0         255.255.255.0   U         0 0          0 eth0     192.168.3.0     0.0.0.0         255.255.255.0   U         0 0          0 wlan0     alix:~# ping 192.168.0.254     PING 192.168.0.254 (192.168.0.254) 56(84) bytes of data.     64 bytes from 192.168.0.254: icmp_req=1 ttl=64 time=0.537 ms     64 bytes from 192.168.0.254: icmp_req=2 ttl=64 time=0.199 ms     64 bytes from 192.168.0.254: icmp_req=3 ttl=64 time=0.188 ms     ^C     --- 192.168.0.254 ping statistics ---     3 packets transmitted, 3 received, 0% packet loss, time 2005ms     rtt min/avg/max/mdev = 0.188/0.308/0.537/0.161 ms      Everything works fine as you can see. Now I would like to make the configuration permanent. Therefor I added the following section to `/etc/network/interfaces`:               alix:~# sed -n '/iface eth1/,/^$/p' /etc/network/interfaces     iface eth1 inet static       address 192.168.0.2       netmask 255.255.255.0      But when I try to start the network I get the following error:               alix:~# ifconfig eth1 down     alix:~# ifup -v eth1     Configuring interface eth1=eth1 (inet)     run-parts --verbose /etc/network/if-pre-up.d     run-parts: executing /etc/network/if-pre-up.d/hostapd     ip addr add 192.168.0.2/255.255.255.0 broadcast 192.168.0.255     dev eth1 label eth1     RTNETLINK answers: File exists     Failed to bring up eth1.      When I run the `ip` command manually I get the same error:               alix:~# ip addr add 192.168.0.2/255.255.255.0 broadcast 192.168.0.255     dev eth1 label eth1     RTNETLINK answers: File exists      What is wrong with the command? And how can I tell Debian to do the right thing?


title: "nohup sudo ..." does not prompt for passwd and does nothing

text: When I run               nohup sudo myscript.sh &      I only get something like               [1] 1220      in return and do not get prompted for a password. The process does not start either. I want to run this script in the background and it needs to be run under sudo. Anybody guess what I am doing wrong? Using OSX Mountain Lion (Darwin).


title: Adding a second user to a system group?

text: I am trying to get around a permission issue I am having. The only reasonable option (other than ACL) is to add the user that needs access to the system group of the user that has access. Yes, the user that has access was birthed as a system user. Lets assume the GID is 121 and the needy user is `dog`. When I `sudo usermod -aG 121 dog` it says `121 isn't a group` or something of the like; the `ls -al` CLEARLY shows that the GID of the directory is 121. Is this method not possible or am I encountering some interesting problem?


title: How to convert a VOB file to avi?

text: I am trying to convert a VOB file copied from a DVD into an avi in Ubuntu 13.10. I tried `dvdrip`, which failed due to a frame count error or something. I tried acidrip as well, but it always choose an audio track I did not want to use. I would prefer to have a command line solution to create an avi with the following features:   * usable with mplayer (i.e. using the step functions)   * with the subtitle as required (or no one at all)   * with the correct audio track   * with video and audio in sync I tried some `ffmpeg` and `avconv` commands and managed to create an avi, but the video and audio were completly out of sync. So what options should I use to have the VOB file converted to an avi file? **I would appreciate some explanations on the suggested options!** Additional information:   1. The `ffmpeg` command gives the following output for the input file              Input #0, mpeg, from 'Videos/Test/VIDEO_TS/VTS_01_1.VOB':       Duration: 00:04:53.32, start: 0.045500, bitrate: 29284 kb/s         Stream #0.0[0x1e0]: Video: mpeg2video (Main), yuv420p, 720x480 [PAR 8:9 DAR 4:3], 7500 kb/s, 27.68 fps, 59.94 tbr, 90k tbn, 59.94 tbc         Stream #0.1[0x82]: Audio: ac3, 48000 Hz, 5.1, s16, 384 kb/s         Stream #0.2[0x80]: Audio: ac3, 48000 Hz, 5.1, s16, 448 kb/s         Stream #0.3[0x81]: Audio: ac3, 0 channels     [buffer @ 0x15ca6e0] w:720 h:480 pixfmt:yuv420p        2. The following command              ffmpeg -i Videos/Test/VIDEO_TS/VTS_01_1.VOB -ss 589 -t 274 -sameq -acodec copy -ab 320k output.avi      for example resulted in a crash of my Ubuntu session.   3. The following command               avconv -i Videos/Test/VIDEO_TS/VTS_01_1.VOB -acodec copy -vcodec copy output.avi      for example resulted in the following error:              Application provided invalid, non monotonically increasing dts to muxer in stream 1: 374 >= 374     av_interleaved_write_frame(): Invalid argument        4. The following command               avconv -i Videos/Test/VIDEO_TS/VTS_01_1.VOB -f avi -c:v mpeg4 -b:v 800k -g 300 -bf 2 -c:a libmp3lame -b:a 128k output.avi      for example resulted in the following error:              Error while opening encoder for output stream #0:1 - maybe incorrect parameters such as bit_rate, rate, width or height        5. The following command               avconv -i Videos/Test/VIDEO_TS/VTS_01_1.VOB -f avi -c:v mpeg4 -b:v 800k -g 300 -bf 2 -c:a ac3 -b:a 128k output.avi      for example seemed to work for some frames. But very soon I encountered many errors of the form              [ac3 @ 0x120d480] frame sync error     Error while decoding stream #0:1     frame CRC mismatch        6. The following command               mencoder Videos/Test/VIDEO_TS/VTS_01_1.VOB -oac copy -ovc x264 -x264encopts bitrate=2500 -o output.avi      did some converting, but is (i) using subtitles although I did not want to use them (ii) got the audio wrong (audio and video is terribly misplaced) and (iii) seems to be slower than the movie actually goes (might take 2 hours for a 90 minute movie).   7. I tried to command given here (third post from Xeratul), but it stopped with the error              FATAL: Cannot initialize video driver.        8. I tried the suggestion made below to look at the mencoder page. This page suggests to use two passes: _the first reads informations about the movie, the second uses that information to encode._ but neither it is explained _which_ information to extract nor _how_ to use them in the second pass. So I used the following command:              mencoder Videos/Test/VIDEO_TS/VTS_01_1.VOB -nosound -ovc x264 \     -x264encopts direct=auto:pass=2:bitrate=900:frameref=5:bframes=1:\     me=umh:partitions=all:trellis=1:qp_step=4:qcomp=0.7:direct_pred=auto:keyint=300 \     -vf scale=-1:-10,harddup -o video.avi      which did convert the video, but with an unwanted subtitle. It is not clear at all how I can avoid using a subtitle.


title: Can't install pg gem

text: I cant get the `pg gem` to install. I have tried `\--with-pg_config` and it didnt work.               Gem::Installer::ExtensionBuildError: ERROR: Failed to build gem native extension.                  /usr/local/rvm/rubies/ruby-1.9.3-p194/bin/ruby extconf.rb      checking for pg_config... no     No pg_config... trying anyway. If building fails, please try again with      --with-pg-config=/path/to/pg_config     checking for libpq-fe.h... no     Can't find the 'libpq-fe.h header     *** extconf.rb failed ***     Could not create Makefile due to some reason, probably lack of     necessary libraries and/or headers.  Check the mkmf.log file for more     details.  You may need configuration options.


title: inode limitation on a 500GB hard disk? Can you explain please?

text: I am launching a social networking website on LAMP Stack on Linux Ubuntu, I know that people are going to upload lots of pictures. Let's say I have 5000 users and each user upload a minimum of 100 pictures which is 500,000 pictures. I do have other files on the disk such as my web template images and etc. Under my public www, I might have approximately 1 million files or more. Do Linux filesystems support that many files? What are the limitations and how to overcome them? Can anyone please explain what limits on the number of files there are in Linux in plain English?


title: How to rip a DVD to a format like ogm/mkv

text: I'm trying to convert a DVD to some reasonable format. I'm not opposed to 1:1 conversion, but I want to at least change the container to ogm/mkv. I have already tried various GUI tools like dvd::rip or ogmrip, but they all fail after a while of converting. And my manual converting attempts using ffmpeg just fail gloriously (the quality is appalling).


title: ZSH: `ls *(.)` lists regular files only but `ls *(/)` does not list directories only

text: I'm not sure I am using ZSH's globbing correctly, but I thought `ls *(/)` would just list the dirctories under `pwd`, but it doesn't, it recursively lists all files under every directory under `pwd` (I got the statement from this list of useful zsh tips) What would be right globbing for exclusively listing the directories under my current path?


title: Github adding a repository as a fork from an existing clone

text: So I have a git repository that I cloned from an upstream source on ghithub. I made a few changes to to it (that are uncommitted and in the master branch). What I want to do is push my changes onto my github page as a new branch and have github still see it as a fork. Is that possible? I'm fairly new to git and github. Did my question even make sense? The easiest way that I can think of (which I'm sure is the most aroundabout way), is to fork the repo on github. Clone it locally to a different directory. Add the upstream origin repo. Create a branch in that new forked repo. Copy my code changes by hand into the new local repo. And then push it back up to my github. Is this a common use case that there's a simpler way of doing it without duplicating directories? I guess I'm asking here as opposed to SO since I'm on linux using command line git and the people here give better answers imo =]


title: How would one  detect if external command exists in a script?

text: Is there a way to detect if an external command exists (i.e. wget, svn)? More specifically today, i was trying to run one of my scripts i wrote and the person didn't have `wget` or svn installed. The script just downloads a file extracts it or uses svn to export the trunk.


title: How to run a bootloader from Linux?

text: I want to reboot from Linux to another system (a bootable CD for my current need).   I don't want to modifiy the current bootloader, nor to modify BIOS settings. Some Linux CD can be run from Windows (Windows stops and the Linux is runned from the CD).   How can I do the same thing from Linux ?


title: Copy a line matching pattern to beside another matching pattern line using sed

text: I want to copy the line containing `www.website.com` into the line containing `thetext`. For example, I want to transform this input:               Lorem ipsum dolor sit amet, elit.     Cras eu www.website.com velit vitae     Pellentesque interdum     thetext     Sed ullamcorper tellus      into this output:               Lorem ipsum dolor sit amet, elit.     Cras eu www.website.com velit vitae     Pellentesque interdum     thetextCras eu www.website.com velit vitae     Sed ullamcorper tellus      I have no idea how to copy-paste using `sed`. It looks somewhat tricky.


title: need explainations on this network route

text: I'd like to get some insight as to how I can possibly access network devices that are on a different IP range ( _obviously not mine_ ) compared to what is configured on my wifi router? **setup**   * home wifi connection on private network (192.168.1.x)    * wireless router   * setup to be on 192.168.1.1 / 255.255.255.0    * DHCP enabled only   * connected to our own secured wifi network    * all our devices and computers are on the 192.168.1.x network    * router logs dont show any 192.168.2.x IPs (DHCP leases & wifi logs only show our devices IPs) `$ traceroute 192.168.2.69`               traceroute to 192.168.2.69 (192.168.2.69), 30 hops max, 60 byte packets     1 RT-G32 (192.168.1.1)  1.240 ms  1.375 ms  1.589 ms     2 10.17.64.1 (10.17.64.1)  10.396 ms  10.400 ms  10.372 ms     3 192.168.100.13 (192.168.100.13)  14.912 ms  16.572 ms  16.487 ms     4 192.168.2.69 (192.168.2.69)  13.146 ms  13.127 ms  14.658 ms          $ traceroute  192.168.2.90          traceroute to 192.168.2.90 (192.168.2.90), 30 hops max, 60 byte packets     1  RT-G32 (192.168.1.1)  1.466 ms  1.418 ms  1.551 ms     2  10.17.64.1 (10.17.64.1)  11.025 ms  11.005 ms  10.975 ms     3  192.168.100.13 (192.168.100.13)  10.958 ms  15.729 ms  15.715 ms     4  192.168.2.90 (192.168.2.90)  15.640 ms  15.561 ms  15.532 ms      I'm puzzled as to where the `10.17.64.1` comes from.. it seems to be a gateway of some sort, but _how come_ I can access it from my network?!


title: Sorting files according to size recursively

text: how to scan a folder recursively and find the largest files in the folder, and sort them by size. I have tried using `ls -R -S` but it tends to list the directories as well I need to scan the folders and print the files in the folder and sub folders in sorted manner. I tried using `find` but coudn't find a suitable solution.


title: Disable random memory address generation in my programs

text: I'm reading "The art of exploitation" and would like to try some experiments, including reading from and writing to various memory address. I've created some simple programs and trying to overwrite their variables via various hacks, the problem is that these variables' addresses keep changing every time I run the program, making all this extremely complicated.   I know this is for security reasons but I'm wondering if is it possible to disable it for learning purposes. Here's my system's and gcc's info:               blackbear@blackbear-laptop:~$ uname -a     Linux blackbear-laptop 2.6.32-30-generic #59-Ubuntu SMP Tue Mar 1 21:30:21 UTC 2011 i686 GNU/Linux     blackbear@blackbear-laptop:~$ gcc --version     gcc (Ubuntu 4.4.3-4ubuntu5) 4.4.3     Copyright (C) 2009 Free Software Foundation, Inc.     This is free software; see the source for copying conditions.  There is NO     warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.          blackbear@blackbear-laptop:~$


title: What is the best book to learn Linux system programming?

text: Title says it all. I am trying to learn Linux system programming, which is the best book to learn this?


title: What is the difference between 32-bit PAE and 64-bit kernels?

text: I ask this only in regards to memory addressing. I know that a PAE kernel allows the OS to access more memory than a standard 32-bit kernel, however, what are the other implications? What specific differences are there between a 64-bit kernel and a 32-bit PAE kernel? According to Wikipedia, a processes address space remains at 32-bits, meaning it can only access a maximum of 4GB of memory. The OS however can access a 64GB address space, allocating 4GB chunks to processes. To me it seems like this is a big distinction that seems to be ignored by many people.


title: Where is the dhclient.conf under Fedora 14?

text: I wanted to put this in the dhclient.conf file: supersede domain-name "foo.org foo2.org"; but there is no dhclient.conf file...where is it? (Fedora14/GNOME)


title: Change font color and shadow from titlebar in window manager

text: I'm trying Linux Mint Debian Edition XFCE, and want to use a specific theme; only drawback - the font color and font shadow are unreadable, how can I change them? Also the active/inactive color window separation is very hard to distinguish. I added a screenshot for demonstration. ![enter image description here](http://i.stack.imgur.com/XkCek.png) (seems that stackexchange doesn't zooms in the image when clicking, so you have to use the "right-click>view image" option, I apologize)