Unix/Linux Terminal

New

Essential Unix/Linux commands for file management and system operations

File Navigation

pwd

Print working directory

pwd

ls

List directory contents

ls -la

cd

Change directory

cd /path/to/directory

mkdir

Create directory

mkdir new-folder

rmdir

Remove empty directory

rmdir empty-folder

File Operations

cp

Copy files/directories

cp source.txt destination.txt

mv

Move/rename files

mv old-name.txt new-name.txt

rm

Remove files

rm -rf directory/

touch

Create empty file

touch new-file.txt

cat

Display file contents

cat filename.txt

File Viewing

less

View file page by page

less large-file.txt

head

Show first lines

head -10 filename.txt

tail

Show last lines

tail -f logfile.log

grep

Search text patterns

grep "search-term" file.txt

find

Find files by criteria

find . -name "*.txt"

System Information

top

Show system processes

top

ps

List processes

ps aux

df

Show disk usage

df -h

du

Show directory size

du -sh directory/

free

Show memory usage

free -h

Network

ping

Test network connectivity

ping google.com

curl

Transfer data from URLs

curl https://api.example.com

wget

Download files

wget https://example.com/file.zip

ssh

Secure shell connection

ssh user@hostname

scp

Secure copy files

scp file.txt user@host:/path/

File Permissions

chmod

Change file permissions

chmod 755 script.sh

chown

Change file owner

chown user:group file.txt

umask

Set default permissions

umask 022

Common Patterns

File Search

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' {} \;

Process Management

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

File Compression

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

Tips & Best Practices

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