Tuesday, May 7, 2024
17
rated 0 times [  17] [ 0]  / answers: 1 / hits: 30065  / 3 Years ago, sun, september 26, 2021, 12:01:55

I need to execute a command for my system to search for new sd cards and to be able to execute it I need to execute it as root. Simply using sudo with the command does not work. This is not a question of how to execute an alias with sudo rights!

I want to know how to add an alias to the root user so I can execute it after using sudo -i.
I tried logging in to the root user and just adding the alias (which works fine). The only problem is that the alias disappears after I log out from the terminal.


More From » command-line

 Answers
2

You should add that alias command line to .bashrc file in /root folder and not in /home/user/.bashrc(this .bashrc file belongs to user account not root).



By doing so .bashrc file in /root is run at root login, your alias command will be automatically created every time.



So that you can use your alias command directly in shell when logged in as root.


[#24239] Tuesday, September 28, 2021, 3 Years  [reply] [flag answer]
Only authorized users can answer the question. Please sign in first, or register a free account.
luringdge

Total Points: 3
Total Questions: 126
Total Answers: 109

Location: India
Member since Sun, Feb 6, 2022
2 Years ago
;