The Linux command line (CL) is a wonderful tool, that gives you power beyond normal point-and-click. With it you can unleash the full force of the open-source operating system for any purpose. Yet many new comers shy away from using it.
Though it can seem daunting and intimidating at first, looking more like a no-go area for noobs. But the more you come to know about and use it, you’ll realize that the CL is beginner-friendly and interesting to work with.
To begin this journey lets see some common and powerful commands that should be familiar with like the back of your hands.
#1: cd.
This is one of the most used Linux command of all. The cd (change directory) command is used to transverse the file system – moving from one place (directory I mean) to another. On login in to Linux you’re taken to your home directory (/home/your_username) by default.
To change to another directory simply enter: cd directory_name.
You can see here that I navigated to the desktop.
And also you can to just specify an absolute directory path and fly to the location straight-away instead of some numerous steps of cd-ing.
Here instead of typing about three or four cd commands I used only one with the directory location.
To return to your home directory from anywhere, you can easily combine the cd command with the tilde (~) symbol like this: cd ~
To return to one directory-level up, combine cd with two dots (..): cd ..
#2: ls
The ls (list) command is used to list files in a directory.
Entering the command would return the list of all the files and (sub)directories in your present location. If combined with a directory path, the files and sub-directories in that path are returned.
There two very useful options that can be used with the ls command are:
– a → to list all files (including the hidden files and sub-directories).
– l → to list the details (like file/directory size, date and time of modification, permissions, creator) of files and sub-directories.
And they can be combined like this: ls -al
You can always combine the ls and cd commands to get to any directory of your choice on the file system.
#3: touch
The touch command is used to create a file. It can be used to create any type of file, by simply adding the extension of the file you want. If the extension is not added a normal text (.txt) is created – which is the default.
For instance to create a JavaScript (.js) file in your current directory location, simply enter: touch helloWorld.js
The “helloWorld” is the name of the file and the “.js” is the file extension (i.e. showing that it is a JavaScript file). Adding “.php” creates a PHP file; adding “.html” creates an HTML file and so on.
#4: mkdir
The mkdir (make directory) command, as it names signifies, is used to make directories. This is similar to to right-clicking with your mouse and choosing “New folder” in a graphics user interface (GUI). To use mkdir simply combine the command with the name of the directory you want to ceate: mkdir newDirectory.
This creates the “newDirectory” directory in your current location.
#5: pwd
With this command you could check your current directory location (or absolute path) by simply typing the pwd in the terminal.
#6: clear
The clear command is used to clear the terminal screen. After entering commands with verbose output, you can give yourself a clean slate using the clear command.
Wonderful right?
There are many useful Linux commands you will come across, but these ones above would definitely make your use of the terminal more effective. So play with them and see the magic!
Happy Linux’NG!
- Time complexity analysis: How to calculate running time - April 1, 2024
- Sovereign Tech Fund Invests €1M In GNOME’s Open-Source Project - November 19, 2023
- Google’s Bard AI: ChatGPT Rival or The Next Frontier in AI and NLP Technology - February 8, 2023