The Wiert Corner – irregular stream of stuff

Jeroen W. Pluimers on .NET, C#, Delphi, databases, and personal interests

  • My badges

  • Twitter Updates

  • My Flickr Stream

  • Pages

  • All categories

  • Enter your email address to subscribe to this blog and receive notifications of new posts by email.

    Join 2,481 other followers

Archive for the ‘*nix’ Category

Filippo Valsorda on Twitter: “whoami.filippo.io , the SSH server that knows who you are … Try it out! $ ssh http://whoami.filippo.io”

Posted by jpluimers on 2021/10/20

[Archive.is] Filippo Valsorda on Twitter: “whoami.filippo.io , the SSH server that knows who you are, got some newly refreshed intel! Try it out! $ ssh whoami.filippo.io

The server itself has some HTML with information too whoami.filippo.io redirecting to [WayBack] ssh whoami.filippo.io (source code is at [WayBack] GitHub – FiloSottile/whoami.filippo.io: A ssh server that knows who you are. $ ssh whoami.filippo.io).

It’s a cool open source server written in Golang, that gets all your public ssh keys (ssh automatically transmits those) and tries to map them back to a GitHub account.

In addition it shows you some potential vulnerabilities of your ssh client.

Note that in October 2020, it was temporarily down, but it will be up again: [Archive.is] Filippo Valsorda 💉💉 on Twitter: “Yeah I’m planning to but I can’t give you an ETA I’m afraid. A few weeks, maybe?… “

Thread comments

Some interesting comments in the thread:

Related: [WayBack] Auditing GitHub users’ SSH key quality

Stop presenting public keys

[WayBack] GitHub – FiloSottile/whoami.filippo.io: A ssh server that knows who you are. $ ssh whoami.filippo.io: How do I stop passing public keys

How do I stop it?

If this behavior is problematic for you, you can tell ssh not to present your public keys to the server by default.

Add these lines at the end of your ~/.ssh/config (after other “Host” directives)

Host *
    PubkeyAuthentication no
    IdentitiesOnly yes

And then specify what keys should be used for each host

Host example.com
    PubkeyAuthentication yes
    IdentityFile ~/.ssh/id_rsa
    # IdentitiesOnly yes # Enable ssh-agent (PKCS11 etc.) keys

If you want you can use different keys so that they can’t be linked together

Host github.com
    PubkeyAuthentication yes
    IdentityFile ~/.ssh/github_id_rsa

–jeroen

Read the rest of this entry »

Posted in *nix, *nix-tools, Communications Development, Development, Go (golang), Internet protocol suite, Power User, Software Development, SSH, ssh/sshd, TCP | Leave a Comment »

Raspberry Pi Turn Tv On/Off CEC – Tim Leland

Posted by jpluimers on 2021/10/13

[WayBack] Raspberry Pi Turn Tv On/Off CEC – Tim Leland (with some quote fixes) via [Archive.is] Brad Fitzpatrick on Twitter: “lol tear (from )… “:

Install cec-utils

Once everything is installed you should be able to control the tv using the command below:

  • Turn tv on: echo 'on 0' | cec-client -s -d 1
  • Turn tv off: echo 'standby 0' | cec-client -s -d 1
  • Set active source: echo 'as' | cec-client -s -d 1
  • Tv status: echo 'pow 0' | cec-client -s -d 1

Troubleshooting Tips:

  • Make sure your tv supports cec and that it is enabled. Tv manufactures call CEC by different names so you may have to do some research depending on your brand.
  • Make sure you are using a new hdmi cable that is at least HDMI 1.2a

Different names for HDMI CEC

  • Samsung – Anynet+
  • Sony – BRAVIA Link or BRAVIA Sync
  • Sharp – Aquos Link
  • Hitachi – HDMI-CEC
  • AOC – E-link
  • Pioneer – Kuro Link
  • Toshiba – Regza Link or CE-Link
  • Onkyo – RIHD (Remote Interactive over HDMI)
  • LG – SimpLink
  • Panasonic – VIERA Link or HDAVI Control or EZ-Sync
  • Philips – EasyLink
  • Mitsubishi – NetCommand for HDMI
  • Runco International – RuncoLink

Credits: http://raspberrypi.stackexchange.com/questions/7054/cec-wake-up-command

Related:

–jeroen

Read the rest of this entry »

Posted in *nix, *nix-tools, Development, Hardware Development, Hardware Interfacing, HDMI, Power User, Raspberry Pi, Software Development | Leave a Comment »

Some links on xargs simulation in PowerShell

Posted by jpluimers on 2021/10/13

On nx, I’m used to xargs which allows to convert from a pipe of output into arguments passed to a command. This is useful, as many commands only accept arguments as parameters.

In PowerShell, you can usually avoid an xargs equivalent because commandlet output is a stream of objects that you can post-process using . I for instance used that in PowerShell: recovering from corrupt empty *.nupkg files after a disk was accidentally full during update.

Here are some xargs equivalency examples:

  • [WayBack] PowerShell tips for bash users, part 1 • Five

    xargs

    Xargs is one of the most powerfull UNIX commands. It is used to build and execute command lines from standard input. For example:
    $ cat dirs | xargs mkdir
    will use cat to take the strings (be it newline or blank character separated) from file ‘dirs’ and pass them through pipe to xargs which will then send one by one line as argument to mkdir which will then create those dirs or complain if those are existent.

    PowerShell equivalent:

    PS> cat dirs | %{mkdir $_}

    There is no ‘xargs’ command in PS, but you can use ‘foreach ‘ loop and pass the piped variable ‘$_’ to the mkdir. Shorthand for ‘foreach’ is ‘%’. This time also only newlines will separate the strings apart. If multiple strings separated by blanks are found in same line, mkdir will create a directory with blanks in the name, while we must quote to have the same in bash:

    $ cat dirs | sed 's|^|"|g' | sed 's|$|"|g' |xargs mkdir

  • [WayBack] What’s the equivalent of xargs in PowerShell? – Stack Overflow

    Q

    The POSIX-defined xargs command takes all of the items it receives from standard input and passes them as command-line arguments to the command it receives on it’s own command line. E.g: grep -rn "String" | xargs rm.

    What’s the equivalent in PowerShell?

    The following questions all ask this:

    but there is no correct answer because all the answers either use ForEach-Object, which will process items one-at-a-time (like xargs -n1) which gets the desired result for the examples given, or store the intermediate result in a variable, which offends my functional commandline-fu.

    A

    There are two ways that I’ve found. The first is probably more idiomatic PowerShell, and the second is more true to the pipe-based spirit of xargs.

    As an example, let’s say we want to pass all our cat pics to myapp.exe.

    Method #1: Command substitution

    You can do something similar to using $(command substitution) in sh by embedding your pipeline in the command string:

    &"myapp.exe" @(Get-ChildItem -Recurse -Filter *.jpg | Another-Step)

    The @(...) creates an array from the command inside it, and PowerShell automatically expands arrays passed to & into seperate command-line parameters.

    However, this does not really answer the question, because it will only work if you have control over the command you want to pass to, which may not be the case.

    Method #2: True piping

    You can also construct a “double pipeline” by having a sub-expression to pipe your objects, collecting them to an array, and then piping the array to your final command.

    ,@(Get-ChildItem -Recurse -Filter *.jpg | Another-Step) | %{&"myapp.exe" $_}

    The @(...) as before collects the items into an array, and the array is then piped to the final command which is invoked using % (ForEach-Object). Ordinarily, this would then loop over each item individually, because PowerShell will automatically flatten the array when it’s piped, but this can be avoided by prepending the , operator. The $_ special variable is then used as normal to embed the passed array.

    So the key is to wrap the pipeline you want to collect in ,@(...), and then pipe that to something in %{...}.

References

–jeroen

Posted in *nix, *nix-tools, bash, CommandLine, Development, Power User, PowerShell, PowerShell, Scripting, Software Development, xargs | Leave a Comment »

More on empty files

Posted by jpluimers on 2021/10/07

TL;DR: Empty files are indeed of size zero, but there is some disk space involved for their meta-data (like name, permission, timestamps)

Some links (via [WayBack] create zero sized file – Google Search):

  • [WayBack] Zero-byte file – Wikipedia
  • [WayBack] filesystems – How can a file size be zero? – Super User (thanks [WayBack] phuclv):

    Filesystems store a lot of information about a file such as file name, file size, creation time, access time, modified time, created user, user and group permissions, fragments, pointer to clusters that store the file, hard/soft links, attributes… Those are called file metadata. Why do you count those metadata into file size when users do not (need to) care about them and don’t know about them? They only really care about the file content

    Moreover each filesystem stores different types of metadata which take different amounts of space on disk. For example POSIX permissions are very different from NTFS permission, and there are also inode numbers in POSIX which do not exist on Windows. Even POSIX filesystems vary a lot, like ext3 with 32-bit block address, ext4 with 48-bit, Btrfs with 64-bit and ZFS with 128-bit address. So how will you count those metadata into file size?

    Take another example with a 100-byte file whose metadata consumes 56 bytes on the current filesystem. We copy the file to another filesystem and now it takes 128 bytes of metadata. However the file contents are exactly the same, the number of bytes in the files are also the same. So displaying file size as 156 bytes on a system but 228 bytes on another is very confusing and counter-intuitive.

  • [WayBack] What is the concept of creating a file with zero bytes in Linux? – Unix & Linux Stack Exchange:

    touch will create an inode, and ls -i or stat will show info about the inode:

    $ touch test
    $ ls -i test
    28971114 test
    $ stat test
      File: ‘test’
      Size: 0           Blocks: 0          IO Block: 4096   regular empty file
    Device: fc01h/64513d    Inode: 28971114    Links: 1
    Access: (0664/-rw-rw-r--)  Uid: ( 1000/1000)   Gid: ( 1000/1000)
    Access: 2017-03-28 17:38:07.221131925 +0200
    Modify: 2017-03-28 17:38:07.221131925 +0200
    Change: 2017-03-28 17:38:07.221131925 +0200
     Birth: -
    

    Notice that test uses 0 blocks. To store the data displayed, the inode uses some bytes. Those bytes are stored in the inode table. Look at the ext2 page for an example of an inode structure [WayBack].

Oh and a nice NTFS thing (thanks [WayBack] Paweł Bulwan):

and in case of NTFS, the size of file reported by Windows and most tools is actually the size of the main stream of the file, which we perceive as the content of the file. The file stored on NTFS partition can additionaly have some data stored in alternative data streams, and still have the reported size of 0. It’s a nice filesystem feature to know if you want to have the full picture :)

Related: my really old post command line – create empty text file from a batch file (via: Stack Overflow)

–jeroen

Posted in *nix, btrfs, Development, File-Systems, NTFS, Power User, Software Development, Windows | Leave a Comment »

opensuse – How to install patterns and packages at the same time? – Unix & Linux Stack Exchange

Posted by jpluimers on 2021/09/27

appending : to the resolvable allows you to match different types in one command it seems.

zypper install java-1_6_0-openjdk-devel mercurial +pattern:devel_C_C++ +pattern:devel_java

The italic are packages; the bold are patterns.

Via: [WayBack] opensuse – How to install patterns and packages at the same time? – Unix & Linux Stack Exchange; thanks [WayBack] User llua – Unix & Linux Stack Exchange

–jeroen

Posted in *nix, *nix-tools, Linux, openSuSE, Power User, SuSE Linux, Tumbleweed | Leave a Comment »

 
%d bloggers like this: