Links
Tag cloud
Picture wall
Daily
RSS Feed
  • RSS Feed
  • Daily Feed
  • Weekly Feed
  • Monthly Feed
Filters

Links per page

  • 20 links
  • 50 links
  • 100 links

Filters

Untagged links
page 1 / 2
28 results tagged bash  ✕
Introduction · exa https://the.exa.website/introduction
Tue Feb 14 12:49:36 2023 archive.org

Introduction

exa is a modern replacement for the command-line program ls that ships with Unix and Linux operating systems. This command is used by terminal users, administrators, and developers hundreds of times daily, as well as being useful when writing automated scripts.

Unfortunately, these two uses are at odds with each other. While users want new features and customisation, administrators would prefer the stability of a long-lived and ubiquitous tool.

By deliberately making some decisions differently, exa attempts to be a more featureful, more user-friendly version of ls.

exa bash color shell
Bash prompt generator with colors https://robotmoon.com/bash-prompt-generator/
Fri Jan 20 11:40:53 2023 archive.org

Bash prompt generator
user@hostname ~/path/to/directory $
↑
export PS1="[$(tput setaf 226)]\u[$(tput setaf 220)]@[$(tput setaf 214)]\h [$(tput setaf 33)]\w [$(tput sgr0)]$ "

bash prompt generator
Learn Shell - Free Interactive Shell Tutorial https://www.learnshell.org/
Tue Sep 28 11:45:54 2021 archive.org
thumbnail

Welcome

Welcome to the learnshell.org interactive Shell Programming tutorial.

Whether you are an experienced programmer or not, this website is intended for everyone who wishes to learn programming with Unix/Linux shell interpreters.

You are welcome to join our group on Facebook for questions, discussions and updates.

Just click on the chapter you wish to begin from, and follow the instructions. Good luck!

bash shell dev top tip help
run bash online https://rextester.com/l/bash_online_compiler
Tue Sep 28 11:42:19 2021 archive.org
dev bash top help run
https://git.sr.ht/~gpanders/ijq https://git.sr.ht/~gpanders/ijq
Mon Jan 25 11:22:27 2021 archive.org

#
Installation
#
Homebrew

If you use macOS and Homebrew, you can install ijq with

brew install gpanders/tap/ijq

#
Download a release

Select the version you want to download from sourcehut and download one of the precompiled releases from that page. Then extract the archive and copy the binary and, optionally, the man page to the correct location.

Example:

wget https://git.sr.ht/~gpanders/ijq/refs/v0.2.3/ijq-v0.2.3-linux-x86_64.tar.gz
tar xf ijq-v0.2.3-linux-x86_64.tar.gz
cd ijq-v0.2.3
cp ijq /usr/local/bin
mkdir -p /usr/local/share/man/man1
cp ijq.1 /usr/local/share/man/man1

ijq jq bash linux term
bash errors https://wizardzines.com/comics/bash-errors/
Mon Oct 12 15:40:49 2020 archive.org
thumbnail

Bash error

bash error image tips
Defensive BASH programming - Say what? http://kfirlavi.herokuapp.com/blog/2012/11/14/defensive-bash-programming/
Wed Apr 29 16:29:38 2020 archive.org

Defensive BASH Programming

Nov 14th, 2012 | Comments

Here is my Katas for creating BASH programs that work. Nothing is new here, but from my experience pepole like to abuse BASH, forget computer science and create a Big ball of mud from their programs.
Here I provide methods to defend your programs from braking, and keep the code tidy and clean.
Immutable global variables

Try to keep globals to minimum
UPPER_CASE naming
readonly decleration
Use globals to replace cryptic $0, $1, etc.
Globals I allways use in my programs:
bash programming aide tipsn defensive
Bash Strict Mode http://redsymbol.net/articles/unofficial-bash-strict-mode/
Wed Apr 29 16:06:06 2020 archive.org

Use Bash Strict Mode (Unless You Love Debugging)

Let's start with the punchline. Your bash scripts will be more robust, reliable and maintainable if you start them like this:

#!/bin/bash
set -euo pipefail
IFS=$'\n\t'
bash debug tips info
The Bash Hackers Wiki [Bash Hackers Wiki] https://wiki.bash-hackers.org/start
Mon Apr 20 17:41:15 2020 archive.org

The Bash Hackers Wiki

wiki hacker shell help bash terminal
bash:tip_colors_and_formatting - FLOZz' MISC https://misc.flogisoft.com/bash/tip_colors_and_formatting
Fri Apr 10 16:41:54 2020 archive.org

Bash tips: Colors and formatting (ANSI/VT100 Control sequences)

The ANSI/VT100 terminals and terminal emulators are not just able to display black and white text ; they can display colors and formatted texts thanks to escape sequences.

Those sequences are composed of the Escape character (often represented by “^[” or “<Esc>”) followed by some other characters: “<Esc>[FormatCodem”.

In Bash, the <Esc> character can be obtained with the following syntaxes:

\e
\033
\x1B

Examples:
Code (Bash) Preview

    echo -e "\e[31mHello World\e[0m"

Hello World

    echo -e "\033[31mHello\e[0m World"

Hello World

NOTE¹: The -e option of the echo command enable the parsing of the escape sequences.

NOTE²: The “\e[0m” sequence removes all attributes (formatting and colors). It can be a good idea to add it at the end of each colored text. ;)

NOTE³: The examples in this page are in Bash but the ANSI/VT100 escape sequences can be used in every programming languages.

bash tips formatage color
MOTDs32 | MOTD Fork with some customisation and additional stats. 2017 https://erreur32.github.io/MOTDs32/
Tue Mar 24 11:27:53 2020 archive.org

MOTDs32
MOTD Fork with some customisation and additional stats. 2017

https://asciinema.org/a/Tzr3NNF8pEB9FZ13d3kYDMBw5.png

motd linux bash sh script
Usefull shell default key shortcuts - Grimoire-Command.es - www.grimoire-command.es/ https://www.grimoire-command.es/2019/shell_key_shortcuts.html
Tue Jan 14 16:33:14 2020 archive.org

Usefull shell default key shortcuts

Index

1. Controlling processes
2. While typing commands
3. Correcting text
4. Moving
5. Cut / paste
6. Controlling the terminal
7. Bonus

In Bash and ZSH default key shortcuts are emacs style, a vim style exists.

20 raccourcis clavier du shell (Bash, ZSh) en mode emacs le réglage par défaut. Un mode vim existe.

1. Controlling processes

Keys             Description

CTRL+C        Close the process running in foreground

CTRL+Z        Suspend current process, it goes Zzz
                    bg command to resume it in background,
                    fg command to resume it in foreground.

2. While typing commands

Keys      Description

CTRL+R      Recall a previous command

TAB            Auto-complete files and folder names, also commands and options with ZSH

CTRL+C      Clean the line

3. Correcting text

Keys    Description

CTRL+_       Undo the last key press. Can be repeated.

CTRL+T       Toggle the last 2 characters;
Alt+T the last 2 words;
Esc+T current word with previous

4. Moving

Keys    Description

CTRL+A   Go to the begining of the line (like Home) alpha

CTRL+E   Go to the end of the line (like End)

Alt+F       Move 1 word forward, CTRL+F 1 character

Alt+B       Move 1 word backward, CTRL+B 1 character

5. Cut / paste

Keys    Description

CTRL+H     Cut 1 char before the cursor (like Backspace)

CTRL+W     Cut 1 word before the cursor

CTRL+U      Cut the part of the line before the cursor (Undo)

CTRL+K      Cut the part of the line after the cursor

CTRL+Y      Paste (yank) the last cut string

6. Controlling the terminal

Keys            Description

CTRL+S        Stop the current output (to read it)

CTRL+Q        Quit suspended mode, so resume output.
                    PgUp to read the begining

<cmd> | less to control output from start.

CTRL+L          Clear shell screen, like clear command. Redraw layout

CTRL+D          Exit (destroy) the current shell

7. Bonus

Keys    Description

CTRL+M  Alternative to Enter
CTRL+J   also works
1. CTRL + A Esc ↑ in a screen, Esc to stop
2. Redraw screen in many console-based app. 
bash shell shortcuts
Les raccourcis clavier de Bash – Nicolas Karolak - blog.karolak.fr/ https://blog.karolak.fr/2019/11/25/les-raccourcis-clavier-de-bash/
Mon Dec 9 16:59:25 2019 archive.org

Déplacement

Ctrl + A : aller au début de la ligne
Ctrl + E : aller à la fin de la ligne (End)
Ctrl + F : aller un caractère en avant (Forward)
Ctrl + B : aller un caractère en arrière (Backward)
Alt + B : aller un mot en arrière (Backward)
Alt + F : aller un mot en avant (Forward)
Ctrl + XX : aller et revenir entre le début de la ligne et la position actuelle du curseur
Ctrl + L : vider le terminal

Historique

Ctrl + P : afficher la commande précédente dans l’historique (Previous)
Ctrl + N : afficher la commande suivante dans l’historique (Next)
Alt + < : aller au début de l’historique
Alt + > : aller à la fin de l’historique
Ctrl + R : rechercher une commande (Reverse)
    ensuite il suffit de commencer à écrire les caractères de la commande en question
    Ctrl + R : remonter dans l’historique de recherche
    Ctrl + S : redescendre dans l’historique de recherche, si ce n’est pas déjà utilisé par le contrôle de flux, ce qui est généralement le cas (Search)
    Ctrl + G : quitter la recherche sans rien exécuter

Alt + R : annuler les changements en cours dans une commande de l’historique (Revert)
Ctrl + Alt + Y : insérer le premier argument de la commande précédente (Yanking)
Alt + . ou Alt + _ : insérer la dernière chaîne de caractères de la commande précédente
    répéter la commande pour remonter dans l’historique

Modification

Ctrl + U : supprimer avant le curseur jusqu’au début de la ligne
Ctrl + K : supprimer depuis le curseur jusqu’à la fin de la ligne (Killing)
Ctrl + W : supprimer avant le curseur jusqu’au début de la chaîne
Alt + D : supprimer depuis le curseur jusqu’à la fin de la chaîne
Ctrl + Y : restaurer ce qui a été supprimé avec l’une des combinaisons (Yanking)
    Alt + Y : remonter de l’historique du « kill ring » et ainsi restaurer d’anciennes suppressions

Ctrl + D : supprimer le caractère sous le curseur, comme Suppr
Ctrl + H : supprimer le caractère avant le curseur, comme Retour
Ctrl + J ou Ctrl + M : valide la commande, comme Entrée

Alt + U : mettre en majuscule depuis le curseur jusqu’à la fin de la chaîne (Uppercase)
Alt + L : mettre en minuscule depuis le curseur jusqu’à la fin de la chaîne (Lowercase)
Alt + C : mettre en majuscule le caractère sous le curseur (Capitalize)

Alt + T : inverser les deux chaînes avant le curseur (Transpose)
Ctrl + T : inverser les deux derniers caractères depuis le curseur (Transpose)

Alt + # : insérer un # au début de la ligne et valider
    ça revient à insérer un commentaire dans l’historique de bash

Ctrl + V : fait que le prochain caractère tapé est inséré en « Verbatim »
    faites Ctrl + V et appuyer Entrée en suite pour voir ce que ça fait concrètement, ça peut servir pour insérer une tabulation par exemple

Ctrl + Insert ou Ctrl + Shift + C : copier
Shift + Insert ou Ctrl + Shift + V : coller
    l’avantage de la combinaison avec Insert c’est qu’elle fonctionne partout

Complétion

Tab : compléter l’élément (commande, chemin, arguments) sous le curseur
Alt + ? : afficher les complétions possibles
Alt + * : insérer toutes les complétions possibles

Ctrl + X ( : commencer l’enregistrement d’une macro
Ctrl + X ) : terminer l’enregistrement d’une macro
Ctrl + X E : exécuter la macro précédemment enregistrée

Divers

Ctrl + C : arrêter la commande en cours
Ctrl + Z : suspendre le programme en cours
    il faut saisir la commande fg (foreground) pour reprendre le programme

Shift + PgUp : faire défiler vers le haut une « page »
Shift + PgDn : faire défiler vers le bas une « page »
Ctrl + Shift + Haut : faire défiler vers le haut une ligne
Ctrl + Shift + Bas : faire défiler vers le bas une ligne

Pour en savoir plus

man -P 'less -p ^READLINE' bash
man -P 'less -p ^EDITING' readline
bash raccourci shortcut
Extending and Analyzing the Access Log – Welcome to netnea https://www.netnea.com/cms/apache-tutorial-5_extending-access-log/
Fri Aug 30 11:05:45 2019 archive.org

access.log apache bash script

access.log apache bash script
Testing Bash applications - wemake.services - Medium https://medium.com/wemake-services/testing-bash-applications-85512e7fe2de
Tue Aug 13 11:02:38 2019 archive.org
thumbnail

Testing Bash applications

bash test
linux-sms [Wiki de sebsauvage.net] http://sebsauvage.net/wiki/doku.php?id=linux-sms
Thu Mar 22 18:45:12 2018 archive.org

Envoi d'un SMS lors de certains événements dans les logs

Je me sers de ce script pour "fliquer" un peu l'utilisation de ma machine personnelle qui est sous Linux. Je reçois donc un SMS quand l'un des événements suivants se produit:

  • Ouverture de session d'un utilisateur.
  • Fermeture de session d'un utilisateur.
  • Échec d'ouverture de session (mauvais mot de passe)

C'est assez simple: On surveille le fichier ''/var/log/auth.log'' et quand certains événements sont détectés, on appelle l'API SMS FreeMobile.

Le script ci-dessous est vite bricolé, avec certaines choses codées en dur. Vous devrez sans doute l'adapter.

Je met le script suivant dans ''/opt/scripts/logs-sms.sh'' (sans oublier de faire mon chmod):

logs-sms.sh

#!/bin/bash
# Surveillance des logs, et envoi d'un SMS quand un utilisateur se connecte ou déconnecte.

logger "SMS: Démarrage script SMS connexions."

envoie_sms () {
   chaine="Asus: `date +%Y-%m-%d_%Hh%M` $*"
   logger "SMS: $chaine"
   curl -G -d user=UTILISATEUR -d pass=MOTDEPASSE --data-urlencode msg="$chaine" 'https://smsapi.free-mobile.fr/sendmsg'
}

# Expressions régulières pour détecter certains évènements (ouverture session, fermeture session, mauvais mot de passe)
reg_open="pam_unix.*session opened for user (utilisateur1|utilisateur2|utilisateur3|utilisateur4)"
reg_close="pam_unix.*session closed for user (utilisateur1|utilisateur2|utilisateur3|utilisateur4)"
reg_failure="pam_unix.*authentication failure.*user=(.+)"

tail -fn0 /var/log/auth.log | \
while read line ; do
   if [[ $line =~ $reg_open ]] ; then
       envoie_sms "Ouverture session ${BASH_REMATCH[1]}"
   fi
   if [[ $line =~ $reg_close ]] ; then
       envoie_sms "Fermeture session ${BASH_REMATCH[1]}"
   fi
   if [[ $line =~ $reg_failure ]] ; then
       envoie_sms "Mauvais mot de passe utilisateur ${BASH_REMATCH[1]}"
   fi
done

Puis j'ai ajouté la ligne suivante avant le ''exit 0'' dans ''/etc/rc.local'' afin que ça démarre en même temps que la machine.

nohup /bin/bash /opt/scripts/logs-sms.sh > /dev/null 2>&1 &

Notes:

  • Cela fonctionne aussi bien avec l'ouverture de sessions graphique (mdm/lightdm) que pour un ''su'' dans un terminal.
  • Je fais ''utilisateur1|utilisateur2|utilisateur3|utilisateur4'' car je ne veux surveiller que les évènements pour ces utilisateurs.
  • Vous devrez sans doute adapter les expressions régulières dans les lignes ''reg_...'' en fonction de votre système.
  • J'ai mis en dur le nom de la machine (''Asus:'')
  • Vous devrez remplacer ''UTILISATEUR'' et ''MOTDEPASSE'' par vos propres identifiants SMS API FreeMobile (connectez-vous sur votre [[https://mobile.free.fr/moncompte/|espace abonné FreeMobile]] et activez l'option pour les obtenir).
  • L'API SMS FreeMobile est gratuite et fonctionne sur tous les forfaits FreeMobile. Elle ne peut servir qu'à vous envoyer un SMS à vous-même, pas à d'autres personnes.
  • Le même genre de chose aurait pu être réalisé en modifiant la configuration de pam afin qu'il exécute le script sur certains événements d'authentification. L'avantage du script ci-dessus est qu'il peut être étendu à d'autres logs/événements que l'authentification.
  • J'aurais pu utiliser cron, mais je voulais du temps réel.
linux script bash sms event log
The Bash Hackers Wiki [Bash Hackers Wiki] http://wiki.bash-hackers.org/start
Thu Mar 15 09:48:30 2018 archive.org

The Bash Hackers Wiki

This wiki is intended to hold documentation of any kind about GNU Bash. The main motivation was to provide human-readable documentation and information so users aren't forced to read every bit of the Bash manpage - which can be difficult to understand. However, the docs here are not meant as a newbie tutorial.

This wiki and any programs found in this wiki are free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version.

This wiki and its programs are distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.

You should have received a copy of the GNU General Public License along with this program. If not, see http://www.gnu.org/licenses/.

What would YOU like to see here? (outdated and locked, please use the discussions)

Stranger! Feel free to register and comment or edit the contents. There is a Bash Hackers Wiki needs love page that lists some things to do. The registration is only there to prevent SPAM.

bash wiki doc linux
sed.sf.net - The sed $HOME - http://sed.sourceforge.net/#sedlovers http://sed.sourceforge.net/#sedlovers
Mon Jun 12 11:11:13 2017 archive.org
bash shell
GitHub - fish-shell/fish-shell: The user-friendly command line shell. https://github.com/fish-shell/fish-shell
Wed Jun 7 14:19:19 2017 archive.org
thumbnail

Let's make magic

Good article link:

  • https://www.metal3d.org/ticket/reading-some-lines-from-a-file-in-terminal
fish bash shell termial debian
$ bash - Awesome : Free Commandlines and Git ToolKit. - https://bashawesome.github.io//#blog https://bashawesome.github.io//#blog
Tue May 23 13:50:21 2017 archive.org

Go See it on GitHub

https:// clone URL it to Desktop:
git clone https://github.com/bashawesome/bashunixshell-awesome.git
SSH clone URL it to Desktop:
git clone git@github.com:bashawesome/bashunixshell-awesome.git

bash shell unix commandline
page 1 / 2
1578 links, including 7 private
Shaarli - The personal, minimalist, super-fast, database free, bookmarking service by the Shaarli community - Theme by kalvn