Essential Unix/Linux commands for file management and system operations
Print working directory
pwd
List directory contents
ls -la
Change directory
cd /path/to/directory
Create directory
mkdir new-folder
Remove empty directory
rmdir empty-folder
Copy files/directories
cp source.txt destination.txt
Move/rename files
mv old-name.txt new-name.txt
Remove files
rm -rf directory/
Create empty file
touch new-file.txt
Display file contents
cat filename.txt
View file page by page
less large-file.txt
Show first lines
head -10 filename.txt
Show last lines
tail -f logfile.log
Search text patterns
grep "search-term" file.txt
Find files by criteria
find . -name "*.txt"
Show system processes
top
List processes
ps aux
Show disk usage
df -h
Show directory size
du -sh directory/
Show memory usage
free -h
Test network connectivity
ping google.com
Transfer data from URLs
curl https://api.example.com
Download files
wget https://example.com/file.zip
Secure shell connection
ssh user@hostname
Secure copy files
scp file.txt user@host:/path/
Change file permissions
chmod 755 script.sh
Change file owner
chown user:group file.txt
Set default permissions
umask 022
Find files by name and content
# Find files by name
find . -name "*.txt"
# Find files by content
grep -r "search-term" .
# Find and replace in files
find . -name "*.txt" -exec sed -i 's/old/new/g' {} \;
Manage running processes
# Find process by name
ps aux | grep process-name
# Kill process by PID
kill -9 12345
# Kill process by name
pkill process-name
# Background/foreground
command &
fg
bg
Compress and extract files
# Create tar archive
tar -czf archive.tar.gz directory/
# Extract tar archive
tar -xzf archive.tar.gz
# Create zip archive
zip -r archive.zip directory/
# Extract zip archive
unzip archive.zip
Use man
for command documentation
Be careful with rm -rf
- it deletes permanently
Use Ctrl+C
to interrupt running commands
Use Tab
for command completion
Use history
to see previous commands