Skip to main content

Command Palette

Search for a command to run...

Linux Commands - Basics | For Beginners

Updated
3 min read
Linux Commands - Basics | For Beginners
I

I am Indraneel Chakraborty - a recovering Bioinformatician in love with Technology, Data Science and DevOps. Solving problems (not limited to Bioinformatics) with code-first, data-centric approaches on cloud architecture is my primary focus.

Currently, I'm working with Elucidata as a Bioinformatics Engineer, helping teams to scale up using advanced workflow management systems like Nextflow and cloud based solutions to effectively manage technological resources, thereby cutting costs and time taken in providing ML ready biomedical data. Other than these, I am also involved in development of webapps using R-Shiny (R programming) and Streamlit (Python).

Apart from my full time job, I also volunteer as an application creator at Streamlit, open source lesson maintainer at The Carpentries, technical reviewer at Packt Publications, Community member at Data Science Festival London and beta tester at Coursera.

Found my profile interesting? Lets talk!

Here's a beginner friendly thread on quickly getting started with the basic commands of Linux command terminal using Ubuntu and having some fun, of course!

1. Release details

image.png

  • There are several distributions of Linux (we call them distros)
  • Let's first check the details of the Linux release we are using.
  • We use the command lsb_release -a for this which gives the LSB (Linux Standard Base) information about our Linux distribution.
  • Read more here - https://en.wikipedia.org/wiki/Linux_Standard_Base and https://refspecs.linuxfoundation.org/lsb.shtml

2. User name

image.png

  • Now its time to check the user name.
  • The command whoami prints the effective user-id.
  • So, normally it would show the name you have assigned to your system, but when used sudo (Super User DO) command, it will show the user as root.

3. Print working directory

  • Now that we know who's who, let's also see where are we.
  • Basically, let's print the working directory.
  • Use the pwd command.
  • Refer to the GUI in the image to compare. image.png

4. List files in the directory

  • So what's present in the working/current directory?
  • We use ls command for that.
  • Can you notice the similarity between the CLI and GUI? image.png (says 'Cooool' internally)

5. List hidden files too!

  • Wait a minute! What about the hidden files?
  • On the GUI, we have an option to "show hidden files". How do we see them on the terminal?
  • Just use -a with ls and thou question shall be answered. image.png And yeah, @JohnWickMovie rocks! Big fan!

6. Change directory

  • It's now time for some action. Let us explore the folders and files present in our current working directory.
  • cd command allows you to change directory to the directory you want to access.
  • For folders not in current directory, use full path. image.png

7. Create file(s)

  • So we moved to Desktop and it's empty.
  • Let's create a text file here.
  • This can be done using the touch command. image.png The file.txt file is currently empty. We'll do something about it.

8. Write some text into an empty file

  • There are many ways to write/edit a file in the terminal.
  • For now, lets use echo and >.
  • echo basically prints what you feed to it.
  • The > operator will store the command value in the file mentioned. It will create the file if not present.
  • cat will print the file. image.png

  • Now, lets go back to where we started from - home directory.

  • This can be done using cd .. command. TIP - Every command (generally) has a help option. Try cd --help image.png

9. Linux File System

  • In Linux, EVERYTHING is a file. Even a command.
  • You can find the location of any command using which - which is also a command!

image.png

  • After that you can also print the whole file. Lets try this with ls.

  • So, if we could do the above, can we modify the command file too? (Classic Prank Idea)

  • Lets rename "ls" to "ls1" and see the action - Needs root permission.

Spoiler alert - it works! image.png

  • Now lets revert the changes (coders are good human beings)

image.png

  • Notice that the directory has many other command files too, which we explored earlier. For example - touch, cat, pwd.

Finish

That's all for now, folks. Let me know if you found this helpful. Also feel free to add your inputs too!

image.png

Chapter 2 coming soon...