mutt: how to display selected new messages diferently in index

I have my own colors defined for `mutt`. When I start `mutt`, the cursor (i.e. indicator) is on the first message (i.e. the first message on the top is selected). I have defined colors for the selected message, and I have colors defined for new messages as well:               ...     color indicator color233 color67      color index color75 color232 ~N     ....      Unfortunately, The selected message looks the same, regardless whether the message is new or not. Is there a way to have a different color for selected new messages, so that I can immediately recognize that the selected message is new? Otherwise I have to move the cursor down, to see that the message is new. I have tried the obvious solution:               color indicator color233 color67 ~N      but that does not work. Mutt complains:               Error in .muttrc, line 15: too many arguments


Debian: program in boot

I just configured my new VPS with Apache, PHP, MySQL and ProFTPd. I wanted to install a smtp server, but I was advised to do a apt-get upgrade first. I did this, and I got up a blue screen where I could choose between two alternatives. It said something about GRUB 2 installer. I chose the alternative that was already selected, the topmost. I chose not to update the GRUB2, and use the old one that was installed. Now, ProFTPd doesn't start in boot anymore. I have to /etc/init.d/proftpd start every time. How do I fix this? Should I have chosen to update GRUB2? Should I do apt-get upgrade again and try to do the same GRUB2 installer again?


copying multiple files to multiple directories

I've a problem copying many files in different directories. Let me explain better: Let's say I have the following in a dir:               $ ls     file1 file2 file3 file4 file5 dir1 dir2 dir3      and I want to copy every file* in every dir* with a single command. I've tried with:                echo dir{1..3} | xargs cp file{1..5} '{}' \;      My intent was to tell xargs to process every single dir* from echo and copy all the files in the input processed but this and similar didn't work. I would like to avoid the use of a script because it's a task I have to repeat for about 20 directories and the names of the files are slightly different so I'd prefer modifying a command rather than a script.


Multiline pattern match using sed, awk or grep

Is it possible to do a multiline pattern match using `sed`, `awk` or `grep`? Take for example, I would like to get all the lines between `{` and `}` So it should be able to match                1. {}      2. {.....}      3. {.....                 .....} Initially the question used `<p>` as an example. Edited the question to use `{` and`}`.


Setting up server to share music with tv

Can someone please point me in the right direction? Hopefully first by letting me know if this is possible... I recently purchased a home theater system which you plug via hdmi into the tv. It has its own nice gui with netflix, and youtube, and blah blah blah. One of the options was to "browse your computer." When you click on it it tries to connect to a server to find music/videos. Can I use my Ubuntu installed laptop to host a server to put music on and play it wirelessly essentially? I believe this is possible and should be pretty straight forward. How would I go about creating a server on the same laptop I would be interacting with it...I could then secure copy or sftp the files back and forth. Is there like special settings to keep in mind? Any words of wisdom would be appreciated. Tx C


Bash: keybinding/trap issue

My .bashrc has the following:               # Alt+L lists current directory     bind -x "\"\el\":ls -ltrF --color=auto;"          # trap commands and echo them to xterm titlebar.     trap 'echo -ne "\033]0;$BASH_COMMAND - $USER@${HOSTNAME}>$(pwd)\007"' DEBUG      Demo of the problem:               bash-4.2$ [Alt+L] #works     total 0     -rw-rw-r--  1 me 1234 0 Aug  3 07:11 foo     -rw-rw-r--  1 me 1234 0 Aug  3 07:11 bar     bash-4.2$ ls -ltr #fails first time     bash: -ltr: command not found     bar  foo     bash-4.2$ ls -ltr #works second time     total 0     -rw-rw-r--  1 me 1234 0 Aug  3 07:11 foo     -rw-rw-r--  1 me 1234 0 Aug  3 07:11 bar      As you can see, the `ls` command fails the first time after executing the key binding. I believe it has to do with the trap. Removing the trap fixes the issue. Is there any way to fix this without removing the trap?


What is the difference between "du -sh *" and "du -sh ./*"?

The title says it all. What's the difference between those 2 commands? **NOTE:** I'm more interested in the `*` and `./*` part.


How to fix kdenlive crashes on Ubuntu 13.10 during scene finding

I am new to the video editing software `kdenlive` and tried to use it to edit a large `avi`` file. I added the`avi`clip and started a job to find the scenes in this avi. Halfway through the clip (after 30 minutes or so),`kdenlive` suddenly crashed. How can I fix this problem? Additional information related to my questions will be given below once they are asked. As I have no idea whether the issue is related to Ubuntu, the desktop, kdenlive or the `avi` file, I cannot be more specific at this point. **Additional information**   * Sometimes the program outputs the following:               Unable to start Dr. Konqi      But there seems to exist no package which might solve this problem.


Zip all files in directory?

Is there a way to zip all files in a given directory with the `zip` command? I've heard of using `*.*`, but I want it to work for extensionless files, too.


How does one include the session-name in status bar for byobu-tmux?

I'd like to include the session name of my current tmux session in the status bar. There's nothing in ~/.byobu/status that allows me to do this and including the tmux configuration directive `#S` in the `tmux_left` line doesn't work (for obvious reasons). Cheers.


Swap partition in LVM?

I was wondering if putting the swap partition into a logical volume group has any drawbacks (e.g. performance), or would it be "just the same" as having it as a separate primary/logical partition? I like the fact that it could be easily resized if necessary, but am not sure about possible drawbacks. _Case of application_ : CentOS 7 Webserver.


How good is gnash as a replacement for flash?

Fedora suggests the Gnash plugin as a replacement for the Flash plugin and I am seriously considering it. My question is: how good is the Gnash plugin as a replacement for the Flash plugin? In my case, I'm not interested in anything advanced, just being able to watch youtube videos.


Shell wildcards and dot files

I am a beginner terminal user trying to understand wildcards. I think I pretty much have a good grasp on it, but I have a couple of questions: Why do the following two codes work as expected:               ls -d .[!.]?*     echo [D]*      But the following 2 don't:               ls -d [.][!.]?*     echo [D]      In the first command, I get an error:               ls: cannot access [.][!.]*: No such file or directory      When I am trying to get the same listing `ls -d .[!.]?*`. And for the second, the output is:               [D]      When I'm expecting an error proclamation along the lines of `No such file or directory`. What am I missing? What exactly makes an expression a wildcard, if those wildcard elements shown in the second set of examples above don't cut it? **Clarification** (Also in comments): The wildcard `[D]*` doesn't only output `D`, it also outputs `Desktop`, `Downloads` ... etc. However, I also tried `echo [D]` when I had a file named D and when I didn't. The output worked when the file `D` was there, but I also got the output `[D]` when it wasn't. I don't get why. Why did the presence of the file in the directory change the expression [D] from being a wild card to not?


wine error when using divfix

When I'm logged in through SSH to a Scientific Linux 6.3 machine I get this error message:               /usr/bin/wine /home/USER/.divfix/DivFix++.exe -i INPUT.avi -o out.avi     wine: created the configuration directory '/home/test/.wine'     No protocol specified     No protocol specified     No protocol specified     No protocol specified     No protocol specified     No protocol specified     Application tried to create a window, but no driver could be loaded.     Make sure that your X server is running and that $DISPLAY is set correctly.     err:systray:initialize_systray Could not create tray window     Application tried to create a window, but no driver could be loaded.     Make sure that your X server is running and that $DISPLAY is set correctly.      I have set the DISPLAY variable..:               grep -i display ~/.bashrc      export DISPLAY=":0.0"      I have X/GUI:               yum groupinstall "Desktop" "Desktop Platform" "X Window System" "Fonts"       I have "yum update" and then rebooted (so up-to-date). What am I missing? please help. UPDATE:               xset -q     No protocol specified     xset:  unable to open display ":0.0"


How to install color schemas for Kate running on GNOME

How do I install schemas(like this one; for syntax highlighting, etc) for Kate (which is originally for KDE) running on GNOME 3? Trying to install with the install.sh script took no effect. Also, if you happen to know any good schemas for Kate (for Python), please let me know.


How can I get real-time information about monitor plug/unplug events?

When I connect or disconnect the USB device, udev shows/monitors that event. But udev is not enough smart to detect the plug-out or plug-in of the monitor. Is there any way/tool/utility from which I will get real-time information about the plug-out or plug-in of a monitor?


gedit reverting settings to default

I'd like to revert to the fresh gedit on my system. Any idea how to get back to default state? So that all my preferences would be lost as well as having activated only the plugins active by default? **Some background** My feeling is that it takes quite some time for the gedit to launch on my system and would like to start with the clean table once again. **Distros/versions** I'd like to achieve this on both of my systems: Xubuntu 12.10 (gedit 3.6) as well as Fedora 17 (gedit 3.4.2).


How to notice log file changes with Linux standard tools?

I need something that does not need to be installed. It's on an embedded system with very little space on the HD. I can't instal anything. I need to do it with something that is already included. I have a script that I want to run based on a certain line that appears in a log file. Currenty I placed this script to run every 5 minutes in the crontab and check the file for changes. Is there a way that I can have the system call the script only if the file has changed? Like, to tell the system to fire the script in case a system call was made to open that file with write permission?


Execute command when file changes

> **Possible Duplicate:**   >  Can a bash script be hooked to a file? Hi there, I am trying to execute a command every time a file changes. Is this possible? I think there is some way to watch for a file, but I have no idea. Thank you!


Can a bash script be hooked to a file?

I want a script to sleep unless a certain file is modifed/deleted (or a file created in a certain directory, or ...). Can this be achieved in some elegant way? The simplest thing that comes to my mind is a loop that sleeps for some time before checking the status again, but maybe there is a more elegant way?


How can I make scripts run when a file/directory changes in Linux (like Mac OS X’s launchd)?

> **Possible Duplicate:**   >  Can a bash script be hooked to a file? On Mac OS X, there’s a handy daemon called launchd which (amongst other things) allows you to have scripts run when files or directories change (via the `WatchPaths` and `QueueDirectories` plist file options). Is there a (preferably Debian) Linux program/package that includes this functionality?


Trigger action each time a file is modified

> **Possible Duplicate:**   >  Can a bash script be hooked to a file? Is it possible to mount a mechanism to a file to perform an action (e.g. mark the change in some log file and such) each time the file is modified? I would like to be able to see what all the files modified are in a given time period or receive an alert each time someone modifies a file.


awk read error bad address

I have a file that is roughly 30GB. I am using,               awk ' $1 <= 2000 ' myfile.txt >> myfile_new.txt      But, I get this error after a while -               awk: read error (Bad address)      I guess this is because the file is too large. Is there any way to get past this? How else can I do this? What I need to do is quite simple, I have to extract all records that have value less than 2000 in a column.


Mysql user privileges : Only CREATE table

I am trying to create a user who will be able to manage all databases without the right to CREATE and DROP databases. I have been using the following link : http://dev.mysql.com/doc/refman/5.0/en/privileges-provided.html#priv_create               GRANT SELECT, INSERT, UPDATE, DELETE, ALTER ON *.* TO 'mysql'@'192.168.1.0/255.255.255.0' IDENTIFIED BY PASSWORD 'toto'      I would like to add CREATE in order to allow the user to create a table, but If I do this the user will be able to create a database too. Is it possible to provide CREATE "table" without CREATE "database" privilege ?


User made host aliases

I would like to set up aliases for hosts `/etc/hosts` style, but I don't have root privileges. Would I be able to set these up from within my /home directory? How?


How can I override the /etc/hosts file at user level?

> **Possible Duplicate:**   >  Can I create a user-specific hosts file to complement /etc/hosts? In short: I would like to know if it is possible to get a `~/hosts` file that could override the `/etc/hosts` file, since I don't have any privileged access. A machine I am working on does seem to be properly configured with a correct DNS server. When I try to ping usual machine **name** I am working with, it fails. But when I try to ping them by **IP address** it works as expected. I want to avoid changing any scripts and other _musuculary memorized handcrafted commmand line_ ™ that I made because of a single unproperly configured machine. I contacted sys admin, but they have other fish to fry. How can I implement that?


df says I have 20G more disk space used than du. Why?

I used du to list all folders and sort by size, the results simply doesn't add up to how much disk space is used(using df). There's about 20G in discrepency, why?               [root@xxx lib]# du --max-depth=1 -h /| sort -n -r     310M    /lib     123M    /root     96K /dev     88M /etc     75G /     73G /var     30M /sbin     20M /boot     20K /tmp     18M /lib64     16K /mnt     16K /lost+found     12K /home     8.0K    /srv     8.0K    /selinux     8.0K    /opt     8.0K    /misc     8.0K    /media     7.0M    /bin     1.2G    /usr     0   /sys     0   /proc     [root@xxx lib]# df -h     Filesystem            Size  Used Avail Use% Mounted on     /dev/mapper/VolGroup00-LogVol00                           298G   94G  189G  34% /     /dev/sda1              99M   26M   69M  28% /boot     tmpfs                 2.0G     0  2.0G   0% /dev/shm


`du -sh` reports different used size than `df -h`

> **Possible Duplicates:**   >  linux free disk space confusion   >  Why is there a discrepancy in disk usage reported by df and du? `df -h` says that I have 494G used on `/var`:               Filesystem            Size  Used Avail Use% Mounted on     /dev/sda3             564G  494G   41G  93% /var      But `du -sh /var` says it's `350G` What makes them different?


Why is there a discrepancy in disk usage reported by df and du?

I have a Linux(CentOS) server, the OS+packages used around 5GB. Then, I transferred 97GB data from a Windows server to two folders on this Linux server, after calculated the disk usage, I see the total size of the two folders is larger than the disk used size. Run du -sh on each folder, one use 50GB, the other one use 47GB But run df -h, the used space is 96G. (50GB + 47GB + 5GB) > 96GB Is there any problem? Those two folders contain lots of files(1 million+). Thanks.


Why does df show Available 0 when 1K-blocks minus Used is greater than 0?

Why does it show 0 in the available column?               [root@server log]# df     Filesystem           1K-blocks      Used Available Use% Mounted on     /dev/sda2              4128448   4096484         0 100% /      It's an ext3 filesystem.


GPT Partition - Used Space immediately after creating partition

I wanted to try out the new GPT system, and used it to partition my new HDD, with the partitions themselves using ext4. For some reason, about 1-2% of the space in each partition is already shown as used, both in `df` and `gparted`. Currently the only content of the partitions is the lost+found folder which occupies all of `16K`. Is there a reason for this? Can this be fixed? Or is this just the space used by the file table (or equivalent)? Edit: Is this more related ext4 than GPT? I found this just now, ext4: How to account for the filesystem space?


Why does "df -h" show out of sync space used?

I have tried different commands to see sizes of partitions and space used/left and it seems that they always differ in their results. Here is my space used/left with from the command `df -h`:               Size  Used Avail Use% Mounted on     395G  355G   21G  95% /home      Notice that used and availabe only add up to 376G but size is 395G


SSD seems full, but file system says otherwise

I'm running CentOS and have a 100GB Micron RealSSD P300. It appears that the drive is almost full, as noted by running `df`:               Filesystem     1K-blocks     Used Available Use% Mounted on     /dev/sda3       94753636 86002428   3937948  96% /     tmpfs           12298364        0  12298364   0% /dev/shm     /dev/sda1         253871    58571    182193  25% /boot      However, running `du /` tells another story:               6.9M    /bin     56M     /boot     188K    /dev     28M     /etc     3.3M    /home     251M    /lib     25M     /lib64     16K     /lost+found     4.0K    /media     4.0K    /mnt     8.0K    /opt     0       /proc     11M     /root     18M     /sbin     4.0K    /selinux     0       /service     4.0K    /srv     0       /sys     436K    /tmp     1.4G    /usr     1.9G    /var      What could be taking up all of these blocks that I can't see? Could the drive just be broken? I don't have too much experience working with SSDs, so perhaps there's an obvious step I'm missing?


Why are there so many different ways to measure disk usage?

When I sum up the sizes of my files, I get one figure. If I run `du`, I get another figure. If I run `du` on all the files on my partition, it doesn't match what `df` claims is used. Why are there so many different figures for the total size of my files? Can't computers add? Speaking of adding: when I add the “Used” and “Available” columns of `df`, I don't get the total figure. And that total figure is smaller than the size of my partition. And if I add up my partition sizes I don't get my disk size! What gives?


df vs. du: why so much difference?

> **Possible Duplicate:**   >  Why is there a discrepancy in disk usage reported by df and du? `df` says 8.9G used by the partition mounted in `/`               :~$ df -h     Filesystem      Size  Used Avail Use% Mounted on     /dev/sda5       227G  8.9G  207G   5% /      However, a `du` in `/` yields a **much** smaller number.               :~# du -chs /     5.5G    /     5.5G    total      I was expecting a smaller number, but why is to **so much** smaller?


Most accurate disk usage report?

Since disk space is allocated in blocks, is it a more accurate representation of the actual space consumed by a directory to report it in blocks vs bytes? If a file of size 1,025 bytes resides on a file system where space on the file system is doled out in units of 1,024 byte blocks, that file consumes two whole blocks. That seems more accurate than to say that this file consumes 1,025 bytes of space. Edit: File system in question is ext4, no dedupe, no compression, fwiw. This is my attempt:               def getDirUsage(filepath, block_size=1024):  # block_size as reported by os.statvfs()         '''         return the number of blocks consumed by a directory         '''         total_size = int(math.ceil(os.path.getsize(filepath)/block_size))  # debatable whether this should be included in the size         allfiles = os.listdir(filepath)         for f in allfiles:             p = os.path.join(filepath,f)             if os.path.isdir(p):                 total_size += getDirUsage(p,block_size)             else:                 total_size += int(math.ceil(os.stat(p).st_size/block_size))         return total_size


Disk space shows up as used but not on `du`

I have a problem where 70G on a server seems unreachable:               XXX@XXX:/data$ df -h     Filesystem                        Size  Used Avail Use% Mounted on     /dev/mapper/ubuntu--Storage-root  120G  2.9G  111G   3% /     udev                              7.9G  4.0K  7.9G   1% /dev     tmpfs                             3.2G  296K  3.2G   1% /run     none                              5.0M     0  5.0M   0% /run/lock     none                              7.9G     0  7.9G   0% /run/shm     /dev/sda1                         228M   25M  192M  12% /boot     /dev/sdb1                          19T   70G   18T   1% /data      and when checking usage in the mount point `/data/`:               XXX@XXX:/data$ du -h     8.0K    ./STR1     4.0K    ./STR2     16K .      nothing shows up


df-command free disk-space wrong

Filesystem      Size  Used Avail Use% Mounted on     /dev/sda1       107G  4.4G   97G   5% /     dev             3.9G     0  3.9G   0% /dev     run             3.9G  576K  3.9G   1% /run     tmpfs           3.9G   23M  3.9G   1% /dev/shm     tmpfs           3.9G     0  3.9G   0% /sys/fs/cgroup     tmpfs           3.9G   14M  3.9G   1% /tmp     tmpfs           788M  4.0K  788M   1% /run/user/1000      Why does df shows 97G Available Disk-Space? Shouldn't it be 102.6?


linux + add X days to date and get new virtual date

I have Linux ( RH 5.3) machine I need to add/calculate 10 days plus date so then I will get new date (expiration date)) for example                # date       Sun Sep 11 07:59:16 IST 2012      So I need to get                    NEW_expration_DATE = Sun Sep 21 07:59:16 IST 2012      Please advice how to calculate the new expiration date ( with bash , ksh , or manipulate date command ?)


Compiling code from vim

New to `vim` and and I want to be able to compile code from within `vim` without running a new terminal and calling the compiler. How do I go about doing this? Note that this requirement is not restricted to `gcc` only, I sometimes need to call `python` also on the current script I am working on, so you get the idea...


Fedora 17 freezes at loading screen with a CD-based installation

I'm trying to install F17 on my laptop (Toshiba A-665 ... 4gigs RAM, nividia gforce GTS350M,core-i7 1.7 GHz processor), but the liveCD boot freezes about 3/4 of the way through the loading icon... EVERY TIME. I've checked the image, the LiveCD (using Fedora 17s own media checker) and re-downloaded / rewritten the ISO about a thousand times now. Conclusion: the ISO is fine, the media is fine. The Fedora live environment just WILL NOT BOOT. I even tried to install other Distros of Linux (Ubuntu 12.10, Opensuse 12.2), and both gave me the same problem exactly. To clarify: I turn on my laptop, push F12 to select CD\DVD as boot device Fedora boot options appear, hit enter on the first option, screen flashes white-ish, little cursor at top left (about 3-5 seconds here) little icon appears on screen, starts filling up ~3/4 of the way through, the icon stops filling at this point, the CD Drive stops spinning, as does the disk-usage light on my laptop. And I can't open the DVD Drive tray, with no response AT ALL. No "could not find this, that, or the other thing" errors. No response at all from the keyboard, I have to hold down the power button to reboot. I get exactly the same result (with different progress bar) when I select "Trouble Shooting" and then "Boot in something-or-other graphics mode."


Notify of changes on a file under /proc

I have written a small 'daemon' in bash that will switch to the headphones if they are detected, and if not, switch to an external USB speaker with PulseAudio. What I'm looking for is some way to get notification of changes on the file `/proc/asound/card0/codec#0`, just like `inotifywait` does on real files (considering files under /proc to be as "pseudo-files"). I find my code a bit insane, because it runs `sleep 1` with `awk` for the whole day, that is 86400 times a day :)               while sleep 1; do         _1=${_2:-}         _2=$(awk '/Pin-ctls/{n++;if(n==4)print}' '/proc/asound/card0/codec#0')              [[ ${_1:-} = $_2 ]] ||             if [[ $_2 =~ OUT ]]; then                 use_speakers             else                 use_internal             fi     done      What I'm looking for is something like (this example doesn't work):               codec=/proc/asound/card0/codec#0     while inotifywait $codec; do         if [[ $(awk '/Pin-ctls/{n++;if(n==4)print}' $codec) =~ OUT ]]; then             use_speakers         else             use_internal         fi     done      This way the commands inside the loop would be run only when there are real changes on the `$codec` file.


Do I need Nautilus on RedHat / CentOS / Scientific Linux 6?

I've found that Nautilus causes problems in my Scientific Linux 6 desktop (specifically it gets into an infinite loop opening the file manager at startup). While those problems are interesting in their own right, it got me wondering if I really need it for anything. When I do this:               sudo yum remove nautilus      the problem goes away, and since I never interact with the GUI file manager this doesn't seem like a problem. Will this bite me later on? Are there some hidden uses for Nautilus other than browsing files with a GUI?


Can a user with /sbin/nologin shell login through ssh?

Is it possible to ssh to a machine as a user with no valid shell (say, `mail`)? So far I cannot, and using the command below doesn't work:               $ ssh mail@machine.local /bin/bash      It will always say "This account is currently not available.". But if I'm logged-in to the machine and use 'su'               $ su mail -s /bin/bash      I can become user `mail`.


How to stop a background process?

I have started a wget on remote machine in background using `&`. Suddenly it stops downloading. I want to stop its process, then start it again. How can I stop it? I haven't close its shell window. But as you know it doesn't stop using `Ctrl`+`C` and `Ctrl`+`Z`.


How to pass argument with spaces to a shell script function?

I'm trying to pass multiple argument to a function, but one of them is consist of two words and I want shell function to deal with it as one arg:               args=("$@")     function(){      echo ${args[0]}      echo ${args[1]}      echo ${args[2]}     }      when I call this command `sh shell hi hello guys bye` I get this               hi          hello          guys      But what I really want is:               hi      hello guys     bye


Sending emails from AutoMySQLBackup from Linux Mint

I have set AutoMySQLBackup on a Linux Mint machine and I want to have the backups sent to an email, but I cannot make it work. I'm new to Linux environment and don't understand it very much. I installed `mutt` and `Postfix`, but I don't know how to config them, so `AutoMySQLBackup` will be able to send the backups to a Gmail account.


rm -r path : how to avoid being asked at each level?

How to avoid being asked at each level if I want to delete that path? I just want to remove everything in a path?


How to upgrade Debian stable (Wheezy) to testing (Jessie)?

I downloaded and installed Debian 7 Wheezy, the stable version, but I would like more recent apps and libs so I'd like to switch to testing version (aka Jessie). How do I proceed?


Upgrade debian from oldstable (squeeze) to unstable (sid)

I am trying to get debian sid. Firstly, I installed a clean squeeze on my hard drive. I replaced everything in my 'sources.list' with 'deb http://ftp.de.debian.org/debian unstable main contrib non-free'. Then I performed these commands: apt-get update (no errors), apt-get dist-upgrade (took 10 minutes, no errors), reboot. But after reboot its version is still 6.0.7. Repeating 'apt-get dist-upgrade' "works" but doesn't change much (or nothing).


This file must be edited with the 'visudo' command.?

Why it is recommended to edit `/etc/sudoers` file with the `visudo` command? Here is a sample of the file:               ## Sudoers allows particular users to run various commands as     ## the root user, without needing the root password.     ##     ## Examples are provided at the bottom of the file for collections     ## of related commands, which can then be delegated out to particular     ## users or groups.     ##     ## This file must be edited with the 'visudo' command.      Are there any special reasons for it?


CUPS printing of pdf files

How can I tell the lpr command (cups) that my file is actually a pdf? `lpr file.pdf` won't print anything.


What does the "(8)" in fsck(8) mean?

*nix commands (and functions?) have a number with them, like `fsck(8)`, `killall(1)`, etc.  What does the number mean?


setting Cygwin's $HOME to Windows profile directory

Are there any drawbacks to having Cygwin and Windows share the same $HOME directory, in this case the Windows profile directory?


apt-get error 503

I tried installing pyqt4-dev-tools on my machine using the following command:               sudo apt-get install pyqt4-dev-tools      after a few prompts the installation is aborted with the following message:               Err http://archive.ubuntu.com/ubuntu/ precise/main pyqt4-dev-tools i386 4.9.1-2ubuntu1       503  Service Unavailable [IP: 91.189.91.15 80]     Failed to fetch http://archive.ubuntu.com/ubuntu/pool/main/p/python-qt4/pyqt4-dev-tools_4.9.1-2ubuntu1_i386.deb  503  Service Unavailable [IP: 91.189.91.15 80]     E: Unable to fetch some archives, maybe run apt-get update or try with --fix-missing?      I tried running apt-get with `\--fix-missing`, same error. running apt-get update doesn't help either. I'm using linux mint, if it matters any thing.


Mounting Remote Filesystem over SSH as a Different User

Due to a breach of security, the administrators of the work server have implemented a new method of security. To log into the server, we must log in as our own user (which has severely limited permissions), then `su` into another user under which we can do development (which we cannot log in to from the outside). It used to be that we just logged in to a common user which had permissions, and I could simply mount the remote filesystem right onto my local filesystem using `sshfs`. Now that we have to `su` into another user, I can't simply mount it like I have before. I've done a reasonable amount of research and tried all "solutions" I found. I've been trying to make this work for some time. My question is: is there a way to `su` into a different user inside a `sshfs` mount? Perhaps running a script on the server after the mount completes or something? I would use something like this, but I don't have `sudo` access on the server, only `su`. As a side note, my development computer is running LM11, and I'm mounting a share on some old Red Hat server.


What is causing this Copy command to enter sleep state?

I am trying to recursively copy a huge directory of installables over 25G and want to preserve the owner and group id, permission modes and so on. So I ran the below commands:               bash-3.2$ date; cp -rpP /source/path/Oracle /target/path/Oracle;date;     Tue Jun  4 09:44:54 EDT 2013          ...      * * * **Some observations:**   * Today (Wed Jun 5 12:09:25 EDT 2013) I notice that it still hasn't completed and appears to be stuck somewhere. I started analyzing the process and it seems to be sleeping:              bash-3.2$ truss -p 09431;     read(10, 0xFFBEF288, 32768)     (sleeping...)        * The last entry also shows that its asleep.              bash-3.2$ pflags 09431     9431:   cp -rpP /source/path/Oracle /target/path/Oracle             data model = _ILP32  flags = RLC|ASYNC|MSACCT|MSFORK             flttrace = 0xfffffbff             sigtrace = 0xfffffeff 0xffffffff             HUP|INT|QUIT|ILL|TRAP|ABRT|EMT|FPE|BUS|SEGV|SYS|PIPE|ALRM|TERM|USR1|USR2|CLD|PWR|WINCH|URG|POLL|STOP|TSTP|CONT|TTIN|TTOU|VTALRM|PROF|XCPU|XFSZ|WAITING|LWP|FREEZE|THAW|CANCEL|LOST|XRES|JVM1|JVM2|RTMIN|RTMIN+1|RTMIN+2|RTMIN+3|RTMAX-3|RTMAX-2|RTMAX-1|RTMAX         entryset = 0x00000401 0x04000000 0x00000000 0x00000028                    0x80000000 0x00000000 0x00000000 0x00000000         exitset  = 0xfffffffe 0xffffffff 0xffffffff 0xffffffd7                    0x7fffffff 0xffffffff 0xffffffff 0xffffffff      /1:    flags = ASLEEP  read(0xa,0xffbef288,0x8000)        * Finally tried `pfiles`              bash-3.2$ pfiles -F 09431     9431:   cp -rpP /source/path/Oracle /target/path/Oracle     Current rlimit: 256 file descriptors     0: S_IFCHR mode:0620 dev:363,0 ino:12582922 uid:502012187 gid:7 rdev:24,3       O_RDWR|O_NOCTTY|O_LARGEFILE       /devices/pseudo/pts@0:3     1: S_IFCHR mode:0620 dev:363,0 ino:12582922 uid:502012187 gid:7 rdev:24,3       O_RDWR|O_NOCTTY|O_LARGEFILE       /devices/pseudo/pts@0:3     2: S_IFCHR mode:0620 dev:363,0 ino:12582922 uid:502012187 gid:7 rdev:24,3       O_RDWR|O_NOCTTY|O_LARGEFILE       /devices/pseudo/pts@0:3     3: S_IFDIR mode:0750 dev:377,1 ino:1135681 uid:502012187 gid:502012187 size:4096       O_RDONLY|O_NDELAY|O_LARGEFILE FD_CLOEXEC       /source/path/Oracle     4: S_IFDIR mode:0750 dev:377,1 ino:1135682 uid:502012187 gid:502012187 size:4096       O_RDONLY|O_NDELAY|O_LARGEFILE FD_CLOEXEC       /source/path/Oracle/Middleware     5: S_IFDIR mode:0750 dev:377,1 ino:14640507 uid:502012187 gid:502012187 size:4096       O_RDONLY|O_NDELAY|O_LARGEFILE FD_CLOEXEC       /source/path/Oracle/Middleware/user_projects     6: S_IFDIR mode:0750 dev:377,1 ino:14640508 uid:502012187 gid:502012187 size:4096       O_RDONLY|O_NDELAY|O_LARGEFILE FD_CLOEXEC       /source/path/Oracle/Middleware/user_projects/epmsystem2     7: S_IFDIR mode:0750 dev:377,1 ino:6480147 uid:502012187 gid:502012187 size:4096       O_RDONLY|O_NDELAY|O_LARGEFILE FD_CLOEXEC       /source/path/Oracle/Middleware/user_projects/epmsystem2/EssbaseServer     8: S_IFDIR mode:0750 dev:377,1 ino:6480149 uid:502012187 gid:502012187 size:4096       O_RDONLY|O_NDELAY|O_LARGEFILE FD_CLOEXEC       /source/path/Oracle/Middleware/user_projects/epmsystem2/EssbaseServer/essbaseserver1     9: S_IFDIR mode:0750 dev:377,1 ino:6480151 uid:502012187 gid:502012187 size:4096       O_RDONLY|O_NDELAY|O_LARGEFILE FD_CLOEXEC       /source/path/Oracle/Middleware/user_projects/epmsystem2/EssbaseServer/essbaseserver1/bin     10: S_IFIFO mode:0660 dev:377,1 ino:9088704 uid:502012187 gid:502012187 size:0       O_RDONLY|O_LARGEFILE       /source/path/Oracle/Middleware/user_projects/epmsystem2/EssbaseServer/essbaseserver1/bin/ESSBASE1_1     11: S_IFREG mode:0660 dev:326,22000 ino:128325 uid:502012187 gid:502012187 size:0       O_WRONLY|O_CREAT|O_TRUNC|O_LARGEFILE       /target/path/Oracle/Middleware/user_projects/epmsystem2/EssbaseServer/essbaseserver1/bin/ESSBASE1_1      * * * **UPDATE:** _Note that the above`cp` process has been killed. So below observations are trying to reproduce the issue._   * **File** that is getting blocked:              bash-3.2$ ls -l ESSBASE1_1     prw-rw----   1 kent   kent         0 Nov 22  2011 ESSBASE1_1        * When I try to cp this file individually:              bash-3.2$ cp ESSBASE1_1 ESSBASE1_1kent  # PID = 08745          ...      it hangs too.   * Looking at `pflags`, it seems to be sleeping.              bash-3.2$ pflags 08745     8745:   cp ESSBASE1_1 ESSBASE1_1kent             data model = _ILP32  flags = MSACCT|MSFORK     /1:    flags = ASLEEP  read(0x3,0xffbf6bc8,0x8000)        * Searching for all other processes using this file              bash-3.2$ fuser -f /source/path/Oracle/Middleware/user_projects/epmsystem2/EssbaseServer/essbaseserver1/bin/ESSBASE1_1     /source/path/Oracle/Middleware/user_projects/epmsystem2/EssbaseServer/essbaseserver1/bin/ESSBASE1_1:     8745o   25057o      Note that the 'o' indicates that the process is using the file as an open file.   * Finding at the processes:               bash-3.2$ pstree | grep 8745      | | |       |--- 09695 kent grep 8745      | |         \--- 08745 kent cp ESSBASE1_1 ESSBASE1_1kent     bash-3.2$ pstree | grep 25057      | | |       \--- 09700 kent grep 25057      | |   |-+- 25057 kent 86:43 /some/path/Oracle/Middlewa      Process with PID 25057 is a server process.   * The open file is on a mount-point. It's a NAS disk.              bash-3.2$ cat /etc/mnttab | grep apps     server1.com:/vol/server1_nec_nosnap0/dev_apps   /source/path/       nfs     rw,xattr,dev=5e40001    1362894854      * * *   * Can anyone help me understand what is causing the copy command to freeze up?   * I can guess that the application is running and that might be in some way preventing any other process from accessing a particular file.    * But in such a scenario I would expect `cp` to abort and throw me an error rather than stay blocked indefinitely.   * As per the update, it seems process `PID=25057` seems to be using the file as an open file. But why does this block the `cp` command?


i3wm can't create new tiles and mouse won't move

I installed i3wm and X using the tutorials in the Arch wiki for a new Arch installation. I have Intel video, so I installed the xf86-video-intel package (which takes care of the driver). But when I run: `startx` I'm taken to i3 (which I've never used before), but the mouse won't move (I'm running Ubuntu dual boot on this machine and mouse works great there) and when I try to create a new tile (`alt-enter`), the cursor turns into what looks like a clock surrounded by a frame of sorts, and doesn't recover. When I try to exit (`alt-shift-e`), I'm presented with a tab asking me to be sure, which I have to click with my mouse, which isn't moving, so I can't exit without shutting down (i.e., pressing the i/o power button on the laptop). Here is a log from startup. I pressed new window a couple of times and then shut the computer down:               06/05/13 01:08:09 - i3 4.5.1 (2013-03-18, branch "tags/4.5.1") starting     06/05/13 01:08:09 - Parsing configfile /home/tjb1982/.i3/config     deciding for version 4 due to this line: # i3 config file (v4)     06/05/13 01:08:09 - [libi3] libi3/font.c Using X font -misc-fixed-medium-r-normal--13-120-75-75-C-70-iso10646-1     06/05/13 01:08:09 - Used number 1 for workspace with name 1     06/05/13 01:08:09 - auto-starting i3-config-wizard     06/05/13 01:08:09 - startup id = i3/i3-config-wizard/723-0-arch_TIME0     06/05/13 01:08:09 - executing: i3-config-wizard     06/05/13 01:08:09 - Starting bar process: i3bar --bar_id=bar-hjnjco --socket="/run/user/1000/i3/ipc-socket.723"     06/05/13 01:08:09 - executing: i3bar --bar_id=bar-hjnjco --socket="/run/user/1000/i3/ipc-socket.723"     06/05/13 01:08:09 - Not a managed window, ignoring UnmapNotify event     The config file "/home/tjb1982/.i3/config" already exists. Exiting.     06/05/13 01:08:09 - IPC: looking for config for bar ID "bar-hjnjco"     06/05/13 01:08:09 - workspace visible? fs = 0x1bdb0f0, ws = 0x1bdb0f0     06/05/13 01:08:09 - WM_CLASS changed to i3bar (instance), i3bar (class)     06/05/13 01:08:09 - WM_NAME changed to "i3bar for output LVDS1"     06/05/13 01:08:09 - Using legacy window title. Note that in order to get Unicode window titles in i3, the application has to set _NET_WM_NAME (UTF-8)     06/05/13 01:08:09 - This window is of type dock     06/05/13 01:08:09 - Checking window 0x00a00007 (class i3bar)     06/05/13 01:08:09 - dock status does not match     06/05/13 01:08:09 - Checking window 0x00a00007 (class i3bar)     06/05/13 01:08:09 - dock status matches     06/05/13 01:08:09 - ClientMessage for window 0x0000009e     06/05/13 01:08:26 - startup id = i3/i3-sensible-terminal/723-1-arch_TIME366852     06/05/13 01:08:26 - executing: i3-sensible-terminal     06/05/13 01:08:26 - Not a managed window, ignoring UnmapNotify event     06/05/13 01:08:28 - startup id = i3/i3-sensible-terminal/723-2-arch_TIME368252     06/05/13 01:08:28 - executing: i3-sensible-terminal     06/05/13 01:08:28 - Not a managed window, ignoring UnmapNotify event     06/05/13 01:08:30 - startup id = i3/i3-sensible-terminal/723-3-arch_TIME370387     06/05/13 01:08:30 - executing: i3-sensible-terminal     06/05/13 01:08:30 - Not a managed window, ignoring UnmapNotify event     06/05/13 01:08:31 - startup id = i3/i3-sensible-terminal/723-4-arch_TIME371331     06/05/13 01:08:31 - executing: i3-sensible-terminal     06/05/13 01:08:31 - Not a managed window, ignoring UnmapNotify event     [libi3] libi3/font.c Using X font -misc-fixed-medium-r-normal--13-120-75-75-C-70-iso10646-1      Contents of ~/.i3/config (replaced `#` with `;` for markdown legibility [which I didn't need to do, but I'm leaving it anyway):               ; i3 config file (v4)     ;     ; Please see http://i3wm.org/docs/userguide.html for a complete reference!     ;     ; This config file uses keycodes (bindsym) and was written for the QWERTY     ; layout.     ;     ; To get a config file with the same key positions, but for your current     ; layout, use the i3-config-wizard     ;          ; Font for window titles. Will also be used by the bar unless a different font     ; is used in the bar {} block below. ISO 10646 = Unicode          font -misc-fixed-medium-r-normal--13-120-75-75-C-70-iso10646-1          ; The font above is very space-efficient, that is, it looks good, sharp and     ; clear in small sizes. However, if you need a lot of unicode glyphs or     ; right-to-left text rendering, you should instead use pango for rendering and     ; chose a FreeType font, such as:     ; font pango:DejaVu Sans Mono 10          ; use Mouse+Mod1 to drag floating windows to their wanted position     floating_modifier Mod1          ; start a terminal     bindsym Mod1+Return exec i3-sensible-terminal          ; kill focused window     bindsym Mod1+Shift+q kill          ; start dmenu (a program launcher)     bindsym Mod1+d exec dmenu_run     ; There also is the (new) i3-dmenu-desktop which only displays applications     ; shipping a .desktop file. It is a wrapper around dmenu, so you need that     ; installed.     ; bindsym Mod1+d exec --no-startup-id i3-dmenu-desktop          ; change focus     bindsym Mod1+j focus left     bindsym Mod1+k focus down     bindsym Mod1+l focus up     bindsym Mod1+semicolon focus right          ; alternatively, you can use the cursor keys:     bindsym Mod1+Left focus left     bindsym Mod1+Down focus down     bindsym Mod1+Up focus up     bindsym Mod1+Right focus right          ; move focused window     bindsym Mod1+Shift+j move left     bindsym Mod1+Shift+k move down     bindsym Mod1+Shift+l move up     bindsym Mod1+Shift+semicolon move right          ; alternatively, you can use the cursor keys:     bindsym Mod1+Shift+Left move left     bindsym Mod1+Shift+Down move down     bindsym Mod1+Shift+Up move up     bindsym Mod1+Shift+Right move right          ; split in horizontal orientation     bindsym Mod1+h split h          ; split in vertical orientation     bindsym Mod1+v split v          ; enter fullscreen mode for the focused container     bindsym Mod1+f fullscreen          ; change container layout (stacked, tabbed, toggle split)     bindsym Mod1+s layout stacking     bindsym Mod1+w layout tabbed     bindsym Mod1+e layout toggle split          ; toggle tiling / floating     bindsym Mod1+Shift+space floating toggle          ; change focus between tiling / floating windows     bindsym Mod1+space focus mode_toggle          ; focus the parent container     bindsym Mod1+a focus parent          ; focus the child container     ;bindsym Mod1+d focus child          ; switch to workspace     bindsym Mod1+1 workspace 1     bindsym Mod1+2 workspace 2     bindsym Mod1+3 workspace 3     bindsym Mod1+4 workspace 4     bindsym Mod1+5 workspace 5     bindsym Mod1+6 workspace 6     bindsym Mod1+7 workspace 7     bindsym Mod1+8 workspace 8     bindsym Mod1+9 workspace 9     bindsym Mod1+0 workspace 10          ; move focused container to workspace     bindsym Mod1+Shift+1 move container to workspace 1     bindsym Mod1+Shift+2 move container to workspace 2     bindsym Mod1+Shift+3 move container to workspace 3     bindsym Mod1+Shift+4 move container to workspace 4     bindsym Mod1+Shift+5 move container to workspace 5     bindsym Mod1+Shift+6 move container to workspace 6     bindsym Mod1+Shift+7 move container to workspace 7     bindsym Mod1+Shift+8 move container to workspace 8     bindsym Mod1+Shift+9 move container to workspace 9     bindsym Mod1+Shift+0 move container to workspace 10          ; reload the configuration file     bindsym Mod1+Shift+c reload     ; restart i3 inplace (preserves your layout/session, can be used to upgrade i3)     bindsym Mod1+Shift+r restart     ; exit i3 (logs you out of your X session)     bindsym Mod1+Shift+e exec "i3-nagbar -t warning -m 'You pressed the exit shortcut. Do you really want to exit i3? This will end your X session.' -b 'Yes, exit i3' 'i3-msg exit'"          ; resize window (you can also use the mouse for that)     mode "resize" {             ; These bindings trigger as soon as you enter the resize mode                  ; Pressing left will shrink the window’s width.             ; Pressing right will grow the window’s width.             ; Pressing up will shrink the window’s height.             ; Pressing down will grow the window’s height.             bindsym j           resize shrink width 10 px or 10 ppt             bindsym k           resize grow height 10 px or 10 ppt             bindsym l           resize shrink height 10 px or 10 ppt             bindsym semicolon   resize grow width 10 px or 10 ppt                  ; same bindings, but for the arrow keys             bindsym Left        resize shrink width 10 px or 10 ppt             bindsym Down        resize grow height 10 px or 10 ppt             bindsym Up          resize shrink height 10 px or 10 ppt             bindsym Right       resize grow width 10 px or 10 ppt                  ; back to normal: Enter or Escape             bindsym Return mode "default"             bindsym Escape mode "default"     }          bindsym Mod1+r mode "resize"          ; Start i3bar to display a workspace bar (plus the system information i3status     ; finds out, if available)     bar {             status_command i3status     }          ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;     ; automatically start i3-config-wizard to offer the user to create a     ; keysym-based config which used his favorite modifier (alt or windows)     ;     ; i3-config-wizard will not launch if there already is a config file     ; in ~/.i3/config.     ;     ; Please remove the following exec line:     ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;     exec i3-config-wizard


Convert file path to URI in bash

How can I convert a file path to an URI in the command-line? **Example** :               /home/MHC/directory with spaces and ümläuts      to               file:///home/MHC/directory%20with%20spaces%20and%20%C3%BCml%C3%A4uts


Why do Mono applications only start from their own directory?

If I want to run the application `monodevelop`, I need to chdir to `/usr/lib/monodevelop/Bin` and then execute `./MonoDevelop.exe`. This is the same for all other Mono applications such as `banshee`, `tomboy`, etc. If I attempt to run the Mono applications from another location by simply running `monodevelop`, or even from their own directory, I get _TypeInitializationExceptions_ like this: > behrooz@behrooz:/usr/lib/monodevelop/bin$ monodevelop   >  FATAL ERROR [2012-05-04 11:24:39Z]: MonoDevelop failed to start. Some   >  of the assemblies required to run MonoDevelop (for example gtk-sharp,   >  gnome-sharp or gtkhtml-sharp) may not be properly installed in the   >  GAC. System.TypeInitializationException: An exception was thrown by   >  the type initializer for Gtk.Application --->   >  System.EntryPointNotFoundException: glibsharp_g_thread_supported at   >  (wrapper managed-to-native) GLib.Thread:glibsharp_g_thread_supported   >  () at GLib.Thread.get_Supported () [0x00000] in :0   >  at Gtk.Application..cctor () [0x00000] in :0 ---   >  End of inner exception stack trace --- at   >  MonoDevelop.Ide.IdeStartup.Run (MonoDevelop.Ide.MonoDevelopOptions   >  options) [0x0007e] in   > > /home/behrooz/Desktop/Monodevelop/monodevelop-2.8.6.5/src/core/MonoDevelop.Ide/MonoDevelop.Ide/IdeStartup.cs:95   >  at MonoDevelop.Ide.IdeStartup.Main (System.String[] args) [0x0004f] in   > > /home/behrooz/Desktop/Monodevelop/monodevelop-2.8.6.5/src/core/MonoDevelop.Ide/MonoDevelop.Ide/IdeStartup.cs:503 Why is that? I have tried reinstalling all Mono, Wine, GTK, Glib, X, Gnome packages. > apt-get --purge --reinstall install $(dpkg --get-selections| grep mono |grep > install |grep -v deinstall |awk'{print $1}') I also tried starce on "open" and got nothing by myself System Configuration:   - Debian 6.0-updates 64 bit   - Kernel 3.2.0-2, 3.2.0-1, 3.1 and 3 EDIT: not a kernel thing - Gnome 3.4 EDIT:but a gnome thing - Mono 2.10.5   TLS: __thread   SIGSEGV: altstack   Notifications: epoll   Architecture: amd64   Disabled: none   Misc: softdebug   LLVM: supported, not enabled.   GC: Included Boehm (with typed GC and Parallel Mark) update: with upgrading to the new monodevelop 3.0.2 and latest mono, I can run monodevelop with command "monodevelop" in terminal,no chdir.but gnome-shell cannot run it. Finally found it:   as root:                cd /usr/local/      find | grep mono|xargs rm -rf      # Use with caution/some applications may get messed up(stellarium has MONOchrome images...)


What is a pager?

I saw "pager" in several places: > `less` is a terminal pager program on Unix > > option `-P` for `man` Specify which output pager to use. What is a pager? How is it related to and different from a terminal? Thanks.


Mac OS X LDAP query via dscl yields different results for same user with same datasource

Where is the `NFSHomeDirectory` attribute stored for a Mac user who authenticates via LDAP? It doesn't seem to be in the LDAP database on the backend so I assume Open Directory is involved. I have 2 servers, one is 10.5.8 and one is 10.7. Each is an Open Directory Master. We also have Sun LDAP which is the authoritative LDAP for our entire environment. When I do `dscl /LDAPv3/our.ldap.server read /Users/ouruser` I get a different result for the `NFSHomeDirectory` attribute on the two servers, but I'm querying the same LDAP server in both instances. How could this be? What am I not understanding? I assume the attributes are all stored in LDAP since that is what I'm querying. Could it be caching? ### Some history The newer server was created by cloning the old one with Carbon Copy Cloner and then updating it. Pinging the LDAP server results in the same IP on both machines.


How to check a particular directory is mounted?

How to check a particular directory is mounted on the Linux machine. For instance there is a folder named test, I want to check if it is mounted or not.


How can I have more than one possibility in a script's shebang line?

I'm in a bit of an interesting situation where I have a Python script that can theoretically be run by a variety of users with a variety of environments (and PATHs) and on a variety of Linux systems. I want this script to be executable on as many of these as possible without artificial restrictions. Here are some known setups:   * Python 2.6 is the system Python version, so python, python2, and python2.6 all exist in /usr/bin (and are equivalent).   * Python 2.6 is the system Python version, as above, but Python 2.7 is installed alongside it as python2.7.   * Python 2.4 is the system Python version, which my script does not support. In /usr/bin we have python, python2, and python2.4 which are equivalent, and python2.5, which the script supports. I want to run the same executable python script on all three of these. It would be nice if it tried to use /usr/bin/python2.7 first, if it exists, then fall back to /usr/bin/python2.6, then fall back to /usr/bin/python2.5, then simply error out if none of those were present. I'm not too hung up on it using the most recent 2.x possible, though, as long as it's able to find one of the correct interpreters if present. My first inclination was to change the shebang line from:               #!/usr/bin/python      to               #!/usr/bin/python2.[5-7]      since this works fine in bash. But running the script gives:               /usr/bin/python2.[5-7]: bad interpreter: No such file or directory      Okay, so I try the following, which also works in bash:               #!/bin/bash -c /usr/bin/python2.[5-7]      But again, this fails with:               /bin/bash: - : invalid option      Okay, obviously I could just write a separate shell script that finds the correct interpreter and runs the python script using whatever interpreter it found. I'd just find it a hassle to distribute two files where one should suffice as long as it's run with the most up-to-date python 2 interpreter installed. Asking people to invoke the interpreter explicitly (e.g., `$ python2.5 script.py`) is not an option. Relying on the user's PATH being set up a certain way is also not an option. ## Edit: Version checking within the Python script is **not** going to work since I'm using the "with" statement which exists as of Python 2.6 (and can be used in 2.5 with `from __future__ import with_statement`). This causes the script to fail immediately with a user-unfriendly SyntaxError, and prevents me from ever having an opportunity to check the version first and emit an appropriate error. **Example:** (try this with a Python interpreter less than 2.6)               #!/usr/bin/env python          import sys          print "You'll never see this!"     sys.exit()          with open('/dev/null', 'w') as out:         out.write('something')


Asus Bluetooth Dongle with Atheros (ath3k) chip - OpenSUSE - probe failed with error -5

I'm trying to use an Asus USB Bluetooth Dongle in OpenSUSE. Unfortunately when I plug it in, dmesg gives me the following output:               usb 8-2: new full speed USB device using uhci_hcd and address 3     usb 8-2: New USB device found, idVendor=0cf3, idProduct=3000     usb 8-2: New USB device strings: Mfr=0, Product=0, SerialNumber=0     ath3k: probe of 8-2:1.0 failed with error -5      lsusb gives the following output:               Bus 005 Device 004: ID 0cf3:3005 Atheros Communications, Inc.      The modules ath3k and bluetooth are loaded, but neither bluedevil nor the OpenSUSE bluetooth adapter tool detect the stick. I'm using the 2.6.37.6-0.20-desktop kernel from the OpenSUSE repositories under openSUSE 11.4 32bit. The following packages are installed:   * bluedevil   * bluez    * bluez   * compat    * bluez-firmware   * bluez-gstreamer    * bluez-hcidump   * bluez-test   * gnome-bluetooth   * libbluedevil1    * libbluetooth3   * libgnome-bluetooth8


Simplest way of forwarding all mail from server?

> **Possible Duplicate:**   >  Lightweight outgoing SMTP server I am looking for a minimal mail solution (MTA) for a headless server which generate e-mails for local users and and fully qualified addresses from cron- jobs, etc. Ideally all mails to local user `foo` should be mapped to `foo@mydomain`, with possible modifications for `uid`<1024, and sent off to an external smtp server without involving `/var/mail`. Some years ago, I used sSMTP for a similar task, and I was wondering if this is still the way ahead? Also, how much of the default debian mail system should/could I remove? * * * **Update** Ended up Googling a bit, and the obvious candidates seem to be   * sSMTP: Not actively developed    * eSMTP: Not actively developed according to home page   * mSMTP: Recommended in front of sSMTP at http://www.scottro.net/qnd/qnd-ssmtp.html   * nullmailer: Suggested by Gilles Even though eSMTP is not developed anymore, it seems to have the nicest documentation. It doesn't quite fit my needs though, at it seems to insist on delivering mail to local user `foo` via a Mail Delivery Agent (MDA) instead of pushing it out over smtp to `foo@some.domain`. Or maybe it does do the mapping if I add `qualify_domain` to the config. Might have to try it out...   nullmailer appears to be running a queue in `/var`, which is not something I want. Does anybody have experience with any of these?


"invoke-rc.d: initscript cups, action "start" failed." while configure cups

When I run `apt-get -f install`, I get the following abnormal output:               Setting up cups (1.5.0-8) ...     start: Job failed to start     invoke-rc.d: initscript cups, action "start" failed.     dpkg: error processing cups (--configure):      subprocess installed post-installation script returned error exit status 1     Errors were encountered while processing:      cups     E: Sub-process /usr/bin/dpkg returned an error code (1)      I'm running under **Ubuntu Oneiric Ocelot, x64**. I'm not sure where to start to debug this. I appreciate any suggestions any of you may have.


Understanding ls -l output

When I run `ls -lrt` command on a Unix folder , I get the following output               MyServer> ls -lrt     total 10     drwxr-x---   3 UnixUser  other        512 Jul 22  2011 FolderA     lrwxrwxrwx   1 UnixUser  other         42 Aug 23  2011 BEA -> ../../../Some/Folder/SOLARIS/BEA      I am not sure what are BEA and Perlx.x in these folders. They do not seem to be files nor folders. Why is there a arrow besides them pointing to somewhere else?


Reading passwords without showing on screen in Bash Scripts

How to read passwords in bash scripts in a way like tools which are not showing it on terminal ? (Changing font to black on black might be tricky by easy to copy&paste - so it's not solution)


USB hard drive boot problem

I have a HP Probook 4525s laptop with Windows 7 and Ubuntu installed on it and an external USB Toshiba hard disk(320GB); I've tried to install for several times various linux distros on the USB HD (Ubuntu, Backtrack, Suse 11, Scientific Linux) but I have problems booting it. The instalation went well but, when it comes to boot the external HD, everything stops to a dash blinking forever on a black background. I've tried changing the boot order and manually select the booting device but doesn't solve the problem. If I remove the external HD when the dash blinks, the laptop boots the internal HD and I get the ubuntu boot menu. I've tried booting from other computers and everything works fine, so it seems that my machine has a problem. What should I do in this case? Any suggestion may be useful.


How to restore folders to their original destination using duplicity?

After performing a backup of a couple of directories like so:               # duplicity\      --exclude /home/user/Documents/test1/file\      --include /home/user/Documents/test1\      --include /tmp/test2\      --exclude '**'\      / file:///home/user/Backup      I wanted to test how the restoration works by deleting the backed up directories:               # rm -rf /home/user/Documents/test1 /tmp/test2      And then, restoring the backup,               # duplicity file:///home/user/Backup /      But I got the error,               Restore destination directory / already exists.     Will not overwrite.      So it appears that I can't restore to the original destination without emptying the root folder even though the destination of these included folders have already been cleared. Is there a better way than to restore it to another location and then moving each folder one by one?               # duplicity --file-to-restore home/user/Documents/test1 file:///home/user/Backup /home/user/Restore1     # mv /home/user/Restore1/home/user/Documents/test1 /home/user/Documents/test1     # duplicity --file-to-restore tmp/test2 file:///home/user/Backup /home/user/Restore2     # mv /home/user/Restore2/tmp/test2 /tmp/test2


How to update Debian kernel to latest in backports

I have a machine running Debian stable, and I'd like to update the stock kernel to the latest kernel available in the backports repository. There are many kernel-related packages and virtual packages--what is the right way to do this and get the appropriate packages upgraded?


sed + remove the first directory from path

Please advise on how to remove the first directory from a path by `sed`, (the inverse pf what `basename` does). For example               echo "/mnt/VPfig/Amer/AR4/Celtel/files/COM.txt" | sed ...      I should get:               /VPfig/Amer/AR4/Celtel/files/COM.txt


Why is dnsmasq putting my router IP in /etc/resolv.conf instead of 127.0.0.1?

I'm having DNS resolution issues in various contexts which appear to trace back to my networking configuration. I'm running just the dnsmasq-base installation of dnsmasq on two Linux installations (Lubuntu 12.04 and 12.10). I haven't done anything in particular to configure dnsmasq, but I think some other changes I made previously may have lead to an incorrect configuration when upgrading. The working configuration on machine 'A' running 12.04 sets `/etc/resolv.conf` to use 127.0.1.1 (which in `/etc/hosts` is set to `$HOSTNAME`) On machine 'B' where certain applications such as OpenVPN experience DNS resolution issues, `/etc/resolv.conf` is set to 192.168.1.1, which is my gateway IP. Only certain applications are affected. Web-browsing, for example, works just fine. Any idea if this difference is the cause of the DNS resolution issues, and why 'B' is behaving differently? Edits: Both 'A' and 'B' are running dnsmasq, both are using DHCP to get DNS configuration, and I'm only using dnsmasq for DNS. There is no /etc/dnsmasq.conf file. I understand that this is normal when running just dnsmasq-base. The contents of /etc/resolvconf on the two machines appear to be identical. No extraneous/missing files. Sorry I can't be more specific about the nature of the problem. "DNS resolution issue" was the end-point of my discussion with technical support at my VPN provider.


Determine what device a directory is located on

If I do               # cd /     # ln -s /home test     # cd test     # mount --bind $PWD /mnt      the entry in `/proc/mounts` is               /dev/sda2 /mnt ext4 rw,noatime,data=ordered 0 0      which is the device that is mounted to `/home` and is not easily deducible from `$PWD` which is `/test`. How can I determine which device (i.e., /dev/sda2) is going to show up in `/proc/mounts` in general given that the bind mount may be to a directory/file that is potentially "obscured" by symlinks, other bind mounts, etc?


What disk is a file / directory stored on?

From the command line (bash) I would like to know what disk a given file is stored in. E.G.:               $ [what filesystem is this file in command] /tmp/example/file          /dev/sda1


Is creating a sparse image using dd appropriate for backup/restore from a RAID?

I have two non-networked servers, each with 1.2TB of storage in a RAID5 config on an LSI MegaRaid 9240-8i controller. I have been trying without success to get Symantec Ghost to image one machine to the other due to driver issues, and so I was wondering if it wouldn't be easier to boot from a Linux LiveCD, plug in an external hard disk and `dd` the RAID partition to the external disk. The 1.2TB partition only has around 10GB of data on it, so I hope to generate a sparse image file (to avoid having to find a 1.2TB USB disk!). I have seen people use the `seek` parameter of `dd` to achieve this - is that an appropriate way to create an image of around 10GB size in this situation? Even if this is a sensible way to generate a sparse image, is this a sensible way to mirror one RAID to another of identical configuration, or do the commercial utilities such as Ghost and Acronis do some 'magic' that `dd` does not?


My iptables works the opposite from what I wanted

I have this set of `iptables` rules ...               $ sudo iptables -n -L     Chain INPUT (policy ACCEPT)     target     prot opt source               destination     LOG        all  --  0.0.0.0/0            0.0.0.0/0           limit: avg 5/min bu     REJECT     tcp  --  192.168.1.134        0.0.0.0/0           tcp dpt:22 reject-w          Chain FORWARD (policy ACCEPT)     target     prot opt source               destination          Chain OUTPUT (policy ACCEPT)     target     prot opt source               destination      ... the above blocks 192.168.1.134 but it does not log attempts from 192.168.1.134. Instead connections from other clients are logged. I just want to log the dropped packets. What I want to do is log all dropped packets.


ajaxterm using proportional font

I have Ubuntu 14.04 LTS, Apache 2.4.7, Python 2.7.6 and Ajaxterm 0.10-12ubuntu1. Ajaxterm is proxied via Apache. Here's the apache.conf excerpt:               # Suppresses the Via header     ProxyVia Off     # Do not flood the log     #CustomLog /var/log/apache2/access.log combined env=!dontlog     #SetEnvIf Request_URI "^/ajaxterm/u" dontlog          ProxyRequests Off     <Proxy *>            Order deny,allow            Allow from all     </Proxy>          ProxyPass /ajaxterm/ http://localhost:8022/ retry=0     ProxyPassReverse /ajaxterm/ http://localhost:8022/ retry=0      When it was initially installed, Ajaxterm worked fine. Now, however, it uses a proportional font instead: ![Ajaxterm](http://i.stack.imgur.com/ab4Pv.png) I've uninstalled and reinstalled it, but I can't figure out what the problem is. No errors appear in the browser console or network inspector.


Give user permission to rm without password or sudo

I'm trying to give the `ubuntu` user on my machine the ability to `rm` folders and files (mainly in the `/www/` folder) without the need to invoke a password or the need to use `sudo`. I've been following this article and ended up trying this in my `sudoers` file.               ubuntu ALL = (ALL) NOPASSWD: /bin/rm      This unfortunately doesn't do the trick. Can anyone help me with the proper configuration?


Learning Linux for intermediate user

Here is my situation :   * I know how to compile some programs. I know how `make` and `gcc` works. I know `bash`.   * I am fairly comfortable with command-line.   * I know how it works in my computer for some programs. I am not satisfied. What I want to learn is this :   * I want to learn how programs really work, what really happens when I compile a program, which file gets copied in which directory, etc. I often find myself unable to successfully compile a program, so I end up using `apt-get` to install it. I find it to "magical" for me. I want to know what `apt-get` does to my computer.   * I want to learn where to find configuration files and how to edit them. Particularly, I want to learn how mime-types work. I want to know more about environment variables as well.   * In fact, I am looking for total control over my computer. I think installing Arch Linux would be a good thing, but I want to learn the above before. Can you show me a resource I can use which is not too technical at the same time? Do you have any suggestion, recommendation?


How to fix non-responsive Ubuntu system?

I use Ubuntu. Sometimes, the system does not have any response with mouse and keyboard. Is there any way to solve this problem except hitting the reset button on the machine?


SSH connections not accepted after configuring NFS?

I have a couple of servers in a VPC in Amazon EC2. One of them acts as a NFS server, and one of them as a client. I recently noticed a problem in the client that after a reboot, it would reject all SSH connections, presumably because SSH was not running. After transferring the EBS volume to another instance and taking a peek inside, I commented out the NFS line in `/etc/fstab` and tried attaching it back to the server and booting it. Lo and behold, I was able to connect with SSH. It seems that having the following line in my fstab is breaking everything on boot:               10.0.0.1:/export/share /mnt/shared nfs auto 0 0      Why is this causing SSH to fail to start? How can I have NFS automatically mount on boot without breaking networking/SSH on the system? I've checked that `sudo mount -a` works properly, so it seems that there isn't an inherent problem in the fstab command. What's breaking and how can I fix it?


Restart sound indicator in ubuntu

When the sound crashes, I can restart it with:               sudo alsa force-reload      However, that doesn't bring the sound indicator (system tray indicator) back. I am running Ubuntu 13.10 with LightDm.


Curious about strange ICMP type 3 code 10 traffic to my IP address

My firewall (`iptables`) logs some strange ICMP type 3 code 10 traffic that I am curious to understand (specifically how or if this could be an exploit of some sort). > Type 3 = Destination Unreachable   >  Code 10 = Communication with Destination Host is Administratively > Prohibited). The logged traffic (4-6 packets a few seconds apart, once a day for the last months): > **IN** =eth0 **OUT** = **MAC** = _(eth0 MAC)_ **SRC** = _(Foreign IP > address)_ **DST** = _(My IP address)_ **LEN** =72 **TOS** =0x00 **PREC** > =0x00 **TTL** =50 **ID** =35145 **PROTO** =ICMP **TYPE** =3 **CODE** =10 [ > **SRC** = _(My IP address)_ **DST** = _(Foreign IP address)_ **LEN** =44 > **TOS** =0x00 **PREC** =0x00 **TTL** =50 **ID** =0 **DF** **PROTO** =TCP > **SPT** =25 **DPT** =53454 **WINDOW** =28200 **RES** =0x00 **ACK** **SYN** > **URGP** =0] All logs indicate that _(Foreign IP address)_ only transmits the above ICMP packet.   No other traffic from _(Foreign IP address)_ is recorded in the same time period (see update below).   By default, the system logs and drops any traffic originating from the country of _(Foreign IP address)_. Could this be an exploit, perhaps to trick _(My IP address)_ into transmitting something to _(Foreign IP address)_ , assuming I did not drop the traffic by default? Any insights are welcome. **Update** : The logs show that _(Foreign IP address)_ consistently connects to port 80 and 443 prior to the ICMP packets (9 and 7 hours before the ICMP packets, respectively). Both attempts dropped by the default firewall policy.   According to Network-Tools.com the origin of _(Foreign IP address)_ is China(CN) in region Southern and Eastern Asia, and no host name is associated with the IP address.


Cube not working in Fedora 20 KDE

When I switch desktops on my Fedora 20 system, with the "desktop cube" it doesn't work. Instead of showing the cube effect, it displays briefly LibreOffice with an open document which I closed 10 minutes ago, and then it displays the selected desktop. I have 4 active desktops. Libreoffice does not show up in running processes. Also when the system has turned off the display when Idle and resuming, the screen is frozen and the cube doesn't work, not until I select a different desktop does the cube work and the screen is active. What is happening here and how to resolve it?


How do I find out what filesystem drivers are compiled-in into the linux kernel?

On a running linux system, what is a portable (among linux distributions) way to find out what filesystems the current kernel has compiled-in (not through modules) support for? Consider for example my current Ubuntu x86_64 kernel: `3.11.0-24-generic #41-Ubuntu`. It has for instance no `/proc/config.gz`, which would be my first thought otherwise. The reason I'm interested is that I'd like to (programmatically) build a rescue environment with the current kernel and an initial ramdisk that the kernel will be able to load/mount. **Is is as simple as comparing** `/proc/filesystems` **with** `lsmod` **?** If so: Do the modules always have the exact same name (first column from `lsmod` output) as the filesystem name (last column in `/proc/filesystems`)? Is there perhaps a more modern way such as `/sys` instead of `/proc` to look for info? My current approach is as follows. Can someone confirm that it is correct, or advise how to do it instead?:               for fscand in $(awk '{print $NF}' /proc/filesystems)     do       if test $(lsmod | grep -c -e '^'${fscand}'[^a-z0-9_-]') -eq 0       then         candlist="${fscand} ${candlist}"       fi     done          for fscand in $candlist     do       echo $fscand is compiled-in     done


How do I shut down ports remotely without shutting myself out?

I have an Ubuntu 11.04 server in a remote location on another continent, so I have no physical access to it. I only interact with it by `ssh` (and `scp`), and intend to only ever interact with it that way. For security purposes, I want to ensure that absolutely all ports on the server are closed, except for `ssh`. My understanding is still vague, despite having tried to find instructions on the web. What I've gathered so far is that I need to "flush" the "iptables", and also that I need to edit some files (`/etc/hosts`, maybe?), and reboot the machine. Obviously, though, I want to be very careful about this, because if I do it wrong, I could end up accidentally shutting down the ssh port, making the server inaccessible to me. If that happens, I have to go to the server administrator, who will reinstall the server, and make fun of me in the process. I'm not a server admin guru by any stretch, so I'm looking to establish a fool proof set of steps before I do this. So, how do I shut down all ports while still preserving my access? _**Bonus question:_** While doing this, should I, and can I, change the `ssh` port from 22 to a non-standard one? Does it really make a difference?


Is Windows Linux based

Is Windows Linux based? Because I cannot find a stack exchange site for Windows. If there is not sit for Windows can anybody explain how to request a site.


crontab sets up user variable, redirect output, and detect connetcted network

I have three problem, all of them are about crontab.   1. Can I access `$HOME` variable in crontab ? for example, use `$HOME` like this: `PATH=$HOME/bin:$HOME/scripts:$PATH` ? or `* * * * * echo "test" > $HOME/test.txt` ?   2. I want let crontab redirect normal `stdout` to `/dev/null`, but mail `stderr` to user. For example, when computer is **not** connected to network, then an entry in crontab like `* 2 * * * getmail -n -q ...` will return error, so crontab will send email to user with this error.   3. based on upper example, `getmail` will let crontab mail user when system is **not** connected to network, so I want a method to detect whether user is connected to network. About this method of detecting, it should has bellowing:   1. fast   2. simple   3. easy to combine with other crontab jobs, (like use control: &&, ||, | etc)


Repeatably generate a read error for testing?

I'm trying to test the error handling in some software, in particular what happens when an error occurs reading from a file or pipe. Is there a simple way to send a certain amount of data to stdout and then generate an I/O error? (I.e., the process doing the reading would see read(2) return -1.) A simple shell recipe would be great, but I don't mind writing code if that's the only way.


How to view traffic over a forwarded ssh port?

It is possible to setup an SSH port forward where the ssh client prints out the traffic exchanged over the ssh port to the screen or a file. I am trying to debug a problem and want to see what is being sent between a java process running on my local machine and a remote process running on Solaris. I am using the port forwarding via ssh so that i can step through the java program. Normally I would have to copy the .java files to the Solaris machine, build them and run and it is not very productive way to debug, thus the port forwarding. The client and server as using IIOP protocol so I can't use an http proxy to monitor the traffic.


Gives access to root user for a period of time

I want to know if it's possible to give access to root user for one week or a month, for example. It's possible to increase the period of time before the defined period ends? Is it possible to give access without time limitation, forever?


How to fake the source-port of a TCP packet?

Is there an easy way (or is it possible at all) to rewrite a TCP packet as it leaves the machine?   For example if I run               telnet binfalse.de 22      it will search for an unused port to leave the machine. In this case it's `46576`:               root@srv % lsof -i -P -n | grep telnet     telnet    10150   user    3u  IPv4 1159425      0t0  TCP 1.2.3.4:46576->87.118.88.39:22 (ESTABLISHED)      But now I want to rewrite these packets to let the server think the requests came from port `1337`, or somewhat like this. Of course I know that I don't have to expect an answer in my `telnet` session. **EDIT:**   Of course on `1337` another program is listening, so telling `telnet` to speak through `1337` is no option...


Output of command not in stderr nor stdout

I've stumbled on this issue, so I'm wondering how is this possible? Standard run of command:               # zabbix_sender -c zabbix_agentd.conf -k mmysql.QCInserts -o 14     info from server: "Processed 0 Failed 1 Total 1 Seconds spent 0.000017"     sent: 1; skipped: 0; total: 1 OK, lets try to get the first line only:               # zabbix_sender -c zabbix_agentd.conf -k mmysql.QCInserts -o 14 | head -1     sent: 1; skipped: 0; total: 1 What about standard head?               # zabbix_sender -c zabbix_agentd.conf -k mmysql.QCInserts -o 14 | head      sent: 1; skipped: 0; total: 1 Inverse grep? sed? tee?!?!?!!?               # zabbix_sender -c zabbix_agentd.conf -k mmysql.QCInserts -o 14 | grep -v pero     sent: 1; skipped: 0; total: 1          # zabbix_sender -c zabbix_agentd.conf -k mmysql.QCInserts -o 14 | sed 's/foo/bar/'     sent: 1; skipped: 0; total: 1          # zabbix_sender -c zabbix_agentd.conf -k mmysql.QCInserts -o 14 | tee     sent: 1; skipped: 0; total: 1 stderr to stdout?               # zabbix_sender -c zabbix_agentd.conf -k mmysql.QCInserts -o 14 2>&1 | tee     sent: 1; skipped: 0; total: 1 I'm really puzzled...


Finding the right diplay driver for arch installation on a virtual box on Lenovo edge13''

I'm checking arch on a virtualbox (running on ubuntu) before I install it on my machine. I have followed the wiki up until the display driver section. lspci gives: > VGA compatible controller: InnoTek Systemberatung GmbH Virtual Graphics > Adapter I assume this is some sort of virtualbox compatible layer, is there a way to by pass it and test my real display driver (intel of some kind) on the virtual box?


How do I authenticate to a wireless provider's "open" network without using a browser?

This sort of a setup seems to be common in shopping malls and airports. In Western Canada Shaw provides such a service and calls it "Shaw Open". I'm pretty sure other locales have similar services from providers such as T-Mobile, etc. From something such as a cell phone it's not very complicated to do. No authentication is necessary to connect to the wifi hotspot as it is "open" for public access. But my cell phone won't connect to websites or remote services via apps **until I use my browser and sign in to a particular webpage provided by the ISP**. My question simply stated is: **How do I automate the authentication step from a device that doesn't typically have a traditional browser?** I have, in my particular case, a raspberry Pi configured with software that I want to use at trade shows etc. Theses locations have the same sort of "open" hotspots. The Raspi is meant to be self contained. It just does its business and talks to a website. But this outbound connection is blocked by the ISPs "open" connection because I haven't, nor can I complete the browser part of the process. Assuming I have credentials to do this on a particular provider's network, **how can I automate that part of the process without requiring me to open a terminal session to the Pi?** What kind of technology is even used here, that I can search for?


How to access network without NetworkManager in Fedora 15?

I am running Fedora 15 on VirtualBox 4 and I am failing to reach the internet:               $ ping 8.8.8.8     connect: Network is unreachable      Firefox also refuses, telling me "Server not found". Running `sudo service network restart` and restarting the VM didn't help.


Should my /usr/local/bin be 700 permissions?

I just installed npm and node.js, and I couldn't access `npm`. And I'm like "why?" and my OS is like "because /usr/local/bin is at 700 permissions" and I'm like "should it really be that way?" /usr/local is supposed to be .. the local user's bin folder? Then why does it require root access? It is filled with GAE stuff. Maybe Google App Engine changed it, I don't know.


Batch copying/moving files in unix?

Is there a way to batch copy/move files in unix? I thought it might be an option for `cp/mv` but I can't find any way to do it.


List iptables rules as append command

A while back I was watching over the shoulder of a Linux guru and he issued a command that listed all the iptables rules in the format of the append commands you would need to issue in order to build them, but despite all my googling and man page searching I can't figure out what he did. For example if the output from `iptables -nL INPUT` was:               Chain INPUT (policy DROP)     num  target     prot opt source               destination     1    ACCEPT     tcp  --  0.0.0.0/0            192.168.0.1           tcp dpt:80      The output from the command I'm looking for would be something like:               1  -A INPUT -i eth0 -p tcp --dport 80 -d 192.168.0.1 -j ACCEPT      I seem to remember that it was just another option passed into the standard `iptables -L` command, but I could be wrong. Does anyone know of a command to accomplish this?


Capture output of a bash command, parse it and store into different bash variables

**Explanation:** I have a small _bash_ script which simply runs _any_ Linux command (e.g. say `ifconfig`) The typical output of _ifconfig_ is something like this:               eth0      Link encap:Ethernet  HWaddr 30:F7:0D:6D:34:CA               inet addr:10.106.145.12  Bcast:10.106.145.255  Mask:255.255.255.0               inet6 addr: fe80::32f7:dff:fe6d:34ca/64 Scope:Link               UP BROADCAST RUNNING MULTICAST  MTU:1500  Metric:1               RX packets:1104666 errors:0 dropped:0 overruns:0 frame:0               TX packets:2171 errors:0 dropped:0 overruns:0 carrier:0               collisions:0 txqueuelen:1000               RX bytes:444437904 (423.8 MiB)  TX bytes:238380 (232.7 KiB)          lo        Link encap:Local Loopback                inet addr:127.0.0.1  Mask:255.255.0.0               inet6 addr: ::1/128 Scope:Host               UP LOOPBACK RUNNING  MTU:16436  Metric:1               RX packets:15900 errors:0 dropped:0 overruns:0 frame:0               TX packets:15900 errors:0 dropped:0 overruns:0 carrier:0               collisions:0 txqueuelen:0               RX bytes:467306 (456.3 KiB)  TX bytes:467306 (456.3 KiB)      Now what most people usually do is store the _entire_ output into a file/variable and parse based on that. I however want to know if there is anyway that I could put _specific_ parts of the output in more than one variable (say a _bash variable_ called `${IPETH0}` to carry the IP address `10.106.145.12` from _eth0_ and `${IPLO}` to carry the IP address `127.0.0.1` from _lo_ in the above example _without running ifconfig command twice_ ). Something like what _tee_ command does with the input but I want to do this for the _output_ and store the output into 2 or _more_ variables in one go. Any ideas?


How do I generate a list of the characters occurring before a certain character only in lines that contain another certain character using regex?

I know that's super confusing (total noob-sorry!). To clarify, I have a text file that looks like this:               407-OL?     408-2-OL?     408-OL?     418-het?     420-1 and 2- OL?     429-2-left unscored?     430-2-left both unscored?     431-1 and 2- Ri??     436-1-just homozygote?     444-2-het? ins. both     456-2-ins 246 despite slight OL     456-1-ins 245 (weaker)     457-2-Ri?      I want it to return the numbers on the left (before the dash), but only for lines that contain a question mark. In other words, I want this to be the output:               407     408     408     418     420     429     430     431     436     444     457      Any suggestions would be amazingly helpful! Thank you!


Command to 're-apply' previous command?

Is there an easy way to re-apply a previous command to a new command line entry? Say I typed in `chmod u+r,g+x file.txt` but forgot the sudo. Could I simply type `sudo <some easy symbol>`'? Pardon for the possible noob question.


LD_PRELOAD or similar to prevent network access

I'd like to start a program disconnected from the network (because immediately upon starting it tries to download huge amounts of data, which can be prevented by changing settings as soon as it settles down). However, I really don't want to actually _bring the network down_ for this one program. Is there some LD_PRELOAD or similar to give the program the impression that the network is down? I'd rather not create a virtual machine.


How can I redirect outbound traffic to port 80 using iptables locally?

I'm trying to locally redirect ports on my Ubuntu machine using `iptables`. Similar to transparent proxying. I want to catch anything trying to leave my system on port 80 and redirect it to a remote host and port. Can I achieve this using the NAT and pre-routing functions of `iptables`?


How to add a path to system $PATH for all users's non-login shell for debian

After installing some programs in `/opt/xxx/bin`, I want to add `/opt/xxx/bin` to system `$PATH` for all users's non-login shell. What should I do?


Failure to startx on Ubuntu 14.04 after security update - missing libXfont.so.1

I had Ubuntu 14.04 running perfectly on my system and then it underwent a recommended security update. I let it update while I was at work and when I returned I found a black screen stating, "No init found" and "mount: mounting /dev/mapper/ubuntu-root on /root failed: Invalid argument". I followed some guides and ran the following commands:               ls /dev/sd*     sudo apt-get install lvm2     sudo pvscan     sudo vgscan     sudo vgchange -a y ubuntu-vg     sudo fsck /dev/ubuntu-vg/root      After running those commands and rebooting, my Linux system was back up and running again; however, not quite like it was before. It starts up into command line mode (without GUI) and asks for my username and password. When I log in and try "startx" I get the following:               user@home-pc:~$ startx     xauth:  timeout in locking authority file /home/user/.Xauthority     xauth:  timeout in locking authority file /home/user/.Xauthority          /usr/bin/X: error while loading shared libraries: libXfont.so.1: cannot open shared object file: No such file or directory     xinit: giving up     xinit: unable to connect to X server: Connection refused     xinit: server error     xauth:  timeout in locking authority file /home/user/.Xauthority     user@home-pc:~$       I get the same message when I try "sudo startx". I believe this error is due to the symbolic link that is used to identify the "libXfont.so.1" file, but I don't know how to fix this problem. I already tried running "sudo apt-get update && sudo-apt-get dist-upgrade" in hopes that this would fix or finish the upgrade and/or installing of the security update, but this didn't fix the problem. Does anyone have any idea on what is going on or how I can fix this?


How to make `sudo` preserve $PATH?

I need to run a program installed on /opt/godi/sbin (a custom directory). If I add that directory to my PATH, by adding the following line to my .bashrc file               export PATH=$PATH:/opt/godi/bin:/opt/godi/sbin      then I can try to run the command just fine (except that it fails because it needs sudo). However, when I try to use sudo:               sudo godi_console      I get the following error               sudo: godi_console: command not found      Inspecting the PATH variable after using sudo reveals that its not including the same PATH I have as a normal user:               $ sudo sh     # echo $PATH                      /usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin      Why is the PATH not the same? Am I doing something wrong? I'm on Debian Jessie and unfortunately I cannot get around the issue by passing sudo the the absolute link to godi_console because godi_console itself also depends on the PATH being correctly set.


is there something like a per-user daemon?

I need to run some background processes that live as long as I am logged in with a certain user. Does there exist something like a per-user daemon? I know only of global daemons that live from computer startup 'till shutdown (or manual startup/kill). for now I made a script that checks if the process already exists and creates the process if it doesn't. This script is then run with the `nohup` command from my `.profile`. This way the process launches on startup, and is only launched once (even with multiple `rxvt` terms coming and going). Yet, it never gets killed after I log (which isn't a disaster but it is cleaner to also terminate the process).


Reorder fields/characters with cut command

> **Possible Duplicate:**   >  Combining 2 different cut outputs in a single command? I have One file - temp.txt - which contains               ABCDF          PQRST          LMNOP      I tried this `cut` command               $ cut -c 2-5 temp.txt     BCDF          QRST          MNOP      output is right.               $ cut -c 1,2,3,4 temp.txt     ABCD          PQRS          LMNO      output is right. But when I change sequence, meaning               $ cut -c 2-4,1 temp.txt     ABCD          PQRS          LMNO      above output displayed. but logically output is               BCDA          QRSP          MNOL      so my question is how this happen ,any reason behind that.


Is it safe to pipe the stdout of A to B in parallel

I'm running `A file | B --params > file.txt`. Since I want to accelerate the processing speed, I used the `parallel -j+0< a.txt` to run 20 jobs concurrently. a.txt contains all the commands:               A file1 | B --params > file1.txt           A file2 | B --params > file2.txt          A fileN | B --params > fileN.txt      Is this way safe? Will the stdout from different programs be messed when running in parallel?


How do I create an RPM package that would fail a YUM transaction if certain creteria are met

I'm trying to package a product consisting of many packages. I'm successful with writing all the spec files, the dependencies between the packages and so on. They're all installed and work fine. The one thing I do not succeed to do, is to run a pre-requisition test: In certain cases, I would like the packages not to be installed at all, and the user getting an error, explaining him what he needs to fix first, before he runs the packages installation. For example: I want to verify that the user is running in runlevel 3, and if not, abort the whole installation, and ask the user to re-install CentOS in "Minimal" profile - as I don't want all the extra packages that comes with "Desktop". (This is just an example, I have a few such tests to perform). The way I approached this problem is this: I've created a sort of 'meta package', that its name appears in all the other packages 'Requires:' directive, so it would be installed first by YUM, and in that package spec file, in the `%pre` section, I did the various tests I wanted to perform, outputting test errors when applicable, and then '`exit 1`'. The reason I chose this approach is this: "If every package depends on this package, and this package cannot be installed, the transaction must fail, as soon as the package manager wants to install a package that depends on a package that failed installation... after all, the dependency has not been met". In Gentoo, for example, if a package fails installation, for whatever reason, emerge stops completely - even not for dependency issues; And there's a special flag to tell emerge to continue despite the error returned from one of the packages. The problem is that indeed the package fails when the tests fails (RPM specifically says that it returned code 1), BUT... YUM doesn't really seem to care that this happens - and just continues to install everything else, including packages that depend on a package that is not installed (!). At the very end, it simply reports that all the packages were installed successfully, expect for the package that deliberately failed... I'm guessing that the reason for that is that dependency checking happens before the transaction begins, and indeed, dependencies are met from the various repositories at YUM's disposal. Still, it does not make any sense to me that if a dependency eventually failed, the installation of dependent packages would continue. Is my logic flawed? I doubt it's a bug, as someone would have encountered it by now (this is on CentOS 6.3 if it matters...) - but all my Google-foo yielded nothing. I didn't even find someone asking the same question... maybe I'm using the wrong keywords? Am I approaching this wrong way? Any other idea (that fits into RPM specs or other YUM repository magic, even at the YUM .repo file... - but all contained within the YUM infrastructure, without external scripts to run before 'yum install') - would be greatly appreciated!


Need further explanation on TIME_WAIT

Hi Unix/Linux Gurus out there! I need a solid proof that TIME_WAIT (a lot of it actually) is the real culprit in the slowdown in one of our servers. The server is hosted on Parallels Baremetal virtualization, and the actual server is a VM: CentOS5 with dual CPU and 2GB RAM. A week ago, we started to notice that it was too slow that even doing an 'ls' on a directory with just a few files in there (around 20) would need around 1.5 seconds to display the results. I tried doing `vmstat` but it doesn't seem to be even using it's swap. No bottlenecks on the network. But running `top`, you'd see java mostly hogging the resource. Java is needed since this VM is our hudson server. One of my colleagues tried checking the connections via               $ vmstat -vatpno      And noticed that there where a lot of connections in TIME_WAIT...around 300+. So we tried applying some of the recommendations in this page particularly that of TCP_FIN_TIMEOUT, TCP_KEEPALIVE_INTERVAL & TCP_KEEPALIVE_PROBES. The connections in TIME_WAIT went lower but still fluctuates between 220 to 280(maybe due to the fact that a new connection is added from time to time and other connections in TIME_WAIT is not yet "timed-out"). Perhaps we could try adding TCP_TW_RECYCLE & TCP_TW_REUSE later when we don't see any improvement. Now going back to my main question: is there a solid evidence that a lot of TIME_WAIT'ed connections eat up a lot of RAM? Thanks in advance.


Create ssh user which can only access home directory

I read documentation on the internet on how to create a new user with SSH access. I figured it out and to create a user is quite simple. The next step I want to take is to jail this ssh server to the `/home/` directory on my machine. It needs the permission to write/create folder/files in directories of other users (CMS system). How can I implement this?


Recursively Gziping Files (and keep original files) & Gziping Text Input

I need Gzip to pre-zip some static files for a webserver I'm building. All of the files I need to gzip will be in a folder named `.cache`. Since some clients may not accept responses that are gzipped, I would like to keep all of the original files when I gzip them. Is there any command I can use to recursively gzip the files in my `.cache` folder while still keeping the original files? Will this command gzip gzipped files (ones that are postfixed with .gz already) if run on a folder with already gzipped files? While we're on the topic of gzip: I've been looking for a way to gzip text input passed to gzip instead of files. I came up with postfixing a dash on the command (like `gzip -c -`), but I'm not sure if that will work or how I use it. Can anyone explain?


Replacing/disabling plasma desktop/wallpaper?

I'm looking for a way to replace Plasma's wallpaper (desktop?) with Compiz's (or traditional). I'm running Compiz + Emerald as WM, and this disables the ability to have different activities on different virtual desktops at all, so this is the only way to have different wallpapers on each one. I noticed on Compiz's site, it suggests using wallpapercolor= 0,0,0,0 , but I'm running 4.8 and doubt this will work. I would switch to Gnome, as I had this working on it before, but I'm not a fan of Gnome3. Any help is appreciated.


Configure Clock on different port other than port 80 in CentOS

I installed CentOS 6.4 & noticed that port 80 is being used by Clock application               [root@l-22733-p11 logs]# lsof -i tcp:80     COMMAND     PID      USER   FD   TYPE DEVICE SIZE/OFF NODE NAME     clock-app 10418 jack   21u  IPv4 408998      0t0  TCP l-22733-p11.abc.com:51095->a23-3-105-136.deploy.akamaitechnologies.com:http (CLOSE_WAIT)     clock-app 20477 jack   21u  IPv4 408354      0t0  TCP l-22733-p11.abc.com:51088->a23-3-105-136.deploy.akamaitechnologies.com:http (ESTABLISHED)      If I kill these processes, then the clock gets killed. How can I configure this clock to run on different port than port 80? This issue was not present with earlier version of CentOS. I want to run the Tomcat server on port 80 & it is giving me bind exception since clock is running on port 80.


yum is not working

[root@localhost ~]# yum install percona     Loaded plugins: rhnplugin     Bad id for repo: not installed, byte =   3     This system is not registered with RHN.     RHN support will be disabled.     YumRepo Error: All mirror URLs are not using ftp, http[s] or file.      Eg. 6Server.10 is not a valid release or hasnt been released yet/     http://mirror.centos.org/centos/6Server.10/addons/i386/repodata/repomd.xml: [Errno 14] HTTP Error 404 : http://mirror.centos.org/centos/6Server.10/addons/i386/repodata/repomd.xml      Trying other mirror.     Error: Cannot retrieve repository metadata (repomd.xml) for repository: addons. Please verify its path and try again     You have new mail in /var/spool/mail/root