Opentopia Directory Encyclopedia Tools

Chdir

Encyclopedia : C : CH : CHD : Chdir



 

The correct title of this } is }}}. The initial letter is capitalized due to [Naming conventions #Lower case first lettertechnical restrictions].
cd, sometimes also available as chdir (change directory), is a command line command used to change the current working directory in the Unix and DOS operating systems. It is also available for use in Unix shell scripts or DOS batch files. cd is frequently included built into certain shells such as the Bourne shell, tcsh, bash (where it calls the chdir() POSIX C function) and in DOS's COMMAND.COM.

A directory is a logical section of a filesystem used to hold files. Directories may also contain other directories. The cd command can be used to change into a subdirectory, move back into the parent directory, move all the way back to the root (/ in UNIX, \ in DOS) or move to any given directory.

Consider the following subsection of a Unix filesystem, which shows a user's home directory (represented as "~") with a file ("text.txt") and three subdirectories.

A user's view of the file system in Unix-like systems begins with the home directory (often abbreviated to ~). From there, the tree can spread into more subdirectories and/or files.

If the user's current working directory is the home directory ("~"), then entering the command "ls" followed by "cd games" might produce the following transcript:

me@host:~$ ls
workreports games encyclopedia text.txt
me@host:~$ cd games
me@host:games$
The user is now in the "games" directory.

A similar session in DOS (though the concept of a "home directory" may not apply, depending on the specific version) would look like this:

C:\> dir
workreports               Wed Oct 9th   9:01
games                     Tue Oct 8th  14:32
encyclopedia              Mon Oct 1st  10:05
text        txt           1903 Thu Oct10th  12:43
C:\> cd games
C:\games>
Note that cd has different effects on different operating systems if given with no arguments. For example, if executed without arguments in DOS, the current working directory is printed. If executed without arguments in Unix, then the user is returned to the home directory. The effect of executing the cd command within a script or batch file also varies. In DOS, the caller's current directory can be directly altered by the batch file's use of this command. In Unix the caller's current directory is not altered by the script's invocation of the cd command. This is because in Unix, the script is usually executed within a subshell.


CHDIR() is also a Visual Basic function which changes the working directory.

See also

Unix command line programs[ view][ talk][ edit] )
File and file system management: cat | chdir/cd | chmod | chown | chgrp | cp | du | df | fdupes | file | fsck | ln | ls | lsof | mkdir | more | mount | mv | pwd | rcp | rm | rmdir | split | touch | tree
Process management: anacron | at | chroot | cron/crontab | kill | nice | ps | sleep | time | timex | top | renice | wait
User Management/Environment: env | finger | id | locale | mesg | passwd | su | sudo | uname | uptime | w | who | write
Text processing: awk | cut | diff | ex | head | iconv | join | less | more | nkf | paste | sed | sort | tail | tr | uniq | wc | xargs
Shell programming: echo | expr | unset Printing: lp
Communications:
inetd | netstat | ping | rlogin | traceroute
Searching:
egrep | fgrep | find | grep | strings
Miscellaneous:
banner | bc | cal | man | uname | wall | yes

 


From Wikipedia, the Free Encyclopedia. Original article here. Support Wikipedia by contributing or donating.
All text is available under the terms of the GNU Free Documentation License See Wikipedia Copyrights for details.


Search Titles
0123456789
ABCDEFGHIJ
KLMNOPQRST
UVWXYZ?

E-mail this article to:

Personal Message: