Sed? Stripping all formatting, i.e line breaks and whitespaces, from a report text file, while masking out certain pieces

I am working on a project in which I need to remove all formatting from a text file including whitespaces and line breaks, then replace any colons with pipes. I've made some headway but I cannot find a way to mask out the parts that need to be ignored. I am new to sed and am only at novice level with Bash scripting, and am, in fact, not entirely sure sed is the right tool for the job (maybe vi? I typically use Nano). The file that I am trying to format is similar to this == LUN mysql05-dbdat02 ==                 LUNName:                        mysql05-dbdat02       CollectionStartTime:            2012-09-20T15:43:03-04:00       CollectionEndTime:              2012-09-20T15:43:34-04:00       Capacity         CurrentCapacity:              512       IOOperations         Reads:                        100         Writes:                       0         ReadsPerSecond:               0.000000         WritesPerSecond:              0.000000         ReadMBPerSecond:              0.000         WriteMBPerSecond:             0.000         TotalMBPerSecond:             0.000         NonOptimizedIOPerSecond:      0.000000         CacheHitPercentage:           0.000       PerformanceMetrics         TotalIOsPerSecond:            0.000         ReadIOsPerSecond:             0.000         WriteIOsPerSecond:            0.000         TotalMBPerSecond:             0.000         ReadMBPerSecond:              0.000         WriteMBPerSecond:             0.000       Performance      == LUN mysql05-dbdat02 ==                 LUNName:                        mysql05-dbdat02       CollectionStartTime:            2012-09-20T15:43:03-04:00       CollectionEndTime:              2012-09-20T15:43:34-04:00       Capacity         CurrentCapacity:              512       IOOperations         Reads:                        100         Writes:                       0         ReadsPerSecond:               0.000000         WritesPerSecond:              0.000000         ReadMBPerSecond:              0.000         WriteMBPerSecond:             0.000         TotalMBPerSecond:             0.000         NonOptimizedIOPerSecond:      0.000000         CacheHitPercentage:           0.000       PerformanceMetrics         TotalIOsPerSecond:            0.000         ReadIOsPerSecond:             0.000         WriteIOsPerSecond:            0.000         TotalMBPerSecond:             0.000         ReadMBPerSecond:              0.000         WriteMBPerSecond:             0.000       Performance      and the output needs to be something like this,               cm-data-unity01|LUNNam=cm-data-unity01|CollectionStartTim=2012-09-20T15:43:03-04:00|CollectionEndTim=2012-09-20T15:43:34-04:00|Capacity|CurrentCapacit=2048|IOOperations|Read=10|Write=90|ReadsPerSecon=8.000000|WritesPerSecon=76.000000|ReadMBPerSecon=0.430|WriteMBPerSecon=0.542|TotalMBPerSecon=0.973|NonOptimizedIOPerSecon=85.000000|CacheHitPercentag=0.000|PerformanceMetrics|TotalIOsPerSecon=84.000|ReadIOsPerSecon=8.000|WriteIOsPerSecon=76.000|TotalMBPerSecon=0.973|ReadMBPerSecon=0.430|WriteMBPerSecon=0.542|Performance|      or, all on one line. I have written a very simple Bash script to format it, like thus               # Author Christopher George Bollinger     # Comments: This script will modify the snippet.txt file.       # This script is meant to, first, take a specific bit of unformatted data and  remove all line breaks and non-printable characters.          # Following this, the script is to replace any appropriate colons (those being used as delimiters) and replace them with the equals (=) character.     #!/bin/bash          echo "This script will remove line breaks, remove non-printable characters, and will replace colons used as field delimiters with the equals '(=)' character."     cp snippet.txt snippetwork.txt          RmLB ()     {     tr -d '\n' < snippetwork.txt > snippetwork1.txt          }          RmNonPrint ()     {     tr -cd "[:print:]" < snippetwork1.txt > snippetwork2.txt          }          RplcW ()     {     sed 's/: /=/g' snippetwork2.txt > snippetwork3.txt          }          RmWtSpc ()     {     tr -s ' ' '|' < snippetwork3.txt > snippetgood.txt     sed 'd/(?:[a-z]=) /'     }          QuChek ()     {     cat snippetgood.txt     read -p "Is this satisfactory? (Y/n)" Choice     case $Choice in         Y|y)         mv snippetgood.txt snippet.txt         rm -f snippetwork*         rm -f snippetgood.txt         ;;         N|n)         exit         ;;         *)         echo "Invalid Input."         ;;     esac     }          read -p "Would you like to begin? (Y/n)" YorN          case $YorN in         Y|y)         RmLB         RmNonPrint         RplcW         RmWtSpc         QuChek         ;;         N|n)         exit         ;;         *)         echo "Invalid Selection"         ;;     esac      Which functions except the output is not quite right, it gives:               ==|LUN|mysql05-dbdat02|==|LUNName=|mysql05-dbdat02|CollectionStartTime=|2012-09-20T15:43:03-04:00|CollectionEndTime=|2012-09-20T15:43:34-04:00|Capacity|CurrentCapacity=|512|IOOperations|Reads=|100|Writes=|0|ReadsPerSecond=|0.000000|WritesPerSecond=|0.000000|ReadMBPerSecond=|0.000|WriteMBPerSecond=|0.000|TotalMBPerSecond=|0.000|NonOptimizedIOPerSecond=|0.000000|CacheHitPercentage=|0.000|PerformanceMetrics|TotalIOsPerSecond=|0.000|ReadIOsPerSecond=|0.000|WriteIOsPerSecond=|0.000|TotalMBPerSecond=|0.000|ReadMBPerSecond=|0.000|WriteMBPerSecond=|0.000|Performance|==|LUN|mysql05-dbdat02|==|LUNName=|mysql05-dbdat02|CollectionStartTime=|2012-09-20T15:43:03-04:00|CollectionEndTime=|2012-09-20T15:43:34-04:00|Capacity|CurrentCapacity=|512|IOOperations|Reads=|100|Writes=|0|ReadsPerSecond=|0.000000|WritesPerSecond=|0.000000|ReadMBPerSecond=|0.000|WriteMBPerSecond=|0.000|TotalMBPerSecond=|0.000|NonOptimizedIOPerSecond=|0.000000|CacheHitPercentage=|0.000|PerformanceMetrics|TotalIOsPerSecond=|0.000|ReadIOsPerSecond=|0.000|WriteIOsPerSecond=|0.000|TotalMBPerSecond=|0.000|ReadMBPerSecond=|0.000|WriteMBPerSecond=|0.000|Performance|      the problem being the pipes appearing following the equals signs. If anyone could point me in the right direction on getting this right, or even to an online resource for some clarification, I would be immensely grateful. Funny thing is the end game for this is that, while the immediate request is to format like the above example, to feed this into a Unix cli graphing tool (my guess is gnuplot). From what I understand, gnuplot requires the formatting to be in columns. As mentioned, this is new territory for me and I would greatly appreciate any advice given.


Take a sum based upon particular columns

I am having a huge pile of data around 30 to 40 Million data. We need to process these files and send to another interface team. Below is my file format which we recevie               c1  c2  c3  c4  c5  c6     A   B   C   D   5   s     A   B   C   D   4   s     A   B   E   F   5   s     A   B   E   F   8   S     C   D   E   F   9   S      I need to print in my out file all the columns. Since this is releated to GPRS usage we need to group by c1 - c4 and then if everything is matching we need to sum up the c5 and print everything in the output file. Below is the sample out file.               c1  c2  c3  c4  c5  c6     A   B   C   D   9   s     A   B   E   F   13  s     C   D   E   F   9   s      I do not have much know Unix or perl resources in my team or outside team. Kindly to help me in this. I also heard that this work flow works a lot faster in perl than in Unix scripting. If there is any other better way or method also please do suggest me.


xargs how to put result {} into $(cmd {})?

for example: `find /usr/lib -maxdepth 1 -type l -iname "*libblas*"|xargs -I{} echo "{} =>" $(realpath {})` I would like it to output:               /usr/lib/libblas.so.3gf=>/usr/lib/libblas/libblas.so.3gf.0     /usr/lib/libblas.so=>/usr/lib/libblas/libblas.so.3gf.0     /usr/lib/libblas.a=>/usr/lib/libblas/libblas.a      This will not work because the value in `$()` is expanded before the script actual running. Is there any way I can achieve this result? without loop in bash?


Is there any issue to put / as a home directory of root user from security point of view?

Is there any issue to put / as a home directory of root user from security point of view instead of /root


openldap: add auxiliary class

I want to add an auxiliary class to OpenLDAP. What exactly do I have to do? I'm using Apache Directory Studio as editor. I've added a new core schema with olcObjectClasses "testclass" and an olcAttribute "company". This worked fine. But when I add this auxiliary class to an inetOrgPerson Object and add the new attribute defined in my class, the Apache Directory Studio says that this attribute wasn't allowed. Nevertheless I can add it. Are some auxiliary classes restricted by the inetOrgPerson or is there any dependency between classes? Is it sufficient to define a new schema, a testclass and an olcAttribute? I defined them similar to the inetOrgPerson entries. Are there any "meta-entries" where new entries have to be defined? Those questions are probably quite stupid, but I'm not an LDAP expert :-) Thank you in advance. If there's any forum that is more suitable just point me to it.


Execute shell script from php, as root user?

Need to execute the following line from PHP: > $res = shell_exec('sudo sh /home/nicklas/cronjobs/make_account.sh username > password'); The problem is nothing happens on execution. If i try to echo $res it comes out blank. I've tried using system() also, same result. I'm guessing it doesn't work because i need to run the scrip with root access, and the www- data user doesn't have that by default. I added the following line to /etc/sudoers in hope of getting access: > www-data ALL=(ALL:ALL) NOPASSWD: /home/nicklas/cronjobs/make_account.sh But no success. I've tried restarting apache inbetween, doesn't change anything. Am i missing something?


Social website about shell commands

I remember seeing an entire social website devoted to the question What are your favorite command line features or tricks?, where you can post shell commands, tag them, comment on them, and rate and/or favorite them. Unfortunately, I've forgotten what this site was called and can't seem to muster up enough google-fu to find it. Anyone know of such a site (for which you can actually find a URL)?


bash nested case syntax and ;; terminators

Have I got enough (or perhaps too many) `;;` terminators in this bash script containing nested `case`'s?               case "$1" in     OK)         # Nothing needs done         echo -n "OK:1" ;;          CRITICAL)              case "$2" in         SOFT)             case "$3" in             1|2)                  soft_reset_pool.sh ;;             esac ;;              HARD)             case "$3" in             1|2)                 hard_reset_pool.sh ;;                  3|4)                 hard_reset_service ;;                  esac ;;         esac ;;           esac      It's been a few years since I did any bash in anger.


RAID5 Arrary disappeard with no HW or SW changes made

I have a R-Pi running XBMC (Linux CaribNAS 3.10.24 #2 PREEMPT Mon Dec 23 05:18:12 UTC 2013 armv6l GNU/Linux) with a 3 disk raid 5 array that has been working up till yesterday when is stopped running overnight and now will now not start, I have a lot of data that is not backed up so would like to recover without data loss if poss. I have noticed that mdadm --examine --scan shows two /dev/md/0 arrays, only the second one is correct, but I cant get rid of the first, but I don't think this is the cause but would like to tidy things up.                dmesg |grep md:      md: md0 stopped.      md: sdc1 does not have a valid v1.2 superblock, not importing!      md: md_import_device returned -22      md: sdd1 does not have a valid v1.2 superblock, not importing!      md: md_import_device returned -22      md: sdb1 does not have a valid v1.2 superblock, not importing!      md: md_import_device returned -22                mdadm -D /dev/md0      mdadm: md device /dev/md0 does not appear to be active.                mdadm --examine --scan      ARRAY /dev/md/0 metadata=1.2 UUID=c20f8d11:b81ae9b6:1b318343:ed35987e name=raspbmc:0      ARRAY /dev/md/0 metadata=1.2 UUID=8ec7d307:b5609dfd:caea7099:a9d8201c name=CaribNAS:0                cat /etc/mdadm/mdadm.conf      DEVICE partitions      HOMEHOST CaribNAS      MAILADDR CaribNAS@gmail.com      ARRAY /dev/md0 metadata=1.2 Name=CaribNAS:0 UUID=8ec7d307:b5609dfd:caea7099:a9d8201c           cat /etc/fstab      proc /proc proc defaults 0 0      devpts /dev/pts devpts rw,nosuid,noexec,relatime,gid=5,mode=620 0 0      /dev/sda1 / ext4 defaults 0 0      /dev/sda2 /temp ext4 defaults 0 0      /dev/mmcblk0p1 /boot vfat defaults,noatime 0 0      #/dev/mmcblk0p2 / f2fs defaults,noatime 0 0      /dev/md0 /RAID5 auto defaults 0 3                cat /proc/mdstat      Personalities :      unused devices: <none>           mdadm --stop /dev/md0      mdadm: stopped /dev/md0           mdadm --assemble --scan -v      mdadm: looking for devices for /dev/md0      mdadm: /dev/sdd has wrong uuid.      mdadm: /dev/sdc has wrong uuid.      mdadm: /dev/sdb has wrong uuid.      mdadm: no RAID superblock on /dev/sda2      mdadm: no RAID superblock on /dev/sda1      mdadm: no RAID superblock on /dev/sda      mdadm: no RAID superblock on /dev/mmcblk0p2      mdadm: no RAID superblock on /dev/mmcblk0p1      mdadm: no RAID superblock on /dev/mmcblk0      mdadm: /dev/sdd1 is identified as a member of /dev/md0, slot 2.      mdadm: /dev/sdc1 is identified as a member of /dev/md0, slot 1.      mdadm: /dev/sdb1 is identified as a member of /dev/md0, slot 0.      mdadm: failed to add /dev/sdc1 to /dev/md0: Invalid argument      mdadm: failed to add /dev/sdd1 to /dev/md0: Invalid argument      mdadm: failed to add /dev/sdb1 to /dev/md0: Invalid argument      mdadm: failed to RUN_ARRAY /dev/md0: Invalid argument           mdadm --examine /dev/sd[bcd]1      mdadm --examine /dev/sd[bcd]1      /dev/sdb1:      Magic : a92b4efc      Version : 1.2      Feature Map : 0x0      Array UUID : 8ec7d307:b5609dfd:caea7099:a9d8201c      Name : CaribNAS:0 (local to host CaribNAS)      Creation Time : Thu Jan 16 02:44:56 2014      Raid Level : raid5      Raid Devices : 3           Avail Dev Size : 1953260975 (931.39 GiB 1000.07 GB)      Array Size : 1953260544 (1862.77 GiB 2000.14 GB)      Used Dev Size : 1953260544 (931.39 GiB 1000.07 GB)      Data Offset : 262144 sectors      Super Offset : 8 sectors      State : clean      Device UUID : 8d6ee8dc:1d62a673:74189894:14192b98           Update Time : Sat Mar 15 15:46:41 2014      Checksum : 2cd2a9ae - correct      Events : 345           Layout : left-symmetric      Chunk Size : 512K           Device Role : Active device 0      Array State : AAA ('A' == active, '.' == missing)      /dev/sdc1:      Magic : a92b4efc      Version : 1.2      Feature Map : 0x0      Array UUID : 8ec7d307:b5609dfd:caea7099:a9d8201c      Name : CaribNAS:0 (local to host CaribNAS)      Creation Time : Thu Jan 16 02:44:56 2014      Raid Level : raid5      Raid Devices : 3           Avail Dev Size : 1953260975 (931.39 GiB 1000.07 GB)      Array Size : 1953260544 (1862.77 GiB 2000.14 GB)      Used Dev Size : 1953260544 (931.39 GiB 1000.07 GB)      Data Offset : 262144 sectors      Super Offset : 8 sectors      State : clean      Device UUID : 2f8065d8:ff3a060d:4883c25f:12f543f7           Update Time : Sat Mar 15 15:46:41 2014      Checksum : ebf2db04 - correct      Events : 345           Layout : left-symmetric      Chunk Size : 512K           Device Role : Active device 1      Array State : AAA ('A' == active, '.' == missing)      /dev/sdd1:      Magic : a92b4efc      Version : 1.2      Feature Map : 0x0      Array UUID : 8ec7d307:b5609dfd:caea7099:a9d8201c      Name : CaribNAS:0 (local to host CaribNAS)      Creation Time : Thu Jan 16 02:44:56 2014      Raid Level : raid5      Raid Devices : 3           Avail Dev Size : 1953260975 (931.39 GiB 1000.07 GB)      Array Size : 1953260544 (1862.77 GiB 2000.14 GB)      Used Dev Size : 1953260544 (931.39 GiB 1000.07 GB)      Data Offset : 262144 sectors      Super Offset : 8 sectors      State : clean      Device UUID : 38c6ce39:0ad01a8c:d188672b:4b06661f           Update Time : Sat Mar 15 15:46:41 2014      Checksum : c037ccdb - correct      Events : 345           Layout : left-symmetric      Chunk Size : 512K           Device Role : Active device 2      Array State : AAA ('A' == active, '.' == missing)


Test FTP Username and Password

I'm working on a program that involves uploading some files via FTP. However, I'd like to abort the process if the username and password given by the user are incorrect. Is there any way to "test" if the pair is correct? Is a utility like _ftp_ or _curl_ able to do that, or should I use some feature (apparently hidden at my eyes) from _libcurl_? Any ideas are really appreciated. Maybe this sound like a question coming from a dummy programmer, but indeed I've never dealt with FTP (or any other protocol) directly. Please consider writing "you didn't get the point" or "you're crazy" if needed.


Find and move directories based on file type and date

I have a directory "New Movies" containing 200+ subdirectories "Movie Name (year)". The subdirectories "Movie Name (year)" contains a single video file (avi/mkv) and several related jpg/xml files. I need to move all directories containing a video file that is at least 180 days old to another directory. For example: New Movies/Movie A (year) would contain movie.mkv, folder.jpg & movie.xml and I want to move them to a subdirectory of the same name elsewhere with all files present and intact. After looking elsewhere on this site I have tried:               cd "/mnt/user/New Movies/"     find -type f \( -name "*.avi" -or -name ".*mkv" \) -mtime +180 -exec sh -c 'mv "${0%/*}" /mnt/user/Movies' {} \;      The command successfully moves the first subdirectory and all files to their new home, however every single operation after this one returns the error               find: './Movie B (year)': No such file or directory     find: './Movie C (year)': No such file or directory      and so on through all directories contained under "New Movies" whether they were due to be moved or not.


Using a file input as stdin for a shell script does not work

I have the following script code: **test.sh**               echo "BEGIN"     while read CMD <&1; do         [ -z "$CMD" ] && continue         case "$CMD" in         start)                 echo "get_start"                 ;;         stop)                 echo "get_stop"                 ;;         *)                 echo "get_uknown_command"                 ;;         esac         echo "END";     done      When I run it with:               $./test.sh <input.txt      I get my script locked **input.txt**               start     stop     sthh      Why my script is locked? How I can fix that? BTW: If I enter the data manually then the script will not lock.


Why yum's download speed is too slow

My yum download speed in fedora is in average less than 5KB/s and goes to less than 1KB/s but my normal download speed is around 140KB/s. I tried installing `yum-fastestmirrors` but didn't help. Any suggestions?


Shells in tabbed windows in a terminal

I want to do tabbed terminal stuff without having actual tab windows in my terminal application. Is there any good way to do this within bash? It would come in very handy with SSH if I could avoid signing in twice.


Bashrc disable-ing all but a given command for a given user

Is it possible to have `bashrc` grab every single command the user types, save for those containing a given word? Like the way you can use aliases to change what the user meant, you can alias for instance 'cd' to nothing. that way the user can't apply that command anymore. Maybe that way you can have a given user only able to apply one command?


Gentoo and Systemd: Can openrc be uninstalled without breaking other packages?

I switched my Gentoo system from openrc to systemd, and everything seems to run fine as long as both are installed. Nevertheless, after `emerge --depclean`, which removes openrc, the gentoolkit program revdep-rebuild does not work any more (it misses /etc/init.d/functions.sh and the einfo command). Now the question is, can I get rid of openrc (and sysvinit) without breaking packages, and if yes, how? Should I wait with further steps until bug 373219 is fixed?


why isn't xargs parsing my input correctly?

Ive been trying to write a shell script that will interface with cmus and then notify me of the track info using notify-send. Right now it is not working mainly because xargs does not seem to pass 2 arguments to notify-send. It only sends one and I cannot figure out why. I've done everything I can think of with sed to get the right output but it doesn't work. Also, if I use notify- send with two arguments, it works so I don't think it's a problem with notify- send. The output of cmus-remote -Q is:               status paused     file /home/dennis/music/Coheed And Cambria/GOODAP~1/05 Crossing the Frame.mp3     duration 207     position 120     tag artist Coheed & Cambria     tag album Good Apollo I'm Burning Star IV Volume One: From Fear Through the Eyes of Madness     tag title Crossing the Frame     tag date 2005     tag genre Rock     tag tracknumber 5     tag albumartist Coheed & Cambria     set aaa_mode all     set continue true     set play_library true     set play_sorted false     set replaygain disabled     set replaygain_limit true     set replaygain_preamp 6.000000     set repeat false     set repeat_current false     set shuffle true     set softvol false     set vol_left 100     set vol_right 100      My code is terrible. I'm just starting to learn shell scripting so sorry about that.               #!/bin/sh     #     # notify of song playing          info="$(cmus-remote -Q)"          title="`echo "$info" | grep 'tag title' | sed "s/'//g" | sed 's/tag title \(.*\)/'\''\1'\''/g'`"          artist="`echo "$info" | grep 'tag artist' | sed "s/'//g" | sed 's/tag artist \(.*\)/ '\''\1/g'`"     album="`echo "$info" | grep 'tag album ' | sed "s/'//g" | sed 's/tag album \(.*\)/ \1'\''/g'`"          stupid="${title}${artist}$album"     echo "$stupid" | xargs notify-send


How to hide the . and .. from ls

When I run `ls -l` on a directory, I see an entry titled '.' How can I remove the row containing '.' from the output?               ls -latr /foo | tail -n5      -rw-rw-r--  1 guest bar      59169 Aug 20 12:22 foobar     -rw-rw-r--  1 guest bar      59169 Aug 20 12:23 bar1     -rw-rw-r--  1 guest bar      59169 Aug 20 12:24 foobar42     -rw-rw-r--  1 guest bar      59169 Aug 20 12:25 foo     drwxrws---  8 guest bar    102400 Aug 20 12:26 .      I'm thinking cut should work, but I can't find the right syntax.               ls -latr |tail -n5|cut -d'.'       ls -latr |tail -n5|cut -d.


How to Navigate within bash's Reverse Search?

Bash offers the functionality to reverse search via `Ctrl` + `R`. Then one can type in a part of a command it will show a fitting entry from the history. Assume this is my history:               vim foo1     vim foo2 # I want to go here     vim foo3 # this is where I land, how to go back?      I search for `foo`. Hitting `Ctrl` + `R` again shows the next fitting search entry. Often it happens to me, that I am too fast and navigate past my intended result and `vim foo3` is shown and now I want to go back to `vim foo2`. Hence my question is: How do I navigate within the reverse search?


Supress startup messages on stdout?

I'm using `tcsh`, and have to source a group `.cshrc` file. This file echoes some messages, which is fine for normal shells, but causes problems with programs like `scp` and `rsync`. I can see the solution taking one of a few forms, but am unable to implement any of them. ### Only execute echos when appropriate I've scoured the `rsync` and `tcsh` man pages, but I can't find any variables that are guaranteed to be set or unset when it is called from ssh/rsync/whatever. `$PROMPT` is the same as normal, `$shlvl` is 1, and nothing else looks promising. ### Redirect to stderr rsync/scp/etc don't seem to care about what comes over stderr, so if I could, I would               echo $MSG >&2      But this doesn't even work from the shell. Instead, it writes `$MSG` to a file named `2`. When I look through the history, it seems that something (xterm? readline? tcsh?) is inserting spaces, so what was actually run was               echo $MSG > & 2      So the observed behavior makes sense given the actual input to tcsh. ### Redirect to /dev/stderr I've also tried               echo $MSG > /dev/stderr      Which works for `ssh`, but for `scp` and `rsync`, I get the message '`/dev/stderr: Permission denied.`' and the key difference seems to be where the file is symlinked. Adding `ls -l /dev/stderr /proc/self/fd/2` to the cshrc file shows               # For ssh     lrwxrwxrwx 1 root root    15 Apr 11 09:58 /dev/stderr -> /proc/self/fd/2     lrwx------ 1 <me> <mygrp> 64 May 24 14:34 /proc/self/fd/2 -> /dev/pts/6          # For scp     lrwxrwxrwx 1 root root    15 Apr 11 09:58 /dev/stderr -> /proc/self/fd/2     l-wx------ 1 <me> <mygrp> 64 May 24 15:07 /proc/self/fd/2 -> pipe:[378204842]      However, since the permission denied message comes across on stderr, the scp/rsync process is able to do its thing, so I can live with this solution, but would rather not get this spurious error message.


Change the timezone in a terminal

I connect my web server via SSH Terminal on Mac.               cat /var/www/vhosts/example.com/statistics/logs/error_log       The Date of my server and local computer differs so output of error_logs is not efficient for me. Is it possible to change date output to my local time without modifying settings in server computer? The server date settings should stay same because another user is connecting from another part of world. I want to handle this automatically by Mac terminal if possible and just for me.


How do I ad an if statement (regarding punctuation in a word) to this bash script

I have this bash script               #!/bin/bash     cat $@ | while read line     do         for word in $line         do             echo $word | circling-the-square             # here's where i need to add the if statement:             #if the word contains one of the four [!?.,],             #then also echo that punctuation mark         done     done      circling-the-square is a Python script based on Norvig's spelling corrector. That script rids its input of punctuation               def words(text): return re.findall('[a-z]+', text.lower())       so I need `bash` to notice this. I guess `sed` or `awk` might be useful but I still don't know how to write that regex or put it in an if statement, so I'm asking this here. As is, passing the file               alec@ROOROO:~/oddi-o/newton-fluxions$ cat 199      advertisement lately publijtid by the author, the british hemisphere, or a map of a new contrivance, proper for initiating young minds in the firft rudiments of geography, and the ufe of the globes.      gives               alec@ROOROO:~/oddi-o/newton-fluxions$ ./hmmb 199     advertisement     lately     publijtid          by     the     author     the     british     hemisphere     or     a     map     of     a     new     contrivance     proper     for     initiating     young     minds     in     the     first     rudiments     of     geography     and     the     few     of     the     globes.      Which isn't perfect but still useful. _FYI_ , I have edited the file in question to contain only `\w` and the punctuation `[!?.,]`. The file does not contain characters like : or ;, so I _just need it to echo these four punctuation marks_ if they are included as part of a word, viz.:               alec@ROOROO:~/oddi-o/newton-fluxions/finforno$ ./hmmb 199     advertisement     lately     publijtid     by     the     author,     the     british     hemisphere,     or     a     map     of     a     new     contrivance,     proper     for     initiating     young     minds     in     the     firft     rudiments     of     geography,     and     the     ufe     of     the     globes.


Expect script + automated telnet process between three Linux machines

Is it possible to do the following by expect script? I have Linux server that connected to **linux_machine1** and **linux_machine1** connected to **linux_machine2** My Linux server have access only to **linux_machine1** ( linux server can telnet to **linux_machine1** but can’t telnet to **linux_machine2** ) But from **linux_machine1** I have access VIA telnet to **linux_machine2** So my question is: I need to develop expect script that perform telnet from the Linux server to **linux_machine1** then expect will perform telnet to **linux_machine2** from **linux_machine1** and will copy the **/etc/hosts** file from **linux_machine2** to my Linux server Is this scenario can be implemented by expect script? Short example that descript the process:                 ( run expect from Linux server ) --> linux_machine1 --> linux_machine2        Linux server          <--   /etc/hosts    from linux_machine2 <--        * remark - expect script need to be activate from the linux server


Where can I find the wireless driver for BCM4311 for OpenIndiana 148?

I know that OpenIndiana 148 doesn't have the network driver (BCM4311) for the laptop. I wonder if anyone out there can help, or point the way to me where I can get the driver?


Changing color depth in linux mint

How can I alter color depth settings in Linux Mint 13 maya? I tried to find the `xorg.conf` in               /etc/X11/      But I could not find the file.


SSH on my local network - problem with login

I'm having problem with logging into my local-network-linux (server) ssh with Putty (and with Linux terminal, too) When my server shows me request to insert username, I insert "root" and I do press enter. I am waiting about seven seconds before it requests my password! I also looked at this question and tried accepted answer, also with command               /etc/init.d/ssh restart      It didn't work. My friend told me that I should have to use another SSH deamon, but I don't know which. What could I do now? my current /etc/ssh/ssh_config config:               # configuration file, and defaults at the end.          # Site-wide defaults for some commonly used options.  For a comprehensive     # list of available options, their meanings and defaults, please see the     # ssh_config(5) man page.          Host *     #   ForwardAgent no     #   ForwardX11 no     #   ForwardX11Trusted yes     #   RhostsRSAAuthentication no     #   RSAAuthentication yes     #   PasswordAuthentication yes     #   HostbasedAuthentication no       GSSAPIAuthentication no        GSSAPIDelegateCredentials no        GSSAPIKeyExchange no     #   GSSAPITrustDNS no     #   BatchMode no     #   CheckHostIP yes     #   AddressFamily any     #   ConnectTimeout 0     #   StrictHostKeyChecking ask     #   IdentityFile ~/.ssh/identity     #   IdentityFile ~/.ssh/id_rsa     #   IdentityFile ~/.ssh/id_dsa     #   Port 22     #   Protocol 2,1     #   Cipher 3des     #   Ciphers aes128-ctr,aes192-ctr,aes256-ctr,arcfour256,arcfour128,aes128-cbc,3des-cbc     #   MACs hmac-md5,hmac-sha1,umac-64@openssh.com,hmac-ripemd160     #   EscapeChar ~     #   Tunnel no     #   TunnelDevice any:any     #   PermitLocalCommand no     #   VisualHostKey no     #   ProxyCommand ssh -q -W %h:%p gateway.example.com         SendEnv LANG LC_*         HashKnownHosts yes


Changing linux distro remotely while preserving data

I have a headless Fedora 15 (without GUI) box. With the following partition structure:               $ df -T -h     Filesystem    Type    Size  Used Avail Use% Mounted on     rootfs      rootfs     49G  2.8G   46G   6% /     udev      devtmpfs    1.7G  4.0K  1.7G   1% /dev     tmpfs        tmpfs    1.7G     0  1.7G   0% /dev/shm     tmpfs        tmpfs    1.7G  604K  1.7G   1% /run     /dev/sda1     ext4     49G  2.8G   46G   6% /     tmpfs        tmpfs    1.7G     0  1.7G   0% /sys/fs/cgroup     tmpfs        tmpfs    1.7G     0  1.7G   0% /media     /dev/sda5     ext4    388G   35G  334G  10% /var     /dev/sda2     ext4     28G  1.7G   25G   7% /home      I am tired of Fedora Project's policy of 12-14 month support cycle (they may have their reasons) and intend to migrate to something more stable like Scientific Linux or CentOS. Most of my data is in `/var` (MySQL, Redis & Apache Docroot) and `/home`. Is it possible that I can migrate from fedora to other RH family distro by preserving the directories `/var` and `/home` and do so remotely? (Under dire circumstances I am willing to carry a monitor and keyboard to it.) If yes, then what are the steps for the same?


Remove slashes/parent paths from filenames inside CSS and Javascript content

I need to go through all my css and js files and if there is a filename referenced that has any slashes (/) at all then the slash should be removed. What I want is:   * if any files referenced are named `/file.jpg` then remove the leading slash leaving just `file.jpg`.  For example, in a CSS file change: `@import url("/base.css");` to `@import url("base.css");`   * if the file referenced is named `/files/file.jpg` then the leading slashes and folder name should be removed leaving just `file.jpg`.  I started to write it but then couldn't think about how to deal with the slashes.               grep -o -h -E '[A-Za-z0-9:./_-]+\.(png|jpg|gif|tif|css)' `find     ${new_directory} -name '*.css' -or -name '*.js'`      Any idea how to do this? I am doing this using a `.sh` shell script.


anyway to fail/delay a cp process?

This is a hypothetical scenario. Say that I have a particular folder that is being synchronized by a process which is receiving a files/folders via the internet. Now while this operation is in progress, for the synchronizer's sake, there should be no cp operations to its directory. Anyway this can be acheived?


rc.local - not all commands are executed

I have following lines in my rc.local               #!/bin/sh -e     #     # rc.local     #     # This script is executed at the end of each multiuser runlevel.     # Make sure that the script will "exit 0" on success or any other     # value on error.     #     # In order to enable or disable this script just change the execution     # bits.     #     # By default this script does nothing.          if [ -f /resize ]     then     if [ -f /resize2 ]     then     sh /resize2     else     sh /resize     fi     fi          /etc/rc --foreground     /sbin/iptables-restore /etc/iptables     mkdir /tmp/cooks     mkdir /tmp/cook     chmod 777 /tmp/cook     chmod 777 /tmp/cooks     mkdir /tmp/xhprof     chmod 777 /tmp/xhprof          exit 0      but neither `/tmp/cooks` nor `/tmp/cook` nor `/tmp/xhprof` dir was not created (on system startup). I'm using `Debian GNU/Linux 6.0 squeeze (VPS)`


Why am I getting an AttributeError when I try to use Pyjamas desktop on Fedora 15?

I am trying to run `pyjamas-desktop` on my _Fedora 15_. All packages were installed, I have adjusted `PYTHONPATH` to include `/usr/share/pyjamas/library`, but when I try to run a simple example:               from pyjamas.ui.Button import Button     from pyjamas.ui.RootPanel import RootPanel     from pyjamas.ui.HTML import HTML     from pyjamas import Window          def greet(sender):         Window.alert("Hello, AJAX!")          if __name__ == '__main__':         b = Button("Click me", greet)             RootPanel().add(b)         hw = HTML("Hello <b>World</b>")         RootPanel().add(hw)      I get information:               Traceback (most recent call last):       File "pyjstest.py", line 10, in <module>         b = Button("Click me", greet)       File "/usr/share/pyjamas/library/pyjamas/ui/Button.py", line 36, in __init__         element = DOM.createButton()       File "/usr/share/pyjamas/library/pyjamas/DOM.py", line 190, in createButton         return createElement("button")       File "/usr/share/pyjamas/library/pyjamas/DOM.py", line 202, in createElement         return doc().createElement(tag)       File "/usr/share/pyjamas/library/__pyjamas__.py", line 45, in doc         return main_frame.getDomDocument()      AttributeError: 'NoneType' object has no attribute 'getDomDocument'      Do I need to adjust something here? For Ubuntu I have found information on pyjamas-dev, that it needs to be built from source and bootstrapped. Nothing was required of me, when I installed it from package in Fedora. What may I be doing wrong?


In-place substitution for lines matching some pattern in a given set of files

Following on from my previous question: > Remove slashes/parent paths from filenames inside CSS and Javascript content I arrived at the following command which replaces any filenames in these files with just the basename:               grep -o -h -E '[A-Za-z0-9:./_-]+\.(png|jpg|gif|tif|css)' |\       sed "s:[a-zA-z0-9]*/::" `find . -name '*.css' -or -name '*.js'`       How do I save the output of this command back to the source file for each file processed?


How to background a command chain?

I want to background a command chain like `cp a b && mv b c && rm a`. I have tried doing `cp a b && mv b c && rm a &` but this only backgrounds the last process. How do I background a command chain?


Why does "ls *" take so much longer than "ls"?

I have a couple of files in a directory:               $ ls | wc -l     9376      Can anybody explain why there is such a huge time difference in using `ls *` and `ls`?               $ time ls > /dev/null     real    0m0.118s     user    0m0.106s     sys     0m0.011s      and               $ time ls * > /dev/null     real    1m32.602s     user    0m0.233s     sys     0m0.438s      okay, this is a drastic example and maybe enhanced because the directory is on a general parallel file system (GPFS). But I can also see a significant slowdown on a local file system. **EDIT:**               $ time ls -l > /dev/null     real    0m58.772s     user    0m0.113s     sys     0m0.452s     $ time ls -l * > /dev/null     real    1m19.538s     user    0m0.252s     sys     0m0.461s      and I should add that in my example there are no sub directories:               $ diff <(ls) <(ls *)     $


Configure courier to forward certain mails to external addresses

I have a debian 6.0 server with courier/courier-mta set up and some local domains. Now I want to create some forwards for some email address that should go directly to external addresses as there are no local users for those addresses. Eg. I have an address "peter@example.com" (its an example, I use a different address) and I want it to be redirected to "peter@test.test" and also some other addresses from "example.com" but to different target domains. I tried to configure courier with the webadmin interface and registered "example.com" as a local domain. Then under the aliases section i added the full "peter@example.com" address (as there is no local account) and set "peter@test.test" as recipient - but it didn't work. When I sent to the user I get: > The error that the other server returned was: 550 User unknown Then I read something about courier aliases and created a new file "example.com" under the couriercfgdir/aliases and added some email addresses and targets (e.g.: "peter@example.com: peter@test.test") and run the "makealiases" command but it didn't change anything. I still receive the same 550 error when sending mail to peter@example.com. I'm not really the mail or linux guru but have some basic understanding. I thought maybe aliases is ignored as long as I don't use maildrop, so I changed the courier delivery options to use "maildrop" (and installed the courier- maildrop package), restarted the courier server but still no change. And I also don't know where to find some sort of log file. /var/log/mail.log was last updated in june but I have received emails since then and I don't see any other logfile for courier. Somehow it looks as if my aliases are ignored but I don't get why. Does anyone have an idea why?


timeout without killing process in bash

I have a main script that I'm running, and from it I have a second "slow process" I want to kick off, and "do something" in the main script if it doesn't complete in the time limit -- depending on if it completed or not. N.B. If the "slow process" finishes before my time limit, I don't want to have to wait an entire time limit. I want the "slow process" to keep going so I can gather stats and forensics about it's performance. I've looked into using timeout, however it will kill my script when finished. Suppose this simplified example. **main.sh**               result=`timeout 3 ./slowprocess.sh`     if [ "$result" = "Complete" ]     then      echo "Cool it completed, do stuff..."     else      echo "It didn't complete, do something else..."     fi      **slowprocess.sh**               #!/bin/bash     start=`date +%s`     sleep 5     end=`date +%s`     total=`expr $end - $start`     echo $total >> /tmp/performance.log     echo "Complete"      Here, it uses timeout -- so the script dies, so nothing winds up in `/tmp/performance.log` -- I want `slowprocess.sh` to complete, but, I want `main.sh` to go onto its next step even if it doesn't finish in the 3 seconds.


Manjaro Linux - Cable unplugged even if plugged

I have just installed the system (Manjaro) and I have one, major, problem: it says that my network cable is unplugged, even if it's plugged. I have a Realtek RTL-8110SC/8169SC Gigabit Ethernet and with Windows it works with no problem. If I do **_ifconfig_** in the terminal, I get:               enp7s1: flags=4099<UP,BROADCAST,MULTICAST>  mtu 1500         ether 14:da:e9:21:fd:bf  txqueuelen 1000  (Ethernet)         RX packets 0  bytes 0 (0.0 B)         RX errors 0  dropped 0  overruns 0  frame 0         TX packets 0  bytes 0 (0.0 B)         TX errors 0  dropped 0 overruns 0  carrier 0  collisions 0          lo: flags=73<UP,LOOPBACK,RUNNING>  mtu 65536         inet 127.0.0.1  netmask 255.0.0.0         inet6 ::1  prefixlen 128  scopeid 0x10<host>         loop  txqueuelen 0  (Local Loopback)         RX packets 384  bytes 30176 (29.4 KiB)         RX errors 0  dropped 0  overruns 0  frame 0         TX packets 384  bytes 30176 (29.4 KiB)         TX errors 0  dropped 0 overruns 0  carrier 0  collisions 0      The "enp7s1" should be my card (I recognise the MAC), but usually isn't it "eth **X** " ? Also, here is the output for **_lsmod_** command:               Module                  Size  Used by     rfcomm                 51153  4      fuse                   74541  3      raid1                  27772  1      bnep                   11037  2      usblp                  12722  0      bluetooth             308366  10 bnep,rfcomm     rfkill                 15666  3 bluetooth     iTCO_wdt                5407  0      iTCO_vendor_support     1929  1 iTCO_wdt     mxm_wmi                 1467  0      evdev                   9880  5      joydev                  9663  0      hid_generic             1153  0      md_mod                105782  1 raid1     coretemp                6038  0      kvm_intel             128977  0      kvm                   376330  1 kvm_intel     snd_hda_codec_hdmi     29733  1      microcode              13172  0      psmouse                85132  0      serio_raw               5041  0      snd_hda_codec_realtek    35645  1      r8169                  57640  0     lpc_ich                12849  0      mii                     4027  1 r8169     i2c_i801               11237  0      snd_hda_intel          35309  5      snd_hda_codec         147506  3 snd_hda_codec_realtek,snd_hda_codec_hdmi,snd_hda_intel     snd_hwdep               6332  1 snd_hda_codec     snd_pcm                77765  3 snd_hda_codec_hdmi,snd_hda_codec,snd_hda_intel     snd_page_alloc          7202  2 snd_pcm,snd_hda_intel     snd_timer              18718  1 snd_pcm     snd                    58950  17 snd_hda_codec_realtek,snd_hwdep,snd_timer,snd_hda_codec_hdmi,snd_pcm,snd_hda_codec,snd_hda_intel     acpi_cpufreq           10502  0      soundcore               5418  1 snd     mperf                   1203  1 acpi_cpufreq     i7core_edac            17669  0      edac_core              44137  2 i7core_edac     asus_atk0110           12000  0      wmi                     8283  1 mxm_wmi     processor              27755  1 acpi_cpufreq     button                  4669  0      nfs                   145074  0      lockd                  76805  1 nfs     sunrpc                221055  2 nfs,lockd     fscache                44575  1 nfs     ext4                  456475  1      crc16                   1359  2 ext4,bluetooth     mbcache                 5866  1 ext4     jbd2                   81946  1 ext4     hid_logitech_dj        10567  0      usbhid                 41466  0      hid                    88502  3 hid_generic,usbhid,hid_logitech_dj     sr_mod                 14898  0      sd_mod                 30730  4      cdrom                  34848  1 sr_mod     ata_generic             3370  0      pata_acpi               3387  0      crc32c_intel           14185  0      firewire_ohci          31837  0      firewire_core          51955  1 firewire_ohci     ahci                   22792  5      uhci_hcd               24531  0      ehci_pci                4120  0      libahci                21169  1 ahci     crc_itu_t               1363  1 firewire_core     xhci_hcd               89423  0      ehci_hcd               47672  1 ehci_pci     libata                171016  4 ahci,pata_acpi,libahci,ata_generic     usbcore               177151  6 usblp,uhci_hcd,ehci_hcd,ehci_pci,usbhid,xhci_hcd     scsi_mod              127772  3 libata,sd_mod,sr_mod     usb_common              1648  1 usbcore     radeon                807573  2      i2c_algo_bit            5391  1 radeon     drm_kms_helper         35438  1 radeon     ttm                    65324  1 radeon     drm                   231136  4 ttm,drm_kms_helper,radeon     i2c_core               23720  5 drm,i2c_i801,drm_kms_helper,i2c_algo_bit,radeon      I already tried to change the interface from "down" to "up", but it remains down without displaying any errors. I have the kernel 3.10.1-1-MANJARO (linux310) How can I solve this? P.S: Excuse me for my english, of course.


How to install a shared library in Linux

As part of my research work I have to study a rootkit. So I downloaded ncom rootkit and tried installing. It didnt have any installion files. Please help me in installing it.


ranger: open many files with mplayer

I use the file explorer called ranger and I wonder if it is possible to open many files in different directory with mplayer? What I can already do is to select all the files (pressing `v`) from one directory and then press `Enter`. Mplayer is launched and all the files in that directory are played one after the other. But what if I want to play a list of files that are in different directories? EDIT: To be more general, I'd like to know how to run a command that takes files from different directories as arguments.


Byobu with tmux, how to use F-Keys

I'm accessing a linux box with Byobu enabled (with `tmux`) and I don't seem to be able to use some F-Keys without being binded to Byobu. For example using `F6` to sort on `htop`. I followed this advice, but it doesn't seem to work for me. I press `Shift`-`F2` and then `F6` but nothing happens. If it helps, I'm connecting through PuTTY.


I accidentally removed /var/www/ on my Linux server

I ran `rm -drf` on my web server and accidentally removed everything inside `/var/www/`. Of course, it had everything for our website in it. How can I undo this? Or is it possible to restore it to a previous version?


How to make EDID

I read the post here and I tried to make do with what I understood from the post but here are some questions:   1. Where is the `/lib/firmware` located in for example `/usr/src/linux/lib/firmware` or `/usr/lib/firmware` or elsewhere?   2. Could I use a pre-build EDID in that address the post gave and tweak it with an editor like Gvim and pass it to kernel using the info below? The resolution I am trying to set is 1600x900@60:                1: [H PIXELS RND]  :  1600.000000       2: [V LINES RND]  :  450.000000       3: [V FIELD RATE RQD]  :  120.000000       4: [TOP MARGIN (LINES)]  :  8.000000       5: [BOT MARGIN (LINES)]  :  8.000000       6: [INTERLACE]  :  0.500000       7: [H PERIOD EST]  :  16.648841       8: [V SYNC+BP]  :  33.000000       9: [V BACK PORCH]  :  30.000000       10: [TOTAL V LINES]  :  500.500000       11: [V FIELD RATE EST]  :  120.008471       12: [H PERIOD]  :  16.650017       13: [V FIELD RATE]  :  120.000000       14: [V FRAME RATE]  :  60.000000       15: [LEFT MARGIN (PIXELS)]  :  32.000000       16: [RIGHT MARGIN (PIXELS)]  :  32.000000       17: [TOTAL ACTIVE PIXELS]  :  1664.000000       18: [IDEAL DUTY CYCLE]  :  25.004995       19: [H BLANK (PIXELS)]  :  560.000000       20: [TOTAL PIXELS]  :  2224.000000       21: [PIXEL FREQ]  :  133.573440       22: [H FREQ]  :  60.060000       17: [H SYNC (PIXELS)]  :  176.000000       18: [H FRONT PORCH (PIXELS)]  :  104.000000       36: [V ODD FRONT PORCH(LINES)]  :  1.500000 If yes where could I get an `edid.bin` file?   3. Or should I build an EDID file from scratch; if yes how could I make an EDID file?


BC - no "\\n" at the end + start with zeros?

This is a `bc` output, e.g.: Input:               echo "scale=10; BLA-BLA-HERE-NOT-IMPORTANT" | bc      Output:               .3708446283953709207058828124021300754352578903651372655882743141882\     77124645102027246581819139527644919407424570060822470537797066353573\     96635.8038454068 days      Two Questions:   * can the output be rounded to something like "0.3708..."?   * can I remove the "\n"-s from the end? I can't find any max width option in `bc`.


Cinnamon 2.2 How to add custom shortuct: move workspace up

I'm quite aware this must have been asked many times, but I cannot seem to find the right search terms to get an answer. I would like to have `Ctrl`+`Shift`+`Up` move my workspace up, and similarly `Ctrl`+`Shift`+`Down` to move down. Currently when I use these shortcuts cinnamon shows all the available workspaces or goes into expo mode. How do I change this?


Adding priority to the task permanently on Linux machine

How do I increase the priority for a task in Debian Linux system? After a little research I found that I can increase the priority to a task using `nice` command and if I want to increase the priority for an existing task then I can use the `renice` command.   1. In some tutorials its mentioned that, nice values vary from 0 to 99, But in some tutorials states that nice values vary from -20 to 19. Which one is correct?   2. How do I increase the nice value for an GUI task? If I am doing a copy using a terminal then I can increase its priority using `nice` command, but how do I increase the priority of a task done using GUI (for example: copying files from USB to System through GUI)   3. Is it possible to set the priority of a task every time it is run? I want to set highest priority for copying files via the GUI permanently.


ext4, why 70k file takes 88 blocks

[root@xx]# cat -n create_extents.sh           1  #!/bin/bash          2          3  if [ $# -ne 2 ]          4  then          5          echo "$0 [filename] [size in kb]"          6          exit 1          7  fi          8          9  filename=$1         10  size=$2         11  i=0         12         13  while [ $i -lt $size ]         14  do         15          i=`expr $i + 7`         16          echo -n "$i" | dd of=$1 bs=1024 seek=$i         17  done      so I did               sudo ./create_extents.sh  /device3/test70 70      Then, I use debugfs "stat" command to check it, Inode: 13 Type: regular Mode: 0644 Flags: 0x80000               Generation: 2638566511    Version: 0x00000000:00000001     User:     0   Group:     0   Size: 71682     File ACL: 0    Directory ACL: 0     Links: 1   Blockcount: 88     Fragment:  Address: 0    Number: 0    Size: 0      ctime: 0x53292990:042e685c -- Wed Mar 19 01:22:24 2014      atime: 0x5329298f:edd4dc60 -- Wed Mar 19 01:22:23 2014      mtime: 0x53292990:042e685c -- Wed Mar 19 01:22:24 2014     crtime: 0x5329298f:edd4dc60 -- Wed Mar 19 01:22:23 2014     Size of extra inode fields: 28     EXTENTS:     (ETB0):33803, (1):33825, (3):33827, (5):33829, (7-8):33831-33832, (10):33834, (12):33836, (14-15):33838-33839, (17):33841     (END)      Why it takes so many blocks? and the place is so scattered..? My block size is 4k. I know that ext4 tries hard to keep locality for one file. thanks


Bash: interactive remote prompt

I have a script which connects to a remote server and check if some package is installed:               ssh root@server 'bash -s' < myscript.sh      myscript.sh:               OUT=`rpm -qa | grep ntpdate`     if [ "$OUT" != "" ] ; then         echo "ntpdate already installed"     else         yum install $1     fi      This example could be simplified. Here is `myscript2.sh` which has same problem:               read -p "Package is not installed. Do you want to install it (y/n)?" choise      My problem is that bash can not read my answers interactively. Is there a way to execute local script remotely without losing ability to prompt user?


Greyhole permission problems

I'm setting up a homeserver using Greyhole and Samba. _excerpt_ > Greyhole - An application that uses Samba to create a storage pool of all > your available hard drives (whatever their size, however they're connected), > and allows you to create redundant copies of the files you store, in order > to prevent data loss when part of your hardware fails. The harddrive is mounted into `/mnt/hdd0`, `/mnt/hdd0/gh` is added into the pool and `/mnt/hdd0/shares` contains the Samba shares. I'm able to connect to the server and create files and folders. However, after Greyhole created the symlink and copied them into the pool, I can neither edit nor delete files. Windows just throws "Permission denied."   * The symlinks have full permissions and are owned by `root:root`.   * The files, they are referring to, are owned by the user, who created them and have `rwxr--r--` permissions.   * The subfolders of "gh" and "shares" have `rwx.rwx---` This is the `smb.conf`:               [global]        workgroup = WORKGROUP        server string = Samba Server        security = user        encrypt passwords = true        log file = /var/log/samba/%m.log          [TV]        path = /mnt/hdd0/shares/TV        comment = Recorded TV Shows        available = yes        browseable = yes        writeable = yes        dfree command = /usr/bin/greyhole-dfree        vfs objects = greyhole      What do I need to change, to get write-access to the files? And how do I change the group of the created files to i.e. `sambashare` (a group all my samba users are in)? **Edit:** if i stop greyhole and create a new file, i can edit it. I suppose, GH is the problem.


Using the system date / time in a Cron Script

I'm setting up a Cronjob that will backup a MySQL database I have in my server, but I don't want it to keep overwriting the same file over and over again. Instead, I want to have an array of backups to choose from, done automatically. For example:               ## Cronjob, run May 21st, 2011:     mysqldump -u username -ppasword database > /path/to/file/21-03-2011.sql          ## SAME Conjob, run May 28th, 2011:     mysqldump -u username -ppasword database > /path/to/file/28-03-2011.sql      And so on. Is there any way that I can use the system date and/or time as some kind of variable in my Cronjob? If not, what are your suggestions to accomplish the same?


What's the best way to partition your drive?

I usually install Linux on a single partition since I only use it as a personal desktop. However every now and then I reinstall the box and what I simply do is to move my files around with an external hard disk. So, how could I prevent that when reinstalling my box (e.g. switching to another distro)?


What is 'keyring' in Google Chrome

Every time i run Chrome, it ask for the keyring password for Default. If I fill my password in, it disappears and I can continue, and when I press cancel it has the same effect. So, what does the keyring do and what's the difference with unlocking and canceling?


How to set the CPU freq. in Linux?

I'm using this ARM9 SAM9G25 embedded system, that when switched on, is only online for a few seconds and because I want to speed up the whole process, I'd like to check the CPU frequency, and set it to max. speed. The Linux 2.6.39 kernel is generated here with Buildroot 2013.10. When googeling around it in the end always leads to the "CPU frequency _scaling_ " option, but that's not what I'm looking for. I believe there has to be some kind of a statically value for the CPU, so that e.g.: the kernel tells a 1 GHz CPU to operate at max. 100 MHz. Can anyone point me in the right direction? Thanks for the support.


dark image in Skype but without a problem in other apps

I've just moved to Linux Family. I installed Elementary OS 64bit (based on Ubuntu). I try to configure my Skype, but the video image is really dark. It is working, but it is low in contrast. I've downloaded Cheese and the image there is great. I've download Guvcview and the image there is great as well. But, when I run the guvcview, I have a lot of errors in terminal. The weird is that when I have guvcview opened with the great image and open the preview of Skype camera, then then image of the first one gets darker too.               guvcview 1.5.3          (guvcview:19393): Gtk-WARNING **: Theme parsing error: gtk-widgets.css:756:1: Expected semicolon          (guvcview:19393): Gtk-WARNING **: Theme parsing error: gtk-widgets.css:776:0: Expected a valid selector          (guvcview:19393): Gtk-WARNING **: Theme parsing error: button.css:150:14: Not using units is deprecated. Assuming 'px'.          (guvcview:19393): Gtk-WARNING **: Theme parsing error: button.css:150:14: Junk at end of value          (guvcview:19393): Gtk-WARNING **: Theme parsing error: granite-widgets.css:144:14: Not using units is deprecated. Assuming 'px'.          (guvcview:19393): Gtk-WARNING **: Theme parsing error: granite-widgets.css:144:16: Not using units is deprecated. Assuming 'px'.          (guvcview:19393): Gtk-WARNING **: Theme parsing error: granite-widgets.css:144:22: Not using units is deprecated. Assuming 'px'.          (guvcview:19393): Gtk-WARNING **: Theme parsing error: toolbar.css:110:13: Not using units is deprecated. Assuming 'px'.          (guvcview:19393): Gtk-WARNING **: Theme parsing error: toolbar.css:110:13: Junk at end of value     ALSA lib pcm.c:2217:(snd_pcm_open_noupdate) Unknown PCM cards.pcm.rear     ALSA lib pcm.c:2217:(snd_pcm_open_noupdate) Unknown PCM cards.pcm.center_lfe     ALSA lib pcm.c:2217:(snd_pcm_open_noupdate) Unknown PCM cards.pcm.side     ALSA lib audio/pcm_bluetooth.c:1614:(audioservice_expect) BT_GET_CAPABILITIES failed : Input/output error(5)     ALSA lib audio/pcm_bluetooth.c:1614:(audioservice_expect) BT_GET_CAPABILITIES failed : Input/output error(5)     ALSA lib audio/pcm_bluetooth.c:1614:(audioservice_expect) BT_GET_CAPABILITIES failed : Input/output error(5)     ALSA lib audio/pcm_bluetooth.c:1614:(audioservice_expect) BT_GET_CAPABILITIES failed : Input/output error(5)     ALSA lib pcm_dmix.c:957:(snd_pcm_dmix_open) The dmix plugin supports only playback stream     Cannot connect to server socket err = No such file or directory     Cannot connect to server socket     jack server is not running or cannot be started     video device: /dev/video0      Init. TOSHIBA Web Camera - HD (location: usb-0000:00:1a.0-1.3)     { pixelformat = 'YUYV', description = 'YUV 4:2:2 (YUYV)' }     { discrete: width = 640, height = 480 }         Time interval between frame: 1/30, 1/25, 1/20, 1/15, 1/10, 1/5,      { discrete: width = 320, height = 240 }         Time interval between frame: 1/30, 1/25, 1/20, 1/15, 1/10, 1/5,      { discrete: width = 176, height = 144 }         Time interval between frame: 1/30, 1/25, 1/20, 1/15, 1/10, 1/5,      { discrete: width = 160, height = 120 }         Time interval between frame: 1/30, 1/25, 1/20, 1/15, 1/10, 1/5,      { discrete: width = 352, height = 288 }         Time interval between frame: 1/30, 1/25, 1/20, 1/15, 1/10, 1/5,      { discrete: width = 1280, height = 720 }         Time interval between frame: 1/10, 1/5,      { discrete: width = 1280, height = 800 }         Time interval between frame: 1/10, 1/5,      { pixelformat = 'MJPG', description = 'MJPEG' }     { discrete: width = 640, height = 480 }         Time interval between frame: 1/30, 1/25, 1/20, 1/15, 1/10, 1/5,      { discrete: width = 320, height = 240 }         Time interval between frame: 1/30, 1/25, 1/20, 1/15, 1/10, 1/5,      { discrete: width = 176, height = 144 }         Time interval between frame: 1/30, 1/25, 1/20, 1/15, 1/10, 1/5,      { discrete: width = 160, height = 120 }         Time interval between frame: 1/30, 1/25, 1/20, 1/15, 1/10, 1/5,      { discrete: width = 352, height = 288 }         Time interval between frame: 1/30, 1/25, 1/20, 1/15, 1/10, 1/5,      { discrete: width = 1280, height = 720 }         Time interval between frame: 1/30, 1/25, 1/20, 1/15, 1/10, 1/5,      { discrete: width = 1280, height = 800 }         Time interval between frame: 1/30, 1/25, 1/20, 1/15, 1/10, 1/5,      { pixelformat = 'RGB3', description = 'RGB3' }     { discrete: width = 640, height = 480 }         Time interval between frame: 1/30, 1/25, 1/20, 1/15, 1/10, 1/5,      { discrete: width = 320, height = 240 }         Time interval between frame: 1/30, 1/25, 1/20, 1/15, 1/10, 1/5,      { discrete: width = 176, height = 144 }         Time interval between frame: 1/30, 1/25, 1/20, 1/15, 1/10, 1/5,      { discrete: width = 160, height = 120 }         Time interval between frame: 1/30, 1/25, 1/20, 1/15, 1/10, 1/5,      { discrete: width = 352, height = 288 }         Time interval between frame: 1/30, 1/25, 1/20, 1/15, 1/10, 1/5,      { discrete: width = 1280, height = 720 }         Time interval between frame: 1/30, 1/25, 1/20, 1/15, 1/10, 1/5,      { discrete: width = 1280, height = 800 }         Time interval between frame: 1/30, 1/25, 1/20, 1/15, 1/10, 1/5,      { pixelformat = 'BGR3', description = 'BGR3' }     { discrete: width = 640, height = 480 }         Time interval between frame: 1/30, 1/25, 1/20, 1/15, 1/10, 1/5,      { discrete: width = 320, height = 240 }         Time interval between frame: 1/30, 1/25, 1/20, 1/15, 1/10, 1/5,      { discrete: width = 176, height = 144 }         Time interval between frame: 1/30, 1/25, 1/20, 1/15, 1/10, 1/5,      { discrete: width = 160, height = 120 }         Time interval between frame: 1/30, 1/25, 1/20, 1/15, 1/10, 1/5,      { discrete: width = 352, height = 288 }         Time interval between frame: 1/30, 1/25, 1/20, 1/15, 1/10, 1/5,      { discrete: width = 1280, height = 720 }         Time interval between frame: 1/30, 1/25, 1/20, 1/15, 1/10, 1/5,      { discrete: width = 1280, height = 800 }         Time interval between frame: 1/30, 1/25, 1/20, 1/15, 1/10, 1/5,      { pixelformat = 'YU12', description = 'YU12' }     { discrete: width = 640, height = 480 }         Time interval between frame: 1/30, 1/25, 1/20, 1/15, 1/10, 1/5,      { discrete: width = 320, height = 240 }         Time interval between frame: 1/30, 1/25, 1/20, 1/15, 1/10, 1/5,      { discrete: width = 176, height = 144 }         Time interval between frame: 1/30, 1/25, 1/20, 1/15, 1/10, 1/5,      { discrete: width = 160, height = 120 }         Time interval between frame: 1/30, 1/25, 1/20, 1/15, 1/10, 1/5,      { discrete: width = 352, height = 288 }         Time interval between frame: 1/30, 1/25, 1/20, 1/15, 1/10, 1/5,      { discrete: width = 1280, height = 720 }         Time interval between frame: 1/30, 1/25, 1/20, 1/15, 1/10, 1/5,      { discrete: width = 1280, height = 800 }         Time interval between frame: 1/30, 1/25, 1/20, 1/15, 1/10, 1/5,      { pixelformat = 'YV12', description = 'YV12' }     { discrete: width = 640, height = 480 }         Time interval between frame: 1/30, 1/25, 1/20, 1/15, 1/10, 1/5,      { discrete: width = 320, height = 240 }         Time interval between frame: 1/30, 1/25, 1/20, 1/15, 1/10, 1/5,      { discrete: width = 176, height = 144 }         Time interval between frame: 1/30, 1/25, 1/20, 1/15, 1/10, 1/5,      { discrete: width = 160, height = 120 }         Time interval between frame: 1/30, 1/25, 1/20, 1/15, 1/10, 1/5,      { discrete: width = 352, height = 288 }         Time interval between frame: 1/30, 1/25, 1/20, 1/15, 1/10, 1/5,      { discrete: width = 1280, height = 720 }         Time interval between frame: 1/30, 1/25, 1/20, 1/15, 1/10, 1/5,      { discrete: width = 1280, height = 800 }         Time interval between frame: 1/30, 1/25, 1/20, 1/15, 1/10, 1/5,      vid:04ca      pid:7012      driver:uvcvideo     checking format: 1196444237     VIDIOC_G_COMP:: Inappropriate ioctl for device     fps is set to 1/25     drawing controls          no codec detected for H264     no codec detected for MP3 - (lavc)     Checking video mode 640x480@32bpp : OK


simple hostname resolution on LAN

I read this question How to make a machine accessible from the LAN using its hostname What is the simplest way to enable a LAN of Linux hosts to identify each other by hostname? Obviously each host will still require an IP address, but how do you make sure hosts can recognize eachother by hostname? Is this possible without nmap, setting up a DHCP server, or installing `avahi`?


How can I resolve local IPs to hostnames?

> **Possible Duplicate:**   >  How to make a machine accessible from the LAN using its hostname I have is a simple home network with a few machines connecting through DHCP. If everyone and their respective devices are all home and active I'll have about 15 active IPs. I would like to be able to identify hosts on the network by name. I am not interested in solutions involving static IPs or permanent DHCP leases. Ideally, it should be transparent to the user and any new machine connected to my LAN should be able to access any other by name. It should be cross-platform. My LAN has Linux, OSX, iOS and the occasional windows machine. I'm not too bothered if it doesn't work in windows but I'd like to have it in the rest at least. I realise I can set up a local DNS server but I'm hoping there is a simpler solution that I am not aware of (avahi? NIS?). So, is a local DNS server the best way to go about this?


How to read NTFS drives in Linux (RHEL 6)?

My system is on dual boot. I have installed both RHEL 6 and win7 in it. I use RHEL mostly and I want to use my windows' NTFS drive in RHEL. How can I do it? Tell me the procedure. ![enter image description here](http://i.stack.imgur.com/cTRv8.png)


Linux LXC vs FreeBSD jail

Are there any notable differences between LXC (Linux containers) and FreeBSD's jails in terms of security, stability & performance? On first look, both approaches look very similar.


recursively copy only images and preserve path

I'm working on a website migration. I have a scrape of the site, with all the files and directory structure as you would see them in the URL. I want to pull all images, maintaining the directory structure, and copy them into a new place. For instance, if I have               /content1/index.php     /content1/page2.php     /content1/images/image1.jpg     /content1/images/image2.jpg     /content1/background/spacer.gif     /content1/background/background.gif     /content2/index.php     /content2/images/image3.jpg     /content2/background/spacer.gif     /content2/background/background.gif      Then I want               /content1/images/image1.jpg     /content1/images/image2.jpg     /content1/background/spacer.gif     /content1/background/background.gif     /content2/images/image3.jpg     /content2/background/spacer.gif     /content2/background/background.gif      I can use the `find` command to get a list of only image files, but I don't know how to manipulate each file while preserving the directory path to it. I could make a copy of the entire directory, and then recursively delete any non-image file, but now that I have set this problem before myself, I figure its worthwhile to know how to do it, in case I really do need to do it this way later.


Extract multiple .tar.gz files with a single tar call

I was wondering whether (and, of course, how) it’s possible to tell `tar` to extract multiple files in a single run. I’m an experienced Unix user for several years and of course I know that you can use `for` or `find` or things like that to call `tar` once for each archive you want to extract, but I couldn’t come up with a working command line that caused my `tar` to extract two .tar.gz files at once. (And no, there’s nothing wrong with `for`, I’m merely asking whether it’s possible to do without.) I’m asking this question rather out of curiosity, maybe   * there’s a strange fork of `tar` somewhere that supports this   * someone knows how to use the `-M` parameter that `tar` suggested to me when I tried `tar -zxv -f a.tgz -f b.tgz`   * we’re all blind and it’s totally easy to do — but I couldn’t find any hint in the web that didn’t utilize `for` or `find` or `xargs` or the like. Please don’t reply with `tar -zxvf *.tar.gz` (because that does **not** work) and only reply with “doesn’t work” if you’re absolutely sure about it (and maybe have a good explanation _why_ , too). **Edit:** I was pointed to an answer to this question on Stack Overflow which says in great detail that it’s not possible without breaking current `tar` syntax, but I don’t think that’s true. Using `tar -zxv -f a.tgz -f b.tgz` or `tar -zxv --all-args-are-archives *.tar.gz` would break no existing syntax, imho.


How to tell if a file is being downloaded by wget?

I use `wget` to download files (most are zip files) automatically for me during the night. However, sometimes in the morning I find that a few files cannot be unzipped. I don't know why this is happening, perhaps it's something wrong with the remote server. I want to write a script to test zip files in my download folder periodically using 'unzip -t', but I don't want to test on the files that are being downloaded. So how can I tell if a file is being used by `wget`?


Grant permissions using rysnc

I want to use `rsync` (as a user) from "me" on a local computer to "another" user on a distant computer. However, I also want "another" user (on the distant computer) to own the files and to be able to use them exactly as "me" (on the local computer). I believe I shall play with the options: `-p` (preserve permissions), `-g` (preserve groups) and `-o` (preserve ownership), but I'm not sure of the exact effect of those. Which one(s) shall I impose ?


Tips for making software updates automatic in OpenSuse (zypper)

I'm currently working in a command line only environment. I would like to perform daily updates automatically using `zypper`, however I can't find a good way to do it. By good I mean clean and simple. Is it safe to execute `sudo zypper update` daily using cron? I was told that this isn't always a good way to do it. Are there other ways I could make package updates through zypper completely automatic?


Why is root in wheel and operator? Can root being in a group ever make a difference?

I just noticed on my FreeBSD machine that root is in wheel and operator. I'm trying to think of a situation where UID 0 being in a group would have any effect on... well... anything, and I'm coming up blank. For that matter, does root even need a primary login group in /etc/passwd? Or does login(3) choke and die if the user has a blank primary group field? (To clarify: I understand the purpose of the "root" group's existence, since files need a group owner. I'm not understanding how it matters that the user root/toor/whatever has that group membership.) Is this just cruft from decades ago, or is there a real reason for it?


losing unicode support urxvt when logged in as user, root shell has them

I am on a minimal debian testing install. I've set up `rxvt-unicode`, `herbstluftwm`, and `SLiM`. With my username, after SLiM logs me in, all of the `urxvt` terminal instances i start lack unicode support. If I do `sudo urxvt`, then the new urxvt instance shows unicode characters in the terminal (as root). This is a new install in a vm. Before I set up SLiM, I had unicode support as a user. at some point afterwards, I no longer saw the characters. Can anyone please assist? This issue seems **very** similar to this question, but I wasnt able to see any similar actions I could take. * * * relevant configs: ### SLiM               default_path        /usr/local/bin:/usr/bin:/bin:/usr/local/games:/usr/games     default_xserver     /usr/bin/X11/X     xserver_arguments   -nolisten tcp         halt_cmd            /sbin/shutdown -h now     reboot_cmd          /sbin/shutdown -r now     console_cmd         /usr/bin/xterm-C -fg white -bg black +sb -T "Console login" -e /bin/sh -c "/bin/cat /etc/issue.net; exec /bin/login"         xauth_path         /usr/bin/X11/xauth         authfile           /var/run/slim.auth     numlock             on         # hidecursor          false            login_cmd           exec /bin/bash -login ~/.xinitrc %session     # login_cmd           exec /bin/bash -login /etc/X11/Xsession %session            # sessionstart_cmd  some command     # sessionstop_cmd   some command             # daemon    yes            sessiondir            /usr/share/xsessions/         screenshot_cmd      scrot ~/img/slim.png             welcome_msg         Welcome to %host             # session_msg         Session:              shutdown_msg       The system is halting...     reboot_msg         The system is rebooting...             default_user       seldon              focus_password      yes             auto_login          yes         current_theme       debian-joy         lockfile            /var/run/slim.lock     logfile             /var/log/slim.log      ### User env               SHELL=/bin/bash     TERM=rxvt-unicode-256color     XDG_SESSION_COOKIE=f71ffba1619e7393bb13421e5323c9ee-1394949532.816048-1558277790     WINDOWID=23068679     USER=seldon     MAIL=/var/mail/seldon     PATH=/home/seldon/bin:/usr/local/bin:/usr/bin:           /bin:/usr/local/games:/usr/games:/home/seldon/bin     PWD=/home/seldon     LANG=en_US.utf8     COLORFGBG=default;default     SHLVL=1     HOME=/home/seldon     LS_OPTIONS=--color=auto --group-directories-first     LOGNAME=seldon     DISPLAY=:0.0     COLORTERM=urxvt     XAUTHORITY=/home/seldon/.Xauthority     _=/usr/bin/env      ### Root env               SHELL=/bin/bash     TERM=rxvt-unicode-256color     WINDOWID=20971527     USER=root     SUDO_USER=seldon     SUDO_UID=1000     USERNAME=root     MAIL=/var/mail/root     PATH=/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/root/bin     PWD=/home/seldon     LANG=en_US.utf8     SHLVL=1     COLORFGBG=default;default     SUDO_COMMAND=/usr/bin/rxvt     HOME=/root     LS_OPTIONS=--color=auto --group-directories-first     LOGNAME=root     SUDO_GID=1000     DISPLAY=:0.0     COLORTERM=urxvt     XAUTHORITY=/home/seldon/.Xauthority     _=/usr/bin/env      ### Xresources               !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!     !! Terminal Colors     !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!          ! ... removed for brevity ...                    !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!     !! URxvt Config      !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!          ! buffer     URxvt*saveLines: 12000          ! fonts     URxvt*font: xft:DejaVu Sans Mono:pixelsize=12:antialias=true:hinting=true     URxvt*boldFont: xft:DejaVu Sans Mono:bold:pixelsize=12:antialias=true:hinting=true          ! URxvt*font: xft:Bitstream Vera Sans Mono:pixelsize=12:antialias=true:hinting=true     ! URxvt*boldFont: xft:Bitstream Vera Sans Mono:bold:pixelsize=12:antialias=true:hinting=true               ! transparency     ! URxvt*transparent: true     ! URxvt*shading: 25          URxvt*depth: 32     URxvt.background: [75]#000000          ! scrollbars     !    active - true (default) or false     URxvt*scrollBar: false          !    position - left=false (default) or right=true     URxvt*scrollBar_right: false          !    style - rxvt (default), plain, next, or xterm     URxvt*scrollstyle: rxvt          ! borders     URxvt*borderless: true      ### xinitrc               #!/bin/bash          xrandr -s 8         hsetroot -fill /home/seldon/img/olCTXdz.jpg &              function wm() {             xrdb -load ~/.Xresources &             compton -cb -o0             exec $1 -c /home/seldon/.config/herbstluftwm/autostart         }          [[ -z $1 ]] && wm herbstluftwm          wm $1


debhelper and fun question about dh_make

I create an distro about 6 years ago, i recall i used `dh_make command`, i have a suggesstion for creating distro recently, When i use :               root@debian:/home/mohsen# dpkg -L debhelper |egrep dh_make     /usr/bin/dh_makeshlibs     /usr/share/man/man1/dh_makeshlibs.1.gz     /usr/share/man/es/man1/dh_makeshlibs.1.gz     /usr/share/man/fr/man1/dh_makeshlibs.1.gz     /usr/share/man/de/man1/dh_makeshlibs.1.gz      I'm confused.Why `dh_make` doesn't exist? I decide to use `debian installer` ,`debhelper` and `deboostrap`, But i don't know dh_make has been eliminated?


Is LXLE more resource-intensive than Lubuntu?

I'm using Lubuntu on an Acer Aspire One. It works well, and I'm happy with it. Recently, however, I came across the Lubuntu-derived LXLE distribution and it looks interesting. But I'm wondering whether all the added eye candy, etc. makes the distribution use more memory and/or slows down (other) applications.


How can I force bash to deallocate a brace expanded variable without name?

For benchmarking, I ran the command:               for i in {1..100000000}; do        echo "$i" line >> file     done      Bash expanded the braces and stored the list `1 2 3 4 5 6 ... 100000000` in memory. I thought this will somehow deallocated at a point. After all, it's a temporary variable. A couple of days have since passed and the `bash` process is still occupying 17.9GB of memory. Can I force bash to clear these temporary variables? I cannot use `unset`, because I don't know the variable name. (obviously `unset i` doesn't help) Of course, a solution is to close the shell and open a new one.


Is it possible to rename Thunar's side pane default items?

![enter image description here](http://i.stack.imgur.com/upaBD.png) I would like to display a different name of these items - that would indicate for example that one is windows partition, other ubuntu, etc. Is it feasible?


Linux can't read and write, but windows can

I have a hard drive with a lot of back up files, that were created by PhotoRec. When mounting it with a windows computer I can read all the files perfectly fine. Under linux I get an error when trying to look at the folder that contains all my backups. The rest of the hard drive is perfectly readable but when I try to ls the backup folder I get `ls: reading directory .: Input/output error` In Dolphin I just see a blank directory. I have tried letting arch auto mount and I have tried manually mounting it with `-t ntfs-3g` option (only flag used). A strange thing I notice is that if I manually mount it with the 3g option then all permissions are `-rwxrwxrwx` but if I let it be automatically mounted I have permissions `-rw------- 1 steven steven` (some have 2, but not many. The directories show `d` as they should). These are the same for every file and directory on the system. I don't understand why I can't see these files under Linux, but can under Windows. I even booted up SystemRescueCD again to see if it recognized it, but it couldn't even see the files (even though it was what had originally written the files in the first place). What is so weird to me is that I can read everything on the hard drive except that one folder. It has the exact same permissions as everything else in the hard drive. Additional info: This is a fresh install of Arch. As of today. `[steven@serenity ~]$ uname -a Linux serenity 3.16.1-1-ARCH #1 SMP PREEMPT Thu Aug 14 07:40:19 CEST 2014 x86_64 GNU/Linux` (auto mounted)               [steven@serenity ~]$ sudo fdisk -l          Disk /dev/sdb: 596.2 GiB, 640135028736 bytes, 1250263728 sectors     Units: sectors of 1 * 512 = 512 bytes     Sector size (logical/physical): 512 bytes / 512 bytes     I/O size (minimum/optimal): 512 bytes / 512 bytes     Disklabel type: dos     Disk identifier: 0x1549f232          Device     Boot Start        End    Sectors   Size Id Type     /dev/sdb1  *       63 1250258159 1250258097 596.2G  7 HPFS/NTFS/exFAT


complete KVM / libvirt breakdown after OS upgrade (openSUSE)

I have upgraded two E-350 systems which have been running VMs (one of the systems only Linux VMs, the other one Windows VMs) to openSUSE 13.1 (i.e kernel 3.11.10, kvm-1.6.0, libvirt-1.1.2). After a few seconds the VMs crash, in different ways:   1. (The already installed Linux and Windows VMs) Linux is doing magic, not in the positive sense though. I am not kidding: I have a **zombie** process which consumes a whole CPU core (at least according to `top`):              3673 3 qemu 20 0 0 0 0 Z 100,1 0,000 2:07.08 [qemu-system-x86] <defunct>      I need `kill -9` to get rid of it.   2. (The Linux / Windows DVD) The systems boots for a few seconds and then just stops. The `qemu` process is still around but it has less than 50 MiB resident memory and 0% CPU usage - but is shown as alive yet. Attaching with `strace` shows:              futex(0x7f433536fac0, FUTEX_WAIT_PRIVATE, 2, NULL      This happens both directly after the upgrade to openSUSE 13.1 and after installing the patches. I have disabled AppArmor but that influenced the crash by a few seconds only.


What's a safe and portable way to split a string in shell programming?

When writing a shell script, I often want to split a string. Here's a very simple example:               for dir in $(echo $PATH | tr : " "); do         [[ -x "$dir"/"$1" ]] && echo $dir     done      This will search each directory in the $PATH for an executable with the same name as `$1`. Pretty straightforward, it runs well, but breaks if a directory in my $PATH contains a whitespace in its name. **What's the recommended way to split a string at the occurrence of a recurrent separator?** Ideally, the solution would be able to run on (fairly) old shells, namely ksh88.


History command in ksh not able to use

I am using the ksh shell. I am not getting any impact of these following commands. It is executing without any error but it is not giving the proper results.               export HISTTIMEFORMAT='%F %T '      Use the `Up` arrow to view the previous command and press enter to execute it. Type `!!` and press `Enter` from the command line. Type `!-1` and press `Enter` from the command line. Press `Control`+`P` will display the previous command, press `Enter` to execute it. Basically I am not to do anything other than basic history command.


How can I quickly return back to the last working directory?

All too often I find myself cycling between two directories to perform different tasks. The directories don't always have an easy-to-use relative path between them. As a result it is quite cumbersome to have to specify a directory path that is essentially the previous working directory. Is there a command by which I can easily return back to the previous working directory?


Wireless interface only reachable when ethernet cable plugged in

I'm facing a problem that's about to drive me crazy. I'm running a Debian Linux distribution and currently trying to establish a connection to my wireless network (WPA2 security, wpa_supplicant already installed). The wireless dongle connects to the network, but it only responds to pings and lets me connect through SSH from another computer when the ethernet cable is plugged in. It is still reachable via wireless connection after unplugging the ethernet connection, but it won't work until a connection to a wired network had been created. I'm not sure if anything's wrong with my configuration here... Output of 'ifconfig wlan0':               wlan0     IEEE 802.11bgn  ESSID:"*censored*"  Nickname:"<WIFI@REALTEK>"               Mode:Managed  Frequency:2.457 GHz  Access Point: *censored*                 Bit Rate:72.2 Mb/s   Sensitivity:0/0                 Retry:off   RTS thr:off   Fragment thr:off               Encryption key:****-****-****-****-****-****-****-****   Security mode:open               Power Management:off               Link Quality=89/100  Signal level=58/100  Noise level=0/100               Rx invalid nwid:0  Rx invalid crypt:0  Rx invalid frag:0               Tx excessive retries:0  Invalid misc:0   Missed beacon:0      Contents of /etc/network/interfaces               auto lo     iface lo inet loopback          allow-hotplug eth0     iface eth0 inet static         address 192.168.178.130         netmask 255.255.255.0          allow-hotplug wlan0     iface wlan0 inet static         wpa-ssid "*censored*"         wpa-key-mgmt WPA-PSK         wpa-group TKIP CCMP         wpa-psk *censored*         address 192.168.178.131         netmask 255.255.255.0         gateway 192.168.178.1


How will GUI applications behave if there is no system tray?

Currently I'm running Openbox and I have no need for a pane. However, I know that some applications, like network managers etc, like to place themselves in the system tray - either by default or when minimized. What would happen if something would try to minimize itself to a nonexistent tray?


Apt-get, no sudoers file

I am trying to install a module using apt-get. I do the following:   sudo apt-get install      But I get the following error:   sudo: can't stat /etc/sudoers: No such file or directory   sudo: no valid sudoers sources found, quitting      I have been trying to google the answer but can't find any solution to the problem. How can I solve this?


Simulating GNU Screen's shelltitle in tmux

I'm trying to simulate GNU Screen's `shelltitle` feature in tmux. I have the following in my `~/.bashrc`:               if [[ "$TERM" == screen* ]]; then         SCREEN_ESC='\[\ek\e\\\]'     else         SCREEN_ESC=''     fi          PS1="\n\w ${SCREEN_ESC}$ "      and the following in my `~/.screenrc`:               shelltitle        "$ |bash"      Setting `shelltitle` makes GNU Screen search for a newline in the shell and strip away all the characters from `$PS1` upto the escape character, and replace it with the first word found after that. This is more clearly explained in the man page: > Here's how it works: you must modify your shell prompt to output a null > title-escape-sequence (<esc>k<esc>) as a part of your prompt. The last part > of your prompt must be the same as the string you specified for the search > portion of the title. Once this is set up, screen will use the title-escape- > sequence to clear the previous command name and get ready for the next > command. Then, when a newline is received from the shell, a search is made > for the end of the prompt. If found, it will grab the first word after the > matched string and use it as the command name. If the command name begins > with either '!', '%', or '^' screen will use the first word on the following > line (if found) in preference to the just- found name. This is different from tmux's `set-option -g set-titles on` which only captures the process name. So a Python script `script.py` would be titled as `script.py` in Screen (which is the way I want it) whereas, it would be titled as `python` in tmux (which I don't want.) I know that one can rename tmux windows by:               printf '\033kWINDOW_NAME\033\\'      So I was wondering if there is some way I can alternatively let tmux know that I've entered a new command. If there is some way I can get the last command entered, I could use Bash's `PROMPT_COMMAND` to do this. Any ideas?


Realtek RTL8188CE don't appear while installing Linux Mint

When I logged in to the installer, I found that my wireless wasn't working. This is strange because in every other Linux Mint installation I've done, wireless cards are recognized automatically, I continued the installation until the end using ethernet, when I logged in, I couldn't turn on Wi-Fi. So I went to the magical google.ca and found the command `inxi -n` which returned this:                Network:        Card-1: Realtek RTL8101E/RTL8102E PCI Express Fast Ethernet controller driver: r8169                 IF: eth0 state: up speed: 100 Mbps duplex: full mac: e8:40:f2:f0:65:57          Card-2: Realtek RTL8188CE 802.11b/g/n WiFi Adapter driver: rtl8192ce                 IF: wlan0 state: down mac: 74:e5:43:3b:c2:38      The important bit being the second part, where it says state: down I looked around a bit more and found a script, which when ran, this caught my eye:                0: phy0: Wireless LAN         Soft blocked: no          Hard blocked: yes


sudo hangs indefinitely without prompting for password

When I logged back into my Ubuntu desktop after an update, my display driver was seemingly unavailable and I was met with vt-7's output. I changed to a different terminal and logged in. However, when I attempted to use sudo to install a display driver, sudo hung forever. No prompt for a password, Ctrl+c Ctrl+d Ctrl+z all didn't do anything. It ate my virtual terminal. I changed to another one and the same thing happened. What's happening? ## Update ### /etc/pam.d/sudo               #%PAM-1.0     auth required pam_env.so readenv=1 user_readenv=0     auth required pam_env.so readenv=1 envfile=/etc/default/locale user_readenv=0     @include common-auth     @include common-account     @include common-session-noninteractive      Other commands such as ifconfig also seem to hang. ## Update 2 I think that this breakage has to do with the fact that Ubuntu tried to upgrade a kernel with an earlier verison. I was running kernel 3.7.1 which I downloaded and installed manually, and Ubuntu did a dist-upgrade which "upgraded" the kernel to 3.2.X. I have a feeling that this messed things up substantially. I'm going to try reinstalling the kernel and see if I can undo some of the fallout. Note to self: always disable Ubuntu kernel updates when running a later kernel.


how to disable USB devices based on vendor id in Linux environment?

I want to disable usb devices based on vendor id in Linux environment. I want to allow only specific USB devices, based on vendor id.


Problems with basename in a loop

I am new at shell script programming and I'm trying to execute a software that reads a text and perform it's POS tagging. It requires an input and an output, as can be seen in the execute example:               $ cat input.txt | /path/to/tagger/run-Tagger.sh > output.txt      What I'm trying to do is to execute this line not only for a text, but a set of texts in an specific folder, and return the output files with the same name as the input files. So, I tried to do this script:               #!/bin/bash     path="/home/rafaeldaddio/Documents/"     program="/home/rafaeldaddio/Documents/LX-Tagger/POSTagger/Tagger/run-Tagger.sh"          for arqin in '/home/rafaeldaddio/Documents/teste/*'     do     out=$(basename $arqin)     output=$path$out     cat $arqin | $program > $output     done      I tried it with only one file and it works, but when I try with more than one, I get this error:               basename: extra operand ‘/home/rafaeldaddio/Documents/teste/3’     Try 'basename --help' for more information.          ./scriptLXTagger.sh: 12: ./scriptLXTagger.sh: cannot create /home/rafaeldaddio/Documents/: Is a directory      Any insights on what I'm doing wrong? Thanks.


Clickable PDFs in rxvt

I would like to open PDFs (say, with `evince`) by clicking in the terminal. The setup is `urxvt` in Fedora 19 here, but if `urxvt` cannot do this, can you let me know which terminal emulators can. I got URL detection working by putting:               urxvt*perl-lib: /usr/libi64/urxvt/perl/     urxvt*perl-ext-common: default,matcher     urxvt*matcher.button: 1     urxvt*url-launcher: /usr/bin/xdg-open      Into my `~/.Xdefaults` and running `xrdb -load ~/.Xdefaults`, so hopefully there is some similar solution for the problem at hand.


How to get RPM's that has been published after the install DVD?

So if I download a:               SL-63-x86_64-2012-08-02-Install-DVD.iso      and install it, and give out a "yum update" - then it will find many-many XY packages to update. **Q:** are there any methods/solutions to get these XY rpm's? (and then I can put them in the: "/var/cache/yum/x86_64/6.3/" - because internet connection is not too fast.)


HTTP Downloader that supports directory index? So that I could use globbing?

Is there an `http` downloader that supports `globbing`? i.e. I would like to fetch the latest update of a package, `abc-XXX.rpm`, but the `XXX` (version number) is unknown to me. Is it possible to do a `globbing` on directory index of the remote server?


How can I create a virtual ethernet interface on a machine without a physical adapter?

I have a Dell XPS 13 ultrabook which has a wifi nic, but no physical ethernet nic (wlan0, but no eth0). I need to create a virtual adapter for using Vagrant with NFS, but am finding that the typical `ifup eth0:1...` fails with `ignoring unknown interface eth0:1=eth0:1`. I also tried creating a virtual interface against `wlan0`, but received the same result. How can I create a virtual interface on this machine with no physical interface?


Header about MIME email

Morning, can some body help me about MIME email? I want to send HTML email like this:               MIME-Version: 1.0     Content-type: multipart/alternative; boundary=lazuardi     --lazuardi      After that email. I have html email.               Content-type: text/html; charset=UTF-8     <html>     <body>     ......     This is HTML message     </body>     </html>     --lazuardi      Then i also include plain text               Content-type: text/plain     this is plain text message     --lazuardi--      My question is, am I wrong that I include header in my body.html? Where should I put the header? I using Mutt email client, everytime I send the email, mutt always give me this message: No boundary parameter found! [report this error]... Could not send the message. Can somebody help me to solve this?


How to do command-line completion with files and folders

As a new Linux user, one of the things that's kept me away from the Command Line (CL) is that, for tasks involving files and folders (i.e. everything!), the amount of typing involved makes using the CL inefficient. I myself have a tendency to use detailed file names. For example, if I have a book called "Elementary Differential Equations and Boundary Value Problems", which is in its 9th edition and is written by William Boyce and Richard DiPrima, then I'll name it like: `elementary_differentail_equations_and_boundary_value_problems_9ed_boyce_diprima.pdf`. So in my effort for learning to use the CL I've look around for ways to overcome this problem and found about _Command-line completion_ with the `Tab` key. The thing with this is that it does word completion but only for commands, not for files and folders. I would like to know if there is a similar feature that works for files?


My SMDK2416 (for s3c2416) kernel works on 64MRAM but crashed on 128M

I'm currently working on embedded arm linux with smdk2416(s3c2416) The kernel is working on the 64MRAM. Recently, I need to increase the RAM from 64M to 128MB with 64MB on bank0 and 64MB on bank1.               bank0's physical address is at 0x30000000       bank1's physical address is at 0x38000000        I have successfully mapped bank0 from 0x30000000 to 0xc0000000, and bank1 from 0x38000000 to 0xc4000000 in U-Boot. I have tried a memory test on these addresses (both banks' physical and virtual addr) under U-Boot. When I'm booting the linux kernel with bootarg memory tag `mem=128M`, and run a simple program which use memory beyond 64MB. Then the system crashed with the "kernel NULL pointer dereference" message. I found there is a `CONFIG_DISCONTIGMEM` defined in `src/include/asm- arm/memory.h`, but when I look into "Kernel Features/Memory model" in `make menuconfig`, there is only "Flat Memory" option. How and where should I modify the config/code to make the Linux kernel works on the full 128MB?


In Vim, how can I automatically determine whether to use spaces or tabs for indentation?

Sometimes I edit others source code where the prevailing style is to use tabs. In this case, I want to keep the existing convention of using literal tabs. For files I create myself, and files that use spaces as the prevailing indent style, I wish to use that instead. How can I do this in vim?


If a file tells the OS its file format, how does the OS choose which application to open it by default? In Windows, is the association stored in the registry table? How does Linux choose which application to open a file? I used to use Nautilus a lot, but now I change to terminal. Is it true that in terminal, we always have to explicitly specify which application to open a file? Does the settings of which application to open a file of a certain format by default belong to the file manager (e.g. Nautilus), and it is not an issue when we are living in terminals?


Common subroutines in RPM

I have some common code that I would like to execute in the **%pre** and **%post** section of my **rpm** spec file. When I place a subroutine in the **%pre** section, I need to add the same subroutine to the **%post** section of the RPM. It sucks maintaining the same subroutine twice. Here is an example: **RPM** spec file **%pre** and **%post** sections:               %pre     log_file=/var/log/myrpminstall.log     #-------------------------------------     # Send text log_file     #-------------------------------------     log_it() {       log_msg=$1       echo -e $log_msg >> $log_file     }          log_it "pre section log information"          %post          log_it "Post section log informations"      Currently, when the **%post** section of the **rpm** executes during an install, I receive an error message:               /var/tmp/rpm-tmp.36557: line 5: log_it: command not found      So, is there a way to make a subroutine like **log_it** accessible to all sections (global function) of the **RPM**?? Currently, I have to place the **log_it** function in the **%post** section if I want to use it there.


how to disable auto login in linux mint

I'm using linux mint with Cinnamon. The login screen comes to type a username but it also displays that in 10 seconds userx will be automatically logged in. And it happens. How to make it wait indefinitely?


wget images with certain path

im looking to only grab images from a document with a certain path for example domain.com/uploads/287167/file_name.jpg only grab those with the uploads/number/filename im currently doing it this way               wget http://domain.com/news/36843 -q -O - | sed -n -e"s%^.*\(http://site.com/uploads/[0-9][^ \"\']*\.jpg\).*$%\1%p" | xargs wget -q      any other ways of doing this? thanks in advance