cd - Dagens terminalkommando  

Postat av rancor under ,

cd som står för Change Directory - byt katalog är det kommando man använder för att navigera sig i sitt filträd. För att få hjälp om cd skriver man "help cd" eftersom cd inte är ett program utan en funktion i bash som är Ubuntus standardskal

rancor@crm:~$ help cd
cd: 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 is the same as
the current directory, i.e. `.'. If DIR begins with a slash (/),
then CDPATH is not used. If the directory is not found, and the
shell option `cdable_vars' is set, then try the word as a variable
name. If that variable has a value, then cd to the value of that
variable. The -P option says to use the physical directory structure
instead of following symbolic links; the -L option forces symbolic links
to be followed.
När man startar en ny terminalsession så hamnar man som standard i sin hemmakatalog vilket är /home/"användarnamn".
rancor@crm:~$ pwd
/home/rancor
För att gå upp en nivå till /home skriver man "cd .."
rancor@crm:~$ cd ..
rancor@crm:/home$ pwd
/home
Som ni även ser använder jag kommandot pwd för att verifiera att jag står i rätt katalog

Om man vill byta till en katalog man vet sökvägen till skriver man cd "sökväg" och enklast är ange sökvägen från botten av katalogstrukturen. Botten, här efter root-katalogen anges som / och det är under denna alla samtliga kataloger och filer finns på hela systemet. För att då förflytta sig till /var/log skriver man följande "cd /var/log"
rancor@crm:/home$ cd /var/log
rancor@crm:/var/log$ pwd
/var/log
Det finns en smidig genväg för att förflytta sig hem igen till sin hemmakatalog och för att göra det skriver man endast "cd"
rancor@crm:/var/log$ cd
rancor@crm:~$ pwd
/home/rancor
// rancor

0 kommentarer

Skicka en kommentar