My usefull aliases

xrs1969
  10 years ago
  3

Ok , working on windows and DOS , so many years , some DOS commands became my second nature in my everyday computer life !!!  DIR, CLS, DIR /P, DEL, REN,PING, etc, were my everyday's keyboard stokes !

When i switch to Linux and Unix-like environments , I find somewhat difficult to have to remember new commands for doing common tasks : LS, LS -altrh , CLEAR, DU -h, and many more commands using complicated options and the PING command just keep pinging  Endlessly (why ????) .....

So, I have created a useful  file that has all my aliases in one place and copying it over to my bash login script is my FIRST thing to do , before I even clear the screen on a Linux terminal !!!

It's not that I have invented the wheel, but I find them extremely useful to work with !

You can put them all in a file called : ".bash_aliases" and put it your Home directory, or modify you .bashrc file  so that it can be executed upon opening a terminal window :

#General use
alias cls='clear' : yes clear is too long for me to write after writing cls so many years in the past !!

alias dfm='df -h' : originally I used df -m to display the sizes in Megabytes, but -h switch is much more convenient !

alias edit='nano' : edit is another way to open up nano if your're used to type edit . Or you can put in gedit, vim or your favorite editor !

alias dir='dir -achltr --group-directories-first --color=auto' : dir now display directories first , show all files with different colors , shows all files and display permissions, file sizes and date as well.

alias h='history' : history toooo long type. h is better .

alias del='rm -i' : because I was used to del   and the -i switch adds a confirmation just to make sure !


alias copy='cp -i' : cp is much shorter , but copy is easier to remember plus it prompts you in case you overwrite any file at the destination.

alias restart='sudo shutdown -r now' : isn't it much better , athough you have to be carefull !


alias ping='ping -c 4' : yes , only 4 pings !!!!!!


alias shut='sudo shutdown -P now' : shuts your computer , be very carefull to close all open applications otherwise you may lose  your work.

# Transmission-daemon start/stop
alias tron='sudo /etc/init.d/transmission-daemon start' : nice alias to start the transmission-daemon if you use it !


alias troff='sudo /etc/init.d/transmission-daemon stop' : nice alias to stop the transmission-daemon service .

#Apt-get update/upgrade
alias update='sudo apt-get update' : usefull
alias upgrade='sudo apt-get upgrade' :  also usefull

#Check open ports
alias ports='netstat -tulanp' : checks open ports on your computer but not all services , you have to run it as root (sudo) in order to display all !

#Get free mem stats
alias mem='free -h' :  nice alias to display freem RAM in Gigabytes


#Color Prompt
export PS1='${debian_chroot:+($debian_chroot)}\[\033[01;32m\]\u@\h\[\033[00m\]:\[\033[01;34m\]\w\[\033[00m\]\$' : a nice prompt for your terminal displaying the user and the hostname as well as the current folder you're in , in different colors !!

#XBMC start/stop
alias xbmcstart='sudo initctl start xbmc' : start XBMC service
alias xbmcstop='sudo initctl stop xbmc' : stop XBMC service


Well that's all for now ! I will try to update this with any new and usefull aliases !
If you any other userfull aliases that could make our lives easier please notify me .
 

Comments
jahid_0903014 10 years ago

informative


Qruqs 10 years ago

Additional stuff, for keyboard junkies (like me):
clear = Ctrl-L
exit = Ctrl-D
Those work in Python interpreter, too.


sujitnag 10 years ago

I have basic knowledge about it. .bash_aliases is not problem for me. In
this tutorial is used only a basic command "alias". so this tutorial is only for linux beginner. so you have to clearly mention every step.otherwise this tutorial is worthless.

you have to modify your tutorial for linux beginner.


Hammer459 10 years ago

I am using it :-) The nroff system (groff is the gnu version?) is used by man ....
As for the include/execute of .bash_aliases that does need to be better described.


xrs1969 10 years ago

Thanx for the feedback....the .bash_aliases does work nicely if you modify the .bashrc to execute the .bash_aliases script. That way you have all your aliases in one place !!
As for the troff , it is indeed a Unix command ("troff - the troff processor of the groff text formatting system") but who is using it !!??!!!


sujitnag 10 years ago

.bash_aliases is not work. we need to incorporate it in some way.
this tutorial need modification.


Hammer459 10 years ago

Oh I forgot your alias "restart" is already a command "reboot" that actually is clearer as to what it does.
However doing reboot or shutdown from DE shuts down your apps nicely too. Much safer and 2 clicks rather than 5 keystrokes :-)


Hammer459 10 years ago

I am not sure about the usefulness of cementing your DOS-commands it is a good description on how to create aliases.
Note: "troff" is already a unix command so it may not be a good idea to mask it with an alias doing something completely different.