Syntax:
ls [OPTIONS] [FILES...]
Options:
Option | Description |
---|---|
-l |
Long listing format |
-a |
Show hidden files |
-h |
Human-readable file sizes |
-R |
Recursively list directories |
-t |
Sort by modification time |
-r |
Reverse sort order |
Examples:
ls
ls -l
ls -la
ls -lh
ls -ltr
Syntax:
cd [directory]
Examples:
cd # Home directory
cd /etc # Go to /etc
cd .. # One level up
cd - # Switch to previous dir
Syntax:
pwd
Description: Prints the full path of the current directory.
Example:
pwd
# Output: /home/user/Desktop
Syntax:
echo [OPTIONS] [STRING...]
Options:
Option | Description |
---|---|
-n |
Do not print newline |
-e |
Enable backslash escapes |
-E |
Disable escape interpretation (default) |
Examples:
echo "Hello"
echo -n "Same line"
echo -e "Line1\nLine2\tTabbed"
Syntax:
cat [OPTIONS] [FILES...]
Options:
Option | Description |
---|---|
-n |
Number all lines |
-b |
Number only non-blank lines |
-E |
Show $ at end |
-T |
Show tabs as ^I |
Examples:
cat file.txt
cat -n file.txt
cat file1.txt file2.txt > combined.txt
Syntax:
cp [OPTIONS] SOURCE DEST
Options:
Option | Description |
---|---|
-r |
Copy directories recursively |
-u |
Only copy if newer |
-i |
Prompt before overwrite |
-v |
Verbose output |
Examples:
cp file.txt backup.txt
cp -r dir1/ dir2/
cp -uv config.sh /etc/
Syntax:
mv [OPTIONS] SOURCE DEST
Options:
Option | Description |
---|---|
-i |
Prompt before overwrite |
-u |
Move only if newer |
-v |
Verbose output |
Examples:
mv old.txt new.txt
mv file.txt ~/Downloads/
mv -iv script.sh /usr/local/bin/
Syntax:
rm [OPTIONS] FILE...
Options:
Option | Description |
---|---|
-r |
Recursively delete dirs |
-f |
Force delete (no prompt) |
-i |
Ask before delete |
-v |
Show deleted files |
Examples:
rm file.txt
rm -rf /tmp/test/
rm -iv backup.zip
β οΈ
rm -rf
can delete everything β use with extreme caution!π touch β Create or Update File Timestamp
Syntax:
touch [OPTIONS] FILE...
Options:
Option | Description |
---|---|
-c |
Donβt create if missing |
-a |
Change access time |
-m |
Change modification time |
-t |
Use custom time: [[CC]YY]MMDDhhmm[.ss] |
Examples:
touch newfile.txt
touch -c file.txt
touch -t 202507041200.00 data.log
Syntax:
mkdir [OPTIONS] DIRECTORY...
Options:
Option | Description |
---|---|
-p |
Create parent directories |
-v |
Show created directories |
Examples:
mkdir mydir
mkdir -p parent/child/grandchild
mkdir -vp logs/errors/
Syntax:
man [COMMAND]
Description:
Shows the manual page for a command.
Examples:
man ls
man bash
Press
q
to exit.π§© alias β Create Command Shortcuts
Syntax:
alias name='command'
Examples:
alias ll='ls -l'
alias gs='git status'
alias rm='rm -i'
alias update='sudo apt update && sudo apt upgrade'
Remove alias:
unalias ll
π‘ To make the alias permanent across terminal sessions, add it to your ~/.bashrc
file:
echo "alias ll='ls -l'" >> ~/.bashrc
source ~/.bashrc # Apply changes immediately