Nice: “you can get both aliases and functions with compgen -a -A function”
It uses the compgen completion generator. Simply brilliant (:
Source: bash – how do I list the functions defined in my shell? – Stack Overflow
–jeroen
Posted by jpluimers on 2017/03/07
Nice: “you can get both aliases and functions with compgen -a -A function”
It uses the compgen completion generator. Simply brilliant (:
Source: bash – how do I list the functions defined in my shell? – Stack Overflow
–jeroen
Posted in *nix, *nix-tools, bash, bash, Development, Power User, Scripting, Software Development | Leave a Comment »
Posted by jpluimers on 2017/01/10
Getting the local IP (actually IPs, but most hosts only have a single IP):
# OS X:
alias whatismylocalip='ifconfig | sed -En '\''s/127.0.0.1//;s/.*inet (addr:)?(([0-9]*\.){3}[0-9]*).*/\2/p'\'''
# Linux:
alias whatismylocalip='ip a | sed -En '\''s/127.0.0.1//;s/.*inet (addr:)?(([0-9]*\.){3}[0-9]*).*/\2/p'\'''
I got them via bash – How to I get the primary IP address of the local machine on Linux and OS X? – Stack Overflow
Mac OS X and BSD have ifconfig, but most Linux distributions don’t use ifconfig any more in favour of iproute2, so you use ip a (which is shorthand for ip address show) there.
Their output is similar enough for the sed to work, though. Which surprised be because I didn’t know about the -E option (it lacks in the manual Linux page but it is in the Mac OS X one) which enables POSIX extended regular expressions. In Linux this is documented as -r, but -E also works.
I learned this through the Sed – An Introduction and Tutorial which compares the various versions of sed which also explains about the -n doing no printing.
–jeroen
Posted in *nix, *nix-tools, Apple, bash, bash, Development, Linux, Mac, Mac OS X / OS X / MacOS, Mac OS X 10.4 Tiger, Mac OS X 10.5 Leopard, Mac OS X 10.6 Snow Leopard, Mac OS X 10.7 Lion, MacBook, MacBook Retina, MacBook-Air, MacBook-Pro, MacMini, openSuSE, OS X 10.10 Yosemite, OS X 10.8 Mountain Lion, OS X 10.9 Mavericks, Power User, Scripting, Software Development, SuSE Linux, Tumbleweed | Leave a Comment »
Posted by jpluimers on 2016/11/01
If you see this in journalctl after boot in a VM, then you likely want to disable piix4 smbus device detection:
Jul 07 23:02:47 revue systemd-udevd[507]: maximum number (136) of children reached Jul 07 23:02:47 revue systemd-udevd[507]: maximum number (136) of children reached ... Jul 07 23:02:47 revue systemd-udevd[507]: maximum number (136) of children reached Jul 07 23:02:47 revue systemd-udevd[507]: maximum number (136) of children reached ... Jul 07 23:02:47 revue kernel: piix4_smbus 0000:00:07.3: SMBus Host Controller not enabled!
The solution is to add one line to /etc/modprobe.d/50-blacklist.conf (well: maybe [WayBack] add a comment line as well):
blacklist i2c_piix4
via:
–jeroen
Posted in *nix, *nix-tools, bash, bash, Development, Linux, openSuSE, Power User, Scripting, Software Development, SuSE Linux, Tumbleweed | 2 Comments »
Posted by jpluimers on 2016/10/20
The unix shell is hard, but boy, sometimes it can work like magic, for instance piping two testssl.sh commands into one gist:
retinambpro1tb:testssl.sh jeroenp$ ( ./testssl.sh --version ; ./testssl.sh --local ) | gist -d "testsll version and local ciphers for Mac OS X Darwin binarries supporting zlib"
https://gist.github.com/701496d7fbf929967aa1
The source of this magic was this AskUbuntu answer: How to merge and pipe results from two different commands to single command? – Ask Ubuntu
–jeroen
via: openssl.Darwin.x86_64 lacks zlib support · Issue #164 · drwetter/testssl.sh
Posted in *nix, *nix-tools, bash, bash, Development, Power User, Scripting, Software Development, Uncategorized | Leave a Comment »
Posted by jpluimers on 2016/09/14
The ESXi console top to show processes is not available *, the alternative is esxtop. But that can show garbage because the ESXi console has a very limited support of terminals **.
For instance, when connecting from a Mac OS X terminal through ssh, this is my terminal:
# echo $TERM
xterm-256color
The solution:
TERM=xterm esxtop
–jeroen
via: VMware KB: Output of esxtop defaults to non-interactive CSV with unknown TermInfo.
Posted in *nix, *nix-tools, bash, bash, Development, ESXi5, ESXi5.1, ESXi5.5, ESXi6, Power User, Scripting, Virtualization, VMware, VMware ESXi | 2 Comments »
Posted by jpluimers on 2016/08/05
Kev:
Try the command line tool expand.
expand -t 4 input >output
And for those systems that don’t use the GNU Core Utilities, you have a decent chance of expand being installed since it is standardized by The Open Group’s Single Unix Specification. See Issue 6, which is from 2001, though some updates were applied, hence the year of publication being 2004: expand
–jeroen
via bash – How can I convert tabs to spaces in every file of a directory? – Stack Overflow.
Posted in *nix, *nix-tools, bash, bash, Development, Linux, openSuSE, Power User, Scripting, Software Development, SuSE Linux | Leave a Comment »
Posted by jpluimers on 2016/06/16
Since quite a few commands that you regularly see mentioned on the web have been removed from OpenSuSE net-tools, I’ve created a few bash aliases in /etc/bash.bashrc.local below.
Note the original commands are not good have been deprecated for years on various distros and therefore removed:
# stuff removed from net-tools # see https://features.opensuse.org/317197 and https://build.opensuse.org/package/view_file/network:utilities/net-tools/net-tools.changes ## Because of changes on Thu Apr 10 12:33:41 UTC 2014 alias "arp=echo 'use \"ip neigh\" or \"ip -r neight\"' && ip neigh" alias "ifconfig=echo 'use \"ip a\"' && ip a" alias "netstat= echo 'use \"ss\" or \"ss -r\"' && ss" alias "route=echo 'use \"ip r\"' && ip r" ## Because of changes on Sun Mar 29 00:41:21 UTC 2015 alias "ipmaddr=echo 'use \"ip maddr\"' && ip maddr" alias "iptunnel=echo 'use \"ip tunnel\"' && ip tunnel"
Some bits of the net-tools change-log:
------------------------------------------------------------------- Sun Mar 29 00:41:21 UTC 2015 - jengelh@inai.de - ipmaddr and iptunnel are obsolete too, move them to subpackage. (Superseded by `ip maddr` and `ip tunnel`) - remove redundant %clean section ------------------------------------------------------------------- Thu Apr 10 12:33:41 UTC 2014 - mmarek@suse.cz - Move arp, ifconfig, netstat and route to a -deprecated subpackage (fate#317196, fate#317197) - Drop the rarp tool, which has been broken since kernel 2.3
Note that the -lntu parameter seems to be the same for both ss and netstat: [WayBack] Get a list of Open Ports in Linux – Super User
–jeroen
via File net-tools.changes of Package net-tools – openSUSE Build Service.
Posted in *nix, *nix-tools, bash, bash, Development, Linux, openSuSE, Power User, Scripting, Software Development, SuSE Linux | Leave a Comment »
Posted by jpluimers on 2016/06/01
I needed to find the symlinks in /etc pointing to directories and know both the name and place they point to.
revue:~ # ls -al `find -L /etc/ -xtype l -type d` find: ‘/etc/ssh/broken/ssh_host_dsa_key’: Too many levels of symbolic links find: ‘/etc/ssh/broken/ssh_host_ecdsa_key’: Too many levels of symbolic links find: ‘/etc/ssh/broken/ssh_host_key’: Too many levels of symbolic links find: ‘/etc/ssh/ssh_host_ecdsa_key’: Too many levels of symbolic links find: ‘/etc/ssh/ssh_host_dsa_key’: Too many levels of symbolic links find: ‘/etc/ssh/ssh_host_key’: Too many levels of symbolic links lrwxrwxrwx 1 root root 19 May 7 15:43 /etc/apparmor.d/cache -> /var/cache/apparmor lrwxrwxrwx 1 root root 6 Sep 28 2014 /etc/rc.d -> init.d lrwxrwxrwx 1 root root 26 May 23 13:50 /etc/squid/errors -> /usr/share/squid/errors/de lrwxrwxrwx 1 root root 28 Mar 25 22:07 /etc/ssl/certs -> /var/lib/ca-certificates/pem lrwxrwxrwx 1 root root 18 Apr 30 14:20 /etc/xdg/systemd/user -> ../../systemd/user
–jeroen
via: bash – How do I find all of the symlinks in a directory tree? – Stack Overflow.
Posted in *nix, *nix-tools, bash, bash, Development, Linux, openSuSE, Power User, Scripting, Software Development, SuSE Linux | Leave a Comment »
Posted by jpluimers on 2016/03/10
Since ESXi is based on busybox, it is using ash a variation of sh (the classic bourne shell) called Almquist shell and most nxes use some form of bash a lot of things won’t work.
For instance, doesn’t support sh –version.
Luckily there are uname -mrs and (more elaborate) vmware -vl to get the version.
Note there is support busybox aliases so alias dir=”ls -laF” works, and you can define aliases for the version information too.
–jeroen
via:
Posted in *nix, *nix-tools, bash, Linux, Power User, SuSE Linux, Virtualization, VMware, VMware ESXi | Leave a Comment »
Posted by jpluimers on 2016/01/13
Many sites giving your public IP address return a web page with a bloat of html. From the command-line, you are usually only interested in the IP-address itself. Few services return exactly that.
Below are command-line examples to provide the public IP address mostly from a *nix perspective. Usually you can get similar commands to work with Windows binaries for wget and Windows binaries for curl.
In the end, I’ve opted for commands in this format, as I think akamai will last longer than the other sites (but does not include an end-of-line in the http result hence the echo on Mac/*nix):
I’ve not tried aria2 yet, but might provide commands for that in the future.
These are the Linux permutations for akamai:
curl whatismyip.akamai.com && echo curl ipv4.whatismyip.akamai.com && echo curl ipv6.whatismyip.akamai.com && echo curl ipv4.whatismyip.akamai.com && echo && curl ipv6.whatismyip.akamai.com && echoThe last two are convenient when you have both IPv4 and IPv6 configured on “the outside”.
You can replace curl with wget -q -O – (which outputs to stdout) for each command. You can even ommit the http:// (as that is the default protocol for both curl and wget).
Posted in *nix, *nix-tools, Apple, bash, bash, Batch-Files, cURL, Development, Linux, Mac, Mac OS X / OS X / MacOS, Mac OS X 10.4 Tiger, Mac OS X 10.5 Leopard, Mac OS X 10.6 Snow Leopard, Mac OS X 10.7 Lion, MacBook, MacBook Retina, MacBook-Air, MacBook-Pro, MacMini, OS X 10.10 Yosemite, OS X 10.8 Mountain Lion, OS X 10.9 Mavericks, Power User, Scripting, Software Development, SuSE Linux, wget | Leave a Comment »