cd(Change Directory):- Description: Changes the current working directory.
- Use Cases:
cd Documents: Move to the "Documents" directory.cd ..: Move up one level in the directory structure.cd /: Change to the root directory.cd ~/Downloads: Quickly navigate to the user's Downloads folder.cd -: Toggle between the current and previous directories.cd -L: Follow symbolic links.
ls(List):- Description: Lists the contents of the current directory.
- Use Cases:
ls -a: List all files, including hidden ones.ls -l: Display detailed information about files.ls *.txt: List all files with a .txt extension.ls -R: Recursively list subdirectories and their contents.ls -lh: List files with human-readable file sizes.ls -t: Sort files by modification time.
pwd(Print Working Directory):- Description: Prints the current working directory.
- Use Cases:
pwd: Display the full path of the current directory.echo $(pwd): Use in scripts to get and print the current directory.cd "$(pwd)": Change to the current directory.pwd -P: Print the physical path (resolved symlink path).pwd -L: Print the logical path (unresolved symlink path).pwd -W: Print the Windows path style.
mkdir(Make Directory):- Description: Creates a new directory.
- Use Cases:
mkdir new_folder: Create a directory named "new_folder."mkdir -p path/to/new/directory: Create nested directories.mkdir {dir1,dir2,dir3}: Create multiple directories at once.mkdir -m 755 new_directory: Create a directory with specific permissions.mkdir -v new_directory: Display a message for each created directory.mkdir --help: Show help information for the command.
rmdir(Remove Directory):- Description: Removes an empty directory.
- Use Cases:
rmdir empty_folder: Remove an empty directory named "empty_folder."rmdir -p path/to/empty/directory: Remove nested empty directories.rmdir --ignore-fail-on-non-empty non_empty_folder: Remove a non-empty directory.
rm(Remove):- Description: Removes files or directories.
- Use Cases:
rm file.txt: Delete a file named "file.txt."rm -r folder: Remove a directory and its contents.rm *.log: Delete all files with a .log extension.rm -f file.txt: Forcefully remove a file without confirmation.rm -i *.txt: Interactively remove files with confirmation.rm -v file1 file2: Display a message for each removed file.
cp(Copy):- Description: Copies files or directories.
- Use Cases:
cp file.txt /path/to/destination: Copy a file to a specified directory.cp -r source_folder destination_folder: Copy a directory and its contents.cp *.jpg backup_folder: Copy all JPEG files to a backup directory.cp -u *.txt /backup: Copy files only if the source is newer than the destination.cp -i file.txt /path/to/destination: Interactively copy files with confirmation.cp --preserve=mode,timestamps source.txt destination.txt: Copy while preserving specified attributes.
mv(Move):- Description: Moves or renames files or directories.
- Use Cases:
mv old_file.txt new_file.txt: Rename a file.mv file.txt /new/location/: Move a file to a different directory.mv folder1 folder2: Rename a directory.mv -u *.txt /backup: Move files only if the source is newer than the destination.mv -i file.txt /path/to/destination: Interactively move files with confirmation.mv --backup=numbered file.txt /path/to/backup: Move and create numbered backups.
touch:- Description: Creates an empty file.
- Use Cases:
touch new_file.txt: Create an empty file named "new_file.txt."touch file1.txt file2.txt: Create multiple empty files.touch $(date +"%Y%m%d").log: Create a log file with a timestamp.touch -t 202201011200 file.txt: Create a file with a specific timestamp.touch -c existing_file.txt: Update the access and modification times of an existing file.touch --reference=template_file.txt new_file.txt: Set the timestamps of a new file to match an existing file.
cat:- Description: Concatenates and displays the content of files.
- Use Cases:
cat file.txt: Display the content of "file.txt."cat file1.txt file2.txt > combined.txt: Concatenate two files into one.cat *.log > all_logs.txt: Combine multiple log files into one.cat -n file.txt: Display line numbers with the content.zcat compressed_file.gz: Display the content of a compressed file.cat file.txt | grep "pattern": Display lines matching a specific pattern.
grep:- Description: Searches for a pattern in files.
- Use Cases:
grep "keyword" file.txt: Display lines containing the specified keyword.grep -r "pattern" /path/to/search: Recursively search for a pattern in files.ps aux | grep "process_name": Find a specific process in the process list.grep -i "case-insensitive" file.txt: Perform a case-insensitive search.grep -w "word" file.txt: Match whole words only.grep -v "exclude_pattern" file.txt: Invert match to exclude lines containing a pattern.
find(Continued):
- Description: Searches for files and directories in a directory hierarchy.
- Use Cases:
find /path/to/search -name "*.txt": Find all text files in a directory.find / -size +100M: Find files larger than 100 megabytes.find . -type f -exec chmod 644 {} \;: Change permissions of all files in the current directory.find /path -mtime -7: Find files modified in the last 7 days.find / -name "*.log" -exec rm {} \;: Delete all log files on the system.find /path -type d -empty -delete: Delete all empty directories in a specific path.
chmod:- Description: Changes file permissions.
- Use Cases:
chmod +x script.sh: Add execute permission to a script.chmod 644 file.txt: Set read and write permissions for the owner, read-only for others.chmod -R 755 /path/to/directory: Recursively set permissions for a directory and its contents.chmod g+s directory: Set the setgid bit, making files created in the directory inherit its group.chmod a-x file.txt: Remove execute permission for all users.chmod u=rw,g=r,o=r file.txt: Set specific permissions using symbolic notation.
chown:- Description: Changes file owner and group.
- Use Cases:
chown user:group file.txt: Change the owner and group of a file.chown -R user:group /path/to/directory: Recursively change ownership of a directory and its contents.chown :group file.txt: Change only the group of a file.chown user: /path/to/directory: Change the owner of a directory, leaving the group unchanged.chown -c user:group file.txt: Display a message for each changed ownership.chown --reference=template_file.txt new_file.txt: Set ownership based on an existing file.
ps(Process Status):- Description: Displays information about processes.
- Use Cases:
ps aux: Display a detailed list of all processes.ps -e | grep "process_name": Find a specific process by name.ps -ef | grep "username": List processes associated with a specific user.ps -e | grep -v "grep" | grep "process_name": Exclude the grep process from the result.ps -e --sort=-cpu: Display processes sorted by CPU usage (descending).ps -p PID -o pid,ppid,cmd,%cpu,%mem: Show specific information for a process with a given PID.
kill:- Description: Sends a signal to terminate processes.
- Use Cases:
kill PID: Terminate a process by its process ID.kill -9 PID: Forcefully terminate a process.pkill -f "process_name": Kill processes by name.killall process_name: Kill all processes with a specific name.kill -STOP PID: Suspend a process.kill -CONT PID: Resume a suspended process.
echo:- Description: Prints text to the terminal.
- Use Cases:
echo "Hello, World!": Display the text "Hello, World!".echo $PATH: Print the value of the PATH environment variable.echo -e "Line1\nLine2": Print multiple lines with the -e option.echo $((2+2)): Perform arithmetic and print the result.echo "Error: Something went wrong" >&2: Print an error message to standard error.echo "Today is $(date)": Embed command output within an echo statement.
man(Manual):- Description: Displays the manual page for a command.
- Use Cases:
man ls: View the manual page for the "ls" command.man -k keyword: Search for manual pages containing a specific keyword.man 5 passwd: Display information about the passwd file format.man -t find | ps2pdf - > find.pdf: Convert a manual page to PDF.man -Hfirefox command: Open the manual page in a web browser.man -l file.5: View a specific section of a manual page.
head:
- Description: Displays the first few lines of a file.
- Use Cases:
head file.txt: Display the first 10 lines of "file.txt."head -n 20 file.txt: Display the first 20 lines.ls | head -3: Display the first 3 items in the current directory.head -c 100 file.txt: Display the first 100 bytes of a file.head -q file1.txt file2.txt: Quiet mode, don't display headers when multiple files are specified.journalctl | head -n 50: Display the first 50 lines of system journal entries.
tail:
- Description: Displays the last few lines of a file.
- Use Cases:
tail file.txt: Display the last 10 lines of "file.txt."tail -n 20 file.txt: Display the last 20 lines.tail -f /var/log/syslog: Follow the content of a log file in real-time.tail -c +101 file.txt: Display all characters from the 101st character onwards.journalctl | tail -n 50: Display the last 50 lines of system journal entries.ls -lt | tail -n +6: Display a directory listing, excluding the first 5 lines.
nano:
- Description: A simple command-line text editor.
- Use Cases:
nano file.txt: Open or create a file for editing.nano +10 file.txt: Open a file and position the cursor at line 10.nano -B file.txt: Create a backup of the file before saving changes.nano -c file.txt: Show line numbers and column numbers.nano -x: Start nano in no-wrapping mode.nano --help: Display help information for nano.
vim:
- Description: A powerful text editor with modes and extensive features.
- Use Cases:
vim file.txt: Open or create a file for editing.vim +10 file.txt: Open a file and position the cursor at line 10.vim -O file1.txt file2.txt: Open multiple files in split windows.vim -u NONE -N: Start Vim with no plugins and no compatible mode.vim -c "set number" file.txt: Execute a command on startup (set line numbering).vimdiff file1.txt file2.txt: Compare two files using Vim's side-by-side mode.
du(Disk Usage):
- Description: Displays the disk space used by files and directories.
- Use Cases:
du -h /path: Show disk usage in human-readable format.du -sh *: Display the total disk usage of each item in the current directory.du -c -h /path/*: Display the total disk usage of all items in a directory.du -d 2 /path: Display disk usage up to a specified depth.find / -type f -exec du -h {} + | sort -rh | head -n 10: Find and display the largest files on the system.du -h --max-depth=1 /path: Display disk usage of each immediate subdirectory.
df(Disk Free):
- Description: Displays information about available disk space.
- Use Cases:
df -h: Show disk space usage in a human-readable format.df -T: Display filesystem types along with disk space information.df -i: Show inode usage on filesystems.df -h /path: Display disk space information for a specific directory or filesystem.df --total: Display total disk space usage across all filesystems.df -P /path: Use the POSIX output format for consistent column widths.
tar:
- Description: Creates or extracts tar archives.
- Use Cases:
tar -cvf archive.tar file1 file2: Create a tar archive of specified files.tar -xvf archive.tar: Extract files from a tar archive.tar -czvf archive.tar.gz directory/: Create a compressed tar archive.tar -tvf archive.tar: List the contents of a tar archive.tar -rvf archive.tar new_file: Add a new file to an existing tar archive.tar --exclude=*.log -cvf archive.tar *: Create an archive excluding all .log files.
gzip:
- Description: Compresses or decompresses files using gzip compression.
- Use Cases:
gzip file.txt: Compress a file and add the ".gz" extension.gzip -d file.txt.gz: Decompress a gzip-compressed file.gzip -c file.txt > file.txt.gz: Compress a file and retain the original.gunzip -k file.txt.gz: Decompress a file and keep the original compressed file.gzip -r directory: Compress all files in a directory recursively.zcat file.txt.gz: Display the content of a compressed file without decompressing.
gunzip:
- Description: Decompresses files compressed with gzip.
- Use Cases:
gunzip file.txt.gz: Decompress a gzip-compressed file.gunzip -k file.txt.gz: Decompress a file and keep the original compressed file.gunzip -c file.txt.gz > file.txt: Decompress a file and retain the original.gunzip -r directory: Decompress all files in a directory recursively.gunzip -l file.txt.gz: Display information about the compressed file.gunzip --help: Display help information for gunzip.
zip:
- Description: Compresses files into a zip archive.
- Use Cases:
zip archive.zip file1 file2: Create a zip archive of specified files.unzip archive.zip: Extract files from a zip archive.zip -r archive.zip directory/: Create a zip archive of an entire directory.zip -u archive.zip new_file.txt: Update a zip archive with a new file.zip -d archive.zip file.txt: Deletezip -e secure.zip file.txt: Create a password-protected zip archive.
unzip:
- Description: Extracts files from a zip archive.
- Use Cases:
unzip archive.zip: Extract files from a zip archive.unzip -l archive.zip: List the contents of a zip archive.unzip -d /path/to/extract archive.zip: Extract files to a specified directory.unzip -u archive.zip: Update an existing zip archive with new files.unzip -p archive.zip file.txt > output.txt: Extract and redirect the content of a specific file.unzip -e password_protected.zip: Extract from a password-protected zip archive.
curl:
- Description: Transfers data to or from a server.
- Use Cases:
curl http://example.com: Retrieve content from a URL and display it.curl -O http://example.com/file.txt: Download a file from a URL.curl -X POST -d "data" http://api.com: Send a POST request with data.curl -I http://example.com: Show only the HTTP headers.curl -u username:password http://secure-site.com: Authenticate with a username and password.curl -L http://shorturl.com: Follow redirects to the final destination.
wget:
- Description: Downloads files from the web using HTTP, HTTPS, or FTP.
- Use Cases:
wget http://example.com/file.txt: Download a file from a URL.wget -c http://example.com/largefile.zip: Resume a partially downloaded file.wget -r -np http://example.com/folder/: Recursively download files from a website.wget --limit-rate=500k http://example.com/file.iso: Limit download speed to 500 KB/s.wget --ftp-user=user --ftp-password=pass ftp://example.com/file.txt: Download from an FTP server with authentication.wget --spider -r http://example.com: Check if web pages are accessible without downloading.
ssh:
- Description: Connects to a remote server securely.
- Use Cases:
ssh username@hostname: Connect to a remote server with a specified username.ssh -p 2222 username@hostname: Connect to a server on a non-default SSH port.ssh-keygen -t rsa: Generate an SSH key pair for authentication.ssh-copy-id username@hostname: Copy SSH keys to a remote server for passwordless login.ssh -L 8080:localhost:80 username@hostname: Create an SSH tunnel for local port forwarding.scp file.txt username@hostname:/path/to/destination: Securely copy a file to a remote server.
scp:
- Description: Securely copies files between local and remote hosts.
- Use Cases:
scp file.txt username@hostname:/path/to/destination: Copy a file to a remote server.scp -r directory username@hostname:/remote/directory/: Copy a directory and its contents.scp username@remote:/path/to/file.txt .: Copy a file from a remote server to the local directory.scp -P 2222 file.txt username@hostname:/path/to/destination: Specify a non-default SSH port.scp -i keyfile.pem file.txt username@hostname:/path/to/destination: Use a specific private key for authentication.rsync -avz --progress /local/path/ username@remote:/remote/path/: Synchronize files between local and remote hosts with rsync.
rsync:
- Description: Synchronizes files and directories between local and remote systems.
- Use Cases:
rsync -avz /local/path/ username@remote:/remote/path/: Copy files from local to remote using compression.rsync -avz --delete /local/path/ username@remote:/remote/path/: Synchronize and delete extraneous files on the destination.rsync -avz --exclude='*.log' /local/path/ username@remote:/remote/path/: Exclude specific file types during synchronization.rsync -avz --dry-run /local/path/ username@remote:/remote/path/: Perform a dry run without making changes.rsync -avz --bwlimit=1000 /local/path/ username@remote:/remote/path/: Limit the bandwidth during synchronization.rsync -avz -e 'ssh -p 2222' /local/path/ username@hostname:/remote/path/: Specify a non-default SSH port.
history:
- Description: Displays the command history.
- Use Cases:
history: Display the command history.!ls: Execute the last command that started with "ls."history | grep "keyword": Search the command history for a specific keyword.!!: Repeat the last command.!n: Repeat the nth command from the history.history -c: Clear the entire command history.
clear:
- Description: Clears the terminal screen.
- Use Cases:
clear: Clear the terminal screen.clear && command: Clear the screen before executing a command.Ctrl + L: Shortcut to clear the terminal screen.clear -x: Clear the screen and scrollback buffer.watch -n 1 'command | clear': Continuously run a command and clear the screen every second.tput reset: Use the terminfo capability to clear the screen.
date:
- Description: Displays or sets the system date and time.
- Use Cases:
date: Display the current date and time.date +"%Y-%m-%d %H:%M:%S": Format and display the date and time.date -s "2022-01-01 12:00:00": Set the system date and time.date --date="2 days ago": Display the date from two days ago.date -u: Display the date in Coordinated Universal Time (UTC).date +%s: Display the current timestamp (seconds since 1970-01-01 00:00:00 UTC).
cal:
- Description: Displays a calendar.
- Use Cases:
cal: Display the current month's calendar.cal -3: Display the previous, current, and next month's calendars.cal 2022: Display the calendar for the entire year 2022.cal -j: Display Julian dates in the calendar.cal -y: Display a calendar with a week starting from Sunday.cal -A 1 -B 1: Display one month ahead and one month behind the current month.
uptime:
- Description: Displays how long the system has been running.
- Use Cases:
uptime: Display the current time, how long the system has been running, and the number of users.uptime -p: Display the uptime in a more human-readable format.w: Similar touptimebut also shows who is logged in and what they are doing.top: Display real-time system statistics, including uptime.ps -eo etime,cmd | grep -i "process_name": Check the uptime of a specific process.watch -n 1 uptime: Continuously monitor system uptime.
whoami:
- Description: Displays the username of the current user.
- Use Cases:
whoami: Display the current username.echo "I am $(whoami)": Use in scripts to incorporate the username.sudo -u $(whoami) command: Execute a command with elevated privileges as the current user.id -un: Display the username using theidcommand.finger $(whoami): Display additional information about the user.who: Display information about currently logged-in users.
uname:
- Description: Displays system information.
- Use Cases:
uname: Display the system name (kernel name).uname -a: Display all system information.uname -s: Display the kernel name.uname -r: Display the kernel release.uname -m: Display the machine hardware name.uname -n: Display the network node hostname.
df(Data Format):
- Description: Converts and formats data.
- Use Cases:
echo "123" | df: Display the size and usage of standard input.df -hT: Display a summarized and human-readable format of filesystem information.df -B MB: Display block sizes in megabytes.df --output=source,size,used,avail: Specify the columns to be displayed.df -H /path: Display disk usage with human-readable units.df --sync: Synchronize output to avoid displaying outdated information.
ps(PostScript):
- Description: Generates PostScript files.
- Use Cases:
ps2pdf file.ps: Convert a PostScript file to PDF.ps2pdf -dPDFSETTINGS=/prepress file.ps: Optimize PDF output for prepress printing.ps2pdf -sOutputFile=output.pdf input.ps: Specify the output file name.ps2pdf -dNOPAUSE -dBATCH -sDEVICE=jpeg -r300 -sOutputFile=output.jpg input.ps: Convert to JPEG format.ps2pdf -dEmbedAllFonts=true -dSubsetFonts=true input.ps: Embed and subset fonts in the PDF.ps2pdf -dFirstPage=2 -dLastPage=5 input.ps output.pdf: Convert specific pages to PDF.
echo:
- Description: Prints text to the terminal.
- Use Cases:
echo "Hello, World!": Display the text "Hello, World!".echo $PATH: Print the value of the PATH environment variable.echo -e "Line1\nLine2": Print multiple lines with the -e option.echo $((2+2)): Perform arithmetic and print the result.echo "Error: Something went wrong" >&2: Print an error message to standard error.echo "Today is $(date)": Embed command output within an echo statement.
printf:
- Description: Formats and prints data.
- Use Cases:
printf "Name: %s\nAge: %d\n" "John" 25: Display formatted text.printf "%-10s %-8s %-4s\n" "Name" "Age" "ID": Format text with specified widths.printf "%0.2f\n" 3.14159: Format and display a floating-point number.printf "Hex: %x\n" 255: Display a hexadecimal representation.printf "Binary: %b\n" 101: Display a binary representation.printf "Octal: %o\n" 8: Display an octal representation.
grep(Global Regular Expression Print):
- Description: Searches for a pattern in files.
- Use Cases:
grep "keyword" file.txt: Display lines containing the specified keyword.grep -r "pattern" /path/to/search: Recursively search for a pattern in files.ps aux | grep "process_name": Find a specific process in the process list.grep -i "case-insensitive" file.txt: Perform a case-insensitive search.grep -w "word" file.txt: Match whole words only.grep -v "exclude_pattern" file.txt: Invert match to exclude lines containing a pattern.
awk:
- Description: A versatile text processing tool.
- Use Cases:
ls -l | awk '{print $1, $9}': Display file permissions and names.ps aux | awk '$3 > 50 {print $1, $3}': Print user and CPU usage for processes using more than 50% CPU.awk '{sum += $1} END {print sum}' numbers.txt: Calculate and print the sum of numbers in a file.df -h | awk '$5 > 80 {print $6, $5}': Display filesystems with usage above 80%.awk '/pattern/ {print $0}' file.txt: Print lines containing a specific pattern.awk -F: '{print $1, $3}' /etc/passwd: Set a custom field separator and print user names and IDs.
sed(Stream Editor):
- Description: Edits text streams.
- Use Cases:
sed 's/old/new/' file.txt: Replace the first occurrence of "old" with "new" in each line.sed '2,5s/old/new/' file.txt: Replace "old" with "new" in lines 2 to 5.sed 's/old/new/g' file.txt: Replace all occurrences of "old" with "new" in each line.sed -n '1,5p' file.txt: Print only lines 1 to 5.sed '/pattern/d' file.txt: Delete lines containing a specific pattern.sed 's/^/prefix_/' file.txt: Add a prefix to the beginning of each line.
cut:
- Description: Removes sections from each line of a file.
- Use Cases:
cut -d',' -f2 file.csv: Extract the second field from a CSV file.cut -c1-5 file.txt: Extract the first five characters from each line.ps aux | cut -c1-20,30-: Extract specific columns from the output ofps.cut -f1,3 -d':' /etc/passwd: Extract user names and user IDs from the passwd file.cut -f2- file.txt: Extract fields starting from the second field.echo "apple,orange,banana" | cut -d',' --output-delimiter=' | ' -f2,3: Change the output delimiter.
sort:
- Description: Sorts lines of text files.
- Use Cases:
sort file.txt: Sort lines alphabetically.sort -r file.txt: Sort lines in reverse order.sort -n numbers.txt: Sort numerical values.ls -l | sort -k5,5nr: Sort files by size in descending order.sort -t':' -k3,3n /etc/passwd: Sort the passwd file by user ID.sort -u file.txt: Sort and remove duplicate lines.
uniq:
- Description: Removes duplicate lines from a sorted file.
- Use Cases:
sort file.txt | uniq: Remove consecutive duplicate lines.sort file.txt | uniq -c: Count and remove consecutive duplicate lines.sort file.txt | uniq -u: Display only lines that are not repeated.uniq -i file.txt: Case-insensitive comparison.uniq -d file.txt: Display only duplicate lines.uniq -w 3 file.txt: Compare only the first 3 characters.
tr(Translate):
- Description: Translates or deletes characters.
- Use Cases:
echo "Hello" | tr 'a-z' 'A-Z': Convert lowercase to uppercase.echo "Hello 123" | tr -d '0-9': Remove digits.echo "Hello 123" | tr -c 'a-z' 'X': Replace non-lowercase characters with 'X'.echo " Hello " | tr -s ' ': Squeeze consecutive spaces into one.echo "abc" | tr -d -c 'a-z': Delete characters not in the specified range.echo "HELLO" | tr 'A-Z' 'a-z': Convert uppercase to lowercase.
wc(Word Count):
- Description: Counts lines, words, and characters in a file.
- Use Cases:
wc file.txt: Display the line, word, and byte count for a file.wc -l file.txt: Display only the line count.wc -w file.txt: Display only the word count.echo "Hello" | wc -c: Count the number of characters in a string.cat *.txt | wc -l: Count the total number of lines in multiple files.find /path -type f -exec cat {} \; | wc -l: Count the total number of lines in all files in a directory.
curl:
- Description: Transfers data to or from a server.
- Use Cases:
curl http://example.com: Retrieve content from a URL and display it.curl -O http://example.com/file.txt: Download a file from a URL.curl -X POST -d "data" http://api.com: Send a POST request with data.curl -I http://example.com: Show only the HTTP headers.curl -u username:password http://secure-site.com: Authenticate with a username and password.curl -L http://shorturl.com: Follow redirects to the final destination.
wget:
- Description: Downloads files from the web using HTTP, HTTPS, or FTP.
- Use Cases:
wget http://example.com/file.txt: Download a file from a URL.wget -c http://example.com/largefile.zip: Resume a partially downloaded file.wget -r -np http://example.com/folder/: Recursively download files from a website.wget --limit-rate=500k http://example.com/file.iso: Limit download speed to 500 KB/s.wget --ftp-user=user --ftp-password=pass ftp://example.com/file.txt: Download from an FTP server with authentication.wget --spider -r http://example.com: Check if web pages are accessible without downloading.
ssh:- Description: Connects to a remote server securely.
- Use Cases:
ssh username@hostname: Connect to a remote server with a specified username.ssh -p 2222 username@hostname: Connect to a server on a non-default SSH port.ssh-keygen -t rsa: Generate an SSH key pair for authentication.ssh-copy-id username@hostname: Copy SSH keys to a remote server for passwordless login.ssh -L 8080:localhost:80 username@hostname: Create an SSH tunnel for local port forwarding.scp file.txt username@hostname:/path/to/destination: Securely copy a file to a remote server.
docker:
- Description: Manages containers for developing, shipping, and running applications.
- Use Cases:
docker build -t image_name .: Build a Docker image from the current directory.docker run -p 8080:80 image_name: Run a Docker container, mapping port 8080 to port 80.docker ps: List running containers.docker exec -it container_name /bin/bash: Access a running container's shell.docker-compose up: Start services defined in a Docker Compose file.docker system prune: Remove all stopped containers, unused networks, and dangling images.
kubectl:
- Description: Interacts with Kubernetes clusters to deploy and manage applications.
- Use Cases:
kubectl apply -f deployment.yaml: Deploy a Kubernetes resource defined in a YAML file.kubectl get pods: List running pods in a Kubernetes cluster.kubectl logs pod_name: View logs from a specific pod.kubectl describe deployment deployment_name: Display detailed information about a deployment.kubectl scale deployment deployment_name --replicas=3: Scale the number of replicas for a deployment.kubectl delete pod pod_name: Delete a pod in a Kubernetes cluster.
ansible:
- Description: Automates configuration management, application deployment, and task execution.
- Use Cases:
ansible-playbook deploy_app.yml: Run an Ansible playbook for deploying an application.ansible all -m ping: Check connectivity to all hosts in the inventory.ansible-playbook -i inventory_file deploy_app.yml: Use a custom inventory file for playbook execution.ansible-vault encrypt secrets.yml: Encrypt sensitive data in an Ansible Vault.ansible-galaxy init role_name: Initialize a new Ansible role.ansible-doc command_module: View documentation for an Ansible module.
terraform:
- Description: Manages infrastructure as code and enables provisioning of resources.
- Use Cases:
terraform init: Initialize a Terraform working directory.terraform apply: Apply changes to infrastructure as defined in Terraform configuration.terraform plan: Generate and show an execution plan for changes.terraform destroy: Destroy Terraform-managed infrastructure.terraform state show: Show Terraform state or plan file.terraform fmt: Format Terraform configuration files.
git:
- Description: Version control system for tracking changes in source code during software development.
- Use Cases:
git clone repository_url: Clone a Git repository.git add file_name: Add changes in a file to the staging area.git commit -m "Commit message": Commit changes to the local repository.git push origin branch_name: Push changes to a remote repository.git pull origin branch_name: Pull changes from a remote repository.git branch -a: List all branches in the repository.
jenkins:
- Description: An automation server used for building, testing, and deploying software.
- Use Cases:
- Jenkins Pipeline: Define a continuous integration/continuous deployment (CI/CD) pipeline.
- Jenkins Job DSL: Create and manage Jenkins jobs programmatically.
- Jenkins CLI: Interact with Jenkins from the command line.
- Jenkins Plugin Management: Install and manage plugins for extending Jenkins functionality.
- Jenkins Slave Configuration: Set up and configure build agents (slaves) in Jenkins.
- Jenkins System Configuration: Adjust global settings and configurations in Jenkins.
curl(for API testing):
- Description: Command-line tool for making HTTP requests.
- Use Cases:
curl -X GET http://api_endpoint: Send a GET request to an API.curl -X POST -H "Content-Type: application/json" -d '{"key":"value"}' http://api_endpoint: Send a POST request with JSON data.curl -H "Authorization: Bearer token" http://api_endpoint: Include an authorization token in the request header.curl -I http://api_endpoint: Fetch only the HTTP headers from the response.curl -u username:password http://api_endpoint: Perform basic authentication.curl --data-urlencode "param1=value1" --data-urlencode "param2=value2" http://api_endpoint: Send data as URL-encoded form parameters.
vault(HashiCorp Vault):
- Description: Manages secrets and protects sensitive data for applications.
- Use Cases:
vault write secret/myapp/apikey value=supersecret: Store a secret in Vault.vault read secret/myapp/apikey: Retrieve a secret from Vault.vault kv get secret/myapp: List all key-value pairs in a secret path.vault policy write mypolicy policy.hcl: Create or update a policy in Vault.vault token create -policy=mypolicy: Create a new token with a specified policy.vault audit enable file file_path.log: Enable file-based auditing in Vault.
logrotate:
- Description: Rotates, compresses, and mails system logs.
- Use Cases:
logrotate -f /etc/logrotate.conf: Force log rotation using a specific configuration file.logrotate -d /etc/logrotate.conf: Debug mode to check the log rotation process without making changes.logrotate --state /var/lib/logrotate/status: Specify an alternate state file for log rotation.logrotate -s /path/to/state/file: Set the state file for log rotation.logrotate -v /etc/logrotate.conf: Verbose mode to display detailed information during log rotation.logrotate --force /etc/logrotate.d/custom: Force log rotation for a specific log file.
htop:
- Description: Interactive process viewer for monitoring system resources.
- Use Cases:
htop: Launch the htop process viewer.htop -u username: Display processes for a specific user.htop -p PID: Show information for a specific process ID.htop -s: Sort processes based on a selected column.htop -t: Tree view, display processes in a hierarchical structure.