This Guide Lists the Available Commands From the ~/.bash_aliases File, with Short Usage Examples.
Latest Bash Aliases : Source
v1.1
- Reload and Edit Shell Configuration
- Clear and Exit
- Safer File Operations
- Disk Usage
- ls Shortcuts
- Navigation
- File Viewing
- Search and Find
- Disk and Directory Usage Helpers
- Process Management
- System Information
- Network
- Logs
- systemd Services
- Package Management
- Permissions and Ownership
- Archives
- Git Helpers
- Docker Helpers
- Nginx Helpers
- Apache Helpers
- Security and Firewall
- Environment Variables
- JSON Helpers
- Date and Time
- History
- Text Utilities
- File Safety Helpers
- Python Helpers
- Node.js Helpers
- Convenience
- Checks
- Built-in Help
- Common Practical Examples
- Donations
Reload the current Bash configuration.
source ~/.bashrc
Reload Bash configuration using the short alias.
reload
Reload Bash configuration using the alternative alias.
reloadbash
Open .bashrc for editing.
bashrc
Open .bash_aliases for editing.
aliases
Open .bash_aliases for editing using the alternative alias.
editaliases
Show the current .bash_aliases file.
showaliases
Clear the terminal screen.
c
Clear the terminal screen using the alternative alias.
cls
Exit the current shell session.
q
Exit the current shell session using the alternative alias.
quit
Copy a file with confirmation before overwrite.
cp source.txt target.txt
Move or rename a file with confirmation before overwrite.
mv oldname.txt newname.txt
Remove a file with confirmation before deletion.
rm file.txt
Run the original cp command without the alias.
\cp source.txt target.txt
Run the original mv command without the alias.
\mv oldname.txt newname.txt
Run the original rm command without the alias.
\rm file.txt
Create a directory and show what was created.
mkdir new-directory
Create nested directories and show what was created.
mkdir nested/path/example
Make a script executable.
chmodx script.sh
Show disk usage in human-readable format.
df
Show file or directory size in human-readable format.
du file-or-directory
Show total size of a directory.
du -sh directory-name
Show size of all items in the current directory.
du -sh ./*
List files in compact format.
l
List all files except . and ...
la
List files with details and type indicators.
ll
List all files with human-readable sizes.
lla
List files with human-readable sizes.
lh
List files sorted by modification time.
lt
List files sorted by modification time in reverse order.
ltr
List files sorted by size.
lsize
List directories only.
ldir
List regular files only.
lfiles
List hidden files only.
lhidden
Go up one directory.
..
Go up two directories.
...
Go up three directories.
....
Go up four directories.
.....
Go to the home directory.
home
Go to the root directory.
root
Go to /tmp.
tmp
Go to /opt.
opt
Go to /var.
var
Go to /var/log.
logdir
Go to /var/www.
www
Go to /etc.
etc
Go back to the previous directory.
back
Create a directory and enter it.
mkcd new-directory
Create a nested directory and enter it.
mkcd nested/path/example
Show a file with line numbers.
catn file.txt
View a file with less.
less file.txt
View a file using the more alias.
more file.txt
Show the first 20 lines of a file.
head20 file.txt
Show the first 50 lines of a file.
head50 file.txt
Show the last 20 lines of a file.
tail20 file.txt
Show the last 50 lines of a file.
tail50 file.txt
Follow a log file in real time.
tailf file.log
Follow a log file in real time and show the last 100 lines first.
tailf100 file.log
View a file with numbered lines through less.
viewn file.txt
Search inside a file with colored output.
grep "text" file.txt
Search recursively from the current directory.
grep -R "text" .
Search with extended regular expressions.
egrep "pattern" file.txt
Search for a fixed literal string.
fgrep "literal-text" file.txt
Search recursively for text in the current directory.
search "text"
Search recursively for text in a specific path.
search "text" /path/to/search
Find files or directories by name in the current directory.
findname "filename"
Find files or directories by name in a specific path.
findname "filename" /path/to/search
Find files by extension in the current directory.
findext "log"
Find files by extension in a specific path.
findext "php" /var/www
Find files larger than 100 MB in the current directory.
bigfiles
Find files larger than 100 MB in a specific path.
bigfiles /var/log
Find files larger than a custom size.
bigfiles /var/www 50M
Find very large files under root.
bigfiles / 500M
Find files modified in the last 1 day.
recent
Find files modified in the last 1 day in a specific path.
recent /var/www
Find files modified in the last 7 days in a specific path.
recent /var/www 7
Show block devices with size, filesystem, mountpoint, and model.
disks
Show mounted filesystems in table format.
mounts
Show size of items in the current directory.
usage
Show size of all files and directories recursively.
usageall
Show top-level directory sizes.
topdirs
Show free disk space and filesystem type.
freespace
Show largest directories in the current path.
bigdirs
Show largest directories in a specific path.
bigdirs /var
Show largest directories under a website path.
bigdirs /var/www
Search running processes by name.
psg nginx
Search running PHP processes.
psg php
Search running SSH processes.
psg ssh
Show listening ports and related processes.
ports
Show listening ports using the alternative alias.
listen
Show top processes by memory usage.
processes
Show top memory-consuming processes.
topmem
Show top CPU-consuming processes.
topcpu
Kill processes by name.
killname process-name
Kill nginx processes by name.
killname nginx
Kill PHP processes by name.
killname php
Show process tree.
pst
Show general system information.
sysinfo
Show operating system information.
osinfo
Show kernel version.
kernel
Show uptime.
uptimeinfo
Show memory usage.
meminfo
Show CPU information.
cpuinfo
Show IP addresses.
ipinfo
Show routing table.
routeinfo
Show hostname and system identity information.
hostnameinfo
Show a quick system status overview.
status
Show public IP address.
myip
Show public IP address using an alternative service.
myip2
Show the first local IP address.
localip
Flush DNS resolver cache when supported.
flushdns
Show HTTP headers for a URL.
headers https://example.com
Show HTTP headers for a URL path.
headers https://example.com/path
Show only the HTTP status code for a URL.
httpcode https://example.com
Show only the HTTP status code for a URL path.
httpcode https://example.com/path
Check if a TCP port is open.
portcheck example.com 80
Check if HTTPS port is open.
portcheck example.com 443
Check if local SSH port is open.
portcheck 127.0.0.1 22
Run a full DNS lookup.
dns example.com
Show A records.
dnsa example.com
Show CNAME records.
dnscname www.example.com
Show TXT records.
dnstxt example.com
Show common DNS records together.
dnsall example.com
Go to /var/log and list log files.
logs
Follow syslog.
syslog
Follow authentication log.
authlog
Follow kernel log.
kernlog
Show recent systemd journal errors and context.
jctl
Follow systemd journal in real time.
jctlf
Show logs from the current boot.
jboot
Show errors from the current boot.
jerr
Show recent logs for a service.
slog nginx
Show recent logs for Apache.
slog apache2
Show recent logs for SSH.
slog ssh
Show recent logs for Docker.
slog docker
Follow logs for a service.
slogf nginx
Follow Apache logs.
slogf apache2
Follow SSH logs.
slogf ssh
Follow Docker logs.
slogf docker
List running services.
services
Show failed services.
failed
Show all systemd timers.
timers
Show status of a service.
sstatus nginx
Show status of Apache.
sstatus apache2
Show status of SSH.
sstatus ssh
Show status of Docker.
sstatus docker
Start a service.
sstart nginx
Start Apache.
sstart apache2
Start SSH.
sstart ssh
Start Docker.
sstart docker
Stop a service.
sstop nginx
Stop Apache.
sstop apache2
Stop SSH.
sstop ssh
Stop Docker.
sstop docker
Restart a service.
srestart nginx
Restart Apache.
srestart apache2
Restart SSH.
srestart ssh
Restart Docker.
srestart docker
Reload a service without full restart when supported.
sreload nginx
Reload Apache.
sreload apache2
Enable a service at boot.
senable nginx
Enable Apache at boot.
senable apache2
Enable SSH at boot.
senable ssh
Enable Docker at boot.
senable docker
Disable a service at boot.
sdisable nginx
Disable Apache at boot.
sdisable apache2
Disable Docker at boot.
sdisable docker
Update package indexes.
aptup
Update package indexes and upgrade packages.
aptug
Install one package.
aptin package-name
Install multiple packages.
aptin curl jq git unzip
Remove a package.
aptrm package-name
Purge a package and its configuration.
aptpurge package-name
Search for a package.
aptsearch package-name
Show package details.
aptshow package-name
Remove unused packages and clean package cache.
aptclean
Fix broken package dependencies.
aptfix
Show manually installed packages.
aptmanual
Install common useful terminal tools.
installtools
Show permissions, numeric mode, owner, group, and filename.
perms file.txt
Show permissions for a directory.
perms directory-name
Show owner and group of a file.
own file.txt
Show owner and group of a directory.
own directory-name
Change ownership of a file or directory to the current user.
chownme file-or-directory
Change ownership of a project directory to the current user.
chownme ./project
Set directories to 755 under the current path.
fixdirs755
Set directories to 755 under a specific path.
fixdirs755 /path/to/directory
Set files to 644 under the current path.
fixfiles644
Set files to 644 under a specific path.
fixfiles644 /path/to/directory
Extract a tar.gz archive.
extract archive.tar.gz
Extract a tar.bz2 archive.
extract archive.tar.bz2
Extract a tar.xz archive.
extract archive.tar.xz
Extract a tar archive.
extract archive.tar
Extract a zip archive.
extract archive.zip
Extract a gz file.
extract archive.gz
Extract a bz2 file.
extract archive.bz2
Extract an xz file.
extract archive.xz
Extract a 7z archive.
extract archive.7z
Create a tar.gz archive from a directory.
targz directory-name
Create a tar.gz archive from a file.
targz file-name
Create a zip archive from a directory.
zipdir directory-name
Run git directly through the short alias.
g status
Show Git status.
gs
Add one file to staging.
ga file.txt
Add all changes to staging.
gaa
Create a commit interactively.
gc
Create a commit with a message.
gcm "commit message"
Push commits.
gp
Pull latest changes.
gl
List local branches.
gb
List all branches.
gba
Checkout a branch.
gco branch-name
Create and checkout a new branch.
gcb new-branch-name
Show unstaged diff.
gd
Show staged diff.
gds
Show compact Git log graph.
glog
Stash current changes.
gstash
Apply the latest stash and remove it from stash list.
gstashp
Show Git repository root.
groot
Show running containers.
dps
Show all containers.
dpsa
Show Docker images.
di
Show logs for a container.
dlog container-name
Follow logs for a container.
dlogf container-name
Execute sh inside a container.
dexec container-name sh
Execute bash inside a container.
dexec container-name bash
Open sh inside a container.
dcsh container-name
Open bash inside a container.
dcbash container-name
Stop all running containers.
dstopall
Remove stopped containers.
drmstop
Prune unused Docker data.
dclean
Prune unused Docker data, images, and volumes.
dcleanall
Run docker compose directly through the short alias.
dc
Show docker compose containers.
dc ps
Show docker compose logs.
dc logs
Start docker compose stack in detached mode.
dcup
Stop docker compose stack.
dcdown
Restart docker compose stack.
dcrestart
Show docker compose logs.
dclogs
Follow docker compose logs.
dclogsf
Show docker compose service status.
dcps
Test Nginx configuration.
ngt
Reload Nginx.
ngr
Restart Nginx.
ngrestart
Show Nginx service status.
ngstatus
Show recent Nginx logs.
nglogs
Follow Nginx logs.
nglogsf
Print full Nginx configuration.
ngconf
Show Apache service status.
a2status
Restart Apache.
a2restart
Reload Apache.
a2reload
Show recent Apache logs.
a2logs
Follow Apache logs.
a2logsf
Show Apache virtual host configuration.
a2conf
Show UFW status with details.
ufws
Show UFW numbered rules.
ufwa
Show iptables rules.
iptableslist
Show nftables ruleset.
nftlist
Show recent failed SSH login attempts.
sshfailed
Show recent successful SSH logins.
sshaccepted
Show recent login history.
lastlogins
Show all environment variables.
envs
Show PATH entries line by line.
path
Print environment variables matching a pattern.
prtenv PATH
Print HOME environment variable.
prtenv HOME
Print USER environment variable.
prtenv USER
Print environment variables matching sensitive names.
prtenv "TOKEN|SECRET|PASSWORD|KEY"
Print environment variables matching sensitive names with values hidden.
prtenvs "TOKEN|SECRET|PASSWORD|KEY"
Print broader sensitive environment matches with values hidden.
prtenvs "API|TOKEN|SECRET|PASSWORD|PASS|KEY"
Check if a command exists.
has curl
Check if jq exists.
has jq
Check if git exists.
has git
Check if docker exists.
has docker
Check if nginx exists.
has nginx
Show command path.
cmdpath curl
Show jq command path.
cmdpath jq
Show git command path.
cmdpath git
Show docker command path.
cmdpath docker
Show nginx command path.
cmdpath nginx
Pretty-print JSON from stdin.
jqpretty < file.json
Pretty-print a JSON file.
json file.json
Show top-level JSON keys.
jsonkeys file.json
Pretty-print JSON using a pipe.
cat file.json | jqpretty
Show current local date and time.
now
Show current UTC date and time.
nowutc
Show current Unix timestamp.
timestamp
Show today's date.
today
Convert Unix timestamp to readable date.
fromts 1710000000
Show command history.
h
Search command history.
hg ssh
Search Docker commands in history.
hg docker
Search Nginx commands in history.
hg nginx
Search apt commands in history.
hg apt
Clear shell history.
hclear
Search history using a function.
histg ssh
Search Docker history using a function.
histg docker
Search Nginx history using a function.
histg nginx
Search apt history using a function.
histg apt
Count lines in a file.
lines file.txt
Sort lines and count duplicates.
cat file.txt | countdups
Remove blank lines from output.
cat file.txt | noblank
Trim trailing whitespace from a file.
trimspace file.txt
Create a timestamped backup of a file.
bak file.txt
Create a timestamped backup of a directory.
bak directory-name
Generate a random password.
randpass
Generate a random password with custom length.
randpass 32
Generate a longer random password.
randpass 64
Generate a random hex string.
randhex
Generate a random hex string with custom byte length.
randhex 16
Generate a longer random hex string.
randhex 32
Show Python version.
py --version
Run a Python script.
py script.py
Show pip version.
pip --version
Install a Python package.
pip install package-name
Install Python requirements.
pip install -r requirements.txt
Create a Python virtual environment in .venv.
venv
Activate the .venv virtual environment.
activate
Install Node.js dependencies.
ni
Install a Node.js package.
ni package-name
Run an npm script.
nr script-name
Run npm build script.
nr build
Run npm dev script.
nr dev
Run npm start script.
nr start
Start a Node.js project.
ns
Run Node.js tests.
nt
Print current path without a trailing newline.
pwdc
Copy current path to clipboard if xclip exists.
copypwd
Show all aliases.
aliaseslist
Show all shell functions.
functionslist
Show directory tree with depth 1.
tree1
Show directory tree with depth 2.
tree2
Show directory tree with depth 3.
tree3
Check whether common terminal tools are installed.
nettoolscheck
Show built-in help for all aliases and functions.
aliaseshelp
Show the current .bash_aliases file.
showaliases
Show quick system overview.
status
Show listening ports.
ports
Show top memory processes.
topmem
Show top CPU processes.
topcpu
Show largest directories under root.
bigdirs /
Show files larger than 500 MB under root.
bigfiles / 500M
Show files modified in /var/log during the last 2 days.
recent /var/log 2
Search for error text in /var/log.
search "error" /var/log
Show Nginx service status.
sstatus nginx
Show recent Nginx logs.
slog nginx
Follow Nginx logs.
slogf nginx
Show HTTP headers for a website.
headers https://example.com
Show HTTP status code for a website.
httpcode https://example.com
Show common DNS records for a domain.
dnsall example.com
Backup Nginx main configuration.
bak /etc/nginx/nginx.conf
Test Nginx configuration.
ngt
Reload Nginx after a successful test.
ngr
Show UFW firewall status.
ufws
Show failed SSH login attempts.
sshfailed
Show recent login history.
lastlogins
Show sensitive environment variable names with hidden values.
prtenvs "TOKEN|SECRET|PASSWORD|PASS|KEY"
Install common useful terminal tools.
installtools
Check whether useful terminal tools are installed.
nettoolscheck
Show the aliases help menu.
aliaseshelp
To directly support the author of this code source and provide encouragement, you can send your donations in Bitcoin to the following wallet address; this action will strengthen their motivation:
Bitcoin Wallet:
1MMDRZAcM6dzmdMUSV8pDdAPDFpwzve9Fc
If you do not provide support, using this code is still permitted without any issues, provided that you do not make any changes to it and preserve the author's name.