0 1 0 1 0 1 0 1 0 1 0 1 0 1 0 1 0 1 0 1 0 1 0 1 0 1 0 1 0 1 0 1 0 1 0 1 0 1 0 1 0 1 0 1 0 1 0 1 0 1 0 1 0 1 0 1 0 1 0 1 0 1 0 1 0 1 0 1 0 1 0 1 0 1 0 1 0 1 0 1 0 1 0 1 0 1 0 1 0 1 0 1 0 1 0 1 0 1 0 1 0 1 0 1 0 1 0 1 0 1 0 1 0 1 0 1 0 1 0 1 0 1 0 1 0 1 0 1 0 1 0 1 0 1 0 1 0 1 0 1
JPPINTO
  • Home
  • Blog
  • Certifications
  • About
  • Contact
  • Shop
  • Gallery
  • Current Setup
Contact

Search

July 3, 2026 / Linux, Servers, Ubuntu

How to Use Alias in Linux and Ubuntu

Tags: alias, bash, command line, linux, terminal, ubuntu
Featured image for How to Use Alias in Linux and Ubuntu

An alias in Linux or Ubuntu is a shortcut for a command. It lets you type a short command and have the shell run a longer command for you.

For example, if you often run ls -l to see a detailed file listing, you can make ls run ls -l --color=auto instead. This saves typing and makes common terminal work faster.

Aliases are especially useful for commands you run every day, such as directory listings, server checks, log viewing, Git commands, and script folders.

Check the Current Folder

Start by moving into a folder and listing its files.

This example uses a sample server script folder:

cd /srv/admin/scripts/site-tools
ls

Example output:

Check-Backups.sh  Server-Inventory.sh

The normal ls command shows the file names, but it does not show details such as permissions, owner, file size, or modified date.

Run `ls -l` Manually

To see the long listing format, run:

ls -l

Example output:

total 20
-rwxrwxr-x 1 admin admin  4569 Jul  2 00:41 Check-Backups.sh
-rwxrwxr-x 1 admin admin 11641 Jul  2 00:41 Server-Inventory.sh

This output shows more useful information:

  • File permissions, such as -rwxrwxr-x.
  • Number of links.
  • File owner and group.
  • File size.
  • Last modified date and time.
  • File name.

If you always want this detailed view, you can create an alias.

Create a Temporary Alias

Run this command:

alias ls='ls -l'

Now run:

ls

Example output:

total 20
-rwxrwxr-x 1 admin admin  4569 Jul  2 00:41 Check-Backups.sh
-rwxrwxr-x 1 admin admin 11641 Jul  2 00:41 Server-Inventory.sh

Now the short command ls runs ls -l.

This alias is temporary. It only works in the current terminal session. If you close the terminal or log out, the alias is gone.

Make the Alias Permanent

To keep the alias after logging out, add it to your ~/.bashrc file.

Use this command:

echo "alias ls='ls -l --color=auto'" >> ~/.bashrc

Then reload the file:

source ~/.bashrc

Now run:

ls

Example output:

total 20
-rwxrwxr-x 1 admin admin  4569 Jul  2 00:41 Check-Backups.sh
-rwxrwxr-x 1 admin admin 11641 Jul  2 00:41 Server-Inventory.sh

The --color=auto option keeps normal color output when your terminal supports it. This makes executable scripts, directories, and other file types easier to spot.

View Existing Aliases

To see all aliases currently loaded in your shell, run:

alias

To check one alias, run:

alias ls

Example output:

alias ls='ls -l --color=auto'

Remove an Alias

To remove an alias from the current terminal session, use unalias.

Example:

unalias ls

After that, ls goes back to its normal behavior for the current session.

If the alias is saved in ~/.bashrc, open that file and remove the alias line:

nano ~/.bashrc

Remove or comment out this line:

alias ls='ls -l --color=auto'

Then reload the file:

source ~/.bashrc

Useful Alias Examples

Here are a few common aliases for Linux and Ubuntu.

Show all files in long format:

alias ll='ls -la --color=auto'

Show disk space in human-readable format:

alias dfh='df -h'

Show folder sizes in the current directory:

alias duh='du -h --max-depth=1'

Clear the terminal:

alias c='clear'

Go up one directory:

alias ..='cd ..'

View recent system logs on systems that use journalctl:

alias logs='journalctl -xe'

Edit `.bashrc` Directly

If you plan to add several aliases, it is cleaner to edit ~/.bashrc directly:

nano ~/.bashrc

Add your aliases near the bottom:

alias ls='ls -l --color=auto'
alias ll='ls -la --color=auto'
alias dfh='df -h'
alias c='clear'

Save the file, then reload it:

source ~/.bashrc

You do not need to reboot. Reloading ~/.bashrc applies the aliases to the current terminal.

Important Notes

  • Aliases only affect the shell where they are loaded.
  • A temporary alias disappears when you close the terminal.
  • A permanent alias should be saved in ~/.bashrc.
  • Use quotes around the command when creating an alias.
  • Be careful when aliasing common commands such as rm, cp, mv, or ls.
  • If an alias does not work, run source ~/.bashrc or open a new terminal.

Quick Reference

Create a temporary alias:

alias ls='ls -l'

Make it permanent:

echo "alias ls='ls -l --color=auto'" >> ~/.bashrc
source ~/.bashrc

Check the alias:

alias ls

Remove it from the current session:

unalias ls

Aliases are a simple way to make Linux and Ubuntu commands faster, shorter, and easier to remember. Once you start using them for repeated commands, the terminal feels much more comfortable.

Post Views: 27
<- Install Ubuntu Server 26.04 LTS Step by Step for Beginners
Fix Windows Line Endings and Make Shell Scripts Executable in Linux ->

Categories

  • Active Directory (5)
  • AI (2)
  • Amazon Cloud Services (1)
  • Blazor (1)
  • C# (C-Sharp) (3)
  • CI/CD Pipelines (1)
  • Containers (4)
  • Deployment (2)
  • Development (4)
  • Docker (3)
  • General (5)
  • IIS 6.0 (4)
  • IIS 7.0 (10)
  • IIS 8.0 (1)
  • Infrastructure as Code (IaC) (1)
  • Kubernetes (3)
  • Linux (8)
  • Microsoft 365 (2)
  • MySQL (1)
  • Office 2010 (1)
  • PHP (1)
  • PowerShell (7)
  • Productivity (1)
  • Servers (8)
  • SharePoint 2007 (8)
  • SharePoint 2010 (19)
  • SharePoint 2013 (2)
  • SharePoint Online (1)
  • SMTP (4)
  • SQL Server 2008 (1)
  • SQL Server 2008 R2 (1)
  • SQL Server 2012 (2)
  • SQL Server 2019 (1)
  • Ubuntu (8)
  • Uncategorized (1)
  • URL Rewrite (2)
  • Visual Studio 2019 (1)
  • Visual Studio Code (1)
  • Windows 10 (5)
  • Windows 2003 (9)
  • Windows 2008 (18)
  • Windows 2012 (6)
  • Windows 7 (3)
  • Windows Firewall (1)
  • Windows Vista (1)
  • WordPress (3)
  • WP-CLI (3)

Recent Posts

  • Create an Nginx Default Catch-All Site on Ubuntu
  • Install and Configure Redis on Ubuntu for Local Object Cache
  • Install and Configure MySQL on Ubuntu for WordPress
  • Install PHP-FPM and Common PHP Extensions on Ubuntu
  • Install and Tune Nginx on Ubuntu for Web Hosting

Advertisement

Tags

ai coding agents bash developer workflow dev to production exe permissions externalize blob externalize sharepoint data filezilla server firewall rules filazilla full installation http redirect https https redirect IIS iis7 iis 7 installation IIS installation index server configuration installing cumulative updates linux load balance central administration microsoft 365 nginx nlb powerpoint powershell redirect http to https server setup sharepoint 2010 cumulative updates sharepoint 2010 farm build sharepoint 2010 farm configuration sharepoint 2010 farm installation sharepoint data externalization SMTP storagepoint ubuntu web server windows Windows 7 windows firewall configuration windows server 2008 wlbs wordpress wp-cli x86
© 2026 JPPinto.com. All rights reserved.