Complétion - Command-not-found

Complétion - Command-not-found

Mise à jour : Debian 9.1

La complétion et command-not-found sont deux utilitaires destinés à faciliter la saisie dans la ligne de commande.

1 - Complétion

La complétion de ligne de commande est une propriété du shell qui permet de remplir automatiquement tout ou partie d'une commande partiellement saisie.

Cette propriété est fournie par le paquet bash-completion et est activée par défaut dans le fichier de démarrage /etc/bash.bashrc de tous les utilisateurs (et super-utilisateur).

Sur Debian, avec bash,

La liste des commandes disposant de complétion est disponible avec

$ complete -p

Exemples :

$ ls / "Tab" "Tab"
bin/ initrd.img.old proc/ usr/
boot/ lib/ root/ var/
core lib32/ run/ vmlinuz
dev/ lib64/ sbin/ vmlinuz.old
etc/ media/ srv/
home/ mnt/ sys/
initrd.img opt/ tmp/
$ ls /pr "Tab" >>>> oc # ls /proc
$ grub- "Tab" Tab"
grub-editenv grub-mkimage grub-mount
grub-file grub-mklayout grub-ntldr-img
grub-fstest grub-mknetdir grub-render-label
grub-glue-efi grub-mkpasswd-pbkdf2 grub-script-check
grub-kbdcomp grub-mkrelpath grub-syslinux2cfg
grub-menulst2cfg grub-mkrescue
grub-mkfont grub-mkstandalone
$ grub-mkp "Tab" >>>> asswd-pbkdf2 # grub-mkpaswd-pdkf2
$ ping "Tab" "Tab"
asus localhost
$ ping lo "Tab" >>>> calhost # ping localhost
# chown "Tab" "Tab"
_apt geoclue nobody sys
avahi gnats openvpn systemd-bus-proxy
avahi-autoipd gpsd pengouin systemd-network
backup irc pengouinbis systemd-resolve
..........
# echo $DB "Tab" >>>>> US_SESSION_BUS_ADDRESS # echo $DBUS_SESSION_BUS_ADDRESS
# modinfo nvidia "Tab" >>>> -current "Tab" "Tab"
nvidia-current nvidia-current-modeset
nvidia-current-drm nvidia-current-uvm
# modinfo nvidia-current-m "Tab" >>>>>> deset # modinfo nvidia-current-modeset

2 - Command not found

Lorsqu'une commande inconnue de bash a été saisie, le paquet command-not-found détecte si cette commande appartient à un paquet non installé, mais faisant partie des dépôts présents dans les sources. Si ce n'est pas le cas, command-not-found propose des commandes ayant un nom proche.

Le paquet command-not-found n'est pas installé par défaut, mais lorsqu'il est installé, sa prise en compte est activée par défaut dans le fichier de démarrage /etc/bash.bashrc de tous les utilisateurs (et super-utilisateur).

# apt install command-not-found
# apt update
# update-command-not-found

Activer la prise en compte de command-not-found, en refermant et ré-ouvrant la console.

# rfkill
The program 'rfkill' is currently not installed. You can install it by typing:
apt install rfkill
rfkill: command not found
# rekill
No command 'rekill' found, did you mean:
Command 'rekall' from package 'rekall-core' (main)
Command 'rfkill' from package 'rfkill' (main)
Command 'rkill' from package 'pslist' (main)
rekill: command not found