Quick startalias
Command, used to create a shortcut to another command
In general, always run the program with a set of options you like to use.
For example, takels
command. By default, it only prints very little information:
currently using-al
Option, it will print out more useful content, including file modification date, size, owner and permissions, and also list hidden files (files beginning with ".".
:
You can create a new command, for example I like to call itll
, This is an aliasls -al
.
You can do this in the following ways:
alias ll='ls -al'
Once you’re done, you can callll
Just like a regular UNIX command:
Call nowalias
The list without any options will list the defined aliases:
The alias will work until the terminal session is closed.
To make it permanent, you need to add it to the shell configuration, which may be~/.bashrc
or~/.profile
or~/.bash_profile
If you use the Bash shell, it depends on the use case.
If the command contains variables, be careful to use quotation marks: use double quotation marks to parse the variable when it is defined, and use single quotation marks to parse it when it is called. Those two are different:
alias lsthis="ls $PWD"
alias lscurrent='ls $PWD'
\$PWD is the current folder where the shell program is located. If you navigate to the new folder now,lscurrent
List the files in the new folder,lsthis
The files in the folder you were in when you defined the alias will still be listed.
This
alias
This command can be used in Linux, macOS, WSL and wherever you have a UNIX environment
Download mine for freeLinux Command Manual
More cli tutorials:
- Bash shell
- Introduction to Bash Shell Script
- Fish shell
- Shell, monitor file content
- How to exit Vim
- UNIX editor
- UNIX file system commands
- Unix Shell Tutorial
- How to set an alias in macOS or Linux Shell
- Homemade practical guide
- How to fix XCRUN invalid active developer path error in MacOS
- Getting Started
- Introduction to Linux
- How to find the process that is using the port
- Linux command: mkdir
- Linux command: cd
- Linux command: pwd
- Linux command: rmdir
- Linux command: ls
- Linux command: mv
- Linux command: cp
- Linux commands: less
- Linux command: tail
- Linux command: touch
- Linux command: cat
- Linux command: find
- Linux command: ln
- Linux command: ps
- Linux command: echo
- Linux command: top
- Linux command: kill
- Linux command: killall
- Linux command: alias
- Linux command: job
- Linux command: bg
- Linux command: fg
- Linux command: Type
- Linux command: where
- Linux command: whoami
- Linux command: who
- Linux command: clear
- Linux command: su
- Linux command: sudo
- Linux command: chown
- Linux command: chmod
- Linux command: passwd
- Linux command: open
- Linux command: wc
- Linux commands: history
- Linux command: du
- Linux command: umask
- Linux command: grep
- Linux command: man
- Linux command: uname
- Linux commands: sort
- Linux command: uniq
- Linux command: diff
- Linux command: nohup
- Linux command: df
- Linux command: xargs
- Linux command: gzip
- Linux command: gunzip
- Linux command: ping
- Linux command: traceroute
- Linux command: tar
- Linux command: export
- Linux command: crontab
- Linux command: dirname
- Linux command: base name
- Linux command: printenv
- Linux command: env
- A short guide to the ed editor
- vim short guide
- A brief guide to emacs
- A brief guide to Nano
- Linux, no space left on the device
- How to use Netcat