What happens with ls *.c on Linux?

Wiston Venera Macías
2 min readSep 15, 2020

--

ls *.c may seem like a simple command to list all files and directories terminated in .c, but we need to be careful because maybe ls isn’t ls at all...

Today I’ve learned if I want to use a developer machine that isn’t mine, first of all, I have to check the aliases. Alias is a very useful tool when you need to save time. For example, you can store a command and its arguments, or aliasing “long” commands like xargs or history to one letter. For example alias x='xargs' or alias h='history'. In my case, I have the next alias alias ls='rm *' on my pc. For anyone who wants to use my pc and tries to list files/directories with the command ls, could end erasing all my files and directories of the current directory.

With that in mind, If I use ls *.c on my pc, I could erase every file terminated in .c located in the current directory. Aliases can be a good tool for people who want to protect their data. Aliasing the most used commands like pwd, whoami, ls, find, grep, inclusive the alias command, it can be very useful to secure your machine on a basic level. If the person who has access to your machine has enough experience, he or she will know how to bypass every alias. And it’s really easy, we just need to put a slash before the command we want to use, \pwd instead of pwd, or \ls instead of ls. For beginners like me, the most useful use for that command is for the git command git commit -m. alias gm='git commit -m'. With this alias, I save a lot of time doing commit every time I want to fix a task.

--

--