Today I came through a concept called aliases in linux. It was pretty interesting topic. An alias is a command that is user-defined built from other commands. For eg, you could build an alias by,
$ alias aliasName=’command1; command2;’
After that you could enter this alias name in the terminal to execute the commands in chain.
.bashrc is a hidden file which is located in your home directory. Some linux based operating systems have them by default, but sometime they are not created by default. If not already present, then you can create it yourself. But remember to create it in the home directory. ‘.bashrc’ is a shell script that is automatically executed by terminal session, whenever it is started. ‘.bashrc’ file allows you to create permanent aliases.
The problem with alias is that they are temporary by default, means aliases will only execute for one terminal session in which it was created. If you create an alias and close the terminal, and then you opened a new terminal session, the previous alias you created won’t work in the new terminal session.
So inorder to solve this problem we need to create permanent alias. For creating permanent alias, simply copy your alias command and paste it into the .bashrc file. So each time you open a new terminal session, the .bashrc file will create your alias for you.
While reading a book on linux ( The linux command line ), I came through the concept of links. There are two types of links in linux, hard link and symbolic link. The latter was created to overcome the limitations of the former.
The hardlinks was the method adopted by the earlier linux versions. It was the original way of creating a link in linux. Every file will have a filename, by default this filename is attached to the file using a hardlink, therefore every file has a hardlink by default. Now coming to the limitations of hardlink.
A hardlink can be created by using the following command.
$ ln file linkname
A hardlink can be removed by using the following command.
$ unlink linkname
Now the awesome part of the links is that whenever you make any changes to content of the link, it is automatically applied to the file.
The symbolic links allows you to create links to the directories as well. Also it allow you to create a link that can reference a file outside it’s own filesystem.
A symlink can be created by using the following command.
$ ln -s <directory/file> linkname
A symlink can be removed by using the following command.
$ unlink linkname
Being a linux user, you may be familiar with terminals. Terminals are used to enter commands that could perform some functions. In windows, there is something called batch programs that allow you to execute the windows cmd commands one by one. Shell programming allow you to create script files that are programs on their own. These scripts can execute a chain of commands. Shell programming also allow you to use normal programming constructs like for, while, if etc..
Shell is basically an interface between us and unix kernal. It converts the commands we enter into something the kernal could understand. Kernal is what that manages resources in our linux OS. Most of linux operating system provide it’s users with a shell program from the GNU project called the ‘bash’. The bash is the acronym for ‘bourne again shell’. For the graphical user interface, there is another program called the terminal emulator which is supplied for interaction with the shell.