您需要通过 .bash_profile 或 kubuntu .profile 添加自定义别名
sudo 进入 root 并使用您选择的文本编辑器。我更喜欢 vi 但你可以使用 nano!
sudo -i
root@server vi .profile
默认情况下,您的个人资料应如下所示
if [ "$BASH" ]; then
if [ -f ~/.bashrc ]; then
. ~/.bashrc
fi
fi
mesg n
所以现在添加一个别名。你可以为你的别名命名任何东西!这是我使用的 .profile 的自定义别名。我在旧金山工作,住在奥克兰,所以天气可能会略有不同,所以我创建了一个自定义别名来为天气卷曲
alias weatherSF="curl -s 'http://rss.accuweather.com/rss/liveweather_rss.asp?metric=1&locCode=en|us|san-francisco-ca|94103' | sed -n '/Currently:/ s/.*: \(.*\): \([0-9]*\)\([CF]\).*/\2°\3, \1/p'"
alias weatherOak="curl -s 'http://rss.accuweather.com/rss/liveweather_rss.asp?metric=1&locCode=en|us|Oakland-ca|94612' | sed -n '/Currently:/ s/.*: \(.*\): \([0-9]*\)\([CF]\).*/\2°\3, \1/p'"
现在请注意,如果您尝试使用标签,它不会起作用..所以您需要做的是
source ~/.profile
在来源之后,您应该能够标记您的新别名!
如果您对其他别名感兴趣,这里有一些其他示例
alias myip='curl ip.appspot.com' # myip: Public facing IP Address
alias netCons='lsof -i' # netCons: Show all open TCP/IP sockets
alias flushDNS='dscacheutil -flushcache' # flushDNS: Flush out the DNS Cache
alias lsock='sudo /usr/sbin/lsof -i -P' # lsock: Display open sockets
alias lsockU='sudo /usr/sbin/lsof -nP | grep UDP' # lsockU: Display only open UDP sockets
alias lsockT='sudo /usr/sbin/lsof -nP | grep TCP' # lsockT: Display only open TCP sockets
alias ipInfo0='ipconfig getpacket en0' # ipInfo0: Get info on connections for en0
alias ipInfo1='ipconfig getpacket en1' # ipInfo1: Get info on connections for en1
alias openPorts='sudo lsof -i | grep LISTEN' # openPorts: All listening connections
alias showBlocked='sudo ipfw list' # showBlocked: All ipfw rules inc/ blocked IPs
check this website for some tips