Shell Commands
Search Results
Shell Commands
Navigation
pwd
Print the current working directory.
pwd
ls
List files and directories in the current directory.
ls -lah
cd <directory>
Change to the specified directory.
cd /usr/local/bin
cd ..
Move up one directory level.
cd ..
cd -
Switch to the previous directory.
cd -
Directories
mkdir <directory>
Create a new directory.
mkdir project
rmdir <directory>
Remove an empty directory.
rmdir old_folder
rm -r <directory>
Remove a directory and its contents recursively.
rm -r build
mv <source> <destination>
Move or rename files/directories.
mv old_folder new_folder
du -sh <directory>
Show disk usage of a directory in human-readable format.
du -sh logs/
Files
touch <file>
Create an empty file or update its timestamp.
touch README.md
rm <file>
Remove a file.
rm temp.txt
cp <source> <destination>
Copy files or directories.
cp -r src/ backup/src/
cat <file>
Display the contents of a file.
cat notes.txt
head <file>
Show the first lines of a file.
head -n 10 logfile.log
tail <file>
Show the last lines of a file.
tail -f logfile.log
Search & Display
find <path> -name "<pattern>"
Search directories for files matching a pattern.
find . -name "*.log"
grep -R "<text>" <directory>
Recursively search files for a text pattern.
grep -R "TODO" src/
tree
Display directory structure as a tree.
tree -L 2
locate <filename>
Quickly find file paths by name (requires updated database).
locate config.yaml
which <command>
Show the full path of a command binary.
which python3
File Operations
nano <file>
Edit file in terminal text editor.
nano config.txt
chmod <mode> <file>
Change file permissions.
chmod 755 script.sh
chown <user>:<group> <file>
Change file ownership.
chown user:group file.txt
Archives
tar -czvf <archive.tar.gz> <folder>
Create compressed tar archive.
tar -czvf backup.tar.gz documents/
tar -xzvf <archive.tar.gz>
Extract compressed tar archive.
tar -xzvf backup.tar.gz
zip -r <archive.zip> <folder>
Create ZIP archive.
zip -r project.zip project/
unzip <archive.zip>
Extract ZIP archive.
unzip project.zip
Terminal Helpers
clear
Clear terminal screen.
clear
history
Show command history.
history | tail -10
Text Processing
grep "<text>" <file>
Search for text pattern in file.
grep "error" logfile.txt
wc -l <file>
Count lines in file.
wc -l data.txt
sort <file> | uniq
Sort file and remove duplicate lines.
sort names.txt | uniq
Processes
ps aux | grep <process>
Find running processes by name.
ps aux | grep nginx
top
Display running processes and system resources.
top
htop
Interactive process viewer (if installed).
htop