In Bash, the filesystem refers to the organization and structure of files and directories on a computer. Bash provides a set of commands and utilities to interact with the filesystem and perform various operations such as navigating directories, creating and deleting files, and modifying permissions. Here are some common commands and concepts related to the Bash filesystem:
- Current Directory: The current directory refers to the directory you are currently in. It is represented by a dot (
.). You can use thepwdcommand to print the current directory. - Directory Navigation: You can navigate through directories using the
cdcommand. For example,cd /path/to/directorymoves to a specific directory,cd ..moves to the parent directory, andcd ~moves to the home directory. - Listing Files: The
lscommand lists the files and directories in the current directory. Adding options such as-lor-aprovides additional details or includes hidden files, respectively. - Creating Directories: The
mkdircommand is used to create directories. For example,mkdir new_dircreates a directory named “new_dir” in the current directory. - Creating Files: You can create empty files using the
touchcommand. For example,touch new_file.txtcreates an empty file named “new_file.txt” in the current directory. - Copying Files: The
cpcommand is used to copy files. For example,cp source_file destination_filecopies thesource_fileto thedestination_file. - Moving/Renaming Files: The
mvcommand is used to move or rename files. For example,mv old_file new_filerenamesold_filetonew_file. - Removing Files and Directories: The
rmcommand is used to remove files, and thermdircommand is used to remove empty directories. Use them with caution, as the deletion is permanent. To remove directories and their contents recursively, userm -rorrm -rffor forceful removal. - File Permissions: The
chmodcommand is used to modify file permissions, allowing you to control who can read, write, or execute a file. Thechowncommand changes the ownership of a file or directory. - File Information: The
statcommand displays detailed information about a file, such as size, permissions, and timestamps.
These are just a few examples of the many commands and concepts related to the Bash filesystem. Bash provides a rich set of tools to interact with files, directories, and the overall filesystem structure, enabling you to perform various tasks and manage your files effectively.