Affichage des articles dont le libellé est Recent Questions - Unix & Linux Stack Exchange. Afficher tous les articles
Affichage des articles dont le libellé est Recent Questions - Unix & Linux Stack Exchange. Afficher tous les articles

jeudi 26 mars 2015

(Linux - Command) How to disable keyboard's NUMPAD (located right side of the keyboard)


Does anyone knows how to do this?


I want to disable all numpads, the ones located on the right side of the keyboard.


How can I do that? Ofcource, including how to revert it back to re-enable it too?


I have tried different stuff, like remapping:



xmodmap -e "keycode # = """


But I get an error:



xmodmap commandline1: bad keycode value


Did I do it wrong?



How to print file content *and delete printed content* from file?


In Linux bash shell, How can I print file content and delete printed content from file?


I have a program writing texts to a file repeatedly. On a Linux shell prompt, I want to print the contents of the file and then delete printed contents from the file repeatedly, to make my file size small enough.


Do we have bash command lines or combinations to do that?



Keyboard merely plugged in greatly increases kernel boot time


Specs are here. I am using a K65 RGB. I am using the ckb-git package from the AUR to provide basic input functionality.



  • With Keyboard and with driver:


Startup finished in 3.100s (firmware) + 5.648s (loader) + 31.800s (kernel) + 5.664s (userspace) = 46.213s



  • Without Keyboard and with driver:


Startup finished in 2.873s (firmware) + 5.652s (loader) + 2.395s (kernel) + 5.855s (userspace) = 16.777s



  • With Keyboard without driver:


Startup finished in 3.120s (firmware) + 5.654s (loader) + 31.735s (kernel) + 5.583s (userspace) = 46.093s



  • Without Keyboard without driver:


Startup finished in 2.879s (firmware) + 5.653s (loader) + 2.279s (kernel) + 6.008s (userspace) = 16.821s


As you can see, the pure act of having the keyboard plugged into the computer causes the kernel to boot about 30 seconds slower. This is kindof rediculous.


While the kernel is booting it just says:



starting version 218


if I dont have it plugged in. I believe this is referring to the kernel booting.


If the keyboard is plugged in, then it says:



starting version 218
[ random number] usbhid 3-2:1.1: can't add hid device: -110
worker [66] /devices/pci0000:00/0000:00:14.0/usb3/3-2 is taking a long time
[ random number about times two] usbhid 3-2:1.2: can't add hid device: -110


Then it boots to arch.


It is good to note that if I plug in the keyboard after it boots to arch, it takes about 30 seconds for the keyboard to be recognized (but I can still use my old keyboard).



How to find whether a file exists in a directory or sub-directory or not


Try to write a code which indicates whether a named file exists or not in your home directory or any of its subdirectories. Any help??



Does the inode change when renaming or moving a file?


in PHP the fileinode() functions returns the inode of a file. I was wondering if I can use it to determine if a file was renamed, moved or modified.


I did some tests and it seems the inode stays the same after rename. Is this behavior consistent? Does it work for any type of file, on any linux distribution?



2 monitors works as wide one (xorg.conf, intel+nvidia)


I have 3 monitors (1 intel + 2 nvidia). After some magic with xorg.conf they started to work, but nvidia monitors works as one wide monitor (any fullsize window half/half seperated).



Section "ServerLayout"
Identifier "X.org Configured"
Screen 0 "Screen0" 0 0
Screen 2 "Screen2" RightOf "Screen0"
Screen 1 "Screen1" RightOf "Screen2"
InputDevice "Mouse0" "CorePointer"
InputDevice "Keyboard0" "CoreKeyboard"
Option "Xinerama" "on"
EndSection

Section "Device"
Identifier "Card0"
Driver "intel"
BusID "PCI:0:2:0"
EndSection

Section "Device"
Identifier "Card1"
Driver "nvidia"
BusID "PCI:1:0:0"
EndSection

Section "Monitor"
Identifier "Monitor0"
VendorName "Monitor Vendor"
ModelName "Monitor Model"
EndSection

Section "Monitor"
Identifier "Monitor1"
VendorName "Monitor Vendor"
ModelName "Monitor Model"
EndSection

Section "Monitor"
Identifier "Monitor2"
VendorName "Monitor Vendor"
ModelName "Monitor Model"
EndSection

Section "Screen"
Identifier "Screen0"
Device "Card0"
Monitor "Monitor0"

EndSection

Section "Screen"
Identifier "Screen1"
Device "Card1"
Monitor "Monitor1"
Option "TwinView" "0"
EndSection

Section "Screen"
Identifier "Screen2"
Device "Card1"
Monitor "Monitor2"
Option "TwinView" "0"
EndSection


I'm so sorry for my English and idiotic xorg.conf :)



Combine lines of file to string [on hold]


I am trying to have a file inputted by my script and put into a string to be put into another file.



./script.sh -u uuids.txt -s servers.txt


Each file will have a list with each value being on it's own line and where each line on each file belong together each time the string is made.



user:UUID:*:SERVER


That is an example of the string with the variables put into it.


I have the getops part right and I am able to print out the file contents correctly. I am asking for a way to add the lines one by one to the string to be added to a new line in another file.


I was thinking having awk split the lines within a loop that runs how ever many times for the lines in the files this would then save the overall string (pictured above) to a new line of a file with the >>.




I would like run remote ssh commands and have them always load server-side startup files by default. I am looking for a solution that does not require:



  • configuration by root

  • adding extra boiler plate to the command each time

  • duplicating environment variables across multiple files


I am not looking to transport local environment variables to the remote shell. I want to run a remote command using the vanilla ssh <host> <command> syntax and have it run using the same environment a remote login session would get.


Background


The below assumes bash is being used for simplicity


By default, remote ssh commands start a non-interactive, non-login shell. Quoting the man page:



If command is specified, it is executed on the remote host instead of a login shell.



You can see this more explicitly on the shell by running:



# the lack of 'i' indicates non-interactive
$ ssh localhost 'echo $-'
hBc

$ ssh localhost 'shopt login_shell'
login_shell off


But what if your remote command needs certain environment variables set? Being a non-interactive, non-login shell means neither .bash_profile or .bashrc will be sourced.


This is problematic, for example, if you're using tools like perlbrew or virtualenv and want to use your custom interpreter in the remote command:



$ which perl
/home/calid/perl5/perlbrew/perls/perl-5.20.1/bin/perl

$ ssh localhost 'which perl'
/usr/bin/perl


Solutions that do not satisfy the requirements above


Explicitly invoke a login shell in the remote command


$ ssh localhost 'bash --login -c "which perl"'


Requires extra boiler plate each time


Explicitly source your profile before the command


$ ssh localhost 'source ~/.bash_profile && which perl'


Requires extra boiler plate each time


Set environment variables in ~/.ssh/environment


Requires root to enable this functionality on the server


Duplicates environment variables already set in server startup files


Set ENV and BASH_ENV


Does not work: .bash_profile and .bashrc aren't sourced


Setting in ~/.ssh/environment works, but requires root access to enable


Preface the command with the environment variables you need


Requires extra boiler plate each time (potentially a lot)


Duplicates environment variables already set in server startup files


Related posts


http://ift.tt/1N8Y1Bc


http://ift.tt/1E0cPR3


dot file not sourced when running a command via ssh



In bash .* equals to upper directories


Someone of our team wanted to recursively change the user permissions on all hidden directories in a users home directory. To do so he executed the following command:



cd /home/username
chown -R username:groupname .*


We were pretty surprised when we realized, that he actually recursively changed the permissions of all user directories in /home, because .* equals to .. as well. Would you have expected this behavior in Linux though?



Configured terminal window size does not create terminal windows of correct size


With my Xubuntu 12 with xfce I have configured a standard 80x24 window size for my terminals. But opening a window results in a smaller 79x24 window. (To me this looks like a bug - at least my former Xubuntu system did not show that behaviour -, but in case I missed something I welcome pointers.)


What can I do to get the window size I configured through my profile setting?


Additional information (in case it matters): Some additional configuration for terminal windows I have done is; activating vertical scroll bar, changing the font size to a larger font, and using a bold face font. (I think that none of that should result in a reduction of the configured dimension which is defined in units of to be displayed characters, or so I think.) And I also already looked into the configuration file ~/.config/Terminal/terminalrc (as proposed in another SE question), but there's also just the things visible that I configured by the GUI, specifically the 80x24 setting.)


(In case it's a bug I'd also welcome hints for alternatives.)



Help me: HTTP POST Request with Curl


I want to generate a HTTP request with CURL: enter image description here


The purpose is that, I could make such request without need to "acctually click on a webpage".








enter image description here


Do you guys think this is correct?


curl --data "GENERATE_SNAPSHOT=Generate Snapshot" http://ift.tt/1yfM2Jh



Binder warned not to be used outside Android


I am reading an article from lwn and it mentions the following:



Binder has a number of serious security issues when used outside of an Android environment, he said, so he stressed that it should never be used by other Linux-based systems.



Does anyone know which issues this author is referring to ?



What is the meaning of read -r ?


in order to understand another answer:



find / -type d -print0 | while read -r -d ''; do ls -ltr "$dir" | sed '$!d'


the first step is to understand the usage of the option -r of the read command.


First, I thought, it would be sufficient to simply execute



man read


to lookup the meaning of the -r option , but I realized the man page does not contain any explanation for option at all, so I googled for it got some read -t , read -p examples but no read -r .



Encrypted FileSystem in VirtualBox


I'm looking for any information regarding how secure an encrypted Linux file system is when contained in a VirtualBox virtual drive on a Windows host? Specifically I'm looking for answers to the following questions:



  1. Does the fact it is hosted as a guest system expose the encrypted data to any new attack vectors?

  2. Aside from the threat of key loggers on the Host OS, malware etc., when the virtual machine is turned on is there the threat of a rogue host process accessing the virtual machine's file system on the fly?

  3. When both the Host and Guest OSes are turned off and the data is at rest on a storage device, is it any easier/harder to retrieve the encrypted file system?



Porting Binder IPC to Linux


Android provides a device driver based IPC mechanism called Binder. I see it as one of the staging drivers in Linux. Although I can have a linux kernel running with this device driver, if I want to use it for IPC between applications in my desktop Linux, what other steps do I need to complete ?


Any reference would be helpful.



Dynamic linking of library to another process using C Program


Lets say I have two process A and B.I have a library called libsample.so. The question is, Can I load libsample.so dynamically to process B using Process A. If I can , How can I do it?



Check for hardware damage (GPU)


I need to check for damage to my graphics card. I suspect I have done damage to my gpu through overclocking. Now, whenever I do anything graphically intensive my screen will flash various colours and then turn off. The system is also then unresponsive.


Here you can find the Dmesg and Xorg logs after such an event.


My question is, what should I be looking for in the system logs to confirm this? Also are there other tools that can give me more diagnostic information about the hardware?



chown .bash_aliases


I need to append would be aliases to the .bash_aliases file through the echo command


For example I echoed this command echo 'cp -r .git ls | grep -v .gitignore ~/env/' >> ~/.bash_aliases to the .bash_aliases file and later created the alias alias uu=cp -r .git ls | grep -v .gitignore ~/env/ (note escape characters missing)


I was not able to echo onto the .bash_aliases file until I made the below permission changes:



sudo chmod 660 .bash_aliases
chown tech-ministry:tech-ministry .bash_aliases


The resulting permission changes:



-rw-r----- 1 tech-ministry tech-ministry 231 Mar 26 02:05 .bash_aliases


Previously the file was owned by root and I was unable to echo onto the .bash_aliases file as I was told I did not have sufficient privileges. I even tried with the sudo command, but I was still unable to append. Thus I changed permissions as stated.


Now whenever I open a terminal shell I see this:



bash: alias: -r: not found
bash: alias: .git: not found
bash: alias: 2my_comp.sh: not found
bash: alias: cron_vs_sudo.txt: not found
bash: alias: cust_packages.txt: not found
bash: alias: Desktop: not found
bash: alias: Documents: not found
bash: alias: Downloads: not found
bash: alias: env: not found
bash: alias: examples.desktop: not found
bash: alias: morning-ravine-7736: not found
bash: alias: Music: not found
bash: alias: my_computer.sh: not found
bash: alias: pack_me_in: not found
bash: alias: Pictures: not found
bash: alias: Public: not found
bash: alias: skype-install.deb: not found
bash: alias: Templates: not found
bash: alias: Videos: not found


I used chown to revise the permissions back to root:root and I sourced the file, but I still see the above 'bash: alias:' dump every time I open a terminal shell.


What have I done and how could I repair? Does the .bash_aliases file NEED to be root?



How to make backticks accept variables as variables?


In my bash script I have the following line


[backtick]mosquitto_pub -t '/$location/[backtick]


With this I want to 'publish' to the MQTT stream. The publishing part works great but it takes the variable name $location literally, and doesn't substitute $location with the initialized value for like NYC,Paris or Tokyo.


Q: How can make it so that the assigned value/string gets substituted to $location when the code is executed



Several hard-links with different metadata in Linux using Ext4


Is it possible for Ext4 file systems (or maybe another one understood by Linux) to assign different metadata (like modification time, owner, access rights) to several hard-links that refer to the same data. (I know that for the size this is impossible, of course).


Rationale: I want to create a simple de-duplicated archive. It can (and often will) happen, that files contain precisely the same data, but the metadata differ. My idea was to create a hard-link per file and then set the metadata accordingly. But changing one hard-link seems to also change the others. (Or maybe there's another solution to my problem?)