25 Basic Linux Commands for Beginners - GeeksforGeeks
25 Basic Linux Commands for Beginners - GeeksforGeeks
Shell Scripting Kali Linux Ubuntu Red Hat CentOS Docker in Linux Kubernetes in Linux Linux intervi
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?
We use cookies to ensure you have the best browsing experience on our website. By using
our site, you acknowledge that you have read and understood our Cookie Policy & Privacy Got It !
Policy
https://www.geeksforgeeks.org/basic-linux-commands/?ref=outind 1/37
3/2/24, 6:32 PM 25 Basic Linux Commands For Beginners - GeeksforGeeks
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.
Displays information
1 Is about files in the current
directory.
https://www.geeksforgeeks.org/basic-linux-commands/?ref=outind 2/37
3/2/24, 6:32 PM 25 Basic Linux Commands For Beginners - GeeksforGeeks
To navigate between
4 cd
different folders.
Removes empty
5 rmdir directories from the
directory lists.
8 rm Delete files
https://www.geeksforgeeks.org/basic-linux-commands/?ref=outind 3/37
3/2/24, 6:32 PM 25 Basic Linux Commands For Beginners - GeeksforGeeks
Create or update
20 whoami passwords for existing
users
View Calendar in
22 cal
terminal
https://www.geeksforgeeks.org/basic-linux-commands/?ref=outind 4/37
3/2/24, 6:32 PM 25 Basic Linux Commands For Beginners - GeeksforGeeks
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.
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.
We useCommand:
cookies to ensure you have the best browsing experience on our website. By using
our site, you acknowledge that you have read and understood our Cookie Policy & Privacy
Policy
https://www.geeksforgeeks.org/basic-linux-commands/?ref=outind 5/37
3/2/24, 6:32 PM 25 Basic Linux Commands For Beginners - GeeksforGeeks
Output:
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.
mkdir GeeksforGeeks
In case you want to create another directory inside the main directory
We useGeeksforGeeks
cookies to ensure youtohave
store projects,
the best browsingyou can on
experience use
ourthe following
website. By using command to do
our site,
so.you acknowledge
mkdir that you have read and understood our Cookie Policy & Privacy
GeeksforGeeks/projects
Policy
https://www.geeksforgeeks.org/basic-linux-commands/?ref=outind 6/37
3/2/24, 6:32 PM 25 Basic Linux Commands For Beginners - GeeksforGeeks
Command:
Output:
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
https://www.geeksforgeeks.org/basic-linux-commands/?ref=outind 7/37
3/2/24, 6:32 PM 25 Basic Linux Commands For Beginners - GeeksforGeeks
Command:
Output:
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
https://www.geeksforgeeks.org/basic-linux-commands/?ref=outind 8/37
3/2/24, 6:32 PM 25 Basic Linux Commands For Beginners - GeeksforGeeks
Output:
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
Command:
We use cookies to ensure you have the best browsing experience on our website. By using
our site, you acknowledge that you have read and understood our Cookie Policy & Privacy
Policy
https://www.geeksforgeeks.org/basic-linux-commands/?ref=outind 9/37
3/2/24, 6:32 PM 25 Basic Linux Commands For Beginners - GeeksforGeeks
Output:
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
Command:
We use cookies to ensure you have the best browsing experience on our website. By using
our site, you acknowledge that you have read and understood our Cookie Policy & Privacy
Policy
https://www.geeksforgeeks.org/basic-linux-commands/?ref=outind 10/37
3/2/24, 6:32 PM 25 Basic Linux Commands For Beginners - GeeksforGeeks
Output:
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
Command:
We use cookies to ensure you have the best browsing experience on our website. By using
our site, you acknowledge that you have read and understood our Cookie Policy & Privacy
Policy
https://www.geeksforgeeks.org/basic-linux-commands/?ref=outind 11/37
3/2/24, 6:32 PM 25 Basic Linux Commands For Beginners - GeeksforGeeks
Output:
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.
Command:
We use cookies to ensure you have the best browsing experience on our website. By using
our site, you acknowledge that you have read and understood our Cookie Policy & Privacy
Policy
https://www.geeksforgeeks.org/basic-linux-commands/?ref=outind 12/37
3/2/24, 6:32 PM 25 Basic Linux Commands For Beginners - GeeksforGeeks
Output:
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:
We use cookies to ensure you have the best browsing experience on our website. By using
our site, you acknowledge that you have read and understood our Cookie Policy & Privacy
Policy
https://www.geeksforgeeks.org/basic-linux-commands/?ref=outind 13/37
3/2/24, 6:32 PM 25 Basic Linux Commands For Beginners - GeeksforGeeks
Output:
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.
The touch command creates an empty file when put in the terminal in this
format as touch <file name>
Command:
We use cookies to ensure you have the best browsing experience on our website. By using
our site, you acknowledge that you have read and understood our Cookie Policy & Privacy
Policy
https://www.geeksforgeeks.org/basic-linux-commands/?ref=outind 14/37
3/2/24, 6:32 PM 25 Basic Linux Commands For Beginners - GeeksforGeeks
Output:
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.
Command:
We use cookies to ensure you have the best browsing experience on our website. By using
our site, you acknowledge that you have read and understood our Cookie Policy & Privacy
Policy
https://www.geeksforgeeks.org/basic-linux-commands/?ref=outind 15/37
3/2/24, 6:32 PM 25 Basic Linux Commands For Beginners - GeeksforGeeks
Output:
Here we used mkdir to create two directories and then we used ln with an -
s to create a soft link in it.
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:
We use cookies to ensure you have the best browsing experience on our website. By using
our site, you acknowledge that you have read and understood our Cookie Policy & Privacy
Policy
https://www.geeksforgeeks.org/basic-linux-commands/?ref=outind 16/37
3/2/24, 6:32 PM 25 Basic Linux Commands For Beginners - GeeksforGeeks
Output:
We use cookies to ensure you have the best browsing experience on our website. By using
our site, you acknowledge that you have read and understood our Cookie Policy & Privacy
Policy
https://www.geeksforgeeks.org/basic-linux-commands/?ref=outind 17/37
3/2/24, 6:32 PM 25 Basic Linux Commands For Beginners - GeeksforGeeks
Output:
Command:
We use cookies to ensure you have the best browsing experience on our website. By using
our site, you acknowledge that you have read and understood our Cookie Policy & Privacy
Policy
https://www.geeksforgeeks.org/basic-linux-commands/?ref=outind 18/37
3/2/24, 6:32 PM 25 Basic Linux Commands For Beginners - GeeksforGeeks
Output:
The man command displays a user manual for any commands or utilities
available in the Terminal, including their name, description, and options.
For example, suppose you want to look up the manual for the ls command:
man ls
Command:
We use cookies to ensure you have the best browsing experience on our website. By using
Output:
our site, you acknowledge that you have read and understood our Cookie Policy & Privacy
Policy
https://www.geeksforgeeks.org/basic-linux-commands/?ref=outind 19/37
3/2/24, 6:32 PM 25 Basic Linux Commands For Beginners - GeeksforGeeks
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:
Command:
Output:
We use cookies to ensure you have the best browsing experience on our website. By using
our site, you acknowledge that you have read and understood our Cookie Policy & Privacy
Policy
https://www.geeksforgeeks.org/basic-linux-commands/?ref=outind 20/37
3/2/24, 6:32 PM 25 Basic Linux Commands For Beginners - GeeksforGeeks
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.
Command:
Output:
We use cookies to ensure you have the best browsing experience on our website. By using
our site, you acknowledge that you have read and understood our Cookie Policy & Privacy
Policy
https://www.geeksforgeeks.org/basic-linux-commands/?ref=outind 21/37
3/2/24, 6:32 PM 25 Basic Linux Commands For Beginners - GeeksforGeeks
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.
Command:
wget http://sample.com/sample-menu.php
Output:
We use cookies to ensure you have the best browsing experience on our website. By using
our site, you acknowledge that you have read and understood our Cookie Policy & Privacy
Policy
https://www.geeksforgeeks.org/basic-linux-commands/?ref=outind 22/37
3/2/24, 6:32 PM 25 Basic Linux Commands For Beginners - GeeksforGeeks
Command:
Output:
We use cookies to ensure you have the best browsing experience on our website. By using
our site, you acknowledge that you have read and understood our Cookie Policy & Privacy
Policy
https://www.geeksforgeeks.org/basic-linux-commands/?ref=outind 23/37
3/2/24, 6:32 PM 25 Basic Linux Commands For Beginners - GeeksforGeeks
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)
We use cookies to ensure you have the best browsing experience on our website. By using
our site, you acknowledge that you have read and understood our Cookie Policy & Privacy
Policy
https://www.geeksforgeeks.org/basic-linux-commands/?ref=outind 24/37
3/2/24, 6:32 PM 25 Basic Linux Commands For Beginners - GeeksforGeeks
Command:
Output:
We use cookies to ensure you have the best browsing experience on our website. By using
our site, you acknowledge that you have read and understood our Cookie Policy & Privacy
Policy
https://www.geeksforgeeks.org/basic-linux-commands/?ref=outind 25/37
3/2/24, 6:32 PM 25 Basic Linux Commands For Beginners - GeeksforGeeks
Here first we checked the file content using the cat command and then we
sorted it alphabetically using the sort command.
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:
Output:
whereis command in Linux is generally used to see the exact location of any
We use cookies to ensure you have the best browsing experience on our website. By using
command
our site, typed
you acknowledge thatafter this.
you have readLet’s see how
and understood ourthis performs.
Cookie Policy & Privacy
Policy
https://www.geeksforgeeks.org/basic-linux-commands/?ref=outind 26/37
3/2/24, 6:32 PM 25 Basic Linux Commands For Beginners - GeeksforGeeks
Command:
Output:
Command:
We use cookies to ensure you have the best browsing experience on our website. By using
our site, you acknowledge that you have read and understood our Cookie Policy & Privacy
Policy
https://www.geeksforgeeks.org/basic-linux-commands/?ref=outind 27/37
3/2/24, 6:32 PM 25 Basic Linux Commands For Beginners - GeeksforGeeks
Output:
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.
We useLet’s see
cookies one example
to ensure you have theof
bestthese options
browsing experience on our website. By using
our site, you acknowledge that you have read and understood our Cookie Policy & Privacy
Command: Policy
https://www.geeksforgeeks.org/basic-linux-commands/?ref=outind 28/37
3/2/24, 6:32 PM 25 Basic Linux Commands For Beginners - GeeksforGeeks
Output:
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.
Conclusion
We hope that this list of all Linux commands will assist you in getting
started as a beginner. There are more such commands in Linux and these are
only a few of them; you’ll discover many more as time goes on, but this is a
good place to start. The best way to learn Linux is to experiment with these
essential commands.
We use cookies
Q1. What to ensure
areyou have
the the best
most browsing
basic experience
Linux on our website.
Commands By usingfor beginners?
to learn
our site, you acknowledge that you have read and understood our Cookie Policy & Privacy
Policy
https://www.geeksforgeeks.org/basic-linux-commands/?ref=outind 29/37
3/2/24, 6:32 PM 25 Basic Linux Commands For Beginners - GeeksforGeeks
Answer:
1 Displays information
Is about files in the
current directory.
4 To navigate between
cd
different folders.
5 Removes empty
rmdir directories from the
directory lists.
8 rm Delete files
We use cookies to ensure you have the best browsing experience on our website. By using
our site, you acknowledge that you have read and understood our Cookie Policy & Privacy
Policy
https://www.geeksforgeeks.org/basic-linux-commands/?ref=outind 30/37
3/2/24, 6:32 PM 25 Basic Linux Commands For Beginners - GeeksforGeeks
Answer:
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.
Answer:
Q4. How can I edit a file in Linux from the command line?
Answer:
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’
We use cookies to ensure you have the best browsing experience on our website. By using
our site, you acknowledge that you have read and understood our Cookie Policy & Privacy
Policy
https://www.geeksforgeeks.org/basic-linux-commands/?ref=outind 31/37
3/2/24, 6:32 PM 25 Basic Linux Commands For Beginners - GeeksforGeeks
Answer:
And why go anywhere else when our DSA to Development: Coding Guide
helps you do this in a single program! Apply now to our DSA to
Development Program and our counsellors will connect with you for further
guidance & support.
Previous Next
10 Best Linux PDF Editors in 2023 20 Best Artificial Intelligence Movies You
Must Watch (2023)
Share
We use cookies your you
to ensure thoughts in the
have the best experience on our website. By using Add Your Comment
comments
browsing
our site, you acknowledge that you have read and understood our Cookie Policy & Privacy
Policy
https://www.geeksforgeeks.org/basic-linux-commands/?ref=outind 32/37
3/2/24, 6:32 PM 25 Basic Linux Commands For Beginners - GeeksforGeeks
Similar Reads
Basic CentOS Linux Commands in linux Basic Shell Commands in Linux
halt, poweroff and reboot Commands Custom commands for linux terminal
in Linux
R ranunh1mh
Additional Information
We use cookies to ensure you have the best browsing experience on our website. By using
our site, you acknowledge that you haveA-143,
read and9th Floor, Sovereign
understood Corporate
our Cookie Policy & Privacy
Tower,
Policy Sector-136, Noida, Uttar Pradesh -
https://www.geeksforgeeks.org/basic-linux-commands/?ref=outind 33/37
3/2/24, 6:32 PM 25 Basic Linux Commands For Beginners - GeeksforGeeks
201305
Company Explore
About Us Job-A-Thon Hiring Challenge
Legal Hack-A-Thon
Careers GfG Weekly Contest
In Media Offline Classes (Delhi/NCR)
Contact Us DSA in JAVA/C++
Advertise with us Master System Design
GFG Corporate Solution Master CP
Placement Training Program GeeksforGeeks Videos
Geeks Community
Languages DSA
Python Data Structures
Java Algorithms
C++ DSA for Beginners
PHP Basic DSA Problems
GoLang DSA Roadmap
SQL Top 100 DSA Interview Problems
R Language DSA Roadmap by Sandeep Jain
Android Tutorial All Cheat Sheets
Tutorials Archive
https://www.geeksforgeeks.org/basic-linux-commands/?ref=outind 34/37
3/2/24, 6:32 PM 25 Basic Linux Commands For Beginners - GeeksforGeeks
https://www.geeksforgeeks.org/basic-linux-commands/?ref=outind 35/37
3/2/24, 6:32 PM 25 Basic Linux Commands For Beginners - GeeksforGeeks
https://www.geeksforgeeks.org/basic-linux-commands/?ref=outind 36/37
3/2/24, 6:32 PM 25 Basic Linux Commands For Beginners - GeeksforGeeks
We use cookies to ensure you have the best browsing experience on our website. By using
our site, you acknowledge that you have read and understood our Cookie Policy & Privacy
Policy
https://www.geeksforgeeks.org/basic-linux-commands/?ref=outind 37/37