I went for a technical interview yesterday, 1st Oct 2019 and I was asked a question, to name a Linux command for each of the alphabets a to z. I thought the question was brilliant and no one had ever asked me that ever before. At the same time it got me wondering, is there a Linux command starting with every alphabet ?
My immediate thought was, will I remember the alphabets while I start wracking my brains to list one by one 26 different commands.
So this post is dedicated to my interviewer, ‘Matt’ who works for a very large media company. Among all the interviews I have done, his questions were truly thought provoking!
Here we go, I will list my answer, my mistakes and also some of the more commonly used commands. This is not a complete list so feel free to leave me a comment to add commands to this post which you feel are commonly used.
I work with Ubuntu the most, so the first thing that came to my mind was apt and that is what I answered. Having said it, I realized that apt is Ubuntu/Debian specific, but there was no going back. It was already out there.
- alias – To set a shortcut for a commonly used command.
- at – To execute commands at a later time using /bin/sh.
- awk – Pattern scanning and processing language.
My answer was bzip2 which I have used to compress files.
- bash – Start a new Bourne Again Shell.
At this point my brain was already spinning out of control. I was thinking of words and characters and I blurted count thinking of wc. Sadly there is no count command but there are so many other commands that I could have said. Of all the alphabets this should have been the easiest one. It was a ‘Brain Freeze’ moment.
- cat – Concatenate and print the contents of a file.
- cd – Change directory.
- chgrp – Change group ownership of a file or directory.
- chmod – Change file mode bits.
- chown – Change file owner and group.
- clear – Clear the terminal screen.
- cp – Copy one or more files.
My answer was dd used to convert and copy a file. Here are some other commands that I think are very common.
- df – Display free disk space.
- diff – Display the differences between two files.
- du – Report the amount of disk space used by the specified files and for each subdirectory.
My answer was egrep which is used to search for lines that match an extended expression
- env – Display, set, or remove environment variables, Run a command in a modified environment.
- export – Set an environment variable.
My answer was find which is very common and I have a post covering some examples for the find command.
- file – Determine file type.
- flock – I use this a lot in my scripts. I have a post on the usage of flock.
- free – Display amount of free and used memory.
- fsck – Filesystem consistency check and interactive repair.
My answer here was grep used to search files for text.
- gzip – Compress or decompress files.
I answered htop which is not installed by default. I should have said
At this point Matt asked me to stop and said that he does not usually let the interviewee go all the way up to the alphabet z. However, if you are still interested let us keep going all the way to z.
- ifconfig – Used to configure network interface.
- ip – Show / manipulate routing, devices, policy routing and tunnels.
- kill – Send a specified signal to a process.
- less – Paging through text forward or backward one screen full at a time.
- link – Make hard or soft links.
- ls – List information about files.
- lsblk – List block devices.
- lsof – List open files.
- mkdir – Make a new directory.
- more – for paging through text one screen full at a time .
- mount – Mount a file system.
- mv – Move or rename files or directories.
- netstat – Show network connections. I have started using ‘ss’ though.
- nice – Set the priority of a process.
- nohup – Run a command immune to hangups.
Ok for the alphabet ‘O’ I could not come up with any command that i use regularly.
- pgrep – List process by name.
- pkill – Kill process by name.
- ps – process list/status.
- pwd – Print working directory.
Same as ‘O’. Nothing that I use regularly.
- shutdown – Shutdown or restart server.
- sleep – Delay for a specified time.
- sort – sort files.
- ss – Connection Statistics. See practical examples here.
- stat – Display file or file system status.
- sudo – Execute command as another user.
- tail – Print tail end of file.
- tar – Store, list or extract files from an an archive.
- tee – Redirect output to multiple files.
- touch – Change timestamp of a file.
- traceroute – Trace route.
- tr – Translate, squeeze, and/or delete characters.
- vmstat – Print virtual memory statistics.
Finally the wc that I was thinking about ‘c’.
- wc – Print byte, word or line count.
- which – Search the user’s path for a executable program.
- whoami – Print current username and id.
Same as ‘O’ and ‘Q’. Nothing that I use regularly.
- zip – Compress or decompress files.
I could not come up with commonly used commands for the alphabets ‘O’, ‘Q’ and ‘Y’, but for all other there are quite a few commands that are used often or daily.
Please free to comment and let me know if I should add any command that you feel is commonly used.