How do i suppress the editor in dpkg-source --commit calls? - linux

On Ubuntu precise
I am calling "dpkg -q --commit ./ patchsetname"
When I do this it decides to open an editor using the select editor binary.
I want to suppress that. Any thoughts?
I'd rather not have to interrupt the exec syscall with a shared library and filter for the editor query. There should be a cleaner way of doing this.

I just fixed this with the following:
EDITOR=/bin/true dpkg-source -q --commit . patchsetname
This will (obviously) use true instead of nano and at least on kubuntu this seems to work fine.

Related

how to start the neovim gio from the cli

I'm trying to switch from vim/gvim to neovim on Linux. Up to now my standard workflow started with opening the cli, navigate to my project directory, and run gvim <filename> with the file I intend to start working with.
With neovim I can start it from the KDE menu to get a nice GUI. according to the menu settings, it simply runs nvim with an optional filename parameter. But I don't find the way to run nvim from the cli in a way, that it starts the GUI. Running nvim <filename> simply starts the cli UI.
Google gave me a lot of interesting information, but not, what I'm looking for.
There are different GUIs for neovim. Check which one do you actually use and start it from the command line. Navigate to the KDE menu for neovim GUI, right-click on it and select Edit application... Go to the Application tab and check the Command edit box. There you'll see the actual command which is run by KDE when you select the corresponding menu item. You can create your own shell script or alias which will run this command and use it on the command line.
UPDATE
Maybe some parameter or environment variable is passed to nvim so it changes its behavior. You can try to see what system call KDE actually performs to start the editor. For example, I'm using KDE plasma, so pidof plasmashell gives me the pid which I need. Then:
strace -f -v -e trace=execve -p `pidof plasmashell` &> plasma.trace
After that go to KDE menu and start neovim. Terminate the strace command with Ctrl-C and check the plasma.trace file for the execve system calls made to start the neovim process.

Cannot find chmod[metasploit installation]

in the picture below you can see that it says chmod command is not found yet it has chmod installed. I am installing metasploit directly from the terminal(I did not install any desktop environment and don't want to run msf from there). Is there any way to solve this? I would gladly appreciate any replies.
Instead of using that command, use this instead
curl https://raw.githubusercontent.com/rapid7/metasploit-omnibus/master/config/templates/metasploit-framework-wrappers/msfupdate.erb > msfinstall && chmod 755 msfinstall && ./msfinstall
Remove the backslashes from the composite Bash command, they're used in Linux to escape the space character. For example, ỳou would have to type:
cd ~/Documents/My\ Folder
to access
~/Documents/My Folder
By writing the command the way you did you were looking for the ' chmod' command instead of 'chmod', you've basically inserted a space before the command name.
I'd suggest studying Linux Bash scripting before venturing into Metasploit.
You would otherwise continually stumble against this kind of issues, also if you'd like to work with Metasploit from its command console it's pretty much mandatory to study Linux Bash scripting (and the Linux OS as a whole).

View source for standard Linux commands e.g. cat, ls, cd

I would like to view the source code for a Linux command to see what is actually going on inside each command. When I attempt to open the commands in /bin in a text/hex editor, I get a bunch of garbage. What is the proper way to view the source on these commands?
Thanks in advance,
Geoff
EDIT:
I should have been more specific. Basically I have a command set that was written by someone who I can no longer reach. I would like to see what his command was actually doing, but without a way to 'disassemble' the command, I am dead in the water. I was hoping for a way to do this within the OS.
Many of the core Linux commands are part of the GNU core utils. The source can be found online here
The file you are opening is the binary executables which are the stuff the kernel passes to the CPU. These files are made using a compiler that takes in the source code you and I understand and turns it via a number of stages into this CPU friendly format.
You can find out the system calls that are being made using strace
strace your_command
Most likely you can download the source code with your distribution's package manager. For example, on Debian and related distros (Ubuntu included), first find which package the command belongs to:
$ dpkg -S /bin/cat
coreutils: /bin/cat
The output tells you that /bin/cat is in the coreutils package. Now you can download the source code:
apt-get source coreutils
This question is related to reverse engineering.
Some keyword is static analysis and dynamic analysis
use gdb to check that the binary file have symbol table inside or not. (if binary compile with debugging flag, you can get the source code and skip below step)
observe program behavior by strace/ltrace.
write seudo-code by use objdump/ida-pro or other disassembler.
run it by gdb to dynamic analysis and correct the seudo-code.
A normal binary file can be reverted back to source code if you want and have time. Conversely, an abnormal program is not easy to do this, but it only appear on specific ctf competition. (Some special skill like strip/objcopy/packer ... etc)
You can see assembly code of /bin/cat with:
objdump -d /bin/cat
Then analyze it and see what command can be launch.
Another way of approaching is strings /bin/cat, it is usefull make a initial idea and then reverse it.
You can get the source code of every linux command online anyway :D

How to get Command history by cursor key in Linux tclsh

Can get the command history by using cursor key (like up arrow key) in TCL shell (tclsh).
I am running tclsh on fedora with linux version 2.6.21.
You want access to the readline library, you can do that with rlwrap:
$ rlwrap tclsh
Useful options are -c for file name completion, and -f to add words from a file to the completion list:
$ rlwrap -cf my_complete_file tclsh
Since you almost always want to use rlwrap, adding a shell alias is useful:
alias tclsh='rlwrap tclsh'
I usually use tkcon which comes with ActiveTcl, or as a separate installation. tkcon has many features, but the one I use the most is the command-line editing aspect.
Another good pure-terminal option is tclsh-wrapper
Link to tclsh-wrapper on github
It provides rich command line editing, history, aliasing, and keyword completion but does not require X11. Documentation for the key mapping is also available.

How does one override an existing zsh keyboard completion?

I would like to enable zsh to autocomplete modules for yast2 (an OpenSuSE control panel), but it seems to already have some things defined. I can run
compctl -k "(hello world)" nonexistantprogram
just fine, but
compctl -k "(hello world)" yast2
doesn't work at all. Some things for yast2 seem to be already defined, namely the "-" options: --fullscreen, --geometry, --list [submodules], etc.
Even if for those who don't use OpenSuSE: Are there any flags to compctl to make it override previous settings? Thanks very much in advance.
Most likely, your system is using the newer compsys system rather than the older compctl system. See man zshcompsys and man zshcompwid (and man zshcompctl).
The completion function for yast2 is probably in this file (or similar path):
/usr/share/zsh/functions/Completion/Linux/_yast

Resources