📜 ⬆️ ⬇️

sudo and alias in .bashrc

Foreword


Recently, visiting a friend, I saw Scott Granneman’s book “ Linux. Pocket guide "and begged her to read. And although Linux has been on my computer for two years now, I don’t know perfectly the command line commands (I apologize for the tautology).
Actually, in the third year of university, we had a Unix course, which I really liked, and on which I was able to evaluate the power and strength of the command line unix 'similar systems. Unfortunately, at that time I had only dialup , and I had to code mainly Delphi , so the transition to Linux ( Mandrake ) was not set, but very sorry .

alias


Something I digress from the topic of the post. I read in the book means some interesting points and immediately decided to try. Firstly, this is an assignment to ~ / .bashrc alias for commands. The first thing I did was assign alias for the ls command , I often use it and almost on the machine drive ls -l . From the same book, I learned that it is useful to specify another parameter h , for a more visual display of file sizes, and this is what I did:
alias l='ls -lh'
It would seem nothing special, but convenient pancake .

sudo


Then I read to the ways of combining teams, and found an interesting example:
apt-get update && apt-get upgrade
The main idea of ​​this record is to perform a system update if the list of packages has been successfully updated. Since I now have a beta of Ubuntu 10.04, then I update every day, so I decided to add another alias :
alias uu='apt-get update && apt-get upgrade'
I restart the terminal, sudo uu , and he says to me that I don’t know the uu command. Without hesitation, I add a similar alias to /root/.bashrc .
I restart the terminal, sudo uu , but it’s the same to me again. And then I wondered, and who are you then sudo ?

After some thought, I decided to ask google what I immediately received a few answers, but not one of them did not work for me. If anyone is interested, it was suggested to add alias to the global /etc/bash.bashrc file, as well as to call sudo -E .
')
A simple and effective solution was suggested by the familiar Linuxa guru - medvoodoo .
sudo is a command that alias ' s handles bash itself, therefore sudo cannot understand what they want from it. (I can be wrong here, you can correct me in the comments).
As a result, my alias uu looks like this:
alias uu='sudo apt-get update && sudo apt-get upgrade -y'

I hope this information will be interesting for someone.

PS Congratulations to all on the occasion of the Great Easter and Happy 4.04 .

Source: https://habr.com/ru/post/89916/


All Articles