New to AWS, custom bash aliases and functions not working

Let me explain. I’m using the t2.micro instance (Debian), and I just cloned my git repository containing the customisations that I do for every workstation. You can find these functions and aliases here. The thing is, when I source these files in my .bashrc and then try to use the aliases (defined in .bash_aliases), I can use only some of them.

What I mean is, when I run alias on the command line, this is the output:

alias cl='clear && printf "%s\n\n" "/home/admin" && ls -apF && printf "\n" && find . -maxdepth 1 | wc -l'
alias dc='cd'
alias l='clear && ls -apF --color=auto'
alias la='ls -alt'
alias ls='ls --color=auto'
alias mst='cd /home/admin/git-repos/workstation-dotfiles && git status -sb'
alias sl='ls'
alias sob='clear && source ~/.bashrc'

Whereas, the .bash_aliases file contains ~50 lines of aliases. I wonder why only a few aliases from the file are getting sourced while the others aren’t.

I’ll leave my .bash_aliases file here

A Linux distribution running on EC2 is the same as if it were running anywhere else.

Which Debian AMI are you using? Is it official or one that some third party created and made public? There are multiple bash like shells available. Some are used because they are lightweight, but they have subtle incompatibilities. Debian uses dash as the default non-interactive shell, and since you are probably using a minimalist AMI, the preparers might not include bash. Check to see which shell you are actually using to make sure it is bash as well as the version.

Not sure what your issue is but a few things I noticed:

The cl in your repo uses double quotes but the version here uses single quotes. The repo version looks like it would have quoting issues.

Your longer aliases might be more readable as functions.

Triple quotes let you do multiline strings as well as use single and double quotes within. Cuts down on quoting issues.

I believe I’m using the official one. I have tried these aliases and functions on a debian VM as well as a debian container on WSL2. Everything seems fine there.

Also, this is not related, but when I ssh from my computer into the VM, everything lags a bit. From the commands, to writing/deleting text, etc. Do you know why this is happening?

I’d like to make an AWS ec2 as my ideal workstation, but this was not a good start :frowning:

I’ll do that then. I’m not very good at escaping quotes which is where this problem might have come from. I’ll convert them into functions and check. Thanks.

You can see which shell you are using with the ps -p $$ command. Make sure it really is bash. If not, make sure you have bash installed and you can change your user’s default shell with chsh.

For interactive sessions you should make sure you are using the closest AWS region to where you connect from. The larger the distance the higher the latency. If the latency is still too high, try Mosh.

What are you going to run on your EC2 workstation? There may be easier options than using EC2 directly. Cloud9, for example, is a browser based IDE that runs on top of EC2. It automatically starts and stops your instance so you only pay for when you’re using it. If you’re going to run any graphical applications, AWS Workspaces has a Linux option that also starts and stops automatically to save you money.

Thanks a lot. I have solved my problem of not all aliases showing by changing a few to functions. Seems like I wasn’t escaping quotes properly.

I still haven’t found a solution for latency, but it’s a bit weird: I have a decent Internet connection speed (350 mbps), although yes your idea about the regions is probably right. I’ll try that.