-
List directory contents:
ls # List files and directories ls -l # Detailed list view ls -a # Show hidden files
-
Change directories:
cd directory_name # Move to specific directory cd .. # Move up one directory cd ~ # Move to home directory pwd # Show current directory path
-
Create files and directories:
touch filename.txt # Create new file mkdir directory_name # Create new directory mkdir -p path/to/dir # Create nested directories
-
Copy and move:
cp file1 file2 # Copy file1 to file2 cp -r dir1 dir2 # Copy directory and contents mv file1 file2 # Move/rename file mv dir1 dir2 # Move/rename directory
-
Delete files and directories:
rm filename # Remove file rm -r directory # Remove directory and contents rmdir directory # Remove empty directory
-
View file contents:
cat filename # Display entire file less filename # View file with scrolling head filename # Show first 10 lines tail filename # Show last 10 lines
-
Find text in files:
grep "text" filename # Search for text in file grep -r "text" . # Search in all files recursively
-
Basic text editing:
nano filename # Open simple text editor echo "text" > file # Write text to file (overwrite) echo "text" >> file # Append text to file
-
System details:
uname -a # Show system information df -h # Show disk space usage free -h # Show memory usage top # Show running processes
-
User information:
whoami # Show current username id # Show user ID information who # Show who is logged in
-
Network information:
ip addr # Show IP addresses ping hostname # Test network connection netstat -tuln # Show network connections
-
Change permissions:
chmod +x filename # Make file executable chmod 755 filename # Set specific permissions chmod -R 755 dir # Set permissions recursively
-
Change ownership:
chown user filename # Change file owner chown user:group filename # Change owner and group chown -R user directory # Change ownership recursively
-
View permissions:
ls -l filename # Show file permissions ls -ld directory # Show directory permissions
-
Process management:
ps # Show running processes kill process_id # Stop a process killall process_name # Stop all processes by name
-
Archive and compression:
tar -czf archive.tar.gz files/ # Create tar archive tar -xzf archive.tar.gz # Extract tar archive zip -r archive.zip directory # Create zip file unzip archive.zip # Extract zip file
-
Command history:
history # Show command history !! # Repeat last command !number # Run command by history number
-
Keyboard shortcuts:
Ctrl + C # Stop current process Ctrl + L # Clear screen Ctrl + R # Search command history Ctrl + A # Move to start of line Ctrl + E # Move to end of line
-
Command combinations:
command1 && command2 # Run command2 if command1 succeeds command1 || command2 # Run command2 if command1 fails command1 | command2 # Pipe output to next command
-
Quick navigation:
cd - # Go to previous directory pushd directory # Push directory to stack popd # Pop directory from stack