Basic Linux commands for managing directories and files
Helpful Tips
Tab Completion: Press
Tab
to auto-complete commands and file names.Man Pages: Use
man [command]
to read the manual for a command (e.g.,man ls
).
Directory Commands
pwd
: Print the current working directory.
pwd
ls
: List directory contents.
ls
ls -l # Long listing format
ls -a # Include hidden files
ls -lh # Human-readable format
cd [directory]
: Change the current directory.
cd /path/to/directory
cd .. # Move up one directory
cd ~ # Change to home directory
cd - # Change to the previous directory
mkdir [directory]
: Create a new directory.
rmdir [directory]
: Remove an empty directory.
rm -r [directory]
: Remove a directory and its contents recursively.
File Commands
touch [file]
: Create an empty file or update the timestamp of an existing file.
cp [source] [destination]
: Copy files or directories.
mv [source] [destination]
: Move or rename files or directories.
rm [file]
: Remove files or directories.
cat [file]
: Concatenate and display file content.
more [file]
: View file content one screen at a time.
less [file]
: View file content with backward and forward navigation.
head [file]
: Display the first few lines of a file.
tail [file]
: Display the last few lines of a file.