The file system
لم يُترجم بعد؛ يُعرض باللغة الإنجليزية
Linux keeps every file in one tree of folders that starts at the root, written /. A path spells out the folders from the root down to a file, such as /home/sam/notes.txt. Your shell always stands in one folder, the working directory: pwd prints it, ls lists it, and cd moves it. Follow a you-are-here pin as cd uses a relative path, .., an absolute path and ~.
5 أسئلة سريعة
اختر إجابة لتعرف السبب. تُحفَظ نتيجتك مع تقدّمك.
01Where does the Linux file tree start?
Every file and folder hangs off one root folder, written as a single slash: /. Even a USB stick is attached (mounted) somewhere inside that one tree.
02You are in /home/sam and type cd projects. Where are you now?
projects does not start with /, so it is a relative path: it is looked up inside the folder you are in, /home/sam.
03You are in /home/sam/projects. What does cd .. do?
.. always means the parent folder, one level up. Going home is cd ~ (or cd on its own). In the root itself, .. is the root.
04Which of these is an absolute path?
An absolute path starts with /, so it is read from the root and means the same folder wherever you are. The others are relative.
05Which command prints the folder you are in right now?
pwd means print working directory. ls lists what is inside a folder, and cd changes the folder you are in.
المسرد
- Directory
- Another word for a folder: a place in the file system that holds files and other folders.
- Root
- The folder at the top of the tree, written /. Every other file and folder is somewhere inside it.
- Path
- The name of a file or folder spelled out folder by folder, with / between the names, such as /home/sam/notes.txt.
- Absolute path
- A path that starts with /. It is read from the root, so it means the same thing from any folder.
- Relative path
- A path that does not start with /. It is read from the folder you are in.
- Working directory
- The folder your shell is standing in right now. pwd prints it; cd changes it.
- Home folder
- Your own folder, usually /home/<your user name>. The shell writes it as ~ for short.
- Parent folder
- The folder one level up. Every folder has the special name .. for it, and . for itself.
الملاحظات والمصادر
- The user sam and the files notes.txt and projects are an example; your home folder is named after your own user name.
- On Ubuntu, Debian and Fedora the old folder /bin is now a link to /usr/bin, so ls can be reached as /bin/ls or /usr/bin/ls: the same file.
- cd is built into the shell rather than being a separate program, because it must change the shell's own working directory (with the chdir system call).
- ls sorts names in the order of your language settings (the LC_COLLATE locale setting); for plain lower-case names like these that is A to Z.
- ls hides names that start with a dot, such as .bashrc; ls -a shows them all, including . and .. themselves.
- Names are case-sensitive: Notes.txt and notes.txt are two different files.
- Linux man-pages: hier(7), description of the file system hierarchy
- Linux man-pages: path_resolution(7), how a pathname is found
- Linux man-pages: mount(8), one big tree rooted at /
- Linux man-pages: pwd(1)
- Linux man-pages: ls(1)
- Linux man-pages: chdir(2), changing the working directory
- Linux man-pages: getcwd(3), getting the working directory
- GNU Bash Reference Manual: Bourne Shell Builtins (cd)
- GNU Bash Reference Manual: Tilde Expansion
- Linux Foundation: Filesystem Hierarchy Standard 3.0
- Fedora Project: UsrMove (/bin moved into /usr/bin)
- The Linux kernel documentation: Filesystems in the Linux kernel
اختبار يتاح بعد الخطوة الأخيرة.