![]() |
VOOZH | about |
Working with files and directories is a fundamental skill in any command-line environment. It helps you efficiently navigate projects, manage source code, and maintain systems across different platforms.
Navigating between directories allows you to move through the file system hierarchy. This is done using the cd (change directory) command.
This command changes the current working directory to /home/user/Documents.
cd /home/user/DocumentsThis moves you one level up to the parent directory.
cd ..Creating files and folders helps organize your work efficiently.
The touch command is used to create an empty file.
touch myfile.txtThis creates a file named myfile.txt in the current directory.
Directories are created using the mkdir (make directory) command.
mkdir my_directoryThis creates a new directory called my_directory.
To see files and directories inside a folder, use the ls command.
Lists files and directories in the current directory.
lsDisplays file permissions, ownership, size, and modification date.
ls -lShows hidden files (files starting with .).
ls -aDisplays detailed information for all files, including hidden ones.
ls -laBefore modifying or removing files in a Git repository, it’s useful to know what Git is tracking.
git ls-filesThis command lists all files currently tracked by Git in the repository.
Git provides commands to safely remove files and directories while keeping version history consistent.
git rm filenameThis removes the file from the working directory and stages the removal for the next commit.
git rm -r directorynameThe -r (recursive) option removes the directory along with all its contents.
git rm --cached filenameThis removes the file from Git tracking but keeps it in your local file system.
Git Bash includes standard Unix utilities like cp and mv, making it useful beyond Git operations.
cp -r /path/to/source_directory /path/to/destination_directoryIf the destination directory exists, the source directory is copied inside it as a subdirectory.
Directories can be moved or renamed using the mv command.
mv /path/to/source_directory /path/to/destination_directory