Gebruikershulpmiddelen

Site-hulpmiddelen


linux:commandos:pathnames_en.html

Verschillen

Dit geeft de verschillen weer tussen de geselecteerde revisie en de huidige revisie van de pagina.

Link naar deze vergelijking

linux:commandos:pathnames_en.html [2018/12/30 17:17] (huidige)
Regel 1: Regel 1:
 +<​HTML>​
 +
 +<​H1>​UNIX PATHNAMES</​H1>​
 +<​H2>​1. In Unix, there are 2 types of pathnames:</​H2>​
 +<div class="​level2">​
 +
 +<TABLE BORDER="​0"​ CELLPADDING="​5">​
 +<TR>
 +   <​TD></​TD><​TD>​afile</​TD>​
 +   <​TD></​TD><​TD>​adir</​TD>​
 +   <​TD></​TD><​TD><​B>​Relative</​B>​ pathnames</​TD>​
 +</​TR><​TR>​
 +   <​TD></​TD><​TD><​B>​.</​B>/​afile</​TD>​
 +   <​TD></​TD><​TD><​B>​.</​B>/​adir</​TD>​
 +   <​TD></​TD><​TD><​B>​Relative</​B>​ pathnames</​TD>​
 +</​TR><​TR>​
 +   <​TD></​TD><​TD>/​afile</​TD>​
 +   <​TD></​TD><​TD>/​adir</​TD>​
 +   <​TD></​TD><​TD><​B>​Absolute</​B>​ pathnames</​TD>​
 +</TR>
 +</​TABLE>​
 +<BR>
 +A <​B>​relative</​B>​ pathname is relative to the <​B>​current</​B>​ directory.<​BR>​
 +Example:
 +
 +<TABLE BORDER="​0"​ CELLPADDING="​5">​
 +<TR>
 +   <​TD></​TD><​TD>​$ pwd<​BR>/​home/​user1</​TD>​
 +   <​TD></​TD><​TD VALIGN="​top">#​ Which is the current directory?</​TD>​
 +</​TR><​TR>​
 +   <​TD></​TD><​TD VALIGN="​top">​$ cd adir</​TD>​
 +   <​TD></​TD><​TD>#​ Go to directory &​quot;​adir&​quot;​ relative<​BR>​
 +# to the current directory.</​TD>​
 +</​TR><​TR>​
 +   <​TD></​TD><​TD>​$ pwd<​BR>/​home/​user1/​adir</​TD>​
 +   <​TD></​TD><​TD></​TD>​
 +</TR>
 +</​TABLE>​
 +
 +<BR>
 +The pathname &​quot;<​B>​.</​B>/​afile&​quot;​ is also a relative one. See: part 3.<​BR>​
 +
 +<BR>
 +An <​B>​absolute</​B>​ pathname starts with &​quot;<​B>/</​B>&​quot;​.<​BR>​
 +An absolute pathname always refers to the top (/) of the
 +Unix directory hierarchy.<​BR>​
 +There is just <​B>​1</​B>​ &​quot;/​afile&​quot;​ in the entire system.<​BR>​
 +Example:
 +
 +<TABLE BORDER="​0"​ CELLPADDING="​5">​
 +<TR>
 +   <​TD></​TD><​TD>​$ pwd<​BR>/​home/​user1</​TD>​
 +   <​TD></​TD><​TD VALIGN="​top">#​ Which is the current directory?</​TD>​
 +</​TR><​TR>​
 +   <​TD></​TD><​TD>​$ cd /​adir</​TD>​
 +   <​TD></​TD><​TD>#​ Go to directory &​quot;/​adir&​quot;​.</​TD>​
 +</​TR><​TR>​
 +   <​TD></​TD><​TD>​$ pwd<​BR>/​adir</​TD>​
 +   <​TD></​TD><​TD></​TD>​
 +</TR>
 +</​TABLE>​
 +</​div>​
 +
 +<​H2>​2. Some special directories:</​H2>​
 +<div class="​level2">​
 +
 +<TABLE BORDER="​0"​ CELLPADDING="​5">​
 +<TR>
 +   <​TD></​TD><​TD><​B>​.</​B></​TD>​
 +   <​TD></​TD><​TD>​the current directory</​TD>​
 +</​TR><​TR>​
 +   <​TD></​TD><​TD><​B>​..</​B></​TD>​
 +   <​TD></​TD><​TD>​1 directory higher up in the hierarchy</​TD>​
 +</TR>
 +</​TABLE>​
 +<BR>
 +At first sight, the directory &​quot;<​B>​.</​B>&​quot;​ might appear to be of no use at all. Quite to the contrary!<​BR>​
 +Example:
 +
 +<TABLE BORDER="​0"​ CELLPADDING="​5">​
 +<TR>
 +   <​TD></​TD>​
 +   <​TD VALIGN="​top">​$ cp</​TD>​
 +   <​TD VALIGN="​top">/​tmp/​afile</​TD>​
 +   <​TD VALIGN="​top"><​B>​.</​B></​TD>​
 +   <​TD></​TD>​
 +   <​TD>#​ Copy &​quot;/​tmp/​afile&​quot;​ to the<​BR>​
 +# current directory.</​TD>​
 +</TR>
 +</​TABLE>​
 +<BR>
 +In MS-DOS you could leave out the &​quot;<​B>​.</​B>&​quot;​. Not so in Unix!
 +</​div>​
 +
 +<​H2>​3. Why &​quot;​./​acmd&​quot;?</​H2>​
 +<div class="​level2">​
 +
 +De pathnames &​quot;​afile&​quot;​ and &​quot;<​B>​.</​B>/​afile&​quot;​ are both <​B>​relative</​B>​ ones.<​BR>​
 +When used as an <​B>​argument</​B>​ after a command ​ word, there is no difference between the two variants.<​BR>​
 +Example:
 +
 +<TABLE BORDER="​0"​ CELLPADDING="​5">​
 +<TR>
 +   <​TD></​TD><​TD VALIGN="​top">​$ cd</​TD>​
 +   <​TD VALIGN="​top">​adir</​TD>​
 +   <​TD>#​ Go to directory &​quot;​adir&​quot;​ relative<​BR>​
 +# to the current directory.</​TD>​
 +</​TR><​TR>​
 +   <​TD></​TD><​TD>​$ cd</​TD>​
 +   <​TD><​B>​.</​B>/​adir</​TD>​
 +   <​TD>#​ Will do exactly the same.</​TD>​
 +</TR>
 +</​TABLE>​
 +<BR>
 +However, when used as a <​B>​command word</​B>,​ &​quot;​acmd&​quot;​ and &​quot;<​B>​.</​B>/​acmd&​quot;​ are not the same at all!
 +
 +<TABLE BORDER="​0"​ CELLPADDING="​5">​
 +<TR>
 +   <​TD></​TD>​
 +   <​TD>​$ acmd</​TD>​
 +   <​TD></​TD><​TD>#​ Search for program &​quot;​acmd&​quot;​ via $PATH.</​TD>​
 +</​TR><​TR>​
 +   <​TD></​TD>​
 +   <​TD VALIGN="​top">​$ <​B>​.</​B>/​acmd</​TD>​
 +   <​TD></​TD><​TD>#​ Execute program &​quot;​acmd&​quot;<​BR>​
 +# in the current directory.</​TD> ​
 +</TR>
 +</​TABLE>​
 +<BR>
 +
 +Note: In Unix (unlike MS-DOS) the current directory isn't part of the search path by default.<​BR>​
 +The current directory will only be part of the search path if it is explicitly mentioned in the PATH variable.<​BR>​
 +Like this, for example:
 +
 +<TABLE BORDER="​0"​ CELLPADDING="​5">​
 +<TR>
 +   <​TD></​TD><​TD>​$ echo $PATH<​BR>/​usr/​local/​bin:/​usr/​bin:/​bin:/​usr/​bin/​X11:/​usr/​games</​TD>​
 +<TD VALIGN="​top">#​ Check: which is the current search path?</​TD>​
 +</TR>
 +   <​TD></​TD><​TD>​$ export PATH=$PATH:<​B>​.</​B></​TD>​
 +   <​TD>#​ Modify the PATH variable.</​TD>​
 +</TR>
 +   <​TD></​TD><​TD>​$ echo $PATH<​BR>/​usr/​local/​bin:/​usr/​bin:/​bin:/​usr/​bin/​X11:/​usr/​games:<​B>​.</​B></​TD>​
 +   <​TD VALIGN="​top">#​ Check: which is the current search path?</​TD>​
 +</TR>
 +</​TABLE>​
 +<BR>
 +
 +(You may choose to incorporate the line <​B>​export PATH=$PATH:​.</​B>​ in &​quot;<​B>​.</​B>​profile&​quot;​ or &​quot;<​B>​.</​B>​bash_profile&​quot;​.)
 +<BR>
 +<BR>
 +
 +<​B>​CAUTION:</​B>​
 +<​B>​Never</​B>​ add &​quot;<​B>​.</​B>&​quot;​ to the &​quot;<​B>​root</​B>&​quot;​ user's PATH variable!<​BR>​
 +This will highly increase chances of inadvertently executing user-programs<​BR>​
 +whilst performing system maintenance tasks (Trojan horses).
 +</​div>​
 +
 +<br />
 +<br />
 +<hr />
 +<p>
 +<FONT SIZE="​-3">​
 +Copyright (C) 2003 Integrated Services; tux4u.nl<​BR>​
 +Author: Ing.J.M.Waldorp<​BR>​
 +pathnames_en.html 20030403
 +</​FONT>​
 +</p>
 +
 +</​HTML>​
  
linux/commandos/pathnames_en.html.txt ยท Laatst gewijzigd: 2018/12/30 17:17 (Externe bewerking)