Tutorial NO.
1
Basic Linux Terminal Commands
Basic Linux Terminal Commands
Linux Commands Functions
Displays information about files in the current
1. Is command in Linux
directory.
2. pwd command in
Displays the current working directory.
Linux
3. mkdir command in
Creates a directory.
Linux
4. cd command in Linux To navigate between different folders.
5. rmdir command in
Removes empty directories from the directory lists.
Linux
6. cp command in Linux Copy files from one directory to another.
7. mv command in Linux Rename and Replace the files
8. rm command in Linux Delete files
Basic Linux Terminal Commands
9. uname command in
Command to get basic information about the OS
Linux
10. locate command in
Find a file in the database.
Linux
11. touch command in
Create empty files
Linux
12. ln command in Linux Create shortcuts to other files
13. cat command in Linux Display file contents on terminal
14. clear command in
Clear terminal
Linux
15. ps command in Linux Display the processes in terminal
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.
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.
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
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.
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.
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.
Here we used ls to view the files and then used cp to copy the files
of [Link] to [Link] 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.
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.
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.
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
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.
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>
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.
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.
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.
15. ps command in Linux
ps command in Linux is used to check the active processes in the
terminal.