Using tail to follow daily log file in Bash

I have a task to use a bash script to monitor a couple of log files named with the current day, eg. YYYY-MM-DD.log. (1) I used `tail -f` to follow the file but unable to deal file rotation. Even if using `tail -F $FILENAME`, I can only follow the log for 24 hours max and need to restart again. What I wish to accomplish is to have something like `tail -F $CURRENTDATE`, so I can leave it running forever and every midnight It will switch to follow the new log file named with current date. But it seems the variable `$CURRENTDATE` is not dynamic. Is there another way to do this without `crontab`'ing the script every 24 hours? Maybe set a symbolic file or something? (2) Meanwhile, if `tail -f` is used, what signal will it return if the file it follows is missing or changes its name? How can I trap the exceptions during execution.


Determine which process is creating a file

Given file path, how can I determine which process creates it (and/or reads/writes to it)?


Find which process is modifying a file

A specific file on our production servers is being modified at apparently random times which do not appear to correlate with any log activity. We can't figure out what program is doing it, and there are many suspects. How can I find the culprit? It is always the same file, at the same path, but on different servers and at different times. The boxes are managed by puppet, but the puppet logs show no activity at the time the file is modified. What kernel hook, tool, or technique could help us find what process is modifying this file? * * * lsof is unsuitible for this, because the file is being opened, modified and closed very quickly. Any solution that relies upon polling (such as running lsof often) is no good. * * *   * OS: Debian testing   * Kernels: Linux, 2.6.32 through 3.9, both 32 and 64-bit.


How do I know which process created a file?

Some program keeps creating a `Desktop` folder in my home directory, although I configured `xdg-dirs` so that my home directory is my `DESKTOP` directory, so this shouldn't happen. Anyway, how do I know who is the culprit? I strongly suspect of Firefox but I want to be sure.


Need to delete mails for a range of dates in Linux

I have 1 million mails generated in a Linux sever due to a cron job. I want to delete the mails, but not all as this cron mails useful to troubleshoot and find out the issue with cron job's execution. So I need to keep 1 month's mail and remove the remaining.


Which book of those two should i read to study networking for Unix/Linux administrator?

I'm quite a beginner to networking, I want to get the information that i need as a Linux/Unix admin. I have two books in hand right now:   1. TCP/IP Illustrated, Volume 1: The Protocols    2. UNIX and Linux System Administration Handbook The first one is 1059 pages long, only for networking, So it's so much detailed. The second one i feel is talking about networking in an outlined fashion, About 500 pages. I don't want to spend too much time studying for something that won't benefit me much. So what book of those two do you recommend me ? If there's another one, I'd be grateful if you told me about.


Calling an email script from another script using ssmtp on ubuntu

I have an issue with a script, which works fine except that it only sends email when I run it directly from the shell but when called during crontab it doesn't send the emails. There are 2 scripts the main script which does a backup and it calls another script which sends the email. the backup script dump the summary of the operation in a file and reads the file again when to pass it to the email sender script to send. Based on how ssmtp works that's the architecture I have come up with. I needed to change the subject based on the success or failure of the operation. I have been using my gmail thus using the ssmtp library to send the email. How to make the backup script send the email when called by `crontab` schedule?               #!/bin/bash          # File system Parameters     #=========================================================================     TIMESTAMP=`date +%F-%H.%M.%S`     TODAYS_DATE=`date +%Y-%m-%d`          BACKUP_PATH="/mnt/backups/mongo"     SCRIPT_PATH="/root/script"     FILE_NAME="mongodb-$TIMESTAMP"          # Email Parameters     #=========================================================================     TEMPLATE_FILE="/tmp/template.txt"     EMAIL_SUBJECT_CONTEXT="Xylo"     EMAIL_RECIPIENT="myeamil"     EMAIL_SENDER="DB man"     #=========================================================================          BACKUP_PATH=$BACKUP_PATH/$TODAYS_DATE               echo; echo "files will be geneated in  $BACKUP_PATH" | tee $TEMPLATE_FILE     #=========================================================================          [ ! -d  $BACKUP_PATH ] && mkdir -p $BACKUP_PATH || :           if [ -d "$BACKUP_PATH" ]; then         cd $BACKUP_PATH              TMP_BACKUP_DIR="$BACKUP_PATH/mongodb-$TIMESTAMP"              echo; echo "=> $(date +%F-%H.%M.%S) Backing up Mongo Server: $MONGO_HOST:$MONGO_PORT" | tee -a $TEMPLATE_FILE; echo -n ' ' ;                   if [ "$MONGOUSERNAME" != "" -a "$MONGOPASSWORD" != "" ]; then             $MONGODUMP_PATH --host $MONGO_HOST:$MONGO_PORT -u $MONGOUSERNAME -p $MONGOPASSWORD --out $TMP_BACKUP_DIR >> /dev/null         else              $MONGODUMP_PATH --host $MONGO_HOST:$MONGO_PORT --out $TMP_BACKUP_DIR >> /dev/null         fi              echo; echo "=> $(date +%F-%H.%M.%S) Mongo Server: $MONGO_HOST:$MONGO_PORT  backup files generated"  | tee -a $TEMPLATE_FILE; echo -n ' ';              if [ -d "$TMP_BACKUP_DIR" ]; then                  if [ "$FILE_NAME" == "" ]; then                      FILE_NAME = "mongodb-$TIMESTAMP"             fi                  echo; echo "=> $(date +%F-%H.%M.%S) dumping file into  $FILE_NAME.tar.gz"  | tee -a $TEMPLATE_FILE; echo -n ' ';                  $TAR_BIN_PATH --remove-files -czf $FILE_NAME.tar.gz $TMP_BACKUP_DIR >> /dev/null                  if [ -f "$FILE_NAME.tar.gz" ]; then                      echo "=> $(date +%F-%H.%M.%S) successfully generated file $FILE_NAME.tar.gz of size: `du -sh $FILE_NAME.tar.gz` " | tee -a $TEMPLATE_FILE; echo;                      echo; echo "=> $(date +%F-%H.%M.%S) Uploading $FILE_NAME.tar.gz to $S3_BUCKET_NAME on s3" | tee -a $TEMPLATE_FILE; echo -n ' ';                          s3cmd put $FILE_NAME.tar.gz s3://$S3_BUCKET_NAME/$S3_BUCKET_PATH/$FILE_NAME.tar.gz                          filename=s3://$S3_BUCKET_NAME/$S3_BUCKET_PATH/$FILE_NAME.tar.gz             count=$(s3cmd ls ${filename} | awk "\$4 == \"${filename}\" { print \$4 }" | wc -l)     #            if [[ $? -eq 0 ]]; then              if [ $count -eq 0 ]; then                          echo "!!!!=> File $FILE_NAME.tar.gz could not be added to s3" | tee -a $TEMPLATE_FILE                     /bin/sh "$SCRIPT_PATH/s3_backup_email_sender.sh" "$EMAIL_RECIPIENT" "$EMAIL_SENDER" "$EMAIL_SUBJECT_CONTEXT BACKUP FAILURE [s3 Upload]" "$(cat $TEMPLATE_FILE)"                 else                         echo "=> $(date +%F-%H.%M.%S) File $FILE_NAME.tar.gz has successfully be added to s3" | tee -a $TEMPLATE_FILE                                /bin/sh "$SCRIPT_PATH/s3_backup_email_sender.sh" "$EMAIL_RECIPIENT" "$EMAIL_SENDER" "$EMAIL_SUBJECT_CONTEXT BACKUP SUCCESSFUL" "$(cat $TEMPLATE_FILE)"                      fi                 if [ -d "$TMP_BACKUP_DIR" ]; then                         rm -rf "$TMP_BACKUP_DIR"                 fi              else                      echo "!!!=> Failed to create backup file: $BACKUP_PATH/$FILE_NAME.tar.gz"  | tee -a $TEMPLATE_FILE; echo;                 /bin/sh "$SCRIPT_PATH/s3_backup_email_sender.sh" "$EMAIL_RECIPIENT" "$EMAIL_SENDER" "$EMAIL_SUBJECT_CONTEXT BACKUP FAILURE [Failed to gzip $FILE_NAME.tar.gz]" "$(cat $TEMPLATE_FILE)"             fi              else             echo; echo "!!!=> Failed to backup mongoDB or Nothing to Back up"  | tee -a $TEMPLATE_FILE; echo;              /bin/sh "$SCRIPT_PATH/s3_backup_email_sender.sh" "$EMAIL_RECIPIENT"  "$EMAIL_SENDER"  "$EMAIL_SUBJECT_CONTEXT BACKUP FAILURE [Nothing to back up]" " $(cat $TEMPLATE_FILE)"              fi      else          echo "!!!=> Failed to create backup path: $BACKUP_PATH" | tee -a $TEMPLATE_FILE          /bin/sh "$SCRIPT_PATH/s3_backup_email_sender.sh" "$EMAIL_RECIPIENT" "$EMAIL_SENDER" "$EMAIL_SUBJECT_CONTEXT BACKUP FAILURE [Failed to create backup folder]" "$(cat $TEMPLATE_FILE)"      fi      this is the sending script               #!/bin/bash     Now=$(date +"%Y-%m-%d")     SSMTP="$(which ssmtp)"               TEMPLATE="/tmp/s3_backup_mail.txt"          echo "To: $1" > $TEMPLATE     echo "From: $2" >> $TEMPLATE     echo "Subject: $3" >> $TEMPLATE     echo " " >> $TEMPLATE     echo  "$4" >> $TEMPLATE          $SSMTP $1 < $TEMPLATE     #rm $TEMPLATE


Jack vs Pulseaudio -- how is it faster?

I see a bunch of claims that Jack is faster than Pulse and has less latency. How is that so? Why does Pulse call itself lightweight, and the Jack guys call it fat? Could anyone break down the internals of these two daemons to a layman?


/proc/cpuinfo "cache" category: L1, L2 or total?

When I look in /proc/cpuinfo, one of the lines tells me I have 6144 KB of cache. Is this L1 cache, L2 cache, or the sum of both of them? In any case, how do I find out how much L1 and L2 cache my system has?


Iptables forward with pptp and openvpn

I have OpenVPN and PPTP installed on a VPS. I'm having a few questions that I can't seem to get a firm answer on. I want to install OpenVPN on 1.1.1.1 (eth0, public IP address) and PPTP on 1.1.1.2 (eth0:1, public IP address). I was able to achieve this with SNAT. However, from all the tutorials I've been reading it recommends forwarding ppp+ to eth0 and vice versa and the same situation for the tun interface.               iptables -A FORWARD -i tun0 -o eth0 -j ACCEPT     iptables -A FORWARD -i eth0 -o tun0 -j ACCEPT     iptables -A FORWARD -i ppp+ -o eth0 -j ACCEPT     iptables -A FORWARD -i eth0 -o ppp+ -j ACCEPT      My setup is CentOS, dedicated server. For some reason I'm assuming iptables will route all traffic from eth0 to tun0 and stop at that.   1. Will these forward rules conflict with each other?   2. Will I need to forward the ppp+ to eth0:1 instead to avoid confliction? Is it even possible? I haven't figured out a way yet.    3. Is iptables smart enough to route traffic that is specific to tun and ppp through these rules?


systemd - umount device after service which depends on it finishes

I'm trying to implement a mechanism of automated backup using udev rules and systemd. The idea is to launch a backup routine upon hot-plugging a specific storage device, quite similar to this question, for which I provided an answer myself by the way, but here I'm interesteded in discussing some further tweaks. Namely I want the device to be umounted after the backup service finishes. **Some background:** So far I got it to work using udev to start up a systemd service which itself runs a backup routine. The relevant files follow: **backup.service**               [Unit]     Description=<DESCRIPTION HERE>     BindsTo=<STORAGE DEVICE UNIT HERE>.device mnt-backup.mount     After=<STORAGE DEVICE UNIT HERE>.device mnt-backup.mount          [Service]     ExecStart=<CALL TO BACKUP SCRIPT HERE>      **mnt-backup.mount**               [Unit]     DefaultDependencies=no     Conflicts=umount.target     Before=umount.target          [Mount]     What=/dev/disk/by-uuid/<DEVICE UUID HERE>      Where=/mnt/backup     Type=<FILESYSTEM HERE>      **90-backup.rules**               KERNEL=="sd*", ATTRS{serial}=="<HD SERIAL HERE>", TAG+="systemd", ENV{SYSTEMD_WANTS}+="backup.service"       **The question:** Now I want mnt-backup.mount to be stopped as soon as backup.service finishes. According to the documentation ExecStartPost= will be executed after the command in ExecStart=, so I tried adding               ExecStartPost=/usr/bin/systemctl stop mnt-backup.mount      to backup.service, even though I realise it stops mnt-backup.mount, to which it is itself bound, what, as far as I understand, effectively requires backup.service to be stoped before mnt-backup.mount for a graceful stop, hence creating a cyclic dependence. When testing this, it worked a couple of times before I experienced a kernel panic, the first I've seen on my machine, so it got me wondering if this was somehow the cause. In any case, **is my approach correct?**


Error with gedit can't save any file

meraj@meraj-SATELLITE-C850-A785:~$ sudo gedit /etc/php5/apache2/php.ini          (gedit:16243): Gtk-WARNING **: Calling Inhibit failed: GDBus.Error:org.freedesktop.DBus.Error.ServiceUnknown: The name org.gnome.SessionManager was not provided by any .service files      whenever I save the file in gedit it is not saved what should I do? I have ubuntu 14.04


Why do the data and code segments completely overlap in Linux?

Context: I'm reading "Understanding the Linux kernel, 3d ed", which uses the 2.6.11 kernel. Question: As I understand, the physical address is obtained by translating the linear address, which is obtained by translating the logical address. The logical address consists of a segment selector, which identifies a segment in a Description Table The Linux Global Description Table includes, amongst other segments, a user code and data segment. But the base address of both segments is `0x0`, and their size is also the same. So they completely overlap. So as I understand, the logical address `cs + offset` is identical to the logical address `ds + offset`, where `cs` and `ds` are the CPU registers that hold respectively the code segment selector and data segment selector. I think this is the case because both segments have the same base address, which is incremented with the offset to get the linear address. If this is the case and they both map to the same linear address, don't they also map to the same physical address? If so, what is the use of having seperate `cs` and `ds` registers?


Creating an HTTPS tunnel

I have a VPS. How do I connect to my server through HTTPS protocol and redirect my browser connections to the HTTPS connection? Currently I use SSH tunnel but it's too slow.


autoconf save ./configure command line to config.h

Some binaries save the command line used to configure them inside the binary (I don't remember any that do, otherwise I'd check the source). Is there a way to obtain the command line used as a macro in configure.ac? For example, if I compile my code with               ./configure --foo bar CXX=g++      I would like to save **--foo bar CXX=g++** to a macro in config.h so it can be output by the binary using a flag               ./myprogram -V     Version 1.0, compiled using: "./configure --foo bar CXX=g++"


remote desktop view of a Debian Lenny Machine

Let me give a summary of my project specification. I have a windows server and bunch of debian clients on the same LAN, Debian machines do not have x window system, they are bound to command line use. I am running a QT application on system start so user only interacts with my GUI before he sees anything else. According to my project requirements, we should allow system admins to view what end user is doing in debian machines at any time, therefore he should be able to see their screens at any time. He will be using a windows machine to do that. Therefore I am wondering if it is possible to share debian's screen with a windows server, and what would be involved in that. Do I need VNC server setup on debian machines to accomplish that? Is there any other way?


No incoming connections on Fedora 17, except on port 80

All incoming connections seem to be refused on my Fedora machine, except on port 80 with apache. The ports I have tried are 8111 and 1111, neither does work. I have done the forwarding on my hardware router and configured the firewall (iptables, using the GUI) to allow connections on those ports. However, it is still not working. When I run a small HTTP server (the node.js hello-world) on one of these ports and try to curl it, it only works on localhost but not with the public ip address. Using the public address, I immediately get `curl: (7) couldn't connect to host`. Without the port forwarding or the firewall exception, this takes a while and does not appear immediately - so i think that that's not the problem. I also tried using the web browser instead of curl, without any difference. I have tried a tool named `tcptrack`, which shows this whenever I try to curl using the public address (I changed the public address here, 192.168.0.2 is the local one):               215.17.123.60:52014   192.168.0.2:1111      RESET        16s    0 B/s     192.168.0.2:52014     215.17.123.60:1111    RESET        16s    0 B/s      So I am receiving the packages but they are rejected somehow (I don't know exactly what RESET means). Is there another firewall or something? Like I said, port 80 works fine.


Network Disabled

I have just installed ubuntu server edition in order to create a home network. But I am not able to find IP of the machine through ifconfig (showing only localhost). Then I tried                lspci | grep -i ethernet      output:               09:00.0 Ethernet controller: Marvell Technology Group Ltd. 88E8040 PCI-E Fast Ethernet Controller (rev 13)      lshw -C Network Then output was `*-network DISABLED`


Why can user have lower permissions than group or other? Who can change them?

It is my understanding that the owner of a file `user` can have lower permissions than `group` or `other`.   1. What is the justification for this?   2. Can only root and the owner change the permissions on a file?   3. If root removes permissions of the owner, can the owner add their permissions back with `chmod`?


I'm not getting syntax coloring in vim (using Cygwin)

I've been so far unable to figure out why vim's syntax coloring is not working for _most_ files, and it's driving me batty. In case this is relevant: I'm working in Cygwin (more specifically/accurately the bash shell that comes with Git for Windows) because it's the only thing I've been able to smuggle into this Windows shop so far. (I sometimes bring in my MacBook Air but it is somewhat frowned upon. Also, as with most Windows shops they're paranoid about installing software, so a full Cygwin installation would need justification. Also, I'm not using gvim because I prefer to work with vim in a terminal.) I can get syntax coloring to work if I tell vim that the file is C++               :set syntax=cpp      or if it is a shell script, but not if I'm working in Ruby or PHP. I've ensured that syntax is turned on with both `:syntax on` and `:syntax enable`. I've tried installing vim syntax files in `~/.vim/syntax/<syntax-type>.vim` but this has not made a difference. I've ensured files had the standard file extension, so if working with a Vagrantfile I tried adding '.rb', and I've tried avoiding my .vimrc file (as well as tried other .vimrc files):               vim -u /dev/null Vagrantfile.rb      I've also ensured Ruby files had the normal 'shebang' line. Nothing has worked so far. What could prevent vim from properly coloring certain files?


Is it possible to integrate Apple iCloud services (e.g. contacts, calendars) with Fedora 20?

I am a new laptop user after using an iMac desktop for about seven years. Over that time, I had become fairly reliant on Apple's services syncing between my iPhone and my iMac. Now that I'm on Fedora, I'm having to run two separate calendars and contact books, and manually update changes between the two. Is there a way I can integrate Apple's iCloud features (namely contacts and calendar) onto my laptop? It would make day-to-day computing much easier.


How to Remove Windows from dual boot setup?

I originally had Windows 7 Starter and Updated to the Windows 8 90 Day Trial. 30 Days into the trial I decided I absolutely hate it and wanted to try Linux Mint. I installed Linux Mint and found out I absolutely love it, and now I want to remove Windows 8. I have researched all over the web, using: `How to remove Windows 8 from Linux Mint`, but my search results always end up being `How to remove Linux Mint`. This is not what I want. I want to remove Windows 8 from my computer by using Linux Mint. What should I do to do this? I absolutely love Linux Mint.


rcs and graphical diff

I have a machine running Ubuntu 6.06. Source files under rcs (no git available). I need to visually compoare older revs of files with the checked out version. Until now I have moved the file and compared.               mv test.c tmptest.c     co -r1.16 test.c     xxdiff test.c tmptest.c     mv tmptest.c test.c      I know I can make this in a script, but is there a better way to do this? Without touching test.c?


Replace a pattern in a file with a long string

I'm writing a little shell script to generate a directory listing. To make the output easily customizable, the script just builds a HTML-table and than should replace a specific token in a template file with that table and write it to `stdout`. **Example:**   Template file:               <!doctype html>     <html>         <head><title>Directory Listing</title></head>         <body>             {{LISTING}}         </body>     </html>      `{{LISTING}}` should be replaced with the listing (which is stored in a shell variable). The problem here is, that a simple `sed 's/{{LISTING}}/$listing/'` would be limited to the maximum argument length which doesn't work with long listings. How can I replace a pattern in a file with a long string using POSIX utilities? EDIT:   To add more clarification: My current solution is like that:               awk '{ gsub(A, B); print; }' A="{{LISTING}}" B="$listing" < $template      `$listing` gets expanded as awk is invoked, but this can exceed argument length limits, since `$listing` can be really long. For example, when generating a listing of `/usr/lib`, I get an error:               /bin/awk: Argument list too long      I'm thinking whether there is a solution to replace a pattern in a textfile with `stdin`.


HOWTO check if a user account is blocked against /etc/shadow

After set the Account Expire parameter on /etc/shadow (field #7) to 90 days,I need to know where to look around if an user account is locked down or not after those amount of days. Right now, the only solid way which I did find to do that is just seeing the message that says the account is expired when the user tries to do ssh against the server. Any ideas on how to check that from inside the server? I'm using a Red Hat (Santiago) one.


What is the debian equivalent to this repoquery command?               repoquery --repofrompath="abc,http://path/to/repo" --repoid=abc -q mypkg      --qf %{NAME}_%{VERSION}_%{RELEASE}_%{ARCH}_%{BUILDTIME}_%{PACKAGER}_%{LOCATION}      This will ignore any repos specified under /etc/yum.repos.d, and list the requested information for the latest available version of mypkg in the repo specified in repofrompath. So far, I have found               apt-cache showpkg mypkg      but I am not sure how to use the -c config-file option to simulate the effect of repofrompath above.


Vim key binding to cycle through windows

How do I bind one single key to cycle through the windows? For example, each time I want to switch a window, I have to click `ctrl-a` (default was `ctrl-c`) then use arrow key up/down/left/right to switch. Can I have just one key that does `ctrl-a` + switching the window? I was thinking to bind it with the `tab` key, but I couldn't resolve the issue yet.


Disable the configuration tool in Zsh

When there is no `.zshrc` file in a user's home directory and `zsh` is started, an interactive configuration utility is run instead of directly giving access to the shell prompt. I set up `zsh` to be the default shell on my Debian Wheezy systems. Therefore every newly created user gets `zsh` as login shell if I do not change that manually. Also there is a default `.zshrc` in `/etc/skel`, so all regular users on my system have a copy of the file in their home directory. This is not the case for system users. When I now change into a system user (for example the user for a specific network daemon) via `sudo` or `sh` I run into the configuration tool, because these users have no `.zshrc` in their home directories. It doesn't feel right to place a `.zshrc` into each and every daemon's home directory, which also would be a pain to setup and maintain on a lot of systems. But I still wouldn't want to downgrade to a less comfortable `bash` for these users. Is there a way to disable the `zsh` configuration tool without having to create a `.zshrc` file in the user's home directory? Additionally a way to setup a single file to be the system-wide default `.zshrc` for all users which don't have one would be nice too.


slow down of mpi by Torque

I'm running Torque with Open MPI on a cluster with 30 nodes and 360 cores. I have found that the wall time of `mpirun -np N ~./myjob` and `qsub -l nodes=1:ppn=N mpirun -np N ~./myjob` differs many times. For small jobs it grows from 1.2 s to 20 s, from 2 s to 37 s and so on.   For larger jobs the difference becomes important. How to overcome it?


Launch a GNOME session from terminal

I'm sshing into my friends machine and I'm wondering how would i launch a GNOME session over SSH? I need to open a web browser on his machine to view something which can only be done from his hostname. What's the easiest way to achieve this via SSH?


VSFTPD Configuration with Shared folder in Oracle Linux 6.5

I'm trying to configure VSFTPD, for each user to have a PublicFTP directory, since all users are chrooted, but they still need a central FTP dir. I've created this directory in each of the local system users, and created the shared directory in `/var/www/public_ftp` with an ownership of "Developers" group and chmodded to 775. Next step was to add the entries in `/etc/fstab`. I even restarted the server and the vsftpd service. When I login to a user from Developers group and create a file in their PublicFTP directory the file is created and shows up under `/var/www/public_ftp`; just like as in any other user's PublicFTP directory. Now, if I login via FTP and try to upload a file to the PublicFTP folder, I get permission denied message.               drwxrwxr-x.  2 root    Developers 4096 Mar 28 10:49 PublicFTP    /home/<user>/PublicFTP     drwxrwxr-x.  2 root    Developers 4096 Mar 28 10:49 public_ftp   /var/www/public_ftp      groupmems -g Developers --list > the list contains the . _/etc/vsftpd/vsftpd.conf:_               anonymous_enable=NO     local_enable=YES     write_enable=YES     local_umask=022     dirmessage_enable=YES     xferlog_enable=YES     xferlog_std_format=YES     connect_from_port_20=YES     ascii_upload_enable=YES     ascii_download_enable=YES     ls_recurse_enable=YES     listen=YES     pam_service_name=vsftpd     userlist_anble=YES     tcp_wrappers=YES     use_localtime=YES     chroot_local_user=YES      _/etc/fstab:_               /var/www/public_ftp    /home/<user>/PublicFTP    none    bind    0 0      ### Sample Scenario   1. Login to the server and touch a file.              $ cd /home/<user>/PublicFTP     $ touch Hi.txt     $ ls -la     -rw-r--r--.  1 <user> users 0 Mar 28 11:05 Hi.txt        2. Confirm on the server side.              $ cd /var/www/public_ftp     $ ls -la     -rw-r--r--.  1 <user> users 0 Mar 28 11:05 Hi.txt        3. Open some FTP application from a client machine and connect to the FTP server and login.   4. Navigate to PublicFTP directory is empty. Kinda funny since on the server it's clearly visible.   5. Try to copy a file. An error occurred copying a file to the FTP Server. Make sure you have permission to put files on the server.              Details:     200 Switching to binary mode.     227 Entering Passive mode (10,232,118,108,90,133).     553 Could not create file.        6. The contents of the log file:              Mon Mar 31 09:52:07 2014 [pid 17629] [<user>] OK LOGIN: Client "xxx.xxx.xxx.xxx"     Mon Mar 31 09:52:07 2014 [pid 17634] [<user>] FAIL DELETE: Client "xxx.xxx.xxx.xxx", "/PublicFTP/proxy.txt"


How to change Fedora 14 dual-monitor default behavior (No clone)

I am running F14 on my laptop, and I use it either with or without an external screen.               [nbarraille@barraille ~]$ xrandr | grep " connected "     LVDS1 connected 1280x800+1280+0 (normal left inverted right x axis y axis) 304mm x 190mm     VGA1 connected 1280x1024+0+0 (normal left inverted right x axis y axis) 338mm x 270mm      When the VGA screen is plugged in, everytime I reboot the system sets it up so that VGA1 is a clone of LVDS1 and I have to do a:               xrandr --output VGA1 --left-of LVDS1      How can I change it to be the default behavior? Thanks!


different loopback mounted volumes exported through NFS are seen as 1 by the client

I have a rather peculiar problem. I'm running `3.2.0-58-generic #88-Ubuntu` (Ubuntu 12.04) and I have mouonted the following loopback devices:               cat /proc/mounts | grep loop         /dev/loop0 /work/kernel/AEL/fpga-filesystem ext4 rw,relatime,user_xattr,barrier=1,data=ordered 0 0         /dev/loop1 /work/kernel/AEL/model-filesystem ext4 rw,relatime,user_xattr,barrier=1,data=ordered 0 0          sudo losetup -a     /dev/loop0: [fc02]:4990567 (/work/kernel/AEL/openembed-fpga.img), offset 54525952     /dev/loop1: [fc02]:4990564 (/work/kernel/AEL/vexpress64-openembedded_minimal-armv8-gcc-4.8_20140222-611.img), offset 54525952      The 2 .img files are completely separate files and not symlinks:               ls -li /work/kernel/AEL/           2 drwxr-xr-x 21 root     root           4096 Mar 26 20:14 fpga-filesystem           2 drwxr-xr-x 21 root     root           4096 Mar 26 20:05 model-filesystem     4990567 -rw-r-----  1 nikbor01 nikbor01 3221225472 Mar 27 09:47 openembed-fpga.img     4990564 -rw-r-----  1 nikbor01 nikbor01 3221225472 Mar 26 20:06 vexpress64-openembedded_minimal-armv8-gcc-4.8_20140222-611.img      The reason why the 2 directories have the same INODE number is that the images are the same (as in have the same content) but are clearly mounted under a different loop device. And finally I export the 2 directories where the images are mounted via nfs:               /work/kernel/AEL/fpga-filesystem *(rw,sync,no_subtree_check,no_root_squash,insecure)     /work/kernel/AEL/model-filesystem *(rw,sync,crossmnt,no_subtree_check,no_root_squash,insecure)      And now the pinnacle of everything - when I mount fpga-filesystem on client1 and model-filesystem on client2 they both see the same filesystem (e.g. the one under fpga-filesystem). Here is the mount on client1:               10.1.209.36:/work/kernel/AEL/fpga-filesystem / nfs rw,relatime,vers=3,rsize=4096,wsize=4096,namlen=255,hard,nolock,proto=tcp,timeo=600,retrans=2,sec=sys,mountaddr=10.1.209.36,mountvers=3,mountproto=tcp,local_lock=all,addr=10.1.209.36 0 0      And on client2:               10.1.209.36:/work/kernel/AEL/model-filesystem / nfs rw,relatime,vers=3,rsize=4096,wsize=4096,namlen=255,hard,nolock,proto=tcp,timeo=600,retrans=2,sec=sys,mountaddr=10.1.209.36,mountvers=3,mountproto=tcp,local_lock=all,addr=10.1.209.36 0 0      However, when I do `ls /` on both clients I see the conents of only the fpga- filesystem directory, which makes absolutely no sense. Any ideas how i might be able to debug the issue.


How do I get the menu bar to reappear

This sound like a really simple thing, but it has me stumped. I was using Thunar file manager on my Xfce desktop and I wanted to try it without the menu bar at the top (the one with File, Edit, View and so on), so I disabled it through View > Menu Bar (or something similar). After realising how much I use and rely on it, I wanted it back, but could not find an option anywhere to re-enable it. I tried using the Alt key and the file manager preferences, but couldn't find anything. Surely there's an option _somewhere_.


Change 4 mirrored HDDs to RAID 10

My boss has a large computer (12-core, 4 HDD computer that we use for scientific computing) and he has all of the HDDs mirrored. Is it possible to change this to RAID 10 without data loss and without needing to copy all of the data to a temporary HDD? OS: Mac OSX Mountain Lion. I can find out other details as necessary when I have access to the computer (unless there is useful information I can obtain by ssh'ing in and using the terminal).


How do I start my service at boot-time?

I'm trying to run a CherryPy app on my NetBSD 5.1 box. To have it start automatically, I've added this line to my `/etc/rc.local`:               /bin/httpd &      When I boot the machine, some of the output of the Webserver starting is visible, right after the `Starting sshd.` message. None the less, I can't connect to my web-server. I can log into the machine, and when I start the web-server by typing `httpd`, it all works well. What am I doing wrong? What is the correct way to have my program start on boot-time?


How to get the latest GNOME shell in Fedora?

I want to try gnome-shell 3.5 but I dont see it in the repos, I'm using Fedora 17, is there any way adding gnome-shell 3.5 to my repos? Regards **Update:** Please note the question was asked on Aug 2012. Now i'm using Fedora 18 with gnome-shell 3.6 as on 29th jan 2013. what I meant was how to install the latest from gnome-development. I see that as of today GNOME shell 3.7 something is the latest but Fedora has 3.6 in its repos. Thats what my question is about, how to get the latest.


Do I really need an antivirus on Debian 7?

I use Debian 7 and I visit unknown and different websites. I want to know that people say that we get virus form internet and those virus hack our Bank accounts. Do I really need any antivirus? I have 512 MB RAM. Also, I do not install software from our sources except repository. My RAM is 47% used. I have also installed Wine.


linux static compilation issue

I am building testdisk as static and when i run > make static i am getting the following error > /usr/bin/ld: cannot find -luuid > > collect2: ld returned 1 exit status what's the problem? in the makefile i have the following line > LIBS = -lz -lntfs -luuid -lcrypto -lext2fs -lcom_err and i am getting error on all the floowing flags > -luuid -lcrypto -lext2fs -lcom_err


VNC on elementary os

I installed elementary OS on my laptop and tried to install VNC server. First I installed `vnc4server`, opened and logged from phone. On screen I saw:               failed to load session gnome      How do I need to configure it to run under elementary OS? I am not interested in installing GNOME.


"tcpdump" to capture the last packets

I am monitoring a certain port, because my application uses that port, it seems that the connection drops at random times, I want to see what are the last packets passing through before the connection drops: I used this line                sudo tcpdump -XX -i eth0 port 3050 | tail  >> tcpamir.txt      but for it to work I have to start another terminal and issue               sudo killall tcpdump      is there a better approach? EDIT1: it is important to capture only the last packets since I don't want the file to balloon, since there is enough traffic to fill the disk space quickly .


Grepping several lines from Nmap output

I apologize in advance as this is a simple question. So I'm attempting to scan a Class C to identify all mail servers by IP. The vast majority of IPs aren't mail servers. I'm trying to filter out the ones that are. I've tried the following but they haven't returned what I wanted.               nmap -p 25 192.168.15.1-254 | grep report && grep open       and               nmap -p 192.168.15.1-254 (grep report | grep open)      Is there a different utility that I should use? Or is it a problem with my syntax?


Make all files under a directory read-only without changing permissions?

First, some background:   * /dev/md1 is a RAID-0 array serving as primary file store. It is mounted to /var/smb.   * /dev/md2 is another RAID-0 array storing backup snapshots taken from /dev/md1. It is mounted to /var/smb/snapshots.   * Three directories are made available via Samba: /var/smb/files (publicly-shared files), /var/smb/private (private files), and /var/smb/snapshots (providing read-only access to backup snapshots). Only users in the smbusers group are allowed to access the files and snapshots shares; similarly, only users in the smbprivate group are allowed to access the files in private. Additionally, Linux permissions prohibit users not in the respective groups from accessing the files and private directories, both on the local system and within the snapshots Samba share. This is great, because it means that we have a fully functional file server with a self-help "restore from backup" option (users can simply access the snapshots share and retrieve the file(s) they want to restore themselves), but so far I lack one key ingredient: Non-root access on the local system to the /var/smb/snapshots directory. The snapshots _must_ be strictly read-only to all regular users, however of course the file system must be mounted read-write to allow the backup operation to take place. The permissions on these directories are currently:               root@odin:/var/smb# ll     total 40     drwxrwxr-x  7 root   root        4096 2011-04-11 15:18 ./     drwxr-xr-x 14 root   root        4096 2011-04-10 19:07 ../     drwxrwx--- 15 kromey smbusers    4096 2010-12-07 13:09 files/     drwxrwx---  7 kromey smbprivate  4096 2010-04-07 07:08 private/     drwxrwx---  3 root   root        4096 2011-04-11 15:16 snapshots/      Now, what I want is to provide access to the snapshots directory to non-root users, but in a strictly read-only fashion. I can't mount /dev/md2 read-only, though, because I have to have it read-write to run backups; I can't simply re-mount it read-write for a backup and then re-mount it back to read-only, because that provides a window of time when the backups could be written to by another user. Previously I did this by making my snapshots directory a read-only NFS export (only to localhost) and mounting that locally (the original secured under a directory lacking traversal rights for non-root users), but this feels like a hack and there seems like there should be a better way to accomplish this. I did try the `mount --bind` option, but it seems to lack the ability to have different access levels (i.e. read-only versus read-write) on the two directories (unless I'm missing something: `mount -r --bind dir1 dir2`). Any ideas how I can accomplish this without NFS, or is that my best option? **TL;DR:** How can I make the contents of a file system available read-write to a select user, but strictly read-only to everyone else, while maintaining original permissions and ownerships on the files backed up to this file system?


ls -a not showing folder "system", but echo * shows it

When I create a folder named system in my home folder, or in /tmp (can't try other locations as I am not root, but owner confirmed same problem even on root), ls -a will not show it. Also tried /bin/ls -a, same deal. Otherwise the folder "works" fine, I can cd into it, pwd shows the right location and everything. I can even rename it to something else and ls will show it then. But if I rename it back to system, ls will not show it anymore. Please note even if I remove the folder completely, or create it in a location where it previously didn't exist, with "mkdir system", it will not be shown by ls unless I rename it to something else. "echo *" shows the system folder. dir behaves same as ls (doesn't show the folder). Other folders with different names work fine and show up. Distro is CentOS 5.6. I have another box with CentOS 5.5 and I DO NOT have this issue there. I don't think it's distro-related. I do not have root access but owner confirmed the problem on root as well. Info about mount point from /etc/mtab: /dev/mapper/VolGroup00-LogVol00 / ext3 rw 0 0


How to tell when a computer is idle?

I have a computer that is only used some of the time, and I was was wondering if there was a way to have it turn itself off after a period of inactivity. Here's the tricky part, if I was just thinking about having it turn itself off _when the GUI is idle_ then I think it would be significantly easier, but I'm trying to make sure I don't cut anyone off who is actively using the machine via SSH as well. The computer in question is Debian 5.0. Is there a way of detecting if the machine is idle, as in nobody using the GUI and nobody is using the machine via SSH? If an SSH connection is open, but is not actively being used, then the computer should consider that idle.


Suspending laptop fails ~50% of the time

Running ArchLinux and GNOME 3 on a Thinkpad X220. When I suspend my laptop it goes into sleep mode and the LED ring around the power button fades in and out. When a suspend fails, the LED ring and the screen is on but I can't do anything. My only recovery is to do a hard reset. This only happens 33 - 50% of the time within the last few months, but it never happened a year ago. How can I debug / fix this issue? Output from `sudo journalctl --since=today | tac | sed -n '/-- Reboot --/{n;:r;/-- Reboot --/q;p;n;b r}' | tac`:               Mar 17 15:10:49 noa systemd-logind[349]: Suspend key pressed.     Mar 17 15:10:49 noa NetworkManager[332]: <info> sleep requested (sleeping: no  enabled: yes)     Mar 17 15:10:49 noa NetworkManager[332]: <info> sleeping or disabling...     Mar 17 15:10:49 noa NetworkManager[332]: <info> (eth0): device state change: unavailable -> unmanaged (reason 'sleeping') [20 10 37]     Mar 17 15:10:49 noa NetworkManager[332]: <info> (eth0): cleaning up...     Mar 17 15:10:49 noa NetworkManager[332]: <info> (eth0): taking down device.     Mar 17 15:10:50 noa NetworkManager[332]: <info> (wlan0): device state change: disconnected -> unmanaged (reason 'sleeping') [30 10 37]     Mar 17 15:10:50 noa NetworkManager[332]: <info> (wlan0): cleaning up...     Mar 17 15:10:50 noa NetworkManager[332]: <info> (wlan0): taking down device.     Mar 17 15:10:50 noa systemd[1]: Starting Sleep.     Mar 17 15:10:50 noa systemd[1]: Reached target Sleep.     Mar 17 15:10:50 noa systemd[1]: Starting Suspend...     Mar 17 15:10:50 noa dbus-daemon[353]: dbus[353]: [system] Rejected send message, 2 matched rules; type="method_return", sender=":1.1" (uid=0 pid=349 comm="/usr/lib/systemd/systemd-logind ") interface="(unset)" member="(unset)" error name="(unset)" requested_reply="0" destination=":1.57" (uid=1000 pid=638 comm="gnome-session --session=xmonad ")     Mar 17 15:10:50 noa dbus[353]: [system] Rejected send message, 2 matched rules; type="method_return", sender=":1.1" (uid=0 pid=349 comm="/usr/lib/systemd/systemd-logind ") interface="(unset)" member="(unset)" error name="(unset)" requested_reply="0" destination=":1.57" (uid=1000 pid=638 comm="gnome-session --session=xmonad ")


Free BSD/ Mac OS X Sed: Print regex match and the line 5 lines after the match

I thought it would be `sed -n /mymatch/,+5p` but I get expected context address. At this point I am just guessing commands, nothing works! I want to grab every line that matches the regex and print that line and the line which comes 5 lines after it, globally from a file.


Where are netstat's -t and -u flags documented?

I use the following command to find open ports on my servers:               $ netstat -ntulp      I've probably found that on some random website over the years. However, I cannot find where `-t` or `-u` are documented. It certainly isn't in the man page. The man page does allude the their existence, and possibly hints that they are synonyms for `-tcp` and `-udp` (also undocumented, though easy enough to infer meaning for) respectively. Though it _seems_ that `-t` and `-u` are synonyms for `-tcp` and `-udp`, **where is this documented?**


Zsh completion for mounts (/run/media/DISK-LABEL)?

I am looking or `zsh` functionality to expand disk-labels into mountpoins: Example: I have disk with label `DISK-LABEL1` mounted on `/run/media/god/DISK- LABEL1`. Is there a plugin which expands input Like: `cat //DISK-LA<Tab>` to the `cat /run/media/god/DISK-LABEL1`? " **//** " was chosen as an example to trigger that type of autocompletion...


Fedora + KDE, ridiculously long delay starting applications after login

I'm running fedora 20 and installed KDE since I got sick of gnome 3. Everything's been fine but lately applications can get stuck launching. This is quite reproducible just after login for a few minutes but happens occasionally afterwards. Particularly google-chrome, sometimes I'll start it and it just shows a spinning icon in the task bar which may not even load eventually and disappear (waiting times on the order of 30 seconds). Running a terminal is similar, even when executed via shortcut keys. I'm not sure if KDE or something else is doing something at login and sucking _all_ my CPU (`top` shows krunner occasionally reach 6% ). Maybe what ever is launching my applications is just terrible at it.   1. How can I go about debugging this? Especially since most of the time I can't even open a terminal to type `top`. Are there KDE specific logs I can look at? Is there a list of KDE services somewhere?   2. What might be some possible causes? I'll accept that a fair amount of CPU time is needed at login, but I'd like some priority thrown my way.


How does a bootloader and kernel interact after the kernel is loaded in memory?

I'm a little bit confused about the role of bootloader and its interaction with kernel, especially when talking wrt ARM Llnux. Once the Kernel is loaded into RAM, is there any job left for the bootloader? For example look at the log messages here:               Thu Feb 06 18:05:34.660 2014]      [Thu Feb 06 18:05:34.660 2014]      [Thu Feb 06 18:05:34.660 2014] U-Boot 2013.07 (Feb 04 2014 - 14:41:40)     [Thu Feb 06 18:05:34.660 2014]      [Thu Feb 06 18:05:34.660 2014] Memory: ECC disabled     [Thu Feb 06 18:05:34.660 2014] DRAM:  1 GiB     [Thu Feb 06 18:05:34.677 2014] MMC:   zynq_sdhci: 0     [Thu Feb 06 18:05:34.677 2014] SF: Detected N25Q128A with page size 64 KiB, total 16 MiB     [Thu Feb 06 18:05:34.708 2014] *** Warning - bad CRC, using default environment     [Thu Feb 06 18:05:34.708 2014]      [Thu Feb 06 18:05:34.708 2014] In:    serial     [Thu Feb 06 18:05:34.708 2014] Out:   serial     [Thu Feb 06 18:05:34.708 2014] Err:   serial     [Thu Feb 06 18:05:34.708 2014] U-BOOT for Xilinx-ZC702-14.7     [Thu Feb 06 18:05:34.708 2014]      [Thu Feb 06 18:05:34.708 2014]      [Thu Feb 06 18:05:34.708 2014] SF: Detected N25Q128A with page size 64 KiB, total 16 MiB     [Thu Feb 06 18:05:36.285 2014] SF: 11010048 bytes @ 0x520000 Read: OK     [Thu Feb 06 18:05:36.285 2014] ## Loading kernel from FIT Image at 01000000 ...     [Thu Feb 06 18:05:36.285 2014]    Using 'conf@1' configuration     [Thu Feb 06 18:05:36.285 2014]    Trying 'kernel@1' kernel subimage     [Thu Feb 06 18:05:36.285 2014]      Description:  PetaLinux Kernel     [Thu Feb 06 18:05:36.285 2014]      Type:         Kernel Image     [Thu Feb 06 18:05:36.285 2014]      Compression:  gzip compressed     [Thu Feb 06 18:05:36.285 2014]      Data Start:   0x010000f0     [Thu Feb 06 18:05:36.285 2014]      Data Size:    4997719 Bytes = 4.8 MiB     [Thu Feb 06 18:05:36.285 2014]      Architecture: ARM     [Thu Feb 06 18:05:36.285 2014]      OS:           Linux     [Thu Feb 06 18:05:36.285 2014]      Load Address: 0x00008000     [Thu Feb 06 18:05:36.285 2014]      Entry Point:  0x00008000     [Thu Feb 06 18:05:36.285 2014]      Hash algo:    crc32     [Thu Feb 06 18:05:36.285 2014]      Hash value:   db7d8248     [Thu Feb 06 18:05:36.285 2014]    Verifying Hash Integrity ... crc32+ OK     [Thu Feb 06 18:05:36.383 2014] ## Loading fdt from FIT Image at 01000000 ...     [Thu Feb 06 18:05:36.383 2014]    Using 'conf@1' configuration     [Thu Feb 06 18:05:36.383 2014]    Trying 'fdt@1' fdt subimage     [Thu Feb 06 18:05:36.383 2014]      Description:  Flattened Device Tree blob     [Thu Feb 06 18:05:36.383 2014]      Type:         Flat Device Tree     [Thu Feb 06 18:05:36.383 2014]      Compression:  uncompressed     [Thu Feb 06 18:05:36.383 2014]      Data Start:   0x014c442c     [Thu Feb 06 18:05:36.383 2014]      Data Size:    11161 Bytes = 10.9 KiB     [Thu Feb 06 18:05:36.383 2014]      Architecture: ARM     [Thu Feb 06 18:05:36.383 2014]      Hash algo:    crc32     [Thu Feb 06 18:05:36.383 2014]      Hash value:   8aee0d02     [Thu Feb 06 18:05:36.383 2014]      Hash algo:    sha1     [Thu Feb 06 18:05:36.383 2014]      Hash value:   266e39ed71a93229a26f0cf7e9f5317b64c2e407     [Thu Feb 06 18:05:36.383 2014]    Verifying Hash Integrity ... crc32+ sha1+ OK     [Thu Feb 06 18:05:36.387 2014]    Booting using the fdt blob at 0x14c442c     [Thu Feb 06 18:05:36.387 2014]    Uncompressing Kernel Image ... OK     [Thu Feb 06 18:05:36.782 2014]    Loading Device Tree to 07ffa000, end 07fffb98 ... OK     [Thu Feb 06 18:05:36.782 2014]      [Thu Feb 06 18:05:36.782 2014] Starting kernel ...     [Thu Feb 06 18:05:36.782 2014]      [Thu Feb 06 18:05:37.570 2014] INIT: version 2.88 booting     [Thu Feb 06 18:05:37.867 2014] Starting Bootlog daemon: bootlogd.     [Thu Feb 06 18:05:37.910 2014] Creating /dev/flash/* device nodes     .     .        .      Is there any role of bootloader after the lines `" Starting Kernel ...` above? Or the bootloader is always active occupying some memory and CPU resources? If it does remain active, then it makes sense to have a simpler bootloader for fast booting. Just a guess though?


Unsure about java JDK for Centos 6.4

I have done a yum search java before installing anything to see if may have already. It comes back with the following:               libreadline-java-javadoc.i686 : Javadoc for libreadline-java     libvirt-java-devel.noarch : Compressed Java source files for libvirt-java     libvirt-java-javadoc.noarch : Java documentation for libvirt-java     lpg-java-compat.noarch : Compatibility Java runtime library for LPG 1.x     pki-java-tools.noarch : Certificate System - PKI Java-Based Tools     pki-java-tools-javadoc.noarch : Certificate System - PKI Java-Based Tools     ppl-java-javadoc.i686 : Javadocs for ppl-java     java-1.5.0-gcj.i686 : JPackage runtime compatibility layer for GCJ     java-1.5.0-gcj-devel.i686 : JPackage development compatibility layer for GCJ     java-1.5.0-gcj-javadoc.i686 : API documentation for libgcj     java-1.5.0-gcj-src.i686 : Source files for libgcj     java-1.6.0-openjdk.i686 : OpenJDK Runtime Environment     java-1.6.0-openjdk-demo.i686 : OpenJDK Demos     java-1.6.0-openjdk-devel.i686 : OpenJDK Development Environment     java-1.6.0-openjdk-javadoc.i686 : OpenJDK API Documentation     java-1.6.0-openjdk-src.i686 : OpenJDK Source Bundle     java-1.7.0-openjdk.i686 : OpenJDK Runtime Environment     java-1.7.0-openjdk-demo.i686 : OpenJDK Demos     java-1.7.0-openjdk-devel.i686 : OpenJDK Development Environment     java-1.7.0-openjdk-javadoc.noarch : OpenJDK API Documentation     java-1.7.0-openjdk-src.i686 : OpenJDK Source Bundle      So does this mean I have it installed or is this just some general information pertaining to what java can run on the system?


Creating a messagebox using commandline

How can I create a message box using command-line to show a text?


Creating a User-less Distro

One of the popular programs I use is GParted, and it has its own custom distro, that boots straight to the desktop, and starts the program. I couldn't find any information on creating such a distro. I need it to be where I can install packages of my choosing, just without the user system. Is this possible to remove from a base installation of openSUSE or Ubuntu?


Why does the exclamation mark `!` sometimes upset bash?

I realize that `!` has special significance on the commandline in the context of the commandline history, but aside from that, in a runing script the exclamation mark can sometimes cause a parsing error.   I think it has something to do with an `event`, but I have no idea what an _event_ is or what it does. Even so, the same command can behave differently in different situations.   The last example, below, causes an error; but why, when the same code worked outside of the command substitution? .. using GNU bash 4.1.5               # This works, with or without a space between ! and p       { echo -e "foo\nbar" | sed -nre '/foo/! p'         echo -e "foo\nbar" | sed -nre '/foo/!p'; }     # bar     # bar          # This works, works when there is a space between ! and p       var="$(echo -e "foo\nbar" | sed -nre '/foo/! p')"; echo "$var"     # bar          # This causes an ERROR, with NO space between ! and p       var="$(echo -e "foo\nbar" | sed -nre '/foo/!p')"; echo "$var"     # bash: !p': event not found


can't open transfered website from old DS to new DS

I have 2 dedicated servers both running CentOS 5.3/Plesk 10. I've transfered a website (domain) from old server to a new one via Plesk migration manager and the website (domain) shows in the domain list on Plesk, and it's files are in /var/www/vhosts/domain.com/httpdocs/ I tried to open the website like this: http://xx.xx.xx.xx/domain.com where xx.xx.xx.xx is a shared IP that I've assigned to the domain on a new server during transfer and domain.com is website's domain name. Instead of website loading I get a 404. How can I open the website and see if everything is ok? Essentially, what is the path (using IP) to the website until it gets DNS sorted out? UPDATE: apache error_log file shows:               [Tue Aug 23 11:05:15 2011] [error] [client xx.xx.xx.xx] File does not exist: /var/www/vhosts/default/htdocs/domain.com      This is where the problem exists, I've expected it to follow path like this:               /var/www/vhosts/domain.com/htdocs/      and instead the server apparently tries this:               /var/www/vhosts/default/httpdocs/domain.com      Note the difference - "htdocs" and "httpdocs", which is the actual folder on the server. I need to know that the website is running ok, otherwise I cannot assign DNS to make it live... UPDATE2: I am able to access the website if I edit hosts file on my PC with something like that: 1.2.3.4 domain.com So how come I can't load it like this: http://1.2.3.4/domain.com/ ?


How to dump memory image from linux system?

I know to dump memory images in Window. (eg-dumpit) But I don't know how to dump memory images in Linux. I wanna get memory images in Linux and from linux to linux with ssh connection or something. How can I get in linux ? please help me.


Combos with shift not working in emacs on console

I'm running emacs 24.3.1 on a system with a console-only minimal install of Debian Jessie. Non of the keybindings that involve the shift key works in emacs (except shift to modify upper case). These are the combos I'm missing (all important for editing tree structure in org-mode):               M-S-RET     C-S-RET     M-S-LEFT     M-S-RIGHT     M-S-UP     M-S-DOWM      Neither register as anything but RET (new line) or arrow movement. Tried running both `dpkg-reconfigure console-data` and `dpkg-reconfigure keyboard- configuration` but neither gives me relevant options to solve the problem. **EDIT:** found this from org manual. Turns out that it's a well known problem that the speed keys can take pretty good care of. To activate speed keys: (setq org-use-speed-commands t) Then when you're at the beginning of a headline:               M-S-LEFT = L      M-S-RIGHT = R     M-S-UP = U     M-S-DOWM = D      As for: M-S-RET C-S-RET Custom speed keys can quite easily be set for those. But workaround aside I would still like to hear from folks who knows how to get normal function for shift key outside of X. It is a text-based environment after all, I need all the keys I can get.


How does nickel-browser in Jolicloud launch apps, behind the scenes?

For the last few days I've been playing with nickel-browser, Jolicloud's Chromium mod in Ubuntu 10.10. I'm try to create a desktop similar to Jolicloud's, but I've hit a big problem: I can only make it open links. I can't find a way to run commands to launch applications such as Empathy, or a way to open links as a webapp, instead of in a normal browser window. If anyone could help me, I'd really appreciate it. Sorry if this is the wrong place to ask, but I've been unable to find a Jolicloud forum.


Getting all files that have been modified on a specific date

Is it possible to find all php files within a certain directory that have been modified on a certain date I'm using               find /var/www/html/dir/ -mtime -28 | grep '\.php'       to get files modified within the last 28 days, but I only need files that have been modified on the following date 2011-02-08


How do I get a list of all enabled media in Mageia via CLI?

I have read URPMI from Mageia wiki but there seems to be no mention of how I can check the currently enabled media using `urpmi` command. There is `urpmi.addmedia` and `urmpi.removemedia`. So I tried doing `urpmi.listmedia` but it obviously isn't an existing command. Any way I can check this? Do note that I don't have any `X Windows` installed so I need to do this via command line.


Why does no one use the true Bourne shell as /bin/sh?

I've noticed that basically no system I've ever worked with has `/bin/sh` as a real executable. It's always a symlink to `dash`, `bash` in POSIX mode, or something similar. Why? What are the disadvantages of using the true, original `/bin/sh`? (Speed? Licensing?)


Edit a command?

I'm using many basic commands of unix/linux. In Mac OS X Mavericks, I type cat for a file, but output was faulty. In example, content of the file named bar:               foo        bar      Then:               kaanklky-air:foo-folder kaanklky$ cat bar     foo     barkaanklky-air:foo-folder kaanklky$      `cat` command give last line of file with shell's last status, so I want edit `cat` command to fix it. How I can do it?


Sensors showing bad values

I use Debian linux squeeze x64 now on gigabyte 970a-DS3. I installed this OS on motherboard which burned (from asus). And I've changed my motherboard to that gigabyte. After running back into linux, it shows I have only 13,9 °C temperatures and is it only 1 sensor (instead of about 3 or 4 sensors), which it has detected. it shows just:               Debx64>sensors     k10temp-pci-00c3     Adapter: PCI adapter     temp1:       +13.9°C  (high = +70.0°C, crit = +86.0°C)      I searched on google, but nothing there helping me. I was trying to reinstall lm_sensors, trying again sensors-detect |y and nothing was working. Why it doesn't show all of my sensors and why it shows only 1 sensors with totaly low temperature (13.9°C is epic fail...) What to do, to fix this problem? Is there anything how to tell linux "I want to search again all devices, which has any sensors"? I know this is unique problem, but I would like to know, how to solve this problem. Thank you, all for helping me


What chunk size for KVM under Debian linux is optimal with RAID 5?

I would like to know, how to set optimal chunk size for my debian squeeze in future. I Work with 3x WD RE4 500Gb 7200RPM in SW-RAID 5, under debian squeeze. (in the future maybe under wheezy) I Saw this test: http://alephnull.com/benchmarks/sata2012/chunk.html 1)Does it mean, when bigger chunk size is set, it will be faster with larger files,for example with KVM running VM? 2)What about MySQL? Would you recommend me bigger chunk size like 2048K or 4096K? (I have about 60 MySQL databases, some of them MYISAM, some of them innodb). Some of them has only 4 MB, maybe 5 or 10 of them have about 700MB, 10 about 120 Mb, the rest has under 20 MB, few of them have under 1 MB of size. 3)Is there any possibility how to change chunk size on running RAID 5? Is it possible to change it (chunk size) without rebuilding my raid? How? Thank you for answers


Using empty line as context "group-separator" for grep

I need grep output with context, in color, and blank lines as group separator. In this question, I learned how to define custom `group-separator`, and I have constructed my grep command like this:               grep --group-separator="" --color=always -A5      but the group separator is actually not empty, instead it still contains the color code (i.e. `[[36m[[K[[m[[K`). This is because I am using `\--color=always`. But I need color in my grep command, and I need separator to be blank line (for further processing) How can I combine these two conditions?


Using LDAP for authentication, how can I safely disable/deactivate an account without deleting it?

We use LDAP for authentication for thousands of users. The primary tactic we have been employing to make a user unable to login, without removing their account, is to change the LDAP attribute "loginShell" to something like "None" or "NA", as opposed to "/bin/bash". What this does is upon login attempt throw the user "Permission Denied." I'm not sure if this setup with LDAP and the "loginShell" is a unix standard, or specific just to our environment here. My question is, is this a sufficient measure for disabling an account, making a user unable to log in? Are there any holes or workarounds in which a user could still log in? Are there any other steps we can take to disable an account?


Privoxy/VPN/remote proxy

On Privoxy, my current config involves this. (forwarding all requests to netshade proxy):               forward   /      nl1.netshade.net:350      Now, I would like to use a VPN on top of this config while keeping my current forwarding. If my understanding is correct, would I need to amend the "listen- address" or play with "forward-socks"? If so, how to. I don't know how to setup this up properly.


Fake linux as android device

How can I let my GNU/linux completely mimic an android device when connecting to a wireless Access Point? I explain: I moved to another location and it seems that my android phone and tablet have a wireless internet connection of more than **20mbps**. However, this does not happen with my main computer, which for some reason is restricted to 0.5 mbps at best, and usually around **0.2 mbps** , using exactly the same wireless connection as my phone. This is not a GNU/Linux-side problem, because it works perfectly with any other wireless AP. I suspect it's some sort of network restriction and I would like to find out more about it, because this is the first time I encounter it. Tethering does not work on my android devices. Is this restriction a common practice by network administrators? With the help of the commentators I have tried:   * Changing hostname to something like `android-713d51a9d238cfcb`   * Changing MAC address   * Changing program that I use for downloads (`wget`)   * My mobile device has user agent `"Mozilla/5.0 (Linux; Android 4.4.4; Nexus 4 Build/KTU84P) AppleWebKit/537.36 (KHTML, like Gecko) Version/4.0 Chrome/33.0.0.0 Mobile Safari/537.36"`. I tried the same with `wget` and chrome but nothing works. I note that `ping` appears to have the same performance between computer and android device. Any ideas? * * * **EDIT:** I posted the results from the script on pastebin (please click this link) and I will certainly change the title of my question when we seem to arrive at some conclusion. To my surprise after running the wireless-script I also did a speedtest. My Computer had ~3.5Mbps Download and ~20Mbps Upload, while my android ~20Mbps for Download and ~20Mbps Upload.


Server Not accepting TCP/IP Connections

I have a Wt application running in a CentOS server machine(Machine A) in the port number 9798. Application is up and I could view the web page with the URL,               http://localhost:9798      But application is not loading up in another machine(Machine B) in the same network with the URL,               http://<ip of server>:9798      The port is open and listening. Same thing happens with the PostgreSQL which is running in the server machine. I'm unable to connect to PostgreSQL from other machine through PgAdmin III. But reverse is happening, I am able to connect to the Application and PostgreSQL from Machine A to Machine B. I double checked the running ports, PostgreSQL settings, etc., but could not figure out why is this happening. Why is this happening, what should I try now to explore? Machine A = CentOS 6.4 server,   Machine B = Ubuntu 12.04 Desktop


denyhosts is blocking existing users from logging in from unknown (new) IP addresses

I have denyhosts set up and working on Ubuntu 12.04. It apparently works well, except it is too strict. I can log in from any IP address that I have added to hosts.allow in advance. My sshd_config does not allow password login, only login with keys. However, logging in from a new IP address with my valid RSA key (which works from my known IP addresses), the server shows this msg in /var/log/auth.log: > Jun 23 19:16:31 MyServerName sshd[5949]: refused connect from > hostname.comcast.net (XXX.XXX.XXX.XXX) In order to connect, all I have to do is add the new IP address to /etc/hosts.allow. That's it. Then I can log in: > Jun 23 19:45:03 MyServerName sshd[6024]: Accepted publickey for username > from XXX.XXX.XXX.XXX port 61236 ssh2   >  Jun 23 19:45:03 MyServerName sshd[6026]: pam_unix(sshd:session): session > opened for user username by (uid=0) I have not changed any of the default denyhosts config values and it works really well -- except that it is too strict. (Or does something else read /etc/hosts.allow?) I need to allow any linux user (whose account already exists on the server) to log in from any IP address without making changes on the server in advance (such as adding the IP to hosts.allow). EightBitTony suggests that denyhosts should allow this behavior. In response to EightBitTony, I changed this question and the title.


mkfst command not found

My server has just been reinstalled by my host If I do,               mkfst.ext4  /dev/sdb1      I get following error :               command not found      It's usually there when the system is installed. What should I do so that `mkfst` command is available?


rename a list of files according to a text file

I have a list of files in a folder, which I will like to rename according to a textfile. For example: These are the 5 files in the folder.               101_T1.nii     107_T1.nii      109_T1.nii     118_T1.nii     120_T1.nii      I will like to have them rename using a text file containing a list of new filenames in the same order, without the extension `.nii`:               n01     n02     n03     n04     n05      How may I go about doing so?


how to configure xorg.conf for extended desktop?

I would like to setup the dual monitor settings where I can use two monitors as a single Desktop with single panel, single launcher and when some programs are maximized then it should span both the monitors (i.e fullscreen over both the monitors) I have ATI raedon graphics cards and after searching it in the internet I found that by configuring the xorg.conf file I can setup the settings that I want. I have tried several ways to do it i.e                using gksu amdcccle       And setting MultiDisplay settings , but my requirement has not yet been met. I have done this using Nvidia graphics but its seem that it doesnot work with ATI graphics card. After searching for a while I found the link which gave me hope that it can be done in ATI as well , According to this  link xrandr must be disabled and AMD catalyst center will give the extra option of Big Desktop, to set it I used                sudo aticonfig --set-pcs-str="DDX,EnableRandR12,FALSE"      Then I restart X as per that  link But this command gives this output to the stdout               SetPcsStr is exclusive, other options will not be used.      And I didnot find any extra configuration in my xorg.conf file. And I didnt even get the Big Desktop option in the AMD Catalyst center's Display manager. There is still three options i.e                Single Desktop      Cloned Display      Multiple Display


Problems with automatically starting screen on SSH login

I'm looking at http://taint.org/wk/RemoteLoginAutoScreen to setup my server so it autostarts a screen session when I login via SSH. I have added the following to my .bashrc:               # Auto-screen invocation. see: http://taint.org/wk/RemoteLoginAutoScreen     # if we're coming from a remote SSH connection, in an interactive session     # then automatically put us into a screen(1) session.   Only try once     # -- if $STARTED_SCREEN is set, don't try it again, to avoid looping     # if screen fails for some reason.     if [ "$PS1" != "" -a "${STARTED_SCREEN:-x}" = x -a "${SSH_TTY:-x}" != x ]     then       STARTED_SCREEN=1 ; export STARTED_SCREEN       [ -d $HOME/lib/screen-logs ] || mkdir -p $HOME/lib/screen-logs       sleep 1       screen -RR && exit 0       # normally, execution of this rc script ends here...       echo "Screen failed! continuing with normal bash startup"     fi     # [end of auto-screen snippet]      The catch is that I always have a detached named screen session running a rails application server. Now when I login I am put into this session. Is there anyway to modify the above code to not select the session either by name or some other value? If the detached session is the only screen session then I would like to start a new screen session. Another issue that I am encountering is that when I detach I am completely logged out of my SSH connection as opposed to just leaving the screen session.


Machine Check Exceptions with Wildcard TE420 and Asus P5N-E SLI

I have been seeing machine check exceptions when trying to call dahdi_cfg (or, sometimes, even on just loading the kernel module) to configure a Digium Wildcard TE420 Quad-Span T1 PCI-E card. Running Debian Wheezy (kernel 3.2.0-4), dahdi kernel modules 2.6.1. Machine check looks something like this (recovered using netconsole; machine is quite dead after MCE):               CPU 1: Machine Check Exception: 5 Bank 5: b200121020080400     RIP !INEXACT! 10:<ffffffff810146a3> {mwait_idle+0x7f/0xac}     TSC b773cee10f      PROCESSOR 0:6f7 TIME 1354843514 SOCKET 0 APIC 1 microcode 66     Run the above through 'mcelog --ascii'     CPU 1: Machine Check Exception: 5 Bank 0: b200004000000800     RIP !INEXACT! 10:<ffffffff810146a3> {mwait_idle+0x7f/0xac}     TSC b773cee10f      PROCESSOR 0:6f7 TIME 1354843514 SOCKET 0 APIC 1 microcode 66     Run the above through 'mcelog --ascii'     Some CPUs didn't answer in synchronization     Machine check: Processor context corrupt     Kernel panic - not syncing: Fatal machine check on current CPU      By fiddling around with which PCI express socket its plugged into, as well as removing the other PCI-E card (an nVidia video card), sometimes it doesn't immediately machine check. I then managed to get an error in the kernel log. I get these messages, error is the last line:               [    6.222755] wct4xxp 0000:02:08.0: 5th gen card with initial latency of 2 and 1 ms per IRQ     [    6.222767] wct4xxp 0000:02:08.0: Firmware Version: c01a016d     [    6.225338] wct4xxp 0000:02:08.0: FALC Framer Version: 3.1     [    6.225477] wct4xxp 0000:02:08.0: Found a Wildcard: Wildcard TE420 (5th Gen)     [    6.225525] wct4xxp 0000:02:08.0: VPM450: Not Present     [   13.089474] wct4xxp 0000:02:08.0: Span 1 configured for ESF/B8ZS     [   13.089616] wct4xxp 0000:02:08.0: RCLK source set to span 1     [   13.089621] wct4xxp 0000:02:08.0: Recovered timing mode, RCLK set to span 1     [   13.089627] wct4xxp 0000:02:08.0: SPAN 1: Primary Sync Source     [   15.192016] wct4xxp 0000:02:08.0: Interrupts not detected.      Checking `/proc/interrupts` indeed confirms that the 1000-per-second expected interrupts aren't present. Also, alarm lights (there are currently no T1s plugged in) aren't on; there are no lights lit on the board. Googling didn't find much useful. There is a patch to the dahdi drivers, but that should already be included in the version I'm using. Someone else had this problem with an old revision of the board (solved by getting a newer board), but I have the newer revision. I unfortunately do not have a spare machine to check on.


Get text between a word and the last line?

According to the answers in Stack Overflow question _How to use sed/grep to extract text between two words?_ , we can get text between two words:               sed -n "/first/,/second/p" file      But what if I want to get text between a word and the last line of the file, as in the following?               sed -n "/word/,/lastline/p" file


Why wget does not work via ssh tunnel? What does proxy prevent ssh-client to do?

To test things I'm trying to establish a local ssh tunnel from my laptop to a site via `ssh-server`, and download a page of the site (or view it in a browser). The tunnel is made like this:               $ ssh -L 9999:www.gnu.org:80 ssh-server      I check the tunnel works with `nc` program and `~#` characker on the server. I check I'm allowed to do http requests on ssh-server by running `wget` and `lynx` on the server -- they both run without errors. But when I run `wget --no-proxy localhost:9999` on the laptop I get error 403. I can do the same thing using `ssh ssh-server 'wget -O - http://www.gnu.org/' >> whatever`. But why the tunnel doesn't work? So I want to clear up what is going on and what kind of things the proxy does not allow. My guess is proxy prevents specifically the ssh-client from doing http requests. Is it so? If it is so - how does proxy distinguish ssh-client from other programs? Can it distinguish a request sent from ssh-client and a request from another program? And what are common ways for "masking ssh-client to another program" (or other ways to pass by the proxy)? **PS** It would be awesome if someone wrote the address of a free ssh-server open for testing ssh-tunneling and other stuff in the comments. (Usually ssh- servers don't allow tunneling for free.)


CONFIG_GPIO_SYSFS makes /sys/class/leds disappear

I have an embedded Linux board I'm working on, with a button and a couple LEDs. By default, I can control the LEDs via               /sys/class/leds/redled/brightness However, I have no way to monitor the button. If I enable CONFIG_GPIO_SYSFS, I can't see the LEDs anymore - /sys/class/leds/ is empty. Additionally, the GPIOs that in theory should go to the LEDs don't do anything, so I can't even hack it. Any thoughts on how I could get both of these working?


Managing (Dynamic) DNS Zone Files with Puppet (Solved)

I'm running a Debian 7.0 (Wheezy) server and I have a dynamic DNS setup wherein my clients make DHCP requests and the DHCP server updates the DNS zone files with whatever IP was assigned to each client. I want to manage this setup with Puppet. There's only one problem, though: I don't want Puppet clobbering my DNS records every time I push my manifests. In any case, it doesn't make much sense for the zone files to be managed by Puppet in the first place as they will normally be continuously updated. What I would like to do, however, is to have Puppet push "skeleton" zone files in their correct place when the DNS service (`bind9`) is first installed. The reason I want this is because I want to encapsulate all of the server configuration in one place so that with only a few manifests, I can clone the entire configuration of the server. At first I wanted to have `file` resources for the zone files subscribe to the DNS server package and set `refreshonly` to `true`. The only problem is that `file` types don't have a `refreshonly parameter`. So obviously, this approach is a dead-end. Is there a "correct" way of doing this? Perhaps with Augeas? * * * **Update** I tried               augtool ls /files/etc/bind      and this returned _nothing_! It seems that Augeas is unable to parse my zone files for some reason. It seems Augeas is not the answer, then...


Any (text based) plotting tools in unix toolbox?

I was wondering if there are any generic plotting tools available in the unix toolbox?   By plotting I mean simple bars or things you see in many curses based utilities.   And by unix toolbox I mean things that you can pipe data into them using standard unix conventions. I need to count somethings in log files (that I am monitoring with `tail -F` or something) and plot live ratios of things (like percent errors or warnings).


Why do systems become slow when doing massive writes to disk?

I want to know why systems become slow when writing mass data to disk. I think that for system to become slow, there should be some issue with CPU. But write is only I/O bound. Do hardware interrupts occur when writing data? If so, it may be because of the interrupts that the CPU is always context switching.


Do I need to stop processes like mysql or apache before "reboot"?

I have been wondering if issuing a reboot command safely stops running LAMP processes like MySQL or Apache?


Transposing multiple columns is a row

I need to transpose a file from this format               1 2 3 4       6 7 8 9        a b c d        f g h i j       to this format               1 2 6 7 a b f g       3 4 8 9 c d h k      two columns in a single row in the way posted above. Any suggestions??


"Software update" appears empty in Debian, but there are upgrades available

I'm running Debian 7 on vmware workstation. When I run Applications - System Tool - Software Update I just get a blank window, nothing happens. Updating the system works fine with "apt-get update && apt-get -u dist- upgrade".   But when I do this, I get a GUI window with "Could not get update, failed to process request - more details: Operation was cancelled". I'm running gnome as a normal user (not root).   Not able to find anything interesting in /var/log/* Anyone got any ideas what's causing this?


e2fsck giving some error

I am playing with LVM and while doing `lvreduce`. I now get this error:               [root@localhost raja]# e2fsck -f /dev/vg1/lvol2     e2fsck 1.41.12 (17-May-2010)     e2fsck: Superblock invalid, trying backup blocks...     e2fsck: Bad magic number in super-block while trying to open /dev/vg1/lvol2          The superblock could not be read or does not describe a correct ext2     filesystem.  If the device is valid and it really contains an ext2     filesystem (and not swap or ufs or something else), then the superblock     is corrupt, and you might try running e2fsck with an alternate superblock:         e2fsck -b 8193 <device>      How can I fix this?


Arch sometimes won't suspend

Sometimes the computer won't auto-suspend when the lid has been closed. When this happens re-closing the lid won't make it suspend until next reboot. After the reboot the auto-suspend works again. After a while it stops working again, I haven't been able to determine what changes the state from suspendable to unsuspendable. In the unsuspendable state "sudo pm-suspend" and "sudo systemctl suspend" don't make it stay suspended. I'm running a Lenovo X220 with Arch 64 bit. What should I do/try to make it work as it is supposed to? EDIT:added journalctl output: journalctl -xn               -- Logs begin at Sun 2013-08-25 11:05:23 CEST, end at Tue 2014-03-04 20:32:31 CET. --     Mar 04 20:32:06 x220 systemd[1]: systemd-suspend.service: main process exited, code=exited, status=1/FAILURE     Mar 04 20:32:06 x220 systemd[1]: Failed to start Suspend.     -- Subject: Unit systemd-suspend.service has failed     -- Defined-By: systemd     -- Support: http://lists.freedesktop.org/mailman/listinfo/systemd-devel     -- Documentation: http://www.freedesktop.org/wiki/Software/systemd/catalog/be02cf6855d2428ba40df7e9d022f03d     --      -- Unit systemd-suspend.service has failed.     --      -- The result is failed.     Mar 04 20:32:06 x220 systemd[1]: Dependency failed for Suspend.     -- Subject: Unit suspend.target has failed     -- Defined-By: systemd     -- Support: http://lists.freedesktop.org/mailman/listinfo/systemd-devel     -- Documentation: http://www.freedesktop.org/wiki/Software/systemd/catalog/be02cf6855d2428ba40df7e9d022f03d     --      -- Unit suspend.target has failed.     --      -- The result is dependency.     Mar 04 20:32:06 x220 systemd[1]: Service sleep.target is not needed anymore. Stopping.     Mar 04 20:32:06 x220 systemd[1]: Unit systemd-suspend.service entered failed state.     Mar 04 20:32:06 x220 systemd[1]: Stopping Sleep.     -- Subject: Unit sleep.target has begun shutting down     -- Defined-By: systemd     -- Support: http://lists.freedesktop.org/mailman/listinfo/systemd-devel     --      -- Unit sleep.target has begun shutting down.     Mar 04 20:32:06 x220 systemd[1]: Stopped target Sleep.     -- Subject: Unit sleep.target has finished shutting down     -- Defined-By: systemd     -- Support: http://lists.freedesktop.org/mailman/listinfo/systemd-devel     -- Documentation: http://www.freedesktop.org/wiki/Software/systemd/catalog/9d1aaa27d60140bd96365438aad20286     --      -- Unit sleep.target has finished shutting down.     Mar 04 20:32:06 x220 sudo[21989]: pam_unix(sudo:session): session closed for user root     Mar 04 20:32:06 x220 kernel: video LNXVIDEO:00: Restoring backlight state


How do I tell whether I'm in a non-login shell or a login shell?

> **Possible Duplicate:**   >  How to check if a shell is login/interactive/batch And what's the benefits of non-login shell over login shell?


Can I use an if statement to detect if bash and dash are being run interactively?

After looking around for a while I've found several good pages describing how to check and see if a bash script is running interactively and there seem to be several methods, but one of them that I keep seeing over and over is checking the variable `$-` for the presence of `i` to signify that it is interactive. I'm looking for a way to use an `if` statement that would work with both `/bin/bash` and `/bin/sh` (which is typically aliased to `/bin/dash` on Ubuntu systems), or in fewer words   " **an interactive`if` test that is universal as possible**" For `bash` it seems these things should work: ### Case Statement               case "$-" in     *i*)    echo This shell is interactive ;;     *)  echo This shell is not interactive ;;     esac      ### If Statement               if [[ $- == *i* ]]     then         do_interactive_stuff     fi      But `$-` is apparently not set in `dash`. Possibly because `$-` is supposed to be the Flags passed to script variable which > was originally a ksh construct adopted into Bash, and unfortunately it does > not seem to work reliably in Bash scripts... [ for it's intended purpose > however] ...One possible use for it is to have a script self-test whether it > is interactive. ### So is there an (relatively simple) `if` test that can be used both with `bash` and `dash`? Or am I just "doing it wrong?" ps: I have been under the impression that `dash` is faster than `bash`, and unless the script needs "bash specific" functions it would be better to hashbang it as `#!/bin/sh` and let it use the system-default shell. I get that checking for an interactive shell in the way mentioned above _is_ "bash specific" but it seems odd to think there is not a more universal way. In the script I'm working on I don't need any other bash-specific functionality.


Slow performance when copying files to and from USB devices

When I copy files to and from USB devices (camera, HDD, memory card) my system becomes very slow. For example if I want to close a window I move the mouse but it takes about 2 seconds or more before the mouse cursor moves. When I finally get the cursor over the x and click it nothing happens for 10+ seconds. I've tried this with all desktop effects disabled but the issue persists. Software: Linux Mint 9 KDE Hardware:   * Asus SLI motherboard   * NVidia 6600 GPU   * 2 GB Ram   * 2 GB Swap   * AMD Athlox X2 @ 3800+ To me this hardware should not have any issues running this software and it doesn't until I copy files using USB. Where should I start looking to figure this one out? I'm kind of thinking the graphics driver may be part of the problem but I don't know for sure.


OpenVPN bridge. Can't access machines on local network

Followed this guide: https://wiki.archlinux.org/index.php/OpenVPN_Bridge This is my setup: I have a wireless router(192.168.2.1) which connects to the Internet through a PPPoE connection and acts as a gateway and DHCP server for the local network. I'm trying to make a VPN on a machine(192.168.2.201). I bridged the VPN tap0 with eth0 through br0 like in the guide. Connecting works ok and the client receives the proper IP but I cannot access other machines on the local network (ping works only server and client). This is my server.conf:               port 1194     proto tcp     dev tap0     ca ca.crt     cert server.crt     key server.key  # This file should be kept secret     dh dh1024.pem     ifconfig-pool-persist ipp.txt     server-bridge 192.168.2.1 255.255.255.0 192.168.2.202 192.168.2.210     push "route 192.168.2.0 255.255.255.0"     keepalive 10 120     comp-lzo     persist-key     persist-tun     status openvpn-status.log     verb 6      This is my client.conf:               client     dev tap     proto tcp     remote hostname.com 1194     resolv-retry infinite     nobind     persist-key     persist-tun     ca ca.crt     cert client.crt     key client.key     ns-cert-type server     comp-lzo     verb 6      If you need any more info just ask. Thank you.


Simple command that switches between two host files

I am using /etc/host to map localhost to a web domain. I would like a fast way of doing this rather than searching and replacing every time. I put this in my .bashrc file.               alias hostchange='     nowdir=$PWD;     cd /etc;     mv hosts hoststempname;     mv hostssecondary hosts;     mv hoststempname hostssecondary;     cd $nowdir'      I am getting this error and it won't progress regardless y or n.               mv: rename hosts to hoststempname: Permission denied     override rw-r--r--  root/wheel for hosts? (y/n [n])       I got it to work by adding sudo.               alias hostchange='     nowdir=$PWD;     cd /etc;     sudo mv hosts hoststempname;     sudo mv hostssecondary hosts;     sudo mv hoststempname hostssecondary;     cd $nowdir'      Is this legitimate, I'm taking a shot in the dark here?


How do I prevent Skype notifications during a call

If I am on a Skype call with a person (with Share Screen Option switched ON), I don't want to get notified if someone calls me or messages me. They shouldn't know who my contacts are. What should I do in order to achieve this?


How to run chrome from command line by using process substitution?

I am using the following command without success -               $ google-chrome <(grep "simple" SimpleDoc.txt)      If I simply do a `grep`, I get -               $ grep "simple" SimpleDoc.txt     Very simple doc that contains plaintext.       I also wrote a python script called `showFileContents.py` to test process substitution and it works -               #! /usr/bin/python          import sys          arg1 = sys.argv[1]     f = open(arg1)     line = f.readline()          while line:         sys.stdout.write(line)         line = f.readline()          f.close()      Here's the output -               $ showFileContents.py <(grep "simple" SimpleDoc.txt)     Very simple doc that contains plaintext.      But when I try to do the same with               $ google-chrome <(grep "simple" SimpleDoc.txt)      the browser window shows nothing. With Firefox, I get an error saying that "Firefox can't find the file". Why is this happening and how can I use process substitution with chrome?


How to print 1st and 4th variable only if 4th variable is > or equal to 25

Networking:            [Test] => 10.729519791085          GAMES:            [Real] => 10          Fashion:            [Test] => 27.729519791085          Movies:            [Real] => 5          Food:            [Test] => 101.729519791085          Sports:            [Real] => 7      How to print 1st and 4th variable if value is greater or equal 25.


Run mysqld_safe in background

I have a bash script that installs mysql for me. One line, that executes `mysqld_safe`, makes the script to hang - it won't continue to the following code. Obviously there's ampersand at line's end, but it won't help, see:               root@dor-desktop:/home/dor/Documents/LAMP_setup/webs_install# /usr/local/mysql/bin/mysqld_safe --skip-networking --skip-grant-tables --user=mysql --basedir=/usr/local/mysql --ledir=/usr/local/mysql/libexec &     [1] 20131     root@dor-desktop:/home/dor/Documents/LAMP_setup/webs_install# 130531 17:45:54 mysqld_safe Logging to '/usr/local/mysql/var/dor-desktop.err'.     130531 17:45:54 mysqld_safe Starting mysqld daemon with databases from /usr/local/mysql/var     ^C     root@dor-desktop:/home/dor/Documents/LAMP_setup/webs_install#       You can see that only `CTRL+C` helps to exit, but it exits my entire bash script... I've also tried using `nohup`, still didn't help, see:               root@dor-desktop:/home/dor/Documents/LAMP_setup/webs_install# nohup /usr/local/mysql/bin/mysqld_safe --skip-networking --skip-grant-tables --user=mysql --basedir=/usr/local/mysql --ledir=/usr/local/mysql/libexec &     [1] 19751     root@dor-desktop:/home/dor/Documents/LAMP_setup/webs_install# nohup: ignoring input and appending output to `nohup.out'     ^C     [1]+  Exit 1                  nohup /usr/local/mysql/bin/mysqld_safe --skip-networking --skip-grant-tables --user=mysql --basedir=/usr/local/mysql --ledir=/usr/local/mysql/libexec     root@dor-desktop:/home/dor/Documents/LAMP_setup/webs_install#       Any idea how to force `mysqld_safe` to run in background? * * * **Edit (May 31, 16:37 UTC):** The error log, `'/usr/local/mysql/var/dor-desktop.err'`:               130531 18:03:55 mysqld_safe Starting mysqld daemon with databases from /usr/local/mysql/var     130531 18:03:55 [Warning] '--skip-locking' is deprecated and will be removed in a future release. Please use '--skip-external-locking' instead.     130531 18:03:55 [Note] Plugin 'FEDERATED' is disabled.     130531 18:03:55  InnoDB: Initializing buffer pool, size = 8.0M     130531 18:03:55  InnoDB: Completed initialization of buffer pool     InnoDB: The first specified data file ./ibdata1 did not exist:     InnoDB: a new database to be created!     130531 18:03:55  InnoDB: Setting file ./ibdata1 size to 10 MB     InnoDB: Database physically writes the file full: wait...     130531 18:03:56  InnoDB: Log file ./ib_logfile0 did not exist: new to be created     InnoDB: Setting log file ./ib_logfile0 size to 5 MB     InnoDB: Database physically writes the file full: wait...     130531 18:03:56  InnoDB: Log file ./ib_logfile1 did not exist: new to be created     InnoDB: Setting log file ./ib_logfile1 size to 5 MB     InnoDB: Database physically writes the file full: wait...     InnoDB: Doublewrite buffer not found: creating new     InnoDB: Doublewrite buffer created     InnoDB: Creating foreign key constraint system tables     InnoDB: Foreign key constraint system tables created     130531 18:03:56  InnoDB: Started; log sequence number 0 0     130531 18:03:56 [Note] /usr/local/mysql/libexec/mysqld: ready for connections.     Version: '5.1.57-log'  socket: '/usr/local/mysql/mysql.sock'  port: 3306  Source distribution     130531 18:08:41 mysqld_safe mysqld from pid file /usr/local/mysql/var/dor-desktop.pid ended     130531 18:17:09 mysqld_safe Starting mysqld daemon with databases from /usr/local/mysql/var     130531 18:17:09 [Warning] '--skip-locking' is deprecated and will be removed in a future release. Please use '--skip-external-locking' instead.     130531 18:17:09 [Note] Plugin 'FEDERATED' is disabled.     130531 18:17:09  InnoDB: Initializing buffer pool, size = 8.0M     130531 18:17:09  InnoDB: Completed initialization of buffer pool     InnoDB: The log sequence number in ibdata files does not match     InnoDB: the log sequence number in the ib_logfiles!     130531 18:17:09  InnoDB: Database was not shut down normally!     InnoDB: Starting crash recovery.     InnoDB: Reading tablespace information from the .ibd files...     InnoDB: Restoring possible half-written data pages from the doublewrite     InnoDB: buffer...     130531 18:17:09  InnoDB: Started; log sequence number 0 44233     130531 18:17:09 [Note] Recovering after a crash using mysql-bin     130531 18:17:09 [Note] Starting crash recovery...     130531 18:17:09 [Note] Crash recovery finished.     130531 18:17:09 [Note] /usr/local/mysql/libexec/mysqld: ready for connections.     Version: '5.1.57-log'  socket: '/usr/local/mysql/mysql.sock'  port: 3306  Source distribution     130531 18:21:14 mysqld_safe Starting mysqld daemon with databases from /usr/local/mysql/var     130531 18:21:14 [Warning] '--skip-locking' is deprecated and will be removed in a future release. Please use '--skip-external-locking' instead.     130531 18:21:14 [Note] Plugin 'FEDERATED' is disabled.     130531 18:21:14  InnoDB: Initializing buffer pool, size = 8.0M     130531 18:21:14  InnoDB: Completed initialization of buffer pool     InnoDB: The log sequence number in ibdata files does not match     InnoDB: the log sequence number in the ib_logfiles!     130531 18:21:14  InnoDB: Database was not shut down normally!     InnoDB: Starting crash recovery.     InnoDB: Reading tablespace information from the .ibd files...     InnoDB: Restoring possible half-written data pages from the doublewrite     InnoDB: buffer...     130531 18:21:14  InnoDB: Started; log sequence number 0 44233     130531 18:21:14 [Note] Recovering after a crash using mysql-bin     130531 18:21:14 [Note] Starting crash recovery...     130531 18:21:14 [Note] Crash recovery finished.     130531 18:21:14 [Note] /usr/local/mysql/libexec/mysqld: ready for connections.     Version: '5.1.57-log'  socket: '/usr/local/mysql/mysql.sock'  port: 3306  Source distribution      * * * **Edit #2 (May 31, 16:46 UTC):** **Sorry!** I forgot to add that immediately after executing mysqld_safe, there's a `wait` command. The `wait` command exists in order to make sure that the daemon has started, so that I'd be able to execute `mysql -u root`. Please wait, perhaps I'll find a solution.


Search and replace with sed

Last week I accidently externalized all my strings of my eclipse project. I need to revert this and my only hope is sed. I tried to create scripts but failed pathetically because I'm new with sed and this would be a very complicated operation. What I need to do is this: Strings in `class.java` file is currently in the following format(method) `Messages.getString(<key>)`. Example :                   if (new File(DataSource.DEFAULT_VS_PATH).exists()) {             for (int i = 1; i <= c; i++) {                 if (!new File(DataSource.DEFAULT_VS_PATH                         + Messages.getString("VSDataSource.89") + i).exists()) { //$NON-NLS-1$                     getnewvfspath = DataSource.DEFAULT_VS_PATH                             + Messages.getString("VSDataSource.90") + i; //$NON-NLS-1$                     break;                 }             }         }      The key and matching Strings are in `messages.properties` file in the following format.               VSDataSource.92=No of rows in db =      VSDataSource.93=Verifying db entry :      VSDataSource.94=DB is open     VSDataSource.95=DB is closed     VSDataSource.96=Invalid db entry for      VSDataSource.97=\ removed.     key=string      So I need the java file back in this format:                   if (new File(DataSource.DEFAULT_VS_PATH).exists()) {             for (int i = 1; i <= c; i++) {                 if (!new File(DataSource.DEFAULT_VS_PATH                         + "String 2" + i).exists()) { //$NON-NLS-1$                     getnewvfspath = DataSource.DEFAULT_VS_PATH                             + "String 1" + i; //$NON-NLS-1$                     break;                 }             }         }      How can I accomplish this with `sed`? Or is there an easier way?


How to know who accessed a file or if a file has 'access' monitor in linux

I'm a noob and have some questions about viewing who accessed a file. I found there are ways to see if a file was accessed (not modified/changed) through audit subsystem and inotify. However, from what I have read online, according to here: http://www.cyberciti.biz/tips/linux-audit-files-to-see-who-made-changes-to-a- file.html it says to 'watch/monitor' file, I have to set a watch by using command like:               # auditctl -w /etc/passwd -p war -k password-file      **So if I create a new file or directory, do I have to use audit/inotify command to 'set' watch first to 'watch' who accessed the new file?** Also is there a way to know if a directory is being 'watched' through audit subsystem or inotify? How/where can I check the log of a file? **edit:** from further googling, I found this page saying: http://www.kernel.org/doc/man-pages/online/pages/man7/inotify.7.html The inotify API provides no information about the user or process that triggered the inotify event. So I guess this means that I cant figure out which user accessed a file? Only audit subsystem can be used to figure out who accessed a file?


How to delete a file on remote machine via SSH by using a Shell Script?

I am writing a Shell Script where I have to delete a file on a remote machine via a Shell Script. Flow manually:               ssh username@domain.com      .. then at domain:               cd ./some/where     rm some_file.war      How to accomplish that task?


fdisk hangs on "Syncing disk" when resizing a raw QEMU image

I'm using fdisk to resize the partitions on a raw QEMU image. When I write the new partition table, it hangs at "Syncing disks." Note that I'm running fdisk as non-root since I don't need root to edit the image file. What would cause "Syncing disks" to hang like this?


Xterm with Solarized only showing dark background without font colors

I am trying to get the Solarized color scheme for xterm, but have not had much success with it. I am running Debian 6 and downloaded the `Xresources` to `~/.Xresources`. After loading the new settings with `xrdb -load ~/.Xresources`, I get a XTerm with the blueish background from the theme, but no font colors. ![Xterm with solarized theme](http://i.stack.imgur.com/N2FXU.png) The default xterm is capable of color, as you can see below: ![default xterm with Debian](http://i.stack.imgur.com/44jk0.png) How do I get the colors from solarized to show?


Use sed to find whole word and replace

I have the following block of text in a file:               test3.legacy test4.legacy test3 test3.kami      I only want to search for `test3` as a whole and replace it with nothing. Unfortunately, all my attempts have removed **test3** from `test3.legacy` and `test3.kami`. I've tried:               sed 's/^test3://g' myfile.txt     sed 's/\btest3\b//g' myfile.txt     sed 's/\<test3\>//g' myfile.txt      without any luck. Any ideas how I can resolve this please? **EDIT:** Most attempts have resulted in the following: `.legacy test4.legacy .kami`