Favorite Lesser-Known Commands?

This thread to gather commands or one liner scripts that you find useful or that one never finds in basic tutorials.

Please give short detail of what the command achieves ! :man_student:

You can use asciinema for this -> Favorite Lesser-Known Open-Source Resources?

9 Likes

I re discover inxi all the time.

inxi -p
to get your partitioning

inxi -r
to get your repo’s list (whichever distro you have : Debian, Arch…)

inxi -i
to get your network details (including public IP)

curl -y 4 -L "https://get.geojs.io/v1/ip"
another way to get your public IP

7 Likes

curl -y 4 -L “https://get.geojs.io/v1/ip
another way to get your public IP

Not working for me. I use this instead.

curl ifconfig.me
3 Likes

inxi -w --weather
or for a specific location e.g. inxi -W Chicago,IL

4 Likes

Not really a command, but rather an option. Anything that does a similar thing to --dry-run (such as with pamac or make) can be really helpful.

2 Likes

I have added this to my .bashrc. It saves a lot of time.

alias q="exit 0"
3 Likes
4 Likes

Same here:

curl -y 4 -L “https://get.geojs.io/v1/ip”

Gave me:

curl: (3) Failed to convert “https to ACE; string contains a disallowed character

I have (I admit: is more complicated) the following which, since years, works like a charm:

#!/bin/sh

myip=$(curl -s "http://www.showmemyip.com/" | grep -o "[0-9]*\.[0-9]*\.[0-9]*\.[0-9]*" | head -1)

echo -e $myip

:laughing:

I use this alias to hunt down files that seem to be overgrowing:
alias freespace="sudo du -h /* --exclude={'proc','run'}| sort -hr | less"

3 Likes

@Lavi_Jaat_1232 @D.Dave : thank you for elegant your public IP solutions.

The one I initially gave is somehow modified when copied/pasted (the quotation marks are not the original ones) as you can see here :

[meuh@ordi1 ~]$ curl -y 4 -L “https://get.geojs.io/v1/ip”
curl: (3) Failed to convert “https to ACE; string contains a disallowed character

[meuh@ordi1 ~]$ curl -y 4 -L "https://get.geojs.io/v1/ip"
XX.XXX.XX.XXX
[meuh@ordi1 ~]$ 
1 Like

Don’t know about “never finding this in tutorials” (I never bothered looking for it tbh), but I find this rather helpful when working on many different projects with VS Code:

#!/bin/bash

# get param
repo=$1

if [ -z "$repo" ]
  then
    # check first
    ls /home/USER/Repos/

    # ask user for input
    echo -n "which repo: "
    read repo
  else
    echo "opening "$repo
fi

code /home/USER/Repos/$repo

Reasoning/explanation here: my website

More simply, you can just curl https://ifconfig.co

2 Likes

A few of mine which I don’t see published (I haven’t looked):
pinky
pwd | du -h

Aliases include:
alias speedtest='echo "wget -O - https://raw.githubusercontent.com/sivel/speedtest-cli/master/speedtest.py | python" && echo "" && wget -O - https://raw.githubusercontent.com/sivel/speedtest-cli/master/speedtest.py | python'
and
alias ping****='echo "ping -c3 d**********rg" && echo "" && ping -c3 d*************rg' (to check if my mate’s machine is online; target machine details obfuscated for obvious reasons)

3 Likes

Another useful one is ip neigh as I usually do the admin on my mate’s machine via ssh. Handy when down the Pub.

1 Like

pwd is the current working directory. du uses the current working directory if nothing is specified. Save yourself 6 keystrokes :slight_smile:

With no arguments, du reports the disk space for the current directory.
du invocation (GNU Coreutils)

2 Likes

Favorite aliases

alias l='ls -l --size --group-directories-first'
alias ll='ls -alsF'
alias f1='find -newermt "1 minute ago"'

I’m still get used to systemd and all its’ parts…
alias s='systemctl --no-pager'
alias sf='systemctl --failed'
alias jboot='journalctl -b -p 0..3'
alias j='journalctl --no-pager'
alias jt="journalctl --since=yesterday"

If you want to bypass an alias put a backslash at the beginning.
For example, if you have alias grep='grep --colour=auto' you can execute
\grep pattern file.

4 Likes

You could just use Ctrl + D

1 Like

nice suggestions so far :+1:

one thing i really liked when i found out about it: !! just repeats the last command.
So when you i.e. run a command without sudo that needs it, you can just sudo !! :slight_smile:

4 Likes

alias clean='paccache -rvuk0'
:wink:

1 Like

Cheers, was an experiment to see if it worked. :slight_smile: