Strange behavior in $(dirname `readlink -f $0`)

When I run the following as a normal user, everything is fine:               $(dirname `readlink -f $0`)      but after I switched to root, the following error occurred:               readlink: invalid option -- 'b'     Try `readlink --help' for more information.     dirname: missing operand     Try `dirname --help' for more information.      Any ideas? I tried on local Fedora 16 and Amazon EC2, both running bash shell. edit for illustration. apologze that I did not further illustrate the issue here. here is the scenario: using normal user account:               $ pwd      /home/myuser      $ export MY_DIR=$(dirname `readlink -f $0`)      $ echo MY_DIR      /home/myuser      using root:               # pwd     /root     # export ROOT_DIR=$(dirname `readlink -f $0`)     readlink: invalid option -- 'b'     Try `readlink --help' for more information.     dirname: missing operand     Try `dirname --help' for more information.          # export ROOT_DIR=echo $(dirname `readlink -f -- $0`)     # echo $ROOT_DIR     /root


libfaketime and Mac OS, LD_PRELOAD

Running Mac OS 10.7.2 and trying to run libfaketime and nothing happen. I installed and ran exactly as directed only the time and date stay exactly as are set in the system? Is anyone else able to successfully run this on OSX?               $ date     Mon Jan 30 21:05:09 CST 2012     $ LD_PRELOAD=./libfaketime.so.1 FAKETIME="-15d" date     Mon Jan 30 21:05:32 CST 2012


Sed not giving the first occurence of pattern

cat file contains                inet addr:192.168.154.102 Bcast:192.168.154.255 Mask:255.255.255.0      inet addr:127.0.0.1 Mask:255.0.0.0      i am extracting the ipaddress(`192.168.154.102` and `127.0.0.1`) using sed like this :               sed -ne 's/.*\([0-9]\{1,3\}\.[0-9]\{1,3\}\.[0-9]\{1,3\}\.[0-9]\{1,3\}\).*/\1/p'      but it just gives :               5.255.255.0     5.0.0.0


Determining if GPU switching works?

I have a 8,3 MacBook Pro with an onboard Radeon 6700M GPU alongside the integrated Intel Sandy Bridge GPU. I recently upgraded to FGLRX 8.930/12.1, and Catalyst Control Center seemed to look the same, there weren't any different options as opposed to 8.920/11.12. However, here it mentions that someone tested things out and was able to determine that with FGLRX on the same card as me, they were able to determine that GPU switching was, in fact, working. Unfortunately, the blog doesn't allow comments, so I can't ask this question there. Is there a way for me to determine if GPU switching is working or not between ATI and Intel cards? How can I know if it's working or not? Again, there doesn't seem to be anything in CCC that tells me whether it's enabled or not. There's "PowerPlay," but that seems to be more of a setting for battery-saving in general and doesn't make any mention of GPU switching. How can I test if GPU-switching/hybrid graphics is enabled and working on my Ubuntu 11.10 machine?


Finding error log related to specific crash in Ubuntu

Every time I try to start a specific program (Mathematica), my Ubuntu session crashes and I get thrown back to login screen. I want to find out 1) what is it exactly that crashes (probably X) and 2) find the error log produced by this crash. I tried looking at .xsession-errors file, but the file is huge and I don't know how to find what I'm looking for from there. It would be ideal if I could somehow make X output its error log to another file temporarily or something. EDIT: The relevant error log was found from /var/log/syslog which says: "gnome-session[3679]: Gdk-WARNING: gnome-session: Fatal IO error 11 (Resource temporarily unavailable) on X server :0.#012". This is possibly related to this bug: https://bugs.launchpad.net/ubuntu/+source/nvidia-graphics- drivers/+bug/999191 .


Pcie 1.1 device is not detected on a pcie gen 3 slot

My PC is running in Ubuntu 12.04 LTS with kernel version 3.11.0-23. The link below is my PC model: http://www.villman.com/Product- Detail/HP_Pavilion_500_232d I inserted a x4 pcie 1.1 device on the x16 PCIE 3.0 slot. When I do lspci, my device is not shown in the list. I tested my device on other PC with Gen 2.0 slot and it is detected. Is there a way for my device to be detected?


Why don't I have read access to files with modified ACL?

My aim is to allow read access to folder `/var/www/mysite/` only for users in group www-data using a default **ACL**. **This works for a regular ACL, but not for a default ACL. Why?** This is how I did it: I am logged on as user _www-data_ who is in group _www-data_. I am in directory _`/var/www`_. I created a directory _mysite_ and gave it the permission 0. Then I added ACL permissions so that anyone in group _www-data_ has read-access to directory _mysite/_.               $ mkdir mysite     $ chmod 0 mysite     $ setfacl -m g:www-data:r-x mysite     $ ls -la     d---------+  2 root root 4096 Sep  6 11:16 mysite     $ getfacl mysite/     # file: mysite/     # owner: root     # group: root     user::---     group::---     group:www-data:r-x     mask::r-x     other::---      At this point user _www-data_ has access to the folder. However, if I instead add a default ACL, access is denied!               $ setfacl -m d:g:www-data:r-x mysite # <---- NOTE the default acl rule.     $ ls -la     d---------+  2 root root 4096 Sep  6 11:16 mysite     $ getfacl mysite/     # file: mysite/     # owner: root     # group: root     user::---     group::---     other::---     default:user::---     default:group::---     default:group:www-data:r-x     default:mask::r-x     default:other::---


How can I merge multiple lines with spaces (blank line) separating them?

I'd like to merge the following multiple lines of output so that they form a single line: _line 1:_ > > ,,,1,,,,,,,,18,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,42,1,121,1,17,10,21,1,,IU,8,0,,0, > ,0,0,0,,,,,,,,,,,,,,,,,,,,,,,,1227,,,11,,0,,,,1,01,,,1,12769,,7707,0,,,,12769,,,12769,6,0,,,,10,,,1, > 901,10800,14/04/13,,,4,,,,2,,,,,,,,,,,,,,,,,,,,,,,,,,,,,A,,,,1001,,,,,,,,,,,01,,12769,0,,,,,,,,,,,,, > ,,,,,,,,,,,,,,,,14/04/13,10800,,,,,,,,,,,,,,,,,,,,,,1,,,,,,,,,964750001210,,1001,,1,,0,,,,,,,,,,,,17 > ,,,,,,,,,31685125704,,,,1,,1,0,,,,,,,,,,,,,,,,,,19,0,.901,19,0,.901,,,901,1,,,8767318,13790084045,1, > 1304150024556817,,,,33399399,,,,,,,,,,,,901,1,,,,,,0,,0,,,,,,GSMT11B* *** > _S_** ,,,4,,,,,,10800,14/04/1 > 3,10800,14/04/13,443867992,,,,,,,,1,0,,0,,,,,,,61409,51,,,9647507763683,,1001,1,0,,60,0,5,,N,,0,1,I, > 1,,,,,,47,,,,,54,1,4,19,,29,1,1,1,3,1112,2,,Usage,Usage,USG,,N,N,0,,1,,TRNT01I,90,,0GRI3,90,,,,,0,1, > 1,1,1,1,34111,437956,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,19,,,,,,,,,,,,,,,H,,1,0,1,0 _...blank line..._ _line 2:_ > > ,,,1,,,,,,,,18,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,42,1,121,1,17,10,21,1,,IU,8,0,,0, > ,0,0,0,,,,,,,,,,,,,,,,,,,,,,,,399,,,11,,0,,,,1,01,,,1,61,,67,0,,,,61,,,61,6,0,,,,10,,,1,74,10800,14/ > 04/13,,,4,,,,2,,,,,,,,,,,,,,,,,,,,,,,,,,,,,A,,,,1001,,,,,,,,,,,01,,61,0,,,,,,,,,,,,,,,,,,,,,,,,,,,,, > 14/04/13,10800,,,,,,,,,,,,,,,,,,,,,,1,,,,,,,,,964750001210,,1001,,1,,0,,,,,,,,,,,,17,,,,,,,,,9647703 > 026865,,,,1,,1,0,,,,,,,,,,,,,,,,,,19,0,.061667,19,0,.061667,,,74,1,,,8820807,13790084046,1,130415002 > 4556817,,,,33399399,,,,,,,,,,,,74,1,,,,,,0,,0,,,,,,GSMT11B* *** _S_** > ,,,4,,,,,,10800,14/04/13,10800,14 > /04/13,443867993,,,,,,,,1,0,,0,,,,,,,61409,51,,,9647503228592,,1001,1,0,,60,0,5,,N,,0,1,I,1,,,,,,20, > ,,,,25,1,4,19,,19,1,1,1,3,980,2,,Usage,Usage,USG,,N,N,0,,1,,ASIA03I,90,,0GRI3,90,,,,,0,1,1,1,1,1,341 > 12,437956,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,19,,,,,,,,,,,,,,,H,,1,0,1,0 _...blank line..._ _line 3:_ > > ,,,1,,,,,,,,18,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,42,1,121,1,17,10,21,1,,IU,8,0,,0, > ,0,0,0,,,,,,,,,,,,,,,,,,,,,,,,327,,,11,,0,,,,1,01,,,1,12769,,7707,0,,,,12769,,,12769,6,0,,,,10,,,1,2 > ,10800,14/04/13,,,4,,,,2,,,,,,,,,,,,,,,,,,,,,,,,,,,,,A,,,,1001,,,,,,,,,,,01,,12769,0,,,,,,,,,,,,,,,, > ,,,,,,,,,,,,,14/04/13,10800,,,,,,,,,,,,,,,,,,,,,,1,,,,,,,,,964750001210,,1001,,1,,0,,,,,,,,,,,,17,,, > ,,,,,,96171254836,,,,1,,1,0,,,,,,,,,,,,,,,,,,19,0,.002,19,0,.002,,,2,1,,,8825322,13790084047,1,13041 > 50024556817,,,,33399399,,,,,,,,,,,,2,1,,,,,,0,,0,,,,,,GSMT11B* *** _S_** > ,,,4,,,,,,10800,14/04/13,10800 > ,14/04/13,443867994,,,,,,,,1,0,,0,,,,,,,61409,51,,,9647501378572,,1001,1,0,,60,0,5,,N,,0,1,I,1,,,,,, > 47,,,,,54,1,4,19,,29,1,1,1,3,1112,2,,Usage,Usage,USG,,N,N,0,,1,,TRNT01I,90,,0GRI3,90,,,,,0,1,1,1,1,1 > ,34113,437956,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,19,,,,,,,,,,,,,,,H,,1,0,1,0 _...blank line..._


How to run awk for some number of lines.?

I want to extract some lines with `awk`. Is it possible to do the following task:               ls -l | awk 'BEGIN FOR(i=122;i<=129;i++) FNR==i'      How can I display the details from line numbers 122 to 129?


How to restore a DD image file in my primary disk on new debian server

I have a dedicated Debian server at Online.net and I want to change the server by a more powerful (always Debian OS). For that, I have made an image on my old hard disk with this command:               dd if=/dev/sda | gzip -c > /backup/sda1_image.gz       In my 2 machines, I don't have partitions and I have just one hard disk. My question : How I can to restore my image in my new Debian server, on his primary disk? It's possible to make it in ssh:               gzip -cd /backup/sda1_image.gz | dd of=/dev/sda      Question: I have to unmount my primary disk before the restoration ? Question: If I unmount the primary(boot) disk by ssh, it not freeze ? Because I just can access to my server in ssh (no phisical).


Mounting error while installing VM ware tools in Kali Linux

I'm new to Linux and I have installed Kali Linux on VM Workstation.I want to install the VM tools but when I click "install VMware tools" from the VM workstation menu I receive this error at the guest OS window "unable to mount VM ware tools error mounting:mount exited with with exit code 1:...." Does any on know what's the problem here and how I can proceed with the installation.


What is the .gitignore pattern equivalent of the regex (Big|Small)(State|City)-[0-9]*\.csv

I have a regex I stuck in my `.gitignore` similar to:               (Big|Small)(State|City)-[0-9]*\.csv      It didn't work so I tested it against RegexLab.NET. I then found the gitignore man page which led me to learn that gitignore doesn't use regexes, but rather fnmatch(3). However, fnmatch it doesn't seem to have an equivalent of the capture groups. Is this feasible or do I need to break this into three lines?


Does brand/hardware limit the distributions that are safe to run?

I recently tried running Fedora 16 on my laptop and had problems with the fan. In particular, the fan would start, run at full power, and never turn off. I spent a few hours online looking for solutions but didn't find any. I then reverted back to Ubuntu and had the problem disappear (after some minor configuration). I would really like to try different distributions, but I'm afraid that the hardware on my laptop would not be supported. Is there always a fix to these kinds of problems or should I just stick to what works? I have a Toshiba Satellite L305-S5945.


I can't login to Crunchbang Linux

I rebooted my VM and now I can't login. It gives me the following error:               Your session only lasted less than 10 seconds. If you have not logged out yourself, this could mean that there is some installation problem or that you may be out of diskspace. Try logging in with one of the failsafe sessions to see if you fix this problem.          View details (!/.xsession-errors file)          /etc/gdm/Xsession: Beginning session setup...     mkdtemp: private socket dir: Permission denied      When changing the session to failsafe gnome it gives me `Could not find the GNOME installation, will try running the "Failsafe xterm" session`. And when trying failsafe terminal I get `Cannot find "xterm" to start a failsafe session.` I had not rebooted my VM in a while; I can't think of something that would cause this. But how do I fix it? Edit: The output of `stat /tmp`:                 File: `/tmp`       Size: 4096        Blocks: 8        IO Block: 4096   directory     Device: 801h/2049d    Inode: 131238    Links: 13     Access: (0755/drwxr-xr-x) Uid: (    0/    root)  Gid: (    0/    root)     Access: 2012-02-15 06:18:42.360913478 -0700     Modify: 2012-02-16 19:17:01.514555114 -0700     Change: 2012-02-16 19:17:01.514555114 -0700


Set Variable Environment Variables in bash (or other)

I want my script to read a file containing key/value pairs of environment variables to set, and then to set them. So far, I have this:               #!/bin/bash          cat $1 | while read kv     do         key=${kv%=*}         val=`echo ${kv#*=} | sed 's/^"\|"$//g'`         export $key="$val"     done      And I want to read a file like this:               XAUTHLOCALHOSTNAME="localhost"     DISPLAY=":0"     XAUTHORITY="/tmp/some-XAuthority"      I only need these variables in scope for the duration of the script, so I don't need to solve the problem of setting a variable in script for the parent scope. From my testing, I think my problem lies with `export $key="$val"`, so I think I just need a replacement for that line.


dynamic display of a running process?

I am writing a script and acording to that when i run it certain info will be displayed on the output screen. for example say the **constant data** displayed is:               my name is mukesh.     i am 27 years old     unix version 7.2.3.0      but along with the above display something else is also need to be displayed( **varying data** ) i.e               Process A is starting     Process A is running     Process A is completed.      but i dont want the above display. I want `Process A is starting` to be cleared from screen and replaced by `Process A is running` and then by `Process A is completed.` i am not very keen to use `clear` as it will remove the whole screen containing the **constant data** also. and also because the constant data takes a lot of time to process and to be displayed on the screen.


Two way internet sharing configuration (swiching modem from one machine to another)

I have:   1. One Raspberry Pi with Raspbian (distribution based on Debian), with one enthernet interface   2. One laptop with windows, with one ethernet interface   3. One USB modem   4. Ethernet cable between Pi and laptop I want to:   1. Share internet on Raspberry Pi when modem is connected to Pi   2. Use internet which is shared on laptop when modem is connected to laptop. What I have done:   1. My modem is working on both machines, its ppp0 interface on Pi. ppp0 has dynamic IP.   2. Sharing internet from laptop to Raspberry works. Laptop IP: 192.168.137.1 Question: **How can I share internet on Raspberry Pi without ruining too much / reconfiguring network on both machines when I switch modem from one machine to another?** Extra question: I know that interfaces on both windows and linux can have multiple IP addresses. Can I have both configurations set and just plug my modem here and there and start connection to have internet on second machine?


If I connect a physical device, how can I ever know which device file belongs to it?

Say I plug in several USB drives which don't get automatically mounted. How can I find out which device file belongs to which physical device, so I can mount it for example? I'm running Mac OS X but I rather like an answer that works on all (or at least the most popular) Unix systems. I had this problem with Linux in the past.


counting the number of occurences in a file of data list

I have a data file, like               7     2     10     9     10     3     2     4     2     4     6      Each line has a single value. I want to count the occurence of each value. For instance, 10 occurs two times in this file. Is there a simple way to do that under linux without writing formal counting program?


Changing suspend order on OpenSUSE 12.2

This question seems more relevant here than SO. I've been trying to debug a library that X uses through a GDB session that I'm running through SSH, but it seems that on OpenSUSE, the SSH session is being "suspended" before GDB hits a breakpoint that occurs in the library on suspend. As a result, the system waits on the remote GDB to continue, but I can't continue because the SSH session is "suspended". I noticed on Ubuntu 12.04 and 12.10, the GDB session stops while the SSH connection is still active, so I can continue on the breakpoint and continue on the SIGUSR1 signal that GDB gets. Is it possible to mimic this behaviour on SUSE and "reverse" the order of suspends?


Remap keypad keys to modifiers

I did some research but I couldn't find a working solution: How can I make my keyboard buttons: `KP_1`, `KP_2`, `KP_3` to work exactly the same as `Shift_L`, `Alt_L` and `Control_L`? I use Linux Mint 17 Cinnamon. I want the new keys to work in game Dota 2 (but i don't mind if they will work globally). I tried different things but none of it worked as expected: ### `xmodmap` I run in terminal:               xmodmap -e "keycode 87 = Shift_L"     xmodmap -e "keycode 88 = Alt_L"     xmodmap -e "keycode 89 = Control_L"      Results:   * OS: `KP_1` and `KP_2` work as they should (as `Shift` and `Alt`), but somehow `kp_3` doesn't work as `Ctrl`     * Dota 2: none of the `kp_1`, `kp_2`, `kp_3` work as `Shift`/`Alt`/`Ctrl` (why?) ### `remap.inc` file I added the following lines to `/etc/console-setup/remap.inc`               keycode  79 = Shift     keycode  80 = Alt     keycode  81 = Control      and then run               sudo dpkg-reconfigure console-setup -phigh      Results: doesn't work anywhere. I don't know why these keycodes are different than what "xev" returns, but that's what I found using dumpkeys:               sudo dumpkeys | egrep "^keycode.*KP_[123]"     keycode  79 = KP_1                 keycode  80 = KP_2                 keycode  81 = KP_3       ### `xbindkeys` + `xte` I addedd these lines to `~/.xbindkeysrc`:               "xte 'key Shift_L'"         Mod2 + KP_End      and ran "xbindkeys" in terminal.   Results: doesn't work anywhere (probably because `Shift_L` is pressed only once - I would like it to be kept pressing when I keep pressing `KP_1`, just like the normal `Shift` button).


How can I know if the current kernel was compiled with a certain option enabled?

Is there a way to know if the kernel was compiled with a certain option activated (i.e. `CONFIG_PROC_EVENTS=y`) without having to pull out the kernel sources package and looking in the config file?


vagrant private network unstable

I have these 2 boxes, but I have a problem, when I start `disributed` and `ping 172.28.128.2` often the network isn't working, but if I then go into `oracle` and `ping 172.28.128.3` it'll find that and both networks will suddenly be able to talk to each other (once saw `ip neigh` in a `DELAY` state)               config.vm.box = "chef/centos-6.5"          config.vm.define "oracle", primary: true do |oracle|         config.vm.network "private_network", ip: "172.28.128.2"         config.vm.network "forwarded_port", guest: 1521, host: 1521          config.vm.define "distributed", autostart: false do |distributed|         config.vm.network "private_network", ip: "172.28.128.3"      what could be going wrong?               [root@localhost ~]# ip neigh     172.28.128.1 dev eth1 lladdr 0a:00:27:00:00:01 REACHABLE     10.0.2.2 dev eth0 lladdr 52:54:00:12:35:02 REACHABLE     172.28.128.2 dev eth1 lladdr 08:00:27:e3:d8:31 DELAY


iptables: refuse immediately when blocking particular domain from visiting by browser

I need to block particular domain "megafonpro.ru" and all subdomains from visiting by browser. Here's rule that I wrote:               sudo iptables -I OUTPUT -p tcp --dport 80 -m string --string "megafonpro.ru" --algo kmp --to 65535 -j REJECT      It works, but not perfect: when I try to enter matching URL (say, "wap.megafonpro.ru"), firefox tries to connect for very long time (about 30 seconds), and then reports "The connection was reset". How to make it refuse immediately? * * * **UPD:** I found out that I can just add non-wanted domains to the `/etc/hosts`, like that:               127.0.0.1   megafonpro.ru     127.0.0.1   m.megafonpro.ru     127.0.0.1   wap.megafonpro.ru      We can't wildcard sumdomains unfortunately ( related question: http://serverfault.com/questions/118378/in-my-etc-hosts-file-on-linux-osx-how- do-i-do-a-wildcard-subdomain ). Now, browser refuses immediately. But anyway, I'm interested how to make it with iptables.


How can I tell what woke my laptop from suspend?

On other operating systems, there are ways to see what process or event woke them from suspend. I leave my laptop often for multiple days in suspend, sometimes to find that it has woken itself up and is heating whatever surface it is resting on :) Is there a way to find out what woke it up so that I can prevent that thing from happening again? On Ubuntu 12.04 (elementary Luna).


How to redirect stdout to a file and read from the same file simultaneously with another task?

I want to run a task (which takes quite a long time) remotely in Ubuntu Linux Bash via `nohup` and redirect `stdout` to a file, e.g.: `nohup task > out.txt &` From time to time I would like to check the progress of the task by looking into the output file: `cat out.txt` I haven't yet figured out how to do that because the file's content is shown as empty as long as the file is opened for writing by Bash. So my question is: Is there any linux command that allows a 'shared' `stdout` redirection?


System calls in linux

Generally, systems provide a library or API that sits between normal programs and the operating system. On Unix-like systems, that API is usually part of an implementation of the C library (libc), such as glibc, that provides wrapper functions for the system calls.In C i can use these wrapper functions to make system calls. How do i make system calls in other languages?


squashfs reserve some free space

**Briefly: Is it possible to reserve some free space using mksquashfs?** I'm creating an image of simple livecd based on squashfs filesystem. Everything works fine except that I've got very little "free" space on a root partition. Can I assign more free space with mksquashfs? For now as I workaround I'm mounting ramfs after livecd boot. Another idea will be to create a large file on squashfs, pack it using mksquashfs and delete it after bootup. Is there any "clean" solution?


System calls source code

C library provides functions such as write(),read(),open()...that we can use in our C program to make system calls. where can I find source code for these functions?


How to clone linux installation onto an external harddisk?

I see a lot of `dd` related questions, but could not find answers to the following. If question/answers already exist, please point to them, then flag to close, delete or merge.   1. Can a working linux installation (say on `/dev/sda7`) be cloned to an external hard disk partition (say `/dev/sdb2`), while on it? (`/dev/sdb` is a 1TB USB hard disk, `/dev/sdb2` is of size 100GB)   2. If not, can I do it using a live cd? Will the cloned partition on external drive be bootable?    3. If it is not bootable, how to do that? **Why want to do that ?** : Need to carry the cloned external drive than the laptop itself, with all the installed (& customized) programs and data. Additional info (relevant parts only):               $ sudo fdisk -l     Disk /dev/sda: 160.0 GB, 160041885696 bytes     Device Boot      Start         End      Blocks   Id  System     /dev/sda1   *           1        2550    20482843+   7  HPFS/NTFS     /dev/sda7            5660        6904    10000431   83  Linux          $ df -h     Filesystem            Size  Used Avail Use% Mounted on     /dev/sda7             9.4G  7.4G  1.6G  83% /


Additional keybinding combination to copy text to clipboard

I would like know, how to make _copy to clipboard_ work not only with the default `Ctrl`+`c` key-combination but also using `Ctrl`+`End` for instance. How do I do that?


Not able to deny selected local user to login ftp server

I added the below 2 lines in the end of the configuration file `/etc/vsftpd.conf` so as to deny a local user named 'tentenths' from loggin in the ftp server. I restarted the vsftpd service after the change. But still the user was permitted to login. Where am I mistaken!               userlist_deny=YES     userlist_file=/etc/vsftpd.denied_users      The content of the above file is:               ravbholua@ravi:~$ cat /etc/vsftpd.denied_users     tentenths     ravbholua@ravi:~$      I am referring this link for the same. Have a look at the whole conf. file:               # Example config file /etc/vsftpd.conf     #     # The default compiled in settings are fairly paranoid. This sample file     # loosens things up a bit, to make the ftp daemon more usable.     # Please see vsftpd.conf.5 for all compiled in defaults.     #     # READ THIS: This example file is NOT an exhaustive list of vsftpd options.     # Please read the vsftpd.conf.5 manual page to get a full idea of vsftpd's     # capabilities.     #     #     # Run standalone?  vsftpd can run either from an inetd or as a standalone     # daemon started from an initscript.     listen=YES     #     # Run standalone with IPv6?     # Like the listen parameter, except vsftpd will listen on an IPv6 socket     # instead of an IPv4 one. This parameter and the listen parameter are mutually     # exclusive.     #listen_ipv6=YES     #     # Allow anonymous FTP? (Disabled by default)     anonymous_enable=YES     #     # Uncomment this to allow local users to log in.     local_enable=YES     #     # Uncomment this to enable any form of FTP write command.     write_enable=YES     #     # Default umask for local users is 077. You may wish to change this to 022,     # if your users expect that (022 is used by most other ftpd's)     #local_umask=022     #     # Uncomment this to allow the anonymous FTP user to upload files. This only     # has an effect if the above global write enable is activated. Also, you will     # obviously need to create a directory writable by the FTP user.     anon_upload_enable=YES     #     # Uncomment this if you want the anonymous FTP user to be able to create     # new directories.     #anon_mkdir_write_enable=YES     #     # Activate directory messages - messages given to remote users when they     # go into a certain directory.     dirmessage_enable=YES     #     # If enabled, vsftpd will display directory listings with the time     # in  your  local  time  zone.  The default is to display GMT. The     # times returned by the MDTM FTP command are also affected by this     # option.     use_localtime=YES     #     # Activate logging of uploads/downloads.     xferlog_enable=YES     #     # Make sure PORT transfer connections originate from port 20 (ftp-data).     connect_from_port_20=YES     #     # If you want, you can arrange for uploaded anonymous files to be owned by     # a different user. Note! Using "root" for uploaded files is not     # recommended!     #chown_uploads=YES     #chown_username=whoever     #     # You may override where the log file goes if you like. The default is shown     # below.     #xferlog_file=/var/log/vsftpd.log     #     # If you want, you can have your log file in standard ftpd xferlog format.     # Note that the default log file location is /var/log/xferlog in this case.     #xferlog_std_format=YES     #     # You may change the default value for timing out an idle session.     #idle_session_timeout=600     #     # You may change the default value for timing out a data connection.     #data_connection_timeout=120     #     # It is recommended that you define on your system a unique user which the     # ftp server can use as a totally isolated and unprivileged user.     #nopriv_user=ftpsecure     #     # Enable this and the server will recognise asynchronous ABOR requests. Not     # recommended for security (the code is non-trivial). Not enabling it,     # however, may confuse older FTP clients.     #async_abor_enable=YES     #     # By default the server will pretend to allow ASCII mode but in fact ignore     # the request. Turn on the below options to have the server actually do ASCII     # mangling on files when in ASCII mode.     # Beware that on some FTP servers, ASCII support allows a denial of service     # attack (DoS) via the command "SIZE /big/file" in ASCII mode. vsftpd     # predicted this attack and has always been safe, reporting the size of the     # raw file.     # ASCII mangling is a horrible feature of the protocol.     #ascii_upload_enable=YES     #ascii_download_enable=YES     #     # You may fully customise the login banner string:     #ftpd_banner=Welcome to blah FTP service.     #     # You may specify a file of disallowed anonymous e-mail addresses. Apparently     # useful for combatting certain DoS attacks.     #deny_email_enable=YES     # (default follows)     #banned_email_file=/etc/vsftpd.banned_emails     #     # You may restrict local users to their home directories.  See the FAQ for     # the possible risks in this before using chroot_local_user or     # chroot_list_enable below.     chroot_local_user=NO     #     # You may specify an explicit list of local users to chroot() to their home     # directory. If chroot_local_user is YES, then this list becomes a list of     # users to NOT chroot().     # (Warning! chroot'ing can be very dangerous. If using chroot, make sure that     # the user does not have write access to the top level directory within the     # chroot)     #chroot_local_user=YES     chroot_list_enable=YES     # (default follows)     chroot_list_file=/etc/vsftpd.chroot_list     #     # You may activate the "-R" option to the builtin ls. This is disabled by     # default to avoid remote users being able to cause excessive I/O on large     # sites. However, some broken FTP clients such as "ncftp" and "mirror" assume     # the presence of the "-R" option, so there is a strong case for enabling it.     #ls_recurse_enable=YES     #     # Customization     #     # Some of vsftpd's settings don't fit the filesystem layout by     # default.     #     # This option should be the name of a directory which is empty.  Also, the     # directory should not be writable by the ftp user. This directory is used     # as a secure chroot() jail at times vsftpd does not require filesystem     # access.     secure_chroot_dir=/var/run/vsftpd/empty     #     # This string is the name of the PAM service vsftpd will use.     pam_service_name=vsftpd     #     # This option specifies the location of the RSA certificate to use for SSL     # encrypted connections.     rsa_cert_file=/etc/ssl/certs/ssl-cert-snakeoil.pem     # This option specifies the location of the RSA key to use for SSL     # encrypted connections.     rsa_private_key_file=/etc/ssl/private/ssl-cert-snakeoil.key     userlist_deny=YES     userlist_file=/etc/vsftpd.denied_users


Mixing 4k/512 drives with ZFS (FreeNAS)

I have the following drives:   * Seagate Barracuda ST3200054AS   * WDC WD20EADS-00S2B0   * Samsung HD204UI As far as I understand, the first are ordinary 512 drives while the last is 4096 (Advanced format). Together with a new 2TB drive, I want to create a 6TB RAIDz1 with ZFS in FreeNAS. The new drive must most likely be also Advanced format because the old 512 are becoming rare/expensive. So I will effectively have two 512-byte-block and two 4096-byte-block drives. What special things must I take care in order to not **decrease** performance? When I chose "Force 4096 bytes sector size" in the volume manager, will I make sure that I will get the same performance if all block sizes were equal?


pam-auth-update does not display prompt screen or log any failure

~# lsb_release -a     No LSB modules are available.     Distributor ID: Ubuntu     Description:    Ubuntu 12.04.4 LTS     Release:        12.04     Codename:       precise          ~# dpkg -l \*pam\* | grep ii     ii  libpam-krb5                          4.5-3                               PAM module for MIT Kerberos     ii  libpam-modules                       1.1.3-7ubuntu2                      Pluggable Authentication Modules for PAM     ii  libpam-modules-bin                   1.1.3-7ubuntu2                      Pluggable Authentication Modules for PAM - helper binaries     ii  libpam-runtime                       1.1.3-7ubuntu2                      Runtime support for the PAM library     ii  libpam0g                             1.1.3-7ubuntu2                      Pluggable Authentication Modules library      trying to run pam-auth-update on this particular box. Other boxes causea prompt screen to pop up. This particular box, however, does absolutely nothing with no feedback or logs as far as I can tell.


RAIDing with LVM vs MDRAID - pros and cons?

In his answer to the question "mixed raid types", HBruijn suggests using LVM to implement RAID vs the more standard MDRAID. After a little investigation, it seems LVM also supports RAID functionality. In the past, I have used LVM on top of MDRAID, and was not aware till now that LVM also supports RAID functionality. This seems to be a relatively recent development, but I have not found out exactly when this was implemented. So, these are alternative ways to implement software RAID on Linux. What are the pros and cons of these two different approaches? I'm looking for feature comparisons between the two approaches so people can decide which is better for them. Conclusions based on experimentation (as in, this feature doesn't work as well as this feature and here is why) are also Ok, provided you include your data in the answer. Some specific issues to address:   1. Suppose I want to do sw RAID + LVM (a common scenario). Should I use LVM's support for sw RAID and thus use one utility instead of two? Does this more integrated approach have any advantages?   2. Does LVMs support for sw RAID have significant deficiencies compared to the more mature MDADM? Specifically, how stable/bug-free is the LVM support for sw RAID? It seems this support only goes back to 2011 (see below), while MDADM is much older. Also, how does it compare in terms of feature set. Does it have significant feature deficiencies compared to MDADM? Conversely, does it have support for any sw RAID features that MDADM does not have? NOTEs:   1. There is a detailed discussion at http://www.olearycomputers.com/ll/linux_mirrors.html but I could not find what date it was written. Similar question on Serverfault: linux LVM mirror vs. MD mirror. However, this question was asked in 2010, and the answers may be out of date.   2. The changelog entry for version 2.02.87 - 12th August 2011 has > Add configure --with-raid for new segtype 'raid' for MD RAID 1/4/5/6 support So, it looks like RAID support in LVM is about 3 years old.


sed convert 4 spaces to 2

How does one convert 4 spaces into 2 spaces with `sed`? Is it possible? I found this but it converts tab to spaces: `sed -r ':f; s|^(\t*)\s{4}|\1\t|g; t f' file`


Can files be created with permissions set on the command line?

When creating directories, `mkdir -m <mode> <dir>` provides for creating one or more directories with the given mode/permissions set (atomically). Is there an equivalent for creating files, on the command line? Something akin to:               open("file", O_WRONLY | O_APPEND | O_CREAT, 0777);      Is using `touch` followed by a `chmod` my only option here? * * * **Edit:** After trying out teppic's suggestion to use `install`, I ran it through `strace` to see how close to atomic it was. The answer is, not very:               $ strace install -m 777 /dev/null newfile     ...     open("newfile", O_WRONLY|O_CREAT|O_EXCL, 0666) = 4     fstat(4, {st_mode=S_IFREG|0666, st_size=0, ...}) = 0     ...     fchmod(4, 0600)                         = 0     close(4)                                = 0     ...     chmod("newfile", 0777)                  = 0     ...      Still, it's a single shell command and one I didn't know before.


mount failed to process probably corrupted CD

I wanted to check a CD from my drawer. I inserted it into my drive and issued mount. I got               mount: block device /dev/sr0 is write-protected, mounting read-only      mount command did not exit. I checked its state in top:               4640 root      20   0 27088 1280 1060 R  99,8  0,0   1:36.90 mount      99,8% CPU usage what was not true because usage of all my cores is almost 0,0%. I tried to kill it - no success (both signals KILL and TERM fail to stop the mount programme). I tried reboot -f and reboot got into D state. fuser helped neither. /dev/sr0 is my cdrom and it was not present in mount output               umount  /media/cdrom           umount: /media/cdrom0 is not mounted (according to mtab)      fstab:               /dev/sr0       /media/cdrom0   udf,iso9660 user,noauto     0       0      Don't know what to do with that. All what works is to cut power and start again. System doesn't reboot or shutdown.


busybox initramfs loop mount

I'm trying to loop mount my root filesystem (a loop file) within a busybox initramfs. I try to run the command: mount /rootfs.raw /root ... which works on my Ubuntu laptop, however, I simply get `mount: mounting /dev/loop0 on /root failed: Invalid argument` No matter what combination of options I use, (including loading to /loop0 manually and trying to mount it), the system will not mount the loop device. Why can't I mount it?


How can I change the default gateway?

Currently I'm running a FreeBSD 9.1 and the default gateway is already configured in the `rc.conf`. `rc.conf`:               defaultrouter = "10.0.0.1"      But now I want to change the default gateway without rebooting the system, is this possible?


Make vim open files as nomodifiable, under certain conditions

How can I make open files as `readonly` and `nomodifiable`, if they're in a certain folder hierarchy, but do NOT contain a certain extension? For example, if I open files on /server/(production|uat)/* I want to be prompted whether to edit the file, or just view it. An exception might be needed as well--such as if the file contains the prefix `temp`.


Upgrade to squeeze and dpkg returned an error code(1)

I want to upgrade my server so I ran `apt-get dist upgrade` but I keep having this error:               Unpacking replacement aptitude ...     dpkg-deb: file `/var/cache/apt/archives/aptitude_0.6.8.2-1_armel.deb' contains ununderstood data member data.tar.xz     , giving up     dpkg: error processing /var/cache/apt/archives/aptitude_0.6.8.2-1_armel.deb (--unpack):      subprocess dpkg-deb --fsys-tarfile returned error exit status 2     dpkg: considering deconfiguration of aptitude, which would be broken by installation of aptitude-common ...     dpkg: yes, will deconfigure aptitude (broken by aptitude-common).     Unpacking aptitude-common (from .../aptitude-common_0.6.8.2-1_all.deb) ...     De-configuring aptitude ...     dpkg-deb: file `/var/cache/apt/archives/aptitude-common_0.6.8.2-1_all.deb' contains ununderstood data member data.tar.xz     , giving up     dpkg: error processing /var/cache/apt/archives/aptitude-common_0.6.8.2-1_all.deb (--unpack):      subprocess dpkg-deb --fsys-tarfile returned error exit status 2                    Errors were encountered while processing:                                             /var/cache/apt/archives/aptitude_0.6.8.2-1_armel.deb                                 /var/cache/apt/archives/aptitude-common_0.6.8.2-1_all.deb                           E: Sub-process /usr/bin/dpkg returned an error code (1)       Here's some of what I've tryied:               sudo apt-get dist-upgrade     sudo dpkg --configure -a     sudo ldconfig     sudo apt-get check     sudo apt-get -f install     sudo apt-get -f upgrade --fix-missing      Always ending with the same errors so I can't do anything else. What should I do?


What is loop0 and how do I e2fsck it?

EXT3-fs (sdd1): using internal journal     EXT3-fs (sdd1): mounted filesystem with ordered data mode     EXT4-fs (sda1): mounted filesystem with ordered data mode. Opts:      EXT4-fs (sdb1): mounted filesystem with ordered data mode. Opts:      EXT4-fs (sdc1): mounted filesystem with ordered data mode. Opts:      Adding 4194296k swap on /dev/sdd2.  Priority:-1 extents:1 across:4194296k SSD     kjournald starting.  Commit interval 5 seconds     EXT3-fs (loop0): warning: maximal mount count reached, running e2fsck is recommended     EXT3-fs (loop0): using internal journal     EXT3-fs (loop0): mounted filesystem with ordered data mode      (loop0) is mounted too many times. What is it? Is it important? This is my fstab               #     # /etc/fstab     # Created by anaconda on Wed Nov  1 00:29:46 2000     #     # Accessible filesystems, by reference, are maintained under '/dev/disk'     # See man pages fstab(5), findfs(8), mount(8) and/or blkid(8) for more info     #     UUID=9fac7ae7-9948-4612-88dc-e652fc4ceb73 /                       ext4    defaults        1 1     UUID=1daa52c7-a5da-464d-a4c7-2ee19ef017af /boot                   ext3    defaults        1 2     UUID=12649fb1-fd53-4558-8a2a-79692ada8b19 swap                    swap    defaults        0 0     tmpfs                   /dev/shm                tmpfs   defaults        0 0     devpts                  /dev/pts                devpts  gid=5,mode=620  0 0     sysfs                   /sys                    sysfs   defaults        0 0     proc                    /proc                   proc    defaults        0 0     /usr/tmpDSK             /tmp                    ext3    defaults,noauto        0 0     /dev/sda1               /home1                  auto    auto,noatime,defaults        0 2     /dev/sdb1               /home2                  auto    auto,noatime,defaults        0 2     /dev/sdc1               /home3                  auto    auto,noatime,defaults        0 2


no irq handler vector

I'm a Linux newbie and I've just installed CentOS 6.4 on my desktop machine. Everytime I start my terminal I get these error messages and I can't figure out why. How can I trace the problem and fix it?               Message from syslogd@dan-p4 at Jan 16 18:52:50 ...      kernel:do_IRQ: 0.115 No irq handler for vector (irq -1)


Count lines of non-terminating input

Is there any way to count the lines of a non-terminating input source? For example, I want to run the following for a period of time to count the number of requests:               ngrep -W byline port 80 and dst host 1.2.3.4 | grep ":80" | wc      Obviously, that doesn't work. When I `Ctrl`+`C` kill that, I'm not going to get any output from `wc`. I would rather avoid creating a file if I can.


Access Share Files on Ubuntu with Win7: error "Path cannot be found"

Yesterday I added a share folder via system-config-samba. I created a new samba user for my Windows 7 64 bit machine. At first it worked fine, the next day, I cannot access from Windows 7. I click on Network in Explorer, and click on my Linux machine which appears, operation just times out. "Path cannot be be found". Edit: if you think there is a better way to share folders with Win7, please suggest.                   #     # Sample configuration file for the Samba suite for Debian GNU/Linux.     #     #     # This is the main Samba configuration file. You should read the     # smb.conf(5) manual page in order to understand the options listed     # here. Samba has a huge number of configurable options most of which      # are not shown in this example     #     # Some options that are often worth tuning have been included as     # commented-out examples in this file.     #  - When such options are commented with ";", the proposed setting     #    differs from the default Samba behaviour     #  - When commented with "#", the proposed setting is the default     #    behaviour of Samba but the option is considered important     #    enough to be mentioned here     #     # NOTE: Whenever you modify this file you should run the command     # "testparm" to check that you have not made any basic syntactic      # errors.      # A well-established practice is to name the original file     # "smb.conf.master" and create the "real" config file with     # testparm -s smb.conf.master >smb.conf     # This minimizes the size of the really used smb.conf file     # which, according to the Samba Team, impacts performance     # However, use this with caution if your smb.conf file contains nested     # "include" statements. See Debian bug #483187 for a case     # where using a master file is not a good idea.     #          #======================= Global Settings =======================          [global]          ## Browsing/Identification ###          # Change this to the workgroup/NT-domain name your Samba server will part of         workgroup = WORKGROUP          # server string is the equivalent of the NT Description field         server string = %h server (Samba, Ubuntu)          # Windows Internet Name Serving Support Section:     # WINS Support - Tells the NMBD component of Samba to enable its WINS Server     #   wins support = no          # WINS Server - Tells the NMBD components of Samba to be a WINS Client     # Note: Samba can be either a WINS Server, or a WINS Client, but NOT both     ;   wins server = w.x.y.z          # This will prevent nmbd to search for NetBIOS names through DNS.         dns proxy = no          # What naming service and in what order should we use to resolve host names     # to IP addresses     ;   name resolve order = lmhosts host wins bcast          #### Networking ####          # The specific set of interfaces / networks to bind to     # This can be either the interface name or an IP address/netmask;     # interface names are normally preferred     ;   interfaces = 127.0.0.0/8 eth0          # Only bind to the named interfaces and/or networks; you must use the     # 'interfaces' option above to use this.     # It is recommended that you enable this feature if your Samba machine is     # not protected by a firewall or is a firewall itself.  However, this     # option cannot handle dynamic or non-broadcast interfaces correctly.     ;   bind interfaces only = yes                    #### Debugging/Accounting ####          # This tells Samba to use a separate log file for each machine     # that connects         log file = /var/log/samba/log.%m          # Cap the size of the individual log files (in KiB).         max log size = 1000          # If you want Samba to only log through syslog then set the following     # parameter to 'yes'.     #   syslog only = no          # We want Samba to log a minimum amount of information to syslog. Everything     # should go to /var/log/samba/log.{smbd,nmbd} instead. If you want to log     # through syslog you should set the following parameter to something higher.         syslog = 0          # Do something sensible when Samba crashes: mail the admin a backtrace         panic action = /usr/share/samba/panic-action %d               ####### Authentication #######          # "security = user" is always a good idea. This will require a Unix account     # in this server for every user accessing the server. See     # /usr/share/doc/samba-doc/htmldocs/Samba3-HOWTO/ServerType.html     # in the samba-doc package for details.     #   security = user          # You may wish to use password encryption.  See the section on     # 'encrypt passwords' in the smb.conf(5) manpage before enabling.         encrypt passwords = true          # If you are using encrypted passwords, Samba will need to know what     # password database type you are using.       ;   passdb backend = tdbsam              obey pam restrictions = yes          # This boolean parameter controls whether Samba attempts to sync the Unix     # password with the SMB password when the encrypted SMB password in the     # passdb is changed.         unix password sync = yes          # For Unix password sync to work on a Debian GNU/Linux system, the following     # parameters must be set (thanks to Ian Kahan <<kahan@informatik.tu-muenchen.de> for     # sending the correct chat script for the passwd program in Debian Sarge).         passwd program = /usr/bin/passwd %u         passwd chat = *Enter\snew\s*\spassword:* %n\n *Retype\snew\s*\spassword:* %n\n *password\supdated\ssuccessfully* .          # This boolean controls whether PAM will be used for password changes     # when requested by an SMB client instead of the program listed in     # 'passwd program'. The default is 'no'.         pam password change = yes          # This option controls how unsuccessful authentication attempts are mapped      # to anonymous connections         map to guest = bad user          ########## Domains ###########          # Is this machine able to authenticate users. Both PDC and BDC     # must have this setting enabled. If you are the BDC you must     # change the 'domain master' setting to no     #     ;   domain logons = yes     #     # The following setting only takes effect if 'domain logons' is set     # It specifies the location of the user's profile directory     # from the client point of view)     # The following required a [profiles] share to be setup on the     # samba server (see below)     ;   logon path = \\%N\profiles\%U     # Another common choice is storing the profile in the user's home directory     # (this is Samba's default)     #   logon path = \\%N\%U\profile          # The following setting only takes effect if 'domain logons' is set     # It specifies the location of a user's home directory (from the client     # point of view)     ;   logon drive = H:     #   logon home = \\%N\%U          # The following setting only takes effect if 'domain logons' is set     # It specifies the script to run during logon. The script must be stored     # in the [netlogon] share     # NOTE: Must be store in 'DOS' file format convention     ;   logon script = logon.cmd          # This allows Unix users to be created on the domain controller via the SAMR     # RPC pipe.  The example command creates a user account with a disabled Unix     # password; please adapt to your needs     ; add user script = /usr/sbin/adduser --quiet --disabled-password --gecos "" %u          # This allows machine accounts to be created on the domain controller via the      # SAMR RPC pipe.       # The following assumes a "machines" group exists on the system     ; add machine script  = /usr/sbin/useradd -g machines -c "%u machine account" -d /var/lib/samba -s /bin/false %u          # This allows Unix groups to be created on the domain controller via the SAMR     # RPC pipe.       ; add group script = /usr/sbin/addgroup --force-badname %g          ########## Printing ##########          # If you want to automatically load your printer list rather     # than setting them up individually then you'll need this     #   load printers = yes          # lpr(ng) printing. You may wish to override the location of the     # printcap file     ;   printing = bsd     ;   printcap name = /etc/printcap          # CUPS printing.  See also the cupsaddsmb(8) manpage in the     # cupsys-client package.     ;   printing = cups     ;   printcap name = cups          ############ Misc ############          # Using the following line enables you to customise your configuration     # on a per machine basis. The %m gets replaced with the netbios name     # of the machine that is connecting     ;   include = /home/samba/etc/smb.conf.%m          # Most people will find that this option gives better performance.     # See smb.conf(5) and /usr/share/doc/samba-doc/htmldocs/Samba3-HOWTO/speed.html     # for details     # You may want to add the following on a Linux system:     #         SO_RCVBUF=8192 SO_SNDBUF=8192     #   socket options = TCP_NODELAY          # The following parameter is useful only if you have the linpopup package     # installed. The samba maintainer and the linpopup maintainer are     # working to ease installation and configuration of linpopup and samba.     ;   message command = /bin/sh -c '/usr/bin/linpopup "%f" "%m" %s; rm %s' &          # Domain Master specifies Samba to be the Domain Master Browser. If this     # machine will be configured as a BDC (a secondary logon server), you     # must set this to 'no'; otherwise, the default behavior is recommended.     #   domain master = auto          # Some defaults for winbind (make sure you're not using the ranges     # for something else.)     ;   idmap uid = 10000-20000     ;   idmap gid = 10000-20000     ;   template shell = /bin/bash          # The following was the default behaviour in sarge,     # but samba upstream reverted the default because it might induce     # performance issues in large organizations.     # See Debian bug #368251 for some of the consequences of *not*     # having this setting and smb.conf(5) for details.     ;   winbind enum groups = yes     ;   winbind enum users = yes          # Setup usershare options to enable non-root users to share folders     # with the net usershare command.          # Maximum number of usershare. 0 (default) means that usershare is disabled.     ;   usershare max shares = 100          # Allow users who've been granted usershare privileges to create     # public shares, not just authenticated ones         usershare allow guests = yes         username map = /etc/samba/smbusers          #======================= Share Definitions =======================          # Un-comment the following (and tweak the other settings below to suit)     # to enable the default home directory shares.  This will share each     # user's home directory as \\server\username     ;[homes]     ;   comment = Home Directories     ;   browseable = no          # By default, the home directories are exported read-only. Change the     # next parameter to 'no' if you want to be able to write to them.     ;   read only = yes          # File creation mask is set to 0700 for security reasons. If you want to     # create files with group=rw permissions, set next parameter to 0775.     ;   create mask = 0700          # Directory creation mask is set to 0700 for security reasons. If you want to     # create dirs. with group=rw permissions, set next parameter to 0775.     ;   directory mask = 0700          # By default, \\server\username shares can be connected to by anyone     # with access to the samba server.  Un-comment the following parameter     # to make sure that only "username" can connect to \\server\username     # This might need tweaking when using external authentication schemes     ;   valid users = %S          # Un-comment the following and create the netlogon directory for Domain Logons     # (you need to configure Samba to act as a domain controller too.)     ;[netlogon]     ;   comment = Network Logon Service     ;   path = /home/samba/netlogon     ;   guest ok = yes     ;   read only = yes     ;   share modes = no          # Un-comment the following and create the profiles directory to store     # users profiles (see the "logon path" option above)     # (you need to configure Samba to act as a domain controller too.)     # The path below should be writable by all users so that their     # profile directory may be created the first time they log on     ;[profiles]     ;   comment = Users profiles     ;   path = /home/samba/profiles     ;   guest ok = no     ;   browseable = no     ;   create mask = 0600     ;   directory mask = 0700          [printers]         comment = All Printers         browseable = no         path = /var/spool/samba         printable = yes     ;   guest ok = no     ;   read only = yes         create mask = 0700          # Windows clients look for this share name as a source of downloadable     # printer drivers     [print$]         comment = Printer Drivers         path = /var/lib/samba/printers     ;   browseable = yes         writeable = yes         guest ok = yes     # Uncomment to allow remote administration of Windows print drivers.     # You may need to replace 'lpadmin' with the name of the group your     # admin users are members of.     # Please note that you also need to set appropriate Unix permissions     # to the drivers directory for these users to have write rights in it     ;   write list = root, @lpadmin          # A sample share for sharing your CD-ROM with others.     ;[cdrom]     ;   comment = Samba server's CD-ROM     ;   read only = yes     ;   locking = no     ;   path = /cdrom     ;   guest ok = yes          # The next two parameters show how to auto-mount a CD-ROM when the     #   cdrom share is accesed. For this to work /etc/fstab must contain     #   an entry like this:     #     #       /dev/scd0   /cdrom  iso9660 defaults,noauto,ro,user   0 0     #     # The CD-ROM gets unmounted automatically after the connection to the     #     # If you don't want to use auto-mounting/unmounting make sure the CD     #   is mounted on /cdrom     #     ;   preexec = /bin/mount /cdrom     ;   postexec = /bin/umount /cdrom          [Public]         path = /home/peter/Public         writeable = yes     ;   browseable = yes         guest ok = yes      Edit: Samba not recognised, unable to start | stop | restart? Ideas? @Giles ![enter image description here](http://i.stack.imgur.com/8cLdI.png)


Installing MySQL 5.5 on Mac OS 10.6

I am trying to install MySQL from source on my Mac OS. I've expanded the source code, and am now trying to configure it. However, I can't get past that step:               My-MacBook-Pro-2:mysql-5.5.13-osx10.6-x86 my$ CC=gcc \     CFLAGS="-O3 -fno-omit-frame-pointer" CXX=gcc \     CXXFLAGS="-O3 -fno-omit-frame-pointer -felide-constructors -fno-exceptions -fno-rtti" \     ./configure --prefix=/usr/local/mysql --with-extra-charsets=complex \                 --enable-thread-safe-client --enable-local-infile \                 --enable-shared --with-plugins=innobase       -bash: ./configure: No such file or directory      I've run this command successfully on earlier MySQL versions, so not sure what the issue is.


Why does my system show only 3.2 GiB of RAM when I definitely have 4.0 GiB

I have 2x2 GiB sticks of RAM installed.   Running `memtest86` from the grub boot menu confirms this.. memtest86 reports no errors. However every which way I check my available memory in a running Ubuntu 10.04 system, it reports only approximately 3.2 GiB.   * `cat /proc/meminfo` == 3320132 kB   * `System Monitor` == 3.2 GiB    * `htop` == 3242 MB   * `free -m` == 3242 MB Who's got my _missing_ RAM ? Updated info: I just now _dual_ -booted into another version of Ubuntu 10.04 on the same hardware (I forgot I had installed it many months ago, for emergencies) :).... It reports 3.9 GiB, via `System Monitor`... I've posted my most recent `/var/log/messages` information at http://pastebin.ubuntu.com/629246/


Is '-9' a flag to kill command?

**What does`-9` do?** It does not show up in the syntax:               $ kill     kill: usage: kill [-s sigspec | -n signum | -sigspec] pid | jobspec ... or kill -l [sigspec]     $


How can I fix a partition conflict?

I am running Ubuntu 10.10 on a 250 gb hdd. I chose at installation to install all on one partition (it was recommended for beginners). Unfortunately, I need to use Windows 7 too. I didn't want to format the drive to install Windows first and Ubuntu after, so I used `gparted` to resize the 250 gb partition, and made a 65 gb NTFS primary. I installed Windows 7, but upon restart it boots automatically to Windows 7; I can't see Ubuntu. I did try to press shift many times to bring up GRUB, but it did nothing. What can I do in this situation?


How to use a password as an external variable in shell?

I have this MySQL backup script that I use to back up MySQL databases. Very useful, and it runs on fixed intervals using a cron. However, I need somehow provide this script with the MySQL password. This password is not the same on every server, but as I manage several servers, this particular script is part of a git-controlled repository that is synced together with some other scripts occasionally. Now, my question is: how can I use this same script as part of a git repo, if the password is different? The solution I can come up with is defining the password as an external/global variable in shell, rather than in the script itself, and that way my script can remain the same on every server. However, I am not sure what the proper way is to do so, nor am I sure if this is a good idea (security/best practices-wise). Any thoughts?


Embedded device: How to do raw reads and write to flash (emmc/movinand) bypassing file system cache

I have an embedded device with a flash memory running linux. I want to do raw read writes on the flash part but I also want to avoid any file system cache. How can I do this? Any pointers?


XFS vs Ext4 vs Others - which file system is stable, reliable, for long run such as 24/7 case

XFS and Ext4 file system which one is really stable and reliable for long run with heavy disk write and read?   * the system will be used in a place where 24/7 is in service, and every second there is read and write in the disk   * system need to be 99.95 % uptime for about 1 year run   * system need to be maximum downtime in year for about 20 hours maximum Which file-system is the best choice for such challenge? ( i wanted to use Solaris or FreeBSD but for my project i must have to use Ubuntu or ArchLinux or Fedora or CentOS). But confused with which file system to choose.


How to switch "/" back to writable mode without reboot?

[root@SERVER .ssh]# mount|grep -i " / "     /dev/mapper/rootvg-root_lv on / type ext3 (rw)     [root@SERVER .ssh]# mount -o remount /     mount: block device /dev/rootvg/root_lv is write-protected, mounting read-only     [root@SERVER .ssh]#       How can I make the "/" writable again without a reboot?               [root@SERVER ~]# lsb_release -a     LSB Version:    :core-3.1-amd64:core-3.1-ia32:core-3.1-noarch:graphics-3.1-amd64:graphics-3.1-ia32:graphics-3.1-noarch     Distributor ID: RedHatEnterpriseServer     Description:    Red Hat Enterprise Linux Server release 5.4 (Tikanga)     Release:    5.4     Codename:   Tikanga     [root@SERVER ~]#       UPDATE:               [root@SERVER ~]# lvdisplay rootvg/root_lv       Locking type -1 initialisation failed.     [root@SERVER ~]# lvdisplay rootvg/root_lv --ignorelockingfailure       --- Logical volume ---       LV Name                /dev/rootvg/root_lv       VG Name                rootvg       LV UUID                2Cccd4-oGrx-ssQW-xzK5-MZuA-g4NS-tFDFpd       LV Write Access        read/write       LV Status              available       # open                 1       LV Size                2.00 GB       Current LE             64       Segments               1       Allocation             inherit       Read ahead sectors     auto       - currently set to     256       Block device           253:0          [root@SERVER ~]# lvchange -p rw rootvg/root_lv       Locking type -1 initialisation failed.     [root@SERVER ~]#      [root@SERVER ~]# lvchange --ignorelockingfailure -p rw rootvg/root_lv       Only -a permitted with --ignorelockingfailure       Run `lvchange --help' for more information.     [root@SERVER ~]#       should I use the "-a" function?


$PATH duplication issues

If I do `echo $PATH` I get the following: > > /usr/local/bin:/usr/local/sbin:/usr/bin:/usr/sbin:/usr/local/share/npm/bin:/usr/local/share/python:/opt/X11/bin:/Users/kh/.rvm/bin:/usr/bin:/bin:/usr/sbin:/sbin:/usr/local/bin:/opt/X11/bin This is in my ~/.zshrc file: > export > PATH=/usr/local/bin:/usr/local/sbin:/usr/bin:/usr/sbin:/usr/local/share/npm/bin:/usr/local/share/python:/opt/X11/bin:$HOME/.rvm/bin:$PATH I've had to manually add /usr/local/etc... at the front of this file because homebrew was complaining. I've searched for all possibles files (I know of) to find where $PATH is being built from. But to no avail. These are               ~/.bash_profile     ~/.bashrc     ~/.profile      Any suggestions.


$2 (field reference) in awk BEGIN is not working

In the following snippet, `$2` in awk is returning empty. What am I doing wrong? I am trying to find the difference between MAX and MIN.               #!/bin/ksh     if [ $# -ne 1 ]; then             echo "Usage: sh `basename ${0}` filename";             exit 1;     fi     if [ ! -s ${1} ]; then             echo "file doesn't exist or is empty";             exit 1;     fi     sed -e '/^$/d' -e '/^#/d' ${1} |     awk  -F'=' '             BEGIN {                     MIN=$2; MAX=$2; print MIN;             }             {                     if ( $2 > MAX )                     {                             MAX = $2;                     }                     else if ( $2 < MIN )                     {                             MIN = $2;                     }             }             END {                     DIFF=MAX-MIN; print "DIFF:" DIFF;             }     '      However, this is working fine. Why doesn't `$2` work in the `BEGIN` section?               #!/bin/ksh     if [ $# -ne 1 ]; then             echo "Usage: sh `basename ${0}` filename";             exit 1;     fi     if [ ! -s ${1} ]; then             echo "file doesn't exist or is empty";             exit 1;     fi     sed -e '/^$/d' -e '/^#/d' ${1} |     awk -F'=' '             {                     if ( MAX == "" || MIN == "" )                     {                             MAX = MIN = $2;                     }                     else                     {                             if ( $2 > MAX )                             {                                     MAX = $2;                             }                             else if ( $2 < MIN )                             {                                     MIN = $2;                             }                     }             }             END {                     DIFF=MAX-MIN; print "DIFF:" DIFF;             }     '


ACL mask does not work as expected

If I copy a file with a base ACL of:               u::rw-,g::r--,o::r--      into a directory with a default ACL of:               u::rwx,g::r-x,g:users:rwx,m::rwx,o::r-x      I obtain a file with mask of `m::r--`. I would have expected the union of the permissions of the two group entries (i.e. `m::rwx`). Why it is so? Does it depend on the `mode` parameter used by `cp` in the creation of the file?


How to install a database dump via Shell Script?

I have a Mysql database dump. I want to install it with Hudson via a Shell Script to an external Linux machine. How can you take a Mysql script and run it inside a database on other machine? I know I can transfer files with sftp and use ssh when accessing another machines manually, but how to automate this all to a simple Shell Script?


Mutt: Automatically subscribe to IMAP mailboxes

I'm using a bunch of mailboxes in `mutt` which are populated by `imapfilter`. To avoid manual reconfiguration (by going to the folder list and pressing `s` at every new entry), I'd like to configure `mutt` to simply **subscribe to all IMAP folders except sent, trash and postponed on startup.** Is this possible without having to generate the configuration file?


Pluggin a bunch of USB hard drives into a Linux system?

I've got a Linux system with two USB 2.0 ports and one USB 3.0 port, and I would like to know how many USB hard drives I could plug into it. On the performance side, what would the I/O access be like as I add more and more drives? I expect I will have to have multiple levels of fan-out by plugging hubs into hubs to maximize the number of devices on each USB port. Would a tool like iostat tell me if all the disks share roughly the same bandwidth?


How to resume multiple instances of Screen from command line with minimal steps?

I have about 15 instances of screen running on my linux server. They are each running processes I need to monitor. I had to close terminal (hence the reason I launched screen). Is there a way to reopen all 15 instances of Screen in different tabs without having to open a new tab, login to the server, print all the available screens to resume, and then type in the id for each screen session?


How to refuse routes that are PUSHed by OpenVPN server?

When I establish an OpenVPN client connection over the Internet to our corporate OpenVPN server, it pushes several static routes. Unfortunately, these routes break some connectivity within my local network environment, as they collide with my own routes. How can I refuse those routes?


How to install mysql-server 5.6 on RHEL 5.8 (when MySQL-server 5.0 is already installed)

I want to install mysql-server 5.6 on RHEL 5.8, but when trying `rpm -i` or `rpm -Uvh` it complains that I already have version 5.0 on there. I am happy to replace, upgrade or install another instance. Please advise with steps.


Good distribution for Gnome shell

With Ubuntu pushing Unity, what distribution would you recommend if I just want to run Gnome 3 with the new Gnome shell? Personally, I'm interested in distributions which have the polish and support of Ubuntu, but feel free to recommend anything that makes it easy to run Gnome shell.


Clipboard for images

I often read some text with images and often happens that the text talks about an image that is on the next page and next page and previous page and I have to go back and forward and usually forget where I paused reading.   I got an idea to save the images to image clipboard which is able to contain about 5 images (e.g. with making small screenshot of the screen area). While reading when the text talks "see picture 10.4 (on page 42)" and in a few seconds "compare it to picture 10.2 (on page 40)" I could press only keyboard shortcut and select the desired picture without browsing through the text.   Is this possible in X Window System? Or with some script?


What's the reason that "rm -rf a/b" says "a/b is not empty"?

The following script _sometimes_ gives me things like `can't remove a/b as it's not empty`               ssh -T user@host <<EOF       cd somewhere       rm -rf a/b         EOF      But I log in to the server and execute `rm -rf a/b` then I never had the problem. There are other processes that are generating files to `a/b`, is that related? Anyway, how to make a script that will ensure "a/b" will be deleted?


Getting logged out of user account upon execution of a program

On my friend's computer when Skype is launched either via terminal or GUI the current user is forced to log out of the system. Purging and reinstalling Skype did not work and we are using the same version of Ubuntu, that is 12.04.4 LTS 32-bit, and both our installed Skype programs are of the same version, namely 4.2.0.11. What may be the cause behind this and how can this behaviour of Skype avoided? Is it a bug or something related with installed programs etc. ? Any help is appreciated. EDIT: The log files are as follows and my friend also stated that when he tried to have a look at these files in Emacs he got kicked out of the system again: **skype-err.log**               skype: Fatal IO error 11 (Resource temporarily unavailable) on X server :0.      **.xsession-errors**               Warning: Only changing the first 12 of 24 buttons.          (gnome-settings-daemon:6738): power-plugin-WARNING **: gnome-session is not available     Backend     : gconf     Integration : true     Profile     : unity     Adding plugins     Initializing core options...done     Initializing composite options...done     Initializing opengl options...done     Initializing decor options...done     Initializing mousepoll options...done     Initializing gnomecompat options...done     Initializing grid options...done     Initializing snap options...done     Initializing resize options...done     Initializing move options...done     Initializing unitymtgrabhandles options...done     Initializing place options...done     Initializing vpswitch options...done     ** Message: applet now removed from the notification area     Initializing wall options...done     I/O warning : failed to load external entity "/home/jack/.compiz/session/102004b2d250ec54c7139932580828939400000066890035"     Initializing session options...done     Initializing animation options...done     Initializing workarounds options...done     compiz (expo) - Warn: failed to bind image to texture     Initializing expo options...done     Initializing ezoom options...done     Initializing staticswitcher options...done     ** Message: using fallback from indicator to GtkStatusIcon     Initializing fade options...done     Initializing scale options...done          (compiz:6756): GConf-CRITICAL **: gconf_client_add_dir: assertion `gconf_valid_key (dirname, NULL)' failed     Nautilus-Share-Message: Called "net usershare info" but it failed: 'net usershare' returned error 255: net usershare: cannot open usershare directory /var/lib/sa$     Please ask your system administrator to enable user sharing.               Initializing unityshell options...done     Setting Update "main_menu_key"     Setting Update "run_key"     Setting Update "run_command_terminal_key"     Setting Update "icon_size"     ** Message: moving back from GtkStatusIcon to indicator          ** (zeitgeist-datahub:7185): WARNING **: zeitgeist-datahub.vala:227: Unable to get name "org.gnome.zeitgeist.datahub" on the bus!     [7193:7193:0506/003710:ERROR:nss_util.cc(853)] After loading Root Certs, loaded==false: NSS error code: -8018          ** (nautilus:6770): WARNING **: Error calling current_status: Method "current_status" with signature "" on interface "com.ubuntuone.SyncDaemon.Status" doesn't ex$               ** (nautilus:6770): CRITICAL **: syncdaemon_status_info_get_online: assertion `SYNCDAEMON_IS_STATUS_INFO (sinfo)' failed     No bp log location saved, using default.     [000:000] Cpu: 6.37.2, x4, 2267Mhz, 3887MB     [000:000] Computer model: Not available     [000:003] Warning(clientchannel.cc:472): 0xb8304550: Unreadable or no port file.  Could not initiate GoogleTalkPlugin connection     [000:003] 0xb8304550: SendConnectStatus: Connect Status:     [             "f-connect",                  {                     "error" : -1,                     "step" : "0"             }     ]          [000:004] Warning(clientchannel.cc:445): 0xb8304550: Could not initiate GoogleTalkPlugin connection     [000:004] 0xb8304550: GoogleTalkPlugin not running. Starting new process...     [000:004] Starting Flute     [000:004] Warning(pluginutils.cc:268): Failed to get GoogleTalkPlugin path. Trying default.     [000:006] Started GoogleTalkPlugin, path=/opt/google/talkplugin/GoogleTalkPlugin     [000:006] 0xb8304550: SendConnectStatus: Connect Status:          [             "f-connect",                  {                     "error" : -1,                     "step" : "0"             }     ]          [000:004] Warning(clientchannel.cc:445): 0xb8304550: Could not initiate GoogleTalkPlugin connection     [000:004] 0xb8304550: GoogleTalkPlugin not running. Starting new process...     [000:004] Starting Flute     [000:004] Warning(pluginutils.cc:268): Failed to get GoogleTalkPlugin path. Trying default.     [000:006] Started GoogleTalkPlugin, path=/opt/google/talkplugin/GoogleTalkPlugin     [000:006] 0xb8304550: SendConnectStatus: Connect Status:     [             "f-connect",                  {                     "step" : "2"             }     ]          [000:006] 0xb8304550: Waiting for GoogleTalkPlugin to start...     [001:108] 0xb8304550: Attempting to connect to GoogleTalkPlugin...     [001:108] Read port file, port=55429     [001:108] 0xb8304550: SendConnectStatus: Connect Status:     [             "f-connect",                  {                     "step" : "0"             }     ]          [001:109] 0xb8302d20:  sending cookie Z2CZ//Bddv3VJWxk     [001:109] 0xb8304550: SendConnectStatus: Connect Status:     [             "f-connect",                  {                     "step" : "1"             }     ]          [001:110] 0xb8304550: Initiated connection to GoogleTalkPlugin     [001:209] 0xb8304550: SendConnectStatus: Connect Status:     [             "f-connect",                  {                     "step" : "3"             }     ]          [001:232] 0xb8304550: Socket connection established     [001:232] 0xb8304550: ScheduleOnlineCheck: Online check in 5000ms     [001:236] 0xb8304550: C->F: ["comment","BC state change: 2 to 3. Error? 0"]     [001:254] 0xb8304550: C->F: ["comment","BC state change: 3 to 4. Error? 0"]     [001:309] 0xb8302d20: Got cookie response, socket is authorized     [001:309] 0xb8304550: AUTHORIZED; socket handshake complete     [001:349] 0xb8304550: C->F: ["mf",2,{"appName":"googlemail","buildLabel":"gmail_fe_140429.00_p4","buildCl":"65973900","compileMode":"OPTIMIZED,LOCALE=tr","estima$     [001:353] 0xb8304550: F->C: ["fs",{"pr":"a"}]     [001:417] 0xb8304550: F->C: ["mf","mf5.3","5.3.1.0",2,{"audioCodecs":[[103,"ISAC",1,0,16000],[111,"opus",2,64000,48000],[104,"ISAC",1,0,32000],[109,"CELT",1,6400$     [001:435] 0xb8304550: C->F: ["getdevicestate"]     [001:441] 0xb8304550: F->C: ["getdevicestate","15","0",["__default_device","Built-in Audio Analog Stereo"],"0",["__default_device","High Definition Audio Control$     [001:589] 0xb8304550: C->F: ["jec",[[96,"H264-SVC",320,200,30]],{"num_threads":-1,"cpu_profile":1}]     [001:631] 0xb8304550: C->F: ["jf",[["stun.l.google.com","19302"]     ,["alt3.stun.l.google.com","19302"]     ,["alt2.stun.l.google.com","19302"]     ,["alt4.stun.l.google.com","19302"]     ,["alt1.stun.l.google.com","19302"]     ]     ,["CAESGwoSamFja2FyYXpAZ21haWwuY29tEN+V0YDdKBoQzrz8rti0zAEr12uU4bzj5g\u003d\u003d",["relay.google.com","19305","19305","443"]     ]     [001:634] 0xb8304550: C->F: ["jec",[[96,"H264-SVC",640,400,30]],{"num_threads":-1,"cpu_profile":31}]     [006:260] 0xb8304550: HandleOnlineCheck: Starting check     [006:260] 0xb8304550: HandleOnlineCheck: OK; current state: 3      As far as I am concerned X is the culprit. I would like to hear you feedback and suggestions for possible remedies. Thanks


Is there a way to find all X resources an application uses?

I'm looking for a way to automatically list all X resources that are used in an application. To give you an example, for `xterm` I'd expect a list similar to the following but with _all_ the resources that are used by `xterm`.                background      foreground      cursorColor      vt100.geometry      scrollBar      scrollTtyOutput      ...      The method can work on the source code of the application but if it is possible to do it with only the application binary that would also be interesting.


Slow down the CPU

I tried to slow down my CPU with `powernowd` and `cpufreq-selector`. I hoped that with lower frequency it will be less hot and I won't hear my fan every time I will run internet radio. I used the following commands               sudo cpufreq-selector -f 800000      and               sudo powernowd -m 0 -l 40 -u 60      but this wasn't sufficient for more quiet laptop. My CPU is > Intel(R) Pentium(R) M processor 1.60GHz Could you advise me on how to make it run cooler / quieter? I solved it yesterday with `sudo cpufreq-selector -g powersave`


Can one directory be owned by two groups?

Can one directory be owned by two groups (RHEL 6.2)? I have created one directory: `mkdir /opt/shared`, then I created two groups: `groupadd sales` `groupadd marketing` I added manually to each of these groups 21 users, then I changed the ownership `chown root:sales /opt/shared` and `chown root:marketing /opt/shared`. Then I changed the unmask `chmod 2775 /opt/shared` The problem is, only group `marketing` have permission to `rwx`.


make wget refer to a local copy without redundantly downloading files

I want to archive a message board,I do that by using wget with the parameters: `\--page-requisites`, `\--span-hosts`, `\--convert-links` and `\--no-clobber`. The problem is that using `\--convert-links` disables `\--no-clobber`. for every thread page, wget re-downloads site skins, scripts and icons(For the purpose of keeping them updated). Is there a way to prevent wget from downloading files that already exist locally, referring links to files to their local copies and only downloading files that aren't already in the filesystem?


Why does [a-z] asterisk match numbers?

I have 3 directories at current path.               $ls     a_0db_data  a_clean_0db_data  a_clean_data     $ls a_*_data     a_0db_data:          a_clean_0db_data:          a_clean_data:          $ls a_[a-z]*_data     a_clean_0db_data:          a_clean_data:      I expected last ls command to match only `a_clean_data`. Why did it also match the one containing `0`?               bash --version     GNU bash, version 4.2.24(1)-release (i686-pc-linux-gnu)


How can I write a non-breaking space?

When I write a question, I'd like the space between the final word and the question mark to be non-breaking, and this very sentence is an example of it (this is why it is awkward), how can I do that ?


Can two hosts have the same IP address in /etc/hosts?

can two hosts share the same IP Address without a conflict. This is how my /etc/hosts looks like :-               $ cat /etc/hosts     127.0.0.1   localhost     127.0.1.1   debian     127.0.1.1       mini      Now as can be seen both mini and debian share the same IP Address. Now debian is my hostname.               $ hostname     debian      while mini is a virtual host for an apache site.               /etc/apache2/sites-available$ head minidebconfindia.conf      <VirtualHost mini:80>     ServerAdmin webmaster@localhost      This is in Apache 2.4. I am just not sure whether this is good or not. A friend of mine has the same setup (with a different hostname) on Apache 2.2 and that works without issue. Looking forward to know if this is valid or should I be doing any changes ?


AIX open() : file descriptor is zero (!?)

A daemon process, on detecting the presence of a text file in a particular directory then launches an executable file which opens the aforementioned text file in order to read and then transmit its data over a TCP socket. The number of the file descriptor of the opened text file is logged along with other information about the processing of the file. It has been noticed that from time to time, the file descriptor returned by the open() call is zero (normally this is reserved for stdin). No error is detected and all works well. The source code in C does nothing more that open() and later close() - there is no redirection, duplication or any other wizardry performed on the returned file handle. Under what circumstances could a process's file descriptor 0 be available for general use (and not attributed to stdin) ? Platform is AIX 5.2.


Make GNU indent break long comments

Is there a way to convince GNU indent to break long comment and change it to multiline comment? Something like this:               // Very long comment, longer than 80 characters. Just imagine that.      To this:               /*      * Very long comment, longer than 80 characters. Just      * imagine that.      */      I know that formatting second one can be done simply by '-cdb -sc', but I don't know how to ensure line break and comment type change. Is it even possible?


Keep a PHP script running indefinitely on a Web Server

I'm having a pretty big issue that I need to get resolved. Basically I have little experience using `Linux` and I've been working on a project recentley that involves me having to use quite a lot of `Linux` commands to run `php scripts` on my web server. Basically I've two scripts   1. get_tweets.php   2. parse_tweets.php I need these to be running constantly for the next 3 - 4 weeks on my web server. I use the following command to get them to run and they seem to last for the day but when I check in the morning they seem to have stopped working! `nohup php get_tweets.php > /dev/null &` and then `nohup php parse_tweets.php > /dev/null &` I know that by using `&` I can keep the scripts running in the `background` and they run when I log out of `ssh` but like I said they seem to run fine all day then when I check in the morning they've stopped. The issue I am having is how I can keep them running non stop. Is there a simple `script` I could write to check if they are running and if not then restart them or perhaps restart them every 5 hours or something? I'd appreciate any help guys as this is quite a big issue and I've got no idea how to resolve it.


Why can't new versions of kernel solve the backlight problem?

Currently I am using Linux 3.8.0-27-generic kernel on my Samsung laptop. I replaced grub configuration file with the following text to make backlight control work:               GRUB_CMDLINE_LINUX_DEFAULT="quiet splash acpi_osi=Linux acpi_backlight=vendor"      I do not know if doing this causes a regression. If not, why is this not being included in the never version of kernels? There are not millions of computer manufacturers and at least this could be hardcoded, right?


how to add line in a /etc/sudoers file with the help of shell script (50servers)?

Anyone can help me with shell script, I want to know script which can edit `/etc/sudoers` file and let me add `{{{{{userid ALL=(root) ALL}}}}` to 50 server I have on same network?


Periodically get new lines from file, possibly logrotated

I'm looking for a fairly simple way (no development involved -- I could write this in Python but I'm hoping there's something already out there). I have a log file (in my case written by rsyslogd). For analytics purposes I want to read it every 1 minute and calculate metrics for the last minute e.g. how many page hits my http server had. My 2 requirements: 1) I only want to look at the lines that were added since I last read the file. (I only need the last minute or so, and the file is too large to re-read and filter every minute). 2) Once a day the file gets logrorate'd. The first time after log rotation I want all of the lines from the previous file I haven't yet read, plus all of the lines from the new file. I assume I'm now the only one with such requirements -- what do others do?


Diff similar lines

I'd like to print a list of lines where the first word in two files is identical, and the rest of the words are not. Some complicated mess with `comm`, `grep` and `cut` would be possible, but hopefully there's a simpler way. **Edit** : I've managed to slap together some working code. Example tests:               $ cat file1     a 1 E     b 2 F     c 3 G          $ cat file2     a M X     b 2 Y     c 3 G          $ difff 1 file1 file2 # Differences in fields 2+3     1,2c1,2     < a 1 E     < b 2 F     ---     > a M X     > b 2 Y          $ difff 1-2 file1 file2 # Differences in field 3 only     1c1     < b 2 F     ---     > b 2 Y      **Edit 2** : The speed is now bearable (compares two files of 1800 and 8700 lines in half a second).


How to remove/change the message displayed when opening a terminal?

Using Ubuntu 10.10 .In GUI mode when I open up a terminal, a message is displayed at top left above the prompt: `Ghost@work-Ubuntu:~$` , I would like to change it, so I would like to know in which file the message is saved in order to access it or maybe commands to remove the message. **Edit:** When I open a terminal in gui.need to remove the message on top               You seem confused     Ghost@work-Ubuntu:~$


Why does the "du" command count in 4KB steps?

> **Possible Duplicate:**   >  Directory size calculation difference I don't understand how the `du` command under Linux works. I wanted to count the overall size of a few hundred, small files and `du -sh` returned something along the lines of 150MB. I didn't question it until I realized my file manager displayed only around 50MB for the same set of data and I got confused. Here's what I then tried:               fkochem@WK-6:~/temp$ cat test      a     fkochem@WK-6:~/temp$ du -sh test      4.0K    test      So, now this must be a mistake? I looked at `du -sh *` of my original data and found the following:               4.0K    NCO-0.9.9.9.json     4.0K    NCO-0.99.9.json     4.0K    NCO-0.9.9.json     8.0K    NCO-0.99.json     8.0K    NCO-0.9.json      Why does `du` seem to count in 4KB steps? What am I missing here?


Deploying code on a bunch of machines

I have some binaries and code to be deployed to various environments. I currently use pexpect library in python to connect and rsync over sash to sync the code. Currently the method uses push mechanism to deploy. Is there a better way to do this? Is pull mechanism better. Any suggestions?


Unable to type some special characters in vi on a debian

on a machine I have access to, when I type "€" in vi, "~B� " is displayed instead, and when I type "£", "£ " What can cause this strange behavior, how can I fix it? Typing it in the console gives even less results. `locale` output :               locale: Cannot set LC_CTYPE to default locale: No such file or directory     locale: Cannot set LC_ALL to default locale: No such file or directory     LANG=en_US.UTF-8     LC_CTYPE=fr_FR.UTF-8     LC_NUMERIC="en_US.UTF-8"     LC_TIME="en_US.UTF-8"     LC_COLLATE="en_US.UTF-8"     LC_MONETARY="en_US.UTF-8"     LC_MESSAGES="en_US.UTF-8"     LC_PAPER="en_US.UTF-8"     LC_NAME="en_US.UTF-8"     LC_ADDRESS="en_US.UTF-8"     LC_TELEPHONE="en_US.UTF-8"     LC_MEASUREMENT="en_US.UTF-8"     LC_IDENTIFICATION="en_US.UTF-8"     LC_ALL=      Inside vim (I explicitely tried using vim with an 'm'):               :set enc     encoding=latin1      This looks very wrong... Typing `:set encoding=utf-8` solves the problem, but how can I make my system use utf-8 everywhere? The problem I'm trying to solve is the fact that a fixture file for my database seems to be interpreted as `latin1` by php...


How to fail prerm script and preinst script with error message in Debian package

I structured my debian package in following way   * `preinst script` which displays EULA to user and ask for choice 'y' or 'n'.   * `postinst script` which install the package and updates the initrd image.   * `prerm script` ,before uninstalling package checks for a condition if the condition matches then it exits from prerm with `exit 1`.   * `postrm script` unloads the package if the check in prerm script fails and it update the initrd image. Now I have the following questions   1. Lets say package is already installed on machine and user is trying to reinstall or upgrade it .Now if user says 'yes' to EULA, what debian will do? I observed it simply -uninstall previously installed package and reinstall it which is perfectly fine.But if user says 'n' to EULA how would I exit from uninstallation process? I did it adding `exit 1` in preinst script but its not working.I observed that if you say `dpkg -i package` ,debian first checks if package is already installed, If package is already installed then it unpacks the package even before calling preinst script(`checked it using lsmod) so if you say 'n' to EULA it starts rolling back the changes i.e reinstalling unpacked package by calling postinst script which looks like weird behaviour to end user as user has already said 'n' to EULA.I tried adding a check if module is present the do not re install it but as I said whenever you say dpkg -i package ,debian first removes the module and fails my check.So how can avoid reinstalling package if user says no to EULA?    2. If I say `dpkg -r package` and my `prerm script fails and exits with status 1` .Here the same thing happens as above.If you say `dpkg -r package` ,debian unloads the package before calling prerm script then it checks for the condition in `prerm` if it matches it exits from it and starts rolling back the changes by calling postinst script which is once again weird behaviour. I know it's the default behavior of Debian but what if I want to override default behaviour?


Kickstarter-like solution for OpenBSD?

Are there any solutions for OpenBSD to just: Insert the custom installer CD, press enter (like: "are you sure?" - message), then the installer automatically partitions the disk/installs OpenBSD, and then customize it a little (ex.: install a few apps from ports)? This can be done using Kickstarter for RHEL. **But can it be done for OpenBSD?** I googled for it and didn't found any good yet (only that needs bigger programming skills..).


Can linux use a mix of SHA-1 and CRYPT passwords?

We have an automated sync-routine that uses `useradd` to create new users on a Ubuntu 10.04 machine. The application launching the routine provided both username and `CRYPT`-encrypted password. However, since we changed how passwords are handled in order to include LDAP support, passwords now don't have to be `CRYPT` but can also be `MD5` or `SHA-1`. In fact, `SHA-1` is the new default. This however now causes problems. I have read up on how `/etc/shadow` is handled and there doesn't seem to be an id for `SHA-1`, only for `SHA-256`/`SHA-512`(`$5$` and `$6$` respectively). The only thing I found was to change the whole thing from `CRYPT` to `SHA-1`. We could do that, but we wanted the whole transition to be as non-disruptive as possible. **Is there a way to use both`CRYPT` and `SHA-1` passwords together?** NOTES   - The main application is a CMS on an entirely different server. The linux server in question is a local machine(slave) at the client's location in order to provide local services.   - We are aware that we could switch the entire system out to use LDAP-only, but, as outlined earlier, we don't want to change everything at once.


apt-get purge <packages> works fine, aptitude still has <packages> marked as installed and reinstalls them

I've created a Rubygem to help with removing old kernels that have built up over years and are eating disk space. (My laptop had 19 kernels on it alone, and on a small SSD...) I want to use apt-get or dpkg as the uninstaller since some people will not have aptitude installed and I do not want users of the gem to have to install anything. The problem comes when _some_ users do use `aptitude` for other things. Scenario:   1. User uses my gem which successfully `apt-get purge`'s the kernel packages.   2. User starts `aptitude` in interactive mode for any reason,   3. User presses the 'g' key (Download/Install/Remove Pkgs) immediately without marking any changes, -->   4. `aptitude` re-downloads and re-installs the packages that `apt-get` had purged. Currently, the gem uses `apt-get purge <packages>` to purge the kernel packages. (Seen here.) I also tried with `dpkg --purge <packages>`, but the result is the same, aptitude still wants to reinstall them. I've read through the entire `aptitude` manual and googled many things, no dice. _Maybe_ I could programmatically manage `aptitude`'s marked/unmarked packages list if I could find where it is (although I'd prefer a cleaner solution.) I assume it's not `/var/lib/dpkg/status` or else there would be no disparity? dpkg-query shows the package `status` as `Not` and the `desired` state as `Unknown`.               deKernel$ dpkg-query -l linux-image-3.2.0-39-generic     Desired=Unknown/Install/Remove/Purge/Hold     | Status=Not/Inst/Conf-files/Unpacked/halF-conf/Half-inst/trig-aWait/Trig-pend     |/ Err?=(none)/Reinst-required (Status,Err: uppercase=bad)     ||/ Name                                       Version                                    Description     +++-==========================================-==========================================-====================================================================================================     un  linux-image-3.2.0-39-generic               <none>                                     (no description available)     deKernel$      It's possible to go into aptitude and manually un-mark those kernel packages and the problem disappears, however this is obviously quite impractical.


Trying to open a GUI from a remote server using Mac but not succesfully

I'm brand new user in MacOSX. I'm using ssh to connect to some Linux servers. I'm trying to open a GUI locally for a process running in the remote Linux server. So I read that I should install XQuartz which is used for the X11 in the Mac.   I installed it but when I try to start the GUI I get error that DISPLAY is not set. Indeed when I `echo DISPLAY`, nothing has been set. Am I supposed to set something manually? I also noticed that there is some command line as part of the XQuartz installation. Am I supposed to use only this command line? When I start it and `echo DISPLAY` I see just :0.0. How can I configure this? I tried `ssh -X` to connect and additionally I also checked out the X-11 FAQ According to this something overrides my `DISPLAY` on the local machine. I suspect that TextMate which I installed previously does this, but I'm not sure how can I override it. What should I set? What is: `/tmp/launch-Bh0fLm/:0`?


Problem connecting to linksys wireless using zenwalk

I just recently installed zenwalk linux on my machine, and I am having trouble connecting to my wireless router. I am using the appropriate options such as use encryption, WEP passphrase, the correct passphrase, and so on. It sits there for a minute and gives me an error message of "connection failed: bad password". I have tried everything possible in my power as far as troubleshooting goes. I tried running the wireless configuration through terminal, but I don't believe I am skilled enough to do such a task, as I have not been successful thus far. If anyone is able to help it is much appreciated. Thanks


What is the difference between ioctl(), unlocked_ioctl() and compat_ioctl()?

Going through the linux 2.6.36 source code at lxr.linux.no, I could not find the `ioctl()` method in `file_operations`. Instead I found two new calls: `unlocked_ioctl()` and `compat_ioctl()`. What is the difference between `ioctl()`, `unlocked_ioctl()`, and `compat_ioctl()`?


Rsync two file types in one command?

How to write those into one line, also without repeat the same path?               rsync -a root@somewhere:/folder/remote/*.txt .     rsync -a root@somewhere:/folder/remote/*.jpg .


I need to check a list of directories if it contains a directory newer than 1 month before now

Maybe the title is quite confusing so i'll try to explain what i have done until now. First of all i have build the list of directories i want to investigate with the code below:               $MDIR="/home/user/scripts/fcron"     DIRS=`ls -l $MDIR | egrep '^d' | awk '{print $9}' | grep ^$ts-`      The DIRS list now contain directory **_names_** of the form :               NETGEAR-2013-06-30     NETGEAR-2013-07-01     ........     NETGEAR-2013-05-05      Now i need to check all those directories ( **contained in list DIRS** ) and i need to find one that is newer than 1 month before now (e.g 27 or 29 days). In case i find one match i need to exit the script. In 'pseudocode' i would write:               for dir is DIRS:         if dir is newer than 30 days old:            exit the script         else:            continue      My difficulty is in translating just the above 'pseudocode' in a bash script. /////Latest Update///// OK i have updated the part with the pseudocode with this:                   for DIR is $DIRS;         do         if (( $(stat -c %Y "$dir") < $(date +%s) - 3600*24*30 )); then             echo "exiting!!"                exit         else             continue         fi         done      But now i am getting this :                line 40: syntax error: unexpected word (expecting "do")