The Wayback Machine - https://web.archive.org/web/20241007061442/https://www.geeksforgeeks.org/basic-linux-commands/
Open In App

25 Basic Linux Commands For Beginners

Last Updated : 30 Aug, 2024
Summarize
Comments
Improve
Suggest changes
Like Article
Like
Save
Share
Report
News Follow

While performing a task, we all need shortcuts. Shortcuts help us to complete a task quickly. Linux comes with such commands which are one to two words, using that commands, you can perform several operations in no time. As a beginner, you must be aware of those basic Linux commands to complete an operation in a short time in the Linux-based operating system.

Basic Linux Commands

In this article, you’ll be going through some of the basic Linux commands which beginners can use to complete their tasks very quickly. Let’s go through each, but before that have a short idea on Linux.

What is Linux?

Linux is a free and open-source software that operates on its own operating system. The term ‘Linux’ stands for GNU + Linux. Initially developed by Linus Torvalds, it was created alongside the source code of Unix. While Linux is extensively utilized for various purposes, its applications are well-known to many.

Use of Linux Commands

Linux commands are a type of Unix command or shell procedure. They are the basic tools used to interact with Linux on an individual level. Linux commands are used to perform a variety of tasks, including displaying information about files and directories.

Linux operating system is used on servers, desktops, and maybe even your smartphone. It has a lot of command line tools that can be used for virtually everything on the system.

All users should be familiar with most of these commands as they are required for most operating system tasks and computer programming.

Here we have put all Basic Linux Commands that every Linux user (as a beginner) should know. These are not all that you should know, but these are the basic and most commonly used commands.

Basic Linux Terminal Commands

Linux Commands

Functions

Displays information about files in the current directory.
Displays the current working directory.
Creates a directory.
To navigate between different folders.
Removes empty directories from the directory lists.
Copy files from one directory to another.
Rename and Replace the files
Delete files
Command to get basic information about the OS
Find a file in the database.
Create empty files
Create shortcuts to other files
Display file contents on terminal
Clear terminal 
Display the processes in terminal
Access manual for all Linux commands
Search for a specific string in an output
Print string or text to the terminal
download files from the internet.
Displays the current users name
sort the file content
View Calendar in terminal
View the exact location of any command typed after this command
Check the details of the file system

Check the lines, word count, and characters in a file using different options

25 Most-Commonly Used Linux Commands

1. Is command in Linux

The ls command is commonly used to identify the files and directories in the working directory. This command is one of the many often-used Linux commands that you should know.

This command can be used by itself without any arguments and it will provide us the output with all the details about the files and the directories in the current working directory. There is a lot of flexibility offered by this command in terms of displaying data in the output. Check the below image for the output.

ls command in linux

2. pwd command in Linux

The pwd command is mostly used to print the current working directory on your terminal. It is also one of the most commonly used commands. 

Now, your terminal prompt should usually include the entire directory. If it doesn’t, this is a quick command to see which directory you’re in. Another purpose for this command is when creating scripts because it can help us find the directory in which the script was saved. The below pictures are the output with the command.

Command: 
 

pwd command in linux

Output:

output of pwd command in linux

3. mkdir command in Linux

This mkdir command allows you to create fresh directories in the terminal itself. The default syntax is mkdir <directory name> and the new directory will be created.

For example, if you want to create a directory as “GeeksforGeeks” then the basic syntax would be:

mkdir GeeksforGeeks

In case you want to create another directory inside the main directory GeeksforGeeks to store projects, you can use the following command to do so. mkdir GeeksforGeeks/projects

Command:

mkdir command in linux

Output:

output of mkdir command in linux

You can see we used ls first to see the directories present there and then mkdir to create another directory followed by ls to view the created directories.

4. cd command in Linux

The cd command is used to navigate between directories. It requires either the full path or the directory name, depending on your current working directory. If you run this command without any options, it will take you to your home folder. Keep in mind that it can only be executed by users with sudo privileges.

Command:
 

cd command in linux

Output:

output of cd command in linux

Here we used pwd to view the current directory for reference and then we used cd GeeksforGeeks to switch the directory and with again pwd command we can see the output is the switched directory, i.e – GeeksforGeeks

5. rmdir command in Linux

The rmdir command is used to delete permanently an empty directory. To perform this command the user running this command must be having sudo privileges in the parent directory. 

Command:
 

rmdir command in linux

Command to remove the directory

Output:

output of rmdir command in linux

Here we used the ls command to check the directories present there and used rmdir <directory name> to delete the directory and again the ls command to view the directories after deleting the same.

6. cp command in Linux

The cp command of Linux is equivalent to copy-paste and cut-paste in Windows. 

Command:

 

cp command in linux

Output:

output of cp command in linux

Here we used ls to view the files and then used cp to copy the files of first.txt to second.txt and again used ls command to view the updated files.

7. mv command in Linux

The mv command is generally used for renaming the files in Linux.

Command:

mv command in linux

Output: 

output of mv command in linux

Here we used the ls command to check the directories and then used mv <file name> <Renamed file name> to rename the files, and then again we used the ls command to view the renamed file as you can see in the output screenshot.

8. rm command in Linux

rm command in Linux is generally used to delete the files created in the directory. 

Command:

rm command in linux

Output:

output of rm command in linux

You can see as we wrote the ls command to view the files in the terminal and then rm <file name> to delete the files and again we had the ls command to check the update.

9. uname command in Linux

The uname command is used to check the complete OS information of the system. Check out the command and the output below

Command: 

uname command in linux

Output:

output of uname command in linux

10. locate command in Linux

The locate command is generally used to locate the files in the database. Use an asterisk (*) to search for content that contains two or more words. As an example: locate first*file. This command will search the database for the files that contain these two names first and file.

Command: 

locate command in linux

Output:

output of locate command in linux

We first used the rm command to delete the file and then used the locate command to find the file in the database which in return has given the output with a -e as the file was removed.

11. touch command in Linux

The touch command creates an empty file when put in the terminal in this format as touch <file name> 

Command: 

touch command in linux

Output: 

output of touch command in linux

We used the ls command to check the current directories in the terminal and then used the touch command to create an empty file and then again we used ls to find out the created file in the terminal.

12. ln command in Linux

The ln command is used to create a shortcut link to another file. This is among the most important Linux commands to know if you want to operate as a Linux administrator.

Command:

ln command in linux

Output:

output of ln command in linux

Here we used mkdir to create two directories and then we used ln with an -s to create a soft link in it.

13. cat command in Linux

The cat command is the simplest command to use when you want to see the contents of a particular file. The only issue is that it simply unloads the entire file to your terminal. If you want to navigate around a huge file, should use less command alternatively.

Command:

cat command in linux

Output:

output of cat command in linux

14. clear command in Linux

The clear command is a standard command to clear the terminal screen.

Command: *This was the terminal before the command.
 

clear command in linux

Output: 

output of clear command in linux

15. ps command in Linux

ps command in Linux is used to check the active processes in the terminal.

Command:

ps command in linux

Output:

output of ps command in linux

16. man command in Linux

The man command displays a user manual for any commands or utilities available in the Terminal, including their name, description, and options.

Command to view the full manual: 

man <command name>

For example, suppose you want to look up the manual for the ls command: man ls

Command:

man command in linux

Output: 

output of man command in linux

17. grep command in Linux

The grep command is used to find a specific string in a series of outputs. For example, if you want to find a string in a file, you can use the syntax: <Any command with output> | grep “<string to find> “

For Example:

cat Files.txt | grep “new”

Command: 

grep command in linux

Output: 

output of grep command in linux

In this command, we first used cat <file name> to view the content of the file, and then we used cat <file name> | grep “string” to check the string in it.

18. echo command in Linux

echo command in Linux is specially used to print something in the terminal

Command: 

echo command in linux

Output: 

output of echo command in linux

19. wget command in Linux

The wget command in the Linux command line allows you to download files from the internet. It runs in the background and does not interfere with other processes.

Here is the basic syntax: wget [option] [url]

Command: 

wget http://sample.com/sample-menu.php

wget command in linux

Output:

output of wget command in linux

20. whoami command in Linux

The whoami command provides basic information that is extremely useful when working on multiple systems. In general, if you are working with a single computer, you will not require it as frequently as a network administrator.
 

Command: 

whoami command in linux

Output: 

output of whoami command in linux

21. sort command in Linux

The sort command is used generally to sort the output of the file. Let’s use the command and see the output.

Command: (We are using the cat command to see the file content)

cat command in linux

Output: (The content of multiple.txt file in the terminal)

output of cat command in linux

Now we will sort the outcome using the sort command

Command:

sort command in linux

Output:

output of sort command in linux

Here first we checked the file content using the cat command and then we sorted it alphabetically using the sort command.

22. cal command in Linux

The cal command is not the most famous command in the terminal but it functions to view the calendar for a particular month in the terminal. Let’s see how this works.

Command: 

cal command in linux

Output: 

output of cal command in linux

23. whereis command in Linux

whereis command in Linux is generally used to see the exact location of any command typed after this. Let’s see how this performs.

Command:

whereis command in linux

Output: 

output of whereis command in Linux

24. df command in Linux

df command in Linux gets the details of the file system.

Command: 

df command in linux

Output: 

output of df command in linux

Here we have used df -h as simply typing df will return the output in bytes which is not readable, so we add -h to make the outputs more readable and understandable.

25. wc command in Linux

wc command in Linux indicates the number of words, characters, lines, etc using a set of options. 

  • wc -w shows the number of words
  • wc -l shows the number of lines
  • wc -m shows the number of characters present in a file

Let’s see one example of these options

Command: 

wc command in linux

Output: 

output of wc command in linux

Here we used the touch command to create a text file and then used the echo command to input a sentence that contains six words and we used the wc -w command to calculate the number of words in it.

Basic Linux Commands – FAQs

What are the most basic Linux Commands to learn for beginners?

Here is a list of 10 basic Linux Commands to learn for beginners, along with their functions.

Linux Commands

Functions

Is

Displays information about files in the current directory.

pwd

Displays the current working directory.

mkdir

Creates a directory.

cd

To navigate between different folders.

rmdir

Removes empty directories from the directory lists.

cp

Moves files from one directory to another.

mv

Rename and Replace the files

rm

Delete files 

uname

Command to get basic information about the OS

locate

Find a file in the database.

How do I view files in a Linux Directory?

To view files in a Linux directory, you should use the ‘ls’ command. It lists all files and directories in the current working directory. You can also use ‘ls -l’ to view detailed information about each file, including permissions, number of links, owner, group, size, and modification date.

What is the Command to Create a New File in Linux?

The command to create a new file in Linux is ‘touch’. For example, typing ‘touch filename.txt’ in the terminal will create an empty file named ‘filename.txt’. This command is handy for quickly creating new files without opening an editor.

How can I edit a file in Linux from the command line?

To edit a file in Linux from the command line, you can use text editors such as ‘nano’ or ‘vi’. For instance, typing ‘nano filename.txt’ will open the file in the Nano editor, allowing you to edit and save changes. ‘vi’ or ‘vim’ can be used similarly, though they have a different interface and command structure.

What is the Linux Command for changing file permissions?

The Linux command for changing file permissions is ‘chmod’. It allows you to set read, write, and execute permissions for the file owner, group, and others. For example, ‘chmod 755 filename’ sets read, write, and execute permissions for the owner, and read and execute permissions for the group and others.

Conclusion

We hope that this list of all Linux commands will assist you in getting started as a beginner. Learning basic Linux commands is crucial for beginners to efficiently use a Linux-based system. These commands act as handy shortcuts, helping users perform tasks quickly. From managing files and folders to finding system information, understanding these basic commands is essential. By starting with these simple commands, beginners can build a strong foundation for exploring more advanced features of Linux in the future.



Similar Reads

Basic CentOS Linux Commands in linux
CentOS is a free and open-source operating system that aims to provide a stable reliable, and community-supported platform for servers and other enterprise applications. In this article, we will be covering CentOS Linux basics commands and functions of CentOS and also we will look into the advanced commands. These CentOS commands allow you to manag
3 min read
Top 30 Basic NMAP Commands for Beginners
For a cybersecurity enthusiast or professional, mastering network scanning tools is very important to comprehend and assess the security position of networks and systems. Nmap, an influential and versatile Network Mapper, is the network reconnaissance and vulnerability detection go-to tool. As you begin your journey in ethical hacking or work towar
15 min read
Basic Shell Commands in Linux
A shell is a special user program that provides an interface to the user to use operating system services. Shell accepts human-readable commands from the user and converts them into something which the kernel can understand. It is a command language interpreter that executes commands read from input devices such as keyboards or from files. The shel
3 min read
Basic vi Commands
Text editors are essential tools for any programmer or computer enthusiast. One popular text editor that has been around for decades and is still widely used is vi (pronounced "vee-eye"). vi is a terminal-based text editor that offers powerful editing capabilities once you understand its basic commands. In this article, we will explore the fundamen
7 min read
25 basic Ubuntu Commands
Ubuntu is one of the most popular distributions of Linux, known for its user-friendly interface and robust features. Whether you're a beginner or an experienced user, understanding basic Ubuntu commands is essential for navigating and managing your system efficiently. In this article, we'll explore 25 fundamental Ubuntu commands along with detailed
5 min read
Basic Vim Commands
In this article, we will cover some basic commands in the Vim editor. First, we look at what Linux and VIM editors are and why we use them, followed by basic commands in Vim editor starting from creating/editing a file, different modes, quitting the editor, saving the changes to the file, navigation in the editor, deleting lines, displaying and hid
5 min read
Redux - Basic Understanding of the Concepts for Beginners
Redux is one of the most confusing and probably difficult topics for someone who is trying to learn it from scratch. But why?? Are the number of boilerplates or the terminologies in Redux the reasons that turned you off from learning it? You are searching for a Redux guide, you read some blogs/tutorials, and you watch some YouTube videos but things
15+ min read
Internal and External Commands in Linux
The UNIX system is command-based i.e things happen because of the commands that you key in. All UNIX commands are seldom more than four characters long. They are grouped into two categories: Internal Commands : Commands which are built into the shell. For all the shell built-in commands, execution of the same is fast in the sense that the shell doe
4 min read
Useful and time saving bash commands in Linux
There are many useful bash scripts that can make things easier. Many things can be done just using the terminal. Here is a list of some of such useful bash scripts through which we can do things that cannot be done manually. 1. Counting the number of files(or directory) in a given directory: Go to the directory in which you want to count the number
3 min read
Process Control Commands in Unix/Linux
Process control commands in Unix are: bg - put suspended process into background fg - bring process into foreground jobs - list processes bg Command : bg is a process control command that resumes suspended process while keeping them running in the background. User can run a job in the background by adding a "&" symbol at the end of the command.
3 min read
Custom commands for linux terminal
Linux operating system allows users to create commands and execute them over the command line. To create a command in Linux, the first step is to create a bash script for the command. The second step is to make the command executable. Syntax : $ nano ~/.bashrc Here, bashrc means run the Bash file. Bash is located at /bin/bash . This file helps in c
2 min read
Fun Commands in Linux
cowsay First we install it using sudo apt-get install cowsay. We use other objects to use -l to list them and -f to use them. xcowsay First, we install it using sudo apt-get install xcowsay. Then here is the way to use it. THE MATRIX Use below command to install it sudo apt-get install cmatrix Once installed, use below command to print. cmatrix To
1 min read
How to run Linux Commands on Windows 10?
It is a dilemma when you want to switch from one operating system to another. This is a common case when you switch from Windows to Linux. Either you store your data and then uninstall Windows to install Linux and then transfer your data or you can have a dual boot system where you encounter an option as to which OS to choose in the beginning. Don'
2 min read
Interesting Funny Commands in Linux
This entire article is all about showing off cool commands executable in the Linux terminal. This article is aimed at being a one-stop destination for all cool or you can say interesting funny commands in Linux to play. 1. The Matrix Effect: We all can agree on one thing that the falling down text effect from "The Matrix" movie is one of the best s
5 min read
Deprecated Linux Networking Commands and Their Replacements
In this article, let us have a close look at some networking commands that are deprecated. That means they are not provided by default and replaced by other commands that serve the same purpose. But please note that these commands can still be executed by first downloading the net-tools package onto the machine. sudo apt-get install net-toolsThese
4 min read
Linux vs Windows Commands
Most of us think that Linux has terminal and we can use a command-line interface only in Linux but it is just a myth. There is a PowerShell and a command prompt in windows as well where we may execute the commands easily. But Windows and Linux have commands with the same name as well. .linux-vs-windows-table { border-collapse: collapse; width: 100%
2 min read
How to Build Your Own Commands in Linux?
Linux is one of the most widely used open-source operating systems which supports both GUI as well as CLI. It has been widely used all over the world since its first distribution launched on September 17, 1991, by Linus Torvalds. It is widely known for its command-line operations. We have been using several commands in Linux like date command, mkdi
6 min read
List out all the Shells Using Linux Commands
There are various methods to list all the shells which are installed in our Linux system. A Shell is a software program that acts as an interface between the user and the operating system(OS). It can also be thought of as a command interpreter that is used to execute another program. Method 1: Using cat command Example: cat /etc/shells Explanation:
1 min read
Most Useful Commands to Manage Apache Web Server in Linux
Prerequisite: How do Web Servers work? Apache is one of the most widely used free, open-source Web Server applications in the world, mostly used in Unix-like operating systems but can also be used in windows. As a developer or system administrator, it will be very helpful for you to know about the Apache webserver. It has many notable features amon
3 min read
Viewing Progress of Commands Using Pipe Viewer Tool in Linux
Pipe Viewer (pv) is the CLI tool that allows users to track the progress of the process and display them on the terminal by giving information such as total data transferred, the time elapsed, completed percentage, etc. To visualize the process progress it can be used normally via pipe operator b/w processes. Why do we require it? Some processes ha
3 min read
How to Monitor Linux Commands Executed by System Users in Real-time?
If you are a Linux system administrator then you would definitely want to monitor the interactive activity of all system users, like monitoring the Linux commands they execute in real-time. In this brief Linux system security article, we will be going to discuss how to monitor all Linux shell commands executed by system users in real-time. Let's se
1 min read
Ways to Re-run Last Executed Commands in Linux
It would be quite efficient to re-execute the last command. If the command was quite big to type in again, this would be quite a great trick to improve efficiency. So let us see what the commands are to run the last executed command again in the Linux terminal. The ways to run the last executed command are as follows: Ctrl + PUp Arrow key.bang-bang
3 min read
How to Use Linux Commands in Windows with Cygwin
Cygwin is a collection of tools that provide a Linux Operating System's terminal look, feel, and some of its basic functionality for users of Windows OS who want to have a go over the basic commands of Linux without worrying about installing a Linux OS. To use this tool, first of all, we need to download Cygwin setup depending on the version of Win
3 min read
7 Linux Commands For Managing Users
Linux is a fantastic platform that allows multi-user access options. Different users can access the same Linux OS for working simultaneously. A user account allows multiple people to access directories, terminals, the Internet, etc. There are three types of user accounts: User Account: This account is for general use with limited permissions.System
3 min read
Useful Commands For Filtering Text for Effective File Operations in Linux
In this article, let us learn about different commands used in Linux for filtering text to implement effective file operations on Linux Machines. What is a filter in Linux? In Linux Operating System, Filters act as a specialized program to get desired output from the client/user by taking the help of other files and pipes to perform a series of ope
7 min read
How to execute commands remotely using SSH in Linux?
Many times users need to work in remote systems. For which they have to log in to the remote server, execute certain commands and come out of that session. Is it possible to perform all these actions locally? Yes, it's possible using ssh client. In this article, we will see different ways of running remote commands locally using ssh. Pre-requisite
2 min read
How to Run Multiple Commands on Multiple Linux Servers
In this article, we'll learn how to run multiple commands on multiple Linux servers. It was a manual task completed by System Administrators. Let's say, they made some changes to a server and if they need to make the same changes to many servers they would need to log into each server and repeatedly make changes to each of them. But we can run mult
3 min read
List All Available Commands and Aliases in Linux
There might be sometimes a need to list all the commands and aliases supported by the current system. As we already know, an alias is a custom shortcut that references a command. It can be very useful to replace long commands with a small alternative command. While a command is a program that we can run in the terminal to produce some output or cha
3 min read
The “Argument List Too Long” Error in Linux Commands
There are times when we encounter directories that contain a large number of files, if we try to perform certain operations on those particular directories we may get the error Argument List Too Long. In this article, we will see the cause of this error and how to resolve this error. We have created a directory(temp) with a large number of files (
4 min read
YUM Commands for Linux Package Management
If you are a Linux user or system administrator, chances are you've come across YUM (Yellowdog Updater, Modified) at some point in your journey. YUM is a powerful package management tool that simplifies the process of installing, updating, and managing software on Red Hat-based Linux distributions like CentOS and Fedora. In this article, we will de
4 min read
Article Tags :