LinuxQuestions.org
Help answer threads with 0 replies.
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 10-24-2010, 01: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 directory.how is it?

what "//" denote?

thanks in advance..
 
Old 10-24-2010, 01:55 AM   #2
honeybadger
Member
 
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, 02:07 AM   #3
David the H.
Bash Guru
 
Registered: Jun 2004
Location: Osaka, Japan
Distribution: Debian sid + kde 3.5 & 4.4
Posts: 6,823

Rep: Reputation: 1957Reputation: 1957Reputation: 1957Reputation: 1957Reputation: 1957Reputation: 1957Reputation: 1957Reputation: 1957Reputation: 1957Reputation: 1957Reputation: 1957
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, 02:18 AM   #4
RootAround
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, 08:15 AM   #5
onebuck
Moderator
 
Registered: Jan 2005
Location: Midwest USA, Central Illinois
Distribution: Slackware®
Posts: 12,541
Blog Entries: 23

Rep: Reputation: 1943Reputation: 1943Reputation: 1943Reputation: 1943Reputation: 1943Reputation: 1943Reputation: 1943Reputation: 1943Reputation: 1943Reputation: 1943Reputation: 1943
Hi,

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

if is use the command "cd //".

it changes to root directory.how is it?

what "//" denote?

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

Quote:
excerpt from 'man cd';
NAME
cd - Change working directory

SYNOPSIS
cd ?dirName?
____________________________________________________________________________________

DESCRIPTION
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.

EXAMPLES
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;

Quote:
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, 09:02 AM   #6
eSelix
Senior Member
 
Registered: Oct 2009
Location: Wroclaw, Poland
Distribution: Arch, Kubuntu
Posts: 1,252

Rep: Reputation: 313Reputation: 313Reputation: 313Reputation: 313
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, 04:40 PM   #7
DaneM
Member
 
Registered: Oct 2003
Location: Chico, CA, USA
Distribution: Linux Mint
Posts: 848

Rep: Reputation: 107Reputation: 107
Lightbulb

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:

Code:
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:

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

--Dane

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:

Code:
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 04:54 PM. Reason: Clarification on what a backslash is.
 
  


Reply


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


All times are GMT -5. The time now is 01:58 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
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration