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
- 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 -afor this which gives the LSB (Linux Standard Base) information about our Linux distribution.
- Read more here - en.wikipedia.org/wiki/Linux_Standard_Base and refspecs.linuxfoundation.org/lsb.shtml
2. User name
- Now its time to check the user name.
- The command
whoamiprints 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
- Refer to the GUI in the image to compare.
4. List files in the directory
- So what's present in the working/current directory?
- We use
lscommand for that.
- Can you notice the similarity between the CLI and GUI? (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
lsand thou question shall be answered. 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.
cdcommand allows you to change directory to the directory you want to access.
- For folders not in current directory, use full path.
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
file.txtfile 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
echobasically prints what you feed to it.
>operator will store the command value in the file mentioned. It will create the file if not present.
catwill print the file.
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
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!
After that you can also print the whole file. Lets try this with
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!
- Now lets revert the changes (coders are good human beings)
- Notice that the directory has many other command files too, which we explored earlier. For example - touch, cat, pwd.
That's all for now, folks. Let me know if you found this helpful. Also feel free to add your inputs too!
Chapter 2 coming soon...