
🌐 이 글의 한국어 원문이 있습니다.한국어 원문 보기 →
How to Use 'alias' in pfSense
There are many kinds of shells used on Linux. Besides the well-known Bash, there are plain sh, csh, tcsh, and more.
pfSense is based on the FreeBSD operating system. FreeBSD is an open-source operating system that branched off from Unix in its early days, built for use in ‘network environments’. Even today, packages for network environments like FreeNAS and pfSense use FreeBSD as their operating system.
I wanted to use a separate alias file in the terminal, but I didn't know how and struggled with it. pfSense is designed so that you don't need to do ‘terminal’ work, thanks to its web user interface. But if, like me, you inevitably end up doing a lot of terminal work, you'll really miss aliases. In that case, registering and managing aliases can give you a very handy working environment.
pfSense uses the tcsh shell. So the alias command syntax is a little different too.
alias test "echo test sentence"In Bash, you put an equals sign (=) between the alias keyword and the command. But in tcsh, it's left out.
If you run ls -al in your user folder, you'll see a few files. There's profile, and there are init files for various shell environments like .cshrc, .tcshrc, and .shrc. Of these, the one that takes effect is .tcshrc.
[2.5.1-RELEASE][admin@pfsense]/root: vi .tcshrcAdd alias test "echo test" to the file, log out, and connect again. Then if you run the alias command, you should see the test alias you set.
If you want to manage aliases in a separate file, just specify the alias file path in .tcshrc as shown below.
source ~/.tcsh_aliasesThen save your command shortcut keywords in that file.
set alias_file="~/.tcsh_aliases"
unalias *
alias vialias "vi $alias_file; source $alias_file"
alias main_server "ssh user@main_server.local"
alias public_key "cat ~/.ssh/id_rsa.pub"In my case, as shown above, I use the vialias keyword so I can edit the alias file at any time. In the command above, after editing in vi, the source $alias_file command immediately reloads the modified commands. When reloading, you need to include unalias * so that any keywords you deleted from your previous settings are reflected.


