Linux - SoftwareThis forum is for Software issues.
Having a problem installing a new program? Want to know which application is best for the job? Post your question in this forum.
Notices
Welcome to LinuxQuestions.org, a friendly and active Linux Community.
You are currently viewing LQ as a guest. By joining our community you will have the ability to post topics, receive our newsletter, use the advanced search, subscribe to threads and access many other special features. Registration is quick, simple and absolutely free. Join our community today!
Note that registered members see fewer ads, and ContentLink is completely disabled once you log in.
If you have any problems with the registration process or your account login, please contact us. If you need to reset your password, click here.
Having a problem logging in? Please visit this page to clear all LQ-related cookies.
Get a virtual cloud desktop with the Linux distro that you want in less than five minutes with Shells! With over 10 pre-installed distros to choose from, the worry-free installation life is here! Whether you are a digital nomad or just looking for flexibility, Shells can put your Linux machine on the device that you want to use.
Exclusive for LQ members, get up to 45% off per month. Click here for more info.
I logged into my linux system with a limited user and entered the root using " su " command in the terminal. Then i added some aliases from the root login.then i logged out from root.and again i acquired the root login using "su " command .when i type the alias command it is not showing the previously added aliases.
When you add an alias it is in the current shell. To add it automatically next time you become the user you need to add it to that user's startup files ($HOME/.bashrc and/or $HOME/.bashprofile assuming you're using bash shell).
Also note that when you do "su root" (or just "su" since root is default user) you are NOT invoking the environment of the root user. You must type "su - root" or "su -" to invoke that environment. Otherwise it is using the environment it had before the switch to root.
Where did you put your aliases definition? If you simply write them on the command line, they are local to the current shell and are lost when you terminate the session. If you put them in a file which is sourced every time you login, as $HOME/.bashrc, you retrieve your aliases (or functions).
yes,if i add aliases by logging as "su - root". I only see aliases when login as "su - root".If i login as "su " i could not see any .
why
As jlightner already said, when you switch to root using su without the hyphen, you keep the environment of the current user. When you use su - you switch to root starting a login session. In this way all the files are sourced at login (.bash_profile, .bashrc and so on) and the root's environment is set up.
Quote:
Originally Posted by surya_prakash
there is nothing like .bashrc file in HOME. I could only find .bash_history
.bashrc is not mandatory, but you can always create it if necessary. If it misses, most likely you don't use /bin/bash as login shell. Anyway, you didn't replay to my previous question: where did you put the aliases? If not in the missing .bashrc, to which file have you added them?
$HOME is the home directory of the user. This could be something like:
/
/root
/home/root
/billybob
It is whatever was defined as the user's home directory in /etc/passwd. You can find out what it is by doing the "su -" then typing "echo $HOME".
If there is no .bashrc in root's $HOME you can create it. Of course this also assumes the shell for root is bash. If it were zsh or ksh you might need a different file. The last thing for root user in /etc/passwd is the shell it uses.
That's the 'normal' basic root prompt (especially the '#') to show you are root.
You can customise it by looking at the contents of /etc/profile, /etc/bashrc, looking for the word 'PROMPT' and editing the user's .bashrc as needed.
LinuxQuestions.org is looking for people interested in writing
Editorials, Articles, Reviews, and more. If you'd like to contribute
content, let us know.