close
The Wayback Machine - https://web.archive.org/web/20240825191251/https://www.geeksforgeeks.org/25-basic-ubuntu-commands/
Open In App

25 basic Ubuntu Commands

Last Updated : 15 Mar, 2024
Comments
Improve
Suggest changes
Like Article
Like
Save
Share
Report
News Follow

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 descriptions, syntax, examples, and explanations.

1. ls – List Directory Contents

The ls command is used to list directory contents.

Syntax:

ls [options] [directory]


Example:

ls Desktop/

Listing content inside Desktop directory

Listing content inside Desktop directory

This command lists the contents of the Desktop directory.

2. cd – Change Directory

The cd command is used to change the current working directory.

Syntax:

cd [directory]


The cd command is used to change the current working directory.

Example:

cd Desktop/

changing directory

changing directory

This command changes the current directory to Desktop/. Here we have used pwd command to display the current directory.

3. pwd – Print Working Directory

The pwd command displays the current working directory.

Syntax:

pwd


Example:

pwd

displaying the current directory

displaying the current directory

This command prints the current working directory.

4. mkdir – Make Directory

The mkdir command is used to create a new directory.

Syntax:

mkdir [directory_name]


Example:

mkdir new_folder

creaking directory

creaking directory

This command creates a new directory named new_folder. Here we have used ls command to display the files in the current directory.

5. rm – Remove

The rm command is used to remove files or directories.

Syntax:

rm [options] [file/directory]


Example:

rm new_file

removing file

removing file

This command removes the file named new_file. Here we have used ls command to display the files in the current directory.

6. cp – Copy

The cp command is used to copy files or directories.

Syntax:

cp [options]  [destination]


Example:

cp file1.txt file2.txt


This command copies file1.txt to file2.txt.

7. mv – Move

The mv command is used to move files or directories.

Syntax:

mv [options]  [destination]


Example:

mv file1.txt /path/to/new/location


This command moves file1.txt to /path/to/new/location.

8. touch – Create Empty File

The touch command is used to create an empty file.

Syntax:

touch [file_name]


Example:

touch newfile.txt

creating text file

creating text file

This command creates an empty file named newfile.txt. Here we have used ls command to display the files in the current directory.

9. cat – Concatenate and Display

The cat command is used to display the contents of a file.

Syntax:

cat [file]


Example:

cat newfile.txt

displaying text inside text file

displaying text inside text file

This command displays the contents of newfile.txt.

10. nano – Text Editor

The nano command launches the Nano text editor.

Syntax:

nano [file_name]


Example:

nano newfile.txt

editing text file

editing text file

This command opens newfile.txt in the Nano text editor.

The grep command is used to search for patterns in files.

Syntax:

grep [options] [pattern] [file]

Example:

grep "pattern" file.txt
searching pattern inside the text file

searching pattern inside the text file

This command searches for the specified pattern in file.txt.

12. sudo – Superuser Do

The sudo command allows users to execute commands with superuser privileges.

Syntax:

sudo [command]


Example:

sudo apt-get update

updating package manager

updating package manager

This command updates the package lists using apt-get with superuser privileges.

13. apt-get – Package Manager

The apt-get command is used to manage software packages.

Syntax:

sudo apt-get [options] [command]


Example:

sudo apt-get install package_name


This command installs a package named package_name.

14. dpkg – Package Manager

The dpkg command is used to install, remove, and manage Debian packages.

Syntax:

sudo dpkg [options] [command]


Example:

sudo dpkg -i package.deb


This command installs a Debian package named package.deb.

15. wget – Download

The wget command is used to download files from the internet.

Syntax:

wget [URL]


Example:

wget http://example.com/file.zip

This command downloads a file named file.zip from the specified URL.

16. chmod – Change Mode

The chmod command is used to change file permissions.

Syntax:

chmod [options] [mode] [file]


Example:

chmod 755 file.sh


This command changes the permissions of file.sh to 755.

17. chown – Change Owner

The chown command is used to change file ownership.

Syntax:

chown [options] [owner:group] [file]


Example:

chown user:group file.txt


This command changes the owner and group of file.txt.

18. tar – Tape Archive

The tar command is used to create and extract tar archives.

Syntax:

tar [options] [archive_name.tar.gz] [files/directories]


Example:

tar -cvzf archive.tar.gz directory


This command creates a compressed tar archive named archive.tar.gz from the directory

19. uname – Print System Information

The uname command prints system information such as kernel version and architecture.

Syntax:

uname [options]


Example:

uname -a


This command displays all available system information.

20. date – Display Date and Time

The date command displays the current date and time.

Syntax:

date [options]


Example:

date
displaying date

displaying date

This command prints the current date and time.

21. shutdown – Shutdown or Restart System

The shutdown command is used to shut down or restart the system.

Syntax:

sudo shutdown [options]


Example:

sudo shutdown -h now


This command shuts down the system immediately.

22. ps – Process Status

The ps command displays information about active processes.

Syntax:

ps [options]


Example:

ps aux

list all running process

list all running process

This command lists all running processes.

23. top – Display System Activity

The top command displays real-time information about system activity.

Syntax:

top


Example:

top

displaying dynamic information

displaying dynamic information

This command displays dynamic information about system processes.

24. du – Disk Usage

The du command is used to estimate file and directory space usage.

Syntax:

du [options] [directory]


Example:

du -sh /path/to/directory


This command displays the disk usage of the specified directory.

25. df – Disk Free

The df command displays disk space usage for filesystems.

Syntax:

df [options]


Example:

df -h

display disk space

display disk space

This command displays disk space usage in a human-readable format.

Conclusion

These 25 basic Ubuntu commands provide a solid foundation for navigating and managing your Linux system effectively. As you continue to explore Ubuntu and Linux, you’ll discover more commands and techniques to streamline your workflow and enhance your productivity. Experiment with these commands in your terminal to become more proficient in using Ubuntu.



Similar Reads

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
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 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
25 Basic Linux Commands For Beginners
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 operat
13 min read
Setting up and Securing Ubuntu server with a Basic Firewall
VPS(Virtual Private Servers) are commonly used to host and serve many types of services. There are many providers that provide virtual servers. Many of these provide VPS's with their custom-built Linux OS which is lightweight compared to their desktop versions. These OS have built-in security but we can make them better. This article helps you to s
3 min read
Commands in Unix when things go wrong
Terminals and keyboards has no uniform behavioral pattern. There are some commands to wriggle out of some common traps. You must know which keys you need to press when things don't quite work as expected. 1. Backspacing doesn't work: Consider you misspelled command stty as ssty and when you press backspace to erase the command, an unexpected symbol
2 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
halt, poweroff and reboot Commands in Linux
Below are typical uses of halt, poweroff and reboot. halt : Instructs hardware to stop CPU functions. poweroff : Instructs the system to power down. reboot : Restarts or reboots the system. The above mentioned commands can only be run by super user as these involve the actions to stop the system hardware. If the user is not logged in as super user
2 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
Run commands as root with sudo
Introduction - Linux follows the very tough permission model. A root user can do anything but normal user has no permissions. To run any command, they need to ask for permissions from the superuser. The easy and common way to grant administrative privileges to non-root users is, a user can use su command and temporarily become the root but users mu
3 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
Interesting Commands on Mac Terminal
Terminal is one of the most important tools in MacOS be it any field. To get good knowledge about the terminal is important. It teaches you many things in an innovative way which is liked by most of the developers. It's a knowledge that only geeks and geniuses have. Here are some commands with the most impressive features. The commands used below m
2 min read
Chaining Commands in Linux
Chaining commands in Linux allows us to execute multiple commands at the same time and directly through the terminal. It's like short shell scripts that can be executed through the terminal directly. Linux command chaining is a technique of merging several commands such that each of them can execute in sequence depending on the operator that separa
7 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
Article Tags :