Skip to content
Home » Blog » 12 Basic Linux Commands now in a Simple Version

12 Basic Linux Commands now in a Simple Version

About Linux Basic Commands

In Linux, it’s recommended to use a command-line interface (CLI) because it’s more powerful and effective. Tasks that require a multi-step process through GUI can be done in a matter of seconds by typing commands into the CLI. If you don’t have experience in using the Linux Command line you probably might not know about the basic Linux Commands, and guess what? We’ve got you covered!

So if you’re considering using Linux, learning basic command lines will go a long way. Today, you’ll learn 12 Linux commands, all totally basic, that will undoubtedly help you navigate through Linux as a newbie.

Basic Linux Commands

Before we get started, we suggest you to keep you Command-Line open and run the lines side-by-side to get a better understanding of the commands we list here.

Hope you’re ready, now let’s dive in!

1. ls [Lists all the Directories and Files]

The ls command Lists all the Directories within that file. By default, this command will display the contents of your current working directory.

If you want it to display all the files within another directory without opening it, you should run ls <directory name>

There are variations you can use with the ls command:

  • The ls -R command will list all the files in the sub-directories as well.
  • ls -a will show all the hidden files
  • ls -al will list the files and directories with detailed information like the permissions, size, owner, etc.
ls

2. clear [Clears the Command-Line]

clear

Running the clear command would Clear the Command-Line

3. cd [Navigates through Directories]

The cd command is one of the most run commands on the command-line. It helps you to navigate through and out of directories.

Here I wanted to navigate to a Directory named Documents, so I used the command cd Documents.

There are some shortcuts to help you navigate quickly:

  • cd .. to move one directory up
  • cd to go straight to the home folder
  • cd- to move to your previous directory
cd <Directory Name>

4. mkdir [Create a new Directory/Folder]

Linux Basic Commands

The mkdir, or the Make Directory command creates a new Folder in the current Directory

You must also type in the name that you want to give to your directory along with the command. For that, you must run your command like this: mkdir <directory name>

There are variations you can use with the mkdir command:

  • If you want to create a Directory inside another, you can type something like this: mkdir Music/Pop, where Pop will be the new folder created.
  • You can use mkdir -p Music/New/Pop where New will be the new folder created, which will contain the Pop Directory and all its items.
mkdir <Directory Name>

5. rmdir [Remove Empty Directory/Folder]

rmdir removes the specified Directory, however, this command works only for a Empty Directory.

rmdir <Empty Directory Name>

6. rm [Removes a Directory and all the Contents inside it]

The rm command is deletes all the contents along with the Directory Specified. If you only want to delete the directory — use rm -r.

rm <Directory name>

Warning

Double – check whether you are in the directory you want, since this deletes all the items inside it, there is no Undo

7. touch [Create a file]

The touch command Creates a new file, for example, txt, py, html, xlsx and more. By default, this command will create the file on your current working directory.

If you want it to create a file within another directory without opening it, you should run touch <directory name>/<file name with extension>, For Example, touch Python/code.py

touch file.txt

8. pwd [Shows Location of Current Directory]

Linux Basic Commands

The pwd command displays the location of your current directory, or in other words, the path of the directory you are working in.

pwd

9. cat [Catenates Files and stores in a new File]

It is used to list the contents of a file on the standard output. To run this command, type cat followed by the file’s name and its extension. For instance: cat file.txt.

If you want it to display all the files within another directory without opening it, you should run ls <directory name>

There are variations you can use with the cat command:

  • cat > filename creates a new file
  • cat filename1 filename2>filename3 joins two files (1 and 2) and stores the output of them in a new file (3)
  • To convert a file to upper or lower case use, cat filename | tr a-z A-Z >output.txt
cat > file.txt

10. head [View first few lines of any text file]

Linux Basic Commands

The head command is used to view the first lines of any text file. By default, it will show the first ten lines.

head note.txt

11. tail [View last few lines of any text file]

Linux Basic Commands

The tail command is used to view the last lines of any text file. By default, it will show the last ten lines.

tail note.txt

12. diff [Compares the Contents of two files line by line]

Linux Basic Commands

The diff command compares the contents of two files line by line. After analyzing the files, it will output the lines that do not match.

diff note.txt note2.txt

In closing, Linux Basic Commands

In today’s post, we’ve discussed 12 Linux commands that will sure come in handy while working on the Command-line. If you are on your way to becoming a Linux Geek, you might find our site really helpful. Hit this link for more Linux related posts
Check it out, it’s Simply the Best Code.

Leave a Reply

Your email address will not be published. Required fields are marked *