LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Linux - Newbie (https://www.linuxquestions.org/questions/linux-newbie-8/)
-   -   Basic question. (https://www.linuxquestions.org/questions/linux-newbie-8/basic-question-4175489112/)

lmohammeed 12-25-2013 05:03 AM

Basic question.
 
Dear respected users,
Can anybody tell me the difference between running this command
Code:

cat ~/.bashrc
as a superuser (in root) and as normal user (i.e. not from root). Because when I run in both cases I got different output. Any clarification in this regard is highly appreciated.
Thanks in advance for your response.

druuna 12-25-2013 05:09 AM

The ~ is special and is substituted with the home directory path of the user that executes it.

If you are root ~/.bashrc is substituted to /root/.bashrc and if you are userX it is substituted to /home/userX/.bashrc

Each user has its own .bashrc file, and they do not have to be the same. Most normal users have a .bashrc that is basically the same (assuming you haven't changed anything yourself). Root has a more restrictive .bashrc file (or none at all).

lmohammeed 12-25-2013 06:09 AM

Basic question.
 
Thank you druuna for your reply. It clarify my doubt. In addition, as a follow up question what does this command
Code:

cat /.bashrc
meant.
Thanks.

druuna 12-25-2013 06:23 AM

The cat command shows the content of a file (not sure if you know this).

The /.bashrc part: the / reflects the root (/) directory (not to be confused with the root home directory, which is /root) and the .bashrc reflects the file.

Most, if not all, Linux distro's have their users dedicated to /home (or, in root's case /root). So the above example will probably give you an error message telling you that the file does not exist at that location:
Code:

$ cat /.bashrc
cat: /.bashrc: No such file or directory

Maybe these 2 links will also be of use to you:
- Change Directory (cd) Examples | Unix and Linux Command
- Absloute path vs relative path in Linux

lmohammeed 12-25-2013 07:08 AM

Basic question.
 
Thank you druuna.
Quote:

The cat command shows the content of a file (not sure if you know this)
, yes I know. The links you provided are useful.
Thanks

druuna 12-25-2013 07:15 AM

You're welcome.

BTW: I have an LQ blog entry with many links, which might be of help in the future: Resources / References / Useful links


All times are GMT -5. The time now is 07:51 AM.