-1

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?

  • 1
  • 3
    It's a bit unclear what you actually mean and what your issue is. With your command, you create a directory called myname inside the directory /tmp. Therefore, /tmp is the parent directory to your new directory. If you want to list the contents of /tmp, then use ls /tmp. If you have the pathname /tmp/myname in a variable, $pathname, then dirname "$pathname" would return /tmp (as would dirname /tmp/myname). Please clarify your question. – Kusalananda Dec 20 '20 at 12:43
  • 1
    it is located at /tmp/myname. The parent directory is /tmp. – ctrl-alt-delor Dec 20 '20 at 16:22
  • 1
    You need to start reading. You can't expect others to do your homework for you. Then start practising. Install A Unix (such as debian Gnu/Linux) on your own machine (best to use a virtual machine, when you first start), and use it for everything. It will seem difficult at first, but seen you will be glad. – ctrl-alt-delor Dec 20 '20 at 16:25

1 Answers1

0

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.