Ceci est une ancienne révision du document !
Addendum To my horror, having proudly informed you all of how to create your first alias, I restarted my computer only to notice that my alias commands had disappeared. I repeated the process: set the alias, restarted the puter. Nothing. So: how can an alias survive a restart?
.bashrc The .bashrc file is for user-specific (just your account, not for the whole computer) changes to your terminal. Open .bashrc with your favorite editor. (If I had been a very good boy, I'd have made a copy of it before editing). It's located in your home directory. Run a search for alias on the file contents. You should, with a minimal amount of searching, come across something that looks a bit like this:
… # some more ls aliases alias ll='ls -alF' alias la='ls -A' alias l='ls -CF' …
If you remember from last month, I wanted to change how folders and files were listed when I used ls. I wanted to: i) list files & folders vertically; and ii) list directories first. The more observant of you will realise that the aliases listed above determine the functionality of ll, la & l not ls. The ls alias is sitting above them amidst some code. In my .bashrc file, it looks like the code below.
… # enable color support of ls and also add handy aliases if [ -x /usr/bin/dircolors ]; then test -r ~/.dircolors && eval “$(dircolors -b ~/.dircolors)” || eval “$(dircolors -b)”
alias ls='ls --color=auto'
… fi …
For Ubuntu 12.04 LTS, ls is preset to list files and folders in different colors. Hence, an alias already exists for ls, as seen in the code above. I merely need to add my two preferences to the existing alias.
… alias ls='ls -1 –group-directories-first –color=auto' …
Save the .bashrc file, restart the computer, and the alias settings remained. Problem solved. Showing off Following this small success, I added two more aliases to make my Ubuntu-ing a little quicker.
#firefox alias alias firefox='firefox –private &'
#evolution alias alias evolution='evolution &'
Also, I often turn on my puter and want to open both a browser and my email, but not always. So I added one more alias for this:
#open evolution & firefox together alias internet='evolution firefox'
One important to thing to note about this piece of code is the missing && between evolution and firefox, which would be necessary if I were to run two commands simultaneously at the command line. However, one ampersand & as set in the initial alias alias evolution='evolution &' already returns the command line when the program has been launched so it's not necessary to inform the computer you are launching two commands simultaneously with &&.
To finish, please tell how you use alias on your machine. NB. The alias command & .bashrc is a part of LPIC learning statement 1.105.1 Customize and use the shell environment. (weight: 4)