How can I run a script immediately after connecting via SSH?

_I started to ask this question but answered it while I had it open. I'm going to post this question, follow it up with my solution and leave it open to other potential solutions._ **`<`backstory`>`** I'm a tmux and vim user. I like remote vim work as I don't have to worry about Ubuntu development machines kirking out when a flash movie gives me a kernel panic. Running tmux means that open files are waiting for me after I reboot and I can carry on from where I left off. I've had problems with vim running in a tmux session when I connect like so:               ssh example.com -t 'tmux attach'      UTF-8 issues crop up that don't crop up when shelling in normally and just attaching to a tmux session manually. **`<`/backstory`>`** So I want a reusable method of starting something on ssh login, that doesn't affect any of the other things I have configured in my `.zshrc` (or your `.bashrc` if you still use bash) that may be required for my development environment, that doesn't appear when I'm occasionally working locally on the very said machine.


variables in crontab

On our linux server we have a lot of entries. Many entries look like this:               15 13 * * 3 /very/long/path/to/binary/run.sh ...      These entries would be easier to maintain if I could write:               15 13 * * 3 $FPATH/run.sh      Where could I write this mapping:               FPATH=/very/long/path/to/binary


What's the purpose of the randomart image for user (not host) SSH keys?

The `ssh-keygen` generates the following output:               The key fingerprint is:     dd:e7:25:b3:e2:5b:d9:f0:25:28:9d:50:a2:c9:44:97 user@machine     The key's randomart image is:     +--[ RSA 2048]----+     |       .o o..    |     |       o +Eo     |     |        + .      |     |         . + o   |     |        S o = * o|     |           . o @.|     |            . = o|     |           . o   |     |            o.   |     +-----------------+      What is the purpose of this image, does it provide any value for the user? Note this is a client (user) key, not a host key.


Display the number of bytes, words and lines in a file

I want to create a shell script `df`. As, I want to type in `df name_of_file` and then I can get the contents of the file. If the file name is in the directory, I want it to show its contents. If not, I want to show the size in words, lines, and bytes. How do I go about this? So far, I have this:               #!/bin/bash     FILENAME=$FILENAME     FILEBYTES=$(stat -c%s "$FILENAME")     FILEWORDS=$(stat -w%s "$FILENAME")     FILELINES=$(stat -l%s "$FILENAME")     echo "Size of $FILENAME in bytes = $FILEBYTES  bytes, $FILEWORDS words, $FILELINES lines."


Maximize xterm via bash script

I have found this answer providing how to manipulate the current xterm window's dimensions, ie:               echo -ne "\e[8;30;30t"      How can I modify this to maximize the window (xterm's `alt` + `enter` shortcut)? Also, where do I find more info on these xterm command line modifiers? **UPDATE:** See multiple solutions below for both maximize and full screen (without title and borders)


How to use regex with AWK for string replacement?

Suppose there is some text from a file:               (bookmarks     ("Chapter 1 Introduction 1" "#1"     ("1.1 Problem Statement and Basic Definitions 23" "#2")     ("Exercises 31" "#30")     ("Notes and References 42" "#34"))     )      I want to add 11 to each number followed by a `"` in each line if there is one, ie               (bookmarks     ("Chapter 1 Introduction 12" "#12"     ("1.1 Problem Statement and Basic Definitions 34" "#13")     ("Exercises 42" "#41")     ("Notes and References 53" "#45"))     )      Here is my solution by using GNU AWK and regex:               awk -F'#' 'NF>1{gsub(/"(\d+)\""/, "\1+11\"")}'      i.e., I want to replace `(\d+)\"` with `\1+10\"`, where `\1` is the group representing `(\d+)`. But it doesn't work. How can I make it work? If gawk is not the best solution, what else can be used?


OpenSuse custom keyboard shortcuts not working

Note: This question is specifically on a clean install of OpenSuse 11.3 with gnome as the display/desktop manager I can't get custom keyboard shortcuts to work, default shortcuts are working properly, but the ones I changed I can only get one of them to work, I'm using the "windows key" to match functionality of Windows 7 for a few keys like maximize window (winkey+up), minimize window (winkey+down), etc; none of them work; for the record **I did the exact same thing in Ubuntu and it worked without any problems.** additional info: I also noticed that gnome-do by default uses a key that I had assigned (winkey+space) and it "wins" (runs gnome-do) over the custom global key I had assigned (show main menu), actually, I can change the key in gnome- do to another that I have in the keyboard shortcuts, and the gnome-do works; this just makes me wonder if there are other applications that are disabling the usage of the "winkey" update: I also tried using gconf-editor apps/metacity, adding the keys there, still no luck, I tried _Windows_ , _Super_ , _Mod4_ for the WinKey name, none worked In some apps it seems the WinKey is completely ignored, i.e. it performs the action associated to the key without the WinKey, though, like I said before, there's one or two custom WinKey+SomeKey that ARE working (changed them to something else, stopped working, changed it back, worked again) Found this article from 2006 that sounds very much like the problem I'm having, though I followed the steps to fix it but didn't work for me > There seems to be a bug in Gnome / Metacity / X somewhere that means you > can't use SUPER_L or SUPER_R (the left and right windows keys on a keyboard) > with gnome system commands such as "Lock Screen". another thread of the same issue I'm having I've been reading linux forums, it seems this might a be a bug on recent OpenSuse releases: Many actions do not work with shortcuts in 11.3 Changing the Keyboard shortcuts in System->personal->Keyboard Shortcuts does not seem to be working. and several others


regex matching with "locate"

I'm trying to use the locate command to find files in my home folder, however whenever I try and run this I get no results:               locate -i -l 4 --regexp '^\/home\/jack\/[A-Za-z0-9\/\ ]*(My.)*$'      I've also tried `^\/home\/jack\/^(?!\\.)[A-Za-z0-9\/\ ]*(My.)*$` but that returns no results either. The file I'm looking for just to test it is `/home/jack/Music/Foals/My Number.flac` I would like to exclude the results of hidden files from my search.


ssh -X foo@host then su bar then run X app with local display, while bar also logged in?

I want to `ssh` into another machine, using one user account, then `su` to another user and run X programs as that user, with the display on my computer. The case when the 2nd user is not logged in to X is nicely covered by another question, but what when the other user _is_ logged in? That answer suggests you copy the `.Xauthority` file, created by `ssh -X`, in the first user's home dir, to the `su`-ed to user. However, when they are logged in, they already have an `.Xauthority` file and presumably they won't like me overwriting that... So is this possible?


flash live media encoder Linux

Apparently there is no way of installing Adobe media encoder for Linux unless you use "Wine" which I'm not about to do because seems very messy option. Does anyone know of any other open source live media encoders that will install on Linux and play H.264 codec?


What values from debconf-get-selections should not be preseeded?

I want to replicate the Debian installation choices made for my system's current configuration in the installation of a new system. Debian can be pre-configured through a "pre-configuration" (aka "preseed") file, which basically contains the answers to the questions the installer will ask. The documentation states that one way to create a preconfiguration file from an existing installation of Debian is to: > ...use the `debconf-get-selections` from the debconf-utils package to dump > both the debconf database and the installer's cdebconf database to a single > file: > > `$ debconf-get-selections --installer > file`   >  `$ debconf-get-selections >> file` But it then immediately adds: > However, a file generated in this manner will have some items that should > not be preseeded... The documentation does not elaborate on what those items-that-should-not-be- preseeded would be. Could someone elaborate? * * * By way of illustration, below I include the second field of the output I get from the two commands above, where I've kept only the lines that begin with `d-i`, along with the comments, sometimes truncated for brevity. (The reason for keeping only the configuration lines that begin with `d-i` is that in the example pre-configuration file provided by Debian, only such lines appear.)               # Check the integrity of another CD-ROM?     cdrom-checker/nextcd          # Web server started, but network not running     save-logs/no_network          # for internal use only     debian-installer/consoledisplay          debian-installer/shell-plugin          # Country, territory or area:     # Choices: Antigua and Barbuda, Australia, Botswana, Canada, ...     localechooser/shortlist          # for internal use; can be preseeded     preseed/include_command          # Country of origin for the keyboard:     # Choices:      keyboard-configuration/layout          # Choices: Canada, Mexico, Saint Pierre and Miquelon, United ...     localechooser/countrylist/North_America          # Choices: Greece, Cyprus, other     localechooser/shortlist/el          # Keyboard layout:     # Choices:      keyboard-configuration/variant          # Choices: Algeria, Angola, Benin, Botswana, Burkina Faso, Bu...     localechooser/countrylist/Africa          # Choices: Finland, Sweden, other     localechooser/shortlist/sv          # Keep default keyboard options ()?     keyboard-configuration/unsupported_options          # Choices: Cyprus, Turkey, other     localechooser/shortlist/tr          # Interactive shell     di-utils-shell/do-shell          # for internal use only     # Choices: stable, testing, unstable     cdrom/suite          # Choose an installation step:     # Choices:      debian-installer/missing-provide          # Check CD-ROM integrity?     cdrom-checker/start          # Failed to retrieve the preconfiguration file     preseed/retrieve_error          # Directory in which to save debug logs:     save-logs/directory          # for internal use only     debconf/showold          # Failed to open checksum file     cdrom-checker/md5file_failed          # Choices: Andorra, Spain, France, Italy, other     localechooser/shortlist/ca          # Write the changes to the storage devices and configure RAID...     partman-md/confirm_nooverwrite          # PCMCIA resource range options:     hw-detect/pcmcia_resources          # Failed to mount the floppy     save-logs/floppy_mount_failed          # for internal use only     debconf/language          # Choices: China, Singapore, Taiwan, Hong Kong, other     localechooser/shortlist/zh_TW          # Dummy template for preseeding unavailable questions     debian-installer/dummy          # Additional parameters for module :     hw-detect/retry_params          # Incorrect CD-ROM detected     cdrom-detect/wrong-cd          # for internal use; can be preseeded     cdrom-detect/eject          # Choices: Argentina, Bolivia, Chile, Colombia, Costa Rica, E...     localechooser/shortlist/es          # for internal use; can be preseeded     preseed/run          # Write the changes to disks and configure LVM?     partman-lvm/confirm_nooverwrite          # Cannot save logs     save-logs/bad_directory          # Choices: Belgium, Canada, France, Luxembourg, Switzerland, ...     localechooser/shortlist/fr          # Insufficient memory     lowmem/insufficient          # for internal use     keyboard-configuration/optionscode          # Choices: China, Taiwan, Singapore, Hong Kong, other     localechooser/shortlist/zh_CN          # Load missing firmware from removable media?     hw-detect/load_firmware          # Choices: Italy, Switzerland, other     localechooser/shortlist/it          # Choices: Antarctica     localechooser/countrylist/Antarctica          # Choose the next step in the install process:     # Choices: Choose language, Configure the speech synthesizer ...     debian-installer/main-menu          # Failed to load installer component     anna/install_failed          # Choices: Russian Federation, Ukraine, other     localechooser/shortlist/ru          # for internal use     keyboard-configuration/modelcode          # Entering low memory mode     lowmem/low          # Choices: Jordan, United Arab Emirates, Bahrain, Algeria, Sy...     localechooser/shortlist/ar          # Keep current keyboard options in the configuration file?     keyboard-configuration/unsupported_config_options          # Choices: Antigua and Barbuda, Australia, Botswana, Canada, ...     localechooser/shortlist/en          # Method for toggling between national and Latin mode:     # Choices: Caps Lock, Right Alt (AltGr), Right Control, Right...     keyboard-configuration/toggle          # for internal use only     anna/retriever          # Choices: Curaçao     localechooser/countrylist/other          # Choices: Albania, Andorra, Armenia, Austria, Azerbaijan, Be...     localechooser/countrylist/Europe          # locale     localechooser/help/locale          # Load CD-ROM drivers from removable media?     cdrom-detect/load_media          # for internal use; can be preseeded     debian-installer/framebuffer          # for internal use     espeakup/voice          # for internal use; can be preseeded     preseed/include          # Error reading Release file     cdrom-detect/no-release          # Ignore questions with a priority less than:     # Choices: critical, high, medium, low     debconf/priority          # Key to function as AltGr:     # Choices: The default for the keyboard layout, No AltGr key,...     keyboard-configuration/altgr          # CD-ROM detected     cdrom-detect/success          # Choices: Bouvet Island, Falkland Islands (Malvinas), Saint ...     localechooser/countrylist/Atlantic_Ocean          # Continue the install without loading kernel modules?     anna/no_kernel_modules          # for internal use; can be preseeded     debian-installer/exit/poweroff          # Choices: Bangladesh, India, other     localechooser/shortlist/bn          # for internal use; can be preseeded     preseed/include/checksum          # Integrity test failed     cdrom-checker/mismatch          # Load missing drivers from removable media?     hw-detect/load_media          # Keep default keyboard layout ()?     keyboard-configuration/unsupported_layout          # Start PC card services?     hw-detect/start_pcmcia          # for internal use; can be preseeded     debian-installer/add-kernel-opts          # for internal use; can be preseeded     mouse/protocol          # for internal use; can be preseeded     mouse/left          # for internal use     keyboard-configuration/layoutcode          # for internal use     keyboard-configuration/store_defaults_in_debconf_db          # Choices: Brazil, Portugal, other     localechooser/shortlist/pt          # for internal use; can be preseeded     preseed/early_command          # for internal use only     debian-installer/exit/always_halt          # Choices: Africa, Antarctica, Asia, Atlantic Ocean, Caribbea...     localechooser/continentlist          # Insert Debian boot CD-ROM     cdrom-checker/firstcd          # How should the debug logs be saved or transferred?     # Choices: floppy, web, mounted file system     save-logs/menu          # for internal use; can be preseeded     rescue/enable          # for internal use only     cdrom-detect/cdrom_fs          # Insert formatted floppy in drive     save-logs/insert_floppy          # Translations temporarily not available     localechooser/translation/none-yet          # Keymap to use:     # Choices: American English, Albanian, Arabic, Asturian, Bang...     keyboard-configuration/xkb-keymap          # for internal use; can be preseeded     mouse/device          # for internal use only     cdrom-detect/hybrid          # for internal use only     debconf/translations-dropped          # Country to base default locale settings on:     # Choices: Antigua and Barbuda${!TAB}-${!TAB}en_AG, Australia...     localechooser/preferred-locale          # Choices: Spain, France, other     localechooser/shortlist/eu          # Choices: Argentina, Bolivia, Brazil, Chile, Colombia, Ecuad...     localechooser/countrylist/South_America          # Failed to mount CD-ROM     cdrom-checker/mntfailed          # Retry mounting the CD-ROM?     cdrom-detect/retry          # Choices: Serbia, Montenegro, other     localechooser/shortlist/sr          # Module needed for accessing the CD-ROM:     # Choices:      cdrom-detect/cdrom_module          # for internal use; can be preseeded     preseed/file          # for internal use; can be preseeded     hw-detect/load-ide          # for internal use; can be preseeded     preseed/interactive          # Installation step failed     debian-installer/main-menu/item-failure          # Error while running ''     hw-detect/modprobe_error          # Choices: Pakistan, India, other     localechooser/shortlist/pa          # Use Control+Alt+Backspace to terminate the X server?     keyboard-configuration/ctrl_alt_bksp          # Choices: China, India, other     localechooser/shortlist/bo          # Language:     # Choices: C${!TAB}-${!TAB}No localization, Albanian${!TAB}-$...     localechooser/languagelist          # Installer components to load:     # Choices:      anna/choose_modules_lowmem          # for internal use only     debian-installer/language          # for internal use     keyboard-configuration/variantcode          # Choices: Anguilla, Antigua and Barbuda, Aruba, Bahamas, Bar...     localechooser/countrylist/Caribbean          # Language selection no longer possible     localechooser/translation/no-select          # Failed to copy file from CD-ROM. Retry?     retriever/cdrom/error          # Choices: Afghanistan, Bahrain, Bangladesh, Bhutan, Brunei D...     localechooser/countrylist/Asia          # Write the changes to disk and configure encrypted volumes?     partman-crypto/confirm_nooverwrite          # for internal use; can be preseeded     debian-installer/country          # No valid Debian CD-ROM     cdrom-checker/wrongcd          # Choices: Belgium, Germany, Liechtenstein, Luxembourg, Austr...     localechooser/shortlist/de          # for internal use; can be preseeded     anna/standard_modules          # Failed to process the preconfiguration file     preseed/load_error          # for internal use; can be preseeded     preseed/file/checksum          # Device file for accessing the CD-ROM:     cdrom-detect/cdrom_device          # for internal use; can be preseeded     directfb/hw-accel          # for internal use; can be preseeded     debian-installer/allow_unauthenticated          # Continue the installation in the selected language?     localechooser/translation/warn-severe          # for internal use; can be preseeded     debian-installer/theme          # Choices: American Samoa, Australia, Cook Islands, Fiji, Fre...     localechooser/countrylist/Oceania          # Are you sure you want to exit now?     di-utils-reboot/really_reboot          # Choices: Brazil, Portugal, other     localechooser/shortlist/pt_BR          # for internal use only     debconf/frontend          # for internal use; can be preseeded     debian-installer/exit/halt          # Choices: Belize, Costa Rica, El Salvador, Guatemala, Hondur...     localechooser/countrylist/Central_America          # Keep the current keyboard layout in the configuration file?     keyboard-configuration/unsupported_config_layout          # Compose key:     # Choices: No compose key, Right Alt (AltGr), Right Control, ...     keyboard-configuration/compose          # Method for temporarily toggling between national and Latin ...     # Choices: No temporary switch, Both Logo keys, Right Alt (Al...     keyboard-configuration/switch          # Installer components to load:     # Choices: cfdisk-udeb: Manually partition a hard drive (cfdi...     anna/choose_modules          # Integrity test successful     cdrom-checker/passed          # Manually select a CD-ROM module and device?     cdrom-detect/manual_config          # Terminal plugin not available     debian-installer/terminal-plugin-unavailable          # Insert a Debian CD-ROM     cdrom-checker/askmount          # Additional locales:     # Choices: aa_DJ.UTF-8, aa_DJ, aa_ER, aa_ER@saaho, aa_ET, af_...     localechooser/supported-locales          # for internal use only     cdrom-detect/usb-hdd          # for internal use; can be preseeded     preseed/late_command          # Failed to run preseeded command     preseed/command_failed          # Modules to load:     # Choices:      hw-detect/select_modules          # Keyboard model:     # Choices:      keyboard-configuration/model          # Continue the installation in the selected language?     localechooser/translation/warn-light          # Choices: Aruba, Belgium, Netherlands, other     localechooser/shortlist/nl          # for internal use only     cdrom/codename          # Choices: British Indian Ocean Territory, Christmas Island, ...     localechooser/countrylist/Indian_Ocean          # for internal use; can be preseeded     preseed/boot_command          # Web server started     save-logs/httpd_running          # System locale:     # Choices:      debian-installer/locale          # Choices: Macedonia\, Republic of, Albania, other     localechooser/shortlist/sq          # Country of origin for the keyboard:     # Choices:      keyboard-configuration/layout          # Keymap to use:     # Choices: American English, Albanian, Arabic, Asturian, Bang...     keyboard-configuration/xkb-keymap          # Keyboard layout:     # Choices: English (US), English (US) - Cherokee, English (US...     keyboard-configuration/variant          # Keep default keyboard options ()?     keyboard-configuration/unsupported_options          # Use Control+Alt+Backspace to terminate the X server?     keyboard-configuration/ctrl_alt_bksp          # for internal use     keyboard-configuration/variantcode          # for internal use     keyboard-configuration/optionscode          # for internal use     keyboard-configuration/modelcode          # Keep current keyboard options in the configuration file?     keyboard-configuration/unsupported_config_options          # Keep the current keyboard layout in the configuration file?     keyboard-configuration/unsupported_config_layout          # Method for toggling between national and Latin mode:     # Choices: Caps Lock, Right Alt (AltGr), Right Control, Right...     keyboard-configuration/toggle          # Compose key:     # Choices: No compose key, Right Alt (AltGr), Right Control, ...     keyboard-configuration/compose          # Method for temporarily toggling between national and Latin ...     # Choices: No temporary switch, Both Logo keys, Right Alt (Al...     keyboard-configuration/switch          # Key to function as AltGr:     # Choices: The default for the keyboard layout, No AltGr key,...     keyboard-configuration/altgr          # Keep default keyboard layout ()?     keyboard-configuration/unsupported_layout          # Keyboard model:     # Choices: A4Tech KB-21, A4Tech KBS-8, A4Tech Wireless Deskto...     keyboard-configuration/model          # for internal use     keyboard-configuration/layoutcode          # for internal use     keyboard-configuration/store_defaults_in_debconf_db


Is there a way to run 'screen' in read-only mode?

I'd like to be able to check progress and output of my existing `screen` sessions, but in a read-only manner, so as to prevent something from going wrong due to user error. Is there a way to do this?


Need advice for tools to use in everyday workflow

I am an open source web developer that has decided to transition away from using the Microsoft stack as the center of my everyday workflow and dive into Linux for my primary workstation. As I am new to Linux, I would like to know from Linux experts what the most valuable tools are available for common (and not so common) tasks from a web developer's perspective. The best online resources to learn those tools would also be very helpful.


What's the best way to take a segment out of a text file?

What's a good way of extracting say, lines 20 -45 out of a huge text file. Non-interactively of course!


How to replace all percent-encoded UTF-8 substrings with plain UTF-8 text?

I've got a html file with a lot of %-encoded UTF-8 text in URLs. For example "%D1%80%D0%B5%D1%81%D1%83%D1%80%D1%81%D1%8B" stands for "ресурсы" ("resources" in Russian). The task is to replace all such substrings with readable UTF-8 text. To simplify the task we can consider there is no other `%` sign usage in the file. Letter digits can be both upper and lower case. I suspect this can be done elegantly with `sed`, `perl`, `awk` or something but don't know how. This web application seems to do the trick with text you paste there.


Is there a tmux equivalent of "screen -D -R"

I would like to know if there is a way to get `tmux` to behave like `screen -D -R` so I could say, have the command as a default command in Putty. These `screen` switches would force detach of an existing screen session for my user (even if it was still active and logged-in somewhere else) and reattach it to the current session. Also, in the case that no screen session existed, it would create a new one. I like tmux and can see clear benefits over screen, but the existence of this feature would really seal the deal. `tmux attach` doesn't seem to create a new session if there isn't one. The man page for tmux says: > If no server is started, attach-session (attach) will attempt to start it; > **this will fail unless sessions are created in the configuration file.** What does the section in bold mean? (I can't find an example of creating a session in the conf file).


Replacing lines in files with file contents

I have several files which contain some PHP `include`s and I want to substitute them with the file contents. The file looks like               foo     <?php     include("file1.php");     ?>     bar     baz     <?php     include("file2.php");     include("file3.php");     ?>     more content      So after `foo` should be the content of file1.php and after `baz` should be first content of file2.php followed by file3.php. I want also remove the `<?php` and `?>` tags in both cases. What is a good way to resolve this? Assume the following file contents:   1. `file1.php`: is empty   2. `file2.php`: `<p>Hello`   3. `file3.php`: `World</p>` So the resulting file should look like:               foo     bar     baz
Hello     World
     more content      The word `foo`, `bar` etc. are just expletives within the real file there could be any text.


How can I have screen transmit an audible bell produced in a background window?

I managed to replace the audible bell by a visual clue in the active window, but for background windows, can I get an audible bell instead of a visual notification ?


Can I use divert as an alternative to ipfw fwd?

I would like to lead some traffic through a transparent proxy (which actually is on another server and connected with an ssh tunnel). Normally I could do this:               ipfw add forward localhost,8080 tcp from any to x.x.x.x 80      However, fwd/forward needs a re-compile of the kernel, which I am not happy to do. Therefore, I'm searching for a solution that doesn't need a recompile. For example, could I somehow use a divert socket to implement this? Or are there any other basic good solutions?


Specific Jar file doesn't run on startup

I want to run a jar at startup, so I asked a question here. I was given a few suggestions, so I started from trying to create a script file and desktop file. I created a script file and desktop file and placed the script file in `/usr/bin` and the desktop file in `/etc/xdg/autostart`. The script file and desktop files are as follows: Script: suscript               #!/bin/bash            ### BEGIN INIT INFO       # Provides:          suscript       # Required-Start:    $remote_fs $syslog       # Required-Stop:     $remote_fs $syslog       # Default-Start:     2 3 4 5       # Default-Stop:      0 1 6       # Short-Description: Start daemon at boot time       # Description:       Enable service provided by daemon.       ### END INIT INFO            java -jar /etc/ready/ready.jar       Desktop file: su.desktop               [Desktop Entry]       Name=su       Exec=/usr/bin/suscript       Type=Application       Terminal=false        But it did not work. So I thought of testing and created a jar file which does nothing but display a message dialog with string "success". I followed the same procedure but it worked fine. When i rebooted my system, the message dialog appeared. The script and desktop files are as shown below: Script: sutscript               #!/bin/bash            ### BEGIN INIT INFO       # Provides:          sutscript       # Required-Start:    $remote_fs $syslog       # Required-Stop:     $remote_fs $syslog       # Default-Start:     2 3 4 5       # Default-Stop:      0 1 6       # Short-Description: Start daemon at boot time       # Description:       Enable service provided by daemon.       ### END INIT INFO            java -jar /etc/ready/Start.jar       Desktop file: sut.desktop               [Desktop Entry]       Name=sut       Exec=/usr/bin/sutscript       Type=Application       Terminal=false       After creating the scripts I changed the permission using `chmod +x /path/to/script` for both scripts. The test script works fine but not my original script. I also tried changing the permissions for jar files. Same results. But when I run `suscript` or my jar file from terminal it runs fine. No exceptions or errors occur. I tried these in Ubuntu 14.04 (Trusty) and Linux Mint (Cinnamon).


Wireless connection not figuring in VMware Workstation 10(Kali-Linux)

I just installed **kali-linux** on my **VMware workstation 10**. I had to check for the wireless connection in the kali-linux. I tried to check for the **wireless-network connection(WiFi)** ;but,it was incorrectly identifying the wireless-network as an **Ethernet-connection(eth 0)**. How can this be resolved? I just googled for it and came to know that one can't evaluate the wireless network connection in Virtual Machines. I might sound like nerd, but, I really want to know why exactly is this so; and,if this is a **short-coming of Virtual Machines** ; why don't the bigger giants like VMware/Oracle,etc. figure this out and correct it? Please list the reasons along with some useful resources,if possible. Thanks for giving the time to study the whole question with patience.


Generating a Linux executable with Mono with mkbundle

A C# file in mono can be compiled using `gmcs` command. This will create a `hello.exe` file.               $ gmcs hello.cs     $ ls     hello.cs  hello.exe     $ ./hello.exe     Hello from Mono!      To generate a linux executable, I tried this command, but it generates the error:               $ gmcs /t:exe hello.cs /out:hello          Unhandled Exception: System.ArgumentException: Module file name 'hello' must have file extension.      I want create a standalone executable so that I can execute it simply run it by saying and I get the desired output:               $ ./hello     Hello from Mono!      I searched and found a solution which mentions of a tool called mkbundle:               $ mkbundle -o hello hello.exe --deps     Sources: 1 Auto-dependencies: True     embedding: /home/ed/Projects/hello_world/hello.exe     embedding: /mono/lib/mono/1.0/mscorlib.dll     Compiling:     as -o /tmp/tmp54ff73e6.o temp.s     cc -o hello -Wall temp.c `pkg-config --cflags --libs mono` /tmp/tmp54ff73e6.o     Done          $ ls -l     total 3     -rwxr-xr-x  1 ed users 1503897 2005-04-29 11:07 hello     -rw-r--r--  1 ed users     136 2005-04-29 11:06 hello.cs     -rwxr-xr-x  1 ed users    3072 2005-04-29 11:06 hello.exe      This utility does not seem to exist in my Mono install. I found that this is available in `mono-devel` package. To install this package meant installing around 82 other packages. My goal was to keep my mono install minimal until sometime. Is there a way to install `mkbundle` standalone?


iptables on tor exit node

I want to run an open Tor router. My exit policy will be similar to ReducedExitPolicy. But I also want to make it hard for the tor network to abuse my resources. Cases I want to prevent clients from doing via Tor:   * Hammering one site with very many packets.    * Aggresive netscans of whole IP blocks Cases I do NOT want to prevent clients from doing via Tor:   * uploading a few hudreds of image files to the cloud   * seeding a torrent My question is, can this be done at all, and how? My first thought was some firewall (Linux/iptables or *BSD/ipfw/pf) - but this will probably be useless due to inherent properties of the Onion router. Is there any ongoing torproject team development on this topic? I also ask for general hints on securing Tor exit nodes. ## Update (Sep 2012) From helpful answers and some other research I think this can not be done. The best you can do to stop people from abusing exit node to contribute in DDOS, is to detect very frequent packets directed to one IP. The "very frequent" threshold depends on total node bandwidth... If it is wrong, there will be false positives, blocking legitimate traffic of realtime TCP apps and traffic sourced from very many clients to one destination.


Configurations needed to be done post GCC compilation and installation

I have compiled the latest GCC 4.7.0, on my Linux Mint 12, using gcc 4.6.1 (default).   Compiler compiled successfully, steps followed   1. ./configure   2. make   3. make install Binaries of gcc-4.7.0 are in /usr/local/bin/ after install step. Now the goal is to make the new compiler the default while also keeping the old one around(no uninstall) i.e. I want to be able to do gcc a.c or g++ a.cpp directly in the terminal window.   I have been unable to find a proper series of steps that would help me accomplish this.      Also, doing /usr/local/bin/g++ hello-world.cpp generates iostream file/directory not found. Any help is appreciated.


Multiple subnets on multiple virtual interfaces with one physical interface

I have a Ubuntu pc with one interface -- `eth0` -- which is connected to an unmanaged switch which is linked to two subnets: `192.168.0.0/24` and `192.168.1.0/24`. I want to have two virtual interfaces with different MAC's on Ubuntu pc to connect to both the subnets (each virtual interface is connected to a different subnet). I do not want an alias (eth0:0), because I also want to add default gateways (192.168.0.1 and 192.168.1.1) of both subnets. What I want is something like another dumb virtual switch inside Ubuntu pc to which I can add two or more virtual interfaces. I tried the answer here, but when I ping the ip of the virtual interface I get the MAC of eth0. Also I created a bridge and gave different ips representing different subnets to `br0` and `eth0`, but that too didn't work. I have tried every possible howto and I have also googled for months on the issue: the only solution seems to be to buy another network card and plug both to my unmanaged switch.


Continues Pinging to background, save logs and show statistics

I'm trying to make a script that save the `ping` logs to .txt or .log file. To monitor if my connection is intermittent or not, I'm using this script:               $nohup ping 8.8.8.8 > timeout.txt &      Then when I check if its pinging:               $tailf timeout.txt      It's working! But when I stop the process by using:               $kill (process)      timeout.txt file is stop pinging but didn't show the statistic logs if I had any timeout or packet loss. How to stop the `ping` and also showing the statistic?   Or do I have to add a script to my script?


bash_completion

I have a simple script, which creates a symlink `IP_address` -> `config_file` (used for pxe boot). My script is called like this:               lnpxe CONFIG HOSTNAME      where `CONFIG` is one of my config files stored in `/home/tftp/config/` and `HOSTNAME` is any hostname. Now, I am trying to set up bash_completion for my script. When I type `lnpxe` and then press `TAB`, I would like to have my config files in `/home/tftp/config/` "suggested" to me and autocompleted. Similarly, for the second argument, I would like to have suggestions of available hosts from my `/etc/hosts` file (similar as ping or ssh do) Here is my `/etc/bash_completion.d/lnpxe` file which does NOT work as I would like to:               _lnpxe()     {         local cur prev         COMPREPLY=()         cur="${COMP_WORDS[COMP_CWORD]}"         prev="${COMP_WORDS[COMP_CWORD-1]}"              _filedir          }     complete -F _lnpxe -o filenames lnpxe      Could somebody please help ?


Debian-Windows dual boot: which one should I install first?

I have a fresh desktop with no OS that I want to run Windows 7 and Debian stable on. All guides for dual boot setups I found so far assume a pre- installed Windows (possibly because so many PCs come that way). Because of the bootloader, it does matter what is installed first.   * What is better, Windows or Linux first - and why?   * What’s easier to do?   * Especially with a Linux-first setup, I’d appreciate example of the steps that could be involved.


how to connect ssh 'with' specified port?

I know how to connect 'to' a certain port when ssh'ing.               ssh user@remotehostip -p XXX      but is there a way to establish a ssh 'with' a certain port? I mean, is there a way to specify the port which my local computer will be using?


setup fetchmail/exim4 to download from gmail account and forward to another email address

I'm trying to setup my debian server to download email from a gmail account (e.g. `forwarder@gmail.com`) and then forward it to a 3rd party email. The reason I can't just setup email forwarding within gmail is because I need the headers to reflect that the email is coming from `forwarder@gmail.com`. When I use gmail's forwarding, then it leaves the headers unchanged. I'm first trying to setup exim4 to just use gmail to send. I set it up as a smarthost via the instructions on the Debian wiki, but when I try to send a test email, it gives me the following errors in the exim4 log:               2011-06-26 06:34:37 1QapTx-0000rh-Cu <= root@ETC_MAILNAME U=root P=local S=360     2011-06-26 06:34:37 1QapTx-0000rh-Cu ** 3rdparty@email.com: Unrouteable address     2011-06-26 06:34:38 1QapTx-0000rj-R4 Error while reading message with no usable sender address (R=1QapTx-0000rh-Cu): at least one malformed recipient address: root@ETC_MAILNAME - malformed address: _MAILNAME may not follow root@ETC     2011-06-26 06:34:38 1QapTx-0000rh-Cu Process failed (1) when writing error message to root@ETC_MAILNAME (frozen)      Anyone have any idea what might be the issue? Edit: Running Debian 6.0 "squeeze" and Exim version 4.72 #1 built 12-May-2011 19:03:39 Here is /etc/exim4/exim4.conf:               # /etc/exim4/update-exim4.conf.conf     #     # Edit this file and /etc/mailname by hand and execute update-exim4.conf     # yourself or use 'dpkg-reconfigure exim4-config'     #     # Please note that this is _not_ a dpkg-conffile and that automatic changes     # to this file might happen. The code handling this will honor your local     # changes, so this is usually fine, but will break local schemes that mess     # around with multiple versions of the file.     #     # update-exim4.conf uses this file to determine variable values to generate     # exim configuration macros for the configuration file.     #     # Most settings found in here do have corresponding questions in the     # Debconf configuration, but not all of them.     #     # This is a Debian specific file          dc_eximconfig_configtype='smarthost'     dc_other_hostnames=''     dc_local_interfaces='127.0.0.1 ; ::1'     dc_readhost=''     dc_relay_domains=''     dc_minimaldns='false'     dc_relay_nets=''     dc_smarthost='smtp.gmail.com::587'     CFILEMODE='644'     dc_use_split_config='false'     dc_hide_mailname='false'     dc_mailname_in_oh='true'     dc_localdelivery='mail_spool'


VFS: Cannot open root device “nfs” or unknown-block(0,255)

I am trying to setup a diskless client which will mount over nfs to the server. When I try to boot the client I get the following error message:               VFS: Cannot open root device "nfs" or unknown-block(0,255) Please append a correct "root=" boot option Kernel panic - not syncing: VFS: Unable to mount root fs on unknown-block(0,255)      I've set up my kernel parameters as follows:               kernel=192.79.143.131:/linuxboot,192.168.100.14      (they are tftpboot parameters, which work)               Linux PPC load: root=/dev/nfs rw nfsroot=192.79.143.131:/diskless/client01 ip=dhcp      The kernel is found via tftpboot, so I know the 'kernel' parameter above works. The kernel is loaded and start executing, but hits the above error eventually. The mount point is properly exported from the server, as I can mount it manually from other machines. I've read several threads about this topic (at least very similar), but none, as far as I've seen so far, has addressed mounting a nfs drive. I've only seen topics talking about local hard drives.


How to autologin with XDM?

How to autologin a specified user with `xdm`? I know it's possible with other display managers but I wasn't able to figure out how `xdm` has to be configured to autologin a certain user. Is it possible? Or should I rather remove `xdm` and simply use an initscript with `startx`?


How to script /etc/issue?

I would like to pipe my tty number through figlet (ASCII generator) for the `/etc/issue` (message shown before login). Obviously this means I can't just update it from `/etc/rc.local`. On my system (Arch), `agetty` is responsible for parsing the file.


Getting sudo to work for an alias

I installed Sublime Text 3 in Fedora 20 which has got GNOME, as I couldn't get it being _called_ from terminal I created a `.bash_aliases` file which a line like this:               alias sublime='sublime_text'      And so also added the sublime_text file location to the PATH by editing `.bashrc` file adding:               export PATH=$PATH:/usr/local/share/applications/sublime-text-3/      However, when I want to edit any file for which I might get **_sudo privilege_** first I want to do:               sudo sublime sudoLikelyFile      or               sudo sublime_text sudoLikelyFile      However I'm getting:               sudo: sublime: command not found      How can I work around for this?


Why can't I get the exit values of a command in this bash script?

So I was writing this little nautilus script for transcoding video into mp3:               #! /bin/bash -x          if [ -z "$1" ]         then         zenity --warning --text="Error - No file selected !"         exit 1     fi          BASEFILENAME=${1%.*}          exec ffmpeg -i "$1" -ab 256k "$BASEFILENAME.mp3" &&          if [ "$?" -eq 0 ]         then         zenity --info --text="Converting successful"         exit     fi      The problem is, though the ffmpeg command is executed successfully the `if [ "$?" -eq 0 ]` seems not to get triggered. Why is that? Is the `&&` wrong or is it something else?


Why put some config info in conf/httpd.conf and some in files in the conf.d folder?

The main apache config file is in `/etc/httpd/conf/httpd.conf` on my CentOS system an in there is a line:               Include conf.d/*.conf      Inside conf.d is mostly files that do something like this:               LoadModule auth_kerb_module modules/mod_auth_kerb.so      But there are also other sites that are setup in there to and have their own config files. Was this not well thought out or am I missing something?


How can we use the command 'top‘ to monitor the total CPU usage and each processor usage simultaneously?

You know that we can use the command `top` to monitor the real-time CPU usage and toggle the result display to the per-processor view by pressing key `1`. The disadvantage of it is you can only monitor either the whole CPU usage or each processor usage. That is, you can't see them simultaneously. Does anyone know this? I know that we can use alternative commands such as `mpstat` or `sar` to do the job. But unfortunately, neither of them is available on our system and no chance can we install them.


What is the default encryption type of the ssh-keygen?

When generating private/public keys with `ssh-keygen` what types of keys will it generate if I wont pass `-t` option followed with the encryption type like `rsa`?


sudo cannot open /etc/sudoers

`sudo` does not work. I have installed Arch Linux onto a USB key formatted with BTRFS. The output of `sudo` is:               $ sudo     sudo: unable to stat /etc/sudoers: Permission denied     sudo: no valid sudoers sources found, quitting     sudo: unable to initialize policy plugin          $ ls -l /etc/sudoers     -r--r----- 1 root root 2849 May 18 15:00 /etc/sudoers          $ lsattr /etc/sudoers     --------------- /etc/sudoers          $ ls -ld /etc     drwxr-xr-x 1 root root 2476 May 25 13:45 /etc          $ ls -ld /     drwx------ 1 root root 142 May 25 06:51 /          $ ls -l $(which sudo)     ---s--x--x 2 root root 123995 May 25 13:10 /usr/bin/sudo          $ strace -u ross sudo true 2>&1 | egrep '(sudo|set.*[ug].*id)'     execve("/usr/bin/sudo", ["sudo", "true"], [/* 30 vars */]) = 0     read(3, "31799 (sudo) R 31796 31796 31754"..., 1024) = 223     lstat64("/etc/sudo.conf", 0xbfcddeb0)   = -1 ENOENT (No such file or directory)     stat64("/usr/lib/sudoers.so", {st_mode=S_IFREG|0755, st_size=235092, ...}) = 0     open("/usr/lib/sudoers.so", O_RDONLY|O_CLOEXEC) = 3     stat64("/usr/lib/sudoers.so", {st_mode=S_IFREG|0755, st_size=235092, ...}) = 0     setresuid32(0, -1, -1)                  = 0     setresgid32(-1, 0, -1)                  = 0     setresuid32(-1, 1, -1)                  = 0     lstat64("/etc/sudoers", 0xbfcddd60)     = -1 EACCES (Permission denied)     setresuid32(-1, 0, -1)                  = 0     write(2, "sudo", 4sudo)                     = 4     write(2, "unable to stat /etc/sudoers", 27unable to stat /etc/sudoers) = 27     setresuid32(-1, 1, -1)                  = 0     setresgid32(-1, -1, -1)                 = 0     setresuid32(-1, 0, -1)                  = 0     setresuid32(-1, 0, -1)                  = 0     setresgid32(-1, 1000, -1)               = 0     write(2, "sudo", 4sudo)                     = 4     write(2, "no valid sudoers sources found, "..., 40no valid sudoers sources found, quitting) = 40     write(2, "sudo", 4sudo)                     = 4               $ ltrace -u ross sudo true 2>&1 | egrep '(sudo|stat|set.*[ug].*id)'     bindtextdomain("sudo", "/usr/share/locale")      = "/usr/share/locale"     textdomain("sudo")                               = "sudo"     fopen("/proc/31813/stat", "r")                   = 0x9e51d40     __xstat(3, "/dev/console", 0xbffd6074)           = 0     __xstat(3, "/dev/wscons", 0xbffd6074)            = -1     __xstat(3, "/dev/pts/4", 0xbffd6074)             = 0     __lxstat64(3, "/etc/sudo.conf", 0xbffd9040)      = -1     strlen("sudo")                                   = 4     memcpy(0x09e51e71, "sudo", 4)                    = 0x09e51e71     __xstat64(3, "/usr/lib/sudoers.so", 0xbffd810c)  = 0     dlopen("/usr/lib/sudoers.so", 257 <unfinished ...>     dlsym(0x09e51ef8, "sudoers_policy")              = 0xb75af520     __xstat64(3, "/usr/lib/sudoers.so", 0xbffd810c)  = 0     dlopen("/usr/lib/sudoers.so", 257)               = 0x09e51ef8     dlsym(0x09e51ef8, "sudoers_io")                  = 0xb75af560     fputs("sudo", 0xb7760920sudo)                        = 1     fputs("unable to stat /etc/sudoers", 0xb7760920unable to stat /etc/sudoers) = 1     fputs("sudo", 0xb7760920sudo)                        = 1     fputs("no valid sudoers sources found, "..., 0xb7760920no valid sudoers sources found, quitting) = 1     fputs("sudo", 0xb7760920sudo)                        = 1     +++ exited (status 1) +++


cat /dev/null emptied my log file but size did not change

I'm quite new to Unix. Using Solaris 10 I faced the below issue. There is a large log file with size 9.5G. I tried to empty the file using the below command.               # cat /dev/null file_log.txt      By doing this I regained space on the file system but the size of the file still shows the same and is increasing. I figured a process is still running into the log file. Is there a way to correct the file size? Is this going to effect my file system?


Mint 13: Is it possible to skip standard login password dialog in presence of a pendrive with the key

To meet my security needs I set up quite long user password on my notebook. But when I am at home or other secure location, typing it down is cumbersome. It would be nice to let the gdm (or: mdm, since I am using Mint 13 with Mate) search for a specific file (on a pendrive), and when it is present, treat is as a security token and log in me automaticaly with it. I use encrypted home folders.


How to associate a script at boot time to a specific run level?

I am trying to understand how run levels work. I understand the meaning of the 7 run levels and I understand that they were usually configured by `/etc/inittab`, which used to call `/etc/init.d/rc`, which itself called the various scripts to configure the different run levels and how they should behave. Right now I am on an Ubuntu Server machine (12.04) and I see that the `inittab` file is not used anymore and that instead, scripts are found in the `/etc/init` directory. Now suppose that I want to execute a script at boot time (for example to launch an application). Usually I would do this editing the `/etc/init.d/rc.local` file. And here comes my question: if I edit this file, will this script run for **every** run level? If I want the script to work only at run level 5 for example, should I put this script into the `/etc/rc5.d/` folder instead? Or is there another way to do this?


What is the best way to create remote tunnel?

I have 3 Linux servers:   * 10.0.0.0/24 - (10.0.0.10) Linux server inside my LAN.    * 20.0.0.0/24 - (20.0.0.10) Linux server with HTTP Apache server    * 50.50.50.50/32 - Server on Amazon AWS which see both 10.x and 20.x LANs. 10.x cannot see 20.x and 20.x cannot see 10.x   What is the best way (and how can I do it) to se 50.50.50.50 server on AWS to create tunnel from 10.x to 20.x 20.0.0.10 runs HTTPd server on "DMZ" LAN. I need to see 20.0.0.10:80 from my 10.0.0.0/24 servers.   The 2 networks 10.x and 20.x is on the same Cisco ASA firewall/router, but I cannot route because of License issues, so i want to bypass this by external server which can see 20.x network. I want to be able to go to 50.50.50.50:80 from 10.x servers and see 20.0.0.10:80 content.


Is it possible to know when you're at the first bash prompt of a terminal?

This is sort of a contiunation of my last question: printing saving the last bash input command Now I want to know if it's possible to know when you're at the first bash prompt of a terminal. So I'm displaying the last command run above the current prompt. And I'm thinking it would be cool if when you're at a fresh terminal, to display the last N commands. I guess I could just echo the last commands inside my `.bashrc`, but that doesn't seem like a good idea. And also it'd be cool to get the last N commands shown when the scrollback is cleared (via `clear`). Is any of that (reasonably) possible?


Why does 'set' syntax not work for syntax highlighting in vim?

On searching how to set syntax highlighting on in vim, I found this page which says that vimrc should have the following line               syntax on      **Why is it not something like`set syntax on`?** Like we have `set nu`, `set ai` etc. With `set syntax on`, I get this error               $ vi       syntax=     Error detected while processing /home/lazer/.vimrc:     line   30:     E518: Unknown option: on     Hit ENTER or type command to continue      and with `set syntax`, I get this               $ vi       syntax=     Hit ENTER or type command to continue


Displaying all sysvinit init scripts

Is there some tool that displays all available init scripts (on Debian), short of one having to remember a location like `/etc/init.d`, not to mention that not everything in there is an init script?


How is file ownership affected across different systems?

As I understand Unix file systems, any file on a unix system must belong to a group and a user of the said system. A file cannot belong to a group or user that does not exist on the system. From that assumption, there are a few questions that come to mind. What happens to the group and user attributes when media is transferred between computers, be it via a flash drive, a CDROM or a network share. To whom does the file belong in the new system? Can you limit the data to only work on your system? (Not talking about encryption here, just basics.) Also, when you transfer data between two computers, are there ways to ensure that the group and user attributes stay intact (what belongs to root will belong to root on the new system and the same with the normal user).


lilo, install in target-mbr from another system

I have a embedded system (short ES) on a cf-card (short CFC). I plugged the CFC into the cardreader of my notebook. Sure the devices of my notebook are not the same then in the ES. Now the mainboard of the changed and the CF-card is connected to another controler (other /dev/hdX). So I am not able to boot the ES from the CFC, because of other kernel parameters (hdd device). I mounted the CFC on the notebook and changed the lilo.conf but now I am not able to reinstall the new config into the CFCs MBR. I tried parameter -M but lilo checks that the device-names in the lilo.conf on the CFC are not the same that on my notebook. e.g. I try to install on /dev/sdc (the CFC on my notebook) but the root- parameter in lilo.conf is (dev/hda) because the system is running on the ES, not my notebook. So, how can I tell lilo to install in a MBR with parameters of my target system (ES)??


Is there a way to find out why tmux crashed

I am trying to shift from using VNC to tmux. My tmux keeps crashing at least once in a week and I am clueless why this happens. VNC rarely crashed and this weekly crash is a strong detrimental for me to completely switch. Is there a way I can find out the reason tmux crashes ? My .tmux.conf is pretty simple                #Don't show the green ribbon below      set -g status off                                                                                #Select panes by mouse click                                                                                set -g mouse-select-pane on                                                                                #enable scrolling by mouse in tmux                                                                                set-window-option -g mode-mouse on                                                                                #enable resize of pane by mouse                                                                                set -g mouse-resize-pane on       I use iterm2 with terminal mode set to 256 color and heavily use vim plugins and colorschemes(Lid, nerdtree, tagbar, indentLine, molokai etc.,). To adjust terminal color I had following setting in my .vimrc but I am not sure if these are in any way related to tmux crash               set t_ut=     set t_Co=256      Also, I have enabled mouse in my vim `set mouse=a` Is there a way to find why my tmux session is crashing ? EDIT: Attaching the final logs from my tmux-server               found key 0x1001: ""     input_parse: ' ground     input_c0_dispatch: '     input_parse: ' ' ground     input_parse: ' ground     input_c0_dispatch: '     keys are 1 ()     complete key  0x1001     writing key 0x1001     found key 0x1001: ""     input_parse: ' ground     input_c0_dispatch: '     input_parse: ' ' ground     input_parse: ' ground     input_c0_dispatch: '     keys are 1 ()     complete key  0x1001     writing key 0x1001     found key 0x1001: ""     input_parse: ' ground     input_c0_dispatch: '     input_parse: ' ' ground     input_parse: ' ground     input_c0_dispatch: '     keys are 1 ()     complete key  0x1001     writing key 0x1001     found key 0x1001: ""     input_parse: '' ground     input_c0_dispatch: '     got 5 from client 6     writing 4 to client 6     got 13 from client 6


How can I partition and format my disk to an accuracy of "LBA" by commands?

How can I partition `/dev/sdb` into `/dev/sdb1` and `/dev/sdb2`, and then format `/dev/sdb1` to exFAT ( or FAT32 ) from LBA=1 to 2097152 by commands? ( LBA=0 is reserved for MBR )


Detecting RHEL/RPM based distros

I'm trying to write a script to detect if it's being run on RHEL/RPM based distros. I've faced some odd systems configured such that both `dpkg` and `rpm` are installed, so doing a `which rpm` isn't a solution. I attempted this:               if [[ "$(cat /etc/*[_-][rv]e[lr]*)" == (CentOS|Fedora) ]]; then       #...     fi      but this requires me to know the names of all distributions that are based on RHEL/RPM.


Create Relative Symlink Inside Relative Symlink

I've been browsing for a minute now trying to find a way to create a relative symlink inside a relative symlink, and what I mean by that is this... I have my CakePHP Templates Skeleton as a symlink inside one of my projects, inside my skeleton, I have a symlink to a plugin outside the skeleton folder, the idea being, I can symlink my CakePHP CMS Skeleton inside my projects, create an "Application" plugin outside the CMS skeleton symlink, and and the skeleton symlink point to my projects "Application" plugin. By that I mean the following. I have a CakePHP CMS Skeleton at the following path               /mnt/proj/libs/cakephp/lib/Cake/Console/Templates/skel      The path to my project folder is below               /mnt/proj/mysite.com/      I then symlink the CakePHP CMS Skeleton inside my project folder like so               /mnt/proj/mysite.com/cms-skel -> /mnt/proj/libs/cakephp/lib/Cake/Console/Templates/skel      Inside the skeleton I have a symlink pointing to an Application plugin               /mnt/proj/libs/cakephp/lib/Cake/Console/Templates/skel/Plugin/Application -> ../../Application      So inside the CakePHP CMS symlinked folder in mysite.com folder I have               /mnt/proj/mysite.com/cms-skel/Plugin/Application -> ../../Application      The issue is, that the above symlink points to               /mnt/proj/libs/cakephp/lib/Cake/Console/Templates/Application      And I need it to point to               /mnt/proj/mysite.com/cms-skel/Plugin/Application      Any ideas on how I can do the above with symlinks is greatly appreciate, I am not even sure what to google at this point.


Data Extraction from SCO Open server 5

We have a very old database running on SCO Openserver 5 and we need to export data in CSV format for Excel in order to import to a Windows based system.   * How do I access the system to start exporting?   * Do I need to contact the database provider (datapower, now Infocomm) for this?


Variable as command; eval vs bash -c

I was reading a bash script someone made and I noticed that the author doesn't use eval to evaluate a variable as a command   The author used               bash -c "$1"      instead of               eval "$1"      I assume using eval is the preferred method and it's probably faster anyway. Is that true?   Is there any practical difference between the two? What are notable differences between the two?


Backup script permission issue

I have a server with a user named `deploy-user` and have written a backup script to backup a number of websites associated with this user. However one of the sites I'm trying to backup has a directory `/home/usera/web/www.example.com/some/random_dir` is owned by `apache-data- user`. What permissions would I give `deploy-user` to be able to backup that directory. Options I am aware of are either:   * Running the script as `root`, which I don't really want to do.   * Adding `apache-data-user` and `deploy-user` to the same group. But then `apache-data-user` will have to many permissions. Has anyone got a suggestion of the best way to backup this directory?


How can I instruct BSD sed to interpret escape sequences like \n and \t?

I have a sed replacement command that I would like to be compatible with BSD `sed` as well as GNU `sed`. Extended regular expressions are not an issue as I do not need them in this case. My primary problem is difference in the way that the two `sed`s interpret character escape sequences in the _replacement_ strings. My replacement string contains tabs and newlines and I'd like them to be visible in the command strings for ease of maintenance, however, BSD `sed` doesn't interpret the escape sequences and GNU `sed` _does_. What is the appropriate way to instruct `sed` to interpret these escape sequences on BSD? The following two snippets epitomize my problem: **GNU`sed`**               echo ABC | sed 's/B/\n\tB\n'      yeilds               A         B     C      **BSD`sed`**               echo ABC | sed 's/B\n\tB\n'      yields               AntBnC      Clearly, `\n` and `\t` aren't interpreted as escape sequences by BSD `sed` Now, to my question. According the BSD `sed` manpage: > To specify a newline character in the replacement string, precede it with a > backslash. Does this imply that I'd need to precede a _literal_ newline by a backslash? What is the appropriate way to instruct `sed` to interpret escape sequences like `\n` in the replacement text?


Remove empty configuration section

Files like `~/.config/vlc/vlcrc` are 99% junk if you want to version control only the configuration options. I've got a script to remove the comments, but there's a ton of empty configuration sections left over. My `sed`- and `awk`-fu is not up to speed, so how can I remove the empty configuration sections? The first line of a configuration section matches `^\\[.*\\]$`, and it is _empty_ if the first line is followed by any number of lines consisting only of whitespace, then followed by another line matching `^\\[.*\\]$` or `EOF`.


knock on Scientific Linux 6.1? (perl script for knocking?)

I have an OpenWrt router where I installed knockd:               knockd.conf      [options]         logfile = /var/log/knockd.log          [openSSH]         sequence    = 7000,8000,9000         seq_timeout = 5         command     = /usr/sbin/iptables -I INPUT -s %IP% -p tcp --dport 22 -j ACCEPT         tcpflags    = syn          [closeSSH]         sequence    = 9000,8000,7000         seq_timeout = 5         command     = /usr/sbin/iptables -D INPUT -s %IP% -p tcp --dport 22 -j ACCEPT         tcpflags    = syn      and I'm having a notebook with Scientific Linux 6.1 from where I want to knock.. but seems there isn't any "knock" package for SL 6.1.. Where can I get the RPM for the knock binary? (Or are there any alternatives for knock? A perl script maybe?)


Why is it better to use "#!/usr/bin/env NAME" instead of "#!/path/to/NAME" as my shebang?

I notice that some scripts which I have acquired from others have the shebang `#!/path/to/NAME` while others (using the same tool, NAME) have the shebang `#!/usr/bin/env NAME`. Both seem to work properly. In tutorials (on Python, for example), there seems to be a suggestion that the latter shebang is better. But, I don't quite understand why this is so. I realize that, in order to use the latter shebang, NAME must be in the PATH whereas the first shebang does not have this restriction. Also, it appears (to me) that the first would be the better shebang, since it specifies precisely where NAME is located. So, in this case, if there are multiple versions of NAME (e.g., /usr/bin/NAME, /usr/local/bin/NAME), the first case specifies which to use. My question is why is the first shebang preferred to the second one?


Assigning a command to variable

I assign command `ls` to my variable `my_File` but when I run it as `$my_File` it does not work. Can you please explain why?               #!/bin/bash     my_File='ls -f | grep -v '\/''     $my_File


Boot in rescue mode with vlan support in RHEL

I am trying to restore **RHEL** OS (5.3.1.1) from network, where we have VLANs configured on our switches. So the only way to get to shared folder on remote server with backup image is to configure VLAN. I booted a machine with Red Hat Recovery CD and ran `linux rescue`. But in this mode there is no VLAN support. No file under `/proc/net/vlan/config` and there is no module loaded (`lsmod|grep 802` gives nothing). Is there a way to boot from CD/DVD with 8021q support? `modprobe 8021q` in a regular `linux rescue` mode gives error due to missing folders with `modules.dep`.   On official web site I found some info that we can add more keys after `linux rescue` command in order to include support of other things. Does anybody knows how to make `linux rescue` boot with VLAN support (8021q)?


Why is this OSX/BSD/GNU sed workaround not working

So sed behaves differently depending on if it is the OSX/BSD or GNU version. OSX requires               sed -i '' <pattern> <file>      whereas this works with GNU sed:               sed -i <pattern> <file>      So I have this:               darwin=false;     case "$(uname)" in         Darwin*) darwin=true ;;     esac          if $darwin; then         sedi="sed -i '' "     else         sedi="sed -i"     fi      And then I try to call it on OSX               $sedi "s/VERSION =.*;/VERSION = \"${lver}\";/g" Version.java      And it works except for it creates a backup file named Version.java''. I'm not sure why this isn't working because if I do it explicitly from the CLI:               sed -i '' "s/VERSION =.*;/VERSION = \"${lver}\";/g" Version.java      It works without creating the backup file. Any thoughts?


Anyway to navigate percentage-wise in vim?

I often open large files, looking through logs for finding info. As all lines have timestamp in my case and I am sure of in which part of the whole file the info is present which I am interested in. For example,   * in the bottom half of the file contents(50% or beyond) or    * about 10% more towards the end of file or    * scroll down more 20% of original file. So, to navigate quickly in this fashion i.e. with percentage-wise - Is there any existing functionality already available in `vim`?


Does tmpfs automatically resize when the amount RAM changes, and does it compete when there's multiple tmpfs?

If I have a tmpfs set to 50%, and later on I add or remove RAM, does tmpfs automatically adjust its partition size? Also what if I have multiple tmpfs each set at 50%. Do multiple tmpfs compete against each other for the same 50%? How is this managed by the OS?


Are there any alternatives to Media Lovin' Toolkit (MLT)?

I'm looking for command-line Linux tools for creating video slideshows from images and video clips. I would also like to implement a variety of transitions and effects. So far, Media Lovin' Toolkit (MLT) seems to be the obvious choice, but are there any viable alternatives?


Can system calls be interrupted?

Please comment on the following sentence: > On the standard Linux kernel without the rt patch, interrupts can't > interrupt ongoing system calls. The reason why our machine doesn't stop > working when data is fetched from the hard disk is because the system call > we used for that operation is blocking. Blocking means that once it issues > the request to the hard disc it changes the process state to blocked, and > willingly gives up the processor time. There are no means to interrupt an > ongoing system call on a non real time kernel. This is my understanding of the topic, I am however, not sure if it is correct.


What's the fastest (CPU time) way to get my current git branch?

I'm trying to improve the performance of my fish prompt, and since my prompt includes my current git branch, I'm wondering if there may be a way to make it faster. Right now I'm using `git symbolic-ref HEAD | sed 's/refs\/heads\///'`, and when I first `cd` into a git repo, it sometimes hangs for a little while. I'm wondering if there is a known faster method, or how I could find out. Whenever I run `time git symbolic-ref HEAD`, it simply outputs `0.00 real`.


unzip a file from another folder

How can I unzip a file from another folder?               gunzip -d /home/tomcat_dev/HN/radd/input.txt.gz       unzips that file to the same folder. But if I want to bring it to my folder? When I do this:               gunzip -d /home/tomcat_dev/HN/radd/o.txt.gz /home/tomcat_dev/       it gives me a: `gunzip: /home/tomcat_dev/ is a directory -- ignored`


Universal extractors

With an increasing number of archive/compression file formats, is there a single free/open-source command line tool to rule them all? Perhaps something with a consistent / unified set of flags? (note my friendly implicit reference to tar) I once run into a set of aliases meant to largely simplify the task of compressing/de-compressing files with bindings to `tar` and other utils, but I can't find this anymore. **Update:** How can I configure something like `atool` to not use `unzip` to extract zip files (which apparently can't handle files larger than 4GB) and to use `gunzip` instead?               $ aunpack large_file.zip     error:  Zip file too big (greater than 4294959102 bytes)     Archive:  large_file.zip     warning [large_file.zip]:  1491344848 extra bytes at beginning or within zipfile       (attempting to process anyway)     error [large_file.zip]:  start of central directory not found;       zipfile corrupt.       (please check that you have transferred or created the zipfile in the       appropriate BINARY mode and that you have compiled UnZip properly)     aunpack: unzip ...: non-zero return-code


Manipulating `/dev/video`

I'd like to take the video stream from `/dev/video0`, apply some effects or changes and make the result available on `/dev/video1`. `/dev/video0` ---> Apply Effects ---> `/dev/video1` For example, `mplayer tv:// -vo caca` will display the output of `/dev/video` in ascii art. I would like to make that available on `/dev/video1` so that I could send that through skype instead of my default webcam feed.... Any suggestions?


Bizzarre behaviour of "echo !!" under interactive Bash. Is this a feature?

I wanted to test something in shell and I've typed `echo "!!"` instead of typical `echo "foo"`. I didn't get the `!!` for output. Instead, (and very unexpectedly!) it produced the output of my previous command issued for Bash. I tried to google the phrases `bash !!` (and permutations like `bash +"!!"`), but I couldn't find any reference for this feature. Can someone tell me something about the exclamation marks' stuff and Bash? At least how to find extra info? I use Bash 4.2.45 on Linux Mint 16 64 bit.


Fedora 15 i686 report only 2.6 GB RAM

I have laptop Asus N53SV with 4 GB of RAM, i7 with integrated card and dedicated GPU. My problem on Fedora is that system reports only 2.6 GB RAM. I know that I should use kernel with PAE but even after I install it, I have only 2.6 GB RAM avaiable. Now I use 3.0.0 rc6 kernel, but still nothing. Is it possible that the integrated GPU uses almost 1GB of RAM ? Can I check it somehow?               $ free     Non-standard uts for running kernel:     release 3.0-0.rc6.git6.1.fc15.i686=3.0.0 gives version code 196608                  total       used       free     shared    buffers     cached     Mem:       2752180    2527816     224364          0      11232     499444     -/+ buffers/cache:    2017140     735040     Swap:      4849660     500048    4349612      dmidecode http://pastebin.com/CNrph9KA kernel logs http://pastebin.com/QvqUmEZb


A file exists but executing it doesn't work

I downloaded a Java tarball, extracted the archive and copied over scp to a remote machine. Using the `ls` command, the java executable exists:               ubuntu@Ubuntu:~$ ls -la /home/ubuntu/jre1.7.0_55/bin/     total 420     drwxr-xr-x 2 ubuntu ubuntu   4096 Mar 18 03:54 .     drwxr-xr-x 6 ubuntu ubuntu   4096 Apr 30 12:55 ..     lrwxrwxrwx 1 ubuntu ubuntu      8 Apr 30 10:58 ControlPanel -> jcontrol     -rwxr-xr-x 1 ubuntu ubuntu   5714 Mar 18 03:53 java     -rwxr-xr-x 1 ubuntu ubuntu  16246 Mar 18 03:54 java_vm     -rwxr-xr-x 1 ubuntu ubuntu 104497 Mar 18 03:54 javaws     -rwxr-xr-x 1 ubuntu ubuntu   6391 Mar 18 03:54 jcontrol     -rwxr-xr-x 1 ubuntu ubuntu   5873 Mar 18 03:53 keytool     -rwxr-xr-x 1 ubuntu ubuntu   6013 Mar 18 03:53 orbd     -rwxr-xr-x 1 ubuntu ubuntu   5893 Mar 18 03:53 pack200     -rwxr-xr-x 1 ubuntu ubuntu   5981 Mar 18 03:53 policytool     -rwxr-xr-x 1 ubuntu ubuntu   5865 Mar 18 03:53 rmid     -rwxr-xr-x 1 ubuntu ubuntu   5877 Mar 18 03:53 rmiregistry     -rwxr-xr-x 1 ubuntu ubuntu   5893 Mar 18 03:53 servertool     -rwxr-xr-x 1 ubuntu ubuntu   6045 Mar 18 03:53 tnameserv     -rwxr-xr-x 1 ubuntu ubuntu 215380 Mar 18 03:53 unpack200      However:               ubuntu@Ubuntu:~$ /home/ubuntu/jre1.7.0_55/bin/java     -bash: /home/ubuntu/jre1.7.0_55/bin/java: No such file or directory      What's the reason?


How do I completely disable an account?

How do I completely disable an account? `passwd -l` will not allow anyone to log into an account using a password but you can still log in via private/public keys. How would I disable the account completely? As a quickfix I renamed the file to `authorized_keys_lockme`. Is there another way?


How do I stop sed from adding extra newline characters

I am running the following 2 `sed` commands. The first one adds newline characters where I want them, the second also adds newline characters where I want them, BUT also adds an extra one at the end of the file where there wasn't one before.               sed -e 's|\<LIST_G_STATEMENT>|&\     |g' ${XMLDIR}/statement_tmp_1.xml > ${XMLDIR}/statement_tmp_2.xml          sed -e 's|\</LIST_G_STATEMENT>|&\     |g' ${XMLDIR}/statement_tmp_2.xml > ${XMLDIR}/statement_tmp_3.xml      Using `od -c` on all 3 of the files gives the following output. statement_tmp_1.xml (no `\n` at end of file)               1314700    T   A   T   E   M   E   N   T   >   <   /   L   I   S   T   _     1314720    G   _   S   T   A   T   E   M   E   N   T   >   <   /   G   _     1314740    S   E   T   U   P   >   <   /   L   I   S   T   _   G   _   S     1314760    E   T   U   P   >   <   /   A   R   X   S   G   P   O   >     1314777      statement_tmp_2.xml (no `\n` at end of file)               1314700    S   T   A   T   E   M   E   N   T   >   <   /   L   I   S   T     1314720    _   G   _   S   T   A   T   E   M   E   N   T   >   <   /   G     1314740    _   S   E   T   U   P   >   <   /   L   I   S   T   _   G   _     1314760    S   E   T   U   P   >   <   /   A   R   X   S   G   P   O   >     1315000      statement_tmp_3.xml (`\n` at end of file - where did it come from?)               1314700    S   T   A   T   E   M   E   N   T   >   <   /   L   I   S   T     1314720    _   G   _   S   T   A   T   E   M   E   N   T   >  \n   <   /     1314740    G   _   S   E   T   U   P   >   <   /   L   I   S   T   _   G     1314760    _   S   E   T   U   P   >   <   /   A   R   X   S   G   P   O     1315000    >  \n     1315002      I am running AIX 5.3 Basically, I either want it to stop adding the extra `\n`, or find a way of removing it.


Fix the debian default version to wheezy

I followed this tutorial http://kemitix.postach.io/install-viber-on-debian- wheezy to install viber on debian wheezy 7.6. My problem is about the part that says: > Fix the default version to wheezy. Add this line to > /etc/apt/apt.conf.d/10release: APT::Default-Release "wheezy"; i went to /etc/apt/apt.conf.d/ but there wasn't a 10release file, so i created it and i add the line. After this i did an update and i install libc6 from the testing repository. I saw from the installation log of libc6 that a lot of system libs,etc were changed.   1. So why the 10release file didn't exist? do i need to add the `APT::Default-Release "wheezy";` line somewhere else too?   2. What exactly happed by installing this lib from testing repository?   3. Will i get updates from the testing repo? Did the testing entry to the sources.list changed my debian version?   4. How can i ensure that my default version is wheezy and i won't get updates from testing repo?


Select default binary to use

This is the output from `which -a autoconf`:               /usr/bin/autoconf     /usr/bin/autoconf     /home/amumu/root/bin/autoconf      I want to use autoconf in my home directory since it's newer version compare to the default in the server. How to set it as the default? I don't want to overwrite `/usr/bin/autoconf` or write to `/usr/local/bin`


Can anyone recommend some linux kernel related books for beginners?

I'm a newcomer of Linux kernel, and I want to know the mechanism of Linux kernel. But I was confused by such a huge number of concepts, structs and functions after the reading of _Understanding the Linux kernel_. This book details too many concepts which make me lost in the complex net of relationships between these components. I think I want a book which has many figures to describe these relationships behind this monolithic system. This book needs to describe the mechanisms of kernel instead of details how these functions work. Is there a such book?


How to dual-boot on a machine with PGP WDE?

PGP Whole disk encryption ("WDE") is an encryption software that encrypts all your data, and includes a bootguard. Because of this, I have been unable to successfully dual-boot, as there is no place to install GRUB. (I did attempt an install, the result of which was a complete loss of my Windows partition, and a completely shot weekend.) I attempted the Ubuntu dual-boot (wubi version, does not install bootloader), but since the sequence is PGP decrytption-bootloader-OS, the data necessary for the install were inaccessible. The computer is a work computer, and I have not been granted permission to decrypt it. I'm booting off an external drive for now, but are there any good means of doing this?


Send specific signal number with specific key

I want to set a specific key like F12 to send me a specific signal number that out of linux signals range that I can handle this signal with `trap` command. How can I do that? **NOTE:** I'm working with console and X server not installed.


How to enable killing Xorg with Ctrl+Alt+Backspace

I don't remember why they did this, but at one point X.org decided that disabling `Ctrl``Alt``Backspace` to kill it was a good idea. I know there's a way to re-enable it but I don't remember how. Can someone refresh my memory?


Multiple pattern match and print in single line

I need to match two patterns in a log file and need to get the next line of the one of the pattern (out of two patterns) that is matched, finally need to print these three values in a single line. Sample Log File:               2013/09/05 04:26:00          Processing Batch /fbc/dev/cebi/dod/9739867262     2013/09/05 04:26:02          Batch 9739867262 was successful     2013/09/05 04:26:02          Total Time          =  3.13 Secs     2013/09/05 04:26:02          Repository API Time =  2.96 Secs     2013/09/05 04:26:02          File System Io Time =  0.06 Secs     2013/09/05 04:26:02          Doc Validation Time =  0.03 Secs     2013/09/05 04:26:02      Ending @ Thu Sep 05 04:26:02 EDT 2013     2013/09/05 08:18:10      Starting @ Thu Sep 05 08:18:10 EDT 2013     2013/09/05 08:18:10      Starting @ Thu Sep 05 08:18:10 EDT 2013     2013/09/05 08:18:10          Processing Batch /fbc/dev/cebi/dod/9844867675     2013/09/05 08:18:10          Processing Batch /fbc/dev/cebi/dod/9886743777     2013/09/05 08:18:16          Batch 9844867675 was successful     2013/09/05 08:18:16          Total Time          =  6.00 Secs     2013/09/05 08:18:16          Repository API Time =  5.63 Secs     2013/09/05 08:18:16          File System Io Time =  0.05 Secs     2013/09/05 08:18:16          Doc Validation Time =  0.19 Secs     2013/09/05 08:18:16      Ending @ Thu Sep 05 08:18:16 EDT 2013     2013/09/05 08:18:18          Batch 9886743777 was successful     2013/09/05 08:18:18          Total Time          =  8.27 Secs     2013/09/05 08:18:18          Repository API Time =  8.52 Secs     2013/09/05 08:18:18          File System Io Time =  0.08 Secs     2013/09/05 08:18:18          Doc Validation Time =  0.47 Secs     2013/09/05 08:18:18      Ending @ Thu Sep 05 08:18:18 EDT 2013      I have the numbers seperatly in file named cust_no.txt               9739867262     9844867675     9886743777      Taking these numbers as input I need to match following two patterns in the log file   1. Processing Batch /fbc/dev/cebi/dod/   2. Batch was successful Following are required as output: -> On the match of first pattern (`i.e Processing Batch /fbc/dev/cebi/dod/<numbers in the cust_no.txt>`) I need to get the 2nd word i.e $2 . -> On the match of second patterns (`i.e Batch <numbers in the cust_no.txt> was successful`) I need to get the 2nd word i.e $2 -> And the 6th word ($6) on the next line after the match after the second pattern (i.e the line staring with `Total Time` )  Desired output:               9739867262,04:26:00,04:26:02,3.13 Secs     9844867675,08:18:10,08:18:16,6.00 Secs     9886743777,08:18:10,08:18:18,8.27 Secs      In order get this I tried in the below way but this seems not to work:               awk -v cn=$cust_no '{{if ($0 ~ "Processing.*" cn) st=$2 && if ($0 ~ "Customer cn was successful" et=$2; getline; tt=$4} ; print st,et,tt}


How to find the installation path for a software under linux?

Under linux, I launch a software by typing, e.g., fluidplot. How can I find the installation path for this software?


Text editor with font-size selection for specific human languages (ie. Unicode Block) eg Devanagari

Pre Linux, I used Windows.. (too many years in the wilderness :) ... however there was a ray of sunshine in amongst all the general virus/re-install flack.. and that was Notepad++, a text Editor I really like(d). I'd probably still be using it, even now that I've shifted fully across to Linux(Ubuntu), but it doesn't behave 100% in 'wine'... (and its regex is stunted)... There is one feature in Notepad++ which I sorely miss, and that is the ability to display different SIZE fonts within a single document (at the same time)... At some point, I started learning Hindi, and found that the Devanagari script really needs to be larger than the Latin script (used here)... Devanagari is by nature a "taller" script, with frills above, and below the main line, and has more detail. Because of this I utilized Notepad++'s Syntax Highlighting to display my learning notes in a manner my eyes could handle... Now my dilemma, is to find a Linux Text Editor which can (at least) do what Notepad++ can do (ie. allow me to specify my own mix of font SIZES, and also to specify my own comment-delimiters)... **Now, the big ask**... What I would really like is an editor which is "Human- Language" aware, or "Font-Type" aware, or "Unicode-Codeblock" aware... so I don't have to fiddle and twiddle with syntax-highlighting, which is really not intended for what I want.. (PS... I don't want a word-processor) In October, last year, I asked here about SciTe (Scintilla) specifically (Notepad++ is based on Scintilla), but as per one answer, it is _too painful_ :) ... A comment suggested that Emacs could do it, so if that means "at the same time", then I'm interested, but I need some initial pointers on how to go about it... Here is an example of the Notepad++ presentation.. ![Here is an example of the Notepad++ presentation](http://i.stack.imgur.com/Cn79h.png)


What is Linux doing differently that allows me to remove/replace files where Windows would complain the file is currently in use?

The example I have is Minecraft. When running Bukkit on Linux I can remove or update the .jar files in the /plugins folder and simply run the 'reload' command. In Windows, I have to take the whole server process down because it will complain that the .jar file is currently in use when I try to remove or replace it. This is awesome to me, but why does it happen? What is Linux doing differently here?


What is the default action for incoming packets that don't match explicit iptables rules?

CentOS 5.x I'd like to understand what is specifically happening to incoming packets that don't explicitly match rules in my iptables chains. Is the default action to reject them? Or drop them? How/where can I set this? Here's an example output of my firewall setup (some ports have been modified to protect the innocent :-) ) :               Chain INPUT (policy ACCEPT)     target     prot opt source               destination     RH-Firewall-1-INPUT  all  --  anywhere             anywhere          Chain FORWARD (policy ACCEPT)     target     prot opt source               destination     RH-Firewall-1-INPUT  all  --  anywhere             anywhere          Chain OUTPUT (policy ACCEPT)     target     prot opt source               destination          Chain RH-Firewall-1-INPUT (2 references)     target     prot opt source               destination     ACCEPT     all  --  anywhere             anywhere     ACCEPT     all  --  anywhere             anywhere     ACCEPT     icmp --  anywhere             anywhere            icmp any     ACCEPT     esp  --  anywhere             anywhere     ACCEPT     ah   --  anywhere             anywhere     ACCEPT     all  --  anywhere             anywhere            state RELATED,ESTABLISHED     ACCEPT     tcp  --  anywhere             anywhere            state NEW tcp dpt:456     REJECT     all  --  anywhere             anywhere            reject-with icmp-host-prohibited      The key point though is that I have a different chain called `RH- Firewall-1-INPUT` that doesn't have an explicit `(policy ACCEPT)` or `(policy REJECT)` statement. What would be the default behavior for that (assuming of course that I'm NOT matching any of the prior rules). Is the last line just a "catch all"?


What is the difference between likely and unlikely calls in Kernel?

What is the between likely and unlikely calls in Kernel. While searching through the kernel source i found these statements.               # define likely(x)      __builtin_expect(!!(x), 1)     # define unlikely(x)    __builtin_expect(!!(x), 0)      Could somebody shed some light into it?


Are there any canned solutions for running sshd in the initrd?

This is mostly aimed at Debian/Ubuntu, but I feel savvy enough on a variety of distros to be able to adapt the solution for one distro to another. Here's my scenario. There are a few situations when the boot process will drop you to the shell (usually busybox) of the initrd. Most notably whenever you run a hardware RAID for which drivers have to be rebuilt for each and every new kernel revision. I'd like to be able to access the rescue system the same way as I would access the fully booted system. I reckon it'd be possible to put static builds of the shell(s) and `sshd` (OpenSSH or dropbear) into the initrd and have been looking for an existing solution that I can adjust to my needs. Assuming there is no existing solution (since I have searched for quite a while) what do I need to consider aside from using static builds where possible (or supply the libs)? Is it reasonable to simply cache a static build of dropbear and use `/etc/initramfs-tools/hooks` to embed that along with a "converted" OpenSSH `sshd_config` and the original host keys?


What should look for in log files if I think limited memory or disk space is causing a crash?

Troubleshooting /var/log files for a recent series of crashes, what should I look for in the files if I believe low memory or disk space are to blame? Is there a _general term_ used in the Linux error-throwing lingo for hardware faults of this kind? And, what system processes would be effected, such as the kernel, by a critical shortage of memory? * * * Just as background, I was working on a Drupal site hosted on my Fedora 17 sandbox project laptop when I experienced these system crashes. Recently I've downloaded some rather large files (I've since moved to media) and was down to about 1.8G of HD space. I found some useful posts here about monitoring memory usage with `top` or current disk usage with `du`. This question, however, is specifically about log files. I found a similar post at Fedora Forums searching for an explanation of `FPrintObject` which lead me to do Memtest, but nothing is reported bad there.


Cannot execute binary file on Linux server

I'm currently trying to run Knime (a Java-based program) on a Linux server, and every time I try to execute the file (knime) it gives me a "cannot execute binary file" error. I've posted the relevant information below.                 uname -a          Linux safar 2.6.32-5-amd64 #1 SMP Sun Sep 23 10:07:46 UTC 2012 x86_64 GNU/Linux            ls -al knime_2.6.3          drwxrwxr-x 10 **** **** 4096 Nov 28 23:18 knime_2.6.3            ls -al /knime_2.6.3/knime          -rwxrwxrwx 1 **** ***** 71162 Oct 15 15:11 knime      For reference, the file's name is "knime" and it's within the "knime_2.6.3" folder. There are other files within that folder pertinent to Knime (which I can post information about if necessary) but the Readme simply says to execute knime. Here's the error:                 . knime            -bash: .: knime: cannot execute binary file      I'm not really experienced with Linux, so any help would be appreciated. Thank you!


Exception of inheritance of environment variables

Quoted from Wikipedia: > By default, when a process is created it inherits a duplicate environment of > its parent process, **except for explicit changes made by the parent when it > creates the child**. At API level, these changes must be done between fork > and exec. Alternatively, from shells such as bash, you can change > environment variables for a particular command invocation by indirectly > invoking it via env or using the ENVIRONMENT_VARIABLE=VALUE notation. I understand that "when a process is created it inherits a duplicate environment of its parent process". But I was wondering what the exception "explicit changes made by the parent when it creates the child" really means? I don't understand how the examples in API and shells are examples of the exception.


How can I fsck a partition when the device reads as busy (but has been confirmed otherwise)?

I'm attempting to run `fsck -p /dev/sda5` to repair errors on an ext4 partition, however the command outputs               fsck from util-linux-ng 2.17.2     fsck.ext4: Device or resource busy while trying to open /dev/sda5     Filesystem mounted or opened exclusively by another program?      I have confirmed using `/etc/mtab` and `lsof` that nothing is using the partition and it's not mounted. I also used `fuser -k /dev/sda5` to forcibly close anything using the file, and `umount` to attempt to unmount it to no avail. **How can I force`fsck` to at least check, and hopefully to repair, the partition despite the fact that it reads as busy?** Assuming I'm confident enough that it's neither mounted nor in use, and that the possibility of data corruption isn't an issue. _All commands were executed as root from an Ubuntu 10.04 32-bit liveCD. The partition is the system (non-home) portion of an Ubuntu 10.04 32-bit installation._


How to merge 2 PDF files with interleaving pages order?

I've got a double-side-printed multipage document to scan with a linear bulk scanner. So, as the result I get 2 PDF files: one containing all odd pages and the second containing all even pages. I need to merge them the natural way:               1. <- 1.1. (odd.pdf page 1 to result.pdf page 1)     2. <- 2.1. (even.pdf page 1 to result.pdf page 2)     3. <- 1.2. (odd.pdf page 2 to result.pdf page 3)     4. <- 2.2. (even.pdf page 2 to result.pdf page 4)      etc.


Can't connect unsecured wifi from Wicd or terminal

I can connect without issue to `WPA` networks, but if I am somewhere like a hotel and try to connect to an unsecured WiFi, things hang at the `DHCP` part and I don't get an `IP` assigned. I'm running Ubuntu 12.04 and my Wifi is on `eth1` Wicd, hangs at the getting IP address part. I've tried also (as root)               ifconfig eth0 down     ifconfig eth1 down     dhclient -r eth1     iwconfig eth1 essid AP_Name     ifconfig eth1 up     dhclient eth1      this just hangs at the `dhclient eth1` request until I `Ctrl+C` it.


ext3 Filesystem shows full to most apps, but only 77% full to DF

Var is showing as full to many apps like Nagios, Puppet, and the LVM tools (pvs, vgs, etc) **df -h output**               6.0G  4.3G  1.4G  77% /var      **vgs output**               /var/lock/lvm/V_rootvg:aux: open failed: No space left on device       Can't get lock for rootvg       Skipping volume group rootvg      `lsof +L1` shows nothing under var anymore, so I don't think there are unlinked files which have yet to be cleared from the `/var` filesystem. I don't understand why 1.4G free on a 6G filesystem is considered full. I know some space is reserved by the system on each filesystem but that can't be it, it's too much space. The filesystem is `ext3` on Red Hat 5.               dumpe2fs 1.41.12 (17-May-2010)     Filesystem volume name:   <none>     Last mounted on:          <not available>     Filesystem UUID:          c8f44510-e8f7-4e2e-950a-1410b069910e     Filesystem magic number:  0xEF53     Filesystem revision #:    1 (dynamic)     Filesystem features:      has_journal ext_attr resize_inode dir_index filetype needs_recovery sparse_super large_file     Filesystem flags:         signed_directory_hash      Default mount options:    user_xattr acl     Filesystem state:         clean     Errors behavior:          Continue     Filesystem OS type:       Linux     Inode count:              393216     Block count:              1572864     Reserved block count:     78627     Free blocks:              1183083     Free inodes:              388144     First block:              0     Block size:               4096     Fragment size:            4096     Reserved GDT blocks:      63     Blocks per group:         32768     Fragments per group:      32768     Inodes per group:         8192     Inode blocks per group:   512     Filesystem created:       Mon Apr 29 13:12:02 2013     Last mount time:          Wed Oct 23 19:10:44 2013     Last write time:          Wed Oct 23 19:10:44 2013     Mount count:              6     Maximum mount count:      -1     Last checked:             Mon Apr 29 13:12:02 2013     Check interval:           0 (<none>)     Reserved blocks uid:      0 (user root)     Reserved blocks gid:      0 (group root)     First inode:              11     Inode size:           256     Required extra isize:     28     Desired extra isize:      28     Journal inode:            8     Default directory hash:   half_md4     Directory Hash Seed:      8766dfd5-c802-4bc3-81cc-21869e810656     Journal backup:           inode blocks     Journal features:         journal_incompat_revoke     Journal size:             32M     Journal length:           8192     Journal sequence:         0x0112568e     Journal start:            3334


Linux command line that will fail if any standard out is produced

Is there a simple utility which I can pipe output to on Linux that will:   * Return a success code if there is no output on standard out (and / or standard error).   * Return a failure code if output is produced on standard out (and / or standard error). To provide some context, the command I'm running is:               svn mergeinfo --show-revs eligible     http://mysvnserver.example.com/SVF/repos/common/abc/branches/abc-1.7     http://mysvnserver.example.com/SVF/repos/common/abc/trunk      If there are any unmerged entries on the branch, the command will return a list of revision numbers on standard out. Ideally, the additional command that I'm talking about would:   * Detect entries on standard out and return an error condition to Linux.   * Pass on the standard out so that it does end up appearing on the terminal. I'd rather not suppress it.


Setting vim filetype with modeline not working as expected

As per the accepted answer to this question, I'm attempting to use modelines in vim to force filetype detection in some files. For example, at the top of a file named `gitconfig` (note there is no leading `.`), I have the following line:               # vim: set filetype=gitconfig :       `modeline` is enabled on my system. However, when I open the file in vim, `set filetype?` returns `conf`, rather than the expected `gitconfig`. Is it possible that other parts of my vim configuration (e.g. filetype.vim) are causing this strange behaviour? Edited in response to comments: `set compatible?` returns `nocompatible` `set modeline?` returns `modeline` `verbose set filetype?` returns:               filetype=conf           Last set from /usr/share/vim/vim73/filetype.vim      I don't understand why the system wide filetype plugin would be overriding what I have set in the file itself. One final note: this is the version of Vim 7.3 shipped with OSX. The latest version of MacVim running on the same system using the same `.vimrc` behaves as expected, with `set ft?` returning `filetype=gitconfig`.


Diff head of files

I have two files. One file, I suspect, is a subset of the other. Is there a way to diff the files to identify (in a succinct manner) where in the first file the second file fits?