Okay, here's a comprehensive list of basic Linux commands, categorized for easier understanding. I'll include a brief description and example for each. This is a lot of commands, so it's broken down into sections. I'll also indicate which ones are commonly available in Git Bash vs. WSL/Cygwin. (GB = Git Bash, WSL/C = WSL/Cygwin)
1. File & Directory Management
ls (GB, WSL/C): List files and directories.
ls -l: Long listing format (details like permissions, size, date).
ls -a: Show all files, including hidden ones (starting with .).
ls -h: Human-readable sizes (e.g., 1K, 234M, 2G).
ls -t: Sort by modification time (newest first).
pwd (GB, WSL/C): Print working directory (shows your current location).
cd (GB, WSL/C): Change directory.
cd ..: Go up one directory.
cd ~: Go to your home directory.
cd /path/to/directory: Go to a specific directory.
mkdir (GB, WSL/C): Make directory.
mkdir directory_name: Creates a new directory.
mkdir -p path/to/new/directory: Creates parent directories if they don't exist.
rmdir (GB, WSL/C): Remove directory (only works on empty directories).
rm (GB, WSL/C): Remove file. WARNING: This is permanent!
rm filename: Removes a file.
rm -r directory_name: Removes a directory and its contents recursively. EXTREMELY CAREFUL WITH THIS!
rm -f filename: Force removal (ignores prompts). Use with caution.
cp (GB, WSL/C): Copy file or directory.
cp source_file destination_file: Copies a file.
cp -r source_directory destination_directory: Copies a directory recursively.
mv (GB, WSL/C): Move or rename file or directory.
mv old_name new_name: Renames a file or directory.
mv file destination_directory: Moves a file to a directory.
touch (GB, WSL/C): Create an empty file or update the timestamp of an existing file.
2. File Content Viewing & Editing
cat (GB, WSL/C): Concatenate and display file content.
cat filename: Displays the entire file.
less (GB, WSL/C): View file content one page at a time. (Use spacebar to advance, q to quit).
head (GB, WSL/C): Display the first few lines of a file (default: 10 lines).
head -n 20 filename: Display the first 20 lines.
tail (GB, WSL/C): Display the last few lines of a file (default: 10 lines).
tail -f filename: Follow the file as it grows (useful for logs).
nano (WSL/C): Simple text editor. (Often easier to use than vi or vim for beginners).
vi / vim (WSL/C): Powerful but complex text editor. (Requires learning a bit of a different mode of operation).
echo (GB, WSL/C): Display text. Often used for writing to files.
echo "Hello, world!" > filename: Writes "Hello, world!" to filename (overwrites existing content).
echo "Hello, world!" >> filename: Appends "Hello, world!" to filename.
3. System Information & Process Management
uname (GB, WSL/C): Print system information.
uname -a: Print all system information.
date (GB, WSL/C): Display the current date and time.
cal (GB, WSL/C): Display a calendar.
ps (GB, WSL/C): List running processes.
ps aux: Show all processes with detailed information.
top (WSL/C): Display dynamic real-time view of running processes.
kill (GB, WSL/C): Terminate a process. (Requires the process ID (PID) from ps or top).
kill PID: Sends a termination signal to the process.
kill -9 PID: Forcefully terminates a process (use as a last resort).
df (GB, WSL/C): Display disk space usage.
df -h: Human-readable disk space usage.
du (GB, WSL/C): Display directory space usage.
du -h: Human-readable directory space usage.
4. Networking
ping (GB, WSL/C): Test network connectivity.
ping google.com: Ping Google's website.
ifconfig (WSL/C): Display network interface configuration. (May require installation in some WSL distributions). ip addr is often preferred now.
ip addr (WSL/C): Display network interface addresses.
netstat (WSL/C): Display network connections, routing tables, interface statistics, etc.
ssh (GB, WSL/C): Secure Shell – connect to a remote server.
ssh username@hostname: Connect to a remote server.
5. Permissions & Ownership
chmod (GB, WSL/C): Change file permissions. (This is a complex topic; research "Linux file permissions" for details).
chown (GB, WSL/C): Change file ownership.
chgrp (GB, WSL/C): Change file group ownership.
6. Searching
grep (GB, WSL/C): Search for a pattern in files.
grep "pattern" filename: Search for "pattern" in filename.
grep -i "pattern" filename: Case-insensitive search.
grep -r "pattern" directory: Recursive search in a directory.
find (GB, WSL/C): Find files based on various criteria.
find . -name "filename": Find a file named "filename" in the current directory and its subdirectories.
7. Other Useful Commands
man (GB, WSL/C): Display the manual page for a command. (e.g., man ls shows the manual for the ls command).
history (GB, WSL/C): Display your command history.
clear (GB, WSL/C): Clear the terminal screen.
exit (GB, WSL/C): Exit the current shell.
sudo (WSL/C): Execute a command with superuser (administrator) privileges. (Requires your password).
Important Notes:
- Case Sensitivity: Linux commands are case-sensitive.
ls is different from Ls.
- Tab Completion: Use the Tab key to auto-complete commands and filenames.
- Help: Most commands have a
--help option (e.g., ls --help) that displays usage information.
- Practice: The best way to learn is to practice! Experiment with these commands in a safe environment.
This is a starting point. There are many more Linux commands available, but these are the ones you'll use most frequently. Good luck! Let me know if you have any specific questions about any of these commands.