Reference for sh, bash, dash, and ksh commands
ls - List directory contents
cd - Change directory
pwd - Print working directory
cp - Copy files/directories
mv - Move/rename files
rm - Remove files
cat - Concatenate and display files
less/more - View file contents page by page
head/tail - Show beginning/end of file
grep - Search text patterns
uname - System information
df - Disk space usage
du - Directory space usage
free - Memory usage
top/htop - Process monitoring
ps - Process status
VAR=value - Set variable
export - Make variable available to subprocesses
$0-$9 - Positional parameters
$# - Number of arguments
$*/$@ - All arguments
$? - Exit status of last command
$$ - Current process ID
> - Redirect output (overwrite)
>> - Redirect output (append)
<< /span> - Redirect input
| - Pipe output to another command
2> - Redirect stderr
&> - Redirect stdout and stderr (bash)
test/[ ] - Evaluate conditions
Common test operators:
case - Switch statement
for loop
while loop
until loop
Defining functions:
Example function:
[[ ]] - Enhanced test (bash/ksh)
$(()) - Arithmetic expansion
${var%pattern} - Remove suffix
${var#pattern} - Remove prefix
${var:-default} - Use default if unset