.bash aliases: Unterschied zwischen den Versionen

Aus Foxwiki
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…“
 
Keine Bearbeitungszusammenfassung
Zeile 5: Zeile 5:
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 the .bashrc file in your home directory:
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 the .bashrc file in your home directory:


<tt>cd ~</tt>
cd ~


<tt>ls -al</tt>
ls -al




Check to see if you have a .bashrc file. If you have it then open the file in nano or your favorite text editor and look for the following lines:
Check to see if you have a .bashrc file. If you have it then open the file in nano or your favorite text editor and look for the following lines:


<tt>if [ -f ~/.bash_aliases ]; then</tt>
if [ -f ~/.bash_aliases ]; then


<tt>&nbsp;&nbsp;&nbsp;&nbsp;. ~/.bash_aliases</tt>
. ~/.bash_aliases


<tt>fi</tt>
fi




Zeile 23: Zeile 23:
Now create a .bash_aliases file in your home directory and start adding your aliases to the file. Below is an example of .bash_aliases file:
Now create a .bash_aliases file in your home directory and start adding your aliases to the file. Below is an example of .bash_aliases file:


<tt><nowiki># Update and Upgrade Packages</nowiki></tt>
# Update and Upgrade Packages
 
alias update='sudo apt-get update'
<tt>alias update='sudo apt-get update'</tt>
alias upgrade='sudo apt-get upgrade'
 
<tt>alias upgrade='sudo apt-get upgrade'</tt>
# Install and Remove Packages
 
alias install='sudo apt-get install'
&nbsp;
alias uninstall='sudo apt-get remove'
 
alias installf='sudo apt-get -f install' #force install
<tt><nowiki># Install and Remove Packages</nowiki></tt>
alias installfr='sudo apt-get -f install --reinstall' #force reinstall
 
<tt>alias install='sudo apt-get install'</tt>
# Add repository keys (usage: addkey XXXXXXXX - last 8 digits of the key)
 
alias addkey='sudo apt-key adv --recv-keys --keyserver keyserver.ubuntu.com'
<tt>alias uninstall='sudo apt-get remove'</tt>
 
# Search apt repository
<tt>alias installf='sudo apt-get -f install' #force install</tt>
alias search='sudo apt-cache search'
 
<tt>alias installfr='sudo apt-get -f install --reinstall' #force reinstall</tt>
# Cleaning
 
alias clean='sudo apt-get clean && sudo apt-get autoclean'
&nbsp;
alias remove='sudo apt-get remove && sudo apt-get autoremove'
 
alias purge='sudo apt-get purge'
<tt><nowiki># Add repository keys (usage: addkey XXXXXXXX - last 8 digits of the key)</nowiki></tt>
alias deborphan='sudo deborphan | xargs sudo apt-get -y remove --purge'
 
<tt>alias addkey='sudo apt-key adv --recv-keys --keyserver keyserver.ubuntu.com'</tt>
# Shutdown and Reboot
 
alias shutdown='sudo shutdown -h now'
&nbsp;
alias reboot='sudo reboot'
 
<tt><nowiki># Search apt repository</nowiki></tt>
# Apache Start, Stop, and Restart
 
alias apacherestart='sudo service apache2 reload'
<tt>alias search='sudo apt-cache search'</tt>
alias apachestop='sudo service apache2 stop'
 
alias apachestart='sudo service apache2 start'
&nbsp;
 
#Shellinabox Start, Stop, and Restart
<tt><nowiki># Cleaning</nowiki></tt>
alias shellstart='sudo service shellinabox start'
 
alias shellstop='sudo service shellinabox stop'
<tt>alias clean='sudo apt-get clean && sudo apt-get autoclean'</tt>
alias shellreload='sudo service shellinabox reload'
 
<tt>alias remove='sudo apt-get remove && sudo apt-get autoremove'</tt>
# Network Start, Stop, and Restart
 
alias networkrestart='sudo service networking restart'
<tt>alias purge='sudo apt-get purge'</tt>
alias networkstop='sudo service networking stop'
 
alias networkstart='sudo service networking start'
<tt>alias deborphan='sudo deborphan | xargs sudo apt-get -y remove --purge'</tt>
 
# SAMBA Start, Stop, and Restart
&nbsp;
alias sambarestart='sudo service smbd restart'
 
alias sambastop='sudo service smbd stop'
<tt><nowiki># Shutdown and Reboot</nowiki></tt>
alias sambastart='sudo service smbd start'
 
<tt>alias shutdown='sudo shutdown -h now'</tt>
# NFS Start, Stop, and Restart
 
alias nfsrestart='sudo /etc/init.d/nfs-kernel-server restart'
<tt>alias reboot='sudo reboot'</tt>
alias nfsstart='sudo /etc/init.d/nfs-kernel-server start'
 
alias nfsstop='sudo /etc/init.d/nfs-kernel-server stop'
&nbsp;
 
# Transmission-Daemon Start, Stop, and Restart
<tt><nowiki># Apache Start, Stop, and Restart</nowiki></tt>
alias transstop='sudo /etc/init.d/transmission-daemon stop'
 
alias transstart='sudo /etc/init.d/transmission-daemon start'
<tt>alias apacherestart='sudo service apache2 reload'</tt>
alias transrestart='sudo /etc/init.d/transmission-daemon reload'
 
<tt>alias apachestop='sudo service apache2 stop'</tt>
# SABnzbd Start, Stop, and Restart
 
alias sabrestart='sudo service sabnzbdplus restart'
<tt>alias apachestart='sudo service apache2 start'</tt>
alias sabstop='sudo service sabnzbdplus stop'
 
alias sabstart='sudo service sabnzbdplus start'
&nbsp;
 
# CouchPotato Start, Stop, and Restart
<tt><nowiki>#Shellinabox Start, Stop, and Restart</nowiki></tt>
alias couchstop='/etc/init.d/couchpotato stop'
 
alias couchstart='/etc/init.d/couchpotato start'
<tt>alias shellstart='sudo service shellinabox start'</tt>
alias couchrestart='/etc/init.d/couchpotato stop ; /etc/init.d/couchpotato start'
 
<tt>alias shellstop='sudo service shellinabox stop'</tt>
# Sickbeard Start, Stop, and Restart
 
alias sickstop='/etc/init.d/sickbeard stop'
<tt>alias shellreload='sudo service shellinabox reload'</tt>
alias sickstart='/etc/init.d/sickbeard start'
 
alias sickrestart='/etc/init.d/sickbeard stop ; /etc/init.d/sickbeard start'
&nbsp;
 
# Grub
<tt><nowiki># Network Start, Stop, and Restart</nowiki></tt>
alias grubu='sudo update-grub' #update grub
 
alias grubi='sudo grub-install' #install grub
<tt>alias networkrestart='sudo service networking restart'</tt>
 
# Misellaneous
<tt>alias networkstop='sudo service networking stop'</tt>
alias fdisk='sudo fdisk -l'
 
alias uuid='sudo vol_id -u' #list UUIDs
<tt>alias networkstart='sudo service networking start'</tt>
alias rfind='sudo find / -name' #find a file. Usage: rfind 'filename'
 
alias rd='sudo rm -R' #remove directory
&nbsp;
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
<tt><nowiki># SAMBA Start, Stop, and Restart</nowiki></tt>
 
# Commands
<tt>alias sambarestart='sudo service smbd restart'</tt>
alias rrsync='rsync --verbose -rtvogp --progress'  
 
alias scp='scp -c blowfish'
<tt>alias sambastop='sudo service smbd stop'</tt>
alias nano='sudo nano -iSw$'
 
alias cp='cp --verbose'
<tt>alias sambastart='sudo service smbd start'</tt>
alias mv='mv --verbose'
 
alias make='make -j4'
&nbsp;
 
<tt><nowiki># NFS Start, Stop, and Restart</nowiki></tt>
 
<tt>alias nfsrestart='sudo /etc/init.d/nfs-kernel-server restart'</tt>
 
<tt>alias nfsstart='sudo /etc/init.d/nfs-kernel-server start'</tt>
 
<tt>alias nfsstop='sudo /etc/init.d/nfs-kernel-server stop'</tt>
 
&nbsp;
 
<tt><nowiki># Transmission-Daemon Start, Stop, and Restart</nowiki></tt>
 
<tt>alias transstop='sudo /etc/init.d/transmission-daemon stop'</tt>
 
<tt>alias transstart='sudo /etc/init.d/transmission-daemon start'</tt>
 
<tt>alias transrestart='sudo /etc/init.d/transmission-daemon reload'</tt>
 
&nbsp;
 
<tt><nowiki># SABnzbd Start, Stop, and Restart</nowiki></tt>
 
<tt>alias sabrestart='sudo service sabnzbdplus restart'</tt>
 
<tt>alias sabstop='sudo service sabnzbdplus stop'</tt>
 
<tt>alias sabstart='sudo service sabnzbdplus start'</tt>
 
&nbsp;
 
<tt><nowiki># CouchPotato Start, Stop, and Restart</nowiki></tt>
 
<tt>alias couchstop='/etc/init.d/couchpotato stop'</tt>
 
<tt>alias couchstart='/etc/init.d/couchpotato start'</tt>
 
<tt>alias couchrestart='/etc/init.d/couchpotato stop ; /etc/init.d/couchpotato start'</tt>
 
&nbsp;
 
<tt><nowiki># Sickbeard Start, Stop, and Restart</nowiki></tt>
 
<tt>alias sickstop='/etc/init.d/sickbeard stop'</tt>
 
<tt>alias sickstart='/etc/init.d/sickbeard start'</tt>
 
<tt>alias sickrestart='/etc/init.d/sickbeard stop ; /etc/init.d/sickbeard start'</tt>
 
&nbsp;
 
<tt><nowiki># Grub</nowiki></tt>
 
<tt>alias grubu='sudo update-grub' #update grub</tt>
 
<tt>alias grubi='sudo grub-install' #install grub</tt>
 
&nbsp;
 
<tt><nowiki># Misellaneous</nowiki></tt>
 
<tt>alias fdisk='sudo fdisk -l'</tt>
 
<tt>alias uuid='sudo vol_id -u' #list UUIDs</tt>
 
<tt>alias rfind='sudo find / -name' #find a file. Usage: rfind 'filename'</tt>
 
<tt>alias rd='sudo rm -R' #remove directory</tt>
 
<tt>alias imount='sudo mount -o loop -t iso9660' #mount iso. Usage: imount 'filename.iso'</tt>
 
<tt>alias dirsize='sudo du -hx --max-depth=1' #directory size. Usage: dirsize directoryname</tt>
 
&nbsp;
 
<tt><nowiki># Commands</nowiki></tt>
 
<tt>alias rrsync='rsync --verbose -rtvogp --progress' </tt>
 
<tt>alias scp='scp -c blowfish'</tt>
 
<tt>alias nano='sudo nano -iSw$'</tt>
 
<tt>alias cp='cp --verbose'</tt>
 
<tt>alias mv='mv --verbose'</tt>
 
<tt>alias make='make -j4'</tt>
 


If you would like to share your thoughts/ideas please post in the comments section. Hope this improves your productivity too.
If you would like to share your thoughts/ideas please post in the comments section. Hope this improves your productivity too.

Version vom 17. November 2024, 12:08 Uhr

.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 the .bashrc file in your home directory:

cd ~
ls -al


Check to see if you have a .bashrc file. If you have it then open the file in nano or your favorite text editor and look for the following lines:

if [ -f ~/.bash_aliases ]; then
. ~/.bash_aliases
fi


Make sure that they are uncommented (no # symbol in front of the lines). If you do not find the .bashrc file in your home directory then follow this post to create it.

Now create a .bash_aliases file in your home directory and start adding your aliases to the file. Below is an example of .bash_aliases file:

# 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'

If you would like to share your thoughts/ideas please post in the comments section. Hope this improves your productivity too.