When using the following, I understand that I make a directory inside a directory:
mkdir /tmp/myname
but where is it located? How can I see its parent folder?
When using the following, I understand that I make a directory inside a directory:
mkdir /tmp/myname
but where is it located? How can I see its parent folder?
In unix filesystems your base directory is not disk like in windows (eg. c:\
), but "root" - /
. It is highest level, it contains different system directories, to see them you can do ls /
, this will print all files and folders in /
, the structure is something like this:
user@computer:~$ tree -L 1 /
/
├── bin -> usr/bin
├── boot
├── cdrom
├── dev
├── etc
├── home
├── lib -> usr/lib
├── lib32 -> usr/lib32
├── lib64 -> usr/lib64
├── libx32 -> usr/libx32
├── lost+found
├── media
├── mnt
├── opt
├── proc
├── root
├── run
├── sbin -> usr/sbin
├── snap
├── srv
├── swapfile
├── sys
├── tmp
├── usr
└── var
As you may see /
contains directory tmp
. By running mkdir /tmp/myname
you have created a directory inside /
tmp
and you could find it there. For example you could do ls /tmp
to see content of tmp.
To learn more about unix filesystems you can read about it in the internet.
To learn more about each individual command you can run man mkdir
or google it.
PS: /tmp
is a special directory for temporary files, it is automatically emptied on reboot, so your folder might already be removed.
ls -Al /tmp
? . – Arkadiusz Drabczyk Dec 20 '20 at 12:32myname
inside the directory/tmp
. Therefore,/tmp
is the parent directory to your new directory. If you want to list the contents of/tmp
, then usels /tmp
. If you have the pathname/tmp/myname
in a variable,$pathname
, thendirname "$pathname"
would return/tmp
(as woulddirname /tmp/myname
). Please clarify your question. – Kusalananda Dec 20 '20 at 12:43/tmp/myname
. The parent directory is/tmp
. – ctrl-alt-delor Dec 20 '20 at 16:22