![]() ![]() Sometimes, especially if you use private keys instead of credentials to log in to other Linux systems, it can be easier to set up aliases for each of them with mnemonic names.Īs a SysOp, I use SSH for logging in to different Linux servers and I have several private keys, depending on my clients, therefore it helps me to have aliases such as: #alias for servers SSHĪlias sshserver1='ssh -i ~/Documents/IT/SSH-keys/server1.pem 'Īlias sshserver2='ssh -i ~/Documents/SSH-keys/server2.pem 'Īlias sshplexserverhome='ssh 'Īlias sshclientserver='ssh -i ~/Documents/IT/SSH-keys/client.pem 'Īs you can see, I have all my private keys in a folder named “SSH-keys” inside my own user’s folder and then I simply create aliases to connect each of them, following a standard of “ssh”+”name of the server”. Making ssh to other systems easier and faster This makes ‘rm’ command safer as whenever you use it, it will always ask if you are sure you want to perform the infamous removal operation before proceeding, giving you a second and last chance to not break things unintentionally. This is why, I use the following alias: #make rm command safer Making ‘rm’ saferĪs it is well known, rm command is very commonly used day by day and can be also very destructive and disruptive of a system if not properly used. Let me share some aliases that I always use to work more effectively in Linux. My favorite alias in Linux I cannot live without If you wan to remove an alias permanently, you should delete it from the bashrc file. You can remove all alias at once using the -a option: unalias -aĪs with the alias command, changes by unalias command are also temporary. If you want to remove an alias, you can use the unalias command in this manner: unalias your_alias_name aliasĪlias alert='notify-send -urgency=low -i "$( & echo terminal || echo error)" "$(history|tail -n1|sed -e '''s/^s+s// s/s*alert$//''')"'Īlias ls='ls -color=auto' How to remove alias aliasĪ typically Ubuntu system has the following alias set by default. However, a much easier way to see all the alias would be to simply run the alias command without any arguments. If you want to see all the alias set on the system for you, you can check the configuration file of your shell like ~/.bashrc, ~/.zshrc etc. How to see all the alias set on your Linux system for you If you want the aliases to be available for all users on your Linux system, you should add the aliases in /etc/bash.bashrc file. I suggest creating either blocks or at least adding commentaries in the file for each of the aliases created so it’s easier in the future to know what is each thing for maintenance purposes. bashrc file and you must start adding aliases by the end of the file, just after the last written line of it. You can use vim command to edit the file in terminal. ![]() This file is located in your /home// folder. Some distributions might suggest using a dedicated. In order to add aliases that can work in a system all the time, you need to simply edit your user’s (or any other user’s). If you exit the shell, you’ll lose the alias. If you want to use the original command, without its aliased version, use single quotes around it. For example, in Ubuntu, ls is actually an alias to show you colorful output. You can check if a certain command is actually an alias with the type command. There are no reserved keywords so you may replace an existing command with a totally irrelevant command. Be careful in choosing the name of the alias.If you mistakenly put a space, you’ll see an error like alias not found. There must be no spaces before or after the equals sign in the alias command.The substituted command is always used under the inverted commas (‘).I’ll continue with the same example I used above. In a similar fashion, you can substitute long and complicated commands with small and simple commands by using alias in Linux. ![]() You can type ls -lrta all the time or you create an alias (say) ‘ll’ that will be equivalent to ls -lrta. Take a simple example where you have to use ls command to show everything in reverse chronological order. It can be used to avoid repetitive long typing of commands and shell lines and simplify work or to even make things safer or dumb-proof. The shell alias is simply a way to reference another command. ![]() This is where ‘alias’ command comes to the show and can be extremely useful, especially for security purposes and to simplify work for a system administrator. As it is known, Linux and Unix were created as command line based systems, which means having control of the commands typed is basically the most important thing to be a *nix SysOp. ![]()
0 Comments
Leave a Reply. |
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |