LinuxQuestions.org
Help answer threads with 0 replies.
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Newbie
User Name
Password
Linux - Newbie This Linux forum is for members that are new to Linux.
Just starting out and have a question? If it is not in the man pages or the how-to's this is the place!

Notices


Reply
  Search this Thread
Old 12-25-2013, 05:03 AM   #1
lmohammeed
Member
 
Registered: Sep 2013
Posts: 61

Rep: Reputation: Disabled
Question 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.
 
Old 12-25-2013, 05:09 AM   #2
druuna
LQ Veteran
 
Registered: Sep 2003
Posts: 10,532
Blog Entries: 7

Rep: Reputation: 2405Reputation: 2405Reputation: 2405Reputation: 2405Reputation: 2405Reputation: 2405Reputation: 2405Reputation: 2405Reputation: 2405Reputation: 2405Reputation: 2405
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).
 
1 members found this post helpful.
Old 12-25-2013, 06:09 AM   #3
lmohammeed
Member
 
Registered: Sep 2013
Posts: 61

Original Poster
Rep: Reputation: Disabled
Question 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.
 
Old 12-25-2013, 06:23 AM   #4
druuna
LQ Veteran
 
Registered: Sep 2003
Posts: 10,532
Blog Entries: 7

Rep: Reputation: 2405Reputation: 2405Reputation: 2405Reputation: 2405Reputation: 2405Reputation: 2405Reputation: 2405Reputation: 2405Reputation: 2405Reputation: 2405Reputation: 2405
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
 
1 members found this post helpful.
Old 12-25-2013, 07:08 AM   #5
lmohammeed
Member
 
Registered: Sep 2013
Posts: 61

Original Poster
Rep: Reputation: Disabled
Question 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
 
Old 12-25-2013, 07:15 AM   #6
druuna
LQ Veteran
 
Registered: Sep 2003
Posts: 10,532
Blog Entries: 7

Rep: Reputation: 2405Reputation: 2405Reputation: 2405Reputation: 2405Reputation: 2405Reputation: 2405Reputation: 2405Reputation: 2405Reputation: 2405Reputation: 2405Reputation: 2405
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
 
  


Reply



Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
C Basic question shwethavb Programming 1 03-21-2012 10:56 AM
basic html question - download link to files on my webpage question Davno Linux - Server 5 12-25-2009 07:24 AM
Basic C++ question gregorian Linux - Newbie 4 02-23-2007 07:13 PM
A Basic Question abw Linux - Hardware 2 10-06-2004 03:40 PM
*very* basic c question usernamed Programming 9 08-21-2003 08:29 AM

LinuxQuestions.org > Forums > Linux Forums > Linux - Newbie

All times are GMT -5. The time now is 09:44 PM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration