How can I edit symlinks?

My basic understanding of a symlink is as a special file, a file that contains a string path to another file. The kernel's VFS abstracts a lot of that away but is there any reason why symlinks seem to be impossible to edit? In other words: Can I edit a symlink? If not, why not? * * * I do understand that there are various ways of _replacing_ symlinks (two alternatives are currently in the answers section) but it would be interesting to get an explanation on why replacement seems to be the only way to deal with symlinks. Why can't you just change where they point?


how to change where a symlink points

![enter image description here](http://i.stack.imgur.com/gJh91.png) Can you tell me what is this in red marker area. ? and if want to change /media/files/tb-prod/files to some other path, then how it will be .. ?


Creating multicast join for tcpdump captures

I want to write a linux shell script which will capture specific multicast traffic. Specific as in, I want to create a pcap file that has all the traffic for one specific multicast group/port. Here is the command line I am using to view traffic:               tcpdump -nnXs 0 -i eth1 udp port 22001 and dst 233.54.12.234      This works fine so long as I have a multicast subscription to that group already established. For example, if I run this in another console:               mdump 233.54.12.234 22001 10.13.252.51      `tcpdump` will see packets. If `mdump` is not running, `tcpdump` sees nothing. Is there a standard linux-y way to establish these multicast joins before starting the captures? I could use `mdump` to establish these joins, but that seems wasteful since `mdump` will process all that data on the group, bbut I'm just going to throw it away. Note that because my specific environment, I have been discouraged from putting the interface in to promiscuous mode. It may, in fact, be prohibited.


Should I install ibus-1.0 to build Webdriver?

In the process of building one library (Webdriver) I got the following error:               Package ibus-1.0 was not found in the pkg-config search path.     Perhaps you should add the directory containing `ibus-1.0.pc'     to the PKG_CONFIG_PATH environment variable     No package 'ibus-1.0' found      It seems to be because of the following line in source code of Webdriver:               pkg-config ibus-1.0 --libs      that produces the same output when I run it. So I installed `ibus` using installation instructions from its website:               sudo apt-get install ibus ibus-clutter ibus-gtk ibus-gtk3 ibus-qt4      But I still get the same output after invoking `pkg-config ibus-1.0 --libs`. Should I install ibus 1.0 to build that library? If yes, where can I find it? It doesn't seem to be present in ibus's downloads list? My OS is Ubuntu 13.04


Dumping multicast UDP stream with socat

I am setting up video streaming. In local network, there are two devices streaming video over UDP multicast. One is regular computer with Linux (streaming to 239.220.221.10, port 9200), second one is special DVB-S streamer (streaming to 239.220.220.32, port 9200). There are several IPTV set-top boxes in the network, which are able to play streams from either source. There are also some Cisco switches for multicast filtering, but I am not able to check their configuration. On different computer (running Ubuntu 12.04) I would like to capture the stream, preferably using VLC or FFMPEG. From the computer streamer (239.220.221.10) it works, but from special streamer (239.220.220.32) I get no stream. **What I tried** I tried to narrow down the problem and tried to capture raw UDP datagrams with socat and tcpdump. If I run following command, I get valid video in video.dump file:               > socat UDP4-RECVFROM:9200,ip-add-membership=239.220.221.10:0.0.0.0 - > video.dump      When I simultaneously run tcpdump, I see incoming datagrams:               > sudo tcpdump -i eth1      18:00:39.059824 IP 10.1.2.202.41852 > 239.220.221.10.9200: UDP, length 1316     18:00:39.060789 IP 10.1.2.202.41852 > 239.220.221.10.9200: UDP, length 1316     ...      When I try to run same commands for the special streamer (just change the IP membership address for socat to 239.220.220.32), tcpdump shows incoming datagrams from 239.220.220.32, but video.dump file is empty. What can be the reason that `socat` doesn't see the datagrams that are clearly coming? **Update on 4 March 2014:** I just found out that there are different IP ranges in the network:               Computer streamer: 10.1.2.202 / 255.0.0.0     "Special" streamer: 192.168.85.5 / 255.255.255.0     Computer on which I am trying to grab stream: 10.1.2.203 / 255.0.0.0      When I change IP adress of the last to 192.168.85.x / 255.255.255.0, I can catch streams from the "Special" streamer, but not from the computer streamer. So the question changes to: Is it possible to set socat, VLC or FFMPEG to accept also multicast streams that have source address outside the range of ethernet interface?


Subversion repository on NTFS drive

I am trying to use my repos that is located on an NTFS formatted drive. I am dual-booting Windows 8.1 and Arch Linux. I am running subversion 1.8.5 and apache 2.2.26 with SSL. The problem seems to be related to httpd not being able to open the files where the repos are located.   This is what is added to the **/var/log/httpd/error_log** :               [Sat Mar 01 17:54:58 2014] [notice] caught SIGWINCH, shutting down gracefully     [Sat Mar 01 17:54:59 2014] [warn] RSA server certificate is a CA certificate (BasicConstraints: CA == TRUE !?)     [Sat Mar 01 17:54:59 2014] [warn] RSA server certificate CommonName (CN) `toi' does NOT match server name!?     [Sat Mar 01 17:54:59 2014] [notice] suEXEC mechanism enabled (wrapper: /usr/bin/suexec)     [Sat Mar 01 17:54:59 2014] [notice] Digest: generating secret for digest authentication ...     [Sat Mar 01 17:54:59 2014] [notice] Digest: done     [Sat Mar 01 17:55:00 2014] [warn] RSA server certificate is a CA certificate (BasicConstraints: CA == TRUE !?)     [Sat Mar 01 17:55:00 2014] [warn] RSA server certificate CommonName (CN) `toi' does NOT match server name!?     [Sat Mar 01 17:55:00 2014] [notice] Apache/2.2.26 (Unix) mod_ssl/2.2.26 OpenSSL/1.0.1f DAV/2 SVN/1.8.5 configured -- resuming normal operations     [Sat Mar 01 17:55:03 2014] [error] [client 127.0.0.1] (13)Permission denied: Failed to load the mod_authz_svn config: Can't open file '/run/media/toi/StorageA/repos/.svn-policy-file': Permission denied     [Sat Mar 01 17:55:06 2014] [error] [client 127.0.0.1] (13)Permission denied: Could not open password file: /run/media/toi/StorageA/repos/.svn-auth-file      I have tried many different ways of mounting the ntfs drive without success. The automatic mount with nemo doesn't even allow me to create a file on the drive. I tried mounting it with the ntfs-3g driver and could now create files through nemo and the terminal. I could even set permissions for the folders on the drive (with -o permissions when mounting).   I tried `chown -R http:http /mnt/thedrive/repos` and it seemed to kick in. `ls -a -l` showed http as owner with `drw` permissions. However httpd still couldn't read any of the files. I even tried `chmod 777` on the repo folder but to no avail.      I just recently started using Arch Linux (been using ubuntu or mint before from time to time) so I may just be doing something wrong.   The server seemed to work fine on my ext4 partition. I used the subversion guide on the Arch wiki to set subversion up.      If i recall correctly i managed to setup a working subversion when i was running Mint on the NTFS drive, but i messed the installation up and decided to go for Arch to learn more.      Simply put what I am trying to achieve is to have subversion control on both Windows and Arch without having to copy repos every time i change OS. This may be quite unconventional but would be nice if it could be achieved.      So could it be related to permissions or am I just interpreting the error messages wrong? Any ideas what the problem could be?


Do processes in cgroups have to be set every boot? If so, how to persist them?

I was reading this answer to a question on setting limits for processes by using cgroups. The sample given sets limits for a process (in the example, `sshd`). In the answer, the PID of the process is set manually. This would be unacceptable for my purposes, I would like that processes started from a given application to always have the limits set, no matter when they are started nor limited by how many such processes are started. Perhaps it is unclear from the example how that would happen, so a clear explanation or link to one would also be welcome. The example in the kernel cgroups.txt seems to use the same model as already given above.


Can anything useful be done with a truncated core?

We have processes written in a mix of Python, Java and C++ that core dump from time to time. They allocate more memory in chunks as needed during runtime, and are known to crash when their allocation tips over 4G (I guess the return value of the `malloc()` isn't checked). However the core dumps produced are truncated, according to GDB - they are unlimited in size in the OS, and on-disk they vary between 2-3.8G in size. GDB observes that the size doesn't match what it expects (presumably including the failed alloc?) and gives up - but in 3.8G of data there surely must be _something_ of interest? Possibly even the entire stack I need for a backtrace! How can I persuade GDB to at least try, or is there an alternate tool that can extract something from a truncated core?


sed match pattern N times

I want to split a file into chunks with 2 words each.               $cat tmp     word1 word2 word3 word4 word5 word6 word7     $sed -e 's/word. word. /&\n/g' tmp     word1 word2      word3 word4      word5 word6      word7     $sed -e 's/word. \{2\}/&\n/g' tmp     word1 word2 word3 word4 word5 word6 word7      I expected the last command to give same result as the one before it. What is wrong?


I have submitted my first kernel patch, what next?

I have managed to submit my first kernel patch following these steps. I have also read this book so I have an idea of which subsystem I might get into. However, the details of where to go next seem a little unclear. Do I continue working on patches? Do I join a mailing list, if so then what? What is the conventional sequence of steps one must follow after that all important first patch? Edit: I am not looking for an opinion on what an individual thinks is best. I know I am going to contribute to a subsystem. I am merely asking if there is an official "step 2" in this process after the "step 1" I described above as I have not seen any written documentation to that effect.


Book on Linux kernel driver development

What good books are there out there for Linux kernel driver development? Preferably targeting a rather new kernel release. Which one is best in you opinion?   * Essential Linux Device Drivers   * Linux Device Drivers


Which kernel does reboot load?

I am using ssh to remotely access some machines. These machines have a custom kernel installed (based on the 2.6.28 source). However, whenever I try to reboot the machines using `sudo reboot`, the system uses kexec and loads the 2.6.28-19-generic kernel, which is also intalled on the machine. So how can I specify which kernel image to load after reboot? EDIT: I have ubuntu 9.04 installed on the machine, with grub 1.something. The custom kernel is based on the 2.6.28 source with the name being 2.6.28.10-custom-1.1. Two other kernels are installed on the machine 2.6.28-19-generic and 2.6.28-6-386. I have checked that after calling reboot, the machine does not actually reboot but uses kexec to load the 19-generic kernel, even if the current kernel was the custom one.


Using parallel on Ubuntu

I am having an issue trying to use parallel command on Ubuntu 10.04. I looked up the parallel documentation and few of the commands seem to run. In all cases I just get the command prompt back without any action being taken. e.g. I was trying to compress a bunch of files using bzip2                    17:32 farhat HarshaNaveen$ parallel bzip2 ::: *fastq      17:33 farhat HarshaNaveen$ ls *fastq|parallel bzip2 {}           Neither of these commands worked. Nor was there any error. The example given in the man file worked fine though.               18:58farhat HarshaNaveen$ parallel sh -c "echo hi; sleep 2; echo bye" -- 1 2 3     hi     hi     hi     bye     bye     bye     18:58farhat HarshaNaveen$       What am I doing wrong?


How can I set up smart card SSH authentication?

I would like to be able to SSH to my machine using a Gemalto .NET Smart Card as the authentication method. How could this be done on a Fedora 13 (or generic Red Hat style) machine? These are the rough steps I think are needed:   1. Provision certificate for the smart card (and possibly a CA to issue it?)   2. Get the certificate onto the smart card   3. Configure SSH server to allow smart card authentication and configure it to use a particular certificate/CA   4. An SSH client that has smart card support (extra points for a free Windows based one)


How do I rename lots of files on a directory without changing their extensions?

I have a problem! I have a bunch of image files with extensions. Jpg and. Png. I wrote a script that renames the files, changing their names in a pattern followed by a number like this: ... arquivo_1.jpg arquivo_2.jpg ... And following this sequence, but it needs to know the extension, in this case I used the extension. Jpg. I was wondering how do I optimize the script so that it renames but keeping the original extension of the file and keep doing the sequence I described above. Can someone help me?


Is it safe to disable OOM killer in a web server/reverse proxy?

I have Linux machine dedicated to serving static contents and PHP pages with Apache. Apache also work as a reverse proxy in a subdomain. I moved the PostgreSQL database to another Linux machine. Is it safe to disable the OOM killer in the kernel?


How to rotate all images in a directory with imagemagic?

I want to rotate all the images in a directory that match a pattern. So far I have:               for file in `ls /tmp/p/DSC*.JPG`; do       convert $file -rotate 90 file+'_rotated'.JPG     done      but that gives no output?


Type from right to left

Is there a command to make Vim type from right to left? If not us any one aware of this plugin?


Routing in OpenVPN between a private network and a client

I'm trying to setup OpenVPN between a private network and home clients that connect to it. (The clients don't need to connect to each other). The network topology is a little interesting. There is a public/University network on 10.7.42.0/24. We have some IPs on that network that have public ports forwarded to them, but we're limited on those so we're putting a lot on a private network at 192.168.203.0/24. All machines have at least a private IP and some have both public and private IPs (two adapters. This is all done in VMs but it's like there are two physically separate networks) The OpenVPN server is also the gateway between the public/private networks. It has a 10.7.42.x address, a default gateway of 10.7.42.1 (university gateway), it masquerades/IP forwards any-to-any, and it has an internal address of 192.168.203.1. It successfully works for NAT/gateway. My open VPN Server config looks like this:               local 10.42.7.226     port 443     proto tcp     dev tun     ca /etc/openvpn/easy-rsa-2.0/keys/ca.crt     cert /etc/openvpn/easy-rsa-2.0/keys/server.crt     key /etc/openvpn/easy-rsa-2.0/keys/server.key  # This file should be kept secret     dh /etc/openvpn/easy-rsa-2.0/keys/dh1024.pem     server 192.168.137.0 255.255.255.0          ifconfig-pool-persist /etc/openvpn/ipp.txt          route 192.168.203.0 255.255.255.0     push "route 192.168.203.0 255.255.255.0"          push "dhcp-option DNS 192.168.203.100"          keepalive 10 120          cipher BF-CBC        # Blowfish (default)               comp-lzo          plugin /usr/lib64/openvpn/plugin/lib/openvpn-auth-pam.so login     client-cert-not-required     username-as-common-name          max-clients 201          user nobody     group nobody          persist-key     persist-tun          status /var/log/openvpn-status.log          log-append  /var/log/openvpn.log      The ifconfig looks like this:               eth0      Link encap:Ethernet  HWaddr XX:XX:XX:XX:XX:XX                 inet addr:192.168.203.1  Bcast:192.168.203.255  Mask:255.255.255.0               inet6 addr: fe80::8c2c:6bff:fe5b:5406/64 Scope:Link               UP BROADCAST RUNNING MULTICAST  MTU:1500  Metric:1               RX packets:183488 errors:0 dropped:4 overruns:0 frame:0               TX packets:198145 errors:0 dropped:0 overruns:0 carrier:0               collisions:0 txqueuelen:1000                RX bytes:15024794 (14.3 Mb)  TX bytes:186885934 (178.2 Mb)               Interrupt:32 Base address:0xa000           eth1      Link encap:Ethernet  HWaddr XX:XX:XX:XX:XX:XX                 inet addr:10.42.7.226  Bcast:10.42.7.255  Mask:255.255.255.0               inet6 addr: fe80::a011:59ff:fe3e:c3aa/64 Scope:Link               UP BROADCAST RUNNING MULTICAST  MTU:1500  Metric:1               RX packets:436236 errors:0 dropped:99041 overruns:0 frame:0               TX packets:202673 errors:0 dropped:0 overruns:0 carrier:0               collisions:0 txqueuelen:1000                RX bytes:239838327 (228.7 Mb)  TX bytes:20537299 (19.5 Mb)               Interrupt:36 Base address:0xe100           lo        Link encap:Local Loopback                 inet addr:127.0.0.1  Mask:255.0.0.0               inet6 addr: ::1/128 Scope:Host               UP LOOPBACK RUNNING  MTU:16436  Metric:1               RX packets:2 errors:0 dropped:0 overruns:0 frame:0               TX packets:2 errors:0 dropped:0 overruns:0 carrier:0               collisions:0 txqueuelen:0                RX bytes:100 (100.0 b)  TX bytes:100 (100.0 b)          tun0      Link encap:UNSPEC  HWaddr 00-00-00-00-00-00-00-00-00-00-00-00-00-00-00-00                 inet addr:192.168.137.1  P-t-P:192.168.173.2  Mask:255.255.255.255               UP POINTOPOINT RUNNING NOARP MULTICAST  MTU:1500  Metric:1               RX packets:631 errors:0 dropped:0 overruns:0 frame:0               TX packets:88 errors:0 dropped:0 overruns:0 carrier:0               collisions:0 txqueuelen:100                RX bytes:48118 (46.9 Kb)  TX bytes:13725 (13.4 Kb)      My routes look like this:               192.168.137.2     *               255.255.255.255 UH    0      0        0 tun0     10.42.7.0       *               255.255.255.0   U     0      0        0 eth1     192.168.203.0   *               255.255.255.0   U     0      0        0 eth0     192.168.137.0     192.168.137.2     255.255.255.0   UG    0      0        0 tun0     link-local      *               255.255.0.0     U     0      0        0 eth0     loopback        *               255.0.0.0       U     0      0        0 lo     default         10.42.7.1       0.0.0.0         UG    0      0        0 eth1      The client looks like this:               dev tun     remote vpn.mydomain.com     ca ca.crt          client     port 443     proto tcp     tls-client     auth-user-pass          comp-lzo          ping 15     verb 9     log-append  /tmp/openvpn.log       The problem is I can only get to the OpenVPN server if I ssh to 192.168.137.1. I can't connect to any of the 192.168.203.0/24 addresses. If I do a trace route, it only goes one hop, and it takes 30 seconds to do that across the VPN to the remote tun adapter. The private machines use the 192.168.203.1 (OpenVPN server) as their gateway, so the packets should make their way back fine for at least those machines (really they would be NATed on their way out, so it should make it to machines with both public and private adapters too) I've set these OpenVPN networks up before and I know I've run into this exact problem before, but I can't remember the solution.


Does AIX really beat Red Hat Enterprise Linux?

Our company plan to upgrade our servers, and at the same, we would use AIX over Red Hat Enterprise Linux. I asked my boss the reason of choosing AIX, he said it is because AIX is more powerful. I wonder if it is true. Does AIX really out perform RHEL in terms of data processing? Only text data, no graphic processing. They are AIX 7.1 and RHEL is "Red Hat Enterprise Linux AS release 3 (Taroon Update 2)". Assume we would use the same machine for comparison.


Serial Over Lan redirection stops at OS boot

I'm trying to create a monitoring system for a remote machine using an IPMI Serial Over Lan (SOL) console. The remote OS is RHEL 6, the mobo manufacturer is Supermicro. I've successfully enabled SOL redirection in the BIOS. This allows me to see the BIOS and kernel parts of bootup through an attached SOL console over IPMI. Next, I followed the steps mentioned in many online articles to get my OS ( runlevel 3, just text terminal ) to redirect too. The result is almost always the same : After making the changes to /etc/grub.conf, /etc/inittab, and /etc/securetty, i can see the grub menu through the SOL console (yay!), but as soon as the OS starts booting, my SOL terminal receives 1 gibberish character, and nothing more. Some thoughts:   1. I'm not exaclty sure which serial port my BIOS are trying to redirect stuff into (ttyS0, ttyS1). Most of the examples use ttyS1, and since the grub menu gets redirected there, i'm pretty confident thats 'correct'   2. I know the 'terminal types' and baud rates have to match between the BIOS and OS settings. I am consistently using 115200 for baud, but i'm less confident I'm choosing the right terminal type. The terminal type in BIOS is "ANSI", and this gives the coloration i want for the BIOS over SOL. However, for the OS settings, most of the examples use 'linux'; i'm not sure if that's compatible with my ANSI setting. I've tried VT100 for both BIOS and OS, and I still never see anything past the Grub menu (plus, i lose color info for my BIOS over SOL). Any help is greatly appreciated.


Communication to device is lost when network starts on boot up?

I have an application that opens a socket on port 4444 to a device (/dev/linkToDevice). The "linkToDevice" is a link to ttyUSB0. The application is a c++ program of which is now a daemon and runs at boot up. The daemon runs regardless of network. So when the linux box is booted, and there is not network, the daemon starts immediately and while there is still no network, I can communicate just fine (telnet localhost 4444). But, when I plug in a network cable, or dhclient determines there is no DHCP and leases me a default ip address, or I just simply give it an ip interface, I can no longer communicate. I can, however, still open the telnet connection, I just get no response when I query for one. I use 0.0.0.0 as the ip to open the socket on (signifying any ip address). I dont feel like it is a code problem. The odd part to me is that after I can no longer communicate, if I restart the daemon, everything works great, which is expected. But, when I unplug the network, or unconfigure the interface, or do a sudo /etc/init.d/networking restart, or any sort of bringing the network down and back up again, through that entire process I never lose communication to the device. So the problem ONLY happens when I boot the machine with no network to begin with, and then I all of a sudden get a network. Any thoughts as to why this only happens at boot up?


ssh server: reasons for sudden "Connection closed by remote host"

One of my ec2 servers has stopped receiving ssh connections. The OS is Ubuntu server 8.04, and the ssh server is the standard `openssh-server`. After months of uptime, I tried to connet to it today, and got the following message:               ssh_exchange_identification: Connection closed by remote host      Any idea what could have went wrong? **Update:** After a reboot, the server started receiving new connections. Disks are below 50% usage.


scp transfers slow down and stop over local network

I'll often transfer items to and from my laptop on my local network using `scp`. Often, it seems, I'll see the transfer rate start out right (2.0MB/s), then slowly diminish until the transfer completely stalls. This seems to be fairly reproducible on larger files. Is there a network problem or a way for me to better configure SSH on my laptop? My desktop doesn't seem to have these problems when transferring files to remote servers, so I assume that my laptop's WiFi connection may be to blame. Both computers are running an Ubuntu 12.04 derivative.


Fail2ban for nginx post flood ignores time intervals

I'm trying to create a fail2ban filter that is going to ban the host when it sends over 100 POST requests over 30 seconds interval. jail.local:               [nginx-postflood]          enabled = false     filter = nginx-postflood     action = myaction     logpath = /var/log/nginx/access.log     findtime = 30     bantime = 100     maxretry = 100      nginx-postflood.conf               [Definition]     failregex = ^<HOST>.*"POST.*     ignoreregex =      Using GREP i was able to test the regular expressions and indeed it matches Host and POST requests. Problem is that it bans **any Host that performs at least one POST request**. This means likely that it's not taking _findttime_ or _maxretry_ options into consideration. In my opinion it's timestamp issue. Sample line of nginx log:               5.5.5.5 - user [05/Aug/2014:00:00:09 +0200] "POST /auth HTTP/1.1" 200 6714 "http://referer.com" "Mozilla/5.0 (Windows NT 6.2; WOW64; rv:31.0) Gecko/20100101 Firefox/31.0"      Any help?


Best Linux for a small Web server

I'm currently planning my business servers and I would like to know what's the best Linux distro for these needs:   * Nginx + MySQL + PHP 5.4   * Zimbra Collaboration - Open Source   * Node.js w/ Forever I know it's a objective question but I asked a lot of people and they didn't answer me other thing than "It's your choice"... I have a 2 CPU, 1GB RAM, 30GB SSD server...


What software do all linux distributions have in common?

A little context: I recently installed Arch Linux on a chromebook through a bizarre hack in which I used an install script to install Ubuntu and then overwrote the Ubuntu rootfs with an Arch rootfs. I'm not sure what the mechanics are behind this (like this: https://wiki.archlinux.org/index.php/Acer_C7_Chromebook). Is the part of Linux that runs before chrooting into rootfs common to all Linux distros (and that's why the initial boot worked for both Arch and Ubuntu)? Or, to be more general, what pieces of software are common amongst all Linux distributions, i.e. define a Linux distribution?


SELinux: allow a process to create any file in a certain directory

I have a script that, when invoked, will cause the contents of `dmesg` to be written to a file, with the file's name basically being a timestamp. SELinux prevents this. Following the advice of Fedora's SELinux troubleshooting app, I tried: > grep dmesg /var/log/audit/audit.log | audit2allow -M mypol > > semodule -i mypol.pp However, this doesn't seem to work, probably because the name of the file it's creating is different every time. So how do I tell SELinux to allow `dmesg` to create (and write to) any file in a certain directory? Or tell it that the script in question (and all the processes it spawns) can do that?


Handling sed variables with paths in them?

I have an applescript for doing certain things, like search and replace.               set lol to quoted form of POSIX path of (choose file with prompt "VälJ Fil")      That chooses a file then im doing this               set script1 to "sed 's@id_Shops@ShopID@g'" & lol     do shell script script1      But sed tells me `bad flag in substitute command: '/'" number 1` I figured it was the slashes in the path, how can i fix that? I have tried to use `sed -i` but it gives me this error `sed: -i may not be used with stdin` How can i do to avoid the path conflict in sed?


How much disk space should be allocated for FreeBSD?

I have a Samsung N150 netbook with 160 GB hard disk. I want to install FreeBSD OS. There will be no other OSs, no dual booting or like that, just FreeBSD. So the manual says to have a separate partition for /var, /usr and /   Earlier I used Ubuntu where I created / with 30 GB and rest for /home. But what will be the optimal disk size for use in FreeBSD? How much can /var grow into? Also if I install applications from ports where will it go? Is it to /usr/local/bin or /opt? Which is recommended?   My usage will be as a development machine. i.e it will have all my personal stuffs like music plus development software, server etc. I think of having separate partitions for keeping development files and mounting when ever required. Also separate partition for other stuffs like music, docs etc. So that even if I reformat the OS, I will only have to wipe the OS files, and not my personal files. So which format (like ext4 or zfs) should those partitions have? Can those be on extended partition since FreeBSD need a primary partition.


Is there a port list migration command set for FreeBSD?

On debianized linux distros there is `dpkg --get-selections`, `dpkg --set- selections`, `dpkg -C` to respectively list installed packages, select a list of packages for installations, and list packages that are in a partially installed or broken state. I am wondering if something like this exists for FreeBSD (ports, not packages). I can get the list from `pkg_info`, but is there a simple way to apply it without `cut`, `for port in list`, `cd`, `make install`?


I am failing to build VirtualBox driver for Linux 2.6.38

I am running Debian 6, and decided to install 2.6.38 kernel from Unstable. I also installed the headers so that I can later on :               sudo apt-get install --target-release=unstable linux-image-2.6.38-2-686-bigmem linux-headers-2.6.38-2-686-bigmem      I then re-installed **`virtualbox-ose-dkms`** to that the VirtualBox drivers for 2.6.38 can be rebuilt (so that I can use VirtualBox under 2.6.38), but I get this error:               Building initial module for 2.6.38-2-686-bigmem          Error! Bad return status for module build on kernel: 2.6.38-2-686-bigmem (i686)     Consult the make.log in the build directory     /var/lib/dkms/virtualbox-ose/3.2.10/build/ for more information.     dpkg: error processing virtualbox-ose-dkms (--configure):      subprocess installed post-installation script returned error exit status 10     configured to not write apport reports                                           Errors were encountered while processing:      virtualbox-ose-dkms     E: Sub-process /usr/bin/dpkg returned an error code (1)      Here's the contents of the file they asked me to look at:               $ cat /var/lib/dkms/virtualbox-ose/3.2.10/build/make.log      DKMS make.log for virtualbox-ose-3.2.10 for kernel 2.6.38-2-686-bigmem (i686)     Sat Apr  9 14:11:57 SAST 2011     make: Entering directory `/usr/src/linux-headers-2.6.38-2-686-bigmem'       LD      /var/lib/dkms/virtualbox-ose/3.2.10/build/built-in.o       LD      /var/lib/dkms/virtualbox-ose/3.2.10/build/vboxdrv/built-in.o       CC [M]  /var/lib/dkms/virtualbox-ose/3.2.10/build/vboxdrv/linux/SUPDrv-linux.o     In file included from /var/lib/dkms/virtualbox-ose/3.2.10/build/include/VBox/types.h:30,                      from /var/lib/dkms/virtualbox-ose/3.2.10/build/vboxdrv/linux/../SUPDrvInternal.h:35,                      from /var/lib/dkms/virtualbox-ose/3.2.10/build/vboxdrv/linux/SUPDrv-linux.c:33:     /var/lib/dkms/virtualbox-ose/3.2.10/build/include/iprt/types.h:97:31: error: linux/autoconf.h: No such file or directory     /var/lib/dkms/virtualbox-ose/3.2.10/build/vboxdrv/linux/SUPDrv-linux.c: In function ‘VBoxDrvLinuxInit’:     /var/lib/dkms/virtualbox-ose/3.2.10/build/vboxdrv/linux/SUPDrv-linux.c:451: error: ‘nmi_watchdog’ undeclared (first use in this function)     /var/lib/dkms/virtualbox-ose/3.2.10/build/vboxdrv/linux/SUPDrv-linux.c:451: error: (Each undeclared identifier is reported only once     /var/lib/dkms/virtualbox-ose/3.2.10/build/vboxdrv/linux/SUPDrv-linux.c:451: error: for each function it appears in.)     /var/lib/dkms/virtualbox-ose/3.2.10/build/vboxdrv/linux/SUPDrv-linux.c:451: error: ‘NMI_IO_APIC’ undeclared (first use in this function)     /var/lib/dkms/virtualbox-ose/3.2.10/build/vboxdrv/linux/SUPDrv-linux.c:465: error: ‘nmi_active’ undeclared (first use in this function)     make[4]: *** [/var/lib/dkms/virtualbox-ose/3.2.10/build/vboxdrv/linux/SUPDrv-linux.o] Error 1     make[3]: *** [/var/lib/dkms/virtualbox-ose/3.2.10/build/vboxdrv] Error 2     make[2]: *** [_module_/var/lib/dkms/virtualbox-ose/3.2.10/build] Error 2     make[1]: *** [sub-make] Error 2     make: *** [all] Error 2     make: Leaving directory `/usr/src/linux-headers-2.6.38-2-686-bigmem'


How can I make the GNOME Shell Activities Bar small all the time?

When I have no apps running, or I'm in the activities screen in GNOME shell, the activities bar is maybe 20px high. When I am running an application, this expands to 70px, possibly to fit the 64x64 application icon it uses for the application. Can I make this bar smaller the whole time?


How linux installation process works

can anyone explain me how Linux installation process works? With Windows, installation process starts with Windows Setup. It's a program that installs Windows. Setup starts and restarts a computer, collects informations, copies files, and applies settings. What is for Linux like Setup for Windows, and are there any major differences between installation process of Linux and Windows? Thanks in advance!


Eval emacs init.el from CLI

I want to eval my ~/.emacs.d/init.el file periodically from CLI (cron) since it generates other files that I use in my projects according to some extra data. Something like "emacs -q -eval-file ~/.emacs.d/init.el", or something like this. How can I do it ? Thanks


Virtualbox 64bit image on 64bit computer without virtualization support

I have a 64 bit image for VirtualBox (.vmdk file), and I don't have a 32 bit version. My computer doesn't support hardware virtualization. Logically VirtualBox says: > This kernel requires an x86-64 CPU, but only detected an i686 CPU. Unable to > boot - please a kernel appropriate for your CPU. If I don't have a 32 bit version, does that simply mean I am screwed?


If I redirect logs using rsyslog, will dmesg be affected?

I am trying to get some logging in place and am trying to troubleshoot it and this question became relevant. I use rsyslog config files to redirect some of my logging. (Will use iptables logging since I am working with it but please assume the general case) Under my rsyslog.d config I have               :msg, startswith, "iptables: " /var/log/iptables.log     :msg, startswith, "iptables denied: " /var/log/iptables.log     & ~      I would assume if this was working that it would no longer log to kern.log. Since it is no longer going to kern.log does the redirect also effect the kernel ring buffer?


Bash vs ksh pipes

I am stuck with some problems with my scripts in ksh. FWIW the problem which I am unable to overcome is that when I use a structure such as this               command | while read VAR1      do        many.commands using $VAR1     done      I often get that my scripts do not perform the loop for every line piped to the while. To test this I then change the structure to               command > /tmp/tempfile     cat -n /tmp/tempfile >&2     cat /tmp/tempfile | while read VAR1     etc      This proves that there is many lines in the output. Further I then add an extra line immediately after the do, like               echo DEBUGGING: $VAR1  >&2      Which proves that the loop runs only once. I am really stumped. One workaround which is not always viable, is to do               for X in $(cat /tmp/tempfile )     do     ...     done      This then works correctly but besides the fact that I hate this for structure, It means you expand the entire input data on the command-line (which has hard limits) It appears that bash is better than ksh at handling this kind of thing. In particular it seems that this may be related to read calls failing but not retrying if the loop takes a long time to run. However it seems that bash does not have a built-in "read", which means much of my scripts will need to be re-written. I OFTEN use large structures like               command1 | command2 | while read SOMEVAR; do awk -F: "... long awk program" | sed "long sed program" ; done | sort -u | tail -1 | read FINAL_ANSWER      The problem is that bash uses /usr/bin/read which as expected throws away the result of FINAL_ANSWER as fast as it gets it. The obvious workaround is to replace               | read FINAL_ANSWER      with               > /tmp/final_answer && FINAL_ANSWER="$(cat /tmp/final_answer)"      So.... Any scripting gurus on here able to shed some more light on this? I deliberately did not post my real scripts here both because they are part of a sensitive solution developed for a customer, and because I don't want the actual detail of the scripts to confuse the issue. I use the "while read" format OFTEN. It usually works. I've in fact never had a problem with it in 25 years of shell scripting. Now I'm having problems. Very frustrating. Perplexing. Initially I thought the while read is only receiving, or passing along, the first line of input. But then I discovered a situation where, when I run the script over and over, it runs further and further into the input. Specifically I have something line this               command | while read NEXT_ONE DONEFLAG     do        if [ $DONEFLAG = "yes" ]        then            echo Already completed work for $NEXT_ONE        else            dowork $NEXT_ONE && set_flag $NEXT_ONE        fi     done      It turns out that on each run of the script, it performs `dowork` once. It doesn't really matter what `dowork` is, so long as it takes more than a few seconds. Some kind of shell pipe timeout occurs and the rest of the input then disappears. Google tells me that dtksh may solve this issue (Apparently it will retry the read/write or something, I didn't read enough) I see that dtksh exists in /usr/st/bin/dtksh Who is this? I don't like using shells that I don't know, but it might be worth while to split small portions of scripts into sub-scripts with /usr/dt/bin/dtksh as interpreter. Any advice? EDIT: Providing an example of why I can not use bash as a drop-in replacement for ksh as interpreter:               sol10-primary> # cat test.sh     #!/bin/ksh     echo hello| read VAR1     echo $VAR1     sol10-primary> # ./test.sh     hello     sol10-primary> # sed 's/ksh/bash/' <test.sh >test2.sh     sol10-primary> # chmod +x test2.sh     sol10-primary> # ./test2.sh          sol10-primary> #


Fedora Upgrade Error

I was trying to upgrade to Fedora 16 (I had f14) using _preupgrade_. However, it fails at the end (after saying: _preparing transaction from installation source_ ) and gives the following error: _A fatal error occurred when installing the file system package. This could indicate errors when reading the installation media.Installation cannot continue._


md5sum change after mount?

I have a ext3 filesystem on a .img file. After mounting and unmounting it, I noticed that the md5sum is changed, even if no file inside was changed!               md5sum myfilesystem.img     XXXX myfilesystem.img     mount -t ext3 myfilesystem.img temp/     umount temp/     md5sum myfilesystem.img     YYYY myfilesystem.img      Why does XXXX differs from YYYY? I clearly didn't touch anything inside myfilesystem.img.


I am new to unix command and I have got one scenario that, I want to create a zipped output file while keeping the original one. I want to do it from Informatica end by using command task or session task. Please advice. Below is the example which I am trying:   1. In session task: Command type='Command', Command=   `gzip -c /var/opt/powermart/pc8_dev/infa_shared/TgtFiles/test1/tgt_zip.out`   2. In case of using Command task:  `gzip -c /var/opt/powermart/pc8_dev/infa_shared/TgtFiles/test1/tgt_zip.out` I tried both things, but zip file is not at all created. Below is the screen shot: ![command in session task](http://i.stack.imgur.com/j1t8p.png)


Why did this command delete every package?

I was trying to get a Windows program to run on PlayOnLinux and after it didn't work I went to remove Wine with this command: `sudo apt-get remove --purge wine*` and without thinking I agreed to remove every package on the machine. Can someone tell me why it selected every package instead of all the ones starting with the string "wine"? I'm running Linux Mint 16


How do I move gnome-panel between monitors without gnome-settings-daemon in xmonad?

I'm running xmonad with gnome-panel, but not gnome-settings-daemon. I start up gnome-panel by spawning in xmonad.hs. How can I (on the command line) get gnome-panel to switch monitors? xmonad.hs:               myManageHook :: [ManageHook]     myManageHook =       [ resource =? "Skype" --> doFloat       , resource =? "Vncviewer" --> doFloat       , resource =? "gnome-panel" --> doIgnore       , isFullscreen --> doFullFloat       ]          startup :: X()     startup = do       spawn "gnome-panel"          main = xmonad $ ewmh defaultConfig         { modMask = mod4Mask         , terminal = "gnome-terminal"              -- avoidStruts prevents overlap with gnome-panel         -- smartBorders disables border in full screen (or single-window)         , layoutHook = avoidStruts $ smartBorders $ layoutHook defaultConfig         , manageHook = composeAll myManageHook <+> manageHook gnomeConfig              -- docksEventHook reworks windows whenever a dock gets in the way         , handleEventHook = docksEventHook         , startupHook = startup         }


Search commands in history with discontinuous keywords

I was wondering how to search commands in history without knowing the first few letters of the command? When searching using `Ctrl`-`R` in bash, ~~one has to give the first few letter of the command. What if I only know some characters in the middle, or some at the beginning and some in the middle? For example, to search`cat myfile`, I only know there is `at` in it, or `c` at the beginning and `my` in the middle somewhere.~~ keywords have to be continously positioned. For example, in `cat myfile`, I would like to search for both`c` and `my`, but Ctrl+R will not allow to specify both simultaneously. Thanks!


Pipe chain with devices

As far as I know, you can have the ability to make pipes between applications, such as this one:               $ step1 < input_file | step2 | step3 > result_file      And you can access devices such as `/dev/urandom`, `/dev/zero`. `/dev/null`, etc:               $ cat /dev/urandom > "output_file"     $ someprog > /dev/null      My question is, is it possible to make a pipe with a block device both input and output at the same time? For example, I want to read a `input_file`, send to `/dev/example` (which is `rw`), and then read its output into `output_file`. Can be achieved on a single command just like this:               $ cat input_file | /dev/example > output_file      or               $ /dev/example < input_file > output_file      or is it advised to do in two commands? PS: Maybe I'm misspelling the commands or making syntax errors, please let me know how to get it. I use `sh` or `bash`, I don't know how to use other consoles. If I'm not clear, let me know as English is not my mother tongue.


Best method for performing a HDD copy from a master to slave

We are running a Debian-based system in our product, out of which I need to create new drives from a master drive. ### Method 1: Install OS from debian live CD and copy the required custom software. Earlier, I stared my process with method 1, I various errors like operators missing dependencies, while installing the OS etc and it takes about 80 minutes to install OS and my software. So, I was not able to continue this mechanism. ### Method 2: Taking clone of the master drive and place it in a server. Running clonezilla and installing clone. This method was working out very well for me earlier. Nowadays, customers requires different HDD sizes. A single clone does not work out for me. So this makes me to maintaining multiple clones and it takes about 30 minutes to install the clone. ### Method 3: Just partition the drive copy all the OS files from master to slave. This method gives me the freedom of just copying the files from master to slave. Also, allows me to maintain a single master disk.Also, this method takes about 10 minutes for copying files. But, I feel there might be many CONS using this method. I want to maintain a single copy of my master and consume less time to create a new slave drive.


Problematic quotations

#!/bin/ksh     typeset FILE_SIZE1=$(stat -f '%z' test.txt);     typeset -r BK_STATARGS="-f '%z'"     typeset FILE_SIZE2=$(stat ${BK_STATARGS} test.txt);     echo without arg var ${FILE_SIZE1}     echo with arg var... ${FILE_SIZE2}      Yields....               without arg var 216     with arg var... '216'      Maybe I'm missing the obvious but I can't figure out a fix. I've tried all sorts of things.


How to get recordmydesktop to record application's audio on Debian/Squeeze?

I'm on an amd64 Debian/Squeeze install on an Intel DX58SO motherboard. I want to use recordmydesktop to record application's audiovisual output. It's important any **audio** generated by the applications is recorded along with the video. The app I _actually_ want to record is VirtualBox, but googling suggests that has it's own complications so for now I'm just trying to get recordmydesktop to even just record audacious playing mp3s. Video works great, but I just can't get _any_ sound recorded. `recordmydesktop --print-config` says:               recordMyDesktop was compiled with the following options:     Jack:                   Enabled     Default Audio Backend:  ALSA      When I started off trying to get this to work the machine had ALSA on it (audacious was outputting to it); along the way I've installed pulseaudio and pavucontrol (as suggested by question referenced below) and switched audacious to pulseaudio output - no improvement. Then I installed jackd, fired up qjackctl... and I'm completely out of my depth now. Is there any simple prescription for getting recordmydesktop to record application's audio ? (Preferably with the system restored to it's original ALSAness and the pulse/jack stuff removed if not necessary; I note VirtualBox, which is the intended target, seems to mention ALSA in its logs). I'm aware of this question but the solution is, I assume, Ubuntu specific as, for me, nothing ever appears in the PulseAudio volume control (it continues to display "No application is currently recording audio" on the recording tab, whereas that answer seems to imply recordmydesktop should appear there when running so a stream can be routed to it). I also tried the "instanbul" grabber but that didn't work any better. Also gtk-recordMyDesktop but that just seems to be a thin wrapper for the recordmydesktop commandline tool and just obfuscates problems. Thanks for any Debian-specific help


Force fsck check after reboot with single command

I'm looking for systemd's equivalent to the `shutdown -F` command. I know that I can force fsck by adding `fsck.mode=force` to kernel options or tweak mount count for disks. I have tried `touch /forcefsck` but it doesn't work with latest systemd versions.


How to delete a line containing pattern which is first found after a specific pattern

I am writting a shell script to delete an entry from a specific group. eg: file name is `dest.xml`               <domain id="1" group_name="group1">         <node id="ABC">         <node id="PQR">         <node id="XYZ">     </domain>     <domain id="2" group_name="group2">         <node id="PQR">         <node id="XYZ">     </domain>     <domain id="3" group_name="group3">         <node id="ABC">         <node id="PQR">      </domain>      I want to delete an entry from above file (filename is dest.xml) with `node id="PQR"` from `group_name="group1"` (it should not get deleted from group2 and group3). I can do it by reading a file sequentially n then delete it from a specific group. But if the file is to large (>10k lines) then it takes time. Is there any simple way to this this?


Prevent a second instance of my software from starting

I wrote a service script to run a specific software at boot time. How can I restrict this software so that it does not run manually again? I mean software has to have just one instance in the memory.. I don't want to change the source code of my software, I want init to this job for me.


Why does insert-mode map "<F4>" unpredictably inserts itself or executes intended key strokes?

In Vim 7.3.1-762, mintty 1.1.2 (xterm), cygwin, Windows XP, the insert-mode map `<F4>` executes the intended key strokes at one time but inserts itself at another time. This undeterministic behavior especially occurs if I hold the `<F4>` key depressed. How do I make the behavior predictable accross multiple Vim-, terminal- and operating system versions? This is the code I defined in my `~/.vimrc` file, that seems relevant to me:               set compatible     set timeout     set ttimeout     set timeoutlen=1000     set ttimeoutlen=100     imap <F4> <C-\><C-O>:set relativenumber! relativenumber?<CR>      If I assign the mapping to a function key above `<F4>`, e.g. `<F5>`, `<S-F7>` etc. I don't experience the behavior mentioned above. Also if I disable the `timeout` option with `set notimeout` it does seem to do the trick.


Wrongly set chmod / 777. Problems?

I was trying to run `chmod -R 777 ./` but ended up typing `chmod -R 777 /` and set `777` on my entire machine. What can go wrong? How can I fix it?


Wrong Permission to /etc folder

I have given the wrong permission to the `/etc` folder               chmod -R 777 /etc      When I want to login as root it gives me an error and the following output. How can I correct the permissions?               system13@motpl:~$ sudo su     sudo: /etc/sudoers is mode 0777, should be 0440     sudo: no valid sudoers sources found, quitting     sudo: unable to initialize policy plugin     system13@motpl:~$ su root     Password:      su: Authentication failure     system13@motpl:~$


Terminal is not opening in Linux after accidental permission overwrite

I am using Debian. I tried to give a permissions to /opt/folder by using               chmod -R 0755 / filename      Unfortunately it changed the permissions of a lot of folders in the root filesystem. So it leads into a lot of problem. Now I can't open any application (i.e) Terminal, Browser or even I get errors on restart. How to open a Terminal? (starting and stopping) How to resolve this whole problem?


Accidentaly changed the permissions in /

Accidentally did :               chmod -R 777 /      Now, RHEL 6 is not booting up. What do I do?   I have a DVD and can go into rescue mode. Can someone explain how do I reset all the permissions ? **Update** Actually it boots, and then reaches to a screen where it displays Redhat logo along with some text localhostXXX. But after that nothing happens. It is not going to the login screen.


What is the advantage of a network installation?

Looked into a network installation of fedora there. It seems you need to setup http & ftp servers on the host along with booting from a cd. So what are the advantages of installing linux over the network?


Ephemeral port : What is it and what does it do?

I suddenly came across the term "ephemeral port" in a Linux article that I was reading, but the author did not mention what it is. What is an ephemeral port in UNIX?


Library / program deployment

What is the best way to deploy a self compiled library, which already exists as an older version in the official repository, to multiple CentOS 6.5 workstations?   * Use the upstream `rpm` specification (from Fedora) to create a newer `rpm`   * Compile, install to separate folder and either:     * copy to `/usr/local/{lib,include,...}` on each workstation     * copy to `/usr/local/companyname/{lib,include,...}` on each workstation     * use a `nfs` share with a central lib location   * something else


LUKS change encryption key

To change encryption password I can use command:               cryptsetup luksChangeKey /dev/sda2      ... and that works. But how to encrypt /dev/sda2 partition again with new password? If my old password is compromised and I only change password, stored data is encrypted with old password not with new.


Give domain users permissions on cifs shares?

I am using CentOS 6.5 - users authenticate using winbind, all are domain users except for root. `/home` is mapped to a cifs share on a windows server in `/etc/fstab` with this line: `\\\server\home$ /home cifs credentials=/root/samba.txt,_netdev 0 0` Under the `home$` share there are folders corresponding to each username, that are their home directories in windows. Each user has full windows permissions to their individual folders. However, when on the linux system, users only have read and execute access to `/home/$username` Chmodding and chowning does not throw any errors, but neither have any effect on the subdirectories, which are all owned by root. Each user should ideally own, but at least have full access to read/write to their home directories, but they must not be able to read another users home dir.


How do I fix this strange behavior with ssh, gnome terminal and gnu screen where function keys F1 through F4 are not accepted?

Here is what I am trying to do:   * open Gnome terminal   * launches with my command prompt   * ssh into work via VPN   * launch screen   * create two screen windows   * try to use F3 and F4 as "prev" and "next" with no luck.   * try to use F6 and F7 as "prev" and "next" works fine. Here is my .screenrc                 hardstatus on       hardstatus alwayslastline       hardstatus string "%{.bW}%-w%{.rW}%n %t%{-}%+w %=%{..G} %H %{..Y} %m/%d %C%a "       defscrollback 5000       startup_message off            #bind uppercas x to remove region       bind X remove       bind ^X lockscreen            # Bind F3 and F4 (NOT F1 and F2) to previous and next screen window       bindkey -k k3 prev       bindkey -k k4 next            # Bind F5 to switch to next focus       bindkey -k k5 focus            bindkey -k k6 prev       bindkey -k k7 next            #split window       bindkey -k k8 split       bindkey -k k9 remove      What's strange is the following works: Works 1:   * Doing this via putty works fine Works 2:   * using the exact same .screenrc works fine if I am on my local machine Doesn't work:   * using lxterminal has the same issue My thoughts are that ssh may be causing this but not sure. **EDIT:** Here are the outputs of some terminal related commands: **Local Machine:**               $ echo $TERM     xterm          $ infocmp -1 | grep kf.=         kf1=\EOP,         kf2=\EOQ,         kf3=\EOR,         kf4=\EOS,         kf5=\E[15~,         kf6=\E[17~,         kf7=\E[18~,         kf8=\E[19~,         kf9=\E[20~,      **Work Machine:**               $ echo $TERM     xterm          $ infocmp -1 | grep kf.=         kf1=\EOP,         kf2=\EOQ,         kf3=\EOR,         kf4=\EOS,         kf5=\E[15~,         kf6=\E[17~,         kf7=\E[18~,         kf8=\E[19~,         kf9=\E[20~,      **Work Machine using screen:**               $ echo $TERM     screen          $ infocmp -1 | grep kf.=             kf1=\EOP,             kf2=\EOQ,             kf3=\EOR,             kf4=\EOS,             kf5=\E[15~,             kf6=\E[17~,             kf7=\E[18~,             kf8=\E[19~,             kf9=\E[20~,


unpack and patch source rpm (rpmbuild -bp) safely

I want to unpack source RPM and apply patches to the upstream source. What is _almost_ OK for me is               rpm -i mypkg-*.src.rpm     cd ~/rpmbuild     rpmbuild -bp SPECS/mypkg.spec     # frolic in BUILD/mypkg      My problem is that `rpm -i` always deploys the sources in ~/rpmbuild. And since I want to do it in a middle of automated test (which is running under root), I'd rather do this at least in my own temporary tree. I have tried `\--prefix=mypath` with RPM, but it seems that RPM ignored that ( _after_ hassling me about the path being relative ... nice job ;)). Other thing that came to my mind was creating a temporary user and `su` but that's ugly, adds overhead of creating/removing the user and is not non- intrusive anyway. So what are my other, way better options?


makehuman gives "ImportError: No module named numpy"

I installed 1.0.0 on slackware 14.1 makehuman 64bit slackbuilds through the site, but the makehuman does not open, the program appears in the KDE menu but does not open. I do not know why it happens, the only dependence was a PyOpenGL library and I installed this library. what may have caused this problem? error:               bash-4.2# exit     exit     bash-4.2# makehuman     Initialized logging     VERSION: 1.0.0     SHORT VERSION: v1.0.0     BASEMESH VERSION: hm08     IS BUILT (FROZEN): No     IS RELEASE VERSION: Yes     HOME LOCATION: /root     SYS.VERSION: 2.7.5 (default, May 29 2013, 02:28:51)  [GCC 4.8.0]     SYS.PLATFORM: linux2     PLATFORM.MACHINE: x86_64     PLATFORM.PROCESSOR: AMD Athlon(tm) 64 X2 Dual Core Processor 4000+     PLATFORM.UNAME.RELEASE: 3.10.17     PLATFORM.LINUX_DISTRIBUTION: Slackware  14.1      Could not create debug dump     Traceback (most recent call last):      File "/usr/share/makehuman/makehuman.py", line 284, in debug_dump     debugdump.dump.reset()       File "./lib/debugdump.py", line 98, in reset     import numpy     ImportError: No module named numpy     Traceback (most recent call last):       File "/usr/share/makehuman/makehuman.py", line 362, in <module>     main()     File "/usr/share/makehuman/makehuman.py", line 347, in main     import numpy     ImportError: No module named numpy


How to check whether a command such as curl completed without error?

I am using curl to upload a file to a server via an HTTP post.               curl -X POST -d@myfile.txt server-URL      When I manually execute this command on the command line, I get a response from the server like `"Upload successful"`. However, how if I want to execute this curl command via a script, how can I find out if my POST request was successful?


tail -f equivalent

I am seeing several seconds delay with the tail command. I found the cause for it has something to do with nfs services. I am using arch linux and yet to find out how to disable all these services I have searched and had some indication that other tools will not be effected such as cat so what can give equivalent results to tail -f


`$XAUTHORITY` appears from 'nowhere' on su+tmux

When I switched from `su+bash` to `su+tmux+zsh` I noticed that I get `$XAUTHORITY` variable defined as `/root/.xauthXXXXXX` where `XXXXXX` are 6 random alphanumeric characters. With previous configuration X worked with root flowlessly but now I need to copy `~username/.Xauthority` to `$XAUTHORITY`. Variable is nowhere defined (I checked `.zshrc`, `/etc/profile*`, `/etc/profile.d/*` etc.).               # env     TERM=screen     SHELL=/usr/bin/tmux     USER=toor     TMUX=/tmp//tmux-0/default,6495,3     PATH=/sbin:/bin:/usr/sbin:/usr/bin     PWD=/root     SHLVL=2     HOME=/root     LOGNAME=toor     DISPLAY=:0.0     XAUTHORITY=/root/.xauthUSzLl4     COLORTERM=gnome-terminal     _=/bin/env     OLDPWD=/root     EDITOR=vim     vcs_info_msg_0_=     vcs_info_msg_1_=      **Edit:**               % echo $XAUTHORITY      /home/mpiechotka/.Xauthority     % su      password:     # echo $XAUTHORITY      /root/.xauthUSzLl4     # ls $XAUTHORITY     ls: cannot access /root/.xauthUSzLl4: No such file or directory     # cat .tmux.conf      set -g default-command /bin/zsh     set -g default-shell /bin/zsh      `su` is aliased to `su - toor` and it opens `tmux` as shell. toor is an alias of root with different shell. PS. I just discovered that it appears on normal su as well. It did not some time ago... **Edit 2** `set-enviroment` didn't help either **Edit 3** `xhost +localhost` did not helped but `xhost +` (disabling all control) DID helped.


od emulation for directories

I was wondering why od(1) used to work in UNIX but doesn't work in GNU/Linux. There is a nice answer on serverfault. The next question is, are you aware of any tools that can emulate od behavior to support dumping directory data in GNU/Linux?


crontab, instance, memory issues+spamming

I have a cronjob that runs php5 wp-cron.php every minute to update my website. However something happened and i had 30+ instance of it (31 is marked on this one dump of `ps aux`). It ate up my ram, caused additional instance to terminate do to lack of memory and caused me not to be able to ssh into the box. I can't understand why instances were living >30mins, one usually takes a few seconds. The day it happened i had no jobs planned (although maybe wp cache usesd it? but i never had a problem before) What can i do to prevent a cronjob from spamming and destroying my memory? Is there a way i can say do not start if an instance is alive? and if an instance is alive for more then 5mins kill it? Is there a way i can protect myself from something similar from happening?


Why is almost every program complaining about my locale?

I'm using Arch Linux, and I've followed the directions on the wiki about setting my locale. Nearly every program that runs complains about the locale - even `locale`. It looks like this:               % locale     locale: Cannot set LC_ALL to default locale: No such file or directory     LANG=     LC_CTYPE=en_US.UTF-8     LC_NUMERIC=en-US     LC_TIME=en-US     LC_COLLATE="POSIX"     LC_MONETARY=en-US     LC_MESSAGES="POSIX"     LC_PAPER="POSIX"     LC_NAME="POSIX"     LC_ADDRESS="POSIX"     LC_TELEPHONE="POSIX"     LC_MEASUREMENT=en-US     LC_IDENTIFICATION="POSIX"     LC_ALL=      or:               % perl     perl: warning: Setting locale failed.     perl: warning: Please check that your locale settings:         LANGUAGE = (unset),         LC_ALL = (unset),         LC_TIME = "en-US",         LC_NUMERIC = "en-US",         LC_MONETARY = "en-US",         LC_MEASUREMENT = "en-US",         LC_CTYPE = "en_US.UTF-8",         LANG = (unset)     are supported and installed on your system.     perl: warning: Falling back to the standard locale ("C")      Something slightly confusing is that the `/etc/locale.gen` has several examples; all the UTF-8 lines have "something.UTF-8", and running `locale-gen` shows `en_US.UTF-8... done` while it's running, but `locale -a`, which is supposed to show you the available locales shows `en_US.utf8`. I've tried various combinations of both formats in `/etc/locale-gen` and `LOCALE=` in `/etc/rc.conf`, but nothing has fixed the problem. Additional information:               % locale -a     C     POSIX     en_US     en_US.iso88591     en_US.utf8      Bruce Ediger's suggestion of setting `LANG=C` and `LC_ALL=en_US.UTF-8` worked (in fact, setting `LC_ALL` fixed it, setting `LANG` didn't matter), but I'd like to know what's happening. According to SUS, LC_ALL will override all the other LC_* variables if it is set and not null. In my system, it is set, but it is null, so it should be ignored, and other values should be used instead. That's not what's happening, it seems that applications are calling `setlocale` with `LC_ALL`, getting a `NULL` back, and generating an error, even when other calls to `setlocale` return a good string. Here is the top of an `ltrace` of `locale` (scroll right to see function return values)               % ltrace locale     (0, 0, 0, -1, 0x7f5c1ae44510)                                                                      = 0x7f5c1ae47140     __libc_start_main(0x401d70, 1, 0x7fff7c8cfbf8, 0x404610, 0x4046a0 <unfinished ...>     setlocale(0, "")                                                                                = "en_US.UTF-8"     setlocale(5, "")                                                                                = "en_US.UTF-8"     textdomain("libc")                                                                                = "libc"     argp_parse(0x607280, 1, 0x7fff7c8cfbf8, 0, 0x7fff7c8cfad4)                                         = 0     setlocale(6, "")                                                                                = NULL     dcgettext(0, 0x405aa8, 5, 0, 0)                                                                    = 0x405aa8     error(0, 2, 0x405aa8, 1, 0locale: Cannot set LC_ALL to default locale: No such file or directory)


How to reset Linux root and grub passwords?

If we forget our Linux root password, we can change it by changing grub's boot options. But in this case, we also set a grub password and forgot both passwords. How can we recover both?


System("pause") in Unix?

I normally use a debugger such as `cgdb` so I thankfully hadn't needed to resort to `system` calls for debugging, until now. I have a binary that takes around 30 minutes to load in `gdb` and frequently crashes the debugger thereafter, probably due to the very large number of symbols. This makes my normal workflow (loading `gdb`, adding breakpoints, identifying problem variables, etc.) untenable. In windows I would at this point begin adding lots of `cout` and `system("pause")` (poor man's breakpoint) statements throughout my code; but how do I do this in a unix-like environment?


Is it possible to use pendrive as key for Linux system

I want to give high security for my linux box. So i planed to use my pen drive as key for my linux box. How can i do it ?


WinRAR installer.rar situation (automating expect install)

I'm writing a script that should set up a server with no user input. Whatsoever. In order to automate installation of some programs, I used expect. However, what can I use to automate `expect` instalation? During the instalation user is prompted               Do you want to continue? [Y/n]      and I want to automate the response (Y). Any ideas?


grep list of names and information from bigger file

I have two files: one with list of names (500 entries) and other having some more information for each entry in A.txt and extra entries too. File A.txt (each line is starting with `>` (fasta format) and has spaces, digits and special characters too, but in single line)               >xyz, B=123      >abc, B=231     >mnp, B=567      File B.txt (has some particular information for each entry in A.txt in next line and has extra entries than file A)               >xyz, B=123     01010101010100101     >abc, B=231     1011110000011100000000     >mnp, B=567     10101     >opq, B=678     101010101010101001     >lmn, B=123     101010100000011      Result               >xyz, B=123     01010101010100101     >abc, B=231     1011110000011100000000     >mnp, B=567     10101      I want to grep the entries in list A.txt from list B.txt thanks


How to strip multipe spaces to one using sed?

`sed` on AIX is not doing what I think it should. I'm trying to replace multiple spaces with a single space in the output of IOSTAT:               # iostat     System configuration: lcpu=4 drives=8 paths=2 vdisks=0          tty:      tin         tout    avg-cpu: % user % sys % idle % iowait               0.2         31.8                9.7   4.9   82.9      2.5          Disks:        % tm_act     Kbps      tps    Kb_read   Kb_wrtn     hdisk9           0.2      54.2       1.1   1073456960  436765896     hdisk7           0.2      54.1       1.1   1070600212  435678280     hdisk8           0.0       0.0       0.0          0         0     hdisk6           0.0       0.0       0.0          0         0     hdisk1           0.1       6.3       0.5   63344916  112429672     hdisk0           0.1       5.0       0.2   40967838  98574444     cd0              0.0       0.0       0.0          0         0     hdiskpower1      0.2     108.3       2.3   2144057172  872444176          # iostat | grep hdisk1     hdisk1           0.1       6.3       0.5   63345700  112431123          #iostat|grep "hdisk1"|sed -e"s/[ ]*/ /g"      h d i s k 1 0 . 1 6 . 3 0 . 5 6 3 3 4 5 8 8 0 1 1 2 4 3 2 3 5 4      sed should search & replace (s) multiple spaces (/[ ]*/) with a single space (/ /) for the entire group (/g)... but it's not only doing that... its spacing each character. What am I doing wrong? I know its got to be something simple... AIX 5300-06 **edit:** I have another computer that has 10+ hard drives. I'm using this as a parameter to another program for monitoring purposes. The problem I ran into was that "awk '{print $5}' didn't work because I'm using $1, etc in the secondary stage and gave errors with the Print command. I was looking for a grep/sed/cut version. What seems to work is:               iostat | grep "hdisk1 " | sed -e's/  */ /g' | cut -d" " -f 5      The []s were "0 or more" when I thought they meant "just one". Removing the brackets got it working. Three very good answers really quickly make it hard to choose the "answer".


Screen keeps dimming on Power (Dis-)Connect

I would like to disable the automatic screen dimming when I plug in our out my power adapter. Every time my laptop switches between battery/ac, my screen dims even though I have disabled it in every place I could think of. gnome-power-manager does not seem to be involved, as killing it makes no difference. However, here are some of my settings: In my gconf, under the key `/apps/gnome-power-manager/backlight`, I set:   * `battery_reduce`: false   * `enable`: false   * `brightness_ac`: 100   * `brightness_battery`: 100   * `brightness_dim_battery`: 100   * `idle_dim_time`: 3600 Even under `/apps/gnome-power-manager/lowpower`, I unticked all options. Where else can I control screen dimming?


apt and aptitude died after dist-upgrade

I followed the Debian Instructions for upgrading from Squeeze to Wheezy in Debian. I audited my packages, updated my `/etc/apt/sources.list` file to get Wheezy sources, I ran `apt-get update` and `apt-get upgrade`, and upgraded many packages. Everything was still working. Now, if I do anything with `apt-get` that involves installing or updating, I get the following error: `W: Failed to fetch http://ftp.ca.debian.org/debian/dists/wheezy/main/binary- amd64/Packages Something wicked happened resolving 'ftp.ca.debian.org:http' (-11 - System error)` (the URL may be different, but the error messages are all the same). Many threads online mention to try to ping those addresses. My ISP here blocks ping, but I can do an `nslookup` to the domain names, and get the right IP address. I can also use `wget` to download webpages by name (i.e. `wget www.google.com` works, and gives me the index.html file). So I know name resolution is NOT an issue. I checked the dpkg log, but it doesn't seem too helpful:               /var/log# tail dpkg.log     2014-04-21 09:55:35 status installed dictionaries-common:all 1.12.11     2014-04-21 09:55:35 trigproc menu:amd64 2.1.46 <none>     2014-04-21 09:55:35 status half-configured menu:amd64 2.1.46     2014-04-21 09:55:35 status installed menu:amd64 2.1.46     2014-04-21 09:55:35 trigproc sgml-base:all 1.26+nmu4 <none>     2014-04-21 09:55:35 status half-configured sgml-base:all 1.26+nmu4     2014-04-21 09:55:35 status installed xml-core:all 0.13+nmu2     2014-04-21 09:55:35 status installed sgml-base:all 1.26+nmu4     2014-04-21 11:23:38 startup packages purge     2014-04-21 11:39:37 startup packages purge      (This post is being made about 5 hours later. Apt and Aptitude are not writing here). The files in /var/log/apt haven't been written to since 09:55am today, so nothing is getting written there either. The `/` partition has 83 GB free (I didn't build this server, my predecessor did). Aptitude loads, but won't download anything. In it, if I hit the `u` key to bring up the Update screen, I'm greeted with all the same error messages, in red, and a dialog reading `Downloaded 0 B in 0s (0 B/s). Some files were not downloaded successfully.`. I have tried restarting, and nothing seems to change. My current services are still running OK on it (i.e. Samba, Apache2). What can I look into to try to figure this out?


Install GCC on OpenSUSE 11.4

I installed OpenSUSE 11.4 but I noticed that it don't have `gcc`… How I can install it?


Why does sshd accept local network inbound connections and refuse external inbound connection?

When I try to connect to my server from the internet, I always get:               debug2: ssh_connect: needpriv 0     debug1: connect to address XX.XX.XX.69 port 22: Connection refused     ssh: connect to host XX.XX.XX.69 port 22: Connection refused      But from the local area network with `192.168....` all works fine. Why this difference? _Note_ I tested with `telnet XX.XX.XX.69`. Port 22 is open.


Samba's "inherit permissions" does not inherit modes for other

I have a share with "inherit permissions = yes". I have a directory in the share with mode rwxrwsr-x. If I create a subdirectory, the modes are rwxrws---. The same happens with a parent directory with mode rwxrwxr-x (resulting in rwxrwx---). The permissions of the newly created subdirectory are independent of the OS used to create them and apparently independent of the umask when using smbfs (mount.cifs). The following is an excerpt from **smb.conf** and contains everything related to permissions, modes, etc. of the share.                   force group = +mi         inherit permissions = yes         inherit owner = yes         nt acl support = no      I added "nt acl support = no" for testing purposes and it does not seem to make a difference. Does "inherit permissions" not work for non-user, non-group modes?


Share files between RedHat and Mac

I have one RedHat 6 machine and three Mac OS machines. I want the RedHat one to be a file server, so that all files will be stored there. All Mac clients will access this server according to their rights. It seems that this will not use samba. Could you please let me know what should I do in this case?


How to re-enable the caps lock key?

I am currently setting up my default keyboard layout like this:               setxkbmap -layout us -variant dvorak -option ctrl:nocaps,[...]      It disables the caps lock key and makes it an additional ctrl key, along with a swarm of other options. I would like to do the following to switch keyboard layouts:               setxkbmap -layout us -variant dvorak-l -option ctrl:swapcaps      However, it does not re-enable the caps lock key; both the left control key and the caps lock stay as control keys as far as I can see. I know I can clear the whole options list, but in the interest of maintainability, I would rather not copypaste the options around. How do I re- enable caps lock? _Update:_ Looking at keypresses with xev(1), it appears ctrl:nocaps gives a `Control_L` for both keys, and ctrl:swapcaps "restores" the caps lock key (pressing the key gives `Caps_Lock`). However, the caps lock LED does not light up nor does it actually work. Looking at the `xkeyboard-config/symbols/ctrl` file in X.org sources does hint at the problem:               xkb_symbols "nocaps" {         replace key <CAPS>  {  [ Control_L, Control_L ] };         modifier_map  Control { <CAPS>, <LCTL> };     };     xkb_symbols "swapcaps" {         replace key <CAPS>  {  [ Control_L ] };         replace key <LCTL>  {  [ Caps_Lock ] };     };      The latter option lacks a modifier_map line, whatever that does


How to log if an environment variable is unset?

How can I write a shell script that checks for an environment variable and writes to a log file if the variable is unset? Also, if the file name pointed by env variable doesn't exist, how to create it?


How to set IP adress automatically in Arch Linux?

I am using latest Arch Linux. But whenever I start my PC, it sometimes gets an IP address but most of the time, it gives me stress. I am getting very confused, how can I make sure it is really setting DHCP IP? This is what I have: In `rc.conf`:               DAEMONS=( ... network dhcpcd ) On system boot I have in `~/.xinitrc`               ip link set dev eth0 up     ip link set dev eht1 up     dhcpcd -t 100 But now, I have rebooted 10 times, and I do not get any IP address. Follow up: Yesterday i had interfaces eth0, eth1, lo. After this strange problem of IP. Now i am successfully boot back to my same BOX, same configurations.   1. I do not have any eth1 anymore   2. Network cable was connected to eth1 (eth0 was not used because its in very messy place where i have lot of USB connected + Display cables connected) Why my eth1 completely disappeared? (i never saw this in CentOS, Fedora in my 1 years linux driving experience)


gnome-terminal comes up blank

I'm trying to get gnome-terminal to run on my system. I've tried various installation methods... Unfortunately all of them come up BLANK they also don't accept input very strange... here's a screenshot http://i.imgur.com/EhY4DRX.png wondering if anyone has any knowledge or ideas about this?


Ctrl-space not getting through ssh

I am on windows 8 using GIT bash to access a remote server via `ssh`. When I press `Ctrl`+`Space` in emacs running locally in console (`emacs -nw`), everything works as expected. However, when going over `ssh`, `Ctrl`+`Space` simply inserts a space, while other commands like `Ctrl`+`X` work fine. Why doesn't `Ctrl`+`Space` get through? I have considered switching to a different terminal, but I am also curios as to why this is happening.


How can I install Bastille on a recent version of Debian?

To the best of my ability, I have looked everywhere in order to find a `.deb` file however even on its own website (bastille-linux.org) it is recommended to use `aptitude` which no longer seem to contain Bastille in its repository. How can I download Bastille's installer?


Online administration tool

do you know any solutions like webmin for my ubuntu/debian box? I want to control some of my machines over network via HTTP. Is there any solution that will provide me with a dashboard? Even better if it will support multiple boxes. *EDIT: I got many debian/ubuntu boxes with the same configuration. So I need to a dashboard to overview/control that boxes.  Webmin is a option, but I want to know is there any alternatives like a ajenti, for example. Could our community help me to figure it out?


Who is file owner if the file is created using sudo command?

I logged in using my username `ravbholua`: ravbholua@ravbholua-Aspire-5315:~$ echo $LOGNAME ravbholua I create file named `a1`:               ravbholua@ravbholua-Aspire-5315:~$ echo>a1     ravbholua@ravbholua-Aspire-5315:~$ ll a1     -rw-rw-r-- 1 ravbholua ravbholua 1 Oct  8 09:57 a1      As expected the above file has me (`ravbholua`) as owner. Next I create a2 using sudo with `echo` command:               ravbholua@ravbholua-Aspire-5315:~$ sudo echo>a2     ravbholua@ravbholua-Aspire-5315:~$ ll a2     -rw-rw-r-- 1 ravbholua ravbholua 1 Oct  8 09:57 a2      The owner is me only, i.e. `ravbholua`. Now I create a3 using sudo again but with `vim` command:               ravbholua@ravbholua-Aspire-5315:~$ sudo vim a3     ravbholua@ravbholua-Aspire-5315:~$ ll a3     -rw-r--r-- 1 root root 10 Oct  8 09:57 a3      Oh! how come the owner changes now. It's not me but root. Why such variation with `echo` and `vim`! It's a surprise that with _change of commands_ how can the owner of the created file changes.


Java PATH issue when installing JDK7 on centos 32 bit

I have Installed JDK 7 on CentOS 32 bit virtual machine. I also have set the path for java. In one terminal it is showing java1.7 But when I open another terminal and look for, java -version It is showing java1.4 Need solution, Can anyone help me on this


How can we resize the LVM in Fedora 17?

I was trying to install Backtrack along with Fedora 17. While installing the BT I found there was no free space in my system. When I checked the FS in Fedora, all my space in HDD is used as LVM.


Get the PID of file creation

I am writing a bash script that creates 5 files with the extension ".P" and write a line of "something" into them. "P" represents a number and it's the PID of the process that creates the file. How can you do that? I am creating my file and writing into it like this: `echo "something" > file_name`


Virus 'caught' while using Linux lays dormant, becomes active when login into Windows, can it be?

Can I 'catch' a Windows virus, while using Linux - so it will be saved on my hard drive and start working when I log in to Windows? I know it wouldn't affect the Linux itself. I am using 'Dual boot', not operating both systems at the same time. Also, would a harming change, caused by, say - a spyware, to my browser (Chrome), while surfing when using 'Linux' appear again when I open my 'Chrome' on Windows ?


Setup ssh tunnelling to browse using the IP of a computer inside a private network

I think my question is much easier to understand looking at the draw below. The idea is that for some reasons (such like accessing the intranet of my company, or getting access to some web pages that only my company has access to) I want to browse the Internet using the IP of my company, but from home. The problem is that to get access to my PC "inside" I have to go through a gate. One solution could be of course to login into gate, and from there to my PC, with `ssh -X`. Once inside I can open a Firefox window that will pop up in my PC at home. The problem of this approach is that it is very slow because I have to send the whole GUI through the network, instead of just the Internet packages. A better idea to overcome this problem would be to use `ssh -D8080 ip.remote.company` to create a tunnel, and then setup Firefox in my PC at home to use the remote computer as proxy, sending the internet packages (but not the GUI) through this secure channel, such as explained in many web pages. The problem, of course, is that I have to go through the gate, which adds a level of complexity, so I have to setup (I think) two tunnels instead of just one, those drawn in red in the figure. How can I setup a port forwarding (or something similar) to tunnel my connection to Internet through the network of my company, as illustrated in the figure, from outside? Of course I have access and accounts in the three computers. ![setup](http://i.stack.imgur.com/MQpoP.png)


mysql access denied

Trying to find a way in by going through checklist of possible reasons I am locked out of mysql and one, I read, is to determine if I have grant tables.               -bash-4.1# cd /var     -bash-4.1# ls     cache  empty  lib    lock  mail  opt       run    tmp  yp     db     games  local  log   nis   preserve  spool  www     -bash-4.1# ls db     sudo      Apparently I am supposed to see a file named user.MYD in the db directory. I don't even remember if I created a db after reinstall but I see 'db' there so that must be it(?) Is there a way I can drop the database and recreate one without access in?


Alternative to su/sudo on barebone system

I'd like to run some unit tests in a barebone `chroot` jail on Solaris. **There's no`su` or `sudo`**, and a copy of `su` (with `libpam.so.1`) just returns exit code 1 without any output, with or without parameters. Is there some easy way to **run Bash scripts as a non-root user** on such a system? Maybe setuid or a wrapper script?


Encrypted Booting

I want to boot the Linux from the /boot partition, and also want to encrypt this /boot partition. [ AFAIK, Grub is unable to find the kernel and initrd from an truecrypted partition or cryptsetup encrypted boot partition. ] Is there any way to do so ?


Are there any Linux distros aimed specifically at being Linux tutorials?

Are there any Linux distributions that come pre-loaded with hands-on, guided tutorials or other learning software aimed at teaching a new user how to work with Linux? I'm aware that some distros are naturally easier for new users to pick up than others, but I'm particularly hoping there's one out there that directly _teaches_ the user. I've tried going the independent "learn by using" route with an Ubuntu VM, but would find it much more helpful and fitting to my personal learning and motivational mechanisms to have something that could guide me through the process. To be a bit more specific, I'm not just looking for a general "Linux for Beginners" tutorial (although that also would be a good start). I'm hoping to eventually be as familiar and comfortable in Linux as I am in Windows (System Administrator).


What does this lvcreate call do?

Could someone explain this line:               lvcreate -l 128 vg_appli -n lv_cmp      I think 128 is the size, but what is it doing as a whole?


why does emacs stop superuser from editing files without permissions?

If I have a file I want to edit, as root, I should have the ability to modify it regarless of the permissions. But this does not seem to be the case with all text editors, emacs in particular. If there is a text file with any of the following permissions, with the permissions `-rw-r--r--`, `-r--rw-r--`, or `-r--r--rw-` then as root, I can edit the file, no problem. However, if there are no write permissions at all (`-r--r--r--`), then `emacs` will not allow root to even make changes to the buffer. Vim behaves in a slightly quirky way as well. For the first three cases, it will allow root to save changes with the `:w` command, but in the last case, root must use the override `:w!` command to save. Both `nano` and `gedit` behave properly, giving the super user write access all the time. Does anyone know what the source of this obnoxious behavior is on the part of `emacs` and `vim`? I'm inclined to think it's more of a side-effect of something, rather than an intentional design, based on vim's behavior, but I can't think of what would cause this.


Allow IP packet forwarding from LAN to modem via router

In short: I'd like to be able to telnet to my modem from my PC via my router. There is a simple home router on `192.168.33.1`. It is running OpenWrt. It has the following interfaces defined:               br-lan    Link encap:Ethernet  HWaddr 00:23:CD:20:C3:B0     eth0      Link encap:Ethernet  HWaddr 00:23:CD:20:C3:B0     lan1      Link encap:Ethernet  HWaddr 00:23:CD:20:C3:B0     lan2      Link encap:Ethernet  HWaddr 00:23:CD:20:C3:B0     lan3      Link encap:Ethernet  HWaddr 00:23:CD:20:C3:B0     lan4      Link encap:Ethernet  HWaddr 00:23:CD:20:C3:B0     lo        Link encap:Local Loopback     pppoe-wan Link encap:Point-to-Point Protocol     wan       Link encap:Ethernet  HWaddr 00:23:CD:20:C3:B0      I think only one or two have relevance here:               root@TIBERIUS: ~ > ifconfig wan     wan       Link encap:Ethernet  HWaddr 00:23:CD:20:C3:B0               UP BROADCAST RUNNING MULTICAST  MTU:1500  Metric:1               RX packets:2295 errors:0 dropped:1 overruns:0 frame:0               TX packets:2740 errors:0 dropped:0 overruns:0 carrier:0               collisions:0 txqueuelen:0               RX bytes:270389 (264.0 KiB)  TX bytes:245297 (239.5 KiB)          root@TIBERIUS: ~ > ifconfig eth0     eth0      Link encap:Ethernet  HWaddr 00:23:CD:20:C3:B0               UP BROADCAST RUNNING MULTICAST  MTU:1500  Metric:1               RX packets:6252 errors:0 dropped:0 overruns:83 frame:0               TX packets:4725 errors:0 dropped:0 overruns:0 carrier:0               collisions:0 txqueuelen:1000               RX bytes:863045 (842.8 KiB)  TX bytes:667374 (651.7 KiB)               Interrupt:4      None has an IP address assigned to it. But `pppoe-wan` does. And that's the way Internet access works on this box, via PPPoE. The DSL modem is connected to the router on the WAN port. The one labeled such on the casing. (I do not understand why there are both `eth0` and `wan`.) It has a built-in IP address of `192.168.1.1`. It can be audited via telnet. The first step to do so is to set up an interface on the router box to reach the modem through.               root@TIBERIUS: ~ > ifconfig eth0 192.168.1.220     root@TIBERIUS: ~ > ping 192.168.1.1 -I eth0     PING 192.168.1.1 (192.168.1.1): 56 data bytes     ^C      This adds a route, but doesn't work, not even adding the `-I` switch. Must be the wrong interface. (I don't know what `eth0` corresponds to on this box. Maybe the LAN part, not the WAN part?) Anyway, I then reset the network settings (`/etc/init.d/network restart`) and repeat the procedure for `wan`, and that does work:               root@TIBERIUS: ~ > ifconfig wan 192.168.1.222     root@TIBERIUS: ~ > ping 192.168.1.1 -I wan     PING 192.168.1.1 (192.168.1.1): 56 data bytes     64 bytes from 192.168.1.1: seq=0 ttl=64 time=1.205 ms     64 bytes from 192.168.1.1: seq=1 ttl=64 time=0.496 ms      Audit via `telnet` also works. Now I'd like to also work from my PC on the LAN. My PC is on `192.168.33.152`. Trying to `telnet` the modem from the PC results in "connection refused". And I can't ping the modem either ("Antwort von 192.168.33.1: Zielport nicht erreichbar." = "destination port not reachable"). From what I understand about `iptables` from various docs and graphical schemas floating about the net, packets from the LAN to the modem will enter `PREROUTING` chain on the router (no destination NAT needed), then after routing (hopefully) the `FORWARDING` chain, and then (hopefully) the `POSTROUTING` chain (source NAT required). However, I don't have a clue how to fit this in with the various chains predefined by OpenWrt. There's a couple of them in `nat`:               root@TIBERIUS: ~ > iptables -S -t nat     -P PREROUTING ACCEPT     -P INPUT ACCEPT     -P OUTPUT ACCEPT     -P POSTROUTING ACCEPT     -N nat_reflection_in     -N nat_reflection_out     -N postrouting_rule     -N prerouting_lan     -N prerouting_rule     -N prerouting_wan     -N zone_lan_nat     -N zone_lan_prerouting     -N zone_wan_nat     -N zone_wan_prerouting     -A PREROUTING -j prerouting_rule     -A PREROUTING -i br-lan -j zone_lan_prerouting     -A PREROUTING -i pppoe-wan -j zone_wan_prerouting     -A POSTROUTING -j postrouting_rule     -A POSTROUTING -o br-lan -j zone_lan_nat     -A POSTROUTING -o pppoe-wan -j zone_wan_nat     -A postrouting_rule -j nat_reflection_out     -A prerouting_rule -j nat_reflection_in     -A zone_lan_prerouting -j prerouting_lan     -A zone_wan_nat ! -d 192.168.1.0/24 -j MASQUERADE     -A zone_wan_prerouting -j prerouting_wan      And many more in `filter`:               root@TIBERIUS: ~ > iptables -S -t filter     -P INPUT ACCEPT     -P FORWARD DROP     -P OUTPUT ACCEPT     -N forward     -N forwarding_lan     -N forwarding_rule     -N forwarding_wan     -N input     -N input_lan     -N input_rule     -N input_wan     -N nat_reflection_fwd     -N output     -N output_rule     -N reject     -N syn_flood     -N zone_lan     -N zone_lan_ACCEPT     -N zone_lan_DROP     -N zone_lan_REJECT     -N zone_lan_forward     -N zone_wan     -N zone_wan_ACCEPT     -N zone_wan_DROP     -N zone_wan_REJECT     -N zone_wan_forward     -A INPUT -m conntrack --ctstate RELATED,ESTABLISHED -j ACCEPT     -A INPUT -i lo -j ACCEPT     -A INPUT -p tcp -m tcp --tcp-flags FIN,SYN,RST,ACK SYN -j syn_flood     -A INPUT -j input_rule     -A INPUT -j input     -A FORWARD -m conntrack --ctstate RELATED,ESTABLISHED -j ACCEPT     -A FORWARD -j forwarding_rule     -A FORWARD -j forward     -A FORWARD -j reject     -A OUTPUT -m conntrack --ctstate RELATED,ESTABLISHED -j ACCEPT     -A OUTPUT -o lo -j ACCEPT     -A OUTPUT -j output_rule     -A OUTPUT -j output     -A forward -i br-lan -j zone_lan_forward     -A forward -i pppoe-wan -j zone_wan_forward     -A forwarding_rule -j nat_reflection_fwd     -A input -i br-lan -j zone_lan     -A input -i pppoe-wan -j zone_wan     -A output -j zone_wan_ACCEPT     -A output -j zone_lan_ACCEPT     -A reject -p tcp -j REJECT --reject-with tcp-reset     -A reject -j REJECT --reject-with icmp-port-unreachable     -A syn_flood -p tcp -m tcp --tcp-flags FIN,SYN,RST,ACK SYN -m limit --limit 25/sec --limit-burst 50 -j RETURN     -A syn_flood -j DROP     -A zone_lan -j input_lan     -A zone_lan -j zone_lan_ACCEPT     -A zone_lan_ACCEPT -o br-lan -j ACCEPT     -A zone_lan_ACCEPT -i br-lan -j ACCEPT     -A zone_lan_DROP -o br-lan -j DROP     -A zone_lan_DROP -i br-lan -j DROP     -A zone_lan_REJECT -o br-lan -j reject     -A zone_lan_REJECT -i br-lan -j reject     -A zone_lan_forward -j zone_wan_ACCEPT     -A zone_lan_forward -j forwarding_lan     -A zone_lan_forward -j zone_lan_REJECT     -A zone_wan -p udp -m udp --dport 68 -j ACCEPT     -A zone_wan -p icmp -m icmp --icmp-type 8 -j ACCEPT     -A zone_wan -j input_wan     -A zone_wan -j zone_wan_REJECT     -A zone_wan_ACCEPT -o pppoe-wan -j ACCEPT     -A zone_wan_ACCEPT -i pppoe-wan -j ACCEPT     -A zone_wan_DROP -o pppoe-wan -j DROP     -A zone_wan_DROP -i pppoe-wan -j DROP     -A zone_wan_REJECT -o pppoe-wan -j reject     -A zone_wan_REJECT -i pppoe-wan -j reject     -A zone_wan_forward -j forwarding_wan     -A zone_wan_forward -j zone_wan_REJECT      How can I file my rules in this set of chains? (Feeling encouraged to ask this here because another user was similarly bewildered by the set of default chains in OpenWrt.)


The right way to wrap block of lines in custom text in vim

I would like to be able to select several lines using `vim` when editing an HTML file, then enter some hotkey and get these lines wrapped in a django comment block. For example, I have:               one line     another line      I want to get:               {% comment %}     one line     another line     {% endcomment %}


Extract data from two files

I have two files as given below Output1.csv               201319107648361,12:27:04,12:27:14,0:0:10 secs     201319109089878,12:27:04,12:27:15,0:0:11 secs     201319108968961,12:27:15,12:27:54,0:0:9 secs     201319108686853,12:27:34,12:27:43,0:0:9 secs     .     .     .     n      Output2.csv               201319107648361,200     201319109089878,129     201319108968961,719     201319108686853,412     .     .     .     n      I need to merge these two files in to a single file with one condition i.e if the first field of both the file are same. For Instance, If the first value or field of Output1.csv - **201319107648361** is equal to the first field of Output2.csv then need to print the remaining field of the files in to another file. Desired output file should contain:               201319107648361,12:27:04,12:27:14,0:0:10 secs,200     201319109089878,12:27:04,12:27:15,0:0:11 secs,129     201319108968961,12:27:15,12:27:54,0:0:9 secs,719     201319108686853,12:27:34,12:27:43,0:0:9 secs,412     .     .     .     n


How to create ico file with more then one image

I can use imagemagic to convert png to ico but (I think, not sure) it will create one image ico file for the size I specify.               convert favicon.png --resize 32 favicon.ico      And ico file can contain 2 or 3 images for 16x16 32x32 and 64x64 pixels. Is it posible to create such icon maybe with image magic of other tool?


Use awk to insert a line after N output

I have a text file filled with a bunch of data. I need to pull out lines that contain specific strings. I accomplished this with awk using the following:               awk '/pattern1|pattern2|pattern3/ {print;}' infile      I then need to put a new line (\n) after ever 3rd line. So it would need to look like this               pattern1     pattern2     pattern3     <new line>     pattern1...      I was able to accomplish this by piping the first command into another awk statement               awk -F '\n' '/pattern1|pattern2|pattern3/ { print; }' infile | awk '{ if ((NR % 3) == 1) printf("\n"); print; }'      I figure that there must be a more efficient way of doing this so I started looking to see how I could combine the two commands together. I tried the following:               awk '/pattern1|pattern2|pattern3/ { if ((NR % 3) ==1 ) printf("\n"); print; }'      I figured this would work but the output is completely unpredictable, sometimes there are 5 lines grouped together, groups of 2 lines, but no lines of 3. I was thinking that perhaps there was a delimiter issue so I tried playing with the -F option and setting the IFS but neither changed the output. I figure I am doing something stupid in the way I have tried to combine the pattern match with the if statement but I haven't been able to figure out the combination. Is what I am trying to do possible in a single awk command? And if so, where am I going wrong?


How do I add newly created mount point to fstab?

I just mounted sda2 to /mnt. How can I force a refresh of fstab so it can pickup the changes and insert a new line for sda2-/mnt?


Monitoring progress/liveness of background jobs

I have started a background job. Is there a way to know how it is progressing, and whether it has stopped? My command line is like:               java weka.classifiers.trees.J48  -t data.arff  J48-data.model >&  log


Expanding text format in VI

The following code is taken from the superfish module for websites: > (function($){$.fn.hoverIntent=function(f,g){var > cfg={sensitivity:7,interval:100,timeout:0};cfg=$.extend(cfg,g?{over:f,out:g}:f);var > cX,cY,pX,pY;var track=function(ev){cX=ev.pageX;cY=ev.pageY;};var > compare=function(ev,ob){ob.hoverIntent_t=clearTimeout(ob.hoverIntent_t);if((Math.abs(pX- > cX)+Math.abs(pY-cY)) And once upon a time when editing this kind of file, I once accidentally hit a shortcut key that restructured the code:               (function($){$.fn.hoverIntent=function(f,g){      var cfg={sensitivity:7,interval:100,timeout:0};      cfg=$.extend(cfg,g?{over:f,out:g}:f);      var cX,cY,pX,pY;      var track=function(ev){cX=ev.pageX;cY=ev.pageY;};      var compare=function(ev,ob){ob.hoverIntent_t=clearTimeout(ob.hoverIntent_t);      if((Math.abs(pX-cX)+Math.abs(pY-cY))<cfg.sensitivity       {$(ob).unbind("mousemove",track)       etc..........      I want to know what that shortcut is o.0 It's like the formatting already exists but VI didn't render it?


Java process, swap (/proc Solaris10) memory highly utilized

How can I analyze high swap memory utilization of Solaris 10 for Java processes?


Recommended fstab settings

I made a new partition for my home drive by following this guide I have no idea what the fstab setting it suggests mean: > UUID=???????? /home ext3 nodev,nosuid 0 2 I used an install CD and used "try it without install", so that I could run with my drive unmounted. I used GParted to resize the partition, and make a new one in the unused space. I then looked up the UUID as the guide said (and used ext4 instead), and everything worked fine. However I'd like to understand what the "nodev,nosuid 0 2" settings are. Are these the recommended settings? Is this the only valid setting? Does it matter in any way?


Why does my shell script give the error: "declare: not found"?

Here is a simple example showing that using `declare` in a script the script will not run, while sourcing the script will:               $ cat /tmp/new     #! /bin/sh     declare -i  hello     $ chmod a+rwx /tmp/new     $ /tmp/new     /tmp/new: 3: declare: not found     $ source /tmp/new     $       I wonder why directly running the script doesn't work, while sourcing it does? How can I make the first one work? Thanks!