Linux Commands - Basics | For Beginners

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

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...