PC & IT SUPPORT MADE EASY FORUM
Would you like to react to this message? Create an account in a few clicks or log in to continue.

Example of how to setup an alias from the cli on linux

Go down

Example of how to setup an alias from the cli on linux Empty Example of how to setup an alias from the cli on linux

Post by jamied_uk 29th November 2013, 16:04

Example of how to setup an alias from the cli on linux

Update linux with just 1 word update

Code:
alias update='sudo apt-get update'


Close linux app with the mouse to close unresponsive or apps that fail to close

Code:
alias close=' sudo xkill;'

Type this to make an alias for your firewall in 1 word firewall (easy)


List current running apps with typing list
Code:
alias list='sudo  ps aux | less'


Fix audio issues
Code:
alias fixsound='pkill jackd'


Code:
alias firewall='sudo gufw'



Type this in your cli and then type home to test

Code:
alias home='cd ~/'
Also you can remove alias's by typeing

unalias
for example

Code:
unalias home
Ok now say you want to ping google for 5 seconds then stop using an alias called png


Code:
alias png='timeout 5s ping google.com'
Other fun Alias's to set are for if you like windows commands and have moved over to linux and wish the commands were simular:

Code:
used to windows commands?
Code:
alias ipconfig='ifconfig'
this is good for listing directorys and files
Code:
alias dir='ls -l'
This will restart apache server faster then typing it all out
More Detailed ls

Code:
alias dir='ls -l -a'


Setup a ssh alias

Code:
alias picon1='ssh 192.168.1.16'

clear screan with cls

Code:
alias cls='clear'

Code:
alias srest='sudo /etc/init.d/apache2 restart'

Some alias's may not work permanently read this to make those that need to be made permanent


to make them perminant you can edit file below

Code:
sudo gedit /etc/bash.bashrc


Example of my bashrc file (always put at the bottom of the file after the fi


alias srest='sudo /etc/init.d/apache2 restart'
alias cls='clear'
alias picon1='ssh 192.166.2.19'
alias ipconfig='ifconfig'
alias png='timeout 5s ping google.co.uk'
alias home='cd ~/'
alias firewall='sudo gufw'
alias fixsound='pkill jackd'
alias list='sudo  ps aux | less'
alias close=' sudo xkill;'
alias update='sudo apt-get update'






Also please note you need to test to see if another program is using the word you plan on using so for example before you alias the word test, you first you should type test into your terminal (console aka cli) and if no actual program or command is using that word you plan to use then you should get an error saying not found for example, also try to avoid using alias's words that maybe used so dont use words like list for example.
jamied_uk
jamied_uk
Admin

Posts : 2950
Join date : 2010-05-09
Age : 41
Location : UK

https://jnet.sytes.net

Back to top Go down

Example of how to setup an alias from the cli on linux Empty Re: Example of how to setup an alias from the cli on linux

Post by jamied_uk 20th July 2015, 15:24

Code:
alias openports='sudo nmap -sS net_name'

Where net_name is your server / station name!


Code:
alias netv='sudo nmap -sP 192.168.42.0/24'


Code:
alias netv2='sudo nmap -sP 192.168.1.0/24'

Edit your alias's by using an alias Very Happy (i always think outside of the box you see and made a paradox) this works very well!
Code:
alias bedit='sudo gedit /etc/bash.bashrc'


Quick Shutdown Command Alias

Code:
alias quickshutdown='sudo shutdown -h now'


Quick Convertin Alias

Code:
alias convert1='avconv -i input.mp4 -c:a libmp3lame -q:a 4 output.mp3'


Netstat will fire off on the command rtable and it will display current routing table

Code:
alias rtable='netstat -r'



Crontabs aka cronjobs
~~~~~~~~~~~~~~~~~

Code:
alias cjob='sudo crontab -u john -l'

Web Cron Jos if required

User Specific Cron tab / cronjob
Code:
alias cjob='sudo crontab -u www-data -l'


Code:
alias cjob='sudo crontab -e'

System Wide Cron tab/ cronjob
Code:
sudo crontab -u root -e


More Commands can be found with the 2 following:

http://www.thegeekstuff.com/2010/11/50-linux-commands

http://www.thetechnicalstuff.com/top-120-linux-commands-for-linux-administrators
jamied_uk
jamied_uk
Admin

Posts : 2950
Join date : 2010-05-09
Age : 41
Location : UK

https://jnet.sytes.net

Back to top Go down

Example of how to setup an alias from the cli on linux Empty Re: Example of how to setup an alias from the cli on linux

Post by jamied_uk 30th March 2018, 10:32

More Video Examples!








jamied_uk
jamied_uk
Admin

Posts : 2950
Join date : 2010-05-09
Age : 41
Location : UK

https://jnet.sytes.net

Back to top Go down

Example of how to setup an alias from the cli on linux Empty Re: Example of how to setup an alias from the cli on linux

Post by Sponsored content


Sponsored content


Back to top Go down

Back to top

- Similar topics

 
Permissions in this forum:
You cannot reply to topics in this forum