Filesystem
- Filesystem structure
- Listing files
- Directory
- Creating files
- Reading files
- Editing files
- Moving files
Contents
On Unix systems everything is a file.
Filesystem structure #
A path on a filesystem is noted as a string starting with a /
Example:
/home/user/Documents/mydocument.odt
~ indicates the home directory of the current user (also in $HOME) . the current directory .. the parent directory
Listing files #
ls [directory]: lists files inside a directory, often you use ls without any arguments to show the files in the current directory
-lshows list with permissions are file sizes.-ashows 'hidden' files often also called dotfiles which are files starting with a dot '.'-hshows file sizes in a humman readable format instead of the byte count
Tip: you can combine these flags like this:
ls -lah
Common directories #
ls /
/filesystem root/binprogram binaries/devdevices/etcconfiguration files/homehome directories of normal users/mntmountpoints/optoptional software/procvirtual filesystem to access kernel data/roothome directory of the root user/runruntime data, often for daemons (lost after reboot)/srvservices data, often for web services/sysvirtual filesystem for system devices/tmptemorary data (lost after reboot)/usrUnix System Resources, files that generally not change/varvariable data, files that frequently change like log files
Directory #
cd Change Directory
pwd shows current directory
Creating files #
touch [filename] creates an empty file
Reading files #
cat head tail
Editing files #
You can edit files on the terminal using a terminal text editor like Vi(m) or Nano. Often vi,vim and/or nano are installed by default on many linux distros.
Moving files #
cpfor copymvfor move/renamermfor remove