Review your favorite Linux distribution.
Go Back > Forums > Linux Forums > Linux - Newbie
User Name
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!


  Search this Thread
Old 10-24-2010, 12:16 AM   #1
siva balan
LQ Newbie
Registered: Jul 2010
Posts: 25

Rep: Reputation: 0
root directory

i am using fedora 13.

if is use the command "cd //".

it changes to root is it?

what "//" denote?

thanks in advance..
Old 10-24-2010, 12:55 AM   #2
Registered: Aug 2007
Location: India
Distribution: Slackware (mainly) and then a lot of others...
Posts: 855

Rep: Reputation: Disabled
Well this is strange. I did not try that command but then I think that should not work. You should try cd /.
For more info about directories try man hier.
Hope this helps.
Old 10-24-2010, 01:07 AM   #3
David the H.
Bash Guru
Registered: Jun 2004
Location: Osaka, Japan
Distribution: Debian + kde 4 / 5
Posts: 6,842

Rep: Reputation: 2004Reputation: 2004Reputation: 2004Reputation: 2004Reputation: 2004Reputation: 2004Reputation: 2004Reputation: 2004Reputation: 2004Reputation: 2004Reputation: 2004
The backslash is used in the shell as an escape character. Since some characters, such as spaces, have special meanings, putting a backslash (also a special character) in front of them protects them from interpretation by the shell and makes them literal again. "/ " is a literal space, "/[/]" are literal brackets, and "//" is a literal forward slash.

So in the shell, // = /. But then it's up to the command you're passing it to how to interpret the single literal backslash. The cd command can accept one as a directory separator. You could also use cd "/" or cd '/', which do the same thing.
Old 10-24-2010, 01:18 AM   #4
LQ Newbie
Registered: Oct 2010
Posts: 6

Rep: Reputation: 0
I’ve used cd / and cd.. , but never cd //.

cd / puts you in the top directory, wherever you are. If enter an ls after cd / you should see some of these top-level directories:

boot bin dev etc home lib misc mnt net opt root srv usr var

cd .. puts you one directory ABOVE wherever you are.

More info. on the cd command is available here.

Info. on directory on Fedora directories is available here.
Old 10-24-2010, 07:15 AM   #5
Registered: Jan 2005
Location: Summer Midwest USA, Central Illinois, Winter Central Florida
Distribution: Slackware®
Posts: 13,434
Blog Entries: 31

Rep: Reputation: 2605Reputation: 2605Reputation: 2605Reputation: 2605Reputation: 2605Reputation: 2605Reputation: 2605Reputation: 2605Reputation: 2605Reputation: 2605Reputation: 2605

Originally Posted by siva balan View Post
i am using fedora 13.

if is use the command "cd //".

it changes to root is it?

what "//" denote?

thanks in advance..
'cd' is a 'bash' internal command.

excerpt from 'man cd';
cd - Change working directory

cd ?dirName?

Change the current working directory to dirName, or to the home directory (as
specified in the HOME environment variable) if dirName is not given. Returns
an empty string. Note that the current working directory is a per-process
resource; the cd command changes the working directory for all interpreters
and (in a threaded environment) all threads.

Change to the home directory of the user fred:
cd ~fred

Change to the directory lib that is a sibling directory of the current one:
cd ../lib
You should read the following;

excerpt 'User Commands (1)';
cd [-L|-P] [dir] Change the current directory to dir. The variable HOME is the default dir. The variable CDPATH defines the search path for the directory containing dir. Alternative directory names in CDPATH are separated by a colon (. A null directory name in CDPATH is the same as the current directory, i.e., ``.''. If dir begins with a slash (/), then CDPATH is not used. The -P option says to use the physical directory structure instead of following symbolic links (see also the -P option to the set builtin command); the -L option forces symbolic links to be followed. An argument of - is equivalent to $OLDPWD. If a non-empty directory name from CDPATH is used, or if - is the first argument, and the directory change is successful, the absolute pathname of the new working directory is written to the standard output. The return value is true if the directory was successfully changed; false otherwise.
So from the above definition 'cd //' will indeed place the root/privileged user in '/'.

'man command' is your friend!

1 members found this post helpful.
Old 10-24-2010, 08:02 AM   #6
Senior Member
Registered: Oct 2009
Location: Wroclaw, Poland
Distribution: Arch, Kubuntu
Posts: 1,261

Rep: Reputation: 315Reputation: 315Reputation: 315Reputation: 315
This is intentional action. All consecutive slashes are replaced with one slash to canonicalization. I think this was made for simplify writing scripts.
Old 10-24-2010, 03:40 PM   #7
Registered: Oct 2003
Location: Chico, CA, USA
Distribution: Linux Mint
Posts: 877

Rep: Reputation: 124Reputation: 124

Also, trailing slashes in a path only denote that the path is, in fact, a directory (as opposed to another file type). Try "cd /home" and "cd /home/". Same result (you end up in /home). "/" is the name of a directory (the root directory). Therefore, putting a slash after it is just like (redundantly) saying that "/" is, in fact, a directory.

If you're trying to get to a networked path, you'll want to use the distributions SMB/Samba network browser. There, you can enter a path like "//computer/sharedirectory/file", and it will take you to the expected location. You can also do this using smbmount or "mount -t cifs" like this:

mount -t cifs //computer/sharedirectory/ /place/you/want/to/mount/it/
As mentioned above, in order to type a backslash, "\" on the command line and have it actually actlike punctuation, rather than escape character, you need to type two of them for each backslash you actually want to use, like this:

mount -t cifs \\\\computer\\sharedirectory\\ /place/you/want/to/mount/it/
(If I recall correctly.)


NOTE: The character mentioned in your original post, "/", is NOT a backslash. It is a forward slash (the one on the "?" key, on a QWERTY keyboard). A forward slash, "/", is used in Linux to denote directories, and is not an escape character, although it does have special meaning (namely to denote directories), and thus can BE escaped using a backslash, "\". You do not have to put more than one forward slash to denote a directory or sub-directory. Thus, the following is how to denote a directory/sub-directory:

cd /home/me/stuff/morestuff/
The slash at the far right is optional.

A backslash, "\", on the other hand, IS an escape character, and also has special meaning (which means that it can be escaped by another backslash). The backslash is on the same key as the pipe, "|", and is usually next to or under the BACKSPACE key.

In the examples above, corrected, "\ " is a literal space, "\[\]" are literal brackets, and "\\" is a literal backslash. A literal forward slash is written, simply, "/". (Examples taken from post #3 by David the H.)

Last edited by DaneM; 10-24-2010 at 03:54 PM. Reason: Clarification on what a backslash is.


Thread Tools Search this Thread
Search this Thread:

Advanced Search

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
root directory siva balan Linux - Newbie 2 07-28-2010 07:18 AM
restoring desktop directory in /root (or any home directory) mel_lai Linux - Newbie 3 02-04-2008 03:13 AM
Root Directory fosiul Linux - Server 5 06-20-2007 02:41 AM
accidentally rm -fr in root (/) directory Under Fire Linux - Newbie 2 11-15-2003 10:03 PM
looking up my root directory isaacais Linux - Newbie 3 12-19-2002 06:35 AM > Forums > Linux Forums > Linux - Newbie

All times are GMT -5. The time now is 12:18 PM.

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