$ tree -L 1 /
/ ├── bin # Essential user commands (cp, rm, ls, cat, ...) - available to all users ├── boot # Bootable Linux kernel, boot loader config files (grub.cfg), initial ramdisk images ├── cdrom # Traditional mount point for CD-ROM drives (legacy, now typically under /media) ├── dev # Device files representing access points to hardware (/dev/sda1, /dev/tty, /dev/null, ...) ├── etc # System-wide configuration files (passwd, fstab, hosts, crontab, ...) ├── home # Individual user home directories (/home/username) - where users store personal files ├── lib # Essential shared library files needed by programs in /bin and /sbin ├── lib64 # 64-bit shared library files for 64-bit programs ├── lost+found # Recovery directory for orphaned files found during filesystem check ├── media # Mount point for removable media devices (USB drives, CD-ROMs) - automatically mounted ├── mnt # Mount point for temporarily mounting filesystems, network drives, disk partitions ├── opt # Optional software packages and third-party applications ├── proc # Virtual filesystem containing system and process information (/proc/cpuinfo, /proc/meminfo, ...) ├── root # Root user's home directory - only accessible by root user (not regular users) ├── run # Runtime data for applications and system processes (PID files, sockets, ...) ├── sbin # System administrative commands (mount, fdisk, ...) - typically for root user ├── sys # Virtual filesystem for kernel and hardware information ├── tmp # Temporary files created by applications - typically cleared on reboot ├── usr # User programs, libraries, documentation, and shared files (secondary hierarchy) └── var # Variable data files (logs, databases, web content, mail spools, ...)
Absolute Path: /home/user/documents/file.txt (starts from root /) Relative Path: documents/file.txt (relative to current directory) Home Path: ~/documents/file.txt (starts from user's home) Parent Path: ../documents/file.txt (relative to parent directory) Current Path: ./documents/file.txt (relative to current directory) Variable Path: $HOME/documents/file.txt (using environment variable)
#|+ ${user.home} # |+ folder # |+ folder1 # |+ folder2 $ mkdir ~/folder ~/folder/folder1 ~/folder/folder2
$ cd ${user.home}/folder/ $ ls -1 ./ folder1 folder2
$ cd ${user.home}/folder/folder1/ $ ls -1 ../ folder1 folder2
$ ls -1 ~/folder folder1 folder2
$ ls -1 ~mtitek/folder folder1 folder2
$ echo $HOME /home/username $ ls $HOME/Documents # equivalent to: ls ~/Documents
$ echo $PWD /home/username/projects $ ls $PWD/src # equivalent to: ls ./src
$ cd /home/username/projects $ cd /tmp $ echo $OLDPWD /home/username/projects $ cd $OLDPWD # returns to previous directory
$ echo $PATH /usr/local/bin:/usr/bin:/bin:/usr/local/games:/usr/games
$ cd ${user.home}/folder/ $ ls fold* # all files starting with "test" folder1: folder2: $ ls *.txt # all files ending with .txt $ ls *fold* # all files containing "fold" anywhere in name
$ cd ${user.home}/folder/ $ ls f??der? folder1: folder2:
$ cd ${user.home}/folder/ $ ls f[a-z]*[0-9] folder1: folder2: $ ls file[123].txt # matches file1.txt, file2.txt, file3.txt $ ls [A-Z]+.doc # matches files starting with uppercase letters
$ ls file[!0-9].txt # matches files like filea.txt, fileb.txt (not file1.txt) $ ls [!.]*.txt # matches files not starting with a dot $ ls *[!~] # matches files not ending with ~
$ find . -name "*.txt" # finds all .txt files recursively $ find . -name "**/config.xml" # finds config.xml in any subdirectory
$ touch file{1,2,3}.txt $ ls file*.txt file1.txt file2.txt file3.txt $ mkdir -p src/{main,test}/{java,resources} $ tree src/ src/ ├── main │ ├── java │ └── resources └── test ├── java └── resources