.bash aliases: Unterschied zwischen den Versionen
Die Seite wurde neu angelegt: „= .bash_aliases = Working in commandline offers speed and convenience. The downside is you will have to remember all the commands and some of them are long and can affect your productivity. Fortunately, we can create shortcuts to commands that can significantly speedup the work. In Ubuntu, a user can create a ".bash_aliases" file that contains the list of all shortcuts or aliases to your frequently used commands. First of all, make sure that you have th…“ |
|||
(14 dazwischenliegende Versionen desselben Benutzers werden nicht angezeigt) | |||
Zeile 1: | Zeile 1: | ||
'''.bash_aliases''' - [[Bash]]-Datei für [[Alias]]e | |||
== Beschreibung == | |||
[[Bash]]-Benutzer können eine „.bash_aliases“-Datei erstellen, die eine Liste aller Verknüpfungen oder Aliase zu Ihren häufig verwendeten Befehlen enthält. | |||
; Überprüfen Sie, ob Sie eine .bashrc-Datei haben | |||
Wenn ja, öffnen Sie die Datei in nano oder Ihrem bevorzugten Texteditor und suchen Sie nach den folgenden Zeilen | |||
< | <syntaxhighlight lang="bash" highlight="1" line> | ||
editor ~/.bashrc-Datei | |||
</syntaxhighlight> | |||
Stellen Sie sicher, dass sie nicht kommentiert sind (kein #-Symbol vor den Zeilen) | |||
<syntaxhighlight lang="bash" line> | |||
if [ -f ~/.bash_aliases ]; then | |||
. ~/.bash_aliases | |||
fi | |||
</syntaxhighlight> | |||
; Erstellen einer ''.bashrc'' | |||
Wenn Sie die [[.bashrc]]-Datei nicht in Ihrem Home-Verzeichnis finden, dann [https://www.smarthomebeginner.com/bashrc-file-not-found/ follow this post], um sie zu erstellen. | |||
Erstellen Sie nun eine .bash_aliases-Datei in Ihrem Home-Verzeichnis und fügen Sie Ihre Aliase zur Datei hinzu. | |||
== Beispiel == | |||
<syntaxhighlight lang="bash" line> | |||
# Update and Upgrade Packages | |||
alias update='sudo apt-get update' | |||
alias upgrade='sudo apt-get upgrade' | |||
# Install and Remove Packages | |||
alias install='sudo apt-get install' | |||
alias uninstall='sudo apt-get remove' | |||
alias installf='sudo apt-get -f install' #force install | |||
alias installfr='sudo apt-get -f install --reinstall' #force reinstall | |||
# Add repository keys (usage: addkey XXXXXXXX - last 8 digits of the key) | |||
alias addkey='sudo apt-key adv --recv-keys --keyserver keyserver.ubuntu.com' | |||
# Search apt repository | |||
alias search='sudo apt-cache search' | |||
# Cleaning | |||
alias clean='sudo apt-get clean && sudo apt-get autoclean' | |||
alias remove='sudo apt-get remove && sudo apt-get autoremove' | |||
alias purge='sudo apt-get purge' | |||
alias deborphan='sudo deborphan | xargs sudo apt-get -y remove --purge' | |||
# Shutdown and Reboot | |||
alias shutdown='sudo shutdown -h now' | |||
alias reboot='sudo reboot' | |||
# Apache Start, Stop, and Restart | |||
alias apacherestart='sudo service apache2 reload' | |||
alias apachestop='sudo service apache2 stop' | |||
alias apachestart='sudo service apache2 start' | |||
#Shellinabox Start, Stop, and Restart | |||
alias shellstart='sudo service shellinabox start' | |||
alias shellstop='sudo service shellinabox stop' | |||
alias shellreload='sudo service shellinabox reload' | |||
# Network Start, Stop, and Restart | |||
alias networkrestart='sudo service networking restart' | |||
alias networkstop='sudo service networking stop' | |||
alias networkstart='sudo service networking start' | |||
# SAMBA Start, Stop, and Restart | |||
alias sambarestart='sudo service smbd restart' | |||
alias sambastop='sudo service smbd stop' | |||
alias sambastart='sudo service smbd start' | |||
# NFS Start, Stop, and Restart | |||
alias nfsrestart='sudo /etc/init.d/nfs-kernel-server restart' | |||
alias nfsstart='sudo /etc/init.d/nfs-kernel-server start' | |||
alias nfsstop='sudo /etc/init.d/nfs-kernel-server stop' | |||
# Transmission-Daemon Start, Stop, and Restart | |||
alias transstop='sudo /etc/init.d/transmission-daemon stop' | |||
alias transstart='sudo /etc/init.d/transmission-daemon start' | |||
alias transrestart='sudo /etc/init.d/transmission-daemon reload' | |||
# SABnzbd Start, Stop, and Restart | |||
alias sabrestart='sudo service sabnzbdplus restart' | |||
alias sabstop='sudo service sabnzbdplus stop' | |||
alias sabstart='sudo service sabnzbdplus start' | |||
# CouchPotato Start, Stop, and Restart | |||
alias couchstop='/etc/init.d/couchpotato stop' | |||
alias couchstart='/etc/init.d/couchpotato start' | |||
alias couchrestart='/etc/init.d/couchpotato stop ; /etc/init.d/couchpotato start' | |||
# Sickbeard Start, Stop, and Restart | |||
alias sickstop='/etc/init.d/sickbeard stop' | |||
alias sickstart='/etc/init.d/sickbeard start' | |||
alias sickrestart='/etc/init.d/sickbeard stop ; /etc/init.d/sickbeard start' | |||
# Grub | |||
alias grubu='sudo update-grub' #update grub | |||
alias grubi='sudo grub-install' #install grub | |||
# Misellaneous | |||
alias fdisk='sudo fdisk -l' | |||
alias uuid='sudo vol_id -u' #list UUIDs | |||
alias rfind='sudo find / -name' #find a file. Usage: rfind 'filename' | |||
alias rd='sudo rm -R' #remove directory | |||
alias imount='sudo mount -o loop -t iso9660' #mount iso. Usage: imount 'filename.iso' | |||
alias dirsize='sudo du -hx --max-depth=1' #directory size. Usage: dirsize directoryname | |||
# Commands | |||
alias rrsync='rsync --verbose -rtvogp --progress' | |||
alias scp='scp -c blowfish' | |||
alias nano='sudo nano -iSw$' | |||
alias cp='cp --verbose' | |||
alias mv='mv --verbose' | |||
alias make='make -j4' | |||
</syntaxhighlight> | |||
== Installation == | |||
<syntaxhighlight lang="bash" highlight="1" line> | |||
</syntaxhighlight> | |||
== Aufruf == | |||
<syntaxhighlight lang="bash" highlight="1" line> | |||
< | </syntaxhighlight> | ||
=== Optionen === | |||
=== Parameter === | |||
=== Umgebungsvariablen === | |||
=== Exit-Status === | |||
== Anwendung == | |||
=== Problembehebung === | |||
== Konfiguration == | |||
=== Dateien === | |||
<noinclude> | |||
== Anhang == | |||
=== Siehe auch === | |||
{{Special:PrefixIndex/{{BASEPAGENAME}}}} | |||
==== Dokumentation ==== | |||
===== Man-Page ===== | |||
===== Info-Pages ===== | |||
==== Links ==== | |||
===== Projekt ===== | |||
===== Weblinks ===== | |||
{{SORTIERUNG:.bash_aliases}} | |||
{{DISPLAYTITLE:.bash_aliases}} | |||
[[Kategorie:Bash/Konfiguration]] | |||
< | </noinclude> | ||
Aktuelle Version vom 17. November 2024, 12:46 Uhr
.bash_aliases - Bash-Datei für Aliase
Beschreibung
Bash-Benutzer können eine „.bash_aliases“-Datei erstellen, die eine Liste aller Verknüpfungen oder Aliase zu Ihren häufig verwendeten Befehlen enthält.
- Überprüfen Sie, ob Sie eine .bashrc-Datei haben
Wenn ja, öffnen Sie die Datei in nano oder Ihrem bevorzugten Texteditor und suchen Sie nach den folgenden Zeilen
editor ~/.bashrc-Datei
Stellen Sie sicher, dass sie nicht kommentiert sind (kein #-Symbol vor den Zeilen)
if [ -f ~/.bash_aliases ]; then
. ~/.bash_aliases
fi
- Erstellen einer .bashrc
Wenn Sie die .bashrc-Datei nicht in Ihrem Home-Verzeichnis finden, dann follow this post, um sie zu erstellen.
Erstellen Sie nun eine .bash_aliases-Datei in Ihrem Home-Verzeichnis und fügen Sie Ihre Aliase zur Datei hinzu.
Beispiel
# Update and Upgrade Packages
alias update='sudo apt-get update'
alias upgrade='sudo apt-get upgrade'
# Install and Remove Packages
alias install='sudo apt-get install'
alias uninstall='sudo apt-get remove'
alias installf='sudo apt-get -f install' #force install
alias installfr='sudo apt-get -f install --reinstall' #force reinstall
# Add repository keys (usage: addkey XXXXXXXX - last 8 digits of the key)
alias addkey='sudo apt-key adv --recv-keys --keyserver keyserver.ubuntu.com'
# Search apt repository
alias search='sudo apt-cache search'
# Cleaning
alias clean='sudo apt-get clean && sudo apt-get autoclean'
alias remove='sudo apt-get remove && sudo apt-get autoremove'
alias purge='sudo apt-get purge'
alias deborphan='sudo deborphan | xargs sudo apt-get -y remove --purge'
# Shutdown and Reboot
alias shutdown='sudo shutdown -h now'
alias reboot='sudo reboot'
# Apache Start, Stop, and Restart
alias apacherestart='sudo service apache2 reload'
alias apachestop='sudo service apache2 stop'
alias apachestart='sudo service apache2 start'
#Shellinabox Start, Stop, and Restart
alias shellstart='sudo service shellinabox start'
alias shellstop='sudo service shellinabox stop'
alias shellreload='sudo service shellinabox reload'
# Network Start, Stop, and Restart
alias networkrestart='sudo service networking restart'
alias networkstop='sudo service networking stop'
alias networkstart='sudo service networking start'
# SAMBA Start, Stop, and Restart
alias sambarestart='sudo service smbd restart'
alias sambastop='sudo service smbd stop'
alias sambastart='sudo service smbd start'
# NFS Start, Stop, and Restart
alias nfsrestart='sudo /etc/init.d/nfs-kernel-server restart'
alias nfsstart='sudo /etc/init.d/nfs-kernel-server start'
alias nfsstop='sudo /etc/init.d/nfs-kernel-server stop'
# Transmission-Daemon Start, Stop, and Restart
alias transstop='sudo /etc/init.d/transmission-daemon stop'
alias transstart='sudo /etc/init.d/transmission-daemon start'
alias transrestart='sudo /etc/init.d/transmission-daemon reload'
# SABnzbd Start, Stop, and Restart
alias sabrestart='sudo service sabnzbdplus restart'
alias sabstop='sudo service sabnzbdplus stop'
alias sabstart='sudo service sabnzbdplus start'
# CouchPotato Start, Stop, and Restart
alias couchstop='/etc/init.d/couchpotato stop'
alias couchstart='/etc/init.d/couchpotato start'
alias couchrestart='/etc/init.d/couchpotato stop ; /etc/init.d/couchpotato start'
# Sickbeard Start, Stop, and Restart
alias sickstop='/etc/init.d/sickbeard stop'
alias sickstart='/etc/init.d/sickbeard start'
alias sickrestart='/etc/init.d/sickbeard stop ; /etc/init.d/sickbeard start'
# Grub
alias grubu='sudo update-grub' #update grub
alias grubi='sudo grub-install' #install grub
# Misellaneous
alias fdisk='sudo fdisk -l'
alias uuid='sudo vol_id -u' #list UUIDs
alias rfind='sudo find / -name' #find a file. Usage: rfind 'filename'
alias rd='sudo rm -R' #remove directory
alias imount='sudo mount -o loop -t iso9660' #mount iso. Usage: imount 'filename.iso'
alias dirsize='sudo du -hx --max-depth=1' #directory size. Usage: dirsize directoryname
# Commands
alias rrsync='rsync --verbose -rtvogp --progress'
alias scp='scp -c blowfish'
alias nano='sudo nano -iSw$'
alias cp='cp --verbose'
alias mv='mv --verbose'
alias make='make -j4'
Installation
Aufruf
Optionen
Parameter
Umgebungsvariablen
Exit-Status
Anwendung
Problembehebung
Konfiguration
Dateien
Anhang
Siehe auch
Dokumentation
Man-Page
Info-Pages
Links
Projekt
Weblinks