ποΈ File & Directory Commands
Type | Command | Example 1 | Example 2 |
---|---|---|---|
π Navigation | cd |
cd /var/log β Go to system logs |
cd ~/projects β Jump to projects |
π Listing | ls |
ls -l β Long format |
ls -lha /etc β All files human-readable |
β Creation | mkdir |
mkdir newdir β Create βnewdirβ |
mkdir -p a/b/c β Nested dirs |
π Viewing | cat |
cat README.md β Dump file |
cat file1 file2 β Concat & view |
π Searching | find |
find . -name "*.log" β Find logs |
find /home -size +1M β Files >1 MB |
π Copy | cp |
cp a.txt b.txt β Copy file |
cp -r src/ dest/ β Copy dir |
π Move | mv |
mv old.txt new.txt β Rename |
mv *.log archive/ β Move logs |
ποΈ Deletion | rm |
rm file.txt β Delete file |
rm -rf temp/ β Force delete dir |
π Disk Usage | du |
du -h . β Folder sizes |
du -sh ~/ β Summarize home |
πΎ Disk Free | df |
df -h β FS usage |
df -Th β Type + human |
π Linking |
ln |
ln -s /usr/bin/python3 python β Symlink |
ln file.txt hardlink.txt β Hard link |
π Network Commands
Type | Command | Example 1 | Example 2 |
---|---|---|---|
πΆ Connectivity | ping |
ping google.com β Reachability |
ping -c3 1.1.1.1 β 3 packets |
π°οΈ Trace Route | traceroute |
traceroute example.com |
traceroute -n 8.8.8.8 |
π HTTP Client | curl |
curl https://api.github.com |
curl -I https://example.com |
β¬οΈ Download | wget |
wget file.tar.gz |
wget -qO- https://site.com |
π΅οΈ DNS Lookup | dig |
dig +short example.com |
dig @8.8.8.8 example.com |
π Socket Info | netstat |
netstat -tuln |
netstat -p |
π Socket Info | ss |
ss -tuln |
ss -p |
βοΈ IP Config | ip |
ip addr show |
ip route show |
π Port Scan | nmap |
nmap localhost |
nmap -sS 192.168.1.0/24 |
π Permissions Management
Type | Command | Example 1 | Example 2 |
---|---|---|---|
π Modify Mode | chmod |
chmod 755 script.sh |
chmod -R u+rwX,g-w,o-rwx dir/ |
π€ Change Owner | chown |
chown parvez file.txt |
chown -R user:group dir/ |
π Default Mask | umask |
umask 022 |
umask 077 |
π Get ACL | getfacl |
getfacl file.txt |
getfacl -R dir/ |
π οΈ Set ACL | setfacl |
setfacl -m u:alice:rw file.txt |
setfacl -x g:staff file.txt |
π§ systemd (systemctl)
Type | Command | Example 1 | Example 2 |
---|---|---|---|
βΉοΈ Status | systemctl status |
systemctl status sshd |
systemctl status nginx.service |
βΆοΈ Start | systemctl start |
systemctl start sshd |
systemctl start apache2 |
βΉοΈ Stop | systemctl stop |
systemctl stop sshd |
systemctl stop apache2 |
π Restart | systemctl restart |
systemctl restart sshd |
systemctl restart apache2 |
π‘οΈ Enable | systemctl enable |
systemctl enable sshd |
systemctl enable nginx |
β Disable | systemctl disable |
systemctl disable sshd |
systemctl disable nginx |
π Reload | systemctl daemon-reload |
systemctl daemon-reload |
systemctl reload-or-restart sshd |
π List Units | systemctl list-unit-files |
systemctl list-unit-files |
systemctl list-units --type=service |
βοΈ Service Management (`service`)
Type | Command | Example 1 | Example 2 |
---|---|---|---|
βΉοΈ Status | service <name> status |
service sshd status |
service apache2 status |
βΆοΈ Start | service <name> start |
service sshd start |
service apache2 start |
βΉοΈ Stop | service <name> stop |
service sshd stop |
service apache2 stop |
π Restart | service <name> restart |
service sshd restart |
service apache2 restart |
π Reload | service <name> reload |
service sshd reload |
service apache2 reload |
π .bashrc Snippets
Type | Snippet | Example 1 | Example 2 |
---|---|---|---|
π Alias | alias |
alias ll='ls -la' |
alias gs='git status' |
πΏ Export | export |
export PATH=$PATH:/opt/bin |
export EDITOR=vim |
π¨ PS1 Prompt π Click me |
PS1 |
PS1="\u@\h:\w\$ " |
PS1="
\[\e[32m\]
\u@\h
\[\e[m\]
:\w\$ " |
π Function | mkcd(){ mkdir -p "$1"; cd "$1"; } |
mkcd newdir β Make+cd |
extract(){ tar -xvf "$1"; } |
π Source | source |
source ~/.bash_aliases |
source /etc/bash_completion |
π History | HISTSIZE/HISTCONTROL |
export HISTSIZE=2000 |
export HISTCONTROL=ignoredups:erasedups |
π Shell Options | shopt |
shopt -s histappend |
shopt -s globstar |