The basic command line commands can help you navigate your way through your system or device. These simple command-based prompts can help you reach the core parts of computers and help you find stuff and make major changes.
There are two ways of interacting with your system, one where you directly interact with the user interface, which is simple and user friendly, and the other is based on these text-based prompts, where you interact using commands.
These simple text based prompts can help you boost your productivity as a developer. Here, let us learn more about some of the basic command-line prompts, which you can start using at the beginning of your learning journey.
What is the Command Line?
The Basic command line commands are important when you want to interact directly with the computer or server using simple test-based commands instead of clicking or hovering through files and folders using the user interface on different devices like Windows, macOS, and more.
Using command lines can help you hold on to more control over your system and flexibility, especially for developers. When working on the backend, there are many times when you, as a developer, would need to run commands in a terminal (on macOS) and command line (on Windows), probably the same thing. Once you gain an idea of the basic command line commands, your interaction with the system becomes faster and effective.
Read More: Backend Technologies & Top 10 Backend Technologies You Must Know
Where to Provide Command Line Prompts in macOS?
You can easily open “Terminal” in macOS to start typing your command and interacting with your system.
The quickest way to find the terminal is using the search option or typing the shortcut “command + space” and then typing “terminal” to open the terminal window and start typing your command prompts.
What Do You Need to Start Learning Basic Command Prompts?
Although typing command based texts in a terminal or command window is not so a tedious task, being familiar with certain things might make the entire process a little easier.
- You need to have a basic familiarity with the computer OS and its fundamentals.
- Keep yourself familiar with the basics keyboard shortcuts to maintain your productivity in command based interaction with the system.
- Learn about the basic command line commands to get started with all major functions.
We prepared the top 20 frequently used basic command line prompts, which you can learn and start interacting with your system.
Read More: Understanding OS Fundamentals: Key Concepts of Operating Systems
Top 20 Basic Commands Level Prompts For Beginners
Check some frequently used basic command line commands which is used by developers.
Command Prompts | Uses |
cd | It changes the current working directory to the specified directory. |
pwd | The pwd command is used to print the current working directory path. |
cd .. | It moves one level up from the current directory. |
ls | This command line command displays all files and directories in the current directory. |
ls -a | It lists all files, including hidden ones, starting with a dot. |
ls -l | This is used to list all files with detailed information. |
ls -t | This command lists files sorted by modification time, newest first. |
cp | This is a command used to copy files or directories from a source to a target location. |
mv | It moves or renames files and directories. |
rm | It deletes files or directories. |
touch | The touch command is used to make an empty file with the specified name. |
mkdir | mkdir specifies a new directory in the specified path. |
> | It redirects command output to a file, overwriting it if it exists. |
>> | This command outputs to an existing file. |
grep | This command searches for a specific pattern inside a file. |
env | It displays the current environment variables. |
export | It sets or updates environment variables for the current session. |
PATH | It shows directories where the system looks for executable files. |
HOME | This command prompt is used to display the home directory of the current user. |
alias | The alias creates a shortcut for a command. |
uniq | uniq is used to duplicate consecutive lines from a file. |
sort | It arranges lines of text in alphabetical or numerical order. |
1. cd (Change Directory)
This command is used to change the directory where you are currently working. You only have to use the “cd” command along with the directory you want to move to.
Syntax
cd directory |
Example
![]() |
2. pwd
This command helps you print the current working directory
Syntax
pwd |
Example
![]() |
3. cd ..
This basic command line command with two dots is used to move one level up from the existing directory.
Syntax
cd .. |
Example
![]() |
Read More: Command Line for Beginners – How to Use the Terminal in an Effective way (2025)
4. ls (List of Directory command)
This simple yet very useful command can help you open a list of all files and directories existing in your current directory.
- ls -a: This command can open a list of all files, including all hidden ones, starting with a dot.
- ls -l: This lists all files in a directory along with their complete detailed information.
- ls -t: This command is used to display the modification time of all modified files first.
Syntax
ls |
Example
![]() |
5. cp (Copy Files)
This basic command prompt helps you copy any file or directory from one location to another. You only need to specify the path.
- cp [-R [-H | -L | -P]] [-fi | -n] [-aclpSsvXx] source_file target_file: Use this to copy file/folder to one destination
- cp [-R [-H | -L | -P]] [-fi | -n] [-aclpSsvXx] source_file … target_directory: Use this to copy one or more files into the targeted directory.
Syntax
cp “source destination” |
Example
![]() |
6. mv (Move Files)
This command is used to move or rename files and directories.
Syntax
mv |
Example
![]() |
7. rm (Remove Files)
This command is used to delete files inside a directory.
- Take care of space in your file name, you can wrap your filename in quotes or escape with the backslashes.
Syntax
rm “Filename” |
Example
![]() |
8. touch
You can use these basic command line commands to create a simple empty file.
Syntax
touch “filename” |
Example
![]() |
9. mkdir
This command is used to create a new directory in any of your existing path.
Syntax
mkdir new_folder |
Example
![]() |
10. > Redirection Operator
This operator is used to redirect a command output into a file which creates a new one or overwrites an existing one.
Syntax
command >> filename |
Example
![]() |
11. >>
This operator is used to append the output of a command to an existing file.
Syntax
command >> filename |
Example
![]() |
This operator adds a text, “This! Is the added text”, inside the file name “Good”
Read More: Command Pattern | C++ Design Patterns
12. |
These basic command line commands help to send the output of one command as input to another command.
Syntax
cat Good | grep “Hello” |
Example
![]() |
This command is used to search inside the content of the file named “Good” and search for the text “Hello” and print the line that contains any text.
13. grep
This command prompt helps you search for a specific pattern inside a file. We will hold on to the same example we used grep above.
Syntax
cat Good | grep “Hello” |
Example
![]() |
- The grep -i is a command that performs a case-insensitive search
- The grep -R command searches for a pattern inside a directly recursively.
- The grep -Rl is a command that performs a recursive search and lists only the names of the file that has a similar pattern.
14. env
This command can be used to show the current environment variable used.
Syntax
env |
Example
![]() |
- The env | grep variable can be used to filter and print the variables matching a specific pattern. Check the example above, where we have checked and implemented this command.
15. export
This variable is used to set an environment variable that can be accessed by other processes.
Syntax
export PATH = $PATH: /new/path |
16. PATH
This basic command prompt contains directories where files are stored in the system.
Syntax
echo $PATH |
Example
![]() |
17. HOME
This basic command line directory represents the home directory of the users.
Syntax
echo $HOME |
Example
![]() |
18. alias
This command is used to create shortcuts for commands that you can use in your system.
Syntax
alias name = ‘command’ |
Example
![]() |
19. uniq
This basic command is used to remove duplicate lines from a file name.
Syntax
unique “filename” |
Example
![]() |
There was no repetition in the file name “newfile1”, hence the output is as given in the image.
20. sort
This command is used to arrange lines of text in a serial alphabetical or numerical order.
Syntax
sort filename |
Example
![]() |
Upskill With PW Skills In Web Development
Develop your frontend design skills and learn about all techniques and tools related to frontend and backend in this Full Stack Development Course. Get in-depth learning and tools with the online interactive coursework. The complete course is covered by dedicated mentors guiding you throughout the course duration and even after it.
Strengthen your portfolio and gain an industry renowned certification after completing the course at pwskills.com
Command Line Commands Prompt FAQs
Q1. What are command-line prompts?
Ans: The Command line commands prompt is used to interact directly with the computer or operating system using text based commands instead of a graphical user interface.
Q2. What is the ls command used for?
Ans: The ls command in the command line prompts is used to open a list of all files and directories existing in your current directory.
Q3. Why use command line prompts?
Ans: Command line prompts can be used by developers or users to manage files, automate tasks, troubleshoot issues, and perform administrative-level functions on a system device.
Q4. What is the alias command?
Ans: The alias command can be used to create shortcuts for commands that you can use in your system.