ls
List directory contents.
ls -l
: Long listing formatls -a
: Show hidden filesls -lh
: Long listing with human-readable file sizes
Example: ls -l /home/user
cd
Change directory.
cd ..
: Move up one directorycd ~
: Go to the home directorycd /path/to/directory
: Change to a specific directory
Example: cd /var/log
pwd
Print name of current/working directory.
- This command takes no arguments.
Example: pwd
mkdir
Make directories.
mkdir new_directory
: Create a new directorymkdir -p parent/child
: Create parent directory if it doesn't exist
Example: mkdir project_files
rm
Remove files or directories.
rm file.txt
: Remove a filerm -r directory
: Remove a directory and its contents (recursive)rm -f file.txt
: Force removal without prompting
Example: rm old_report.doc
cp
Copy files and directories.
cp source.txt destination.txt
: Copy filecp -r source_dir destination_dir
: Copy directory
Example: cp document.pdf /backup/
mv
Move (rename) files and directories.
mv old_name.txt new_name.txt
: Rename filemv file.txt /path/to/destination/
: Move file to another directory
Example: mv draft.txt final_version.txt
cat
Concatenate files and print on the standard output.
cat file.txt
: Display file contentcat file1.txt file2.txt > combined.txt
: Combine files
Example: cat README.md
grep
Print lines matching a pattern.
grep "pattern" file.txt
: Search for pattern in a filegrep -i "pattern" file.txt
: Case-insensitive searchgrep -r "pattern" directory/
: Recursive search
Example: grep "error" /var/log/syslog
man
An interface to the on-line reference manuals.
man command_name
: Display manual page for a command
Example: man ls