DEV Community

Udoh Deborah
Udoh Deborah

Posted on

Day 14: Create a Linux & Git-GitHub Cheat Sheet

On day 14, I consolidated all the important Linux and Git commands I have been learning, into a comprehensive Cheat sheet.

A cheat Sheet is a concise document or reference guide that summarizes key information, commands or syntax for a specific tool, technology or topic.

Linux Commands

File Navigation

Command Description Example
pwd Print working directory pwd
ls List directory contents ls -la(list all files with details)
cd Change directory cd Documents
mkdir Create directory mkdir new_folder
rmdir Remove empty directory rmdir old_folder
touch Create empty file touch file.txt

File Operations

Command Description Example
cp Copy files/directories cp file.txt backup/
mv Move/rename files mv old.txt new.txt
rm Remove files/directories rm file.txtorrm -r directory
cat Display file contents cat file.txt
head Display first lines of file head -n 10 file.txt
tail Display last lines of file tail -n 10 file.txt
less View file with pagination less large_file.txt

File Permissions

Command Description Example
chmod Change file permissions chmod 755 script.sh
chown Change file owner chown user:group file.txt

Permission numbers: 4 (read), 2 (write), 1 (execute). Add them together for combined permissions.
e.g., 755 = rwx for owner, r-x for group and others

Text Processing

Command Description Example
grep Search text patterns grep "pattern" file.txt
sed Stream editor sed 's/old/new/g' file.txt
awk Text processing tool awk '{print $1}' file.txt
sort Sort text sort file.txt
uniq Report unique lines uniq -c file.txt
wc Count lines, words, bytes wc -l file.txt

Package Management

Debian/Ubuntu Description
apt update Update package lists
apt upgrade Upgrade installed packages
apt install [package] Install package
apt remove [package] Remove package

Network Commands

Command Description Example
ping Test network connectivity ping google.com
ifconfig/ip Network interface config ip addr show
netstat Network statistics netstat -tuln
ssh Secure shell ssh user@hostname
scp Secure copy scp file.txt user@host:/path
wget Download files wget https://example.com/file
curl Transfer data curl -O https://example.com/file

Git Commands

Configuration

Command Description
git config --global user.name "Name" Set global username
git config --global user.email "email@example.com" Set global email
git config --list List all configurations

Repository Setup

Command Description
git init Initialize a new repository
git clone [url] Clone a repository

Basic Commands

Command Description
git status Check repository status
git add [file] Add file to staging area
git add . Add all changes to staging area
git commit -m "message" Commit staged changes
git push Push commits to remote
git pull Pull changes from remote

Branching

Command Description
git branch List branches
git branch [name] Create new branch
git checkout [branch] Switch to branch
git checkout -b [branch] Create and switch to branch
git merge [branch] Merge branch into current branch
git branch -d [branch] Delete branch

Here's a downloadable Pdf link to have the Cheat Sheet saved for whenever you need it.

Top comments (0)