The basic terminal commands for navigating and manipulating directories and files are as follows:
The cat (short for concatenate) command is used to display the contents of a file in the terminal. It can also be used to concatenate multiple files into one. By default, it outputs the contents of the file(s) to the terminal.
# Display the contents of a file
cat filename.txt
# Display the contents of multiple files
cat file1.txt file2.txt
# Concatenate files into a new file
cat file1.txt file2.txt > combined.txtUse the pwd command to display the current directory:
pwdUse the ls command to list the contents of the current directory:
# Simple list
ls
# Detailed list with more information
ls -l
# List including hidden files
ls -aThe cd command is used to change directories:
# Go to a specific directory
cd directoryPath
# Go to the previous directory
cd -
# Go up one directory level
cd ..To create a new directory:
mkdir newDirectoryNameTo delete an empty directory:
rmdir directoryNameTo create a new empty file:
touch filename.txtTo delete a file:
rm filename.txtTo rename a file or move it to a new location:
# Rename a file
mv oldFileName.txt newFileName.txt
# Move a file to a different directory
mv sourceDirectory/filename.txt destinationDirectory/filename.txtHappy Scripting!